@excalidraw/excalidraw 0.18.0-a5d6939 → 0.18.0-a8acc82

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 (184) hide show
  1. package/dist/dev/chunk-6MX365WZ.js +5666 -0
  2. package/dist/dev/chunk-6MX365WZ.js.map +7 -0
  3. package/dist/dev/chunk-CP5DND7P.js +7 -0
  4. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  5. package/dist/dev/{chunk-X3RYHLJU.js → chunk-QF5FRM6O.js} +15 -5
  6. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  7. package/dist/dev/data/{image-JN3Y4CVN.js → image-GQCFJKGM.js} +3 -3
  8. package/dist/dev/index.css +230 -23
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +10262 -10068
  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-R2M7VUMD.js +4 -0
  18. package/dist/prod/data/image-JWK7QZ22.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 +40 -7
  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 +18 -4
  30. package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +16 -15
  31. package/dist/types/element/src/align.d.ts +4 -3
  32. package/dist/types/element/src/binding.d.ts +25 -14
  33. package/dist/types/element/src/bounds.d.ts +14 -6
  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} +77 -40
  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/elbowArrow.d.ts +1 -1
  41. package/dist/types/element/src/flowchart.d.ts +3 -2
  42. package/dist/types/element/src/fractionalIndex.d.ts +9 -3
  43. package/dist/types/element/src/frame.d.ts +4 -3
  44. package/dist/types/element/src/groups.d.ts +1 -0
  45. package/dist/types/element/src/index.d.ts +44 -2
  46. package/dist/types/element/src/linearElementEditor.d.ts +23 -36
  47. package/dist/types/element/src/mutateElement.d.ts +11 -3
  48. package/dist/types/element/src/newElement.d.ts +4 -3
  49. package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
  50. package/dist/types/element/src/renderElement.d.ts +4 -1
  51. package/dist/types/element/src/resizeElements.d.ts +5 -4
  52. package/dist/types/element/src/selection.d.ts +0 -5
  53. package/dist/types/element/src/shape.d.ts +42 -0
  54. package/dist/types/element/src/sizeHelpers.d.ts +2 -2
  55. package/dist/types/element/src/store.d.ts +237 -0
  56. package/dist/types/element/src/textElement.d.ts +4 -3
  57. package/dist/types/element/src/typeChecks.d.ts +19 -1
  58. package/dist/types/element/src/types.d.ts +15 -2
  59. package/dist/types/element/src/utils.d.ts +16 -6
  60. package/dist/types/element/src/zindex.d.ts +1 -1
  61. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +45 -54
  62. package/dist/types/excalidraw/actions/actionBoundText.d.ts +30 -36
  63. package/dist/types/excalidraw/actions/actionCanvas.d.ts +204 -242
  64. package/dist/types/excalidraw/actions/actionClipboard.d.ts +90 -106
  65. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +15 -18
  66. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +45 -53
  67. package/dist/types/excalidraw/actions/actionElementLink.d.ts +14 -17
  68. package/dist/types/excalidraw/actions/actionElementLock.d.ts +45 -52
  69. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +15 -18
  70. package/dist/types/excalidraw/actions/actionExport.d.ts +145 -172
  71. package/dist/types/excalidraw/actions/actionFinalize.d.ts +77 -42
  72. package/dist/types/excalidraw/actions/actionFrame.d.ts +107 -119
  73. package/dist/types/excalidraw/actions/actionGroup.d.ts +30 -36
  74. package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
  75. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +541 -20
  76. package/dist/types/excalidraw/actions/actionLink.d.ts +14 -17
  77. package/dist/types/excalidraw/actions/actionMenu.d.ts +42 -51
  78. package/dist/types/excalidraw/actions/actionNavigate.d.ts +29 -35
  79. package/dist/types/excalidraw/actions/actionProperties.d.ts +246 -274
  80. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +15 -18
  81. package/dist/types/excalidraw/actions/actionStyles.d.ts +15 -18
  82. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +15 -18
  83. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +15 -18
  84. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +14 -190
  85. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  86. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +15 -18
  87. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +15 -18
  88. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +15 -18
  89. package/dist/types/excalidraw/actions/index.d.ts +1 -1
  90. package/dist/types/excalidraw/actions/types.d.ts +4 -3
  91. package/dist/types/excalidraw/appState.d.ts +20 -10
  92. package/dist/types/excalidraw/clipboard.d.ts +64 -1
  93. package/dist/types/excalidraw/components/Actions.d.ts +8 -5
  94. package/dist/types/excalidraw/components/App.d.ts +30 -30
  95. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  96. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  97. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +7 -2
  98. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  99. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  100. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  101. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  102. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  103. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  104. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  105. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  106. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
  107. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  108. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
  109. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
  110. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
  111. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  112. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  113. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  114. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  116. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  117. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
  118. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  119. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  120. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  121. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  122. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  123. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
  124. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
  125. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  126. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  127. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  128. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  129. package/dist/types/excalidraw/components/icons.d.ts +9 -0
  130. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  131. package/dist/types/excalidraw/data/blob.d.ts +3 -7
  132. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  133. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  134. package/dist/types/excalidraw/data/transform.d.ts +1 -1
  135. package/dist/types/excalidraw/data/types.d.ts +4 -1
  136. package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
  137. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  138. package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
  139. package/dist/types/excalidraw/history.d.ts +30 -22
  140. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  141. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
  142. package/dist/types/excalidraw/index.d.ts +11 -10
  143. package/dist/types/excalidraw/lasso/index.d.ts +1 -0
  144. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  145. package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
  146. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  147. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
  148. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  149. package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
  150. package/dist/types/excalidraw/scene/types.d.ts +2 -0
  151. package/dist/types/excalidraw/snapping.d.ts +2 -2
  152. package/dist/types/excalidraw/types.d.ts +36 -15
  153. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
  154. package/dist/types/math/src/angle.d.ts +2 -0
  155. package/dist/types/math/src/constants.d.ts +3 -0
  156. package/dist/types/math/src/curve.d.ts +34 -0
  157. package/dist/types/math/src/index.d.ts +1 -0
  158. package/dist/types/math/src/point.d.ts +1 -1
  159. package/dist/types/math/src/rectangle.d.ts +2 -0
  160. package/dist/types/math/src/segment.d.ts +1 -0
  161. package/dist/types/math/src/vector.d.ts +8 -2
  162. package/dist/types/utils/src/bbox.d.ts +1 -1
  163. package/dist/types/utils/src/index.d.ts +1 -1
  164. package/dist/types/utils/src/withinBounds.d.ts +1 -1
  165. package/history.ts +146 -109
  166. package/package.json +13 -10
  167. package/dist/dev/chunk-GBJ7S76A.js +0 -18599
  168. package/dist/dev/chunk-GBJ7S76A.js.map +0 -7
  169. package/dist/dev/chunk-GIMGG4AT.js +0 -7
  170. package/dist/dev/chunk-GIMGG4AT.js.map +0 -7
  171. package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
  172. package/dist/prod/chunk-GKI4RZ6C.js +0 -7
  173. package/dist/prod/chunk-IUH5AXLB.js +0 -12
  174. package/dist/prod/chunk-TVF64BAY.js +0 -33
  175. package/dist/prod/data/image-CZ2OEVDB.js +0 -1
  176. package/dist/types/element/src/Shape.d.ts +0 -17
  177. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  178. package/dist/types/element/src/shapes.d.ts +0 -23
  179. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  180. package/dist/types/excalidraw/store.d.ts +0 -129
  181. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  182. package/dist/types/utils/src/collision.d.ts +0 -8
  183. /package/dist/dev/data/{image-JN3Y4CVN.js.map → image-GQCFJKGM.js.map} +0 -0
  184. /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 Be,$d as cn,$e as Mb,$f as Xi,$g as d0,A as Kf,Aa as gp,Ab as ut,Ac as qs,Ad as ob,Ae as V5,Af as j,Ag as ai,Ah as Il,B as ap,Ba as Qt,Bb as Ip,Bc as Lr,Bd as Hi,Be as Y5,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 bb,Cf as Hb,Cg as n0,Ch as w0,D as Qa,Da as eo,Db as v1,Dc as Wo,Dd as ul,De as xb,Df as Ub,Dg as li,Dh as T0,E as lp,Ea as Us,Eb as Sp,Ec as Js,Ed as rc,Ee as cc,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 zp,Ff as El,Fg as i0,Fh as I0,G as nr,Ga as Sr,Gb as ir,Gc as Ar,Gd as ge,Ge as Eb,Gf as mn,Gg as mr,H as Un,Ha as At,Hb as Yn,Hc as he,Hd as _t,He as Mo,Hf as yl,Hg as no,I as el,Ia as Gs,Ib as qe,Ic as Ft,Id as nc,Ie as yb,If as Up,Ig as Xo,J as Go,Ja as it,Jb as Wn,Jc as $n,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 Yi,Kf as Vp,Kg as a0,L as de,La as m1,Lb as Yo,Lc as Z,Ld as ib,Le as wb,Lf as Yp,Lg as qp,M as Vo,Ma as il,Mb as T1,Mc as O1,Md as ab,Me as oi,Mf as Zi,Mg as un,N as Ps,Na as to,Nb as C1,Nc as ec,Nd as Ui,Ne as Tb,Nf as Wp,Ng as Qi,O as Ir,Oa as Et,Ob as Kn,Oc as ie,Od as Gi,Oe as Wi,Of as Gb,Og as Sc,P as qr,Pa as p1,Pb as He,Pc as Lp,Pd as lb,Pe as dc,Pf as ni,Pg as Jp,Q as Rs,Qa as u1,Qb as R,Qc as ce,Qd as Ap,Qe as Cb,Qf as Vb,Qg as wl,R as sp,Ra as h1,Rb as Ye,Rc as ke,Rd as sb,Re as mc,Rf as Yb,Rg as kc,S as Jr,Sa as kr,Sb as zt,Sc as te,Sd as Qn,Se as lr,Sf as Wb,Sg as Qp,T as Ns,Ta as g1,Tb as cl,Tc as B1,Td as cb,Te as Fp,Tf as Kb,Tg as eu,U as Xf,Ua as pe,Ub as rn,Uc as _r,Ud as db,Ue as Ib,Uf as W5,Ug as l0,V as tl,Va as T,Vb as Xs,Vc as z1,Vd as ic,Ve as pc,Vf as pn,Vg as s0,W as $f,Wa as Vs,Wb as kp,Wc as jn,Wd as ei,We as uc,Wf as Ke,Wg as c0,X as jf,Xa as Gn,Xb as Mr,Xc as Dr,Xd as ac,Xe as Sb,Xf as Ec,Xg as Mc,Y as cp,Ya as fp,Yb as Zn,Yc as F1,Yd as hl,Ye as kb,Yf as Zb,Yg as Tl,Z as ol,Za as Ai,Zb as I1,Zc as qn,Zd as Ko,Ze as Hp,Zf as ye,Zg as Lc,_ as ue,_a as Ys,_b as S1,_c as mt,_d as mb,_e as ze,_f as yc,_g as Ac,a as Ss,aa as Os,ab as So,ac as M1,ad as Bi,ae as at,af as J,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 hc,bg as Kp,bh as _c,c as Fn,ca as Jf,cb as bp,cc as ee,cd as U1,ce as Dp,cf as Me,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 gc,dg as vc,dh as p0,e as Of,ea as e1,eb as _i,ec as ar,ed as zi,ee as lc,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 ub,ff as ht,fg as Zp,fh as K5,g as Io,ga as o1,gb as xp,gc as dt,gd as Y1,ge as hb,gf as fc,gg as $b,gh as ta,h as ks,ha as Li,hb as Ws,hc as Ue,hd as W1,he as gl,hf as Ab,hg as $i,hh as Cl,i as Ms,ia as dp,ib as Ep,ic as $s,id as K1,ie as fl,if as Zo,ig as vl,j as Ls,ja as mp,jb as yp,jc as Ri,jd as Z1,je as gb,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 sc,kf as Db,kg as jb,l as Ff,la as n1,lb as vp,lc as nn,ld as $1,le as B,lf as Ki,lg as qb,lh as h0,m as Hf,ma as Bs,mb as M,mc as dl,md as ml,me as oe,mf as Fe,mg as cr,mh as g0,n as Uf,na as zs,nb as se,nc as Je,nd as j1,ne as bl,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 ti,of as Rb,og as wc,oh as f0,p as As,pa as i1,pb as Vn,pc as Xn,pd as pl,pe as xl,pf as Nb,pg as Xp,ph as Pc,q as Gf,qa as a1,qb as Ks,qc as ln,qd as J1,qe as Vi,qf as ri,qg as ii,qh as ou,r as Cr,ra as l1,rb as Tp,rc as P1,rd as Q1,re as Pp,rf as Ob,rg as Jb,rh as Rc,s as Vf,sa as s1,sb as Zs,sc as js,sd as Ht,se as Rp,sf as Bb,sg as qi,sh as b0,t as _s,ta as Fs,tb as x1,tc as oo,td as tc,te as fb,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 U5,uf as zb,ug as e0,uh as Nr,v as qa,va as c1,vb as uo,vc as We,vd as eb,ve as Np,vf as Fb,vg as t0,vh as x0,w as Ja,wa as up,wb as ll,wc as R1,wd as Jn,we as Op,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 Ee,xf as Ut,xg as Tc,xh as E0,y as Hn,ya as d1,yb as y1,yc as sn,yd as oc,ye as Bp,yf as Pr,yg as Cc,yh as y0,z as Ds,za as Hs,zb as Cp,zc as Mp,zd as H5,ze as G5,zf as dn,zg as Ic,zh as v0}from"./chunk-TVF64BAY.js";import{a as k}from"./chunk-GKI4RZ6C.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 I}from"./chunk-SRAX5OIU.js";import hA,{useEffect as gA}from"react";import y5 from"clsx";import G8 from"lodash.throttle";import Tr,{useContext as Bn}from"react";import{flushSync as Nn}from"react-dom";import V8 from"roughjs/bin/rough";import{nanoid as Y8}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)=>{let n=io(t);return dt()&&j5(n,t.id),n.id=ro(),n.updated=L1(),r&&(n.seed=Lr(),bl(n)),n.groupIds=zb(n.groupIds,e,i=>(o.has(i)||o.set(i,ro()),o.get(i))),n},si=e=>{let{elements:o}=e,t="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=new Map,n=new Map,i=[],a=[],l=new Map,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=qs(x).reduce((y,v)=>{if(r.has(v.id))return y;r.set(v.id,!0);let C=$5(t.editingGroupId,n,v,e.randomizeSeed);return r.set(C.id,!0),c.set(C.id,C),l.set(v.id,C.id),s.set(C.id,v),a.push(v),i.push(C),y.push(C),y},[]);return Array.isArray(x)?w:w[0]||null},g=(x,E)=>{if(E){if(x>p.length-1){p.push(...qs(E));return}p.splice(x+1,0,...qs(E))}},b=new Set(o.filter(x=>d.has(x.id)&&ie(x)).map(x=>x.id));for(let x of o){if(r.has(x.id)||!d.has(x.id))continue;let E=Ab(t,x);if(E){let w=Fe(o,E).flatMap(v=>ie(v)?[...Mo(o,v.id),v]:[v]),y=Mr(p,v=>v.groupIds?.includes(E));g(y,u(w));continue}if(!(x.frameId&&b.has(x.frameId))){if(ie(x)){let w=x.id,y=Mo(o,w),v=Mr(p,C=>C.frameId===w||C.id===w);g(v,u([...y,x]));continue}if(mt(x)){let w=ge(x,m),y=Mr(p,v=>v.id===x.id||"containerId"in v&&v.containerId===x.id);w?g(y,u([x,w])):g(y,u(x));continue}if(Be(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))}}if(pb(i,l,c),bb(p,a,l),e.overrides)for(let x of i){let E=s.get(x.id);E&&Object.assign(x,e.overrides({duplicateElement:x,origElement:E,origIdToDuplicateId:l}))}return{duplicatedElements:i,duplicateElementsMap:c,elementsWithDuplicates:p,origIdToDuplicateId:l}},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},io=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]=se(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||_s)),ci=e=>Oc(e)?L0:{},Sl=([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),C={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||(C.n=Or(e+E/2-u/2,o-y-x+v,u,g,n,i,a)),c.s||(C.s=Or(e+E/2-u/2,r+y-v,u,g,n,i,a))),Math.abs(w)>S&&(c.w||(C.w=Or(e-y-b+v,o+w/2-g/2,u,g,n,i,a)),c.e||(C.e=Or(t+y-v,o+w/2-g/2,u,g,n,i,a))),C},Bc=(e,o,t,r="mouse",n=L0)=>{if(e.locked||te(e))return{};if(e.type==="freedraw"||ce(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 ie(e)&&(n={...n,rotation:!0});let i=ce(e)?Jr+8:he(e)?0:Jr;return Sl(Ke(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:ce(t)?t.points.length>2:!0};var oa=100,di=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(jn(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=>ml(i.heading,$1)).map(i=>i.relative);case"down":return n.filter(i=>ml(i.heading,Z1)).map(i=>i.relative);case"right":return n.filter(i=>ml(i.heading,K1)).map(i=>i.relative);case"left":return n.filter(i=>ml(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=di+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:(di+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,di+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(qn(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=di+e.width;r==="left"&&(u*=-1),l=e.x+u;let g=(oa+e.height)*a;s=p+g}else{let d=di*(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=(di+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(qn(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(){I(this,"isExploring",!1);I(this,"sameLevelNodes",[]);I(this,"sameLevelIndex",0);I(this,"direction",null);I(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(o,t,r){if(!jn(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(){I(this,"isCreatingChart",!1);I(this,"numberOfNodes",0);I(this,"direction","right");I(this,"pendingNodes",null)}createNodes(o,t,r,n){if(n!==this.direction){let{nextNode:i,bindingArrow:a}=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=>xb([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});mi(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]=Ke(e,o),m=(a+s)/2,d=(l+c)/2,p;ie(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)=>ce(e)||Lp(e)?{points:Cp(0,o,Cp(1,t,e.points,r),r)}:{},du=(e,o,t)=>{let r=e.width;if(Be(e)){let a=_t(e,o);a&&(r=Gi(a,e))}let i=e.fontSize*(t/r);return i<Ps?null:{size:i}},oT=(e,o,t,r,n,i,a)=>{let[l,s,c,m,d,p]=Ke(o,t),[u,g]=se(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 C=[l,s],S=[c,m],_=[d,p],L=M(l,s);if(["n","w","nw"].includes(r)&&(L=M(S[0]-Math.abs(w),S[1]-Math.abs(y))),r==="ne"){let F=[C[0],S[1]];L=M(F[0],F[1]-Math.abs(y))}if(r==="sw"){let F=[S[0],C[1]];L=M(F[0]-Math.abs(w),F[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=se(L,M(d,p),N),U=M(L[0]+Math.abs(w)/2,L[1]+Math.abs(y)/2),W=se(U,M(d,p),N);L=se(P,W,-N);let[V,q]=L;B(o,{fontSize:v.size,width:w,height:y,x:V,y:q})}if(r==="e"||r==="w"){let w=e.get(o.id),[y,v,C,S]=Xi(w,w.width,w.height,!0),_=M(y,v),L=M(C,S),N=wp(_,L),P=se(M(i,a),N,-w.angle),[U,,W]=Xi(o,o.width,o.height,!0),V=W-U,q=L[0]-_[0],F=Fi(qe({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight),z=q/V;r.includes("e")&&(z=(P[0]-_[0])/V),r.includes("w")&&(z=(L[0]-P[0])/V);let G=o.width*z<F?F:o.width*z,ne=Hi(o.originalText,qe(o),Math.abs(G)),X=Ht(ne,qe(o),o.lineHeight),le=X.height,[be,Te,ot,jt]=Xi(w,G,le,!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=se(qt,N,rr),Jt=M(qt[0]+Math.abs(Ho)/2,qt[1]+Math.abs(or)/2),$r=se(Jt,N,rr);qt=se(Xr,$r,-rr);let po={width:Math.abs(G),height:Math.abs(X.height),x:qt[0],y:qt[1],text:ne,autoResize:!1};B(o,po)}},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(!ie(m)){let[d,p,u,g]=Ke(m,t),b=(d+u)/2,x=(p+g)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=se(M(b,x),M(l,s),c+E-m.angle);te(m)?B(m,{points:gb(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?Ke(o[0],t):ye(o),c=(i+l)/2,m=(a+s)/2,d=o.length===1?o[0].angle:0;switch([r,n]=se(M(r,n),M(c,m),-d),e){case"n":return se(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return se(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return se(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return se(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return se(M(r-i,n-a),M(0,0),d);case"ne":return se(M(r-l,n-a),M(0,0),d);case"sw":return se(M(r-i,n-s),M(0,0),d);case"se":return se(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)}}},mi=(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(ce(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(ce(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<Ps)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}),ul(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=se(M(i,a),b,-o.angle),[E,w,y,v]=Xi(e,e.width,e.height,!0),C=y-E,S=v-w,_=g[0]-u[0],L=g[1]-u[1],N=_/C,P=L/S;n.includes("e")&&(N=(x[0]-u[0])/C),n.includes("s")&&(P=(x[1]-u[1])/S),n.includes("w")&&(N=(g[0]-x[0])/C),n.includes("n")&&(P=(g[1]-x[1])/S);let U=e.width*N,W=e.height*P;if(s&&(U=2*U-o.width,W=2*W-o.height),l){let V=Math.abs(U)/o.width,q=Math.abs(W)/o.height;if(n.length===1&&(W*=V,U*=q),n.length===2){let F=Math.max(V,q);U=o.width*F*Math.sign(U),W=o.height*F*Math.sign(W)}}return{nextWidth:U,nextHeight:W}},lT=(e,o,t,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(V=>o.get(V.id)),c=s.reduce((V,q)=>{if(!ce(q))return V;let F=ko(q);if(!F)return V;let z=o.get(F)??null;return Be(z)?[...V,{...z,...j.getBoundTextElementPosition(q,z,t)}]:V},[]),m=Dt(s.map(V=>V).concat(c)),{minX:d,minY:p,maxX:u,maxY:g,midX:b,midY:x}=m,E=u-d,w=g-p,y={ne:[d,g],se:[d,p],sw:[u,p],nw:[u,g],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,g],s:[d+E/2,p]},[v,C]=l?[b,x]:y[r],S=l?2:1,_=Math.max(Math.abs(n-v)/E||0,Math.abs(i-C)/w||0)*S,L=r.includes("e")||r.includes("w")?Math.abs(n-v)*S:E,N=r.includes("n")||r.includes("s")?Math.abs(i-C)*S:w;a&&(L=E*_*Math.sign(n-v),N=w*_*Math.sign(i-C));let P={ne:[n<v,i>C],se:[n<v,i<C],sw:[n>v,i<C],nw:[n>v,i>C],e:[n<v,!1],w:[n>v,!1],n:[!1,i>C],s:[!1,i<C]},[U,W]=P[r].map(V=>V);return{originalBoundingBox:m,nextWidth:L,nextHeight:N,flipByX:U,flipByY:W}},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(!ce(L))return _;let N=ko(L);if(!N)return _;let P=n.get(N)??null;return Be(P)?[..._,{...P,...j.getBoundTextElementPosition(L,P,o)}]:_},[]);u=Dt(p.map(({orig:_})=>_).concat(S))}let{minX:g,minY:b,maxX:x,maxY:E,midX:w,midY:y}=u,v=x-g,C=E-b;if(m===void 0&&c===void 0&&(m=v,c=C),i&&(m===void 0?m=c*(v/C):c===void 0?c=m*(C/v):Math.abs(m/c-v/C)>.001&&(m=c*(v/C))),m&&c){let S=t.includes("e")||t.includes("w")?Math.abs(m)/v:1,_=t.includes("n")||t.includes("s")?Math.abs(c)/C:1,L;t.length===1?L=t.includes("e")||t.includes("w")?S:_:L=Math.max(Math.abs(m)/v||0,Math.abs(c)/C||0);let N={ne:[g,E],se:[g,b],sw:[x,b],nw:[x,E],e:[g,b+C/2],w:[x,b+C/2],n:[g+v/2,E],s:[g+v/2,b]},[P,U]=a?[w,y]:N[t],W=i||p.some(G=>G.latest.angle!==0||Z(G.latest)||sr(G.latest));W&&(S=L,_=L);let[V,q]=[l?-1:1,s?-1:1],F=[];for(let{orig:G,latest:ne}of p){if(Z(G)&&Be(G))continue;let X=G.width*S,le=G.height*_,be=al(G.angle*V*q),Te=ce(G)||Lp(G),ot=G.x-P,jt=G.y-U,Ho=l&&!Te?X:0,or=s&&!Te?le:0,qt=P+V*(ot*S+Ho),rr=U+q*(jt*_+or),Xr=Uc(G,X*V,le*q,!1),Jt={x:qt,y:rr,width:X,height:le,angle:be,...Xr};if(te(G)&&(G.startBinding&&(Jt.startBinding={...G.startBinding,fixedPoint:[l?-G.startBinding.fixedPoint[0]+1:G.startBinding.fixedPoint[0],s?-G.startBinding.fixedPoint[1]+1:G.startBinding.fixedPoint[1]]}),G.endBinding&&(Jt.endBinding={...G.endBinding,fixedPoint:[l?-G.endBinding.fixedPoint[0]+1:G.endBinding.fixedPoint[0],s?-G.endBinding.fixedPoint[1]+1:G.endBinding.fixedPoint[1]]}),G.fixedSegments&&Xr.points&&(Jt.fixedSegments=G.fixedSegments.map(po=>({...po,start:Xr.points[po.index-1],end:Xr.points[po.index]})))),he(G)&&(Jt.scale=[G.scale[0]*V,G.scale[1]*q]),Z(G)){let po=du(G,o,X);if(!po)return;Jt.fontSize=po.size}let $r=n.get(ko(G)??"");if($r)if(W){let po=$r.fontSize*L;if(po<Ps)return;Jt.boundTextFontSize=po}else Jt.boundTextFontSize=$r.fontSize;F.push({element:ne,update:Jt})}let z=F.map(({element:G})=>G);for(let{element:G,update:{boundTextFontSize:ne,...X}}of F){let{width:le,height:be,angle:Te}=X;B(G,X,!1,{isDragging:!0}),at(G,o,{simultaneouslyUpdated:z,newSize:{width:le,height:be}});let ot=ge(G,o);ot&&ne&&(B(ot,{fontSize:ne,angle:ce(G)?void 0:Te},!1),ul(G,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,ci(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]=Ke(e,o);if(!(ce(e)&&e.points.length<=2)){let E=he(e)?0:Ns/i.value,w=Ns/i.value,y=O0(M(d-E,p-E),M(u+E,g+E),M(b,x),e.angle);for(let[v,C]of Object.entries(y))if(Tp(M(r,n),C,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=Sl([e,o,t,r,(e+t)/2,(o+r)/2],0,a,l,ci(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=Ns/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=se(M(e,o),n,i),l=se(M(t,o),n,i),s=se(M(e,r),n,i),c=se(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=>ie(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]=ut(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 _e,createStore as mT}from"jotai";import{createIsolation as pT}from"jotai-scope";var H0=pT();var{useAtom:ve,useSetAtom:hn,useAtomValue:Gc,useStore:_7}=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=_e(pr.code),pt=()=>{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)])):Xn(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}}}},kl=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),dt()||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."),dt()||Ue())throw r}finally{return[o,t]}}filterInvisibleChanges(o,t,r){let n=Ll(o),i=Ll(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:Xn(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}},De=class De{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 De(a,l,s)}else i=new De(o,t,r);return(dt()||Ue())&&(De.validate(i,"added",this.satisfiesAddition),De.validate(i,"removed",this.satisfiesRemoval),De.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 De.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,De.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,De.stripIrrelevantProps);r.set(a.id,m);continue}if(l.versionNonce!==a.versionNonce){let s=rt.calculate(l,a,De.stripIrrelevantProps,De.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 De.create(r,n,i)}static empty(){return De.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 De.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 De.create(n,i,a,{shouldRedistribute:!0})}applyTo(o,t){let r=sn(new Map(o)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=De.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),dt()||Ue())throw a;return[o,!0]}try{De.redrawTextBoundingBoxes(r,n),r=De.reorderElements(r,n,i),De.redrawBoundArrows(r,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),dt()||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=De.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)De.unbindAffected(o,t,c,n);for(let[c]of this.added)De.rebindAffected(o,t,c,n);for(let[c]of Array.from(this.updated).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>hb.has(p)))){let m=t.get(c);!m||m.isDeleted||De.rebindAffected(o,t,c,n)}let i=new Map(Array.from(o).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=De.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);gl.unbindAffected(t,i(),n),gl.unbindAffected(t,a(),n),fl.unbindAffected(t,i(),n),fl.unbindAffected(t,a(),n)}static rebindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);gl.unbindAffected(t,i(),n),gl.rebindAffected(t,a(),n),fl.unbindAffected(t,i(),(l,s)=>{Z(l)&&n(l,s)}),fl.rebindAffected(t,a(),n)}static redrawTextBoundingBoxes(o,t){let r=new Map;for(let n of t.values()){if(Be(n)){let{containerId:i}=n,a=i?o.get(i):void 0;a&&r.set(a.id,{container:a,boundText:n})}if(mt(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&&jn(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."),dt()||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}};I(De,"satisfiesAddition",({deleted:o,inserted:t})=>o.isDeleted===!0&&!t.isDeleted),I(De,"satisfiesRemoval",({deleted:o,inserted:t})=>!o.isDeleted&&t.isDeleted===!0),I(De,"satisfiesUpdate",({deleted:o,inserted:t})=>!!o.isDeleted==!!t.isDeleted),I(De,"createApplier",(o,t,r)=>{let n=De.createGetter(o,t,r);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let m=De.applyDelta(c,s,r);o.set(m.id,m),a.set(m.id,m)}return a},new Map)}),I(De,"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 Ml=De;var Pt=class{constructor(){I(this,"subscribers",[])}on(...o){let t=o.flat().filter(r=>typeof r=="function");return this.subscribers.push(...t),()=>this.off(t)}once(...o){let t=o.flat().filter(n=>typeof n=="function");t.push(()=>r());let r=this.on(...t);return r}off(...o){let t=o.flat();this.subscribers=this.subscribers.filter(r=>!t.includes(r))}trigger(...o){for(let t of this.subscribers)t(...o);return this}clear(){this.subscribers=[]}};var Y0="__observedAppState",Ll=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(){I(this,"onStoreIncrementEmitter",new Pt);I(this,"scheduledActions",new Set);I(this,"_snapshot",Zc.empty());I(this,"shouldCaptureIncrement",()=>{this.scheduleAction(A.IMMEDIATELY)});I(this,"shouldUpdateSnapshot",()=>{this.scheduleAction(A.NEVER)});I(this,"scheduleAction",o=>{this.scheduledActions.add(o),this.satisfiesScheduledActionsInvariant()});I(this,"commit",(o,t)=>{try{this.scheduledActions.has(A.IMMEDIATELY)?this.captureIncrement(o,t):this.scheduledActions.has(A.NEVER)&&this.updateSnapshot(o,t)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}});I(this,"captureIncrement",(o,t)=>{let r=this.snapshot,n=this.snapshot.maybeClone(o,t);if(r!==n){let i=n.meta.didElementsChange?Ml.calculate(r.elements,n.elements):Ml.empty(),a=n.meta.didAppStateChange?kl.calculate(r.appState,n.appState):kl.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new xu(i,a)),this.snapshot=n}});I(this,"updateSnapshot",(o,t)=>{let r=this.snapshot.maybeClone(o,t);this.snapshot!==r&&(this.snapshot=r)});I(this,"filterUncomittedElements",(o,t)=>{for(let[r,n]of o.entries()){if(!t.get(r))continue;let a=this.snapshot.elements.get(r);a?a.version<n.version&&t.set(r,a):t.delete(r)}return t});I(this,"clear",()=>{this.snapshot=Zc.empty(),this.scheduledActions=new Set});I(this,"satisfiesScheduledActionsInvariant",()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let o=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(o,this.scheduledActions.values()),dt()||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,Ll(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:Ll(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,io(n))}return t}};import fT from"clsx";import bT from"open-color";import kt from"react";import{Fragment as Ne,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})},K={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"},b_=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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),pi=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(Ne,{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(Ne,{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(Ne,{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"}),x_=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}),Al=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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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),_l=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),Dl=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),Pl=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"})]}),K),ui=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"})]}),K),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"})]}),K),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"})]}),K),mx=D(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Rl=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),E_=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"})]}),K),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"})]}),K),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}),y_=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}),v_=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"),w_=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),T_=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"),C_=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}),I_=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"})]}),K),S_=D(O(Ne,{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}),k_=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,K),Su=D(yx,{...K,style:{transform:"rotate(180deg)"}}),ku=D(Ex,K),Mu=D(Ex,{...K,style:{transform:"rotate(180deg)"}}),Lu=D(O(Ne,{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(Ne,{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(Ne,{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(Ne,{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(Ne,{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(Ne,{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"})]}),K),M_=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"),L_=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(Ne,{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),A_=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("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}),D_=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(Ne,{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(Ne,{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(Ne,{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(Ne,{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(Ne,{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(Ne,{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),P_=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"})]}),K),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"})]}),K),_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"})]}),K),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"})]}),K),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(Ne,{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(Ne,{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(Ne,{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(Ne,{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),hi=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"})]}),K),Jx=D(h(Ne,{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"})]})}),K),Nl=D(h(Ne,{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(Ne,{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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K)),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"})]}),K)),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"})]}),K)),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"})]}),K),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}),R_=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"})]}),K),zu=D(O(Ne,{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"})]}),K),ca=D(O(Ne,{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"})]}),K),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"})]}),K),lE=D(O(Ne,{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"})]}),K),N_=D(O(Ne,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),K),O_=D(O(Ne,{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"})]}),K),sE=D(O(Ne,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),K),cE=D(O(Ne,{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"})]}),K),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"})]}),K),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"})]}),K),Ol=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"})]}),K),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),Bl=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"})]}),K),B_=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"})]}),K),z_=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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),{...K,strokeWidth:1.5}),F_=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"})]}),K),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"})]}),K),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"})]}),K),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"})]}),K),_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"})]}),K),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"})]}),K),PE=D(O("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),K),ld=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),K),RE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),K),NE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),K),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"})]}),K),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"})]}),K);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 zl,jsxs as Fl}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 Fl("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)&&Fl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&zl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&zl(Mt,{})]}),r.showAriaLabel&&Fl("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&zl(Mt,{})]}),r.children]})}return Fl("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:[zl("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}),Fl("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&zl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});Q.displayName="ToolButton";var cd=[],H=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=>ie(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(Be(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=Be(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,Be(m)||(n[m.id]=!0),oe(m,{frameId:null})):Be(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,...ht({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},Hl=H({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||ie(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=>ie(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)&&ie(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ie(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=H({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=H({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=H({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=H({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=H({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,...ht({editingGroupId:null,selectedElementIds:n},Ee(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ce(e[0])?new j(e[0]):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as kT}from"react/jsx-runtime";var $u=H({name:"duplicateSelection",label:"labels.duplicateSelection",icon:_l,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{duplicatedElements:n,elementsWithDuplicates:i}=si({type:"in-place",elements:e,idsOfElementsToDuplicate:ee(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+cp/2,y:a.y+cp/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Ut(i,ee(n)),appState:{...o,...gc(n,Ee(i),o)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t})=>kT(Q,{type:"button",icon:_l,title:`${f("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),visible:ze(Ee(e),o)})});import{useEffect as hh,useMemo as t4,useRef as gh,useState as o4}from"react";var MT=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"||!MT.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 DT from"clsx";import LT from"clsx";import{forwardRef as AT}from"react";import{jsx as _T}from"react/jsx-runtime";var md=AT((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return _T("button",{type:"button",ref:o,title:t,"data-testid":n,className:LT(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as ju,jsxs as PT}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):PT("label",{className:DT({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 b6 from"clsx";import{useRef as x6}from"react";import{jsx as RT}from"react/jsx-runtime";var pd=()=>RT("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as zT,useRef as FT}from"react";import{createPortal as HT}from"react-dom";import $E from"react";var qu=$E.createContext(null),Pe=()=>$E.useContext(qu);import{useState as NT,useLayoutEffect as jE}from"react";var ud=e=>{let[o,t]=NT(null),r=Ce(),{theme:n}=Pe(),{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 OT}from"react";function pa(e,o,t){OT(()=>{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 BT}from"react";var fn=e=>{let o=BT(e);return Object.assign(o.current,e),o.current};import{jsx as UT}from"react/jsx-runtime";var bn=_e(null),qE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=ud({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Pe(),a=xn(),l=lt(),s=J(a,i),c=fn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=gt();zT(()=>{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)},C=S=>{S.key===T.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=FT(null);return pa(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?HT(UT("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as ua from"@radix-ui/react-popover";import WT from"clsx";import KT from"react";import GT from"react";import VT from"clsx";import{jsx as YT}from"react/jsx-runtime";var yt=GT.forwardRef(({children:e,padding:o,className:t,style:r},n)=>YT("div",{className:VT("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Ju,jsxs as ZT}from"react/jsx-runtime";var hd=KT.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:ZT(ua.Content,{ref:c,className:WT("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 XT from"clsx";import{useCallback as $T,useEffect as eh,useRef as ey,useState as jT}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},Ul=[["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=_e(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 qT,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]=jT(e),[l,s]=ve(Do);eh(()=>{a(e)},[e]);let c=$T(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(qT,{children:[gd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),gd("div",{ref:d,className:XT("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 g6}from"react";import e6 from"clsx";import{useEffect as t6,useRef as o6}from"react";import{jsxs as QT}from"react/jsx-runtime";var JT=({color:e,keyLabel:o,isShade:t=!1})=>QT("div",{className:"color-picker__button__hotkey-label",style:{color:ha(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ga=JT;import{jsx as th,jsxs as r6}from"react/jsx-runtime";var ny=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ve(Do),a=o6(null);return t6(()=>{a.current&&a.current.focus()},[o,n]),th("div",{className:"color-picker-content--default",children:e.map((l,s)=>r6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:e6("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 n6 from"clsx";import{useEffect as i6,useRef as a6}from"react";import{jsx as oh,jsxs as s6}from"react/jsx-runtime";var l6=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=En({color:o||"transparent",palette:e}),[a,l]=ve(Do),s=a6(null);return i6(()=>{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=Ul[d],g=f(`colors.${c.replace(/\d+/,"")}`,null,"");return s6("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:n6("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=l6;import{jsx as d6}from"react/jsx-runtime";var c6=({children:e})=>d6("div",{className:"color-picker__heading",children:e}),fa=c6;import m6 from"clsx";import{useEffect as p6,useRef as u6}from"react";import{jsx as Gl,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=u6(null);if(p6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return Gl("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:m6("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:[Gl("div",{className:"color-picker__button-outline"}),Gl(ga,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return ay("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Gl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Gl("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/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}}},h6=({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(Ul.includes(e.key)){let l=Ul.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(h6({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,Fn);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 gi,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]=g6(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 gi("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:[gi(fa,{children:f("colorPicker.mostUsedCustomColors")}),gi(ny,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),fd("div",{children:[gi(fa,{children:f("colorPicker.colors")}),gi(iy,{color:e,label:t,palette:i,onChange:o,activeShade:g})]}),fd("div",{children:[gi(fa,{children:f("colorPicker.shades")}),gi(ly,{hex:e,onChange:o,palette:i})]}),l]})})};import f6 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=ks),o==="elementBackground"&&(n=Ms),o==="canvasBackground"&&(n=Ls),r&&(n=r),n?nh("div",{className:"color-picker__top-picks",children:n.map(i=>nh("button",{className:f6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ha(i,Ss)}),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=>Zn(e)?e:uy(`#${e}`)?`#${e}`:uy(e)?e:null,E6=({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=x6(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})},y6=({label:e,color:o,type:t})=>jo(bd.Trigger,{type:"button",className:b6("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o,"has-outline":!ha(o,Ss)}),"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"})}),Vl=({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(y6,{color:o,label:r,type:e}),s.openPopup===e&&jo(E6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Ty from"@radix-ui/react-popover";import V6,{useCallback as Y6,useMemo as W6}from"react";import O6,{useMemo as yn,useState as B6,useRef as z6,useEffect as F6,useCallback as H6}from"react";import v6 from"clsx";import w6 from"react";import{jsx as T6,jsxs as C6}from"react/jsx-runtime";var xd=w6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>C6("div",{className:v6("QuickSearch__wrapper",e),children:[go,T6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import I6 from"clsx";import{Children as S6}from"react";import{jsx as hy}from"react/jsx-runtime";var Ed=({className:e,placeholder:o,children:t})=>{let r=!S6.count(t);return hy("div",{className:I6("ScrollableList__wrapper",e),role:"menu",children:r?hy("div",{className:"empty",children:o}):t})};import{jsx as k6,jsxs as M6}from"react/jsx-runtime";var gy=({children:e,className:o="",style:t,title:r})=>M6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&k6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Yl=gy;gy.displayName="DropdownMenuGroup";import{useEffect as R6,useRef as N6}from"react";import{Fragment as A6,jsx as ah,jsxs as _6}from"react/jsx-runtime";var L6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Ce();return _6(A6,{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=L6;import D6,{useContext as P6}from"react";var lh=D6.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=P6(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=N6(null);return R6(()=>{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 Wl,jsxs as by}from"react/jsx-runtime";var U6=e=>{switch(e){case Bt.Excalifont:case Bt.Virgil:return gn;case Bt.Nunito:case Bt.Helvetica:return Nl;case Bt["Lilita One"]:return Jx;case Bt["Comic Shanns"]:case Bt.Cascadia:return ed;default:return Nl}},xy=O6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=gt(),{fonts:s}=lt(),{showDeprecatedFonts:c}=hr(),[m,d]=B6(""),p=z6(null),u=yn(()=>Array.from(un.registered.entries()).filter(([L,{metadata:N}])=>!N.serverSide&&!N.fallback).map(([L,{metadata:N,fontFaces:P}])=>{let U={value:L,icon:U6(L),text:P[0]?.fontFace?.family??"Unknown"};return N.deprecated&&Object.assign(U,{deprecated:N.deprecated,badge:{type:ba.RED,placeholder:f("fontList.badge.old")}}),U}).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=H6(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]);F6(()=>(i(),()=>{a()}),[]);let v=yn(()=>E.filter(L=>g.has(L.value)),[E,g]),C=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:Yn({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&&Wl(Td,{type:L.badge.type,children:L.badge.placeholder})]},L.value),_=[];return v.length&&_.push(Wl(Yl,{title:f("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&_.push(Wl(Yl,{title:f("fontList.availableFonts"),children:C.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:[Wl(xd,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Wn(d,20)}),Wl(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 G6}from"react";import{jsx as dh}from"react/jsx-runtime";var yy=({selectedFontFamily:e})=>{let o=G6(()=>!!(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:Nl,text:f("labels.normal"),testId:"font-family-normal"},{value:Bt["Comic Shanns"],icon:ed,text:f("labels.code"),testId:"font-family-code"}],K6=new Set(Cy.map(e=>e.value)),vy=e=>e?K6.has(e):!1,Iy=V6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=W6(()=>Cy,[]),s=Y6(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 j6 from"clsx";import Id,{useEffect as q6}from"react";import{jsx as Z6}from"react/jsx-runtime";var vn=({icon:e})=>Z6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as $6,jsx as Sy,jsxs as ky}from"react/jsx-runtime";var X6=({label:e,open:o,openTrigger:t,children:r,className:n})=>ky($6,{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})]}),Kl=X6;import{jsx as fi,jsxs as mh}from"react/jsx-runtime";var J6=_e(!1);function Q6({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(Gn(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(J6),m=Id.useMemo(()=>e.slice(0,i),[e,i]),d=Id.useMemo(()=>e.slice(i),[e,i]);q6(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>fi("div",{className:"picker-content",children:u.map((g,b)=>mh("button",{type:"button",className:j6("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&&fi("span",{className:"picker-keybinding",children:g.keyBinding})]},g.text))});return fi(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&&fi(Kl,{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 fi("div",{children:mh(xa.Root,{open:a,onOpenChange:c=>l(c),children:[fi(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&&fi(Q6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import My,{useEffect as e4}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 e4(()=>{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},r4=(e,o)=>Be(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=r4(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}},n4=H({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Wt(e,o,r=>yl(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(Vl,{topPicks:ks,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})]})}),i4=H({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(Vl,{topPicks:Ms,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})]})}),a4=H({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)}})]})}}),l4=H({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:Us.thin,text:f("labels.thin"),icon:Bu,testId:"strokeWidth-thin"},{value:Us.bold,text:f("labels.bold"),icon:kx,testId:"strokeWidth-bold"},{value:Us.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)})]})}),s4=H({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)})]})}),OB=H({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)})]})}),c4=H({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"})}),d4=H({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=H({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:hi,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=H({name:"increaseFontSize",label:"labels.increaseFontSize",icon:hi,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)}),m4=H({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(([C,S])=>S===d)?.[0];c&&w&&E.some(C=>C.startsWith(w))&&(x=!0),Object.assign(u,{elements:Wt(e,o,C=>{if(Z(C)&&(C.fontFamily!==d||s)){let S=oe(C,{fontFamily:d,lineHeight:kr(d)}),_=n?.get(C.containerId||"")||{},L=r.scene.getContainerElement(C);return a&&L&&_&&B(L,{..._},!1),x||(b=new Set([...b,...Array.from(S.originalText)])),g.set(S,L),S}return C},!0)});let y=`10px ${Yn({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of g)Qe(C,S,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(y,v).then(C=>{for(let[S,_]of g){let L=r.scene.getElement(S.id),N=_?r.scene.getElement(_.id):null;L&&Qe(L,N,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=gh(new Map),i=gh(null),[a,l]=o4({}),s=gh(!0),c=t4(()=>{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()}}})]})}}),p4=H({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)})]})}}),u4=H({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)})})}),BB=H({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=hc(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"}],zB=H({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>{if(ce(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=>ce(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=>ce(n)&&Zi(n.type)?n.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:n=>t({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),FB=H({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 h4}from"react";import{jsx as f4}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`})},g4=(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})=>(h4(()=>()=>Ea().classList.remove("excalidraw-tooltip--visible"),[]),n?null:f4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>g4(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">',b4='<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"/>',x4=`data:${ue.svg},${encodeURIComponent(`${Ny}${Oy}</svg>`)}`,E4=`data:${ue.svg},${encodeURIComponent(`${Ny}${b4}${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?x4:E4;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 T4}from"react/jsx-runtime";var y4=H({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(Vl,{palette:null,topPicks:Ls,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=H({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=H({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=H({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=H({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:T4(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)}),v4=(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=v4(e,{width:E,height:w},n);let v=dr(Tt(f1(y,Li,"floor"),i,a)),C=n0({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:A.EVENTUALLY}},Zl=({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})},vz=H({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ad,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Zl({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]}),wz=H({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ad,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Zl({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]}),w4=H({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ad,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Zl({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]}),bi=H({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?Dl:Pl,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}),Tz=H({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}),Cz=H({name:"toggleLassoTool",label:"toolBar.lasso",icon:Al,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=H({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 C4=H({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 I4}from"react/jsx-runtime";var yo=H({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||ti(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)})}ti(m)&&(s=s.filter(u=>u.id!==m.id));let p=El(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));hl(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&&ce(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})=>I4(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 S4 from"clsx";import{jsx as Fy,jsxs as k4}from"react/jsx-runtime";var Xl=({children:e,checked:o,onChange:t,className:r})=>k4("div",{className:S4("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 $l}from"react/jsx-runtime";var Uy=e=>{let o=e.title||(e.value===de.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return $l(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:$l("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:$l("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:$l("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:$l("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 M4}from"react";import{jsx as Gy,jsxs as L4}from"react/jsx-runtime";var Vy=e=>{let{id:o}=gt(),[t,r]=M4(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 L4("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,xi="NOT_SPREADSHEET",ya="VALID_SPREADSHEET",jl=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=>jl(t[o])!==null),Yy=e=>{let o=e[0].length;if(o>2)return{type:xi,reason:"More than 2 columns"};if(o===1){if(!vh(e,0))return{type:xi,reason:"Value is not numeric"};let s=jl(e[0][0])===null,c=(s?e.slice(1):e).map(m=>jl(m[0]));return c.length<2?{type:xi,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:xi,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=jl(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:xi,reason:"Less than 2 rows"}:{type:ya,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>jl(s[i]))}}},A4=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 L1,A as MC,B as x1,C as E1,D as y1,E as Wl,F as oa,G as Vl,H as Xl,I as w1,J as v1,K as na,L as T1,M as I1,N as C1,O as S1,P as Kl,Q as Cr,R as k1,S as PC,T as Lm,U as LC,V as Sr,W as ra,Y as M1,_ as P1,a as h1,aa as Zl,b as Gn,ba as A1,c as ho,ca as Am,d as g1,da as Dm,e as we,ea as $l,f as f1,fa as D1,g as j,ga as _m,h as ea,ha as Ao,i as go,ia as _1,j as Un,ja as Rm,k as Yn,ka as R1,l as vr,la as N1,m as Wn,ma as jl,n as Tr,na as Nm,o as b1,oa as B1,p as km,pa as F1,q as Jo,qa as O1,r as Qo,ra as ia,s as yt,t as Qt,u as Ir,v as Ul,w as Mm,x as ta,y as Yl,z as Pm}from"./chunk-R2M7VUMD.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as Sm}from"./chunk-I4UNSFV6.js";import{c as u1}from"./chunk-Z3N5DIM6.js";import{b as m1,c as p1,d as I}from"./chunk-SRAX5OIU.js";import kU,{useEffect as MU}from"react";import{DEFAULT_UI_OPTIONS as IC,isShallowEqual as PU}from"@excalidraw/common";import rI from"clsx";import rH from"lodash.throttle";import Lo,{useContext as zn}from"react";import{flushSync as Ki}from"react-dom";import iH from"roughjs/bin/rough";import{nanoid as aH}from"nanoid";import{clamp as iI,pointFrom as ie,pointDistance as Rn,vector as aI,pointRotateRads as ff,vectorScale as lH,vectorFromPoint as bf,vectorSubtract as lI,vectorDot as sI,vectorNormalize as cI}from"@excalidraw/math";import{COLOR_PALETTE as sH,CODES as dI,shouldResizeFromCenter as mI,shouldMaintainAspectRatio as Cl,shouldRotateWithDiscreteAngle as xf,isArrowKey as mm,KEYS as V,APP_NAME as cH,CURSOR_TYPE as _e,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as dH,DEFAULT_VERTICAL_ALIGN as pI,DRAGGING_THRESHOLD as mH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as pH,ELEMENT_TRANSLATE_AMOUNT as uI,EVENT as te,FRAME_STYLE as Nn,IMAGE_MIME_TYPES as uH,IMAGE_RENDER_TIMEOUT as hH,isBrave as gH,LINE_CONFIRM_THRESHOLD as Ef,MAX_ALLOWED_FILE_BYTES as hI,MIME_TYPES as Mo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as fH,POINTER_BUTTON as hr,ROUNDNESS as pm,SCROLL_TIMEOUT as bH,TAP_TWICE_TIMEOUT as xH,TEXT_TO_CENTER_SNAP_THRESHOLD as EH,THEME as um,THEME_FILTER as yH,TOUCH_CTX_MENU_TIMEOUT as wH,VERTICAL_ALIGN as vH,YOUTUBE_STATES as hm,ZOOM_STEP as TH,POINTER_EVENTS as Zi,TOOL_TYPE as Po,isIOS as IH,supportsResizeObserver as gI,DEFAULT_COLLISION_THRESHOLD as fI,DEFAULT_TEXT_ALIGN as CH,ARROW_TYPE as Bn,DEFAULT_REDUCED_GLOBAL_ALPHA as SH,isSafari as kH,isLocalLink as MH,normalizeLink as yf,toValidURL as PH,getGridPoint as rt,getLineHeight as bI,debounce as xI,distance as $i,getFontString as wf,getNearestScrollableContainer as LH,isInputLike as EI,isToolIcon as AH,isWritableElement as Sl,sceneCoordsToViewportCoords as gm,tupleToCoors as vf,viewportCoordsToSceneCoords as He,wrapEvent as DH,updateObject as Tf,updateActiveTool as $o,getShortcutKey as _H,isTransparent as RH,easeToValuesRAF as NH,muteFSAbortError as BH,isTestEnv as Xf,isDevEnv as oC,easeOut as FH,updateStable as kl,addEventListener as Re,normalizeEOL as OH,getDateTime as yI,isShallowEqual as zH,arrayToMap as fm,randomInteger as HH,CLASSES as GH,Emitter as gr,MINIMUM_ARROW_SIZE as wI,DOUBLE_TAP_POSITION_THRESHOLD as UH,isMobileOrTablet as fr,MQ_MAX_MOBILE as YH,MQ_MIN_TABLET as WH,MQ_MAX_TABLET as VH,MQ_MAX_HEIGHT_LANDSCAPE as XH,MQ_MAX_WIDTH_LANDSCAPE as KH}from"@excalidraw/common";import{getObservedAppState as ZH,getCommonBounds as ji,maybeSuggestBindingsForLinearElementAtCoords as vI,getElementAbsoluteCoords as TI,bindOrUnbindLinearElements as II,fixBindingsAfterDeletion as $H,getHoveredElementForBinding as If,isBindingEnabled as Cf,shouldEnableBindingForPointerEvent as jH,updateBoundElements as Sf,getSuggestedBindingsForArrows as kf,LinearElementEditor as Ie,newElementWith as Fn,newFrameElement as qH,newFreeDrawElement as JH,newEmbeddableElement as CI,newMagicFrameElement as SI,newIframeElement as QH,newArrowElement as eG,newElement as tG,newImageElement as oG,newLinearElement as nG,newTextElement as kI,refreshTextDimensions as rG,deepCopyElement as MI,duplicateElements as Mf,hasBoundTextElement as PI,isArrowElement as Pf,isBindingElement as Lf,isBindingElementType as LI,isBoundToContainer as Af,isFrameLikeElement as kt,isImageElement as br,isEmbeddableElement as jo,isInitializedImageElement as Ml,isLinearElement as jt,isLinearElementType as iG,isUsingAdaptiveRadius as aG,isIframeElement as qi,isIframeLikeElement as Pl,isMagicFrameElement as Df,isTextBindableContainer as AI,isElbowArrow as Xe,isFlowchartNodeElement as lG,isBindableElement as sG,isTextElement as po,getLockedLinearCursorAlignSize as DI,getNormalizedDimensions as cG,isElementCompletelyInViewport as _f,isElementInViewport as _I,isInvisiblySmallElement as RI,getCornerRadius as dG,isPathALoop as NI,createSrcDoc as BI,embeddableURLValidator as Rf,maybeParseEmbedSrc as mG,getEmbedLink as bm,getInitializedImageElements as pG,normalizeSVG as FI,updateImageCache as uG,getBoundTextElement as Nf,getContainerCenter as Bf,getContainerElement as OI,isValidTextContainer as hG,redrawTextBoundingBox as gG,shouldShowBoundingBox as fG,getFrameChildren as Ff,isCursorInFrame as zI,addElementsToFrame as Of,replaceAllElementsInFrame as bG,removeElementsFromFrame as xG,getElementsInResizingFrame as zf,getElementsInNewFrame as EG,getContainingFrame as Hf,elementOverlapsWithFrame as yG,updateFrameMembershipOfSelectedElements as HI,isElementInFrame as GI,getFrameLikeTitle as wG,getElementsOverlappingFrame as vG,filterElementsEligibleAsFrameChildren as TG,hitElementBoundText as IG,hitElementBoundingBoxOnly as CG,hitElementItself as Ll,getVisibleSceneBounds as SG,FlowChartCreator as kG,FlowChartNavigator as MG,getLinkDirectionFromKey as UI,cropElement as PG,wrapText as LG,isElementLink as Gf,parseElementLinkFromURL as AG,isMeasureTextSupported as DG,normalizeText as _G,measureText as YI,getLineHeightInPx as RG,getApproxMinLineWidth as NG,getApproxMinLineHeight as BG,getMinTextElementWidth as FG,ShapeCache as Al,getRenderOpacity as OG,editGroupForSelectedElement as zG,getElementsInGroup as xr,getSelectedGroupIdForElement as HG,getSelectedGroupIds as GG,isElementInGroup as WI,isSelectedViaGroup as UG,selectGroupsForSelectedElements as qt,syncInvalidIndices as nC,syncMovedIndices as VI,excludeElementsInFramesFromSelection as YG,getSelectionStateForElements as WG,makeNextSelectedElementIds as ve,getResizeOffsetXY as VG,getResizeArrowDirection as XG,transformElements as KG,getCursorForResizingElement as XI,getElementWithTransformHandleType as KI,getTransformHandleTypeFromCoords as ZI,dragNewElement as $I,dragSelectedElements as ZG,getDragOffsetXY as $G,isNonDeletedElement as jI,Scene as qI,Store as jG,CaptureUpdateAction as Et,hitElementBoundingBox as qG,isLineElement as xm,isSimpleArrow as JG,StoreDelta as JI,positionElementsOnGrid as QI}from"@excalidraw/element";import{KEYS as sp,updateActiveTool as WC}from"@excalidraw/common";import{getNonDeletedElements as cp}from"@excalidraw/element";import{fixBindingsAfterDeletion as VC}from"@excalidraw/element";import{LinearElementEditor as Nb}from"@excalidraw/element";import{newElementWith as ws}from"@excalidraw/element";import{getContainerElement as Bb}from"@excalidraw/element";import{isBoundToContainer as Es,isElbowArrow as XC,isFrameLikeElement as KC}from"@excalidraw/element";import{getFrameChildren as ZC}from"@excalidraw/element";import{getElementsInGroup as dp,selectGroupsForSelectedElements as $C}from"@excalidraw/element";import{CaptureUpdateAction as ys}from"@excalidraw/element";import{isDevEnv as RC}from"@excalidraw/common";import{atom as he,createStore as AC}from"jotai";import{createIsolation as DC}from"jotai-scope";var z1=DC();var{useAtom:le,useSetAtom:en,useAtomValue:ql,useStore:NU}=z1,H1=z1.Provider,Ue=AC();var _C=m1({"./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 NC=85,fo={code:"en",label:"English"},Mr=[fo,...[{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=>u1[e.code]>=NC).sort((e,o)=>e.label>o.label?1:-1)],Ql="__test__";RC()&&Mr.unshift({code:Ql,label:"test language"},{code:`${Ql}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var kr=fo,Jl={},es=async e=>{if(kr=e,document.documentElement.dir=kr.rtl?"rtl":"ltr",document.documentElement.lang=kr.code,e.code.startsWith(Ql))Jl={};else try{Jl=await _C(`./locales/${kr.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Jl=Sm}Ue.set(U1,e.code)},Do=()=>kr,G1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(kr.code.startsWith(Ql))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=G1(Jl,n)||G1(Sm,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},U1=he(fo.code),Ge=()=>{let e=ql(U1);return{t:g,langCode:e}};import BC from"clsx";import FC from"open-color";import et from"react";import{THEME as OC}from"@excalidraw/common";import{Fragment as Ee,jsx as h,jsxs as D}from"react/jsx-runtime";var eo=e=>"var(--icon-fill-color)",Y1=e=>e===OC.LIGHT?FC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:BC({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},O={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},oe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},qU=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"})]}),O),Pr=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"})]}),O),W1=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"})]}),O),V1=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"})]}),O),X1=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),O),K1=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"})]}),O),Bm=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"})]}),O),Vn=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"})})]}),oe),Lr=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"})]}),oe),Z1=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}),$1=M(D(Ee,{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"}),j1=M(D(Ee,{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"}),q1=M(D(Ee,{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"}),JU=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"}),Fm=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}),aa=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}),ts=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"})]}),O),os=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"})]}),O),ns=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),O),J1=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"})]}),O),rs=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),oe),Q1=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"})]}),O),tn=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"})]}),oe),Ar=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"})]}),O),e0=M(D("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),O),t0=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"})]}),oe),o0=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"})]}),O),Om=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),oe),zm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),oe),n0=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"})]}),O),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"}),oe),Hm=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"})]}),oe),la=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"})]}),oe),sa=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"}),oe),ca=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"})}),{...oe,strokeWidth:1.5}),is=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"})]}),O),Xn=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"}),oe),Dr=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"})]}),O),r0=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"})]}),O),Gm=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"}),oe),as=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"}),oe),i0=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"})]}),oe),a0=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"})]}),O),l0=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),da=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"})]}),oe),s0=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}),c0=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}),_r=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"}),oe),QU=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}),d0=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"),ls=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"})]}),O),m0=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),O),ss=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"})]}),O),p0=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}),eY=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}),tY=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}),u0=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"),oY=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"),Um=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"}),oe),Ym=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"}),oe),h0=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}),g0=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"}),oe),nY=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"),rY=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}),iY=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"})]}),O),aY=M(D(Ee,{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}),lY=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}),f0=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"})]}),b0=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"})]}),Wm=M(b0,O),Vm=M(b0,{...O,style:{transform:"rotate(180deg)"}}),Xm=M(f0,O),Km=M(f0,{...O,style:{transform:"rotate(180deg)"}}),Zm=M(D(Ee,{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"})})})]}),oe),$m=M(D(Ee,{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"})})})]}),oe),jm=M(D(Ee,{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"})})})]}),oe),qm=M(D(Ee,{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"})})})]}),oe),x0=M(D(Ee,{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"})})})]}),oe),E0=M(D(Ee,{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"})})})]}),oe),Jm=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"})]}),oe),Qm=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"})]}),oe),cs=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"})]}),O),sY=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"),cY=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"),zt=M(D(Ee,{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"})})})]}),oe),dY=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}),mY=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}),pY=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}),ep=et.memo(({theme:e})=>M(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:eo(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:eo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:eo(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:eo(e),strokeWidth:"2"}),D("g",{fill:Y1(e),stroke:eo(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})),tp=et.memo(({theme:e})=>M(D(Ee,{children:[h("path",{d:"M25 26H111V111H25",fill:eo(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:eo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:eo(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:eo(e),strokeWidth:"2"}),D("g",{fill:Y1(e),stroke:eo(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})),y0=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"})}),oe),w0=M(D(Ee,{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"})})]}),oe),v0=M(D(Ee,{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"})})})]}),oe),T0=M(D(Ee,{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"})})})]}),{...oe,fill:"currentColor"}),op=M(h(Ee,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),oe),I0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),oe),C0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),oe),uY=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:eo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),S0=M(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),O),k0=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"})]}),O),M0=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"}),oe),P0=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"}),oe),L0=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"}),oe),A0=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"})]}),oe),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"})]}),O),_0=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"})]}),O),R0=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})),N0=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})),B0=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})),F0=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})),O0=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})),z0=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})),H0=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})),G0=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})),U0=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})),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 L15,15 L15,5"})}),{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,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),V0=M(D(Ee,{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"})})})]}),oe),X0=M(D(Ee,{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"})})})]}),oe),K0=M(D(Ee,{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"})})})]}),oe),Z0=M(h(Ee,{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"})}),oe),Kn=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"})]}),O),$0=M(h(Ee,{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"})]})}),O),ma=M(h(Ee,{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"})})}),oe),ds=M(D(Ee,{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"})})})]}),oe),j0=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"})]}),O),q0=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"})]}),O),J0=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"})]}),O),Q0=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"})]}),O)),eb=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"})]}),O)),tb=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"})]}),O)),ms=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"})]}),O),ob=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}),hY=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"})),ps=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"})]}),O),np=M(D(Ee,{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"})]}),O),Rr=M(D(Ee,{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"})]}),O),nb=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"})]}),O),rb=M(D(Ee,{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"})]}),O),gY=M(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),O),fY=M(D(Ee,{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"})]}),O),ib=M(D(Ee,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),O),ab=M(D(Ee,{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"})]}),O),lb=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"})]}),O),sb=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"})]}),O),Zn=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"})]}),O),us=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"})),Nr=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"})]}),oe),pa=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),hs=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"})]}),O),bY=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"})]}),O),xY=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"})]}),O),cb=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"})]}),O),Br=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"})]}),O),db=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"})]}),O),mb=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"})]}),O),pb=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"})]}),O),Pt=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),O),ub=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"})]}),O),hb=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"})]}),O),gb=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"})]}),O),ua=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"})]}),O),fb=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"})]}),O),bb=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"})]}),O),xb=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"})]}),O),Eb=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"})]}),O),rp=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"})]}),O),gs=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"})]}),O),yb=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"})]}),O),wb=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"})]}),O),vb=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"})]}),O),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"})]}),O),Ib=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"})]}),{...O,strokeWidth:1.5}),EY=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"})]}),O),Cb=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"})]}),O),Sb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),O),kb=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"})]}),O),Fr=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"})]}),O),Or=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"})]}),O),zr=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),O),fs=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),O),Mb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),O),Pb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),O),ip=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"})]}),O),bs=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"})]}),O),yY=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),O),Lb=M(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),O),Ab=M(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4"}),h("path",{d:"M6 14l8 -8"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M10 18l8 -8"}),h("path",{d:"M14 18l4 -4"})]}),O),Db=M(D("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"6",y:"6",width:"12",height:"12",fill:"none"})]}),O);import _b from"clsx";import lp,{useEffect as GC,useRef as Rb,useState as UC}from"react";import{isPromiseLike as YC}from"@excalidraw/common";import zC from"react";import{jsx as ap}from"react/jsx-runtime";var HC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(zC.useRef(Date.now()).current%1600);return ap("div",{className:`Spinner ${n}`,children:ap("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:ap("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=HC;import{jsx as ha,jsxs as ga}from"react/jsx-runtime";var Z=lp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=lp.useRef(null);lp.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=UC(!1),d=Rb(!0),c=async u=>{let f="onClick"in n&&n.onClick?.(u);if(YC(f))try{m(!0),await f}catch(b){if(b instanceof Tr)console.warn(b);else throw b}finally{d.current&&m(!1)}};GC(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=Rb(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return ga("button",{className:_b("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:c,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&ga("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&ha("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&ha(tt,{})]}),n.showAriaLabel&&ga("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&ha(tt,{})]}),n.children]})}return ga("label",{className:_b("ToolIcon",t),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ha("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:p.current})},checked:n.checked,ref:a}),ga("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&ha("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});Z.displayName="ToolButton";var xs=[],N=e=>(xs=xs.concat(e),e);import{jsx as qC}from"react/jsx-runtime";var jC=(e,o,t)=>{let n=new Set(j(e.filter(d=>KC(d)),o).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of n){let c=ZC(e,d);for(let p of c)if(!a.has(p.id)){if(Es(p)){let u=Bb(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(d=>{if(o.selectedElementIds[d.id]){let c=Es(d)?Bb(d,i):null;return d.frameId&&n.has(d.frameId)?(l=!1,r[d.id]=!0,d):c?.frameId&&n.has(c?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&XC(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),ws(d,{isDeleted:!0}))}return d.frameId&&n.has(d.frameId)?(l=!1,Es(d)||(r[d.id]=!0),ws(d,{frameId:null})):Es(d)&&o.selectedElementIds[d.containerId]?ws(d,{isDeleted:!0}):d}),m=o.editingGroupId;if(l&&o.editingGroupId){let d=dp(s,o.editingGroupId).filter(c=>!c.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{m=null,d[0]&&(r[d[0].id]=!0);let c=d[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=dp(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...$C({selectedElementIds:r,editingGroupId:m},s,o,null)}}},Fb=(e,o)=>{if(e.editingGroupId){let t=dp(cp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},fa=N({name:"deleteSelectedElements",label:"labels.delete",icon:Mt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,d=n.scene.getNonDeletedElementsMap(),c=Nb.getElement(a,d);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?ws(b,{isDeleted:!0}):b),f=Fb(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ys.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:m};return Nb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ys.IMMEDIATELY}}let{elements:r,appState:i}=jC(e,o,n);return VC(r,r.filter(a=>a.isDeleted)),i=Fb(i,r),{elements:r,appState:{...i,activeTool:WC(o,{type:n.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(cp(e),o)?ys.IMMEDIATELY:ys.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===sp.BACKSPACE||e.key===sp.DELETE)&&!e[sp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>qC(Z,{type:"button",icon:Mt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:we(cp(e),o)})});import{KEYS as Hr,CODES as Gr,getShortcutKey as Ur,isDarwin as vs}from"@excalidraw/common";import{moveOneLeft as JC,moveOneRight as QC,moveAllLeft as eS,moveAllRight as tS}from"@excalidraw/element";import{CaptureUpdateAction as Ts}from"@excalidraw/element";import{jsx as Is}from"react/jsx-runtime";var mp=N({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Vm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:JC(e,o,n.scene),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Hr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Gr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Ur("CtrlOrCmd+[")}`,children:Vm})}),pp=N({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Wm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:QC(e,o,n.scene),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Hr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Gr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Ur("CtrlOrCmd+]")}`,children:Wm})}),up=N({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Km,trackEvent:{category:"element"},perform:(e,o)=>({elements:eS(e,o),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyTest:e=>vs?e[Hr.CTRL_OR_CMD]&&e.altKey&&e.code===Gr.BRACKET_LEFT:e[Hr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Gr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${vs?Ur("CtrlOrCmd+Alt+["):Ur("CtrlOrCmd+Shift+[")}`,children:Km})}),hp=N({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Xm,trackEvent:{category:"element"},perform:(e,o)=>({elements:tS(e,o),appState:o,captureUpdate:Ts.IMMEDIATELY}),keyTest:e=>vs?e[Hr.CTRL_OR_CMD]&&e.altKey&&e.code===Gr.BRACKET_RIGHT:e[Hr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Gr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Is("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${vs?Ur("CtrlOrCmd+Alt+]"):Ur("CtrlOrCmd+Shift+]")}`,children:Xm})});import{getNonDeletedElements as oS}from"@excalidraw/element";import{LinearElementEditor as nS}from"@excalidraw/element";import{isLinearElement as rS,isTextElement as iS}from"@excalidraw/element";import{arrayToMap as aS,KEYS as Ob}from"@excalidraw/common";import{selectGroupsForSelectedElements as lS}from"@excalidraw/element";import{CaptureUpdateAction as sS}from"@excalidraw/element";var gp=N({name:"selectAll",label:"labels.selectAll",icon:fb,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(iS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...lS({editingGroupId:null,selectedElementIds:r},oS(e),o,n),selectedLinearElement:Object.keys(r).length===1&&rS(e[0])?new nS(e[0],aS(e)):null},captureUpdate:sS.IMMEDIATELY}},keyTest:e=>e[Ob.CTRL_OR_CMD]&&e.key===Ob.A});import{DEFAULT_GRID_SIZE as zb,KEYS as Hb,arrayToMap as Gb,getShortcutKey as cS}from"@excalidraw/common";import{getNonDeletedElements as Ub}from"@excalidraw/element";import{LinearElementEditor as dS}from"@excalidraw/element";import{getSelectedElements as mS,getSelectionStateForElements as pS}from"@excalidraw/element";import{syncMovedIndices as uS}from"@excalidraw/element";import{duplicateElements as hS}from"@excalidraw/element";import{CaptureUpdateAction as Yb}from"@excalidraw/element";import{jsx as gS}from"react/jsx-runtime";var fp=N({name:"duplicateSelection",label:"labels.duplicateSelection",icon:la,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=dS.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Yb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=hS({type:"in-place",elements:e,idsOfElementsToDuplicate:Gb(mS(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+zb/2,y:a.y+zb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:uS(i,Gb(r)),appState:{...o,...pS(r,Ub(i),o)},captureUpdate:Yb.IMMEDIATELY}},keyTest:e=>e[Hb.CTRL_OR_CMD]&&e.key===Hb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>gS(Z,{type:"button",icon:la,title:`${g("labels.duplicateSelection")} \u2014 ${cS("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:we(Ub(e),o)})});import{pointFrom as u4}from"@excalidraw/math";import{useEffect as zp,useMemo as h4,useRef as Hp,useState as g4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as f4,DEFAULT_ELEMENT_BACKGROUND_PICKS as b4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as x4,DEFAULT_ELEMENT_STROKE_PICKS as E4,ARROW_TYPE as No,DEFAULT_FONT_FAMILY as y4,DEFAULT_FONT_SIZE as w4,FONT_FAMILY as v4,ROUNDNESS as Ys,STROKE_WIDTH as Gp,VERTICAL_ALIGN as Us,KEYS as Jr,randomInteger as T4,arrayToMap as Wp,getFontFamilyString as I4,getShortcutKey as C4,getLineHeight as S4,isTransparent as k4,reduceToCommonValue as M4}from"@excalidraw/common";import{canBecomePolygon as P4,getNonDeletedElements as Rx}from"@excalidraw/element";import{bindLinearElement as Lx,calculateFixedPointForElbowArrowBinding as Ax,updateBoundElements as L4}from"@excalidraw/element";import{LinearElementEditor as Up}from"@excalidraw/element";import{newElementWith as Ze}from"@excalidraw/element";import{getBoundTextElement as mn,redrawTextBoundingBox as Ma}from"@excalidraw/element";import{isArrowElement as Ws,isBoundToContainer as A4,isElbowArrow as Nx,isLinearElement as Yp,isLineElement as Dx,isTextElement as wt,isUsingAdaptiveRadius as D4}from"@excalidraw/element";import{hasStrokeColor as _4}from"@excalidraw/element";import{updateElbowArrowPoints as R4,CaptureUpdateAction as $e,toggleLinePolygonState as N4}from"@excalidraw/element";import{isDevEnv as fS}from"@excalidraw/common";var bS=new Set(["command_palette","export"]),re=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!bS.has(e)||fS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import wS from"clsx";import xS from"clsx";import{forwardRef as ES}from"react";import{jsx as yS}from"react/jsx-runtime";var Yr=ES((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return yS("button",{type:"button",ref:o,title:t,"data-testid":r,className:xS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as TS,jsx as bp,jsxs as vS}from"react/jsx-runtime";var Ht=e=>bp(TS,{children:e.options.map(o=>e.type==="button"?bp(Yr,{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):vS("label",{className:wS({active:e.value===o.value}),title:o.text,children:[bp("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 _s from"@radix-ui/react-popover";import dx from"clsx";import{useRef as mx,useEffect as T6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Lp,COLOR_PALETTE as px,isTransparent as I6}from"@excalidraw/common";import{jsx as IS}from"react/jsx-runtime";var Cs=()=>IS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as PS,useRef as LS}from"react";import{createPortal as AS}from"react-dom";import{EVENT as nn,KEYS as DS,rgbToHex as _S}from"@excalidraw/common";import Wb from"react";var xp=Wb.createContext(null),be=()=>Wb.useContext(xp);import{useState as CS,useLayoutEffect as Vb}from"react";import{THEME as SS}from"@excalidraw/common";var Ss=e=>{let[o,t]=CS(null),n=de(),{theme:r}=be(),{container:i}=Ne();return Vb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.editor.isMobile),o.classList.toggle("theme--dark",r===SS.DARK))},[o,r,n.editor.isMobile,e?.className]),Vb(()=>{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 kS}from"react";import{EVENT as ks}from"@excalidraw/common";function Wr(e,o,t){kS(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(ks.POINTER_DOWN,n),document.addEventListener(ks.TOUCH_START,n),()=>{document.removeEventListener(ks.POINTER_DOWN,n),document.removeEventListener(ks.TOUCH_START,n)}},[e,o,t])}import{useRef as MS}from"react";var on=e=>{let o=MS(e);return Object.assign(o.current,e),o.current};import{jsx as RS}from"react/jsx-runtime";var rn=he(null),Xb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=Ss({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=be(),a=an(),l=Be(),s=j(a,i),m=on({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:d}=Ne();PS(()=>{let p=c.current;if(!p||!l.canvas||!r)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let P=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return _S(P[0],P[1],P[2])},x=({clientX:S,clientY:L,altKey:P})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let B=b({clientX:S,clientY:L});u&&m.onChange(n,B,m.selectedElements,{altKey:P}),p.style.background=B},y=()=>{m.onCancel()},E=(S,L)=>{m.onSelect(S,L)},w=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,d?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===DS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(nn.KEYDOWN,C),r.addEventListener(nn.POINTER_DOWN,w),r.addEventListener(nn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(nn.BLUR,y),()=>{u=!1,r.removeEventListener(nn.KEYDOWN,C),r.removeEventListener(nn.POINTER_DOWN,w),r.removeEventListener(nn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(nn.BLUR,y)}},[m,l.canvas,r,n,d,i.offsetLeft,i.offsetTop]);let c=LS(null);return Wr(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?AS(RS("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),r):null};import*as Vr from"@radix-ui/react-popover";import OS from"clsx";import zS from"react";import{isInteractive as HS}from"@excalidraw/common";import NS from"react";import BS from"clsx";import{jsx as FS}from"react/jsx-runtime";var Ye=NS.forwardRef(({children:e,padding:o,className:t,style:n},r)=>FS("div",{className:BS("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as Ep,jsxs as GS}from"react/jsx-runtime";var _o=zS.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:m=!1},d)=>{let c=de();return Ep(Vr.Portal,{container:o,children:GS(Vr.Content,{ref:d,className:OS("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:p=>{m&&c.isTouchScreen&&p.preventDefault()},onCloseAutoFocus:p=>{p.stopPropagation(),p.preventDefault(),o&&!HS(document.activeElement)&&o.focus(),r()},children:[Ep(Ye,{padding:3,style:n,children:t}),Ep(Vr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as US,useCallback as yp}from"react";var Ms=()=>document.querySelector(".excalidraw-wysiwyg"),Ps=()=>{let e=Ms();return e?{start:e.selectionStart,end:e.selectionEnd}:null},ba=e=>{setTimeout(()=>{let o=Ms();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},xa=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Ps():null;e(),o&&t&&ba(r)},Kb=()=>{let[e,o]=US(null),t=yp(()=>{let i=Ps();o(i)},[]),n=yp(()=>{setTimeout(()=>{let i=Ms();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=yp(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Zb=(e=100)=>{let o=Ms();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import WS from"clsx";import{useCallback as VS,useEffect as vp,useRef as qb,useState as XS}from"react";import{KEYS as Tp,getShortcutKey as KS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as YS}from"@excalidraw/common";var ln=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Ea=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),wp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),jb=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return wp({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,YS)},Gt=he(null),$b=(e,o,t)=>(e*299+o*587+t*114)/1e3,sn=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),m=parseInt(l[1]),d=parseInt(l[2]);return $b(s,m,d)<o}return!0}let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return $b(t,n,r)<o};import{Fragment as ZS,jsx as Ls,jsxs as Jb}from"react/jsx-runtime";var Qb=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=de(),[a,l]=XS(e),[s,m]=le(Gt);vp(()=>{l(e)},[e]);let d=VS(b=>{let x=b.toLowerCase(),y=ex(x);y&&o(y),l(x)},[o]),c=qb(null),p=qb(null);vp(()=>{c.current&&c.current.focus()},[s]);let[u,f]=le(rn);return vp(()=>()=>{f(null)},[f]),Jb("div",{className:"color-picker__input-label",children:[Ls("div",{className:"color-picker__input-hash",children:"#"}),Ls("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{d(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:b=>{b.key!==Tp.TAB&&(b.key===Tp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&Jb(ZS,{children:[Ls("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Ls("div",{ref:p,className:WS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${Tp.I.toLocaleUpperCase()} or ${KS("Alt")} `,children:lb})]})]})};import kp,{useEffect as Mp,useImperativeHandle as u6,useState as h6}from"react";import{EVENT as ax}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as g6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as f6,KEYS as b6}from"@excalidraw/common";import qS from"clsx";import{useEffect as JS,useRef as QS}from"react";import{jsxs as jS}from"react/jsx-runtime";var $S=({color:e,keyLabel:o,isShade:t=!1})=>jS("div",{className:"color-picker__button__hotkey-label",style:{color:sn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Xr=$S;import{jsx as Ip,jsxs as e6}from"react/jsx-runtime";var tx=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=le(Gt),a=QS(null);return JS(()=>{a.current&&a.current.focus()},[o,r]),Ip("div",{className:"color-picker-content--default",children:e.map((l,s)=>e6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:qS("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[Ip("div",{className:"color-picker__button-outline"}),Ip(Xr,{color:l,keyLabel:s+1})]},s))})};import t6 from"clsx";import{useEffect as o6,useRef as n6}from"react";import{jsx as Cp,jsxs as i6}from"react/jsx-runtime";var r6=({palette:e,color:o,onChange:t,activeShade:n})=>{let r=ln({color:o,palette:e}),[i,a]=le(Gt),l=n6(null);return o6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),Cp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],d)=>{let c=(Array.isArray(m)?m[n]:m)||"transparent",p=Ea[d],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return i6("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:t6("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":c==="transparent"||!c}),onClick:()=>{t(c),a("baseColors")},title:`${u}${c.startsWith("#")?` ${c}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:c?{"--swatch-color":c}:void 0,"data-testid":`color-${s}`,children:[Cp("div",{className:"color-picker__button-outline"}),Cp(Xr,{color:c,keyLabel:p})]},s)})})},ox=r6;import{jsx as l6}from"react/jsx-runtime";var a6=({children:e})=>l6("div",{className:"color-picker__heading",children:e}),Kr=a6;import s6 from"clsx";import{useEffect as c6,useRef as d6}from"react";import{jsx as ya,jsxs as nx}from"react/jsx-runtime";var rx=({color:e,onChange:o,palette:t})=>{let n=ln({color:e||"transparent",palette:t}),[r,i]=le(Gt),a=d6(null);if(c6(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,m=t[l];if(Array.isArray(m))return ya("div",{className:"color-picker-content--default shades",children:m.map((d,c)=>nx("button",{ref:c===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:s6("color-picker__button color-picker__button--large has-outline",{active:c===s}),"aria-label":"Shade",title:`${l} - ${c+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{o(d),i("shades")},children:[ya("div",{className:"color-picker__button-outline"}),ya(Xr,{color:d,keyLabel:c+1,isShade:!0})]},c))})}return nx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ya("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ya("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 Zr,COLOR_PALETTE as m6,KEYS as wa}from"@excalidraw/common";var Sp=(e,o,t)=>{let n=Math.ceil(t/Zr);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Zr;return r>=t?o%Zr:r}case"ArrowUp":{let r=o-Zr,i=r<0?Zr*n+r:r;return i>=t?void 0:i}}},p6=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(n[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Ea.includes(e.key)){let l=Ea.indexOf(e.key),s=Object.keys(n)[l],m=n[s],d=Array.isArray(m)?m[a]:m;return t(d),i("baseColors"),!0}return!1},ix=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:d})=>{if(e[wa.CTRL_OR_CMD])return!1;if(e.key===wa.ESCAPE)return d(e),!0;if(e.key===wa.ALT)return m(!0),!0;if(e.key===wa.I)return m(),!0;let c=ln({color:n,palette:t});if(e.key===wa.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[w,v])=>(v&&E.push(w),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,y=u[x];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([w,v])=>Array.isArray(v)?v.includes(n):v===n?w:null)||r(m6.black)),e.preventDefault(),e.stopPropagation(),!0}if(p6({e,colorObj:c,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=Sp(e.key,p,Zr);if(u!==void 0)return r(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=Sp(e.key,f,u.length);if(b!==void 0){let x=u[b],y=t[x];return r(Array.isArray(y)?y[s]:y),!0}}if(o==="custom"){let p=n!=null?i.indexOf(n):0,u=Sp(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as $n,jsxs as As}from"react/jsx-runtime";var lx=kp.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[d]=kp.useState(()=>t==="canvasBackground"?[]:jb(n,t,r)),[c,p]=le(Gt),u=ln({color:e,palette:r});Mp(()=>{if(!c){let y=!!e&&wp({color:e,palette:r}),E=y&&!d.includes(e);p(E?null:y?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,r,p,u,d]);let[f,b]=h6(u?.shade??(t==="elementBackground"?g6:f6));Mp(()=>{u?.shade!=null&&b(u.shade);let y=E=>{E.key===b6.ALT&&l(!1)};return document.addEventListener(ax.KEYUP,y,{capture:!0}),()=>{document.removeEventListener(ax.KEYUP,y,{capture:!0})}},[u,l]);let x=kp.useRef(null);return u6(m,()=>x.current),Mp(()=>{x?.current?.focus()},[]),$n("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:As("div",{ref:x,onKeyDown:y=>{ix({event:y,activeColorPickerSection:c,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(y.preventDefault(),y.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&As("div",{children:[$n(Kr,{children:g("colorPicker.mostUsedCustomColors")}),$n(tx,{colors:d,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),As("div",{children:[$n(Kr,{children:g("colorPicker.colors")}),$n(ox,{color:e,palette:r,onChange:o,activeShade:f})]}),As("div",{children:[$n(Kr,{children:g("colorPicker.shades")}),$n(rx,{color:e,onChange:o,palette:r})]}),a]})})});import x6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as E6,DEFAULT_CANVAS_BACKGROUND_PICKS as y6,DEFAULT_ELEMENT_BACKGROUND_PICKS as w6,DEFAULT_ELEMENT_STROKE_PICKS as v6}from"@excalidraw/common";import{jsx as Pp}from"react/jsx-runtime";var sx=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=v6),o==="elementBackground"&&(r=w6),o==="canvasBackground"&&(r=y6),n&&(r=n),r?Pp("div",{className:"color-picker__top-picks",children:r.map(i=>Pp("button",{className:x6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!sn(i,E6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Pp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Lt,jsxs as Ds}from"react/jsx-runtime";var cx=e=>{let o=new Option().style;return o.color=e,!!o.color},ex=e=>I6(e)?e:cx(`#${e}`)?`#${e}`:cx(e)?e:null,C6=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=px,updateData:a,getOpenPopup:l,appState:s})=>{let{container:m}=Ne(),[,d]=le(Gt),[c,p]=le(rn),u=Ds("div",{children:[Lt(Kr,{children:g("colorPicker.hexCode")}),Lt(Qb,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),f=mx(null),b=()=>{f.current?.focus()};return Lt(_o,{container:m,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{b(),x.preventDefault()},onPointerDownOutside:x=>{c&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),d(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?Lt(lx,{ref:f,palette:i,color:o,onChange:x=>{let y=s.editingTextElement?Ps():null;t(x),s.editingTextElement&&y&&ba(y)},onEyeDropperToggle:x=>{p(y=>x?(y=y||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},y.keepOpenOnAlt=!0,y):x===!1||y?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{c?p(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:u}):u})},S6=({label:e,color:o,type:t,compactMode:n=!1,mode:r="background",onToggle:i,editingTextElement:a})=>{let l=s=>{s.preventDefault(),s.stopPropagation(),a&&Zb(),i()};return Ds(_s.Trigger,{type:"button",className:dx("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!sn(o,Lp)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:l,children:[Lt("div",{className:"color-picker__button-outline",children:!o&&m0}),n&&o&&Lt("div",{className:"color-picker__button-background",children:r==="background"?Lt("span",{style:{color:o&&sn(o,Lp)?"#fff":"#111"},children:Ab}):Lt("span",{style:{color:o&&sn(o,Lp)?"#fff":"#111"},children:Db})})]})},va=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=px,topPicks:a,updateData:l,appState:s,compactMode:m=!1})=>{let d=mx(s.openPopup);return T6(()=>{d.current=s.openPopup},[s.openPopup]),Lt("div",{children:Ds("div",{role:"dialog","aria-modal":"true",className:dx("color-picker-container",{"color-picker-container--no-top-picks":m}),children:[!m&&Lt(sx,{activeColor:o,onChange:t,type:e,topPicks:a}),!m&&Lt(Cs,{}),Ds(_s.Root,{open:s.openPopup===e,onOpenChange:c=>{c&&l({openPopup:e})},children:[Lt(S6,{color:o,label:n,type:e,compactMode:m,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Lt(C6,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>d.current,appState:s})]})]})})};import*as vx from"@radix-ui/react-popover";import e4 from"clsx";import t4,{useCallback as o4,useMemo as n4}from"react";import{FONT_FAMILY as Np}from"@excalidraw/common";import X6,{useMemo as cn,useState as K6,useRef as Z6,useEffect as $6,useCallback as fx}from"react";import{arrayToList as j6,debounce as q6,FONT_FAMILY as jn,getFontFamilyString as J6}from"@excalidraw/common";import k6 from"clsx";import M6 from"react";import{jsx as P6,jsxs as L6}from"react/jsx-runtime";var Rs=M6.forwardRef(({className:e,placeholder:o,onChange:t},n)=>L6("div",{className:k6("QuickSearch__wrapper",e),children:[Pt,P6("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import A6 from"clsx";import{Children as D6}from"react";import{jsx as ux}from"react/jsx-runtime";var Ns=({className:e,placeholder:o,children:t})=>{let n=!D6.count(t);return ux("div",{className:A6("ScrollableList__wrapper",e),role:"menu",children:n?ux("div",{className:"empty",children:o}):t})};import{jsx as _6,jsxs as R6}from"react/jsx-runtime";var hx=({children:e,className:o="",style:t,title:n})=>R6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&_6("p",{className:"dropdown-menu-group-title",children:n}),e]}),Ta=hx;hx.displayName="DropdownMenuGroup";import{useEffect as Y6,useRef as W6}from"react";import{THEME as V6}from"@excalidraw/common";import{jsx as N6}from"react/jsx-runtime";var Ia=({children:e,...o})=>N6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as F6,jsx as Bs,jsxs as O6}from"react/jsx-runtime";var B6=({textStyle:e,icon:o,shortcut:t,children:n})=>{let r=de();return O6(F6,{children:[o&&Bs("div",{className:"dropdown-menu-item__icon",children:o}),Bs("div",{style:e,className:"dropdown-menu-item__text",children:Bs(Ia,{children:n})}),t&&!r.editor.isMobile&&Bs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Fs=B6;import z6,{useContext as H6}from"react";import{EVENT as G6,composeEventHandlers as U6}from"@excalidraw/common";var Ap=z6.createContext({}),Os=(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(),zs=(e,o)=>{let t=H6(Ap);return U6(e,n=>{let r=new CustomEvent(G6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as Dp}from"react/jsx-runtime";var _p=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:d,...c})=>{let p=zs(d,m),u=W6(null);return Y6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Dp("button",{...c,ref:u,value:o,onClick:p,className:Os(i,l,a),title:c.title??c["aria-label"],children:Dp(Fs,{textStyle:s,icon:e,shortcut:r,children:n})})};_p.displayName="DropdownMenuItem";var $r={GREEN:"green",RED:"red",BLUE:"blue"},Hs=({type:e=$r.BLUE,children:o})=>{let{theme:t}=bo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===V6.LIGHT?"1.5px solid white":"none"};switch(e){case $r.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case $r.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case $r.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Dp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Hs.displayName="DropdownMenuItemBadge";_p.Badge=Hs;var pt=_p;import{KEYS as jr}from"@excalidraw/common";var gx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[jr.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===jr.F)return o.current?.focus(),!0;if(e.key===jr.ESCAPE)return r(),!0;if(e.key===jr.ENTER)return t?.value&&i(t.value),!0;if(e.key===jr.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===jr.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as Ca,jsxs as bx}from"react/jsx-runtime";var Q6=e=>{switch(e){case jn.Excalifont:case jn.Virgil:return tn;case jn.Nunito:case jn.Helvetica:return ma;case jn["Lilita One"]:return $0;case jn["Comic Shanns"]:case jn.Cascadia:return ds;default:return ma}},xx=X6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Ne(),s=Be(),{fonts:m}=s,{showDeprecatedFonts:d}=xo(),[c,p]=K6(""),u=Z6(null),f=cn(()=>Array.from(Jo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:F}])=>{let Y={value:k,icon:Q6(k),text:F[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(Y,{deprecated:A.deprecated,badge:{type:$r.RED,placeholder:g("fontList.badge.old")}}),Y}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),b=cn(()=>new Set(m.getSceneFamilies()),[e]),x=cn(()=>f.filter(k=>b.has(k.value)),[f,b]),y=cn(()=>f.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[f,b,d]),E=cn(()=>j6([...x,...y].filter(k=>k.text?.toLowerCase().includes(c))),[x,y,c]),w=cn(()=>{let k;return o?k=E.find(A=>A.value===o):e&&(k=E.find(A=>A.value===e)),!k&&c&&(E[0]?.value?n(E[0].value):r()),k},[o,e,c,E,n,r]),v=fx(k=>{let A=null;if(s.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(A={start:F.selectionStart,end:F.selectionEnd})}t(k),s.state.editingTextElement&&A&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&A&&(F.focus(),F.selectionStart=A.start,F.selectionEnd=A.end)},0)},[t,s.state.editingTextElement]),C=fx(k=>{gx({event:k,inputRef:u,hoveredFont:w,filteredFonts:E,onSelect:v,onHover:n,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[w,E,v,n,a]);$6(()=>(i(),()=>{a()}),[]);let S=cn(()=>E.filter(k=>b.has(k.value)),[E,b]),L=cn(()=>E.filter(k=>!b.has(k.value)),[E,b]),P=(k,A)=>bx(pt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:J6({fontFamily:k.value})},hovered:k.value===w?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:F=>{v(Number(F.currentTarget.value))},onMouseMove:()=>{w?.value!==k.value&&n(k.value)},children:[k.text,k.badge&&Ca(Hs,{type:k.badge.type,children:k.badge.placeholder})]},k.value),B=[];return S.length&&B.push(Ca(Ta,{title:g("fontList.sceneFonts"),children:S.map(P)},"group_1")),L.length&&B.push(Ca(Ta,{title:g("fontList.availableFonts"),children:L.map((k,A)=>P(k,A+S.length))},"group_2")),bx(_o,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[Ca(Rs,{ref:u,placeholder:g("quickSearch.placeholder"),onChange:q6(p,20)}),Ca(Ns,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:B.length?B:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Ex from"@radix-ui/react-popover";import{jsx as Rp}from"react/jsx-runtime";var yx=({selectedFontFamily:e,isOpened:o=!1})=>{let t=ae();return Rp(Ex.Trigger,{asChild:!0,children:Rp("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Rp(Yr,{standalone:!0,icon:Ar,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{t(n=>({openPopup:n.openPopup==="fontFamily"?null:n.openPopup}))},style:{border:"none"}})})})};import{jsx as Sa,jsxs as wx}from"react/jsx-runtime";var Tx=[{value:Np.Excalifont,icon:tn,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Np.Nunito,icon:ma,text:g("labels.normal"),testId:"font-family-normal"},{value:Np["Comic Shanns"],icon:ds,text:g("labels.code"),testId:"font-family-code"}],b$=new Set(Tx.map(e=>e.value));var Ix=t4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=n4(()=>Tx,[]),m=o4(d=>{d&&n(d)},[n]);return wx("div",{role:"dialog","aria-modal":"true",className:e4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Sa("div",{className:"buttonList",children:Sa(Ht,{type:"button",options:s,value:o,onClick:m})}),!l&&Sa(Cs,{}),wx(vx.Root,{open:e,onOpenChange:a,children:[Sa(yx,{selectedFontFamily:o,isOpened:e}),e&&Sa(xx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:m,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as qr from"@radix-ui/react-popover";import l4 from"clsx";import Gs,{useEffect as s4}from"react";import{isArrowKey as c4,KEYS as Ro}from"@excalidraw/common";import{jsx as r4}from"react/jsx-runtime";var dn=({icon:e})=>r4("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 a4,jsx as Cx,jsxs as Sx}from"react/jsx-runtime";var i4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>Sx(a4,{children:[Sx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Cx(dn,{icon:o?Mb:fs})]}),o&&Cx("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),ka=i4;import{jsx as qn,jsxs as Bp}from"react/jsx-runtime";var d4=he(!1);function m4({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=de(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)n(f.value),u.preventDefault();else if(u.key===Ro.TAB){let b=e.findIndex(y=>y.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(c4(u.key)){let b=Do().rtl,x=e.findIndex(y=>y.value===o);if(x!==-1){let y=e.length,E=x;switch(u.key){case(b?Ro.ARROW_LEFT:Ro.ARROW_RIGHT):E=(x+1)%y;break;case(b?Ro.ARROW_RIGHT:Ro.ARROW_LEFT):E=(y+x-1)%y;break;case Ro.ARROW_DOWN:{E=(x+(i??1))%y;break}case Ro.ARROW_UP:{E=(y+x-(i??1))%y;break}}n(e[E].value)}u.preventDefault()}else(u.key===Ro.ESCAPE||u.key===Ro.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=le(d4),d=Gs.useMemo(()=>e.slice(0,i),[e,i]),c=Gs.useMemo(()=>e.slice(i),[e,i]);s4(()=>{d.some(u=>u.value===o)||m(!0)},[o,d,m]);let p=u=>qn("div",{className:"picker-content",children:u.map((f,b)=>Bp("button",{type:"button",className:l4("picker-option",{active:o===f.value}),onClick:x=>{n(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&qn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return qn(qr.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(d),c.length>0&&qn(ka,{label:g("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function Fp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Gs.useState(!1),s=Gs.useRef(null);return qn("div",{children:Bp(qr.Root,{open:a,onOpenChange:m=>l(m),children:[qn(qr.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&qn(m4,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import kx,{useEffect as p4}from"react";import{jsx as Op,jsxs as Mx}from"react/jsx-runtime";var Px=({updateData:e,app:o,testId:t})=>{let n=kx.useRef(null),r=kx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((d,c)=>(d!=null&&d!==c.opacity&&(a=!1),d==null||d>c.opacity?c.opacity:d),l?.opacity??null)??o.state.currentItemOpacity;return p4(()=>{if(n.current&&r.current){let d=n.current,c=r.current,p=d.offsetWidth,u=15,f=m/100*(p-u)+u/2;c.style.left=`${f}px`,d.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),Mx("label",{className:"control-label",children:[g("labels.opacity"),Mx("div",{className:"range-wrapper",children:[Op("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:d=>{e(+d.target.value)},value:m,className:"range-input","data-testid":t}),Op("div",{className:"value-bubble",ref:r,children:m!==0?m:null}),Op("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Fx,jsx as ee,jsxs as ht}from"react/jsx-runtime";var Bx=.1,ut=(e,o,t,n=!1)=>{let r=Wp(j(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},at=function(e,o,t,n,r){let i=o.state.editingTextElement,a=Rx(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let m=o.scene.getSelectedElements(o.state),d=n===!0?m:m.filter(c=>n(c));l=M4(d,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},B4=(e,o,t)=>A4(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}),Vp=(e,o,t,n,r)=>{let i=new Set,a=ut(e,o,l=>{if(wt(l)){let s=n(l);i.add(s);let m=Ze(l,{fontSize:s});return Ma(m,t.scene.getContainerElement(l),t.scene),m=B4(l,m,t.scene),m}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{wt(l)&&L4(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:$e.IMMEDIATELY}},F4=N({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ut(e,o,n=>_4(n.type)?Ze(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?$e.IMMEDIATELY:$e.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht(Fx,{children:[o.stylesPanelMode==="full"&&ee("h3",{"aria-hidden":"true",children:g("labels.stroke")}),ee(va,{topPicks:E4,palette:x4,type:"elementStroke",label:g("labels.stroke"),color:at(e,n,i=>i.strokeColor,!0,i=>i?null:o.currentItemStrokeColor),onChange:i=>t({currentItemStrokeColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),O4=N({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:$e.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!k4(t.currentItemBackgroundColor)&&i.every(l=>Dx(l)&&P4(l.points))){let l=Wp(i);r=e.map(s=>l.has(s.id)&&Dx(s)?Ze(s,{backgroundColor:t.currentItemBackgroundColor,...N4(s,!0)}):s)}else r=ut(e,o,l=>Ze(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:$e.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht(Fx,{children:[o.stylesPanelMode==="full"&&ee("h3",{"aria-hidden":"true",children:g("labels.background")}),ee(va,{topPicks:b4,palette:f4,type:"elementBackground",label:g("labels.background"),color:at(e,n,i=>i.backgroundColor,!0,i=>i?null:o.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})]})}),z4=N({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(re("element","changeFillStyle",`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:ut(e,o,r=>Ze(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=j(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ht("fieldset",{children:[ee("legend",{children:g("labels.fill")}),ee("div",{className:"buttonList",children:ee(Ht,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${C4("Alt-Click")})`,icon:i?y0:w0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:v0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:T0,testId:"fill-solid"}],value:at(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),H4=N({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"stroke-width",options:[{value:Gp.thin,text:g("labels.thin"),icon:op,testId:"strokeWidth-thin"},{value:Gp.bold,text:g("labels.bold"),icon:I0,testId:"strokeWidth-bold"},{value:Gp.extraBold,text:g("labels.extraBold"),icon:C0,testId:"strokeWidth-extraBold"}],value:at(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),G4=N({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{seed:T4(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:M0},{value:1,text:g("labels.artist"),icon:P0},{value:2,text:g("labels.cartoonist"),icon:L0}],value:at(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Ej=N({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:op},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:S0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:k0}],value:at(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),U4=N({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ze(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ee(Px,{updateData:o,app:e,testId:"opacity"})}),Y4=N({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ee("legend",{children:g("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:V0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:X0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:K0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:Z0,testId:"fontSize-veryLarge"}],value:at(e,n,i=>{if(wt(i))return i.fontSize;let a=mn(i,n.scene.getNonDeletedElementsMap());return a?a.fontSize:null},i=>wt(i)||mn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:o.currentItemFontSize||w4),onChange:i=>{xa(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}),Xp=N({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Kn,trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,r=>Math.round(1/(1+Bx)*r.fontSize)),keyTest:e=>e[Jr.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Jr.CHEVRON_LEFT||e.key===Jr.COMMA)}),Kp=N({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Kn,trackEvent:!1,perform:(e,o,t,n)=>Vp(e,o,n,r=>Math.round(r.fontSize*(1+Bx))),keyTest:e=>e[Jr.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Jr.CHEVRON_RIGHT||e.key===Jr.PERIOD)}),W4=N({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let x=r?.get(b.id);return x?Ze(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:$e.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,d=$e.EVENTUALLY,c,p=!1;if(s)c=s,d=$e.IMMEDIATELY;else if(m){c=m,d=$e.EVENTUALLY;let f=j(e,o,{includeBoundTextElement:!0}).filter(b=>wt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let y=f[b];x+=y?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:d};if(c&&!p){let f=new Map,b=new Set,x=!1,y=Array.from(Jo.loadedFontsCache.values()),E=Object.entries(v4).find(([C,S])=>S===c)?.[0];m&&E&&y.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:ut(e,o,C=>{if(wt(C)&&(C.fontFamily!==c||s)){let S=Ze(C,{fontFamily:c,lineHeight:S4(c)}),L=r?.get(C.containerId||"")||{},P=n.scene.getContainerElement(C);return a&&P&&L&&n.scene.mutateElement(P,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,P),S}return C},!0)});let w=`10px ${I4({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(w,v))for(let[C,S]of f)Ma(C,S,n.scene);else window.document.fonts.load(w,v).then(C=>{for(let[S,L]of f){let P=n.scene.getElement(S.id),B=L?n.scene.getElement(L.id):null;P&&Ma(P,B,n.scene)}n.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n,data:r})=>{let i=Hp(new Map),a=Hp(null),[l,s]=g4({}),m=Hp(!0),d=h4(()=>{let c=(p,u)=>at(p,t,f=>{if(wt(f))return f.fontFamily;let b=mn(f,u);return b?b.fontFamily:null},f=>wt(f)||mn(f,u)!==null,f=>f?null:o.currentItemFontFamily||y4);return l.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(i.current?.values()??[]),i.current):!l.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):a.current},[l.openPopup,o,e,t]);return zp(()=>{a.current=d},[d]),zp(()=>{Object.keys(l).length&&(n(l),s({}))},[l]),zp(()=>(m.current=!1,()=>{m.current=!0}),[]),ht("fieldset",{children:[o.stylesPanelMode==="full"&&ee("legend",{children:g("labels.fontFamily")}),ee(Ix,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:d,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:o.stylesPanelMode==="compact",onSelect:c=>{xa(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),i.current.clear()},o.stylesPanelMode==="compact",!!o.editingTextElement)},onHover:c=>{s({currentHoveredFontFamily:c,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:c=>{if(c){i.current.clear();let{editingTextElement:p}=o;if(p?.type==="text"){let u=t.scene.getElement(p.id);i.current.set(p.id,Ze(u||p,{},!0))}else{let u=j(e,o,{includeBoundTextElement:!0});for(let f of u)i.current.set(f.id,Ze(f,{},!0))}s({...l,openPopup:"fontFamily"})}else{let p={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...p}),i.current.clear(),o.stylesPanelMode==="compact"&&o.editingTextElement&&ba(null)}}})]})}}),V4=N({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(wt(r)){let i=Ze(r,{textAlign:t});return Ma(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap();return ht("fieldset",{children:[ee("legend",{children:g("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:j0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:q0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:J0,testId:"align-right"}],value:at(e,n,a=>{if(wt(a))return a.textAlign;let l=mn(a,i);return l?l.textAlign:null},a=>wt(a)||mn(a,i)!==null,a=>a?null:o.currentItemTextAlign),onChange:a=>{xa(()=>t(a),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})]})}}),X4=N({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(wt(r)){let i=Ze(r,{verticalAlign:t});return Ma(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(Ht,{group:"text-align",options:[{value:Us.TOP,text:g("labels.alignTop"),icon:ee(Q0,{theme:o.theme}),testId:"align-top"},{value:Us.MIDDLE,text:g("labels.centerVertically"),icon:ee(tb,{theme:o.theme}),testId:"align-middle"},{value:Us.BOTTOM,text:g("labels.alignBottom"),icon:ee(eb,{theme:o.theme}),testId:"align-bottom"}],value:at(e,n,i=>{if(wt(i)&&i.containerId)return i.verticalAlign;let a=mn(i,n.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},i=>wt(i)||mn(i,n.scene.getNonDeletedElementsMap())!==null,i=>i?null:Us.MIDDLE),onChange:i=>{xa(()=>t(i),o.stylesPanelMode==="compact",!!o.editingTextElement,r?.onPreventClose)}})})})}),yj=N({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Nx(n)?n:Ze(n,{roundness:t==="round"?{type:D4(n.type)?Ys.ADAPTIVE_RADIUS:Ys.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ea(Rx(e),o).some(l=>l.roundness?.type===Ys.LEGACY);return ht("fieldset",{children:[ee("legend",{children:g("labels.edges")}),ht("div",{className:"buttonList",children:[ee(Ht,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:A0},{value:"round",text:g("labels.round"),icon:D0}],value:at(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!Ws(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),_x=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:_0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(R0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:ee(O0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:ee(z0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:ee(N0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(B0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:ee(H0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:ee(G0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:ee(F0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:ee(Y0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:ee(U0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:ee(W0,{flip:e}),keyBinding:"v"}],wj=N({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>{if(Yp(n)){let{position:r,type:i}=t;if(r==="start")return Ze(n,{startArrowhead:i});if(r==="end")return Ze(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:$e.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Do().rtl;return ht("fieldset",{children:[ee("legend",{children:g("labels.arrowheads")}),ht("div",{className:"iconSelectList buttonList",children:[ee(Fp,{label:"arrowhead_start",options:_x(!r),value:at(e,n,i=>Yp(i)&&vr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),ee(Fp,{label:"arrowhead_end",group:"arrowheads",options:_x(!!r),value:at(e,n,i=>Yp(i)&&vr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),K4=N({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>ht("div",{className:"selected-shape-actions",children:[r("changeArrowType"),r("changeArrowhead")]})}),vj=N({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ut(e,o,l=>{if(!Ws(l))return l;let s=Ze(l,{roundness:t===No.round?{type:Ys.PROPORTIONAL_RADIUS}:null,elbowed:t===No.elbow,points:t===No.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Nx(s)){s.fixedSegments=null;let m=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let d=Up.getPointAtIndexGlobalCoordinates(s,0,m),c=Up.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Ax(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...Ax(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...R4(s,m,{points:[d,c].map(x=>u4(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=n.scene.getNonDeletedElementsMap();if(s.startBinding){let d=m.get(s.startBinding.elementId);d&&Lx(s,d,"start",n.scene)}if(s.endBinding){let d=m.get(s.endBinding.elementId);d&&Lx(s,d,"end",n.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new Up(l,Wp(e)))}return{elements:r,appState:i,captureUpdate:$e.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ht("fieldset",{children:[ee("legend",{children:g("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(Ht,{group:"arrowtypes",options:[{value:No.sharp,text:g("labels.arrowtype_sharp"),icon:Fr,testId:"sharp-arrow"},{value:No.round,text:g("labels.arrowtype_round"),icon:zr,testId:"round-arrow"},{value:No.elbow,text:g("labels.arrowtype_elbowed"),icon:Or,testId:"elbow-arrow"}],value:at(e,n,r=>Ws(r)?r.elbowed?No.elbow:r.roundness?No.round:No.sharp:null,r=>Ws(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Jp,roundToStep as ek}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as tk,CURSOR_TYPE as Ux,MAX_ZOOM as Yx,MIN_ZOOM as Wx,THEME as Pa,ZOOM_STEP as Qp,getShortcutKey as Vx,updateActiveTool as ei,CODES as yo,KEYS as Fo}from"@excalidraw/common";import{getNonDeletedElements as ok}from"@excalidraw/element";import{newElementWith as nk}from"@excalidraw/element";import{getCommonBounds as rk}from"@excalidraw/element";import{CaptureUpdateAction as to}from"@excalidraw/element";import{useEffect as Z4}from"react";import{jsx as j4}from"react/jsx-runtime";var Qr=()=>{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},Zp=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},$4=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Zp(o,r)},At=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(Z4(()=>()=>Qr().classList.remove("excalidraw-tooltip--visible"),[]),r?null:j4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>$4(i.currentTarget,Qr(),o,t),onPointerLeave:()=>Qr().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import Vs from"open-color";import{CURSOR_TYPE as $p,MIME_TYPES as jp,THEME as zx}from"@excalidraw/common";var Hx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',q4='<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"/>',Gx='<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"/>',J4=`data:${jp.svg},${encodeURIComponent(`${Hx}${Gx}</svg>`)}`,Q4=`data:${jp.svg},${encodeURIComponent(`${Hx}${q4}${Gx}</svg>`)}`,Ut=e=>{e&&(e.style.cursor="")},ye=(e,o)=>{e&&(e.style.cursor=o)},Eo,Ox,qp=(e,o)=>{let n=()=>{let r=o===zx.DARK;Eo=document.createElement("canvas"),Eo.theme=o,Eo.height=20,Eo.width=20;let i=Eo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Eo.width/2,Eo.height/2,5,0,2*Math.PI),i.fillStyle=r?Vs.black:Vs.white,i.fill(),i.strokeStyle=r?Vs.white:Vs.black,i.stroke(),Ox=Eo.toDataURL(jp.svg)};(!Eo||Eo.theme!==o)&&n(),ye(e,`url(${Ox}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Ut(e);else if(Qt(o))e.style.cursor=$p.GRAB;else if(yt(o))qp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===zx.LIGHT?J4:Q4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=$p.AUTO):e.style.cursor=$p.CROSSHAIR};var Bo=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),m=-(r-r/t),d=-(i-i/t);return{scrollX:l+m,scrollY:s+d,zoom:{value:t}}};import{jsx as $s,jsxs as sk}from"react/jsx-runtime";var ik=N({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?to.IMMEDIATELY:to.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>$s(va,{palette:null,topPicks:tk,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t,compactMode:o.stylesPanelMode==="compact"})}),Oo=N({name:"clearCanvas",label:"labels.clearCanvas",icon:Mt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>nk(r,{isDeleted:!0})),appState:{...Qo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.defaultSelectionTool}:o.activeTool},captureUpdate:to.IMMEDIATELY})}),Xs=N({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Om,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(o.zoom.value+Qp)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Om,title:`${g("buttons.zoomIn")} \u2014 ${Vx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Yx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===yo.EQUAL||e.code===yo.NUM_ADD)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),Ks=N({name:"zoomOut",label:"buttons.zoomOut",icon:zm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(o.zoom.value-Qp)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(Z,{type:"button",className:"zoom-out-button zoom-button",icon:zm,title:`${g("buttons.zoomOut")} \u2014 ${Vx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Wx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===yo.MINUS||e.code===yo.NUM_SUBTRACT)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),Zs=N({name:"resetZoom",label:"buttons.resetZoom",icon:n0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Bo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:ho(1)},o),userToFollow:null},captureUpdate:to.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>$s(At,{label:g("buttons.resetZoom"),style:{height:"100%"},children:sk(Z,{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===yo.ZERO||e.code===yo.NUM_ZERO)&&(e[Fo.CTRL_OR_CMD]||e.shiftKey)}),ak=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,m=a-r,d=o.height/m,p=Math.min(s,d)*Jp(t,.1,1);return Math.min(p,1)},Xx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Jp(r,Wx,Yx);let[l,s,m,d]=e,c=(l+m)/2,p=(s+d)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,y=o.width-u-b,E=o.height-f-x,w;if(n){let S=m-l,L=d-s;w=Math.min(y/S,E/L)*r}else w=ak(e,{width:y,height:E},r);let v=ho(Jp(ek(w,Qp,"floor"),i,a)),C=h1({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:to.EVENTUALLY}},La=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=rk(ok(o));return Xx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},rq=N({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:gs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return La({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===yo.TWO&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),iq=N({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:gs,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return La({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===yo.THREE&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),lk=N({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:gs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>La({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===yo.ONE&&e.shiftKey&&!e.altKey&&!e[Fo.CTRL_OR_CMD]}),Jn=N({name:"toggleTheme",label:(e,o)=>o.theme===Pa.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===Pa.LIGHT?sa:ca,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Pa.LIGHT?Pa.DARK:Pa.LIGHT)},captureUpdate:to.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===yo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),aq=N({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return yt(o)?r=ei(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):r=ei(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.IMMEDIATELY}},keyTest:e=>e.key===Fo.E}),lq=N({name:"toggleLassoTool",label:"toolBar.lasso",icon:aa,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.defaultSelectionTool!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ei(o,{type:"lasso",fromSelection:!1}),ye(n.interactiveCanvas,Ux.CROSSHAIR)):r=ei(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.NEVER}}}),Kx=N({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:ps,viewMode:!1,perform:(e,o,t,n)=>{let r;return Qt(o)?r=ei(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ei(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ye(n.interactiveCanvas,Ux.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:to.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Fo.CTRL_OR_CMD]&&e.key===Fo.H});import{updateActiveTool as Zx}from"@excalidraw/common";import{CaptureUpdateAction as ck}from"@excalidraw/element";var dk=N({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Zx(o,{type:"embeddable"});return Dt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Zx(o,{type:"embeddable"})},captureUpdate:ck.EVENTUALLY}}});import{pointFrom as mk}from"@excalidraw/math";import{maybeBindLinearElement as pk,bindOrUnbindLinearElement as $x,isBindingEnabled as uk}from"@excalidraw/element/binding";import{isValidPolygon as jx,LinearElementEditor as Aa,newElementWith as eu}from"@excalidraw/element";import{isBindingElement as js,isFreeDrawElement as qx,isLinearElement as Jx,isLineElement as qs}from"@excalidraw/element";import{KEYS as tu,arrayToMap as ou,tupleToCoors as hk,updateActiveTool as Qx}from"@excalidraw/common";import{isPathALoop as gk}from"@excalidraw/element";import{isInvisiblySmallElement as nu}from"@excalidraw/element";import{CaptureUpdateAction as ru}from"@excalidraw/element";import{jsx as fk}from"react/jsx-runtime";var _t=N({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Aa.handlePointerUp(l,o.selectedLinearElement,o,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(js(x)&&$x(x,f,b,n.scene),u!==o.selectedLinearElement){let y=e;return x&&nu(x)&&(y=y.map(E=>E.id===x.id?eu(E,{isDeleted:!0}):E)),{elements:y,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:ru.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Aa.getElement(u,m);if(x)return js(x)&&$x(x,f,b,a),qs(x)&&!jx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||nu(x)?e.map(y=>y.id===x.id?eu(y,{isDeleted:!0}):y):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Aa(x,ou(m),!1)},captureUpdate:ru.IMMEDIATELY}}let d=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||js(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.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&&nu(c)&&(d=d.map(u=>u.id===c?.id?eu(u,{isDeleted:!0}):u)),Jx(c)||qx(c)){let u=gk(c.points,o.zoom.value);if(u&&(qs(c)||qx(c))){let f=c.points,b=f[0],x=f.map((y,E)=>E===f.length-1?mk(b[0],b[1]):y);qs(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(qs(c)&&!jx(c.points)&&a.mutateElement(c,{polygon:!1}),js(c)&&!u&&c.points.length>1&&uk(o)){let f=s??hk(Aa.getPointAtIndexGlobalCoordinates(c,-1,ou(e)));pk(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Ut(r);let p;return o.activeTool.type==="eraser"?p=Qx(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=Qx(o,{type:n.defaultSelectionTool}),{elements:d,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&&Jx(c)?new Aa(c,ou(d)):o.selectedLinearElement},captureUpdate:ru.IMMEDIATELY}},keyTest:(e,o)=>e.key===tu.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===tu.ESCAPE||e.key===tu.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>fk(Z,{type:"button",icon:u0,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ni,DEFAULT_EXPORT_PADDING as aM,EXPORT_SCALES as lM,THEME as lu}from"@excalidraw/common";import{getNonDeletedElements as sM}from"@excalidraw/element";import{CaptureUpdateAction as io}from"@excalidraw/element";import bk from"clsx";import{jsx as eE,jsxs as xk}from"react/jsx-runtime";var Da=({children:e,checked:o,onChange:t,className:n})=>xk("div",{className:bk("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[eE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:l0}),eE("div",{className:"Checkbox-label",children:e})]});import{THEME as _a}from"@excalidraw/common";import{jsx as Ra}from"react/jsx-runtime";var oE=e=>{let o=e.title||(e.value===_a.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ra(Z,{type:"icon",icon:e.value===_a.LIGHT?tE.MOON:tE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===_a.DARK?_a.LIGHT:_a.DARK),"data-testid":"toggle-dark-mode"})},tE={SUN:Ra("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ra("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:Ra("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ra("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 Ek}from"react";import{focusNearestParent as yk,KEYS as wk}from"@excalidraw/common";import{jsx as nE,jsxs as vk}from"react/jsx-runtime";var rE=e=>{let{id:o}=Ne(),[t,n]=Ek(e.value),r=a=>{e.ignoreFocus||yk(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===wk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return vk("div",{className:"ProjectName",children:[nE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),nE("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as qk,DEFAULT_FILENAME as Jk,IMAGE_MIME_TYPES as yE,isFirefox as Qk,MIME_TYPES as eM,cloneJSON as tM,SVG_DOCUMENT_PREAMBLE as oM}from"@excalidraw/common";import{getNonDeletedElements as nM}from"@excalidraw/element";import{isFrameLikeElement as rM}from"@excalidraw/element";import{getElementsOverlappingFrame as iM}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as _k,EXPORT_DATA_TYPES as Fa,MIME_TYPES as no,arrayToMap as Rk,isMemberOf as Nk,isPromiseLike as Bk,EVENT as ec}from"@excalidraw/common";import{mutateElement as Fk}from"@excalidraw/element";import{deepCopyElement as Ok}from"@excalidraw/element";import{isFrameLikeElement as zk,isInitializedImageElement as Hk}from"@excalidraw/element";import{getContainingFrame as gE}from"@excalidraw/element";import{pointFrom as pn}from"@excalidraw/math";import{COLOR_PALETTE as aE,DEFAULT_CHART_COLOR_INDEX as Tk,getAllColorsSpecificShade as Ik,DEFAULT_FONT_FAMILY as Ck,DEFAULT_FONT_SIZE as lE,VERTICAL_ALIGN as Sk,randomId as sE,isDevEnv as cE}from"@excalidraw/common";import{newTextElement as Js,newLinearElement as Ba,newElement as au}from"@excalidraw/element";var oo=32,Te=12,un=256,dE=50,Qn="NOT_SPREADSHEET",ti="VALID_SPREADSHEET",Na=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},iu=(e,o)=>e.slice(1).every(t=>Na(t[o])!==null),iE=e=>{let o=e[0].length;if(o>2)return{type:Qn,reason:"More than 2 columns"};if(o===1){if(!iu(e,0))return{type:Qn,reason:"Value is not numeric"};let s=Na(e[0][0])===null,m=(s?e.slice(1):e).map(d=>Na(d[0]));return m.length<2?{type:Qn,reason:"Less than two rows"}:{type:ti,spreadsheet:{title:s?e[0][0]:null,labels:null,values:m}}}let t=iu(e,0),n=iu(e,1);if(!t&&!n)return{type:Qn,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=Na(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Qn,reason:"Less than 2 rows"}:{type:ti,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>Na(s[i]))}}},kk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},mE=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:xi,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:xi,reason:"All rows don't have same number of columns"};let n=Yy(o);if(n.type!==ya){let i=Yy(A4(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}},_4=(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"}))||[],D4=(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]},P4=(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]:[],..._4(e,o,t,r,n),...D4(e,o,t,r,n),...P4(e,o,t,r,n)]},R4=(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())]},N4=(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"?N4(o,t,r):R4(o,t,r);var zF="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,O4=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},B4=({elements:e,files:o})=>{let t=ee(e),r=new Set(e.filter(l=>ie(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(oi(l,t)&&!r.has(oi(l,t))){let s=io(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(B4({elements:e,files:o}),t)},z4=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 F4=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(js(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},H4=async(e,o=!1)=>{try{let t=!o&&e&&F4(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 H4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&z4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Qr.excalidrawClipboardWithAPI;if(O4(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(!U4(e))throw new Error("Error copying to clipboard.")},U4=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 Ei=(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&&ie(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)}},yi=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-CZ2OEVDB.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:wl(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:Qn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Qn,reason:"All rows don't have same number of columns"};let r=iE(o);if(r.type!==ti){let i=iE(kk(o));if(i.type===ti)return i}return r},Qs=Ik(Tk),Yt={fillStyle:"hachure",fontFamily:Ck,fontSize:lE,opacity:100,roughness:1,strokeColor:aE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Sk.MIDDLE,locked:!1},pE=e=>{let o=(oo+Te)*e.values.length+Te,t=un+Te*2;return{chartWidth:o,chartHeight:t}},Mk=(e,o,t,n,r)=>e.labels?.map((i,a)=>Js({groupIds:[n],backgroundColor:r,...Yt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(oo+Te)+Te*2,y:t+Te/2,width:oo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],Pk=(e,o,t,n,r)=>{let i=Js({groupIds:[n],backgroundColor:r,...Yt,x:o-Te,y:t-Te,text:"0",textAlign:"right"}),a=Js({groupIds:[n],backgroundColor:r,...Yt,x:o-Te,y:t-un-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},Lk=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:a}=pE(e),l=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t,width:i,points:[pn(0,0),pn(i,0)]}),s=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t,height:a,points:[pn(0,0),pn(0,-a)]}),m=Ba({backgroundColor:r,groupIds:[n],...Yt,type:"line",x:o,y:t-un-Te,strokeStyle:"dotted",width:i,opacity:dE,points:[pn(0,0),pn(i,0)]});return[l,s,m]},uE=(e,o,t,n,r,i)=>{let{chartWidth:a,chartHeight:l}=pE(e),s=e.title?Js({backgroundColor:r,groupIds:[n],...Yt,text:e.title,x:o+a/2,y:t-un-Te*2-lE,roundness:null,textAlign:"center"}):null,m=i?au({backgroundColor:r,groupIds:[n],...Yt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:aE.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...s?[s]:[],...Mk(e,o,t,n,r),...Pk(e,o,t,n,r),...Lk(e,o,t,n,r)]},Ak=(e,o,t)=>{let n=Math.max(...e.values),r=sE(),i=Qs[Math.floor(Math.random()*Qs.length)];return[...e.values.map((l,s)=>{let m=l/n*un;return au({backgroundColor:i,groupIds:[r],...Yt,type:"rectangle",x:o+s*(oo+Te)+Te,y:t-m-Te,width:oo,height:m})}),...uE(e,o,t,r,i,cE())]},Dk=(e,o,t)=>{let n=Math.max(...e.values),r=sE(),i=Qs[Math.floor(Math.random()*Qs.length)],a=0,l=[];for(let b of e.values){let x=a*(oo+Te),y=-(b/n)*un;l.push([x,y]),a++}let s=Math.max(...l.map(b=>b[0])),m=Math.max(...l.map(b=>b[1])),d=Math.min(...l.map(b=>b[0])),c=Math.min(...l.map(b=>b[1])),p=Ba({backgroundColor:i,groupIds:[r],...Yt,type:"line",x:o+Te+oo/2,y:t-Te,height:m-c,width:s-d,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let y=x*(oo+Te)+Te/2,E=-(b/n)*un+Te/2;return au({backgroundColor:i,groupIds:[r],...Yt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+y+oo/2,y:t+E-Te*2,width:Te,height:Te})}),f=e.values.map((b,x)=>{let y=x*(oo+Te)+Te/2,E=b/n*un+Te/2+Te;return Ba({backgroundColor:i,groupIds:[r],...Yt,type:"line",x:o+y+oo/2+Te/2,y:t-E,height:E,strokeStyle:"dotted",opacity:dE,points:[pn(0,0),pn(0,E)]})});return[...uE(e,o,t,r,i,cE()),p,...f,...u]},hE=(e,o,t,n)=>e==="line"?Dk(o,t,n):Ak(o,t,n);var yJ="clipboard"in navigator&&"readText"in navigator.clipboard,tc="clipboard"in navigator&&"writeText"in navigator.clipboard,oi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,Gk=e=>!!([Fa.excalidraw,Fa.excalidrawClipboard,Fa.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),fE=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(ec.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r),t.clipboardData?.items.add(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Uk=({elements:e,files:o})=>{let t=Rk(e),n=new Set(e.filter(l=>zk(l))),r=!1,i=e.reduce((l,s)=>(Hk(s)&&(r=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Fa.excalidrawClipboard,elements:e.map(l=>{if(gE(l,t)&&!n.has(gE(l,t))){let s=Ok(l);return Fk(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},oc=async(e,o,t)=>{await ro(Uk({elements:e,files:o}),t)},Yk=e=>{let o=mE(e);return o.type===ti?{spreadsheet:o.spreadsheet}:null};function bE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(bE(t));return o}var Wk=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,no.html),n=bE(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},xE=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[no.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(Nk(_k,n))try{if(n===no.text||n===no.html)e[n]=await(await t.getType(n)).text();else if(A1(n)){let r=await t.getType(n),i=O1(r,n,void 0);e[n]=i}else throw new km(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof km?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},Vk=async(e,o=!1)=>{try{let t=e.findByType(no.html),n=!o&&t&&Wk(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(no.text)??n.value.map(r=>r.value).join(`
5
+ `).trim()}:n:{type:"text",value:(e.getData(no.text)||"").trim()}}catch{return{type:"text",value:""}}},Xk=function(e){return this.find(o=>o.type===e)||null},Kk=function(e){return this.find(t=>t.type===e)?.value??null},Zk=function(){return this.filter(e=>e.kind==="file")},Oa=async e=>{let o;jk(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await F1(n);return r=await ia(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(l=>a(l))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:Xk,getData:Kk,getFiles:Zk})},EE=async(e,o=!1)=>{let t=await Vk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=!o&&Yk(t.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(t.value),r=n.type===Fa.excalidrawClipboardWithAPI;if(Gk(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},nc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[no.png]:e})])}catch(o){if(Bk(e))await navigator.clipboard.write([new window.ClipboardItem({[no.png]:await e})]);else throw o}},ro=async(e,o)=>{if(tc)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(no.text,e||""),o.clipboardData?.getData(no.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!$k(e))throw new Error("Error copying to clipboard.")},$k=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},jk=e=>e.type===ec.PASTE||e.type===ec.COPY||e.type===ec.CUT;var er=(e,{selectedElementIds:o},t)=>{e=nM(e);let n=t&&we(e,{selectedElementIds:o}),r=null,i=n?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&rM(i[0])?(r=i[0],i=iM(e,r)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:tM(i)}},tr=async(e,o,t,n,{exportBackground:r,exportPadding:i=qk,viewBackgroundColor:a,name:l=t.name||Jk,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=Cr(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:m});if(e==="svg")return Mm(c.then(p=>new Blob([oM+p.outerHTML],{type:eM.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[yE.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await ro(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let d=Kl(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let c=Ao(d);return t.exportEmbedScene&&(c=c.then(p=>import("./data/image-JWK7QZ22.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:ta(o,t,n,"local")})))),Mm(c,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[yE.png],fileHandle:s})}else if(e==="clipboard")try{let c=Ao(d);await nc(c)}catch(c){throw console.warn(c),c.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):Qk&&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}=Ei(e,o,!1);return await yi(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as G4,jsx as Hr,jsxs as V4}from"react/jsx-runtime";var wh=H({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=H({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(G4,{children:Fs.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=H({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(Xl,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),Od=H({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})=>V4(Xl,{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})})]})}),vi=H({name:"saveToActiveFile",label:"buttons.save",icon:ui,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}),ql=H({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ui,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=H({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=H({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=H({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&&mt(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=H({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||Rs,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})),ie(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 Y4=H({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"})}),W4=H({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"})}),wi=H({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 K4=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&&!K4(r)&&!uc(r)},Sh=H({name:"group",label:"labels.group",icon:e=>Ca(Nu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=vb(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&&Eb(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=H({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=>{Be(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=ht(o,Ee(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return yb(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 j4 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 Z4(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 Ti=(e,o)=>`hsl(${Math.abs(Z4(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=Ti(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,C=5,S=3,_=e.measureText(w),L=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,N=Math.max(L,12),P=y-1,U=v-1,W=_.width+2+C*2+2,V=N+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,U,W,V,8),e.fillStyle=u,e.fill(),e.strokeStyle=tl,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,U-2,W+4,V+4,8),e.strokeStyle=x,e.stroke())):Bd(e,P,U,W,V,8,tl),e.fillStyle=$f,e.fillText(w,y+C+1,v+S+_.actualBoundingBoxAscent+Math.floor((N-L)/2)+2),E){e.fillStyle=x;let q=8,F=8,z=5;e.fillRect(P+W+F,U+(V/2-q/2),2,q),e.fillRect(P+W+F+z,U+(V/2-q*2/2),2,q*2),e.fillRect(P+W+F+z*2,U+(V/2-q/2),2,q)}}e.restore(),e.closePath()}};import X4 from"clsx";import{useState as $4}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]=$4(!1),s=!a&&r,c=s?void 0:{background:e};return l2("div",{className:X4("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 q4=H({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=Ti(r,n),s=j4({"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=H({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 Gs)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(io),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=ri(e,o),i=Dt(e);return n.flatMap(a=>{let l=J4(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})})},J4=(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 ao=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ie(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)},Q4=H({name:"alignTop",label:"labels.alignTop",icon:Lu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(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)})}),eC=H({name:"alignBottom",label:"labels.alignBottom",icon:Au,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(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)})}),tC=H({name:"alignLeft",label:"labels.alignLeft",icon:_u,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(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)})}),oC=H({name:"alignRight",label:"labels.alignRight",icon:Du,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(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)})}),rC=H({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Pu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(o,r),type:"button",icon:Pu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:ze(Ee(e),o)})}),nC=H({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ru,trackEvent:{category:"element"},predicate:(e,o,t,r)=>ao(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:!ao(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=ri(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=>ie(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)},iC=H({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)})}),aC=H({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=H({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=H({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=lC(i,o,t,r,n),l=ee(a);return e.map(s=>l.get(s.id)||s)},lC=(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,io(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),ei(e.filter(ce),o,n.scene.getNonDeletedElements(),n.scene,Qn(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=H({name:"copy",label:"labels.copy",icon:_l,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=H({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=H({name:"cut",label:"labels.cut",icon:aE,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ka.perform(e,o,t,r),Hl.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),Hd=H({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}=Ei(e,o,!0);try{await yi("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=H({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}=Ei(e,o,!0);try{return await yi("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=H({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=H({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=H({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=H({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=H({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=H({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>mt(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=H({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()),pl(a.id,l),{elements:sC(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),sC=(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},cC=(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=H({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=cC([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import dC from"clsx";import{useCallback as g2,useEffect as f2,useLayoutEffect as mC,useRef as pC,useState as uC}from"react";import{jsx as Aa,jsxs as b2}from"react/jsx-runtime";var zh=380,hC=42,Oh=5,x2=85,gC=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]=uC(c),p=pC(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:C}=e,S=ii(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>C?v:C*_:v,height:S?.type==="video"&&v>C?v/_:C}:{},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]);mC(()=>()=>{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=C=>{if(u)return;y&&clearTimeout(y),bC(e,o,a,M(C.clientX,C.clientY))&&(y=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},gC))};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:dC("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=$s("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]=Ke(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"},Jl=null,v2=(e,o,t)=>{Jl&&clearTimeout(Jl),Jl=window.setTimeout(()=>fC(e,o,t),r1)},fC=(e,o,t)=>{if(!e.link)return;let r=Ea();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ai(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=Ke(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=()=>{Jl&&clearTimeout(Jl),Bh&&(Bh=!1,Ea().classList.remove("excalidraw-tooltip--visible"))},bC=(e,o,t,[r,n])=>{let{x:i,y:a}=Ye({clientX:r,clientY:n},t),l=15/t.zoom.value;if(V1(i,a,e,o))return!1;let[s,c,m]=Ke(e,o);if(i>=s&&i<=m&&a>=c-x2&&a<=c)return!1;let{x:d,y:p}=y2(e,t,o);return!(r>=d-l&&r<=d+zh+Oh*2+l&&n>=p-l&&n<=p+l+Oh*2+hC)};import{jsx as xC}from"react/jsx-runtime";var Ql=H({name:"hyperlink",label:(e,o)=>Fh(e,o),icon:Rl,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 xC(Q,{type:"button",icon:Rl,"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=H({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!ie(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:pi},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=H({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:pi,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 dS from"fuzzy";import{useEffect as dm,useRef as mS,useState as cm}from"react";var Wd=H({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=H({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 EC={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:[]},st=(e,o=0)=>{let t=EC[e];return t&&t.length>0?t[o]||t[0]:""};var yC="\\u0300-\\u036f",vC="\\ufe20-\\ufe2f",wC="\\u20d0-\\u20ff",TC=yC+vC+wC,CC=`[${TC}]`,IC=RegExp(CC,"g"),SC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kC={\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(SC,o=>kC[o]||o).replace(IC,"");import WI from"clsx";import{useEffect as KI,useState as ZI}from"react";import{useCallback as MC,useState as LC}from"react";var C2=()=>{let[e,o]=LC(null),t=MC(r=>o(r),[]);return[e,t]};import{useState as mv,useCallback as eg,useMemo as pv,useEffect as sv,memo as uv,useRef as zI}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:wl(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})},AC=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 _C,useState as DC}from"react";var Yh=_e(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]=DC();return _C(()=>{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 PC=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],_2=new Pt,Ci=_e({status:"loaded",isInitialized:!1,libraryItems:[]}),es=e=>oo(e),RC=(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)RC(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){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",es(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)St.set(Ci,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{St.set(Ci,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=es(this.currLibraryItems);let t=es(this.currLibraryItems);this.app.props.onLibraryChange?.(t),_2.trigger(P2(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],St.set(Yh,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(es(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:At.name,tab: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=Cl(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)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=es(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},NC=(e,o=PC)=>{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(zs.addLibrary)||new URLSearchParams(window.location.search).get(Bs.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){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(Cl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Cn.queue.push(n):n()}getLibraryItems(o){return Cn.getLibraryItems(this.adapter,o,!1)}};I(Cn,"queue",new g1),I(Cn,"run",async(o,t)=>{let r=new Cn(o);return Cn.queue.push(()=>t(r))});var Da=Cn,ts=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!==ts&&await e.save({libraryItems:i}),ts=a,i})}finally{Zd--}},OC=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),NC(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(zs.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(zs.addLibrary),window.history.replaceState({},Ja,`#${d.toString()}`)}else if(window.location.search.includes(Bs.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(Bs.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=Cl(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 ts=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&&ts!==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(),ts=0,Zd=0}},[])};import FC from"clsx";import{jsx as zC}from"react/jsx-runtime";var BC=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return zC("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=${Hs.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},N2=BC;import{jsx as HC,jsxs as UC}from"react/jsx-runtime";var jd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>UC("div",{className:FC("library-menu-control-buttons",i),style:r,children:[HC(N2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Na,useEffect as PI,useMemo as av,useRef as RI,useState as NI}from"react";import GC from"lodash.throttle";import{useEffect as VC}from"react";var YC=_e(0),O2=e=>{let[o,t]=ve(YC);return VC(()=>{let{current:r}=e;if(!r)return;let n=GC(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import bI from"clsx";import{useCallback as xI,useState as $h}from"react";import{flushSync as B2}from"react-dom";import WC from"clsx";import{jsx as qd,jsxs as ZC}from"react/jsx-runtime";var KC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return ZC("button",{className:WC("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=KC;import{jsx as z2,jsxs as F2}from"react/jsx-runtime";var XC=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(ct,{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=XC;import em from"open-color";import{useCallback as tI,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}}};I(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}}),I(Ro,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Qd from"react";var $C=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,jC=/{{([\w-]+)}}/,qC=/<([\w-]+)>/,JC=/<\/([\w-]+)>/,QC=(e,o)=>{let t=[{name:"",children:[]}];return e.split($C).filter(Boolean).forEach(r=>{let n=r.match(qC),i=r.match(JC),a=r.match(jC);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},eI=({i18nKey:e,children:o,...t})=>{let{t:r}=pt();return Qd.createElement(Qd.Fragment,{},...QC(r(e),t))},Kt=eI;import{jsx as we,jsxs as Nt}from"react/jsx-runtime";var oI=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 Il(new File([await Nr(a)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},rI=({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})]})]})},nI=({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=[],C=!1;if(d.forEach(U=>{let W="";U.name||(W=f("publishDialog.errors.required"),C=!0),v.push({...U,error:W})}),C){p(v),m(!1);return}let S=await oI(d),_={type:Qr.excalidrawLibrary,version:Hs.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(U=>U.ok?U.json().then(({url:W})=>{Ro.delete(tn.PUBLISH_LIBRARY),r({url:W,authorName:l.authorName,items:d})}):U.json().catch(()=>{throw new Error(U.statusText||"something went wrong")}).then(W=>{throw new Error(W.message||U.statusText||"something went wrong")}),U=>{console.error(U),n(U),m(!1)}).catch(U=>{console.error(U),n(U),m(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(we("div",{className:"single-library-item-wrapper",children:we(rI,{libItem:v,appState:t,index:C,onChange:(S,_)=>{let L=d.slice();L[_].name=S,p(L)},onRemove:a})},C))}),we("div",{className:"selected-library-items",children:y})},x=tI(()=>{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(ct,{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=nI;import lI from"clsx";import{useEffect as sI,useRef as cI}from"react";import{forwardRef as G2}from"react";import V2 from"clsx";import{jsx as Y2}from"react/jsx-runtime";var iI=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})),aI=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:iI,Col:aI};import{jsx as tm}from"react/jsx-runtime";var W2=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=Ce(),a=cI(null),l=fn({onClickOutside:o});pa(a,()=>{l.onClickOutside?.()}),sI(()=>{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=lI(`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 mI}from"react/jsx-runtime";var dI=({children:e,className:o="",selected:t,...r})=>mI("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Z2=dI;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 pI}from"react/jsx-runtime";var j2=()=>pI("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),q2=j2;j2.displayName="DropdownMenuSeparator";import uI from"clsx";import{jsx as hI}from"react/jsx-runtime";var J2=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=Ce(),a=uI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return hI("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 gI,jsxs as fI}from"react/jsx-runtime";var Gr=({children:e,open:o})=>{let t=ev(e),r=tv(e);return fI(gI,{children:[t,o&&r]})};Gr.Trigger=Q2;Gr.Content=K2;Gr.Item=Yt;Gr.ItemLink=Ra;Gr.ItemCustom=Z2;Gr.Group=Yl;Gr.Separator=q2;var Re=Gr;Gr.displayName="DropdownMenu";import{jsx as lo,jsxs as rm}from"react/jsx-runtime";var EI=(e,o)=>e.filter(t=>o.includes(t.id)),yI=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ve(Ci),[c,m]=ve(Pa),d=()=>{let P=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),U=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return lo(Jd,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:U,children:lo("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),C=xI(()=>rm(ct,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[lo("p",{children:lo(Kt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>lo("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),lo(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,U)=>{w(!1),v({url:P.url,authorName:P.authorName});let W=U.slice();W.forEach(V=>{o.includes(V.id)&&(V.status="published")}),t.setLibrary(W)},_=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(Xs).catch(U=>{e({errorMessage:U.message})})},N=()=>rm(Re,{open:c,children:[lo(Re.Trigger,{onToggle:()=>m(!c),children:Z0}),rm(Re.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!g&&lo(Re.Item,{onSelect:_,icon:sa,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&lo(Re.Item,{onSelect:L,icon:ui,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&lo(Re.Item,{onSelect:()=>u(!0),icon:ho,children:x}),g&&lo(Re.Item,{icon:iE,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return rm("div",{className:bI("library-menu-dropdown-container",l),children:[N(),o.length>0&&lo("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&lo(U2,{onClose:()=>w(!1),libraryItems:EI(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(U=>U!==P))}),y&&C()]})},jh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=lt(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Kd(),a=Pe(),l=Ie(),[s]=ve(Ci),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 lo(yI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as LI,useEffect as AI,useState as _I}from"react";import vI,{useCallback as wI}from"react";function TI(){return[!1,wI(o=>o(),[])]}var ov=vI.useTransition||TI;import rv from"clsx";import{memo as CI,useEffect as II,useRef as SI,useState as kI}from"react";import{jsx as nm,jsxs as MI}from"react/jsx-runtime";var nv=CI(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=SI(null),c=k2(e,o,l);II(()=>{let g=s.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[m,d]=kI(!1),p=Ce().editor.isMobile,u=t&&nm("div",{className:"library-unit__adder",children:K0});return MI("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(Xl,{checked:n,onChange:(g,b)=>i(e,b),className:"library-unit__checkbox"})]})}),iv=()=>nm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as DI,jsx as im}from"react/jsx-runtime";var qh=({children:e})=>im("div",{className:"library-menu-items-container__grid",children:e}),am=LI(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=ov(),[s,c]=_I(0);return AI(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),im(DI,{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 so,jsxs as Oa}from"react/jsx-runtime";var OI=17,BI=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=RI(null),d=O2(m);PI(()=>{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]=NI(null),y=Na((P,U)=>{let W=!c.includes(P),V=[...u,...g];if(W){if(U.shiftKey&&E){let q=V.findIndex(ne=>ne.id===E),F=V.findIndex(ne=>ne.id===P);if(q===-1||F===-1){s([...c,P]);return}let z=ee(c),G=V.reduce((ne,X,le)=>((le>=q&&le<=F||z.has(X.id))&&ne.push(X.id),ne),[]);s(G)}else s([...c,P]);w(P)}else w(null),s(c.filter(q=>q!==P))},[E,s,g,c,u]),v=Na(P=>{let U;return c.includes(P)?U=o.filter(W=>c.includes(W.id)):U=o.filter(W=>W.id===P),U.map(W=>({...W,elements:si({type:"everything",elements:W.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),C=Na((P,U)=>{U.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?BI:OI;return Oa("div",{className:"library-menu-items-container",style:n.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&so(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&&so("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&so("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:so(Mt,{})}),!n.length&&!u.length?Oa("div",{className:"library-menu-items__no-items",children:[so("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),so("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&&so(am,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:_,isItemSelected:S,svgCache:p}),so(am,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})]})]}),Oa(lv,{children:[(g.length>0||n.length>0||u.length>0)&&so("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),g.length>0?so(qh,{children:so(am,{itemsRenderedPerBatch:N,items:g,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})}):u.length>0?so("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&so(jd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:so(jh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as In,jsxs as dv}from"react/jsx-runtime";var Pa=_e(!1),cv=({children:e})=>In("div",{className:"layer-ui__library",children:e}),FI=uv(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ve(Ci),d=eg(g=>{(async(x,E)=>{xe("element","addToLibrary","ui");for(let y of Gs)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}),HI=(e,o)=>{let t=xn(),[r,n]=mv(()=>Qh(t,e.selectedElementIds)),i=zI(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=lt(),{onInsertElements:o}=e,t=hr(),r=Pe(),n=Ie(),[i,a]=mv([]),l=pv(()=>e.library,[e.library]),s=HI(r,e),c=eg(d=>{o($d(d))},[o]),m=eg(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return In(FI,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import UI from"clsx";import{useRef as GI}from"react";import{createPortal as VI}from"react-dom";import{jsx as gv,jsxs as YI}from"react/jsx-runtime";var fv=e=>{let{closeOnClickOutside:o=!0}=e,t=ud({className:"excalidraw-modal-container"}),r=GI(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 VI(YI("div",{className:UI("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 os,jsxs as $I}from"react/jsx-runtime";function XI(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var ct=e=>{let[o,t]=C2(),[r]=ZI(document.activeElement),{id:n}=gt(),i=Ce().viewport.isMobile;KI(()=>{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 os(fv,{className:WI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:XI(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:$I(yt,{ref:t,children:[e.title&&os("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:os("span",{className:"Dialog__titleContent",children:e.title})}),i&&os("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Lo}),os("div",{className:"Dialog__content",children:e.children})]})})};import tg from"clsx";import{forwardRef as JI,useRef as QI,useImperativeHandle as eS,useLayoutEffect as tS,useState as oS}from"react";import jI from"clsx";import{jsx as qI}from"react/jsx-runtime";var vo=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>qI("button",{onClick:an(i.onClick,a=>{o()}),type:e,className:jI("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as og,jsxs as bv}from"react/jsx-runtime";var Ba=JI(({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=QI(null);eS(d,()=>p.current),tS(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,g]=oS(!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 rs=[{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=>rs.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 iS}from"react";import{createIsolation as rS}from"jotai-scope";import rg from"react";import br from"tunnel-rat";var ng=rg.createContext(null),Ze=()=>rg.useContext(ng),nS=rS(),Ev=()=>rg.useMemo(()=>({MainMenuTunnel:br(),WelcomeScreenMenuHintTunnel:br(),WelcomeScreenToolbarHintTunnel:br(),WelcomeScreenHelpHintTunnel:br(),WelcomeScreenCenterTunnel:br(),FooterCenterTunnel:br(),DefaultSidebarTriggerTunnel:br(),DefaultSidebarTabTriggersTunnel:br(),OverwriteConfirmDialogTunnel:br(),TTDDialogTriggerTunnel:br(),tunnelsJotai:nS}),[]);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 yl(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>yl(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=hc(o,e),i=!1;n.length===2&&(mt(n[0])||mt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=mn(e.activeTool.type)&&!Zn(e.currentItemBackgroundColor)||n.some(g=>mn(g.type)&&!Zn(g.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&ce(n[0])&&!te(n[0]),p=!e.croppingElementId&&n.length===1&&he(n[0]),u=!i&&ao(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]=iS(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Ze();return vt(Vr,{children:[rs.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(Re,{open:n,children:[Ve(Re.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?Ol:c?vu:l&&!t.props.isCollaborating?Bl:s?Al:mE}),vt(Re.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ve(Re.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Ol,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Ve(Re.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:vu,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),Ve(Re.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Bl,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Ve(Re.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Al,"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(Re.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(Re.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:nd,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Ve(Re.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 aS}from"react";var sg=e=>{let o=aS({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as sS,jsxs as lS}from"react/jsx-runtime";var Ii=_e(null),Cv=()=>{let[e,o]=ve(Ii),t=ft();return e&&e==="clearCanvas"?sS(Jd,{onConfirm:()=>{t.executeAction(Fr),o(null)},onCancel:()=>o(null),title:f("clearCanvasDialog.title"),children:lS("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var cg={};Pf(cg,{toggleTheme:()=>cS});var cS={...bi,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(bi,"commandPalette")}};import{jsx as Zt,jsxs as xr}from"react/jsx-runtime";var pS=_e(null),nt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},uS=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),vq=Object.assign(e=>{let o=Pe(),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(hS,{...e})},{defaultItems:cg});function hS({customCommandPaletteItems:e}){let o=lt(),t=Pe(),r=Ie(),n=hr(),i=ft(),[a,l]=ve(pS),[s,c]=cm(null),m=mS(null),d=fn({uiAppState:t,customCommandPaletteItems:e,appProps:n});dm(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:L}=d,N=V=>{let q="";return V.label&&(typeof V.label=="function"?q=f(V.label(o.scene.getNonDeletedElements(),S,o)):q=f(V.label)),q},P=V=>typeof V.icon=="function"?V.icon(S,o.scene.getNonDeletedElements()):V.icon,U=[],W=(V,q,F)=>{let z={label:N(V),icon:P(V),category:q,shortcut:st(V.name),keywords:V.keywords,predicate:V.predicate,viewMode:V.viewMode,perform:()=>{i.executeAction(V,"commandPalette")}};return F?F(z,V):z};if(S&&o.scene&&i){let V=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,Ql,Wd,T2].map(X=>W(X,nt.elements,(le,be)=>({...le,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(X=>W(X,nt.tools)),F=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(X=>W(X,nt.editor)),z=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>W(X,nt.export));U=[...V,...F,{label:N(Fr),icon:P(Fr),shortcut:st(Fr.name),category:nt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{St.set(Ii,"clearCanvas")}},{label:f("buttons.exportImage"),category:nt.export,icon:Jc,shortcut:st("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...z];let G=[{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(ns)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:nt.elements,icon:qc,viewMode:!1,predicate:(X,le)=>{let be=J(X,le);return be.length>0&&ag(le,be)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:qc,category:nt.elements,viewMode:!1,predicate:(X,le)=>{let be=J(X,le);return be.length>0&&lg(le,be)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:qc,category:nt.editor,viewMode:!1,perform:()=>{r(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...rs.reduce((X,le)=>{let{value:be,icon:Te,key:ot,numericKey:jt}=le;if(L.UIOptions.tools?.[be]===!1)return X;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 X.push(qt),X},[]),...q,{label:f("toolBar.lock"),category:nt.tools,icon:S.activeTool.locked?aa:pi,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(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:nt.tools,icon:rd,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ne=[...U,...G,..._||[]].map(X=>({...X,icon:X.icon||id,order:X.order??uS(X.category),haystack:`${Vh(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));c(ne),l(ne.find(X=>X.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),C=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(V=>V.label===g?.label);if(N){if(P===0){b(a);return}if(g===a){let V=L[L.length-1];V&&b(V);return}}let U;P===-1?U=L.length-1:U=P===0?L.length-1:(P-1)%L.length;let W=L[U];W&&b(W);return}if(S.key===T.ARROW_DOWN){S.preventDefault();let P=L.findIndex(V=>V.label===g?.label);if(N){if(!g||P===L.length-1){b(a);return}if(g===a){let V=L[0];V&&b(V);return}}let U=(P+1)%L.length,W=L[U];W&&b(W);return}if(S.key===T.ENTER&&g&&setTimeout(()=>{y(g,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return dm(()=>(window.addEventListener("keydown",C,{capture:!0}),()=>window.removeEventListener("keydown",C,{capture:!0})),[C]),dm(()=>{if(!s)return;let S=P=>{let U={};for(let W of P)U[W.category]?U[W.category].push(W):U[W.category]=[W];return U},_=s.filter(v).sort((P,U)=>P.order-U.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,""));_=dS.filter(N,_,{extract:P=>P.haystack}).sort((P,U)=>U.score-P.score).map(P=>P.original),E(S(_)),b(_[0]??null)},[p,s,v,a]),xr(ct,{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 gS}from"react/jsx-runtime";var dg=H({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&&ce(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 gS(Q,{type:"button",icon:AE,title:n,"aria-label":n,onClick:()=>o(null)})}});var ns=H({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 fS}from"react/jsx-runtime";var mg=H({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 fS(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&&ie(t[0])},Lv=H({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ie(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=H({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ie(n)?{elements:Cb(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)}),UJ=H({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}),GJ=H({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Ol,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=H({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=>ie(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 Si=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},is=class e{constructor(){I(this,"onHistoryChangedEmitter",new Pt);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o,t){let r=pg.create(t,o);r.isEmpty()||(this.undoStack.push(r.inverse()),r.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Si(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 Si(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t,r){let n=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 bS,useState as xS}from"react";var ug=(e,o)=>{let[t,r]=xS(o);return bS(()=>{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]&&Vs(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>{let{isUndoStackEmpty:n}=ug(e.onHistoryChangedEmitter,new Si(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&&Vs(t,T.Z)||As&&t.ctrlKey&&!t.shiftKey&&Vs(t,T.Y),PanelComponent:({updateData:t,data:r})=>{let{isRedoStackEmpty:n}=ug(e.onHistoryChangedEmitter,new Si(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=H({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=H({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 ES}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){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{gg(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return ES(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(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(){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 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 yS=8,zv=99999,hm=e=>yS/e,Xt=class Xt{};I(Xt,"referenceSnapPoints",null),I(Xt,"visibleGaps",null),I(Xt,"setReferenceSnapPoints",o=>{Xt.referenceSnapPoints=o}),I(Xt,"getReferenceSnapPoints",()=>Xt.referenceSnapPoints),I(Xt,"setVisibleGaps",o=>{Xt.visibleGaps=o}),I(Xt,"getVisibleGaps",()=>Xt.visibleGaps),I(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,vS=(e,o,t=.01)=>Math.abs(e-o)<=t,as=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=Ke(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,g=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=se(M(l,s+g),M(d,p),a.angle),x=se(M(l+u,s),M(d,p),a.angle),E=se(M(c,s+g),M(d,p),a.angle),w=se(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=se(M(l,s),M(d,p),a.angle),x=se(M(c,s),M(d,p),a.angle),E=se(M(l,m),M(d,p),a.angle),w=se(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=>ie(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=ri(n,r).filter(d=>!(d.length===1&&Be(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(uo(b,E),uo(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(uo(b,E),uo(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(uo(b,x),uo(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(uo(b,x),uo(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(uo(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,C=m-v,S=et(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[_,,,]=x.startBounds,L=_-p,N=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(uo(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,C=v-u,S=et(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,_]=x.endBounds,L=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 ri(n,r).filter(i=>!(i.length===1&&Be(i[0]))).flatMap(i=>as(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=as(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,as(a,n,{dragOffset:u}),t,r,l,s,m),Fv(a,u,t,r,l,s,m);let g=xg(l,s),b=TS(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]))})))},wS=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())},TS=(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(uo(n,a),s.gap.overlap),w=sl(uo(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 wS(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&&!vS(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 C=xg(u,g);return{snapOffset:b,snapLines:C}},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=as([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=as([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,CS=(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:Xn(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:Xn(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(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>Pr(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>sn(ee(this.getElements())));I(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=Jn(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=vl({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Xn(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]=CS(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 C=i.get(v);if(!C)throw new Error(`Element with ${v} wasn't mapped correctly`);let S=r.getElement(C);if(!S)throw new Error(`Frame element with id ${C} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(_=>{let L=r.getElement(_.id);if(!L)throw new Error(`Bound element with id ${_.id} doesn't exist`);Object.assign(L,{frameId:c.id}),m.push(L)}),m.push(S)});let[d,p,u,g]=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 IS="#ff6b6b",SS="#ff0000",$v=1,jv=2,qv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===de.LIGHT||o.zenModeEnabled?IS:SS,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,MS(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,LS(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,kS(n,e,o));e.restore()},kS=(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)},MS=(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()},LS=(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),C=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===C?null:{x:u?Math.max(p.left,Qo):o-Er-Math.max(p.right,Qo),y:(b-y)/(C-y)*t+Math.max(p.top,Qo),width:Er,height:(E-b)/(C-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 AS=(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()},_S=(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)",Tl(o,e[0],e[1],j.POINT_HANDLE_SIZE/t.zoom.value,!1)},ls=(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()},DS=(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)"),Tl(e,t[0],t[1],r/o.zoom.value,!i)},PS=(e,o,t,r,n,i)=>{e.beginPath(),e.ellipse(r,n,o/2,t/2,i,0,Math.PI*2),e.stroke()},RS=(e,o,t,r)=>{let[n,i,a,l]=Ke(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)";let m=r.value<1?r.value:1;e.lineWidth=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":ls(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;DS(e,s+g*2,c+b*2,n+s/2,i+c/2,o.angle);break;case"ellipse":PS(e,s+d*2,c+d*2,n+s/2,i+c/2,o.angle);break}},NS=(e,o,t,r)=>{let[n,i,a]=o,l=ub(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);Tl(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,ls(e,n-x,i-x,u+x*2,g+x*2,c,m,r);e.restore()},OS=(e,o,t,r)=>{let n=Array.isArray(t)?NS:RS;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},BS=(e,o,t,r)=>{let[n,i,a,l]=Ke(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Vo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ls(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Vo.radius/o.zoom.value),e.restore()},zS=(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"?Tl(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()):ls(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},FS=(e,o,t,r,n)=>{let[i,a,,,l,s]=Ke(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,g=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,g);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-g],[0,p],[b,p],[p,0],[p,x]],[[u-p,-g],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,g],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,g],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[C,S],[_,L],[N,P],[U,W]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+_,v+L),e.stroke(),e.beginPath(),e.moveTo(y+N,v+P),e.lineTo(y+U,v+W),e.stroke(),e.restore()}),e.restore()},HS=(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&&HS(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{OS(d,a,b,o)}),a.frameToHighlight&&BS(d,a,a.frameToHighlight,o),a.elementsToHighlight&&zS(d,a,a.elementsToHighlight);let u=r.some(b=>ie(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?AS(d,a):(te(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&_S(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=zc(r,a),x=r.length===1&&ce(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 C of o.values()){let S=[],_=l.remoteSelectedElementIds.get(C.id);if(x&&te(C)&&(C.startBinding||C.endBinding)||(w.has(C.id)&&!fc(a,C)&&S.push(E),_&&S.push(..._.map(L=>Ti(L,a.collaborators.get(L))))),S.length){let[L,N,P,U,W,V]=Ke(C,o,!0);y.push({angle:C.angle,x1:L,y1:N,x2:P,y2:U,selectionColors:S,dashed:!!_,cx:W,cy:V,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||he(C)?0:void 0})}}let v=C=>{let S=Fe(o,C),[_,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 C of Zo(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>rw(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=fm.white;let w=Bc(r[0],a.zoom,o,"mouse",ci(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)&&FS(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,C,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,ls(d,y-w,v-w,C-y+w*2,S-v+w*2,(y+C)/2,(v+S)/2,0),d.lineWidth=L,d.setLineDash(_);let N=Sl([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...ci(s),rotation:!0}:ci(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,,,C,S]=Ke(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(C,S),d.rotate(w.angle),E.forEach(_=>{d.fillRect(y+_.offsetX-C,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 ss=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())xl(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 VS}from"react/jsx-runtime";var US=5,GS=(e,o,t)=>{let[r,n]=Ke(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}=GS(o,r,t);return VS("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:US},children:e})};import{LaserPointer as YS}from"@excalidraw/laser-pointer";var Wr=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(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 YS(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;I(this,"localTrail");I(this,"collabTrails",new Map);I(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||Ti(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 WS}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=WS.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 KS=(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=(F,z)=>{if(!z.style.fontFamily||!z.style.fontSize)return!1;let G=z.style.fontFamily.replace(/"/g,"");return Yn({fontFamily:F.fontFamily})!==G||`${F.fontSize}px`!==z.style.fontSize},m=()=>{let F=l.state,z=dn.getScene(n)?.getElement(e);if(!z)return;let{textAlign:G,verticalAlign:ne}=z,X=l.scene.getNonDeletedElementsMap();if(z&&Z(z)){let le=z.x,be=z.y,Te=_t(z,l.scene.getNonDeletedElementsMap()),ot=z.width,jt=z.height,Ho=z.width,or=z.height;if(Te&&z.containerId){if(ke(Te)){let jr=j.getBoundTextElementPosition(Te,z,X);le=jr.x,be=jr.y}let Is=c(z,d),ja;if(Is?ja=pl(Te.id,Te.height):(ja=q1[Te.id],ja||(ja=pl(Te.id,Te.height))),Ho=Gi(Te,z),or=lb(Te,z),!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,z,X);be=jr}}let[qt,rr]=r(le,be),Xr=d.selectionStart,Jt=d.selectionEnd,$r=d.value.length;if(Xr===Jt&&Jt!==$r){let Is=$r-Jt;d.selectionStart=d.value.length-Is,d.selectionEnd=d.value.length-Is}Te?ot+=.5:(Ho=(F.width-8-qt)/F.zoom.value,ot=Math.min(ot,Ho)),jt*=1.05;let po=qe(z),_f=(F.height-rr)/F.zoom.value;Object.assign(d.style,{font:po,lineHeight:z.lineHeight,width:`${ot}px`,height:`${jt}px`,left:`${qt}px`,top:`${rr}px`,transform:KS(ot,jt,rb(z,Te),F,Ho,_f),textAlign:G,verticalAlign:ne,color:z.strokeColor,opacity:z.opacity/100,filter:"var(--theme-filter)",maxHeight:`${_f}px`}),d.scrollTop=0,dt()&&(d.style.fontFamily=Yn(z)),B(z,{x:le,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";(Be(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 F=>{let z=await Rd(F,!0);if(!z.text)return;let G=Jn(z.text);if(!G)return;let ne=_t(n,l.scene.getNonDeletedElementsMap()),X=qe({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ne){let le=ge(ne,l.scene.getNonDeletedElementsMap()),be=Hi(`${d.value}${G}`,X,Gi(ne,le)),Te=ob(be,X);d.style.width=`${Te}px`}},d.oninput=()=>{let F=Jn(d.value);if(d.value!==F){let z=d.selectionStart;d.value=F,d.selectionStart=z,d.selectionEnd=z}o(d.value)}),d.onkeydown=F=>{if(!F.shiftKey&&kd.keyTest(F))F.preventDefault(),l.actionManager.executeAction(kd),m();else if(!F.shiftKey&&Md.keyTest(F))F.preventDefault(),l.actionManager.executeAction(Md),m();else if(!F.shiftKey&&Ld.keyTest(F))F.preventDefault(),l.actionManager.executeAction(Ld),m();else if(bh.keyTest(F))l.actionManager.executeAction(bh);else if(xh.keyTest(F))l.actionManager.executeAction(xh);else if(F.key===T.ESCAPE)F.preventDefault(),C=!0,S();else if(vi.keyTest(F))F.preventDefault(),S(),l.actionManager.executeAction(vi);else if(F.key===T.ENTER&&F[T.CTRL_OR_CMD]){if(F.preventDefault(),F.isComposing||F.keyCode===229)return;C=!0,S()}else if(F.key===T.TAB||F[T.CTRL_OR_CMD]&&(F.code===pe.BRACKET_LEFT||F.code===pe.BRACKET_RIGHT)){if(F.preventDefault(),F.isComposing)return;F.shiftKey||F.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:F,selectionEnd:z}=d,G=y(),ne=d.value;G.forEach(X=>{let le=ne.slice(0,X),be=ne.slice(X);ne=`${le}${b}${be}`}),d.value=ne,d.selectionStart=F+g,d.selectionEnd=z+g*G.length},w=()=>{let{selectionStart:F,selectionEnd:z}=d,G=y(),ne=[],X=d.value;G.forEach(le=>{let be=X.slice(le,le+g).match(x);if(be){let Te=X.slice(0,le),ot=X.slice(le+be[0].length);X=`${Te}${ot}`,ne.push(le)}}),d.value=X,ne.length&&(F>ne[ne.length-1]?d.selectionStart=Math.max(F-g,ne[ne.length-1]):d.selectionStart=F,d.selectionEnd=Math.max(d.selectionStart,z-g*ne.length))},y=()=>{let{selectionStart:F,selectionEnd:z,value:G}=d,ne=G.slice(0,F).match(/[^\n]*$/)[0].length;return F=F-ne,G.slice(F,z).split(`
8
- `).reduce((le,be,Te,ot)=>le.concat(Te?le[Te-1]+ot[Te-1].length+1:F),[]).reverse()},v=F=>{F.target instanceof HTMLCanvasElement&&(F.preventDefault(),F.stopPropagation())},C=!1,S=()=>{if(V)return;V=!0,_();let F=dn.getScene(n)?.getElement(n.id);if(!F)return;let z=_t(F,l.scene.getNonDeletedElementsMap());if(z){if(d.value.trim()){let G=ko(z);!G||G!==n.id?B(z,{boundElements:(z.boundElements||[]).concat({type:"text",id:n.id})}):ke(z)&&bl(z)}else B(z,{boundElements:z.boundElements?.filter(G=>!Z(G))});Qe(F,z,l.scene.getNonDeletedElementsMap())}t({viaKeyboard:C,nextOriginalText:d.value})},_=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",L),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),U(),W(),d.remove()},L=F=>{window.removeEventListener("pointerup",L);let z=F?.target,G=z instanceof HTMLElement&&z.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,G||d.focus()})},N=()=>{d.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",S)},P=F=>{let z=F?.target;if(F.button===nr.WHEEL){z instanceof HTMLTextAreaElement&&(F.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(F)),N();return}let G=z instanceof HTMLElement&&z.classList.contains("properties-trigger");(F.target instanceof HTMLElement||F.target instanceof SVGElement)&&F.target.closest(`.${Go.SHAPE_ACTIONS_MENU}, .${Go.ZOOM_ACTIONS}`)&&!ir(F.target)||G?N():F.target instanceof HTMLCanvasElement&&!dt()&&requestAnimationFrame(()=>{S()})},U=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),W=l.onScrollChangeEmitter.on(()=>{m()}),V=!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=F=>F.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 ZS}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=ZS(o,a)),i.clear();for(let c of t)!n.has(c.id)&&!i.has(c.id)&&(XS(l,c,r)?i.add(c.id):$S(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},XS=(e,o,t)=>{let r=x1(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>E1(a,r))):!1},$S=(e,o,t)=>{let r=t.get(o.id);return r?e.reduce((i,a,l)=>(l===0||i.push(Ks(e[l-1],a)),i),[]).some(i=>r.some(a=>Zs(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)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&Z(c)){let m=_t(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&ie(c)){let m=Mo(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=ht({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&&ce(this.app.scene.getNonDeletedElement(a[0]))?new j(this.app.scene.getNonDeletedElement(a[0])):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>M(r[0],r[1]));if(!this.elementsSegments){this.elementsSegments=new Map;let r=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 jS=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)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set);I(this,"segmentsCache",new Map);I(this,"geometricShapesCache",new Map)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>M(l[0],l[1]))||[];r=r?.slice(r.length-jS);let n=this.app.visibleElements.filter(l=>!l.locked),i=ee(n),a=r.reduce((l,s,c)=>(c===0||l.push(Ks(r[c-1],s)),l),[]);if(a.length===0)return[];for(let l of n)if(t&&this.elementsToErase.has(l.id)){if(dw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=Fe(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.delete(d.id);this.groupsToErase.delete(c)}if(Be(l)&&this.elementsToErase.delete(l.containerId),mt(l)){let m=ko(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&dw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=Fe(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.add(d.id);this.groupsToErase.add(c)}if(mt(l)){let m=ko(l);m&&this.elementsToErase.add(m)}Be(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear(),this.segmentsCache.clear()}},dw=(e,o,t,r,n,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=>Zs(c,m,i.getElementHitThreshold())!==null))};import{jsx as Bo,jsxs as mw}from"react/jsx-runtime";var qS=()=>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=qS;import tk from"clsx";import ok from"react";import{useLayoutEffect as JS,useRef as uw,useEffect as hw}from"react";import{unstable_batchedUpdates as QS}from"react-dom";import{jsx as ek}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 JS(()=>{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)||QS(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),ek("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Ua,jsxs as rk}from"react/jsx-runtime";var bt="separator",fw=ok.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:rk("button",{type:"button",className:tk("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?st(m):""})]})},c)})})})});import{jsx as Sg,jsxs as bw}from"react/jsx-runtime";var nk=({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=nk;import xs from"clsx";import m8 from"react";import ik from"clsx";import{useState as ak,useEffect as lk}from"react";import{jsx as kg,jsxs as sk}from"react/jsx-runtime";var vm=({delay:e,theme:o})=>{let[t,r]=ak(!!e);return lk(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:sk("div",{className:ik("LoadingMessage",{"LoadingMessage--dark":o===de.DARK}),children:[kg("div",{children:kg(Mt,{})}),kg("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import ck from"clsx";import{jsx as yw,jsxs as mk}from"react/jsx-runtime";var dk="medium",Ew={CHECKED:aa,UNCHECKED:pi},wm=e=>mk("label",{className:ck("ToolIcon ToolIcon__lock",`ToolIcon_size_${dk}`,{"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 pk from"clsx";import{jsx as uk}from"react/jsx-runtime";var Tm=({children:e,side:o,className:t})=>uk("div",{className:pk("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import hk from"clsx";import{jsx as gk}from"react/jsx-runtime";var Cm=e=>gk(Q,{className:hk("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 fk=({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 ce(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(ce(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 qn(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=fk({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 bk from"clsx";import{jsx as ww,jsxs as Ek}from"react/jsx-runtime";var xk="medium",Sm=e=>e.penDetected?Ek("label",{className:bk("ToolIcon ToolIcon__penMode",`ToolIcon_size_${xk}`,{"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 yk,jsx as Tw,jsxs as vk}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):vk(yk,{children:[n,o]})})};import{Fragment as wk,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}=Ze(),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(wk,{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=>({...li(o,y)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import Tk from"open-color";import Ck,{useLayoutEffect as Ik,useRef as Sk,useState as kk}from"react";import{jsx as cs,jsxs as Mk}from"react/jsx-runtime";var Iw=e=>{let o=Sk(null),[t,r]=kk(null);return Ik(()=>{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:Tk.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]),cs("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:cs("div",{ref:o})})},Sw=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=lt(),n=Ck.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),xe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return cs(ct,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:Mk("div",{className:"container",children:[cs(Iw,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),cs(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 Lk}from"react";import{Fragment as Rk,jsx as yr,jsxs as Mm}from"react/jsx-runtime";var Ak=4,_k=8,Dk=({shouldWrap:e,children:o,username:t})=>e?yr(bo,{label:t||"Unknown user",children:o}):yr(Rk,{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(Dk,{username:o.username,shouldWrap:n,children:l},t)},Pk=["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);Lk(()=>{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(Ak),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>=_k&&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,Pk))return!1}return!0});import Am from"clsx";import{jsx as Nk}from"react/jsx-runtime";var Mw=e=>Nk("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}=Ze(),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(wi)})]})}),vr(wv,{actionManager:o,showExitZenModeBtn:t})]})},Aw=Lw;Lw.displayName="Footer";import Vk from"clsx";import{useEffect as Hw,useLayoutEffect as Uw,useRef as zg,useState as Yk,forwardRef as Gw,useImperativeHandle as Wk,useCallback as zw}from"react";import Bk from"clsx";import{useContext as zk}from"react";import Ok from"react";var _m=Ok.createContext({});import{jsx as Ag,jsxs as _w}from"react/jsx-runtime";var _g=({children:e,className:o})=>{let t=Ce(),r=zk(_m),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return _w("div",{className:Bk("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 Fk}from"react/jsx-runtime";var Pg=({children:e,...o})=>Fk(Rw.List,{className:"sidebar-triggers",...o,children:e});Pg.displayName="SidebarTabTriggers";import Hk 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=Pe();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:Hk("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 Uk}from"react/jsx-runtime";var Og=({children:e,...o})=>{let t=Pe(),r=Ie();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Uk(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 Gk}from"react/jsx-runtime";var Bg=({tab:e,children:o,...t})=>Gk(Bw.Content,{...t,value:e,"data-testid":e,children:o});Bg.displayName="SidebarTab";import{jsx as Fw}from"react/jsx-runtime";import{createElement as Kk}from"react";var ds=_e(!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(ds);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);Wk(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:Vk("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=Pe(),{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]=Yk(!1);return Uw(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?Kk(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 Zk,useRef as Xk}from"react";import{jsx as $k}from"react/jsx-runtime";var Zr=(e,o)=>{let t=_e(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ze(),[,a]=i(t),l=Xk({preferHost:!1,counter:0});return Zk(()=>{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:$k(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 Qk from"clsx";var Fg=_e({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 jk from"clsx";import{jsx as Ww,jsxs as qk}from"react/jsx-runtime";var Dm=function({onChange:e,value:o,choices:t,name:r}){return Ww("div",{className:"RadioGroup",children:t.map(n=>qk("div",{className:jk("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 Jk,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(Jk,{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 eM,jsx as wt,jsxs as l3}from"react/jsx-runtime";var $w=()=>{let{t:e}=pt(),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:st("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};$w.displayName="LoadScene";var jw=()=>{let{t:e}=pt(),o=ft();return o.isActionEnabled(vi)?wt(Yt,{shortcut:st("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(vi),icon:px,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};jw.displayName="SaveToActiveFile";var qw=()=>{let e=Ie(),{t:o}=pt();return wt(Yt,{icon:Jc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:st("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};qw.displayName="SaveAsImage";var Jw=e=>{let o=Ie(),{t}=pt();return wt(Yt,{icon:id,"data-testid":"command-palette-button",onSelect:()=>{xe("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:st("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Jw.displayName="CommandPalette";var Qw=e=>{let{t:o}=pt(),t=ft();return wt(Yt,{icon:go,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ns)},shortcut:st("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};Qw.displayName="SearchMenu";var e3=()=>{let{t:e}=pt(),o=ft();return wt(Yt,{"data-testid":"help-menu-item",icon:la,onSelect:()=>o.executeAction(wi),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};e3.displayName="Help";var t3=()=>{let{t:e}=pt(),o=hn(Ii);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}=pt(),t=Pe(),r=ft(),n=st("toggleTheme");return r.isActionEnabled(bi)?e?.allowSystemTheme?wt(Xw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:de.LIGHT,label:Pl,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:de.DARK,label:Dl,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(bi)},icon:t.theme===de.DARK?Pl:Dl,"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}=pt(),o=Pe(),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}=pt(),o=Ie();return wt(Yt,{icon:ui,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}=pt();return l3(eM,{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}=pt();return wt(Yt,{"data-testid":"collab-button",icon:Qc,className:Qk({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};a3.displayName="LiveCollaborationTrigger";import{jsx as Pm,jsxs as Gg}from"react/jsx-runtime";var tM=Object.assign(Zr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ze(),r=Ce(),n=Pe(),i=Ie(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Pm(t.In,{children:Gg(Re,{open:n.openMenu==="canvas",children:[Pm(Re.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:$c}),Gg(Re.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:Re.Trigger,Item:Re.Item,ItemLink:Re.ItemLink,ItemCustom:Re.ItemCustom,Group:Re.Group,Separator:Re.Separator,DefaultItems:Ug}),Ot=tM;import oM from"clsx";import{forwardRef as rM,useState as nM}from"react";import{jsx as Rm,jsxs as iM}from"react/jsx-runtime";var An=rM(({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]=nM(!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:oM("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:iM("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 sM}from"react/jsx-runtime";var Nm=({title:e,children:o,actionLabel:t,onClick:r})=>sM("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})]}),aM=()=>{let{t:e}=pt(),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")})},lM=()=>{let{t:e}=pt(),o=ft();return Ga(Nm,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ql,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Vg=Object.assign(({children:e})=>Ga("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:aM,SaveToDisk:lM});import{jsx as _n,jsxs as s3}from"react/jsx-runtime";var Om=Object.assign(Zr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ze(),[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(ct,{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 CM from"clsx";import cM from"clsx";import dM from"lodash.debounce";import{Fragment as mM,memo as pM,useEffect as ms,useRef as Yg,useState as c3}from"react";import{Fragment as TM,jsx as wo,jsxs as ps}from"react/jsx-runtime";var uM=_e(""),Wg=_e(null),hM=350,m3=()=>{let e=lt(),o=Ie(),t=Yg(null),[r,n]=ve(uM),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();ms(()=>{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(C=>({id:C.textElement.id,focus:!1,matchedLines:C.matchedLines}))})}))},[a,i,g,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};ms(()=>{o(y=>({searchMatches:y.searchMatches.map((v,C)=>C===p?{...v,focus:!0}:{...v,focus:!1})}))},[p,o]),ms(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=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([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||L){let N;L?_>=S?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:So(S/_,1)}:N={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),ms(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:[]}),l(!1)},[o,u]);let E=fn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});ms(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),t.current?.matches(":focus")?o({openSidebar:null}):(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return We(window,"keydown",y,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return ps("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,(C,S)=>{c({nonce:Lr(),items:C}),u(S),m.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.map(_=>({id:_.textElement.id,focus:!1,matchedLines:_.matchedLines}))}),l(!1)})},selectOnRender:!0})}),ps("div",{className:"layer-ui__search-count",children:[s.items.length>0&&ps(TM,{children:[p!==null&&p>-1?ps("div",{children:[p+1," / ",w]}):wo("div",{children:w}),ps("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(xM,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},gM=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:cM("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(mM,{children:r===2?wo("b",{children:t}):t},r))})})},fM=e=>wo("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((o,t)=>wo(gM,{searchQuery:e.searchQuery,preview:o.preview,highlighted:t===e.focusIndex,onClick:()=>e.onItemClick(t)},o.textElement.id+o.index))}),bM=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,xM=pM(fM,bM),EM=(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}},yM=(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
- `)},vM=(e,o,t)=>{let n=yM(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),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}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},wM=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),d3=dM((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(wM(e),"gi");for(let c of n){let m=null,d=c.originalText;for(;(m=a.exec(d))!==null;){let p=EM(d,m.index,e),u=vM(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)},hM);import{jsx as er,jsxs as p3}from"react/jsx-runtime";import{createElement as IM}from"react";var u3=Zr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ze();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}=Ze();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=Pe(),a=Ie(),{DefaultSidebarTabTriggersTunnel:l}=Ze(),s=i.openSidebar?.tab===Sr;return IM(zo,{...n,name:"default",key:"default",className:CM("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 FM,useRef as Xg,useState as Zm}from"react";import{useState as E3,useRef as y3,useEffect as v3,useDeferredValue as DM}from"react";import{useEffect as SM,useRef as g3}from"react";import{jsx as kM}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,SM(()=>{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)}}},[]),kM("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 MM=({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(MM,{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 us}from"react/jsx-runtime";var Va=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>us("div",{className:"ttd-dialog-panel",children:[us("div",{className:"ttd-dialog-panel__header",children:[Kg("label",{children:e}),i?.()]}),o,us("div",{className:b3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[us(vo,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[us("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 LM}from"react/jsx-runtime";var Um=({children:e})=>LM("div",{className:"ttd-dialog-panels",children:e});import{jsx as x3,jsxs as AM}from"react/jsx-runtime";var Gm=()=>AM("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 _M=({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){_M({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}}},hs=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&&hs(t))};import{Fragment as NM,jsx as wr,jsxs as T3}from"react/jsx-runtime";var PM=`flowchart TD
7
+ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var wE=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=P1(a);if(!a||!L1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:m}=er(e,o,!1);return await tr(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as cM,jsx as zo,jsxs as dM}from"react/jsx-runtime";var su=N({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>zo(rE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),vE=N({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=sM(e),i=we(n,o)?j(n,o):n;return zo(cM,{children:lM.map(a=>{let[l,s]=k1(i,aM,a),m=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return zo(Z,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),cu=N({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo(Da,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),rc=N({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>dM(Da,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),zo(At,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:zo("div",{className:"excalidraw-tooltip-icon",children:h0})})]})}),or=N({name:"saveToActiveFile",label:"buttons.save",icon:Xn,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=Zl(o.fileHandle)?await wE(e,o,n.files,n.getName()):await Yl(e,o,n.files,n.getName());return{captureUpdate:io.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:io.EVENTUALLY}}},keyTest:e=>e.key===ni.S&&e[ni.CTRL_OR_CMD]&&!e.shiftKey}),za=N({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Xn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await Yl(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:io.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:io.EVENTUALLY}}},keyTest:e=>e.key===ni.S&&e.shiftKey&&e[ni.CTRL_OR_CMD],PanelComponent:({updateData:e})=>zo(Z,{type:"button",icon:c0,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:de().editor.isMobile,hidden:!Ir,onClick:()=>e(null),"data-testid":"save-as-button"})}),ri=N({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Pm(o,e);return{elements:r,appState:i,files:a,captureUpdate:io.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:io.EVENTUALLY}}},keyTest:e=>e[ni.CTRL_OR_CMD]&&e.key===ni.O}),TE=N({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:io.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>zo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:zo(oE,{value:e.exportWithDarkMode?lu.DARK:lu.LIGHT,onChange:t=>{o(t===lu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as mM,DEFAULT_FONT_FAMILY as pM,DEFAULT_TEXT_ALIGN as uM,CODES as IE,KEYS as CE,getLineHeight as hM}from"@excalidraw/common";import{newElementWith as ic}from"@excalidraw/element";import{hasBoundTextElement as gM,canApplyRoundnessTypeToElement as fM,getDefaultRoundnessTypeForElement as bM,isFrameLikeElement as xM,isArrowElement as EM,isExcalidrawElement as yM,isTextElement as du}from"@excalidraw/element";import{getBoundTextElement as wM,redrawTextBoundingBox as vM}from"@excalidraw/element";import{CaptureUpdateAction as mu}from"@excalidraw/element";var SE="{}",pu=N({name:"copyStyles",label:"labels.copyStyles",icon:rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&gM(i)){let a=wM(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(SE=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:mu.EVENTUALLY}},keyTest:e=>e[CE.CTRL_OR_CMD]&&e.altKey&&e.code===IE.C}),uu=N({name:"pasteStyles",label:"labels.pasteStyles",icon:rp,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(SE),i=r[0],a=r[1];if(!yM(i))return{elements:e,captureUpdate:mu.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let d=i;if(du(m)&&m.containerId&&(d=a),!d)return m;let c=ic(m,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?fM(d.roundness.type,m)?d.roundness:bM(m):null});if(du(c)){let p=d.fontSize||mM,u=d.fontFamily||pM;c=ic(c,{fontSize:p,fontFamily:u,textAlign:d.textAlign||uM,lineHeight:d.lineHeight||hM(u)});let f=null;c.containerId&&(f=l.find(b=>du(c)&&b.id===c.containerId)||null),vM(c,f,n.scene)}return c.type==="arrow"&&EM(d)&&(c=ic(c,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),xM(m)&&(c=ic(c,{roundness:null,backgroundColor:"transparent"})),c}return m}),captureUpdate:mu.IMMEDIATELY}},keyTest:e=>e[CE.CTRL_OR_CMD]&&e.altKey&&e.code===IE.V});import{KEYS as TM}from"@excalidraw/common";import{getNonDeletedElements as IM}from"@excalidraw/element";import{showSelectedShapeActions as CM}from"@excalidraw/element";import{CaptureUpdateAction as hu}from"@excalidraw/element";import{jsx as kE}from"react/jsx-runtime";var SM=N({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:hu.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>kE(Z,{type:"button",icon:is,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),kM=N({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:hu.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>kE(Z,{visible:CM(o,IM(e)),type:"button",icon:d0,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),nr=N({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:r0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:hu.EVENTUALLY}),keyTest:e=>e.key===TM.QUESTION_MARK});import{getNonDeletedElements as lc}from"@excalidraw/element";import{newElementWith as LE}from"@excalidraw/element";import{isBoundToContainer as MM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as PM,getElementsInResizingFrame as LM,getFrameLikeElements as AM,getRootElements as DM,groupByFrameLikes as _M,removeElementsFromFrame as RM,replaceAllElementsInFrame as NM}from"@excalidraw/element";import{KEYS as sc,randomId as BM,arrayToMap as gu,getShortcutKey as AE}from"@excalidraw/common";import{getSelectedGroupIds as ac,selectGroup as FM,selectGroupsForSelectedElements as OM,getElementsInGroup as ME,addToGroup as zM,removeFromSelectedGroups as HM,isElementInGroup as DE}from"@excalidraw/element";import{syncMovedIndices as GM}from"@excalidraw/element";import{CaptureUpdateAction as Ha}from"@excalidraw/element";import{jsx as ii}from"react/jsx-runtime";var UM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&DE(r,t),!0))return!0}return!1},PE=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!UM(n)&&!PM(n)},fu=N({name:"group",label:"labels.group",icon:e=>ii(ep,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=DM(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY};let i=ac(o);if(i.length===1){let x=i[0],y=new Set(ME(e,x).map(v=>v.id)),E=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(E)]).size===y.size)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&_M(r).forEach((y,E)=>{RM(y,n.scene.getNonDeletedElementsMap())});let s=BM(),m=gu(r);a=a.map(x=>m.get(x.id)?LE(x,{groupIds:zM(x.groupIds,s,o.editingGroupId)}):x);let d=ME(a,s),c=d[d.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!DE(x,s)),b=GM([...f,...d,...u],gu(d));return{appState:{...o,...FM(s,{...o,selectedGroupIds:{}},lc(a))},elements:b,captureUpdate:Ha.IMMEDIATELY}},predicate:(e,o,t,n)=>PE(e,o,n),keyTest:e=>!e.shiftKey&&e[sc.CTRL_OR_CMD]&&e.key===sc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ii(Z,{hidden:!PE(e,o,n),type:"button",icon:ii(ep,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${AE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:we(lc(e),o)})}),bu=N({name:"ungroup",label:"labels.ungroup",icon:e=>ii(tp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=ac(o),i=gu(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Ha.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{MM(p)&&l.push(p.id);let u=HM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:LE(p,{groupIds:u})});let s=OM(o,lc(a),o,null),m=n.scene.getSelectedElements(o),d=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return AM(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=NM(a,LM(a,p,o,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Ha.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[sc.CTRL_OR_CMD]&&e.key===sc.G.toUpperCase(),predicate:(e,o)=>ac(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>ii(Z,{type:"button",hidden:ac(o).length===0,icon:ii(tp,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${AE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:we(lc(e),o)})});import $M from"clsx";import{CaptureUpdateAction as FE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as YM,COLOR_VOICE_CALL as WM,COLOR_WHITE as dc,THEME as VM,UserIdleState as _E}from"@excalidraw/common";var cc=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function XM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var rr=(e,o)=>`hsl(${Math.abs(XM(o?.id||e))%37*10}, 100%, 83%)`,RE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},NE=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let d=11,c=14,p=l<0||l>n-d||s<0||s>r-c;l=Math.max(l,0),l=Math.min(l,n-d),s=Math.max(s,0),s=Math.min(s,r-c);let u=rr(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===_E.IDLE||f===_E.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===VM.DARK?"#2f6330":WM,y=m?.isSpeaking;y&&(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=dc,e.strokeStyle=dc,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 w=(y?l+0:l)+d/2,v=(y?s+0:s)+c+2,C=5,S=3,L=e.measureText(E),P=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,B=Math.max(P,12),k=w-1,A=v-1,F=L.width+2+C*2+2,Y=B+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(k,A,F,Y,8),e.fillStyle=u,e.fill(),e.strokeStyle=dc,e.stroke(),y&&(e.beginPath(),e.roundRect(k-2,A-2,F+4,Y+4,8),e.strokeStyle=x,e.stroke())):cc(e,k,A,F,Y,8,dc),e.fillStyle=YM,e.fillText(E,w+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((B-P)/2)+2),y){e.fillStyle=x;let Q=8,_=8,R=5;e.fillRect(k+F+_,A+(Y/2-Q/2),2,Q),e.fillRect(k+F+_+R,A+(Y/2-Q*2/2),2,Q*2),e.fillRect(k+F+_+R*2,A+(Y/2-Q/2),2,Q)}}e.restore(),e.closePath()}};import KM from"clsx";import{useState as ZM}from"react";import{jsx as BE}from"react/jsx-runtime";var xu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=RE(t),[a,l]=ZM(!1),s=!a&&n,m=s?void 0:{background:e};return BE("div",{className:KM("Avatar",r),style:m,onClick:o,children:s?BE("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as wo,jsxs as mc}from"react/jsx-runtime";var jM=N({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:FE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:FE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=rr(n,r),s=$M({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),m=r.isInCall?r.isSpeaking?mc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[wo("div",{}),wo("div",{}),wo("div",{})]}):r.isMuted?wo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:gb}):wo("div",{title:g("userList.hint.inCall"),children:hb}):null;return i?mc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[wo(xu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),wo("div",{className:"UserList__collaborator-name",children:r.username}),mc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&wo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Br}),m]})]}):mc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[wo(xu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),m&&wo("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as qM,randomId as JM}from"@excalidraw/common";import{deepCopyElement as QM}from"@excalidraw/element";import{CaptureUpdateAction as Eu}from"@excalidraw/element";var yu=N({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of qM)if(r.some(a=>a.type===i))return{captureUpdate:Eu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:JM(),status:"unpublished",elements:r.map(QM),created:Date.now()},...i])).then(()=>({captureUpdate:Eu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Eu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as ai}from"@excalidraw/element";import{isFrameLikeElement as eP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as tP}from"@excalidraw/element";import{KEYS as hn,arrayToMap as oP,getShortcutKey as pc}from"@excalidraw/common";import{alignElements as nP}from"@excalidraw/element";import{CaptureUpdateAction as li}from"@excalidraw/element";import{getSelectedElementsByGroup as rP}from"@excalidraw/element";import{jsx as ci}from"react/jsx-runtime";var gt=(e,o)=>{let t=o.scene.getSelectedElements(e);return rP(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>eP(n))},si=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=nP(r,n,t.scene,o),a=oP(i);return tP(e.map(l=>a.get(l.id)||l),o,t)},iP=N({name:"alignTop",label:"labels.alignTop",icon:Zm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"start",axis:"y"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Zm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${pc("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:we(ai(e),o)})}),aP=N({name:"alignBottom",label:"labels.alignBottom",icon:$m,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"end",axis:"y"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:$m,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${pc("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:we(ai(e),o)})}),lP=N({name:"alignLeft",label:"labels.alignLeft",icon:jm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"start",axis:"x"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:jm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${pc("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:we(ai(e),o)})}),sP=N({name:"alignRight",label:"labels.alignRight",icon:qm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"end",axis:"x"}),captureUpdate:li.IMMEDIATELY}),keyTest:e=>e[hn.CTRL_OR_CMD]&&e.shiftKey&&e.key===hn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:qm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${pc("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:we(ai(e),o)})}),cP=N({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Jm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"center",axis:"y"}),captureUpdate:li.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Jm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:we(ai(e),o)})}),dP=N({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Qm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>gt(o,n),perform:(e,o,t,n)=>({appState:o,elements:si(e,o,n,{position:"center",axis:"x"}),captureUpdate:li.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ci(Z,{hidden:!gt(o,n),type:"button",icon:Qm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:we(ai(e),o)})});import{getNonDeletedElements as OE}from"@excalidraw/element";import{isFrameLikeElement as mP}from"@excalidraw/element";import{CODES as zE,KEYS as HE,arrayToMap as pP,getShortcutKey as GE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as uP}from"@excalidraw/element";import{distributeElements as hP}from"@excalidraw/element";import{CaptureUpdateAction as UE}from"@excalidraw/element";import{getSelectedElementsByGroup as gP}from"@excalidraw/element";import{jsx as VE}from"react/jsx-runtime";var YE=(e,o)=>{let t=o.scene.getSelectedElements(e);return gP(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>mP(n))},WE=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=hP(r,t.scene.getNonDeletedElementsMap(),n,o),a=pP(i);return uP(e.map(l=>a.get(l.id)||l),o,t)},fP=N({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:WE(e,o,n,{space:"between",axis:"x"}),captureUpdate:UE.IMMEDIATELY}),keyTest:e=>!e[HE.CTRL_OR_CMD]&&e.altKey&&e.code===zE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>VE(Z,{hidden:!YE(o,n),type:"button",icon:x0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${GE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:we(OE(e),o)})}),bP=N({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:WE(e,o,n,{space:"between",axis:"y"}),captureUpdate:UE.IMMEDIATELY}),keyTest:e=>!e[HE.CTRL_OR_CMD]&&e.altKey&&e.code===zE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>VE(Z,{hidden:!YE(o,n),type:"button",icon:E0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${GE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:we(OE(e),o)})});import{getNonDeletedElements as xP}from"@excalidraw/element";import{bindOrUnbindLinearElements as EP,isBindingEnabled as yP}from"@excalidraw/element";import{getCommonBoundingBox as XE}from"@excalidraw/element";import{newElementWith as wP}from"@excalidraw/element";import{deepCopyElement as vP}from"@excalidraw/element";import{resizeMultipleElements as TP}from"@excalidraw/element";import{isArrowElement as IP,isElbowArrow as CP,isLinearElement as SP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as KE}from"@excalidraw/element";import{CODES as ZE,KEYS as kP,arrayToMap as MP}from"@excalidraw/common";import{CaptureUpdateAction as $E}from"@excalidraw/element";var wu=N({name:"flipHorizontal",label:"labels.flipHorizontal",icon:Eb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:KE(jE(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:$E.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ZE.H}),vu=N({name:"flipVertical",label:"labels.flipVertical",icon:xb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:KE(jE(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:$E.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ZE.V&&!e[kP.CTRL_OR_CMD]}),jE=(e,o,t,n,r)=>{let i=j(xP(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=PP(i,o,t,n,r),l=MP(a);return e.map(s=>l.get(s.id)||s)},PP=(e,o,t,n,r)=>{if(e.every(u=>IP(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return wP(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=XE(e);TP(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(u=>[u.id,vP(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),EP(e.filter(SP),yP(t),[],r.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>CP(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:d}=XE(e),[c,p]=[i-m,a-d];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as LP}from"@excalidraw/element";import{getTextFromElements as AP}from"@excalidraw/element";import{CODES as DP,KEYS as qE,isFirefox as _P}from"@excalidraw/common";import{CaptureUpdateAction as Rt}from"@excalidraw/element";var di=N({name:"copy",label:"labels.copy",icon:la,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await oc(r,n.files,t)}catch(i){return{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Rt.EVENTUALLY}},keyTest:void 0}),Tu=N({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await xE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),_P?{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(fE({types:r}))}catch(i){return console.error(i),{captureUpdate:Rt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Rt.EVENTUALLY}},keyTest:void 0}),uc=N({name:"cut",label:"labels.cut",icon:nb,trackEvent:{category:"element"},perform:(e,o,t,n)=>(di.perform(e,o,t,n),fa.perform(e,o,null,n)),keyTest:e=>e[qE.CTRL_OR_CMD]&&e.key===qE.X}),hc=N({name:"copyAsSvg",label:"labels.copyAsSvg",icon:yb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Rt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=er(e,o,!0);try{await tr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Rt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Rt.EVENTUALLY}}},predicate:e=>tc&&e.length>0,keywords:["svg","clipboard","copy"]}),gc=N({name:"copyAsPng",label:"labels.copyAsPng",icon:wb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Rt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=er(e,o,!0);try{return await tr("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Rt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Rt.EVENTUALLY}}},predicate:e=>oi&&e.length>0,keyTest:e=>e.code===DP.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),fc=N({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{ro(AP(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Rt.EVENTUALLY}},predicate:(e,o,t,n)=>tc&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(LP),keywords:["text","clipboard","copy"]});import{CODES as RP,KEYS as NP}from"@excalidraw/common";import{CaptureUpdateAction as BP}from"@excalidraw/element";var bc=N({name:"gridMode",icon:Sb,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:BP.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[NP.CTRL_OR_CMD]&&e.code===RP.QUOTE});import{CODES as FP,KEYS as OP}from"@excalidraw/common";import{CaptureUpdateAction as zP}from"@excalidraw/element";var mi=N({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:zP.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[OP.CTRL_OR_CMD]&&e.altKey&&e.code===FP.Z});import{CODES as HP,KEYS as GP}from"@excalidraw/common";import{CaptureUpdateAction as UP}from"@excalidraw/element";var Iu=N({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:vb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:UP.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[GP.CTRL_OR_CMD]&&e.altKey&&e.code===HP.S});import{CODES as YP,KEYS as WP}from"@excalidraw/common";import{CaptureUpdateAction as VP}from"@excalidraw/element";var pi=N({name:"stats",label:"stats.fullTitle",icon:bb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:VP.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[WP.CTRL_OR_CMD]&&e.altKey&&e.code===YP.SLASH});import{BOUND_TEXT_PADDING as JE,ROUNDNESS as QE,TEXT_ALIGN as ty,VERTICAL_ALIGN as oy,arrayToMap as ny,getFontString as XP}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as KP,resetOriginalContainerCache as ZP,updateOriginalContainerCache as $P}from"@excalidraw/element";import{computeBoundTextPosition as jP,computeContainerDimensionForBoundText as ey,getBoundTextElement as ry,redrawTextBoundingBox as iy}from"@excalidraw/element";import{hasBoundTextElement as qP,isArrowElement as JP,isTextBindableContainer as Cu,isTextElement as Ga,isUsingAdaptiveRadius as QP}from"@excalidraw/element";import{measureText as eL}from"@excalidraw/element";import{syncMovedIndices as ay}from"@excalidraw/element";import{newElement as tL}from"@excalidraw/element";import{CaptureUpdateAction as Su}from"@excalidraw/element";var ku=N({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>qP(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=ry(a,i);if(l){let{width:s,height:m}=eL(l.originalText,XP(l),l.lineHeight),d=KP(a.id);ZP(a.id);let{x:c,y:p}=jP(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:c,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:o,captureUpdate:Su.IMMEDIATELY}}}),Mu=N({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=Ga(r[0])||Ga(r[1]),a;if(Cu(r[0])?a=r[0]:Cu(r[1])&&(a=r[1]),i&&a&&ry(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;Ga(r[0])&&Cu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:oy.MIDDLE,textAlign:ty.CENTER,autoResize:!0,angle:JP(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return iy(i,a,n.scene),$P(a.id,l),{elements:oL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Su.IMMEDIATELY}}}),oL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),ay(n,ny([o,t])),n},nL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),ay(n,ny([o,t])),n},ly=N({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>Ga(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if(Ga(l)){let s=tL({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:QP("rectangle")?QE.ADAPTIVE_RADIUS:QE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-JE,y:l.y-JE,width:ey(l.width,"rectangle"),height:ey(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>m.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(c,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:oy.MIDDLE,boundElements:null,textAlign:ty.CENTER,autoResize:!0}),iy(l,s,n.scene),i=nL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Su.IMMEDIATELY}}});import{isEmbeddableElement as yL}from"@excalidraw/element";import{KEYS as by,getShortcutKey as wL}from"@excalidraw/common";import{CaptureUpdateAction as vL}from"@excalidraw/element";import{pointFrom as my}from"@excalidraw/math";import rL from"clsx";import{useCallback as sy,useEffect as cy,useLayoutEffect as iL,useRef as aL,useState as lL}from"react";import{EVENT as Pu,HYPERLINK_TOOLTIP_DELAY as sL,KEYS as xc}from"@excalidraw/common";import{getElementAbsoluteCoords as Ru}from"@excalidraw/element";import{hitElementBoundingBox as cL}from"@excalidraw/element";import{isElementLink as dL}from"@excalidraw/element";import{getEmbedLink as mL,embeddableURLValidator as pL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as py,viewportCoordsToSceneCoords as uL,wrapEvent as hL,isLocalLink as gL,normalizeLink as Lu}from"@excalidraw/common";import{isEmbeddableElement as Au}from"@excalidraw/element";import{jsx as ui,jsxs as dy}from"react/jsx-runtime";var Nu=380,fL=42,Du=5,uy=85,bL=500,_u=!1,Ec=new Map,hy=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=bo(),s=xo(),m=de(),d=e.link||"",[c,p]=lL(d),u=aL(null),f=l.showHyperlinkPopup==="editor",b=sy(()=>{if(!u.current)return;let v=Lu(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),Au(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!pL(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Ec.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=mL(v);L?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let P=L?L.intrinsicSize.w/L.intrinsicSize.h:1,B=Ec.get(e.id)!==e.link;o.mutateElement(e,{...B?{width:L?.type==="video"?C>S?C:S*P:C,height:L?.type==="video"&&C>S?C/P:S}:{},link:v}),i(e,!0),Ec.has(e.id)&&Ec.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);iL(()=>()=>{b()},[b]),cy(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),cy(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),EL(e,a,l,my(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},bL))};return window.addEventListener(Pu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(Pu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=sy(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),y=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=gy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:dy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:Nu,padding:Du},children:[f?ui("input",{className:rL("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[xc.CTRL_OR_CMD]&&v.key===xc.K&&v.preventDefault(),(v.key===xc.ENTER||v.key===xc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?ui("a",{href:Lu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:gL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let C=hL(Pu.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Lu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ui("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),dy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ui(Z,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:tn}),ui(Z,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:bs}),d&&!Au(e)&&ui(Z,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Mt})]})]})},gy=(e,o,t)=>{let[n,r]=Ru(e,t),{x:i,y:a}=py({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-Nu/2,s=a-o.offsetTop-uy;return{x:l,y:s}},Bu=(e,o)=>{let t=j(e,o);return Au(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ua=null,fy=(e,o,t)=>{Ua&&clearTimeout(Ua),Ua=window.setTimeout(()=>xL(e,o,t),sL)},xL=(e,o,t)=>{if(!e.link)return;let n=Qr();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=dL(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Ru(e,t),[s,m,d,c]=E1([r,i,a,l],e.angle,o),p=py({sceneX:s,sceneY:m},o);Zp(n,{left:p.x,top:p.y,width:d,height:c},"top"),re("hyperlink","tooltip","link-icon"),_u=!0},Fu=()=>{Ua&&clearTimeout(Ua),_u&&(_u=!1,Qr().classList.remove("excalidraw-tooltip--visible"))},EL=(e,o,t,[n,r])=>{let{x:i,y:a}=uL({clientX:n,clientY:r},t),l=15/t.zoom.value;if(cL(my(i,a),e,o))return!1;let[s,m,d]=Ru(e,o);if(i>=s&&i<=d&&a>=m-uy&&a<=m)return!1;let{x:c,y:p}=gy(e,t,o);return!(n>=c-l&&n<=c+Nu+Du*2+l&&r>=p-l&&r<=p+l+Du*2+fL)};import{jsx as TL}from"react/jsx-runtime";var Ya=N({name:"hyperlink",label:(e,o)=>Bu(e,o),icon:da,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:vL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[by.CTRL_OR_CMD]&&e.key===by.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=j(e,o);return TL(Z,{type:"button",icon:da,"aria-label":g(Bu(e,o)),title:`${yL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${wL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as xy,arrayToMap as zu,randomId as IL}from"@excalidraw/common";import{elementsAreInSameGroup as CL,newElementWith as Ey,selectGroupsFromGivenElements as yy}from"@excalidraw/element";import{CaptureUpdateAction as wy}from"@excalidraw/element";var Ou=e=>e.every(o=>!o.locked),Wa=N({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Ou(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return Ou(t)?Lr:Vn},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Ou(r),a=zu(r),l=r.length>1&&CL(r),m=r.length===1||l?null:IL(),d={...o.lockedMultiSelections};if(i)d={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let y=r[0].groupIds.at(-1);delete d[y]}let c=e.map(y=>{if(!a.has(y.id))return y;let E=y.groupIds;return i?m&&(E=[...E,m]):E=E.filter(w=>!o.lockedMultiSelections[w]),Ey(y,{locked:i,groupIds:E.length!==y.groupIds.length?E:y.groupIds})}),p=zu(c),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),f=r.map(y=>p.get(y.id)||y),b=i?{}:yy(f,o),x=i?m||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:wy.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===xy.L&&e[xy.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),vy=N({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Vn,predicate:(e,o)=>j(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return Ey(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=zu(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:yy(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:wy.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as ND,isLinearElement as BD,isLineElement as Ai}from"@excalidraw/element";import{arrayToMap as FD,invariant as zh}from"@excalidraw/common";import{toggleLinePolygonState as OD,CaptureUpdateAction as kw}from"@excalidraw/element";import Q2 from"clsx";import M7 from"fuzzy";import{useEffect as qc,useRef as P7,useState as jc}from"react";import{DEFAULT_SIDEBAR as q2,EVENT as Qc,KEYS as lo,capitalizeString as L7,getShortcutKey as A7,isWritableElement as D7}from"@excalidraw/common";import{CaptureUpdateAction as lA}from"@excalidraw/element";import{useEffect as Ka,useMemo as Ty,useRef as Yu,useState as SL}from"react";import{getLinearElementSubType as fi,updateElbowArrowPoints as kL}from"@excalidraw/element";import{pointFrom as wc,pointRotateRads as ML}from"@excalidraw/math";import{hasBoundTextElement as PL,isArrowBoundToElement as LL,isArrowElement as AL,isElbowArrow as DL,isLinearElement as Ku,isUsingAdaptiveRadius as _L}from"@excalidraw/element";import{getCommonBoundingBox as RL,getElementAbsoluteCoords as NL}from"@excalidraw/element";import{getBoundTextElement as My,getBoundTextMaxHeight as BL,getBoundTextMaxWidth as FL,redrawTextBoundingBox as OL}from"@excalidraw/element";import{wrapText as zL}from"@excalidraw/element";import{assertNever as HL,CLASSES as GL,getFontString as Hu,isProdEnv as UL,mapFind as YL,reduceToCommonValue as WL,updateActiveTool as Iy}from"@excalidraw/common";import{measureText as Cy}from"@excalidraw/element";import{LinearElementEditor as VL}from"@excalidraw/element";import{newArrowElement as Gu,newElement as XL,newLinearElement as KL}from"@excalidraw/element";import{ShapeCache as ZL}from"@excalidraw/element";import{updateBindings as $L}from"@excalidraw/element";import{jsx as Xu}from"react/jsx-runtime";var jL=8,qL=10,Va=["rectangle","diamond","ellipse"],Xa=["line","sharpArrow","curvedArrow","elbowArrow"],JL=new Set(Va),QL=new Set(Xa),bi=e=>JL.has(e),Tc=e=>e==="arrow"||QL.has(e),ao=he(null),Za=new Map,$a=new Map,eA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Yu(null);return Ka(()=>{if(o.length===0){e.updateEditorAtom(ao,null);return}let n=xi(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(ao,null),t.current=null)},[o,e]),Ka(()=>()=>{Za.clear(),$a.clear()},[]),Xu(tA,{app:e,elements:o})},tA=({app:e,elements:o})=>{let t=xi(o),n=Ty(()=>t==="generic"?Ly(o):[],[t,o]),r=Ty(()=>t==="linear"?Vu(o):[],[t,o]),i=t==="generic"?n.every(c=>c.type===n[0].type):t==="linear"?r.every(c=>fi(c)===fi(r[0])):!1,[a,l]=SL({x:0,y:0}),s=Yu(""),m=Yu(null);Ka(()=>{let c=[...n,...r].sort((x,y)=>x.id.localeCompare(y.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,,,y,E,w]=NL(c[0],e.scene.getNonDeletedElementsMap());u=ML(wc(x,y),wc(E,w),c[0].angle)}else{let{minX:x,maxY:y}=RL(c);u=wc(x,y)}let{x:f,y:b}=Dy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),Ka(()=>{for(let c of r){let p=Wu(c.id,aA(c));$a.has(p)||$a.set(p,c)}},[r]),Ka(()=>{for(let c of n)if(!Za.has(c.id)){let p=My(c,e.scene.getNonDeletedElementsMap());p&&Za.set(c.id,{fontSize:p.fontSize})}},[n,e.scene]);let d=t==="linear"?[["line",rs],["sharpArrow",Fr],["curvedArrow",zr],["elbowArrow",Or]]:t==="generic"?[["rectangle",ts],["diamond",os],["ellipse",ns]]:[];return Xu("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(qL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-jL}px`,zIndex:2},className:GL.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([c,p])=>{let u=i&&(t==="generic"&&n[0].type===c||t==="linear"&&fi(r[0])===c);return Xu(Z,{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"),Zu(e,{conversionType:t,nextType:c}),m.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},oA=(e,o,t)=>{let n=FL(e,o),r=BL(e,o),i=zL(o.text,Hu(o),n),a=Cy(i,Hu(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=Cy(o.text,Hu(s),o.lineHeight)}Ic(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),OL(o,e,t)},Zu=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=Ly(r),m=l.every(d=>d.type===l[0].type)?Va.indexOf(l[0].type):-1;if(t=t??Va[(m+Va.length+a)%Va.length],t&&bi(t)){let d={};for(let p of l){let u=ky(p,t,e);d[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?c.push(d[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(d)){let u=My(p,e.scene.getNonDeletedElementsMap());u&&(Za.get(p.id)&&Ic(u,e.scene.getNonDeletedElementsMap(),{fontSize:Za.get(p.id)?.fontSize??u.fontSize}),oA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Iy(p,{type:"selection"})}))}}if(o==="linear"){let l=Vu(r);if(!t){let m=WL(l,fi),d=m?Xa.indexOf(m):-1;t=Xa[(d+Xa.length+a)%Xa.length]}if(Tc(t)){let m=[],d=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=$a.get(Wu(c.id,t));if(p&&fi(p)===t)d.set(p.id,p),m.push(p);else{let u=ky(c,t,e);d.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(d);for(let c of m)if(Ku(c))if(DL(c)){let p=nA(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=kL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Ic(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=YL(["line","sharpArrow","curvedArrow"],u=>$a.get(Wu(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Vu(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new VL(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Iy(m,{type:"selection"})}))}return!0},xi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(bi(t.type))return"generic";Py(t)&&(o=!0)}return o?"linear":null},Py=e=>Ku(e)&&(!AL(e)||!LL(e)&&!PL(e)),Wu=(e,o)=>`${e}:${o}`,Ly=e=>e.filter(o=>bi(o.type)),Vu=e=>e.filter(o=>Py(o)),yc=20,hi=(e,o)=>e[0]===o[0],Uu=(e,o)=>e[1]===o[1],Sy=(e,o)=>hi(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),nA=e=>{let o=[e.points[0]],t=rA(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])<yc?l[0]=a[0]:Math.abs(l[1]-a[1])<yc&&(l[1]=a[1]),hi(a,l)||Uu(a,l)||o.push(wc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)hi(o[i-1],o[i])&&hi(o[i],o[i+1])||Uu(o[i-1],o[i])&&Uu(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],m=hi(a,l),d=hi(l,s);if(m!==d){let c=Sy(a,l),p=Sy(l,s);if(c<yc||p<yc){if(p<c)m?s[0]=a[0]:s[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},rA=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},ky=(e,o,t)=>{if(!iA(e.type,o)){if(!UL())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(ZL.delete(e),bi(o)){let n=gi(XL({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:_L(o)?vc.ADAPTIVE_RADIUS:vc.PROPORTIONAL_RADIUS}:e.roundness}));return $L(n,t.scene),n}if(Tc(o))switch(o){case"line":return gi(KL({...e,type:"line"}));case"sharpArrow":return gi(Gu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return gi(Gu({...e,type:"arrow",elbowed:!1,roundness:{type:vc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return gi(Gu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return HL(o,`unhandled conversion type: ${o}`),e},iA=(e,o)=>!!(bi(e)&&bi(o)||Tc(e)&&Tc(o)),aA=e=>Ku(e)?fi(e):e.type,Ay=eA;var _y=N({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return Ue.set(ao,{type:"panel"}),{captureUpdate:lA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>xi(e)!==null});import{canCreateLinkFromElements as $u,defaultGetElementLinkFromSelection as sA,getLinkIdAndTypeFromSelection as cA}from"@excalidraw/element";import{CaptureUpdateAction as ja}from"@excalidraw/element";var Cc=N({name:"copyElementLink",label:"labels.copyElementLink",icon:Rr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=j(e,o);try{if(window.location){let i=cA(r,o);return i?(await ro(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):sA(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:ja.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:ja.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:ja.EVENTUALLY}},predicate:(e,o)=>$u(j(e,o))}),Ry=N({name:"linkToElement",label:"labels.linkToElement",icon:bs,perform:(e,o,t,n)=>{let r=j(e,o);return r.length!==1||!$u(r)?{elements:e,appState:o,app:n,captureUpdate:ja.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:ja.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&$u(r)},trackEvent:!1});import{isDarwin as Ny,getShortcutKey as ne}from"@excalidraw/common";var dA={toggleTheme:[ne("Shift+Alt+D")],saveScene:[ne("CtrlOrCmd+S")],loadScene:[ne("CtrlOrCmd+O")],clearCanvas:[ne("CtrlOrCmd+Delete")],imageExport:[ne("CtrlOrCmd+Shift+E")],commandPalette:[ne("CtrlOrCmd+/"),ne("CtrlOrCmd+Shift+P")],cut:[ne("CtrlOrCmd+X")],copy:[ne("CtrlOrCmd+C")],paste:[ne("CtrlOrCmd+V")],copyStyles:[ne("CtrlOrCmd+Alt+C")],pasteStyles:[ne("CtrlOrCmd+Alt+V")],selectAll:[ne("CtrlOrCmd+A")],deleteSelectedElements:[ne("Delete")],duplicateSelection:[ne("CtrlOrCmd+D"),ne(`Alt+${g("helpDialog.drag")}`)],sendBackward:[ne("CtrlOrCmd+[")],bringForward:[ne("CtrlOrCmd+]")],sendToBack:[Ny?ne("CtrlOrCmd+Alt+["):ne("CtrlOrCmd+Shift+[")],bringToFront:[Ny?ne("CtrlOrCmd+Alt+]"):ne("CtrlOrCmd+Shift+]")],copyAsPng:[ne("Shift+Alt+C")],group:[ne("CtrlOrCmd+G")],ungroup:[ne("CtrlOrCmd+Shift+G")],gridMode:[ne("CtrlOrCmd+'")],zenMode:[ne("Alt+Z")],objectsSnapMode:[ne("Alt+S")],stats:[ne("Alt+/")],addToLibrary:[],flipHorizontal:[ne("Shift+H")],flipVertical:[ne("Shift+V")],viewMode:[ne("Alt+R")],hyperlink:[ne("CtrlOrCmd+K")],toggleElementLock:[ne("CtrlOrCmd+Shift+L")],resetZoom:[ne("CtrlOrCmd+0")],zoomOut:[ne("CtrlOrCmd+-")],zoomIn:[ne("CtrlOrCmd++")],zoomToFitSelection:[ne("Shift+3")],zoomToFit:[ne("Shift+1")],zoomToFitSelectionInViewport:[ne("Shift+2")],toggleEraserTool:[ne("E")],toggleHandTool:[ne("H")],setFrameAsActiveTool:[ne("F")],saveFileToDisk:[ne("CtrlOrCmd+S")],saveToActiveFile:[ne("CtrlOrCmd+S")],toggleShortcuts:[ne("?")],searchMenu:[ne("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Fe=(e,o=0)=>{let t=dA[e];return t&&t.length>0?t[o]||t[0]:""};var mA="\\u0300-\\u036f",pA="\\ufe20-\\ufe2f",uA="\\u20d0-\\u20ff",hA=mA+pA+uA,gA=`[${hA}]`,fA=RegExp(gA,"g"),bA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xA={\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"},ju=e=>e.replace(bA,o=>xA[o]||o).replace(fA,"");import l7 from"clsx";import{useEffect as s7,useState as c7}from"react";import{KEYS as d7,queryFocusableElements as _2}from"@excalidraw/common";import{useCallback as EA,useState as yA}from"react";var By=()=>{let[e,o]=yA(null),t=EA(n=>o(n),[]);return[e,t]};import{useState as k2,useCallback as ph,useMemo as M2,useEffect as I2,memo as P2,useRef as j8}from"react";import{LIBRARY_DISABLED_TYPES as q8,randomId as J8,isShallowEqual as Q8}from"@excalidraw/common";import{useEffect as Hy,useRef as Gy}from"react";import{URL_HASH_KEYS as Qu,URL_QUERY_KEYS as eh,APP_NAME as Uy,EVENT as kc,DEFAULT_SIDEBAR as CA,LIBRARY_SIDEBAR_TAB as SA,arrayToMap as th,cloneJSON as kA,preventUnload as MA,promiseTry as Yy,resolvablePromise as PA,toValidURL as LA,Queue as AA,Emitter as DA}from"@excalidraw/common";import{hashElementsVersion as _A,hashString as RA}from"@excalidraw/element";import{getCommonBoundingBox as Ju}from"@excalidraw/element";import{MIME_TYPES as ir}from"@excalidraw/common";var gn=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Sr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:d}=s;return Kl(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=n<b?n/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Fy=async e=>{let{mimeType:o=ir.png,quality:t}=e;o===ir.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ir.png}" mimeType`),o==="image/jpg"&&(o=ir.jpg),o===ir.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ir.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await gn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ir.png&&e.appState?.exportEmbedScene&&(a=await M1({blob:a,metadata:ta(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Ei=async({elements:e,appState:o=Qo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=Sr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),d={...m,exportPadding:n};return Cr(s,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},wA=async e=>{if(e.type==="svg"){let o=await Ei(e);await ro(o.outerHTML)}else if(e.type==="png")await nc(Fy(e));else if(e.type==="json")await oc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as vA,useState as TA}from"react";import{COLOR_PALETTE as IA}from"@excalidraw/common";var qu=he(new Map),Oy=async e=>await Ei({elements:e,appState:{exportBackground:!1,viewBackgroundColor:IA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),zy=(e,o,t)=>{let[n,r]=TA();return vA(()=>{if(o)if(e){let i=t.get(e);i?r(i):(async()=>{let a=await Oy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),r(a))})()}else(async()=>{let i=await Oy(o);r(i)})()},[e,o,t,r]),n},Sc=()=>{let[e]=le(qu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var NA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Vy=new DA,ar=he({status:"loaded",isInitialized:!1,libraryItems:[]}),qa=e=>kA(e),BA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),Xy=(e,o)=>{let t=[];for(let n of o)BA(e,n)&&t.push(n);return[...t,...e]},Ky=(e,o)=>{let t=th(o),n={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=th(e);for(let i of o)r.has(i.id)||n.addedItems.set(i.id,i);return n},oh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",qa(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)Ue.set(ar,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ue.set(ar,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=qa(this.currLibraryItems);let t=qa(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Vy.trigger(Ky(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ue.set(qu,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(qa(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:CA.name,tab:SA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await _m(s,i):m=ra(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(n?Xy(this.currLibraryItems,m):m)):l(new Tr)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=qa(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Zy=oh,Lc=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:y}=Ju(x.elements);return Math.max(b,y)},0),i=u=>{let f=0,b=0,x=0;for(let y of e){if(f%t===0&&(b=0),b===u){let{width:E}=Ju(y.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,d=0,c=0,p=0;for(let u of e){d&&d%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=r(p)),m=i(c);let{minX:f,minY:b,width:x,height:y}=Ju(u.elements),E=(m-x)/2,w=(s-y)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+w-b}))),a+=m+50,d++,c++}return n},FA=(e,o=NA)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},nh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Qu.addLibrary)||new URLSearchParams(window.location.search).get(eh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},fn=class fn{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(ra(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?fn.queue.push(r):r()}getLibraryItems(o){return fn.getLibraryItems(this.adapter,o,!1)}};I(fn,"queue",new AA),I(fn,"run",async(o,t)=>{let n=new fn(o);return fn.queue.push(()=>t(n))});var yi=fn,Ja=0,Mc=0,Pc=e=>RA(e.map(o=>`${o.id}:${_A(o.elements)}`).sort().join()),Wy=async(e,o)=>{try{return Mc++,await yi.run(e,async t=>{let n=th(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);let i=r.concat(Array.from(n.values())),a=Pc(i);return a!==Ja&&await e.save({libraryItems:i}),Ja=a,i})}finally{Mc--}},OA=e=>{let{excalidrawAPI:o}=e,t=Gy(e);t.current=e;let n=Gy(!1);Hy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=LA(l),FA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),d=s!==o.id;await(d&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(Qu.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(Qu.addLibrary),window.history.replaceState({},Uy,`#${c.toString()}`)}else if(window.location.search.includes(eh.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(eh.addLibrary),window.history.replaceState({},Uy,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=nh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=nh();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,m=PA();s?m.resolve(Yy(s.load).then(async d=>{let c=null;try{if(!d)return yi.getLibraryItems(l,"load");c=ra(d.libraryItems||[],"published");let p=await Wy(l,Ky([],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(d=>(console.error(`error during library migration: ${d.message}`),yi.getLibraryItems(l,"load")))):m.resolve(Yy(yi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(d=>{let c=d||[];return Ja=Pc(c),c}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(kc.HASHCHANGE,i),()=>{window.removeEventListener(kc.HASHCHANGE,i)}},[o]),Hy(()=>{let r=Vy.on(async(a,l)=>{let s=n.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&Ja!==Pc(l)&&await Wy(m,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Mc&&MA(a)};return window.addEventListener(kc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(kc.BEFORE_UNLOAD,i),r(),Ja=0,Mc=0}},[])};import UA from"clsx";import{VERSIONS as zA}from"@excalidraw/common";import{jsx as GA}from"react/jsx-runtime";var HA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return GA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${zA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},$y=HA;import{jsx as YA,jsxs as WA}from"react/jsx-runtime";var Ac=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>WA("div",{className:UA("library-menu-control-buttons",i),style:n,children:[YA($y,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Ti,useEffect as U8,useMemo as v2,useRef as Y8,useState as W8}from"react";import{MIME_TYPES as V8,arrayToMap as X8}from"@excalidraw/common";import{duplicateElements as K8}from"@excalidraw/element";import VA from"lodash.throttle";import{useEffect as XA}from"react";var KA=he(0),jy=e=>{let[o,t]=le(KA);return XA(()=>{let{current:n}=e;if(!n)return;let r=VA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import C8 from"clsx";import{useCallback as S8,useState as lh}from"react";import{muteFSAbortError as k8}from"@excalidraw/common";import{flushSync as qy}from"react-dom";import ZA from"clsx";import{jsx as Dc,jsxs as jA}from"react/jsx-runtime";var $A=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return jA("button",{className:ZA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Dc("div",{style:a?{visibility:"hidden"}:{},children:n}),Dc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Dc("div",{style:{position:"absolute",inset:0},children:Dc(tt,{})})]})},Ho=$A;import{jsx as Jy,jsxs as Qy}from"react/jsx-runtime";var qA=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=ae(),m=en(wi),{container:d}=Ne();return Qy(Oe,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,Qy("div",{className:"confirm-dialog-buttons",children:[Jy(Ho,{label:i,onClick:()=>{s({openMenu:null}),m(!1),qy(()=>{t()}),d?.focus()}}),Jy(Ho,{label:r,onClick:()=>{s({openMenu:null}),m(!1),qy(()=>{o()}),d?.focus()},actionType:"danger"})]})]})},_c=qA;import Nc from"open-color";import{useCallback as r8,useEffect as ah,useRef as e2,useState as rh}from"react";import{EDITOR_LS_KEYS as ih,EXPORT_DATA_TYPES as i8,MIME_TYPES as t2,VERSIONS as a8,chunk as l8,getExportSource as s8}from"@excalidraw/common";var Wt=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(Wt,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),I(Wt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Rc from"react";var JA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,QA=/{{([\w-]+)}}/,e8=/<([\w-]+)>/,t8=/<\/([\w-]+)>/,o8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(JA).filter(Boolean).forEach(n=>{let r=n.match(e8),i=n.match(t8),a=n.match(QA);if(r!==null){let l=r[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),m=Rc.createElement(Rc.Fragment,{},...s.children),d=o[s.name];typeof d=="function"&&t[t.length-1].children.push(d(m))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},n8=({i18nKey:e,children:o,...t})=>{let{t:n}=Ge();return Rc.createElement(Rc.Fragment,{},...o8(n(e),t))},ft=n8;import{jsx as se,jsxs as lt}from"react/jsx-runtime";var c8=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=l8(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle=Nc.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let d=await gn({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=d,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(d,f+(128-c)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=Nc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await jl(new File([await Ao(a)],"preview",{type:t2.png}),{outputType:t2.jpg,maxWidthOrHeight:5e3})},d8=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=e2(null),a=e2(null);return ah(()=>{let l=i.current;l&&(async()=>{let s=await Ei({elements:e.elements,appState:{...o,viewBackgroundColor:Nc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),lt("div",{className:"single-library-item",children:[e.status==="published"&&se("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),se("div",{ref:i,className:"single-library-item__svg"}),se(Z,{"aria-label":g("buttons.remove"),type:"button",icon:zt,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),lt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[lt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[lt("div",{style:{padding:"0.5em 0"},children:[se("span",{style:{fontWeight:500,color:Nc.gray[6]},children:g("publishDialog.itemName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),se("span",{className:"error",children:e.error})]})]})},m8=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=rh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,d]=rh(!1);ah(()=>{let w=Wt.get(ih.PUBLISH_LIBRARY);w&&s(w)},[]);let[c,p]=rh(o.slice());ah(()=>{p(o.slice())},[o]);let u=w=>{s({...l,[w.target.name]:w.target.value})},f=async w=>{w.preventDefault(),d(!0);let v=[],C=!1;if(c.forEach(A=>{let F="";A.name||(F=g("publishDialog.errors.required"),C=!0),v.push({...A,error:F})}),C){p(v),d(!1);return}let S=await c8(c),L={type:i8.excalidrawLibrary,version:a8.excalidrawLibrary,source:s8(),libraryItems:c},P=JSON.stringify(L,null,2),B=new Blob([P],{type:"application/json"}),k=new FormData;k.append("excalidrawLib",B),k.append("previewImage",S),k.append("previewImageType",S.type),k.append("title",l.name),k.append("authorName",l.authorName),k.append("githubHandle",l.githubHandle),k.append("name",l.name),k.append("description",l.description),k.append("twitterHandle",l.twitterHandle),k.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:k}).then(A=>A.ok?A.json().then(({url:F})=>{Wt.delete(ih.PUBLISH_LIBRARY),n({url:F,authorName:l.authorName,items:c})}):A.json().catch(()=>{throw new Error(A.statusText||"something went wrong")}).then(F=>{throw new Error(F.message||A.statusText||"something went wrong")}),A=>{console.error(A),r(A),d(!1)}).catch(A=>{console.error(A),r(A),d(!1)})},b=()=>{let w=[];return c.forEach((v,C)=>{w.push(se("div",{className:"single-library-item-wrapper",children:se(d8,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let P=c.slice();P[L].name=S,p(P)},onRemove:a})},C))}),se("div",{className:"selected-library-items",children:w})},x=r8(()=>{i(c),Wt.set(ih.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),y=!!o.length,E=o.some(w=>w.status==="published");return se(Oe,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:y?lt("form",{onSubmit:f,children:[se("div",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteDescription",link:w=>se("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:w})})}),se("span",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteGuidelines",link:w=>se("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),se("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&se("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),lt("div",{className:"publish-library__fields",children:[lt("label",{children:[lt("div",{children:[se("span",{children:g("publishDialog.libraryName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),lt("label",{style:{alignItems:"flex-start"},children:[lt("div",{children:[se("span",{children:g("publishDialog.libraryDesc")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),lt("label",{children:[lt("div",{children:[se("span",{children:g("publishDialog.authorName")}),se("span",{"aria-hidden":"true",className:"required",children:"*"})]}),se("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),lt("label",{children:[se("span",{children:g("publishDialog.githubUsername")}),se("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),lt("label",{children:[se("span",{children:g("publishDialog.twitterUsername")}),se("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),lt("label",{children:[se("span",{children:g("publishDialog.website")}),se("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),se("span",{className:"publish-library-note",children:se(ft,{i18nKey:"publishDialog.noteLicense",link:w=>se("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),lt("div",{className:"publish-library__buttons",children:[se(Ho,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),se(Ho,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:m})]})]}):se("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},o2=m8;import h8 from"clsx";import{useEffect as g8,useRef as f8}from"react";import{EVENT as a2,KEYS as b8}from"@excalidraw/common";import{forwardRef as n2}from"react";import r2 from"clsx";import{jsx as i2}from"react/jsx-runtime";var p8=n2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>i2("div",{className:r2("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),u8=n2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>i2("div",{className:r2("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),qe={Row:p8,Col:u8};import{jsx as Bc}from"react/jsx-runtime";var l2=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r})=>{let i=de(),a=f8(null),l=on({onClickOutside:o});Wr(a,()=>{l.onClickOutside?.()}),g8(()=>{let m=c=>{c.key===b8.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener(a2.KEYDOWN,m,d),()=>{document.removeEventListener(a2.KEYDOWN,m,d)}},[l]);let s=h8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Bc(Ap.Provider,{value:{onSelect:n},children:Bc("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?Bc(qe.Col,{className:"dropdown-menu-container",children:e}):Bc(Ye,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};l2.displayName="DropdownMenuContent";var s2=l2;import{jsx as E8}from"react/jsx-runtime";var x8=({children:e,className:o="",selected:t,...n})=>E8("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),c2=x8;import{jsx as d2}from"react/jsx-runtime";var m2=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let m=zs(s.onClick,r);return d2("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Os(i,a),title:s.title??s["aria-label"],onClick:m,children:d2(Fs,{icon:e,shortcut:o,children:n})})},vi=m2;m2.displayName="DropdownMenuItemLink";import{jsx as y8}from"react/jsx-runtime";var p2=()=>y8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),u2=p2;p2.displayName="DropdownMenuSeparator";import w8 from"clsx";import{jsx as v8}from"react/jsx-runtime";var h2=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=de(),a=w8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return v8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},g2=h2;h2.displayName="DropdownMenuTrigger";import Fc from"react";var f2=e=>{let o=Fc.Children.toArray(e).find(t=>Fc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},b2=e=>{let o=Fc.Children.toArray(e).find(t=>Fc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as T8,jsxs as I8}from"react/jsx-runtime";var Go=({children:e,open:o})=>{let t=f2(e),n=b2(e);return I8(T8,{children:[t,o&&n]})};Go.Trigger=g2;Go.Content=s2;Go.Item=pt;Go.ItemLink=vi;Go.ItemCustom=c2;Go.Group=Ta;Go.Separator=u2;var xe=Go;Go.displayName="DropdownMenu";import{jsx as vt,jsxs as Oc}from"react/jsx-runtime";var M8=(e,o)=>e.filter(t=>o.includes(t.id)),P8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=le(ar),[m,d]=le(wi),c=()=>{let k=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),A=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return vt(_c,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:A,children:vt("p",{children:k})})},[p,u]=lh(!1),f=!!o.length,b=f?s.libraryItems.filter(k=>o.includes(k.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[y,E]=lh(!1),[w,v]=lh(null),C=S8(()=>Oc(Oe,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[vt("p",{children:vt(ft,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:k=>vt("a",{href:w?.url,target:"_blank",rel:"noopener noreferrer",children:k})})}),vt(Z,{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,w]),S=(k,A)=>{E(!1),v({url:k.url,authorName:k.authorName});let F=A.slice();F.forEach(Y=>{o.includes(Y.id)&&(Y.status="published")}),t.setLibrary(F)},L=async()=>{try{await t.updateLibrary({libraryItems:Ul({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(k){if(k?.name==="AbortError"){console.warn(k);return}e({errorMessage:g("errors.importLibraryError")})}},P=async()=>{let k=f?b:await t.getLatestLibrary();x1(k).catch(k8).catch(A=>{e({errorMessage:A.message})})},B=()=>Oc(xe,{open:m,children:[vt(xe.Trigger,{onToggle:()=>d(!m),children:V1}),Oc(xe.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!f&&vt(xe.Item,{onSelect:L,icon:_r,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&vt(xe.Item,{onSelect:P,icon:Xn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&vt(xe.Item,{onSelect:()=>u(!0),icon:Mt,children:x}),f&&vt(xe.Item,{icon:ob,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Oc("div",{className:C8("library-menu-dropdown-container",l),children:[B(),o.length>0&&vt("div",{className:"library-actions-counter",children:o.length}),p&&c(),y&&vt(o2,{onClose:()=>E(!1),libraryItems:M8(s.libraryItems,o),appState:a,onSuccess:k=>S(k,s.libraryItems),onError:k=>window.alert(k),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:k=>i(o.filter(A=>A!==k))}),w&&C()]})},sh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Be(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Sc(),a=be(),l=ae(),[s]=le(ar),m=async c=>{let p=c.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return vt(P8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as O8,useEffect as z8,useState as H8}from"react";import L8,{useCallback as A8}from"react";function D8(){return[!1,A8(o=>o(),[])]}var x2=L8.useTransition||D8;import E2 from"clsx";import{memo as _8,useEffect as R8,useRef as N8,useState as B8}from"react";import{jsx as zc,jsxs as F8}from"react/jsx-runtime";var y2=_8(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=N8(null),m=zy(e,o,l);R8(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[d,c]=B8(!1),p=de().editor.isMobile,u=t&&zc("div",{className:"library-unit__adder",children:W1});return F8("div",{className:E2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&d,"library-unit--selected":r,"library-unit--skeleton":!m}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[zc("div",{className:E2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&o&&(d||p||r)&&zc(Da,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),w2=()=>zc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as G8,jsx as Hc}from"react/jsx-runtime";var ch=({children:e})=>Hc("div",{className:"library-menu-items-container__grid",children:e}),Gc=O8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=x2(),[s,m]=H8(0);return z8(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),Hc(G8,{children:e.map((d,c)=>c<s?Hc(y2,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:r,svgCache:i,id:d?.id,selected:n(d.id),onToggle:o,onDrag:t},d?.id??c):Hc(w2,{},c))})});import{Fragment as T2,jsx as Tt,jsxs as Ii}from"react/jsx-runtime";var Z8=17,$8=64;function dh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let d=Y8(null),c=jy(d);U8(()=>{c>0&&d.current?.scrollTo(0,c)},[]);let{svgCache:p}=Sc(),u=v2(()=>o.filter(k=>k.status!=="published"),[o]),f=v2(()=>o.filter(k=>k.status==="published"),[o]),b=!o.length&&!r.length,x=!r.length&&!u.length&&!f.length,[y,E]=W8(null),w=Ti((k,A)=>{let F=!m.includes(k),Y=[...u,...f];if(F){if(A.shiftKey&&y){let Q=Y.findIndex(X=>X.id===y),_=Y.findIndex(X=>X.id===k);if(Q===-1||_===-1){s([...m,k]);return}let R=X8(m),W=Y.reduce((X,G,me)=>((me>=Q&&me<=_||R.has(G.id))&&X.push(G.id),X),[]);s(W)}else s([...m,k]);E(k)}else E(null),s(m.filter(Q=>Q!==k))},[y,s,f,m,u]),v=Ti(k=>{let A;return m.includes(k)?A=o.filter(F=>m.includes(F.id)):A=o.filter(F=>F.id===k),A.map(F=>({...F,elements:K8({type:"everything",elements:F.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=Ti((k,A)=>{let F={itemIds:m.includes(k)?m:[k]};A.dataTransfer.setData(V8.excalidrawlibIds,JSON.stringify(F))},[m]),S=Ti(k=>k?m.includes(k):!1,[m]),L=Ti(()=>{t(r)},[r,t]),P=Ti(k=>{k&&n(v(k))},[v,n]),B=p.size>=o.length?$8:Z8;return Ii("div",{className:"library-menu-items-container",style:r.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&Tt(sh,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Ii(qe.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[Ii(T2,{children:[!x&&Tt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&Tt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Tt(tt,{})}),!r.length&&!u.length?Ii("div",{className:"library-menu-items__no-items",children:[Tt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Tt("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Ii(ch,{children:[r.length>0&&Tt(Gc,{itemsRenderedPerBatch:B,items:[{id:null,elements:r}],onItemSelectToggle:w,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),Tt(Gc,{itemsRenderedPerBatch:B,items:u,onItemSelectToggle:w,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p})]})]}),Ii(T2,{children:[(f.length>0||r.length>0||u.length>0)&&Tt("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?Tt(ch,{children:Tt(Gc,{itemsRenderedPerBatch:B,items:f,onItemSelectToggle:w,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p})}):u.length>0?Tt("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&Tt(Ac,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:Tt(sh,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as bn,jsxs as S2}from"react/jsx-runtime";var wi=he(!1),C2=({children:e})=>bn("div",{className:"layer-ui__library",children:e}),e7=P2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[d]=le(ar),c=ph(f=>{(async(x,y)=>{re("element","addToLibrary","ui");for(let w of q8)if(x.some(v=>v.type===w))return n({errorMessage:g(`errors.libraryElementTypeError.${w}`)});let E=[{status:"unpublished",elements:x,id:J8(),created:Date.now()},...y];t(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,d.libraryItems)},[t,i,n,d.libraryItems]),p=M2(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return bn(C2,{children:bn("div",{className:"layer-ui__library-message",children:S2("div",{children:[bn(tt,{size:"2em"}),bn("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||o.length>0;return S2(C2,{children:[bn(dh,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:m,selectedItems:s}),u&&bn(Ac,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),mh=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),t7=(e,o)=>{let t=an(),[n,r]=k2(()=>mh(t,e.selectedElementIds)),i=j8(new Map);return I2(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),I2(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!Q8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),mh(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return mh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},L2=P2(()=>{let e=Be(),{onInsertElements:o}=e,t=xo(),n=be(),r=ae(),[i,a]=k2([]),l=M2(()=>e.library,[e.library]),s=t7(n,e),m=ph(c=>{o(Lc(c))},[o]),d=ph(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return bn(e7,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:d,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import o7 from"clsx";import{useRef as n7}from"react";import{createPortal as r7}from"react-dom";import{KEYS as i7}from"@excalidraw/common";import{jsx as A2,jsxs as a7}from"react/jsx-runtime";var D2=e=>{let{closeOnClickOutside:o=!0}=e,t=Ss({className:"excalidraw-modal-container"}),n=n7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===i7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return r7(a7("div",{className:o7("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[A2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),A2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Qa,jsxs as p7}from"react/jsx-runtime";function m7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Oe=e=>{let[o,t]=By(),[n]=c7(document.activeElement),{id:r}=Ne(),i=de().viewport.isMobile;s7(()=>{if(!o)return;let m=_2(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let d=c=>{if(c.key===d7.TAB){let p=_2(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",d),()=>o.removeEventListener("keydown",d)},[o,e.autofocus]);let a=ae(),l=en(wi),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return Qa(D2,{className:l7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:m7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:p7(Ye,{ref:t,children:[e.title&&Qa("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:Qa("span",{className:"Dialog__titleContent",children:e.title})}),i&&Qa("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:zt}),Qa("div",{className:"Dialog__content",children:e.children})]})})};import uh from"clsx";import{forwardRef as f7,useRef as b7,useImperativeHandle as x7,useLayoutEffect as E7,useState as y7}from"react";import u7 from"clsx";import{composeEventHandlers as h7}from"@excalidraw/common";import{jsx as g7}from"react/jsx-runtime";var Nt=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>g7("button",{onClick:h7(i.onClick,a=>{o()}),type:e,className:u7("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as hh,jsxs as R2}from"react/jsx-runtime";var Ci=f7(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...d},c)=>{let p=b7(null);x7(c,()=>p.current),E7(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=y7(!1);return R2("div",{className:uh("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&hh("div",{className:"ExcTextField__label",children:o}),R2("div",{className:uh("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[hh("input",{className:uh({"is-redacted":"value"in d&&d.value&&l&&!u}),readOnly:r,value:"value"in d?d.value:void 0,defaultValue:"defaultValue"in d?d.defaultValue:void 0,placeholder:n,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&hh(Nt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?db:Br})]})]})});import{KEYS as ze}from"@excalidraw/common";var Uc=[{icon:Fm,value:"selection",key:ze.V,numericKey:ze[1],fillable:!0},{icon:ts,value:"rectangle",key:ze.R,numericKey:ze[2],fillable:!0},{icon:os,value:"diamond",key:ze.D,numericKey:ze[3],fillable:!0},{icon:ns,value:"ellipse",key:ze.O,numericKey:ze[4],fillable:!0},{icon:J1,value:"arrow",key:ze.A,numericKey:ze[5],fillable:!0},{icon:rs,value:"line",key:ze.L,numericKey:ze[6],fillable:!0},{icon:tn,value:"freedraw",key:[ze.P,ze.X],numericKey:ze[7],fillable:!1},{icon:Ar,value:"text",key:ze.T,numericKey:ze[8],fillable:!1},{icon:t0,value:"image",key:null,numericKey:ze[9],fillable:!1},{icon:o0,value:"eraser",key:ze.E,numericKey:ze[0],fillable:!1}],gh=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:Fm,key:ze.V,numericKey:ze[1],fillable:!0},...Uc.slice(1)]:Uc,N2=(e,o)=>gh(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import el from"clsx";import{useState as T7}from"react";import*as To from"@radix-ui/react-popover";import{CLASSES as H2,KEYS as F2,capitalizeString as xh,isTransparent as Yc}from"@excalidraw/common";import{shouldAllowVerticalAlign as G2,suppportsHorizontalAlign as U2}from"@excalidraw/element";import{hasBoundTextElement as Wc,isElbowArrow as Y2,isImageElement as W2,isLinearElement as V2,isTextElement as yh,isArrowElement as O2}from"@excalidraw/element";import{hasStrokeColor as z2,toolIsArrow as Vc}from"@excalidraw/element";import{createIsolation as w7}from"jotai-scope";import fh from"react";import vo from"tunnel-rat";var bh=fh.createContext(null),Ce=()=>fh.useContext(bh),v7=w7(),B2=()=>fh.useMemo(()=>({MainMenuTunnel:vo(),WelcomeScreenMenuHintTunnel:vo(),WelcomeScreenToolbarHintTunnel:vo(),WelcomeScreenHelpHintTunnel:vo(),WelcomeScreenCenterTunnel:vo(),FooterCenterTunnel:vo(),DefaultSidebarTriggerTunnel:vo(),DefaultSidebarTabTriggersTunnel:vo(),OverwriteConfirmDialogTunnel:vo(),TTDDialogTriggerTunnel:vo(),tunnelsJotai:v7}),[]);import{Fragment as Bt,jsx as J,jsxs as ce}from"react/jsx-runtime";var Eh=el([H2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),Xc=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return z2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>z2(n.type))},Kc=(e,o)=>go(e.activeTool.type)||o.some(t=>go(t.type)),Zc=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=ea(o,e),i=!1;r.length===2&&(Wc(r[0])||Wc(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=de(),s=document.documentElement.getAttribute("dir")==="rtl",m=go(e.activeTool.type)&&!Yc(e.currentItemBackgroundColor)||r.some(f=>go(f.type)&&!Yc(f.backgroundColor)),d=r.length===1||i,c=!e.selectedLinearElement?.isEditing&&r.length===1&&V2(r[0])&&!Y2(r[0]),p=!e.croppingElementId&&r.length===1&&W2(r[0]),u=!i&&gt(e,n);return ce("div",{className:"selected-shape-actions",children:[J("div",{children:Xc(e,r)&&t("changeStrokeColor")}),Kc(e,r)&&J("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(Un(e.activeTool.type)||r.some(f=>Un(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(Yn(e.activeTool.type)||r.some(f=>Yn(f.type)))&&ce(Bt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Wn(e.activeTool.type)||r.some(f=>Wn(f.type)))&&J(Bt,{children:t("changeRoundness")}),(Vc(e.activeTool.type)||r.some(f=>Vc(f.type)))&&J(Bt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(yh))&&ce(Bt,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||U2(r,o))&&t("changeTextAlign")]}),G2(r,o)&&t("changeVerticalAlign"),(vr(e.activeTool.type)||r.some(f=>vr(f.type)))&&J(Bt,{children:t("changeArrowhead")}),t("changeOpacity"),ce("fieldset",{children:[J("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ce("fieldset",{children:[J("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[s?ce(Bt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(Bt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),J("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!a&&r.length>0&&ce("fieldset",{children:[J("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),d&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},X2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ea(o,e),{saveCaretPosition:a,restoreCaretPosition:l}=Kb(),{container:s}=Ne(),m=!!(e.editingTextElement||e.newElement),d=go(e.activeTool.type)&&!Yc(e.currentItemBackgroundColor)||i.some(y=>go(y.type)&&!Yc(y.backgroundColor)),c=i.length===1,p=!e.selectedLinearElement?.isEditing&&i.length===1&&V2(i[0])&&!Y2(i[0]),u=!e.croppingElementId&&i.length===1&&W2(i[0]),f=gt(e,n),b=!1;i.length===2&&(Wc(i[0])||Wc(i[1]))&&(b=!0);let x=document.documentElement.getAttribute("dir")==="rtl";return ce("div",{className:"compact-shape-actions",children:[Xc(e,i)&&J("div",{className:el("compact-action-item"),children:t("changeStrokeColor")}),Kc(e,i)&&J("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),(d||Un(e.activeTool.type)||i.some(y=>Un(y.type))||Yn(e.activeTool.type)||i.some(y=>Yn(y.type))||Wn(e.activeTool.type)||i.some(y=>Wn(y.type)))&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactStrokeStyles",onOpenChange:y=>{r(y?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.stroke"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactStrokeStyles"?null:"compactStrokeStyles"})},children:Lb})}),e.openPopup==="compactStrokeStyles"&&J(_o,{className:Eh,container:s,style:{maxWidth:"13rem"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[d&&t("changeFillStyle"),(Un(e.activeTool.type)||i.some(y=>Un(y.type)))&&t("changeStrokeWidth"),(Yn(e.activeTool.type)||i.some(y=>Yn(y.type)))&&ce(Bt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Wn(e.activeTool.type)||i.some(y=>Wn(y.type)))&&t("changeRoundness"),t("changeOpacity")]})})]})}),(Vc(e.activeTool.type)||i.some(y=>Vc(y.type)))&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactArrowProperties",onOpenChange:y=>{r(y?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.arrowtypes"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactArrowProperties"?null:"compactArrowProperties"})},children:(()=>{let y=at(i,n,E=>O2(E)?E.elbowed?"elbow":E.roundness?"round":"sharp":null,E=>O2(E),E=>E?null:e.currentItemArrowType);return y==="elbow"?Or:y==="round"?zr:Fr})()})}),e.openPopup==="compactArrowProperties"&&J(_o,{container:s,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:t("changeArrowProperties")})]})}),p&&J("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(yh))&&ce(Bt,{children:[J("div",{className:"compact-action-item",children:t("changeFontFamily")}),J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactTextProperties",onOpenChange:y=>{y?(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"})):(r({openPopup:null}),e.editingTextElement&&l())},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.textAlign"),onClick:y=>{y.preventDefault(),y.stopPropagation(),e.openPopup==="compactTextProperties"?r({openPopup:null}):(e.editingTextElement&&a(),r({openPopup:"compactTextProperties"}))},children:e0})}),e.openPopup==="compactTextProperties"&&J(_o,{className:Eh,container:s,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:ce("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||i.some(yh))&&t("changeFontSize"),(e.activeTool.type==="text"||U2(i,o))&&t("changeTextAlign"),G2(i,o)&&t("changeVerticalAlign")]})})]})})]}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:t("duplicateSelection")}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),!m&&i.length>0&&J("div",{className:"compact-action-item",children:ce(To.Root,{open:e.openPopup==="compactOtherProperties",onOpenChange:y=>{r(y?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[J(To.Trigger,{asChild:!0,children:J("button",{type:"button",className:"compact-action-button properties-trigger",title:g("labels.actions"),onClick:y=>{y.preventDefault(),y.stopPropagation(),r({openPopup:e.openPopup==="compactOtherProperties"?null:"compactOtherProperties"})},children:X1})}),e.openPopup==="compactOtherProperties"&&J(_o,{className:Eh,container:s,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ce("div",{className:"selected-shape-actions",children:[ce("fieldset",{children:[J("legend",{children:g("labels.layers")}),ce("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),f&&!b&&ce("fieldset",{children:[J("legend",{children:g("labels.align")}),ce("div",{className:"buttonList",children:[x?ce(Bt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ce(Bt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),i.length>2&&t("distributeHorizontally"),J("div",{style:{flexBasis:"100%",height:0}}),ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),i.length>2&&t("distributeVertically")]})]})]}),ce("fieldset",{children:[J("legend",{children:g("labels.actions")}),ce("div",{className:"buttonList",children:[t("group"),t("ungroup"),c&&t("hyperlink"),u&&t("cropEditor")]})]})]})})]})})]})},$c=({activeTool:e,appState:o,app:t,UIOptions:n})=>{let[r,i]=T7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",m=e.type==="embeddable",{TTDDialogTriggerTunnel:d}=Ce();return ce(Bt,{children:[gh(t).map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(n.tools?.[c]===!1)return null;let y=g(`toolBar.${c}`),E=u&&xh(typeof u=="string"?u:u[0]),w=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return J(Z,{className:el("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${xh(y)} \u2014 ${w}`,keyBindingLabel:f||E,"aria-label":xh(y),"aria-keyshortcuts":w,"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)}),J("div",{className:"App-toolbar__divider"}),ce(xe,{open:r,children:[J(xe.Trigger,{className:el("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||m||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:a?Zn:m?Hm:l&&!t.props.isCollaborating?pa:s?aa:sb}),ce(xe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[J(xe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Zn,shortcut:F2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),J(xe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Hm,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),J(xe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:pa,"data-testid":"toolbar-laser",selected:l,shortcut:F2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&J(xe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:aa,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),J("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&J(d.Out,{}),J(xe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:us,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&J(Bt,{children:ce(xe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:hs,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),J(xe.Item.Badge,{children:"AI"})]})})]})]})]})},K2=({renderAction:e,zoom:o})=>J(qe.Col,{gap:1,className:H2.ZOOM_ACTIONS,children:ce(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Z2=({renderAction:e,className:o})=>ce("div",{className:`undo-redo-buttons ${o}`,children:[J("div",{className:"undo-button-container",children:J(At,{label:g("buttons.undo"),children:e("undo")})}),J("div",{className:"redo-button-container",children:ce(At,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),$2=({actionManager:e,showExitZenModeBtn:o})=>J("button",{type:"button",className:el("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(mi),children:g("buttons.exitZenMode")});import{useRef as I7}from"react";var wh=e=>{let o=I7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as S7,jsxs as C7}from"react/jsx-runtime";var lr=he(null),j2=()=>{let[e,o]=le(lr),t=We();return e&&e==="clearCanvas"?S7(_c,{onConfirm:()=>{t.executeAction(Oo),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:C7("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var vh={};p1(vh,{toggleTheme:()=>k7});var k7={...Jn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Jn,"commandPalette")}};import{jsx as st,jsxs as Io}from"react/jsx-runtime";var _7=he(null),Me={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},R7=e=>{switch(e){case Me.app:return 1;case Me.export:return 2;case Me.editor:return 3;case Me.tools:return 4;case Me.elements:return 5;case Me.links:return 6;default:return 10}},Jc=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return Io("div",{className:Q2("shortcut",o),children:[n.map((r,i)=>st("div",{className:"shortcut-wrapper",children:st("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),st("div",{className:"shortcut-desc",children:t})]})},ew=e=>!e.altKey&&e[lo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===lo.P||e.key===lo.SLASH),wde=Object.assign(e=>{let o=be(),t=ae();return qc(()=>{let n=r=>{ew(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Qc.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(Qc.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:st(N7,{...e})},{defaultItems:vh});function N7({customCommandPaletteItems:e}){let o=Be(),t=be(),n=ae(),r=xo(),i=We(),[a,l]=le(_7),[s,m]=jc(null),d=P7(null),c=on({uiAppState:t,customCommandPaletteItems:e,appProps:r});qc(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:P}=c,B=Y=>{let Q="";return Y.label&&(typeof Y.label=="function"?Q=g(Y.label(o.scene.getNonDeletedElements(),S,o)):Q=g(Y.label)),Q},k=Y=>typeof Y.icon=="function"?Y.icon(S,o.scene.getNonDeletedElements()):Y.icon,A=[],F=(Y,Q,_)=>{let R={label:B(Y),icon:k(Y),category:Q,shortcut:Fe(Y.name),keywords:Y.keywords,predicate:Y.predicate,viewMode:Y.viewMode,perform:()=>{i.executeAction(Y,"commandPalette")}};return _?_(R,Y):R};if(S&&o.scene&&i){let Y=[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,Ya,Cc,Ry].map(G=>F(G,Me.elements,(me,ue)=>({...me,predicate:ue.predicate?ue.predicate:(pe,it,uo,yr)=>j(pe,it).length>0}))),Q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(G=>F(G,Me.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(G=>F(G,Me.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(G=>F(G,Me.export));A=[...Y,..._,{label:B(Oo),icon:k(Oo),shortcut:Fe(Oo.name),category:Me.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Ue.set(lr,"clearCanvas")}},{label:g("buttons.exportImage"),category:Me.export,icon:ss,shortcut:Fe("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...R];let W=[{label:g("toolBar.library"),category:Me.app,icon:Pr,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:q2.name,tab:q2.defaultTab}})}},{label:g("search.title"),category:Me.app,icon:Pt,viewMode:!0,perform:()=>{i.executeAction(tl)}},{label:g("labels.shapeSwitch"),category:Me.elements,icon:ua,perform:()=>{i.executeAction(_y)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Me.elements,icon:ls,viewMode:!1,predicate:(G,me)=>{let ue=j(G,me);return ue.length>0&&Xc(me,ue)},perform:()=>{n(G=>({openMenu:G.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:ls,category:Me.elements,viewMode:!1,predicate:(G,me)=>{let ue=j(G,me);return ue.length>0&&Kc(me,ue)},perform:()=>{n(G=>({openMenu:G.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:ls,category:Me.editor,viewMode:!1,perform:()=>{n(G=>({openMenu:G.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Uc.reduce((G,me)=>{let{value:ue,icon:pe,key:it,numericKey:uo}=me;if(P.UIOptions.tools?.[ue]===!1)return G;let wr=it&&L7(typeof it=="string"?it:it[0])||uo,Hl={label:g(`toolBar.${ue}`),category:Me.tools,shortcut:wr,icon:pe,keywords:["toolbar"],viewMode:!1,perform:({event:Im})=>{ue==="image"?o.setActiveTool({type:ue}):o.setActiveTool({type:ue})}};return G.push(Hl),G},[]),...Q,{label:g("toolBar.lock"),category:Me.tools,icon:S.activeTool.locked?Lr:Vn,shortcut:lo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Me.tools,icon:pb,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(G=>({...G,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Me.tools,icon:us,viewMode:!1,predicate:P.aiEnabled,perform:()=>{n(G=>({...G,openDialog:{name:"ttd",tab:"mermaid"}}))}}],X=[...A,...W,...L||[]].map(G=>({...G,icon:G.icon||ua,order:G.order??R7(G.category),haystack:`${ju(G.label.toLocaleLowerCase())} ${G.keywords?.join(" ")||""}`}));m(X),l(X.find(G=>G.label===a?.label)??null)}},[c,o,i,m,a?.label,l,n]);let[p,u]=jc(""),[f,b]=jc(null),[x,y]=jc({}),E=S=>{n({openDialog:null},S),u("")},w=(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=wh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,r,o):S.predicate===void 0||S.predicate),C=wh(S=>{let L=D7(S.target)||ew(S)||S.key===lo.ESCAPE;if(L&&S.key!==lo.ARROW_UP&&S.key!==lo.ARROW_DOWN&&S.key!==lo.ENTER)return;let P=Object.values(x).flat(),B=a&&!p&&v(a);if(S.key===lo.ARROW_UP){S.preventDefault();let k=P.findIndex(Y=>Y.label===f?.label);if(B){if(k===0){b(a);return}if(f===a){let Y=P[P.length-1];Y&&b(Y);return}}let A;k===-1?A=P.length-1:A=k===0?P.length-1:(k-1)%P.length;let F=P[A];F&&b(F);return}if(S.key===lo.ARROW_DOWN){S.preventDefault();let k=P.findIndex(Y=>Y.label===f?.label);if(B){if(!f||k===P.length-1){b(a);return}if(f===a){let Y=P[0];Y&&b(Y);return}}let A=(k+1)%P.length,F=P[A];F&&b(F);return}if(S.key===lo.ENTER&&f&&setTimeout(()=>{w(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){d?.current?.focus();return}S.preventDefault()}});return qc(()=>(window.addEventListener(Qc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Qc.KEYDOWN,C,{capture:!0})),[C]),qc(()=>{if(!s)return;let S=k=>{let A={};for(let F of k)A[F.category]?A[F.category].push(F):A[F.category]=[F];return A},L=s.filter(v).sort((k,A)=>k.order-A.order),P=!p&&a&&v(a);if(!p){y(S(P?L.filter(k=>k.label!==a?.label):L)),b(P?a:L[0]||null);return}let B=ju(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=M7.filter(B,L,{extract:k=>k.haystack}).sort((k,A)=>A.score-k.score).map(k=>k.original),y(S(L)),b(L[0]??null)},[p,s,v,a]),Io(Oe,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[st(Ci,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:d}),!o.device.viewport.isMobile&&Io("div",{className:"shortcuts-wrapper",children:[st(Jc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),st(Jc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),st(Jc,{shortcut:A7("Esc"),children:g("commandPalette.shortcuts.close")})]}),Io("div",{className:"commands",children:[a&&!p&&Io("div",{className:"command-category",children:[Io("div",{className:"command-category-title",children:[g("commandPalette.recents"),st("div",{className:"icon",style:{marginLeft:"6px"},children:ub})]}),st(J2,{command:a,isSelected:a.label===f?.label,onClick:S=>w(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)=>Io("div",{className:"command-category",children:[st("div",{className:"command-category-title",children:S}),x[S].map(P=>st(J2,{command:P,isSelected:P.label===f?.label,onClick:B=>w(P,B),onMouseMove:()=>b(P),showShortcut:!o.device.viewport.isMobile,appState:t},P.label))]},S)):s?Io("div",{className:"no-match",children:[st("div",{className:"icon",children:Pt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var J2=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a})=>{let l=()=>{};return Io("div",{className:Q2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:r,onMouseMove:t?l:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[Io("div",{className:"name",children:[e.icon&&st(dn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),st(Ia,{children:e.label})]}),i&&e.shortcut&&st(Jc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as f0e,randomInteger as _D,getUpdatedTimestamp as RD}from"@excalidraw/common";import{simplify as TD}from"points-on-curve";import{pointsOnBezierCurves as Sde}from"points-on-curve";import{invariant as Mde}from"@excalidraw/common";import{curve as Lde,lineSegment as Ade,pointFrom as Dde,pointDistance as _de,pointFromArray as Rde,pointFromVector as Nde,pointRotateRads as Bde,polygon as Fde,polygonFromPoints as Ode,PRECISION as zde,segmentsIntersectAt as Hde,vector as Gde,vectorAdd as Ude,vectorFromPoint as Yde,vectorScale as Wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Xde}from"@excalidraw/element";var Th=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 ID,pointDistance as vw,pointRotateRads as e0e}from"@excalidraw/math";import{ROUGHNESS as CD,isTransparent as al,assertNever as SD,COLOR_PALETTE as kD,LINE_POLYGON_POINT_MERGE_DISTANCE as o0e}from"@excalidraw/common";import{RoughGenerator as MD}from"roughjs/bin/generator";import u1e from"roughjs/bin/rough";import{getStroke as gD}from"perfect-freehand";import{isRightAngleRads as f1e,lineSegment as b1e,pointFrom as x1e,pointRotateRads as E1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as w1e,DEFAULT_REDUCED_GLOBAL_ALPHA as v1e,ELEMENT_READY_TO_ERASE_OPACITY as T1e,FRAME_STYLE as I1e,MIME_TYPES as xw,THEME as C1e,distance as S1e,getFontString as k1e,isRTL as M1e,getVerticalOffset as P1e,invariant as L1e}from"@excalidraw/common";import Cge from"roughjs/bin/rough";import{arrayToMap as kge,invariant as dw,rescalePoints as Mge,sizeOf as Pge}from"@excalidraw/common";import{degreesToRadians as Rh,lineSegment as Age,pointDistance as Dge,pointFrom as ot,pointFromArray as Q7,pointRotateRads as Li}from"@excalidraw/math";import{pointsOnBezierCurves as Nge}from"points-on-curve";import{pointCenter as Yhe,pointFrom as Whe,pointRotateRads as Vhe,pointsEqual as Xhe,pointDistance as Khe,vectorFromPoint as Zhe,curveLength as $he,curvePointAtLength as jhe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Qhe,KEYS as ege,shouldRotateWithDiscreteAngle as tge,getGridPoint as oge,invariant as nge,tupleToCoors as rge,viewportCoordsToSceneCoords as ige}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as lge,isPathALoop as sge}from"@excalidraw/element";import{KEYS as Yue,arrayToMap as Wue,isBindingFallthroughEnabled as Vue,tupleToCoors as Xue,invariant as Kue,isDevEnv as Zue,isTestEnv as $ue}from"@excalidraw/common";import{lineSegment as que,pointFrom as Jue,pointRotateRads as Que,vectorFromPoint as ehe,pointDistanceSq as the,clamp as ohe,pointDistance as nhe,pointFromVector as rhe,vectorScale as ihe,vectorNormalize as ahe,vectorCross as lhe,pointsEqual as she,lineSegmentIntersectionPoints as che,PRECISION as dhe}from"@excalidraw/math";import{isTransparent as Epe}from"@excalidraw/common";import{curveIntersectLineSegment as wpe,isPointWithinBounds as vpe,lineSegment as Tpe,lineSegmentIntersectionPoints as Ipe,pointFrom as Cpe,pointFromVector as Spe,pointRotateRads as kpe,pointsEqual as Mpe,vectorFromPoint as Ppe,vectorNormalize as Lpe,vectorScale as Ape}from"@excalidraw/math";import{ellipse as _pe,ellipseSegmentInterceptPoints as Rpe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as B7,DEFAULT_PROPORTIONAL_RADIUS as Ih,LINE_CONFIRM_THRESHOLD as F7,ROUNDNESS as Ch}from"@excalidraw/common";import{curve as qde,curveCatmullRomCubicApproxPoints as Jde,curveOffsetPoints as Qde,lineSegment as eme,pointDistance as O7,pointFrom as tme,pointFromArray as ome,rectangle as nme}from"@excalidraw/math";var ed=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return O7(t,n)<=F7/o}return!1},ol=(e,o)=>{if(o.roundness?.type===Ch.PROPORTIONAL_RADIUS||o.roundness?.type===Ch.LEGACY)return e*Ih;if(o.roundness?.type===Ch.ADAPTIVE_RADIUS){let t=o.roundness?.value??B7,n=t/Ih;return e<=n?e*Ih:t}return 0};import{ROUNDNESS as dme,assertNever as mme}from"@excalidraw/common";import{pointsEqual as ume}from"@excalidraw/math";var tw=e=>!!e&&e.type==="embeddable",ow=e=>!!e&&e.type==="iframe",kh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),sr=e=>e!=null&&e.type==="text";var td=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var xn=e=>e!=null&&z7(e.type);var Si=e=>e!=null&&e.type==="arrow",nl=e=>Si(e)&&e.elbowed;var z7=e=>e==="arrow"||e==="line";var ki=e=>e!==null&&"containerId"in e&&e.containerId!==null&&sr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Ume,ARROW_LABEL_WIDTH_FRACTION as Yme,BOUND_TEXT_PADDING as Wme,DEFAULT_FONT_SIZE as Vme,TEXT_ALIGN as Xme,VERTICAL_ALIGN as Kme,getFontString as Zme,isProdEnv as $me,invariant as jme}from"@excalidraw/common";import{pointFrom as Jme,pointRotateRads as Qme}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Eme,DEFAULT_FONT_SIZE as yme,DEFAULT_FONT_FAMILY as wme,getFontString as vme,isTestEnv as Tme,normalizeEOL as Ime}from"@excalidraw/common";var Cme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Dme,isTestEnv as _me}from"@excalidraw/common";import{curvePointDistance as spe,distanceToLineSegment as cpe,pointRotateRads as dpe}from"@excalidraw/math";import{ellipse as ppe,ellipseDistanceFromPoint as upe}from"@excalidraw/math/ellipse";import{invariant as Xpe,isDevEnv as Kpe,isTestEnv as Zpe}from"@excalidraw/common";import{pointFrom as jpe,pointFromVector as qpe,pointRotateRads as Jpe,pointScaleFromOrigin as Qpe,pointsEqual as eue,triangleIncludesPoint as tue,vectorCross as oue,vectorFromPoint as W7,vectorScale as nue}from"@excalidraw/math";var Dh=[1,0],aw=[0,1],_h=[-1,0],lw=[0,-1],nd=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Dh:o<=-r?_h:t>n?aw:lw},sw=(e,o)=>nd(W7(e,o)),rd=(e,o)=>id(sw(e,o)),Ah=(e,o)=>e[0]===o[0]&&e[1]===o[1],id=e=>Ah(e,Dh)||Ah(e,_h);import{clamp as cue,pointDistance as due,pointFrom as mue,pointScaleFromOrigin as pue,pointsEqual as uue,pointTranslate as hue,vector as gue,vectorCross as fue,vectorFromPoint as bue,vectorScale as xue}from"@excalidraw/math";import{BinaryHeap as yue,invariant as wue,isAnyTrue as vue,tupleToCoors as Tue,getSizeFromPoints as Iue,isDevEnv as Cue,arrayToMap as Sue}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Che,viewportCoordsToSceneCoords as She}from"@excalidraw/common";import{normalizeRadians as Mhe,radiansBetweenAngles as Phe,radiansDifference as Lhe}from"@excalidraw/math";import{pointsEqual as Dhe}from"@excalidraw/math";var Sh=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var eD=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}},tD=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Nh=(e,o,t,n)=>{if(o.length<1)return null;let r=Th(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;dw(a.length===6,"Op data length is not 6");let l=ot(a[4],a[5]),s=ot(a[2],a[3]),m=ot(a[0],a[1]),d=r[i-1],c=ot(0,0);if(d.op==="move"){let _=Q7(d.data);dw(_!=null,"Op data is not a point"),c=_}else d.op==="bcurveTo"&&(c=ot(d.data[4],d.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*m[R]+c[R]*Math.pow(_,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],y=Math.hypot(u-b,f-x),E=(u-b)/y,w=(f-x)/y,v=eD(n),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[W,X]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-W,R-X)}let L=Math.min(v,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),P=u-E*L,B=f-w*L;if(n==="dot"||n==="circle"||n==="circle_outline"){let _=Math.hypot(B-f,P-u)+e.strokeWidth-2;return[u,f,_]}let k=tD(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[_,R]=Li(ot(u,f),ot(P,B),Rh(-k)),[W,X]=Li(ot(u,f),ot(P,B),Rh(k));return[P,B,_,R,W,X]}let[A,F]=Li(ot(P,B),ot(u,f),-k*Math.PI/180),[Y,Q]=Li(ot(P,B),ot(u,f),Rh(k));if(n==="diamond"||n==="diamond_outline"){let _,R;if(t==="start"){let[W,X]=e.points.length>1?e.points[1]:[0,0];[_,R]=Li(ot(u+L*2,f),ot(u,f),Math.atan2(X-f,W-u))}else{let[W,X]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=Li(ot(u-L*2,f),ot(u,f),Math.atan2(f-X,u-W))}return[u,f,A,F,_,R,Y,Q]}return[u,f,A,F,Y,Q]};import{pointFrom as $ge,pointCenter as jge,pointRotateRads as qge,vectorFromPoint as Jge,vectorNormalize as Qge,vectorSubtract as efe,vectorAdd as tfe,vectorScale as ofe,pointFromVector as nfe,clamp as rfe,isCloseTo as ife}from"@excalidraw/math";import{arrayToMap as Vfe}from"@excalidraw/common";import{isPointWithinBounds as Kfe,pointFrom as Zfe}from"@excalidraw/math";import{vectorCross as dfe,vectorFromPoint as mfe}from"@excalidraw/math";import{arrayToMap as oD}from"@excalidraw/common";import{getElementBounds as nD}from"@excalidraw/element";import{isArrowElement as rD,isExcalidrawElement as iD,isFreeDrawElement as aD,isLinearElement as lD,isTextElement as sD}from"@excalidraw/element";import{rangeIncludesValue as ad,pointFrom as Yo,pointRotateRads as cD,rangeInclusive as ld}from"@excalidraw/math";var dD=e=>e.type==="diamond"?[Yo(e.width/2,0),Yo(e.width,e.height/2),Yo(e.width/2,e.height),Yo(0,e.height/2)]:[Yo(0,0),Yo(0+e.width,0),Yo(0+e.width,e.height),Yo(0,e.height)],mD=e=>lD(e)||aD(e)?e.points:dD(e),pw=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},uw=e=>{let o=mD(e),{cx:t,cy:n}=pw(o),r=Yo(t,n),i=o.map(d=>cD(d,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=pw(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},Bh=(e,o,t=!1)=>{let n=uw(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},hw=(e,o)=>{let t=uw(e);return(ad(t[0],ld(o[0],o[2]))||ad(o[0],ld(t[0],t[2])))&&(ad(t[1],ld(o[1],o[3]))||ad(o[1],ld(t[1],t[3])))},gw=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{iD(o)&&(o=nD(o,oD(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?hw(a,r):t==="inside"?Bh(a,r):Bh(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);sD(a)&&a.containerId&&i.add(a.containerId),rD(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 kfe,isShallowEqual as uD}from"@excalidraw/common";var pD=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];m[f]=!0}}let d={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[b]);return f&&(p[u.id]=!0,Array.isArray(d[f])?d[f].push(u.id):d[f]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:Fh({...l.selectedElementIds,...c},s)},t},r=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Oh(a,i);return m.length?n(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Fh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var Rfe=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),Oh=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&ki(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{td(a)&&fw(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var Fh=(e,o)=>uD(o.selectedElementIds,e)?o.selectedElementIds:e;var fw=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var fD=typeof document<"u"?document.createElement("img"):{src:""};fD.src=`data:${xw.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 bD=typeof document<"u"?document.createElement("img"):{src:""};bD.src=`data:${xw.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 Ew=new WeakMap;var xD=new WeakMap([]);function yw(e){let o=ED(e),t=new Path2D(o);return xD.set(e,t),t}function ED(e){return vD(yD(e))}function yD(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!!e.lastCommittedPoint};return gD(o,t)}function bw(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var wD=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function vD(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,bw(n,i[0]),"L",i[0],"Z"):t.push(n,bw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(wD,"$1")}var ww=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var ct=class ct{};I(ct,"rg",new MD),I(ct,"cache",new WeakMap),I(ct,"get",o=>ct.cache.get(o)),I(ct,"set",(o,t)=>ct.cache.set(o,t)),I(ct,"delete",o=>ct.cache.delete(o)),I(ct,"destroy",()=>{ct.cache=new WeakMap}),I(ct,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:ct.get(o);if(n!==void 0)return n;Ew.delete(o);let r=AD(o,ct.rg,t||{isExporting:!1,canvasBackgroundColor:kD.white,embedsValidationStatus:null});return ct.cache.set(o,r),r});var Pi=ct,PD=e=>[8,8+e],Cw=e=>[1.5,6+e];function LD(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&ww(e.type)||xn(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Uo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?PD(e.strokeWidth):e.strokeStyle==="dotted"?Cw(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:LD(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<CD.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=al(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return ed(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},Tw=(e,o,t)=>kh(e)&&(o||tw(e)&&t?.get(e.id)!==!0)&&al(e.backgroundColor)&&al(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:ow(e)?{...e,strokeColor:al(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:al(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Iw=(e,o,t,n,r,i,a)=>{let l=Nh(e,o,t,n);if(l===null)return[];let s=(m,d)=>{if(m===null)return[];let[,,c,p,u,f]=m;return[r.line(c,p,u,f,d)]};switch(n){case"dot":case"circle":case"circle_outline":{let[m,d,c]=l;return delete i.strokeLineDash,[r.circle(m,d,c,{...i,fill:n==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,d,c,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[m,d],[c,p],[u,f],[m,d]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,d,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[m,d],[c,p],[u,f],[b,x],[m,d]],{...i,fill:n==="diamond_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[m,d,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=Cw(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(c,p,m,d,i),r.line(u,f,m,d,i),...n==="crowfoot_one_or_many"?s(Nh(e,o,t,"crowfoot_one"),i):[]]}}};var AD=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=ol(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`,Uo(Tw(e,t,r),!0))}else i=o.rectangle(0,0,e.width,e.height,Uo(Tw(e,t,r),!1));return i}case"diamond":{let i,[a,l,s,m,d,c,p,u]=Sh(e);if(e.roundness){let f=ol(Math.abs(a-p),e),b=ol(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
9
+ C ${s} ${m}, ${s} ${m}, ${s-f} ${m+b}
10
+ L ${d+f} ${c-b}
11
+ C ${d} ${c}, ${d} ${c}, ${d-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}`,Uo(e,!0))}else i=o.polygon([[a,l],[s,m],[d,c],[p,u]],Uo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Uo(e));case"line":case"arrow":{let i,a=Uo(e),l=e.points.length?e.points:[ID(0,0)];if(nl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(DD(l,16),Uo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:m="arrow"}=e;if(s!==null){let d=Iw(e,i,"start",s,o,a,n);i.push(...d)}if(m!==null){let d=Iw(e,i,"end",m,o,a,n);i.push(...d)}}return i}case"freedraw":{let i;if(yw(e),ed(e.points)){let a=TD(e.points,.75);i=o.curve(a,{...Uo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return SD(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},DD=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=rd(l,i),m=rd(a,l),d=Math.min(o,vw(e[r],a)/2,vw(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),m?a[0]<l[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var Sw=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??_D(),updated:RD()}};import{jsx as Mw}from"react/jsx-runtime";var Di=N({name:"toggleLinearEditor",category:Me.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&BD(r[0])&&!ND(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];zh(r,"No selected element found"),zh(o.selectedLinearElement,"No selected linear element found"),zh(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:kw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return Mw(Z,{type:"button",icon:kb,title:r,"aria-label":r,onClick:()=>o(null)})}}),D0e=N({name:"togglePolygon",category:Me.elements,icon:Bm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Ai(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Ai(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Ai(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=FD(i);return{elements:e.map(s=>!l.has(s.id)||!Ai(s)?s:Sw(s,{backgroundColor:a?s.backgroundColor:"transparent",...OD(s,a)})),appState:o,captureUpdate:kw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Ai(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Ai(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Mw(Yr,{icon:Bm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as Pw,CANVAS_SEARCH_TAB as Lw,CLASSES as zD,DEFAULT_SIDEBAR as Aw}from"@excalidraw/common";import{CaptureUpdateAction as HD}from"@excalidraw/element";var tl=N({name:"searchMenu",icon:Pt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===Aw.name&&o.openSidebar.tab===Lw){let r=n.excalidrawContainerValue.container?.querySelector(`.${zD.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:Aw.name,tab:Lw},openDialog:null},captureUpdate:HD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Pw.CTRL_OR_CMD]&&e.key===Pw.F});import{isImageElement as GD}from"@excalidraw/element";import{CaptureUpdateAction as UD}from"@excalidraw/element";import{jsx as YD}from"react/jsx-runtime";var Hh=N({name:"cropEditor",label:"helpDialog.cropStart",icon:ip,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:UD.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&GD(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return YD(Z,{type:"button",icon:ip,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as WD}from"@excalidraw/element";import{mutateElement as VD}from"@excalidraw/element";import{newFrameElement as XD}from"@excalidraw/element";import{isFrameLikeElement as sd}from"@excalidraw/element";import{addElementsToFrame as KD,removeAllElementsFromFrame as ZD}from"@excalidraw/element";import{getFrameChildren as $D}from"@excalidraw/element";import{KEYS as Dw,updateActiveTool as _w}from"@excalidraw/common";import{getElementsInGroup as jD}from"@excalidraw/element";import{getCommonBounds as qD}from"@excalidraw/element";import{CaptureUpdateAction as cr}from"@excalidraw/element";var Rw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&sd(t[0])},Nw=N({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(sd(r)){let i=$D(WD(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:cr.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:cr.EVENTUALLY}},predicate:(e,o,t,n)=>Rw(o,n)}),Bw=N({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return sd(r)?{elements:ZD(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:cr.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:cr.EVENTUALLY}},predicate:(e,o,t,n)=>Rw(o,n)}),Gbe=N({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:cr.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Ube=N({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Zn,viewMode:!1,perform:(e,o,t,n)=>{let r=_w(o,{type:"frame"});return Dt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:_w(o,{type:"frame"})},captureUpdate:cr.EVENTUALLY}},keyTest:e=>!e[Dw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Dw.F}),Fw=N({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length>0&&!r.some(i=>sd(i))},perform:(e,o,t,n)=>{let r=j(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,m]=qD(r,i),d=16,c=XD({x:a-d,y:l-d,width:s-a+d*2,height:m-l+d*2});if(o.editingGroupId){let u=jD(r,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);VD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:KD([...n.scene.getElementsIncludingDeleted(),c],r,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:cr.IMMEDIATELY}}});import{isWindows as r_,KEYS as sl,matchKey as Yh,arrayToMap as Ow}from"@excalidraw/common";import{CaptureUpdateAction as Uh}from"@excalidraw/element";import{orderByFractionalIndex as i_}from"@excalidraw/element";import{Emitter as JD}from"@excalidraw/common";import{CaptureUpdateAction as QD,StoreChange as e_,StoreDelta as t_}from"@excalidraw/element";var _i=class extends t_{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},dr=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},ll=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new JD);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 _i)return;let t=_i.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new dr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=QD.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,d=!1;for(;i;){try{[s,m,d]=i.applyTo(s,m,l);let c=l.elements,p=l.maybeClone(a,s,m),u=e_.create(l,p),f=_i.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(d)break;i=n()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new dr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=_i.inverse(t);return o.push(n)}};import{useEffect as o_,useState as n_}from"react";var Gh=(e,o)=>{let[t,n]=n_(o);return o_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as Uw}from"react/jsx-runtime";var zw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:Uh.EVENTUALLY};let[r,i]=n,a=i_(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Uh.NEVER}}return{captureUpdate:Uh.EVENTUALLY}},Hw=e=>({name:"undo",label:"buttons.undo",icon:Um,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>zw(r,t,()=>e.undo(Ow(o),t)),keyTest:o=>o[sl.CTRL_OR_CMD]&&Yh(o,sl.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:n}=Gh(e.onHistoryChangedEmitter,new dr(e.isUndoStackEmpty,e.isRedoStackEmpty));return Uw(Z,{type:"button",icon:Um,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),Gw=e=>({name:"redo",label:"buttons.redo",icon:Ym,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>zw(r,t,()=>e.redo(Ow(o),t)),keyTest:o=>o[sl.CTRL_OR_CMD]&&o.shiftKey&&Yh(o,sl.Z)||r_&&o.ctrlKey&&!o.shiftKey&&Yh(o,sl.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:n}=Gh(e.onHistoryChangedEmitter,new dr(e.isUndoStackEmpty,e.isRedoStackEmpty));return Uw(Z,{type:"button",icon:Ym,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as a_}from"@excalidraw/common";import{newElementWith as l_}from"@excalidraw/element";import{measureText as s_}from"@excalidraw/element";import{isTextElement as Yw}from"@excalidraw/element";import{CaptureUpdateAction as c_}from"@excalidraw/element";var Ww=N({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length===1&&Yw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&Yw(i)){let a=s_(i.originalText,a_(i),i.lineHeight);return l_(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:c_.IMMEDIATELY}}});import{CODES as d_,KEYS as m_}from"@excalidraw/common";import{CaptureUpdateAction as p_}from"@excalidraw/element";var Wh=N({name:"viewMode",label:"labels.viewMode",icon:Br,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:p_.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[m_.CTRL_OR_CMD]&&e.altKey&&e.code===d_.R});import{isPromiseLike as u_}from"@excalidraw/common";import{jsx as h_}from"react/jsx-runtime";var Vh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},cd=class{constructor(o,t,n,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=m=>{Vh(r,"ui",l,a,this.app,m),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return h_(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(u_(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,m)=>(m.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Vh(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Vh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var dd=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Xh=e=>{let o=Array.from(e.values());return{x:Vw(o,t=>t.x)/o.length,y:Vw(o,t=>t.y)/o.length}},Kh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Vw=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as H,pointRotateRads as En,rangeInclusive as Vt,rangeIntersection as md,rangesOverlap as pd}from"@excalidraw/math";import{TOOL_TYPE as mr,KEYS as Xw}from"@excalidraw/common";import{getCommonBounds as Zh,getDraggedElementsBounds as $h,getElementAbsoluteCoords as g_}from"@excalidraw/element";import{isBoundToContainer as jw}from"@excalidraw/element";import{getMaximumGroups as qw}from"@excalidraw/element";import{getSelectedElements as f_,getVisibleAndNonSelectedElements as Jw}from"@excalidraw/element";var b_=8,Kw=99999,ud=e=>b_/e,bt=class bt{};I(bt,"referenceSnapPoints",null),I(bt,"visibleGaps",null),I(bt,"setReferenceSnapPoints",o=>{bt.referenceSnapPoints=o}),I(bt,"getReferenceSnapPoints",()=>bt.referenceSnapPoints),I(bt,"setVisibleGaps",o=>{bt.visibleGaps=o}),I(bt,"getVisibleGaps",()=>bt.visibleGaps),I(bt,"destroy",()=>{bt.referenceSnapPoints=null,bt.visibleGaps=null});var Xt=bt,yn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Wo=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[Xw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[Xw.CTRL_OR_CMD]&&!yn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},x_=(e,o,t=.01)=>Math.abs(e-o)<=t,cl=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,d,c,p]=g_(a,o);r&&(l+=r.x,m+=r.x,c+=r.x,s+=r.y,d+=r.y,p+=r.y);let u=(m-l)/2,f=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=En(H(l,s+f),H(c,p),a.angle),x=En(H(l+u,s),H(c,p),a.angle),y=En(H(m,s+f),H(c,p),a.angle),E=En(H(l+u,d),H(c,p),a.angle),w=H(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}else{let b=En(H(l,s),H(c,p),a.angle),x=En(H(m,s),H(c,p),a.angle),y=En(H(l,d),H(c,p),a.angle),E=En(H(m,d),H(c,p),a.angle),w=H(c,p);i=t?[b,x,y,E]:[b,x,y,E,w]}}else if(e.length>1){let[a,l,s,m]=$h(e,r??{x:0,y:0}),d=s-a,c=m-l,p=H(a,l),u=H(s,l),f=H(a,m),b=H(s,m),x=H(a+d/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])))},Qw=(e,o,t,n)=>Jw(e,o,t,n),ev=(e,o,t,n)=>{let r=Qw(e,o,t,n),i=qw(r,n).filter(c=>!(c.length===1&&jw(c[0]))).map(c=>Zh(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>Kw)break e;let f=a[u],[,b,x,y]=p,[E,w,,v]=f;x<E&&pd(Vt(b,y),Vt(w,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,y)],endSide:[H(E,w),H(E,v)],length:E-x,overlap:md(Vt(b,y),Vt(w,v))})}}let m=i.sort((c,p)=>c[1]-p[1]),d=[];s=0;e:for(let c=0;c<m.length;c++){let p=m[c];for(let u=c+1;u<m.length;u++){if(++s>Kw)break e;let f=m[u],[b,,x,y]=p,[E,w,v]=f;y<w&&pd(Vt(b,x),Vt(E,v))&&d.push({startBounds:p,endBounds:f,startSide:[H(b,y),H(x,y)],endSide:[H(E,w),H(v,w)],length:w-y,overlap:md(Vt(b,x),Vt(E,v))})}}return{horizontalGaps:l,verticalGaps:d}},Zw=(e,o,t,n,r,i,a)=>{if(!Wo({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Xt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[d,c,p,u]=$h(e,o).map(x=>Le(x)),f=(d+p)/2,b=(c+u)/2;for(let x of s){if(!pd(Vt(c,u),x.overlap))continue;let y=x.startSide[0][0]+x.length/2,E=Le(y-f);if(x.length>p-d&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let k={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(k);continue}let[,,v]=x.endBounds,C=d-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(r.length=0),a.x=Math.abs(S);let k={type:"gap",direction:"side_right",gap:x,offset:S};r.push(k);continue}let[L,,,]=x.startBounds,P=L-p,B=Le(P-x.length);if(Math.abs(B)<=a.x){Math.abs(B)<a.x&&(r.length=0),a.x=Math.abs(B);let k={type:"gap",direction:"side_left",gap:x,offset:B};r.push(k);continue}}for(let x of m){if(!pd(Vt(d,p),x.overlap))continue;let y=x.startSide[0][1]+x.length/2,E=Le(y-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 k={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(k);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 k={type:"gap",direction:"side_top",gap:x,offset:S};i.push(k);continue}let[,,,L]=x.endBounds,P=Le(c-L),B=x.length-P;if(Math.abs(B)<=a.y){Math.abs(B)<a.y&&(i.length=0),a.y=Math.abs(B);let k={type:"gap",direction:"side_bottom",gap:x,offset:B};i.push(k);continue}}}},tv=(e,o,t,n)=>{let r=Qw(e,o,t,n);return qw(r,n).filter(i=>!(i.length===1&&jw(i[0]))).flatMap(i=>cl(i,n))},Ri=(e,o,t,n,r,i,a)=>{if(!Wo({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Xt.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let d=m[0]-s[0],c=m[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[s,m],offset:d}),a.x=Math.abs(d)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:c}),a.y=Math.abs(c))}},ov=(e,o,t,n,r)=>{let i=t.state,a=f_(e,i);if(!Wo({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Le(o.x),o.y=Le(o.y);let l=[],s=[],m=ud(i.zoom.value),d={x:m,y:m},c=cl(a,r,{dragOffset:o});Ri(a,c,t,n,l,s,d),Zw(a,o,t,n,l,s,d);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};d.x=0,d.y=0,l.length=0,s.length=0;let u={x:Le(o.x+p.x),y:Le(o.y+p.y)};Ri(a,cl(a,r,{dragOffset:u}),t,n,l,s,d),Zw(a,u,t,n,l,s,d);let f=jh(l,s),b=y_(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,$w=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},jh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Le(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Le(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:$w(i.map(a=>H(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:$w(i.map(a=>H(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},E_=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Le(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},y_=(e,o,t)=>{let[n,r,i,a]=$h(e,o),l=[];for(let s of t){let[m,d,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,y=md(Vt(r,a),s.gap.overlap),E=md(Vt(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],w),H(n,w)]},{type:"gap",direction:"horizontal",points:[H(i,w),H(s.gap.endSide[0][0],w)]})}break}case"center_vertical":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,s.gap.startSide[0][1]),H(w,r)]},{type:"gap",direction:"vertical",points:[H(w,a),H(w,s.gap.endSide[0][1])]})}break}case"side_right":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(c,w),H(u,w)]},{type:"gap",direction:"horizontal",points:[H(b,w),H(n,w)]})}break}case"side_left":{if(y){let w=(y[0]+y[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,w),H(m,w)]},{type:"gap",direction:"horizontal",points:[H(c,w),H(u,w)]})}break}case"side_top":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,a),H(w,d)]},{type:"gap",direction:"vertical",points:[H(w,p),H(w,f)]})}break}case"side_bottom":{if(E){let w=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(w,p),H(w,f)]},{type:"gap",direction:"vertical",points:[H(w,x),H(w,r)]})}break}}}return E_(l.map(s=>({...s,points:s.points.map(m=>H(Le(m[0]),Le(m[1])))})))},qh=(e,o,t,n,r,i)=>{if(!Wo({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!x_(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=Zh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(m+=r.y));let d=[];if(i)switch(i){case"e":{d.push(H(s,l),H(s,m));break}case"w":{d.push(H(a,l),H(a,m));break}case"n":{d.push(H(a,l),H(s,l));break}case"s":{d.push(H(a,m),H(s,m));break}case"ne":{d.push(H(s,l));break}case"nw":{d.push(H(a,l));break}case"se":{d.push(H(s,m));break}case"sw":{d.push(H(a,m));break}}let c=ud(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ri(o,d,t,n,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,y,E,w]=Zh(e).map(S=>Le(S)),v=[H(x,y),H(x,w),H(E,y),H(E,w)];Ri(e,v,t,n,u,f,p);let C=jh(u,f);return{snapOffset:b,snapLines:C}},nv=(e,o,t,n,r,i)=>{if(!Wo({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(n.x+r.x,n.y+r.y)],l=ud(o.state.zoom.value),s={x:l,y:l},m=[],d=[];Ri([e],a,o,t,m,d,s);let c={x:m[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,m.length=0,d.length=0;let p=cl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ri([e],p,o,t,m,d,s);let u=jh(m,d);return{snapOffset:c,snapLines:u}},rv=(e,o,t,n,r)=>{if(!Wo({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Jw(e,[],o.state,r),a=ud(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let d of i){let c=cl([d],r);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.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:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},iv=e=>e===mr.rectangle||e===mr.ellipse||e===mr.diamond||e===mr.frame||e===mr.magicframe||e===mr.image||e===mr.text;import{pointFrom as hd}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as w_,DEFAULT_FONT_SIZE as v_,TEXT_ALIGN as T_,VERTICAL_ALIGN as I_,getSizeFromPoints as C_,randomId as S_,arrayToMap as k_,assertNever as Jh,cloneJSON as sv,getFontString as M_,isDevEnv as P_,toBrandedType as L_,getLineHeight as A_}from"@excalidraw/common";import{bindLinearElement as av}from"@excalidraw/element";import{newArrowElement as D_,newElement as Qh,newFrameElement as __,newImageElement as R_,newLinearElement as N_,newMagicFrameElement as B_,newTextElement as fd}from"@excalidraw/element";import{measureText as F_,normalizeText as O_}from"@excalidraw/element";import{isArrowElement as z_}from"@excalidraw/element";import{syncInvalidIndices as H_}from"@excalidraw/element";import{redrawTextBoundingBox as G_}from"@excalidraw/element";import{LinearElementEditor as U_}from"@excalidraw/element";import{getCommonBounds as Y_}from"@excalidraw/element";import{Scene as W_}from"@excalidraw/element";var gd={width:100,height:0},wn=100,V_=(e,o,t)=>{let n=fd({x:0,y:0,textAlign:T_.CENTER,verticalAlign:I_.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),G_(n,e,t),[e,n]},lv=(e,o,t,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let d=o?.width??wn,c=o?.height??wn,p;o.id&&(p=n.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-d,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=fd({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=Qh({x:u,y:f,width:d,height:c,...p,...o,type:b});break}default:Jh(e,`Unhandled element start type "${o.type}"`,!0)}av(e,i,"start",r)}}if(t){let d=t?.height??wn,c=t?.width??wn,p;t.id&&(p=n.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-d/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=fd({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=Qh({x:u,y:f,width:c,height:d,...p,...t,type:b});break}default:Jh(e,`Unhandled element end type "${b}"`,!0)}av(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=sv(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,U_.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},eg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>H_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>L_(k_(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ni=(e,o)=>{if(!e)return[];let t=sv(e),n=new eg,r=new Map,i=new Map;for(let s of t){let m,d=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:S_()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||wn,u=s?.label?.text&&s.height===void 0?0:s?.height||wn;m=Qh({...s,width:p,height:u});break}case"line":{let p=s.width||gd.width,u=s.height||gd.height;m=N_({width:p,height:u,points:[hd(0,0),hd(p,u)],...s});break}case"arrow":{let p=s.width||gd.width,u=s.height||gd.height;m=D_({width:p,height:u,endArrowhead:"arrow",points:[hd(0,0),hd(p,u)],...s,type:"arrow"}),Object.assign(m,C_(m.points));break}case"text":{let p=s?.fontFamily||w_,u=s?.fontSize||v_,f=s?.lineHeight||A_(p),b=s.text??"",x=O_(b),y=F_(x,M_({fontFamily:p,fontSize:u}),f);m=fd({width:y.width,height:y.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=R_({width:s?.width||wn,height:s?.height||wn,...s});break}case"frame":{m=__({x:0,y:0,...s});break}case"magicframe":{m=B_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:m=s,Jh(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(n.add(m),r.set(m.id,s),d&&i.set(d,m.id))}let a=n.getElementsMap(),l=new W_(a);for(let[s,m]of r){let d=n.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[c,p]=V_(d,m?.label,l);if(n.add(c),n.add(p),z_(c)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:y}=lv(c,u,f,n,l);c=b,n.add(b),n.add(x),n.add(y)}}else switch(m.type){case"arrow":{let{start:c,end:p}=m;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}=lv(d,c,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,m]of r){if(m.type!=="frame"&&m.type!=="magicframe")continue;let d=n.getElement(s);if(!d)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=n.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:d.id}),L?.boundElements?.forEach(P=>{let B=n.getElement(P.id);if(!B)throw new Error(`Bound element with id ${P.id} doesn't exist`);Object.assign(B,{frameId:d.id}),c.push(B)}),c.push(L)});let[p,u,f,b]=Y_(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let y=d?.x||p,E=d?.y||u,w=d?.width||f-p,v=d?.height||b-u;Object.assign(d,{x:y,y:E,width:w,height:v}),P_()&&m.children.length&&(d?.x||d?.y||d?.width||d?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return n.getElements()};import{isElementInViewport as wR}from"@excalidraw/element";import{memoize as vR,toBrandedType as TR}from"@excalidraw/common";import{pointFrom as Q_,pointsEqual as eR}from"@excalidraw/math";import xd from"open-color";import{arrayToMap as tR,DEFAULT_TRANSFORM_HANDLE_SPACING as sg,FRAME_STYLE as gv,invariant as fv,THEME as oR,throttleRAF as nR}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as og,maxBindingGap as vv}from"@excalidraw/element";import{LinearElementEditor as vn}from"@excalidraw/element";import{getOmitSidesForDevice as ng,getTransformHandles as rR,getTransformHandlesFromCoords as iR,shouldShowBoundingBox as aR}from"@excalidraw/element";import{isElbowArrow as dl,isFrameLikeElement as bv,isImageElement as xv,isLinearElement as lR,isLineElement as sR,isTextElement as Ev}from"@excalidraw/element";import{renderSelectionElement as cR}from"@excalidraw/element";import{getElementsInGroup as ag,getSelectedGroupIds as dR,isSelectedViaGroup as mR,selectGroupsFromGivenElements as pR}from"@excalidraw/element";import{getCommonBounds as lg,getElementAbsoluteCoords as ml}from"@excalidraw/element";import{pointFrom as dt}from"@excalidraw/math";import{THEME as X_}from"@excalidraw/common";var K_="#ff6b6b",Z_="#ff0000",cv=1,dv=2,mv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===X_.LIGHT||o.zenModeEnabled?K_:Z_,n=(o.zenModeEnabled?cv*1.5:cv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,j_(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,q_(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,$_(r,e,o));e.restore()},$_=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Kt(n,r,o)}for(let n of e.points)pv(n,t,o)},j_=(e,o,t)=>{pv(e.points[0],t,o),t.zenModeEnabled||Kt(e.points[0],e.points[1],o)},pv=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?dv*1.5:dv)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},Kt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},q_=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||Kt(dt(e[0],e[1]-i),dt(e[0],e[1]+i),r),Kt(dt(s[0]-l,s[1]-a),dt(s[0]-l,s[1]+a),r),Kt(dt(s[0]+l,s[1]-a),dt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(Kt(dt(o[0],o[1]-i),dt(o[0],o[1]+i),r),Kt(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||Kt(dt(e[0]-i,e[1]),dt(e[0]+i,e[1]),r),Kt(dt(s[0]-a,s[1]-l),dt(s[0]+a,s[1]-l),r),Kt(dt(s[0]-a,s[1]+l),dt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(Kt(dt(o[0]-i,o[1]),dt(o[0]+i,o[1]),r),Kt(e,o,r))}};import{getGlobalCSSVariable as bd}from"@excalidraw/common";import{getCommonBounds as J_}from"@excalidraw/element";var so=4,It=6,uv="rgba(0,0,0,0.3)",hv=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=J_(e),s=o/n.zoom.value,m=t/n.zoom.value,d={top:parseInt(bd("sat"))||0,bottom:parseInt(bd("sab"))||0,left:parseInt(bd("sal"))||0,right:parseInt(bd("sar"))||0},c=Do().rtl,p=-n.scrollX+d.left,u=-n.scrollY+d.top,f=p+s-d.right,b=u+m-d.bottom,x=Math.min(r,p),y=Math.min(i,u),E=Math.max(a,f),w=Math.max(l,b),v=a-r,C=l-i,S=E-x,L=w-y,P=Math.max(so*2,d.left+d.right)+It*2,B=o*(s/S)-P,k=Math.max(so*2,d.top+d.bottom)+It*2,A=t*(m/L)-k,F=S>v?S*n.zoom.value/(B+P):o/(B+P),Y=L>C?L*n.zoom.value/(A+k):t/(A+k);return{horizontal:p===x&&f===E?null:{x:Math.max(d.left,so)+It+(p-x)/S*o,y:t-It-Math.max(so,d.bottom),width:B,height:It,deltaMultiplier:F},vertical:u===y&&b===w?null:{x:c?Math.max(d.left,so):o-It-Math.max(d.right,so),y:Math.max(d.top,so)+It+(u-y)/L*t,width:It,height:A,deltaMultiplier:Y}}},tg=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var uR=(e,o)=>{fv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;fv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Tv(t,e,o),e.restore()},hR=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=vn.getElement(n,t);if(!i)return;let a=vn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Tv(a,e,o),e.restore()},Tv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",oa(o,e[0],e[1],vn.POINT_HANDLE_SIZE/t.zoom.value,!1)},rg=(e,o,t,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),oa(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},gR=(e,o,t,n)=>{let r=vv(o,o.width,o.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":w1(e,o,t,r);break;case"diamond":T1(e,r,o,t);break;case"ellipse":{let[i,a,l,s]=ml(o,t),m=l-i,d=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-og,v1(e,m+r+og,d+r+og,i+m/2,a+d/2,o.angle);break}}},fR=(e,o,t,n)=>{let[r,i,a]=o,l=vv(a,a.width,a.height,n);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[d,c]=vn.getPointAtIndexGlobalCoordinates(r,m,t);oa(e,d,c,l,!0)})},Iv=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:d,dashed:c,activeEmbeddable:p}=t,u=a-r,f=l-i,x=(t.padding??sg*2)/o.zoom.value,y=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 w=s.length;for(let v=0;v<w;++v)e.strokeStyle=s[v],c&&e.setLineDash([y,E+(y+E)*(w-1)]),e.lineDashOffset=(y+E)*v,na(e,r-x,i-x,u+x*2,f+x*2,m,d,n);e.restore()},bR=(e,o,t,n)=>{let r=Array.isArray(t)?fR:gR;e.save(),e.translate(o.scrollX,o.scrollY),r(e,t,n,o.zoom),e.restore()},xR=(e,o,t,n)=>{let[r,i,a,l]=ml(t,n),s=a-r,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=gv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),na(e,r,i,s,m,r+s/2,i+m/2,t.angle,!1,gv.radius/o.zoom.value),e.restore()},yv=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(d=>d.groupIds.length===0),l=t.filter(d=>d.groupIds.length>0),s=d=>{let[c,p,u,f]=lg(d);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=d=>{let c=ag(t,d);return s(c)};Object.entries(pR(l,o)).filter(([d,c])=>c).map(([d,c])=>d).map(d=>m(d)).concat(a.map(d=>s([d]))).forEach(d=>Iv(e,o,d))},ig=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=vn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=vn,a=o.selectedLinearElement?.isEditing?i:i/2,l=dl(t),s=sR(t);if(r.forEach((m,d)=>{if(l&&d!==0&&d!==r.length-1)return;let c=d>0&&(d!==r.length-1||!s||!t.polygon)&&eR(m,d===r.length-1?r[0]:r[d-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(d);s&&t.polygon&&!p&&d===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),rg(e,o,m,a,p,!1,c)}),dl(t)){let m=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,c)=>{vn.isSegmentTooShort(t,r[c+1],r[c],c,o.zoom)||rg(e,o,Q_((d[0]+r[c+1][0])/2,(d[1]+r[c+1][1])/2),i/2,!1,!m.includes(c+1),!1)})}else vn.getEditorMidPoints(t,n,o).filter((d,c,p)=>d!==null&&!(dl(t)&&(c===0||c===p.length-1))).forEach(d=>{(o.selectedLinearElement?.isEditing||r.length===2)&&rg(e,o,d,i/2,!1,!0,!1)});e.restore()},wv=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,m,d]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?oa(e,l+m/2,s+d/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,d,2/t.zoom.value),e.fill(),e.stroke()):na(e,l,s,m,d,l+m/2,s+d/2,r,!0),e.restore()}})},ER=(e,o,t,n,r)=>{let[i,a,,,l,s]=ml(n,r),m=3,d=20,c=m/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(d/t.zoom.value,u),x=Math.min(d/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[[w,v],[C,S],[L,P],[B,k],[A,F]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(w+C,v+S),e.lineTo(w+L,v+P),e.stroke(),e.beginPath(),e.moveTo(w+B,v+k),e.lineTo(w+A,v+F),e.stroke(),e.restore()}),e.restore()},yR=(e,o,t,n)=>{o.save();let r=sg*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+r),d=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(m,d,i,a),o.restore()},Cv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,d]=Vl(e,i),c=Xl({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:d});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&&ig(c,a,p,o),a.selectionElement&&!a.isCropping)try{cR(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Ev(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&yR(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{bR(c,a,b,o)}),a.frameToHighlight&&xR(c,a,a.frameToHighlight,o),a.elementsToHighlight&&yv(c,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:ag(r,a.activeLockedId);yv(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>bv(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&ig(c,a,n[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(y=>y.id===b.elementId);b.segmentMidPointHoveredCoords?uR(c,a):(dl(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&hR(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=aR(n,a),x=n.length===1&&lR(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&ig(c,a,n[0],o);let y=l.selectionColor||xd.black;if(b){let E=tR(n),w=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&dl(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!mR(a,C)&&S.push(y),L&&S.push(...L.map(P=>rr(P,a.collaborators.get(P))))),S.length){let[P,B,k,A,F,Y]=ml(C,o,!0);w.push({angle:C.angle,x1:P,y1:B,x2:k,y2:A,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:F,cy:Y,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||xv(C)?0:void 0})}}let v=C=>{let S=ag(o,C),[L,P,B,k]=lg(S);w.push({angle:0,x1:L,x2:B,y1:P,y2:k,selectionColors:S.some(A=>A.locked)?["#ced4da"]:[xd.black],dashed:!0,cx:L+(B-L)/2,cy:P+(k-P)/2,activeEmbeddable:!1})};for(let C of dR(a))v(C);a.editingGroupId&&v(a.editingGroupId),w.forEach(C=>Iv(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),n.length===1){c.fillStyle=xd.white;let E=rR(n[0],a.zoom,o,"mouse",ng(s));if(!a.viewModeEnabled&&b&&!Ev(a.editingTextElement)&&!a.croppingElementId&&wv(c,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let w=o.get(a.croppingElementId);w&&xv(w)&&ER(c,l,a,w,o)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=sg*2/a.zoom.value;c.fillStyle=xd.white;let[w,v,C,S]=lg(n,o),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let P=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=y,na(c,w-E,v-E,C-w+E*2,S-v+E*2,(w+C)/2,(v+S)/2,0),c.lineWidth=P,c.setLineDash(L);let B=iR([w,v,C,S,(w+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...ng(s),rotation:!0}:ng(s));n.some(k=>!k.locked)&&wv(c,l,a,B,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:y})=>{let E=o.get(b);if(E){let[w,v,,,C,S]=ml(E,o,!0);c.save(),a.theme===oR.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=bv(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(C,S),c.rotate(E.angle),y.forEach(P=>{(P.showOnCanvas||x)&&c.fillRect(w+P.offsetX/L-C,v+P.offsetY/L-S,P.width/L,P.height/L)}),c.restore()}}),mv(c,a),c.restore(),NE({context:c,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:d});let f;return l.renderScrollbars&&(f=hv(o,m,d,a),c.save(),c.fillStyle=uv,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&cc(c,b.x,b.y,b.width,b.height,It/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},cg=nR(e=>{let o=Cv(e);e.callback?.(o)},{trailing:!0}),Sv=(e,o)=>{if(o){cg(e);return}let t=Cv(e);return e.callback(t),t};var pl=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:d})=>{let c=[];for(let p of n.values())wR(p,d,m,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&c.push(p);return c},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=TR(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return vR(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:d,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:d,newElementId:c}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){cg.cancel(),C1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as IR}from"@excalidraw/common";import{getElementAbsoluteCoords as CR}from"@excalidraw/element";import{jsx as MR}from"react/jsx-runtime";var SR=5,kR=(e,o,t)=>{let[n,r]=CR(e,t),{x:i,y:a}=IR({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},dg=({children:e,element:o,elementsMap:t})=>{let n=bo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=kR(o,n,t);return MR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:SR},children:e})};import{DEFAULT_LASER_COLOR as DR,easeOut as Mv}from"@excalidraw/common";import{LaserPointer as PR}from"@excalidraw/laser-pointer";import{SVG_NS as kv,getSvgPathFromStroke as LR,sceneCoordsToViewportCoords as AR}from"@excalidraw/common";var Vo=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(kv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(kv,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new PR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=AR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return LR(r,!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 Vo(o,t,{...this.getTrailOptions(),fill:()=>DR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Mv(i),Mv(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Vo(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||rr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as _R}from"react";import{unstable_batchedUpdates as Pv}from"react-dom";import{throttleRAF as RR}from"@excalidraw/common";var Ae=e=>o=>{Pv(e,o)},yd=e=>RR(o=>{Pv(e,o)}),Bi=(()=>{let e;try{let t=_R.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 mg,KEYS as ul,CLASSES as pg,POINTER_BUTTON as NR,isWritableElement as BR,getFontString as Lv,getFontFamilyString as Av,isTestEnv as Dv,MIME_TYPES as FR}from"@excalidraw/common";import{originalContainerCache as OR,updateOriginalContainerCache as _v}from"@excalidraw/element";import{LinearElementEditor as zR}from"@excalidraw/element";import{bumpVersion as HR}from"@excalidraw/element";import{getBoundTextElementId as GR,getContainerElement as ug,getTextElementAngle as UR,redrawTextBoundingBox as YR,getBoundTextMaxHeight as WR,getBoundTextMaxWidth as Rv,computeContainerDimensionForBoundText as Nv,computeBoundTextPosition as VR,getBoundTextElement as XR}from"@excalidraw/element";import{getTextWidth as KR}from"@excalidraw/element";import{normalizeText as Bv}from"@excalidraw/element";import{wrapText as ZR}from"@excalidraw/element";import{isArrowElement as wd,isBoundToContainer as $R,isTextElement as Fv}from"@excalidraw/element";var jR=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},Ov=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let W=R.style.fontFamily.replace(/"/g,"");return Av({fontFamily:_.fontFamily})!==W||`${_.fontSize}px`!==R.style.fontSize},d=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:W,verticalAlign:X}=R,G=l.scene.getNonDeletedElementsMap();if(R&&Fv(R)){let me=R.x,ue=R.y,pe=ug(R,l.scene.getNonDeletedElementsMap()),it=R.width,uo=R.height,yr=R.width,wr=R.height;if(pe&&R.containerId){if(wd(pe)){let qo=zR.getBoundTextElementPosition(pe,R,G);me=qo.x,ue=qo.y}let Gl=m(R,c),Qi;if(Gl?Qi=_v(pe.id,pe.height):(Qi=OR[pe.id],Qi||(Qi=_v(pe.id,pe.height))),yr=Rv(pe,R),wr=WR(pe,R),!wd(pe)&&uo>wr){let qo=Nv(uo,pe.type);l.scene.mutateElement(pe,{height:qo});return}else if(!wd(pe)&&pe.height>Qi.height&&uo<wr){let qo=Nv(uo,pe.type);l.scene.mutateElement(pe,{height:qo})}else{let{x:qo,y:kC}=VR(pe,R,G);me=qo,ue=kC}}let[Hl,Im]=n(me,ue),CC=c.selectionStart,Cm=c.selectionEnd,c1=c.value.length;if(CC===Cm&&Cm!==c1){let Gl=c1-Cm;c.selectionStart=c.value.length-Gl,c.selectionEnd=c.value.length-Gl}pe?it+=.5:(yr=(_.width-8-Hl)/_.zoom.value,it=Math.min(it,yr)),uo*=1.05;let SC=Lv(R),d1=(_.height-Im)/_.zoom.value;Object.assign(c.style,{font:SC,lineHeight:R.lineHeight,width:`${it}px`,height:`${uo}px`,left:`${Hl}px`,top:`${Im}px`,transform:jR(it,uo,UR(R,pe),_,yr,d1),textAlign:W,verticalAlign:X,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${d1}px`}),c.scrollTop=0,Dv()&&(c.style.fontFamily=Av(R)),l.scene.mutateElement(R,{x:me,y:ue})}},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";($R(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),c.value=r.originalText,d(),o&&(c.onpaste=async _=>{let R=(await Oa(_)).findByType(FR.text);if(!R)return;let W=Bv(R.value);if(!W)return;let X=ug(r,l.scene.getNonDeletedElementsMap()),G=Lv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(X){let me=XR(X,l.scene.getNonDeletedElementsMap()),ue=ZR(`${c.value}${W}`,G,Rv(X,me)),pe=KR(ue,G);c.style.width=`${pe}px`}},c.oninput=()=>{let _=Bv(c.value);if(c.value!==_){let R=c.selectionStart;c.value=_,c.selectionStart=R,c.selectionEnd=R}o(c.value)}),c.onkeydown=_=>{if(!_.shiftKey&&Xs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Xs),d();else if(!_.shiftKey&&Ks.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ks),d();else if(!_.shiftKey&&Zs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Zs),d();else if(Xp.keyTest(_))l.actionManager.executeAction(Xp);else if(Kp.keyTest(_))l.actionManager.executeAction(Kp);else if(_.key===ul.ESCAPE)_.preventDefault(),C=!0,S();else if(or.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(or);else if(_.key===ul.ENTER&&_[ul.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===ul.TAB||_[ul.CTRL_OR_CMD]&&(_.code===mg.BRACKET_LEFT||_.code===mg.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===mg.BRACKET_LEFT?E():y(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),y=()=>{let{selectionStart:_,selectionEnd:R}=c,W=w(),X=c.value;W.forEach(G=>{let me=X.slice(0,G),ue=X.slice(G);X=`${me}${b}${ue}`}),c.value=X,c.selectionStart=_+f,c.selectionEnd=R+f*W.length},E=()=>{let{selectionStart:_,selectionEnd:R}=c,W=w(),X=[],G=c.value;W.forEach(me=>{let ue=G.slice(me,me+f).match(x);if(ue){let pe=G.slice(0,me),it=G.slice(me+ue[0].length);G=`${pe}${it}`,X.push(me)}}),c.value=G,X.length&&(_>X[X.length-1]?c.selectionStart=Math.max(_-f,X[X.length-1]):c.selectionStart=_,c.selectionEnd=Math.max(c.selectionStart,R-f*X.length))},w=()=>{let{selectionStart:_,selectionEnd:R,value:W}=c,X=W.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-X,W.slice(_,R).split(`
16
+ `).reduce((me,ue,pe,it)=>me.concat(pe?me[pe-1]+it[pe-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(Y)return;Y=!0,L();let _=l.scene.getElement(r.id);if(!_)return;let R=ug(_,l.scene.getNonDeletedElementsMap());if(R){if(c.value.trim()){let W=GR(R);!W||W!==r.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:r.id})}):wd(R)&&HR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(W=>!Fv(W))});YR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:c.value})},L=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,Q&&Q.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",k),window.removeEventListener("pointerup",P),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),A(),F(),c.remove()},P=_=>{window.removeEventListener("pointerup",P);let R=_?.target,W=R instanceof HTMLElement&&R.classList.contains("properties-trigger"),X=(R instanceof HTMLElement||R instanceof SVGElement)&&!!R.closest(".properties-content"),G=(R instanceof HTMLElement||R instanceof SVGElement)&&(!!R.closest(`.${pg.SHAPE_ACTIONS_MENU}`)||!!R.closest(".compact-shape-actions-island"));setTimeout(()=>{G||W||X||(c.onblur=S,c.focus())})},B=()=>{c.onblur=null,window.addEventListener("pointerup",P),window.addEventListener("blur",S)},k=_=>{let R=_?.target;if(_.button===NR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),B();return}let W=R instanceof HTMLElement&&R.classList.contains("properties-trigger"),X=(R instanceof HTMLElement||R instanceof SVGElement)&&!!R.closest(".properties-content");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&(_.target.closest(`.${pg.SHAPE_ACTIONS_MENU}, .${pg.ZOOM_ACTIONS}`)||_.target.closest(".compact-shape-actions-island"))&&!BR(_.target)||W||X?B():_.target instanceof HTMLCanvasElement&&!Dv()&&requestAnimationFrame(()=>{S()})},A=l.scene.onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||c.focus()}),F=l.onScrollChangeEmitter.on(()=>{d()}),Y=!1;s&&c.select(),P();let Q=null;return i&&"ResizeObserver"in window?(Q=new window.ResizeObserver(()=>{d()}),Q.observe(i)):window.addEventListener("resize",d),c.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",k,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),S};var zv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as a9}from"@excalidraw/math";import{getElementLineSegments as l9}from"@excalidraw/element";import{LinearElementEditor as s9}from"@excalidraw/element";import{isFrameLikeElement as c9,isLinearElement as d9,isTextElement as m9}from"@excalidraw/element";import{getFrameChildren as p9}from"@excalidraw/element";import{selectGroupsForSelectedElements as u9}from"@excalidraw/element";import{getContainerElement as h9}from"@excalidraw/element";import{arrayToMap as g9,easeOut as Yv,isShallowEqual as f9}from"@excalidraw/common";import{simplify as qR}from"points-on-curve";import{polygonFromPoints as JR,lineSegment as Hv,polygonIncludesPointNonZero as QR}from"@excalidraw/math";import{computeBoundTextPosition as e9,doBoundsIntersect as t9,getBoundTextElement as o9,getElementBounds as n9,intersectElementWithLineSegment as Gv}from"@excalidraw/element";var Uv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=qR(o,l));let m=t.filter(p=>!p.locked);a.clear(),i.clear();let d=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of m){let u=n9(p,n);t9(d,u)&&!i.has(p.id)&&!a.has(p.id)&&(r9(s,p,r)?a.add(p.id):i9(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},r9=(e,o,t)=>{let n=JR(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>QR(a,n))):!1},i9=(e,o,t)=>{let n=e.slice(1).map((i,a)=>Hv(e[a],i)).concat([Hv(e[e.length-1],e[0])]),r=o9(o,t);return n.some(i=>Gv(o,t,i,0,!0).length>0||!!r&&Gv({...r,...e9(o,r,t)},t,i,0,!0).length>0)};var vd=class extends Vo{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(Yv(s),Yv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&m9(m)){let d=h9(m,this.app.scene.getNonDeletedElementsMap());d&&(r[d.id]=!0,delete r[m.id])}}for(let[s]of Object.entries(r)){let m=this.app.scene.getNonDeletedElement(s);if(m&&c9(m)){let d=p9(this.app.scene.getNonDeletedElementsMap(),m.id);for(let c of d)delete r[c.id]}}let i=u9({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&d9(this.app.scene.getNonDeletedElement(a[0]))?new s9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>a9(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!f9(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=g9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=l9(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=Uv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as b9,easeOut as Wv,THEME as x9}from"@excalidraw/common";import{computeBoundTextPosition as E9,doBoundsIntersect as y9,getBoundTextElement as w9,getElementBounds as v9,getElementLineSegments as T9,getFreedrawOutlineAsSegments as I9,getFreedrawOutlinePoints as C9,intersectElementWithLineSegment as Vv,isArrowElement as S9,isFreeDrawElement as Xv,isLineElement as k9,isPointInElement as M9}from"@excalidraw/element";import{lineSegment as P9,lineSegmentsDistance as Kv,pointFrom as Qv,polygon as L9,polygonIncludesPointNonZero as A9}from"@excalidraw/math";import{getElementsInGroup as Zv}from"@excalidraw/element";import{shouldTestInside as D9}from"@excalidraw/element";import{hasBoundTextElement as $v,isBoundToContainer as jv}from"@excalidraw/element";import{getBoundTextElementId as qv}from"@excalidraw/element";var Td=class extends Vo{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(Wv(s),Wv(l))},fill:()=>n.state.theme===x9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>Qv(l[0],l[1]))||[];if(n.length<2)return[];let r=P9(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=b9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Jv(r,l,a,this.app.state.zoom.value)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let d=Zv(this.app.scene.getNonDeletedElementsMap(),m);for(let c of d)this.elementsToErase.delete(c.id);this.groupsToErase.delete(m)}if(jv(l)&&this.elementsToErase.delete(l.containerId),$v(l)){let d=qv(l);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Jv(r,l,a,this.app.state.zoom.value)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let d=Zv(this.app.scene.getNonDeletedElementsMap(),m);for(let c of d)this.elementsToErase.add(c.id);this.groupsToErase.add(m)}if($v(l)){let d=qv(l);d&&this.elementsToErase.add(d)}jv(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()}},Jv=(e,o,t,n)=>{let r=e[1],i=Xv(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=v9(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!y9(a,s))return!1;if(D9(o)&&M9(r,o,t))return!0;if(Xv(o)){let d=C9(o),c=I9(o,d,t),p=Math.max(2.25,5/n);for(let f of c)if(Kv(f,e)<=p)return!0;let u=L9(...d.map(([f,b])=>Qv(o.x+f,o.y+b)));return!!A9(e[0],u)}let m=w9(o,t);if(S9(o)||k9(o)&&!o.polygon){let d=Math.max(o.strokeWidth,o.strokeWidth*2/n),c=T9(o,t);for(let p of c)if(Kv(p,e)<=d)return!0;return!1}return Vv(o,t,e,0,!0).length>0||!!m&&Vv({...m,...E9(o,m,t)},t,e,0,!0).length>0};import{jsx as Zt,jsxs as e3}from"react/jsx-runtime";var _9=()=>e3("div",{"data-testid":"brave-measure-text-error",children:[Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Zt("span",{style:{fontWeight:600},children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Zt("span",{style:{fontWeight:600},children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Zt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Zt("p",{children:Zt(ft,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Zt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>e3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),t3=_9;import z9 from"clsx";import H9 from"react";import{useLayoutEffect as R9,useRef as o3,useEffect as n3}from"react";import{unstable_batchedUpdates as N9}from"react-dom";import{KEYS as B9,queryFocusableElements as F9}from"@excalidraw/common";import{jsx as O9}from"react/jsx-runtime";var r3=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=o3(null);n3(()=>{let c=m.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===B9.TAB){let f=F9(c),{activeElement:b}=document,x=f.findIndex(y=>y===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 d=o3(null);return R9(()=>{if(r&&m.current&&t!=null&&o!=null){let c=m.current,{width:p,height:u}=c.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===o)return;d.current={top:t,left:o},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):o+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${o}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):t+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${t}px`}},[t,o,r,l,s,i,a]),n3(()=>{if(n){let c=p=>{m.current?.contains(p.target)||N9(()=>n(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[n]),O9("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as Fi,jsxs as G9}from"react/jsx-runtime";var Ve="separator",i3=H9.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=bo(),a=an(),l=o.reduce((s,m)=>(m&&(m===Ve||!m.predicate||m.predicate(a,i,e.app.props,e.app))&&s.push(m),s),[]);return Fi(r3,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Fi("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,m)=>{if(s===Ve)return!l[m-1]||l[m-1]===Ve?null:Fi("hr",{className:"context-menu-item-separator"},m);let d=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),Fi("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:G9("button",{type:"button",className:z9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Fi("div",{className:"context-menu-item__label",children:c}),Fi("kbd",{className:"context-menu-item__shortcut",children:d?Fe(d):""})]})},m)})})})});import{jsx as hg,jsxs as a3}from"react/jsx-runtime";var U9=({height:e,width:o,userToFollow:t,onDisconnect:n})=>hg("div",{className:"follow-mode",style:{width:o,height:e},children:a3("div",{className:"follow-mode__badge",children:[a3("div",{className:"follow-mode__badge__label",children:["Following"," ",hg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),hg("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:zt})]})}),l3=U9;import ur from"clsx";import lz from"react";import{CLASSES as sz,DEFAULT_SIDEBAR as uf,MQ_MIN_WIDTH_DESKTOP as cz,TOOL_TYPE as z5,arrayToMap as dz,capitalizeString as mz,isShallowEqual as cm}from"@excalidraw/common";import{mutateElement as pz}from"@excalidraw/element";import{showSelectedShapeActions as uz}from"@excalidraw/element";import{ShapeCache as hz}from"@excalidraw/element";import Y9 from"clsx";import{useState as W9,useEffect as V9}from"react";import{THEME as X9}from"@excalidraw/common";import{jsx as gg,jsxs as K9}from"react/jsx-runtime";var Id=({delay:e,theme:o})=>{let[t,n]=W9(!!e);return V9(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:K9("div",{className:Y9("LoadingMessage",{"LoadingMessage--dark":o===X9.DARK}),children:[gg("div",{children:gg(tt,{})}),gg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import Z9 from"clsx";import{jsx as c3,jsxs as j9}from"react/jsx-runtime";var $9="medium",s3={CHECKED:Lr,UNCHECKED:Vn},Cd=e=>j9("label",{className:Z9("ToolIcon ToolIcon__lock",`ToolIcon_size_${$9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[c3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),c3("div",{className:"ToolIcon__icon",children:e.checked?s3.CHECKED:s3.UNCHECKED})]});import{showSelectedShapeActions as hN}from"@excalidraw/element";import q9 from"clsx";import{jsx as J9}from"react/jsx-runtime";var Sd=({children:e,side:o,className:t})=>J9("div",{className:q9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import Q9 from"clsx";import{KEYS as d3}from"@excalidraw/common";import{jsx as eN}from"react/jsx-runtime";var kd=e=>eN(Z,{className:Q9("Shape",{fillable:!1}),type:"radio",icon:ps,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:d3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":d3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as tN,DEFAULT_SIDEBAR as oN}from"@excalidraw/common";import{isFlowchartNodeElement as nN,isImageElement as m3,isLinearElement as p3,isLineElement as rN,isTextBindableContainer as iN,isTextElement as aN}from"@excalidraw/element";import{getShortcutKey as fg}from"@excalidraw/common";import{isNodeInFlowchart as lN}from"@excalidraw/element";import{jsx as u3}from"react/jsx-runtime";var sN=({appState:e,isMobile:o,device:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===oN.name&&e.openSidebar.tab===tN&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(yt(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:fg("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");let m=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let d=m[0];return p3(d)&&d.points.length===2?g("hints.lockAngle"):m3(d)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(m.length===1&&aN(m[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(m.length===1&&m3(m[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(yn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!m.length&&!o)return[g("hints.canvasPanning")];if(m.length===1){if(p3(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):rN(m[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&iN(m[0]))return nN(m[0])?lN(m[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},Md=({appState:e,isMobile:o,device:t,app:n})=>{let r=sN({appState:e,isMobile:o,device:t,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>fg(a).replace(/\. ?$/,"")).join(". "):fg(r);return u3("div",{className:"HintViewer",children:u3("span",{children:i})})};import cN from"clsx";import{jsx as h3,jsxs as mN}from"react/jsx-runtime";var dN="medium",Pd=e=>e.penDetected?mN("label",{className:cN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${dN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[h3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),h3("div",{className:"ToolIcon__icon",children:Q1})]}):null;import{Fragment as pN,jsx as g3,jsxs as uN}from"react/jsx-runtime";var Tn=({heading:e,children:o,...t})=>{let{id:n}=Ne(),r=g3("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return g3("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):uN(pN,{children:[r,o]})})};import{Fragment as gN,jsx as nt,jsxs as Xo}from"react/jsx-runtime";var f3=({appState:e,elements:o,actionManager:t,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:d,renderWelcomeScreen:c,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ce(),y=()=>Xo(Sd,{side:"top",className:"App-top-bar",children:[c&&nt(f.Out,{}),nt(Tn,{heading:"shapes",children:w=>nt(qe.Col,{gap:4,align:"center",children:Xo(qe.Row,{gap:1,className:"App-toolbar-container",children:[Xo(Ye,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,nt(qe.Row,{gap:1,children:nt($c,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Xo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&nt(x.Out,{}),nt(Pd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),nt(Cd,{checked:e.activeTool.locked,onChange:r,title:g("toolBar.lock"),isMobile:!0}),nt(kd,{checked:Qt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),nt(Md,{appState:e,isMobile:!0,device:d,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?nt("div",{className:"App-toolbar-content",children:nt(b.Out,{})}):Xo("div",{className:"App-toolbar-content",children:[nt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Xo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Xo(gN,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&y(),nt("div",{className:"App-bottom-bar",style:{marginBottom:It+so*2,marginLeft:It+so*2,marginRight:It+so*2},children:Xo(Ye,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&hN(e,o)?nt(Tn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:nt(Zc,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Xo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&nt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(w=>({...Gn(o,w)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import fN from"open-color";import bN,{useLayoutEffect as xN,useRef as EN,useState as yN}from"react";import{jsx as hl,jsxs as wN}from"react/jsx-runtime";var b3=e=>{let o=EN(null),[t,n]=yN(null);return xN(()=>{if(!e.spreadsheet)return;let r=hE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await Cr(r,{exportBackground:!1,viewBackgroundColor:fN.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]),hl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:hl("div",{ref:o})})},x3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=Be(),r=bN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return hl(Oe,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:wN("div",{className:"container",children:[hl(b3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),hl(b3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as In from"@radix-ui/react-popover";import E3 from"clsx";import Ld,{useLayoutEffect as vN}from"react";import{supportsResizeObserver as TN,isShallowEqual as IN}from"@excalidraw/common";import{Fragment as PN,jsx as Co,jsxs as Ad}from"react/jsx-runtime";var CN=4,SN=8,kN=({shouldWrap:e,children:o,username:t})=>e?Co(At,{label:t||"Unknown user",children:o}):Co(PN,{children:o}),bg=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Co(kN,{username:o.username,shouldWrap:r,children:l},t)},MN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Dd=Ld.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=We(),i=new Map;t.forEach((b,x)=>{let y=b.id||x;i.set(y,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Ld.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),d=Ld.useRef(null);vN(()=>{if(d.current){let b=y=>{let E=Math.max(1,Math.min(8,Math.floor(y/38)));p(E)};if(b(d.current.clientWidth),!TN)return;let x=new ResizeObserver(y=>{for(let E of y){let{width:w}=E.contentRect;b(w)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[c,p]=Ld.useState(CN),f=a.slice(0,c-1).map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?Co("div",{className:E3("UserList UserList_mobile",e),children:a.map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Co("div",{className:"UserList__wrapper",ref:d,children:Ad("div",{className:E3("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&Ad(In.Root,{children:[Ad(In.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),Co(In.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ad(Ye,{padding:2,children:[a.length>=SN&&Co(Rs,{placeholder:g("quickSearch.placeholder"),onChange:s}),Co(Ns,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:m.length>0?[Co("div",{className:"hint",children:g("userList.hint.text")}),m.map(b=>bg({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Co(In.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!IN(r,i,MN))return!1}return!0});import xg from"clsx";import{jsx as LN}from"react/jsx-runtime";var y3=e=>LN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Dr});import{jsx as Ko,jsxs as Eg}from"react/jsx-runtime";var w3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ce();return Eg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Ko("div",{className:xg("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Ko(qe.Col,{gap:2,children:Eg(Tn,{heading:"canvasActions",children:[Ko(K2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Ko(Z2,{renderAction:o.renderAction,className:xg("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Ko(r.Out,{}),Ko("div",{className:xg("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Eg("div",{style:{position:"relative"},children:[n&&Ko(i.Out,{}),Ko(y3,{onClick:()=>o.executeAction(nr)})]})}),Ko($2,{actionManager:o,showExitZenModeBtn:t})]})},v3=w3;w3.displayName="Footer";import ON from"clsx";import{useEffect as _3,useLayoutEffect as R3,useRef as Mg,useState as zN,forwardRef as N3,useImperativeHandle as HN,useCallback as L3}from"react";import{EVENT as A3,isDevEnv as GN,KEYS as UN,updateObject as YN}from"@excalidraw/common";import DN from"clsx";import{useContext as _N}from"react";import AN from"react";var _d=AN.createContext({});import{jsx as yg,jsxs as T3}from"react/jsx-runtime";var wg=({children:e,className:o})=>{let t=de(),n=_N(_d),r=!!(t.editor.canFitSidebar&&n.shouldRenderDockButton);return T3("div",{className:DN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,T3("div",{className:"sidebar__header__buttons",children:[r&&yg(At,{label:g("labels.sidebarLock"),children:yg(Nt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:K1})}),yg(Nt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:zt})]})]})};wg.displayName="SidebarHeader";import*as C3 from"@radix-ui/react-tabs";import{jsx as I3}from"react/jsx-runtime";var vg=({children:e,tab:o,onSelect:t,...n})=>I3(C3.Trigger,{value:o,asChild:!0,onSelect:t,children:I3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});vg.displayName="SidebarTabTrigger";import*as S3 from"@radix-ui/react-tabs";import{jsx as RN}from"react/jsx-runtime";var Tg=({children:e,...o})=>RN(S3.List,{className:"sidebar-triggers",...o,children:e});Tg.displayName="SidebarTabTriggers";import NN from"clsx";import{jsx as Ig,jsxs as k3}from"react/jsx-runtime";var Cg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=ae(),m=be();return k3("label",{title:n,className:"sidebar-trigger__label-element",children:[Ig("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=d.target.checked;s({openSidebar:c?{name:e,tab:o}:null}),i?.(c)},checked:m.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),k3("div",{className:NN("sidebar-trigger",a),style:l,children:[t&&Ig("div",{children:t}),r&&Ig("div",{className:"sidebar-trigger__label",children:r})]})]})};Cg.displayName="SidebarTrigger";import*as M3 from"@radix-ui/react-tabs";import{jsx as BN}from"react/jsx-runtime";var Sg=({children:e,...o})=>{let t=be(),n=ae();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return BN(M3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};Sg.displayName="SidebarTabs";import*as P3 from"@radix-ui/react-tabs";import{jsx as FN}from"react/jsx-runtime";var kg=({tab:e,children:o,...t})=>FN(P3.Content,{...t,value:e,"data-testid":e,children:o});kg.displayName="SidebarTab";import{jsx as D3}from"react/jsx-runtime";import{createElement as WN}from"react";var gl=he(!1),B3=N3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{GN()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=ae(),s=en(gl);R3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let m=Mg({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=YN(m.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let d=Mg(null);HN(a,()=>d.current);let c=de(),p=L3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Wr(d,L3(u=>{u.target.closest(".sidebar-trigger")||(!n||!c.editor.canFitSidebar)&&p()},[p,n,c.editor.canFitSidebar])),_3(()=>{let u=f=>{f.key===UN.ESCAPE&&(!n||!c.editor.canFitSidebar)&&p()};return document.addEventListener(A3.KEYDOWN,u),()=>{document.removeEventListener(A3.KEYDOWN,u)}},[p,n,c.editor.canFitSidebar]),D3(Ye,{...i,className:ON("sidebar",{"sidebar--docked":n},r),ref:d,children:D3(_d.Provider,{value:m.current,children:o})})});B3.displayName="SidebarInner";var $t=Object.assign(N3((e,o)=>{let t=be(),{onStateChange:n}=e,r=Mg(t.openSidebar);_3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=zN(!1);return R3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?WN(B3,{...e,ref:o,key:e.name}):null}),{Header:wg,TabTriggers:Tg,TabTrigger:vg,Tabs:Sg,Tab:kg,Trigger:Cg});$t.displayName="Sidebar";import{composeEventHandlers as QN}from"@excalidraw/common";import{useLayoutEffect as VN,useRef as XN}from"react";import{jsx as KN}from"react/jsx-runtime";var Zo=(e,o)=>{let t=he(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ce(),[,a]=i(t),l=XN({preferHost:!1,counter:0});return VN(()=>{let s=l.current;return a(m=>{let d=m+1;return s.counter=d,d}),()=>{a(m=>{let d=m-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:KN(o,{...r})};return n.displayName=e,n};var Ag={};p1(Ag,{ChangeCanvasBackground:()=>j3,ClearCanvas:()=>Z3,CommandPalette:()=>V3,Export:()=>q3,Help:()=>K3,LiveCollaborationTrigger:()=>Q3,LoadScene:()=>U3,SaveAsImage:()=>W3,SaveToActiveFile:()=>Y3,SearchMenu:()=>X3,Socials:()=>J3,ToggleTheme:()=>$3});import qN from"clsx";import{THEME as Cn}from"@excalidraw/common";var Pg=he({active:!1});async function F3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{Ue.set(Pg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import ZN from"clsx";import{jsx as O3,jsxs as $N}from"react/jsx-runtime";var Rd=function({onChange:e,value:o,choices:t,name:n}){return O3("div",{className:"RadioGroup",children:t.map(r=>$N("div",{className:ZN("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[O3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as jN,jsx as Lg,jsxs as z3}from"react/jsx-runtime";var H3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=de();return z3(jN,{children:[z3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Lg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),Lg(Rd,{name:i,value:e,onChange:t,choices:n})]}),o&&!a.editor.isMobile&&Lg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};H3.displayName="DropdownMenuItemContentRadio";var G3=H3;import{Fragment as JN,jsx as je,jsxs as eT}from"react/jsx-runtime";var U3=()=>{let{t:e}=Ge(),o=We(),t=an();return o.isActionEnabled(ri)?je(pt,{icon:_r,onSelect:async()=>{(!t.length||await F3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ft,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>je("strong",{children:r}),br:()=>je("br",{})})}))&&o.executeAction(ri)},"data-testid":"load-button",shortcut:Fe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};U3.displayName="LoadScene";var Y3=()=>{let{t:e}=Ge(),o=We();return o.isActionEnabled(or)?je(pt,{shortcut:Fe("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(or),icon:s0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Y3.displayName="SaveToActiveFile";var W3=()=>{let e=ae(),{t:o}=Ge();return je(pt,{icon:ss,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Fe("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};W3.displayName="SaveAsImage";var V3=e=>{let o=ae(),{t}=Ge();return je(pt,{icon:ua,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Fe("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};V3.displayName="CommandPalette";var X3=e=>{let{t:o}=Ge(),t=We();return je(pt,{icon:Pt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(tl)},shortcut:Fe("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};X3.displayName="SearchMenu";var K3=()=>{let{t:e}=Ge(),o=We();return je(pt,{"data-testid":"help-menu-item",icon:Dr,onSelect:()=>o.executeAction(nr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};K3.displayName="Help";var Z3=()=>{let{t:e}=Ge(),o=en(lr);return We().isActionEnabled(Oo)?je(pt,{icon:Mt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};Z3.displayName="ClearCanvas";var $3=e=>{let{t:o}=Ge(),t=be(),n=We(),r=Fe("toggleTheme");return n.isActionEnabled(Jn)?e?.allowSystemTheme?je(G3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Cn.LIGHT,label:ca,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Cn.DARK,label:sa,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:Ib,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Cn.DARK?Cn.LIGHT:Cn.DARK);else return n.executeAction(Jn)},icon:t.theme===Cn.DARK?ca:sa,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Cn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Cn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};$3.displayName="ToggleTheme";var j3=()=>{let{t:e}=Ge(),o=be(),t=We(),n=xo();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:eT("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")})]})};j3.displayName="ChangeCanvasBackground";var q3=()=>{let{t:e}=Ge(),o=ae();return je(pt,{icon:Xn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};q3.displayName="Export";var J3=()=>{let{t:e}=Ge();return eT(JN,{children:[je(vi,{icon:as,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(vi,{icon:a0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(vi,{icon:i0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};J3.displayName="Socials";var Q3=({onSelect:e,isCollaborating:o})=>{let{t}=Ge();return je(pt,{"data-testid":"collab-button",icon:cs,className:qN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};Q3.displayName="LiveCollaborationTrigger";import{jsx as Nd,jsxs as Dg}from"react/jsx-runtime";var eB=Object.assign(Zo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ce(),n=de(),r=be(),i=ae(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return Nd(t.In,{children:Dg(xe,{open:r.openMenu==="canvas",children:[Nd(xe.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:is}),Dg(xe.Content,{onClickOutside:a,onSelect:QN(o,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&Dg("fieldset",{className:"UserList-Wrapper",children:[Nd("legend",{children:g("labels.collaborators")}),Nd(Dd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:xe.Trigger,Item:xe.Item,ItemLink:xe.ItemLink,ItemCustom:xe.ItemCustom,Group:xe.Group,Separator:xe.Separator,DefaultItems:Ag}),mt=eB;import tB from"clsx";import{forwardRef as oB,useState as nB}from"react";import{isPromiseLike as rB}from"@excalidraw/common";import{jsx as Bd,jsxs as iB}from"react/jsx-runtime";var Sn=oB(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},d)=>{let[c,p]=nB(!1),u=async b=>{let x=t?.(b);if(rB(x)){let y=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Tr)console.warn(E);else throw E}finally{clearTimeout(y),p(!1)}}},f=c?"loading":m;return i=f==="success"?"success":i,Bd("button",{className:tB("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":n,ref:d,disabled:f==="loading"||f==="success",children:iB("div",{className:"ExcButton__contents",children:[f==="loading"?Bd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&Bd("div",{className:"ExcButton__statusIcon",children:ib}),o&&Bd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as Oi,jsxs as sB}from"react/jsx-runtime";var Fd=({title:e,children:o,actionLabel:t,onClick:n})=>sB("div",{className:"OverwriteConfirm__Actions__Action",children:[Oi("h4",{children:e}),Oi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Oi(Sn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),aB=()=>{let{t:e}=Ge(),o=We(),t=ae();return Oi(Fd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(rc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},lB=()=>{let{t:e}=Ge(),o=We();return Oi(Fd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(za,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},_g=Object.assign(({children:e})=>Oi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:aB,SaveToDisk:lB});import{jsx as kn,jsxs as tT}from"react/jsx-runtime";var Od=Object.assign(Zo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ce(),[t,n]=le(Pg);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return kn(o.In,{children:kn(Oe,{onCloseRequest:r,title:!1,size:916,children:tT("div",{className:"OverwriteConfirm",children:[kn("h3",{children:t.title}),tT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[kn("div",{className:"OverwriteConfirm__Description__icon",children:ab}),kn("div",{children:t.description}),kn("div",{className:"OverwriteConfirm__Description__spacer"}),kn(Sn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),kn(_g,{children:e})]})})})}),{Actions:_g,Action:Fd});import LB from"clsx";import{CANVAS_SEARCH_TAB as Og,DEFAULT_SIDEBAR as AB,LIBRARY_SIDEBAR_TAB as mT,composeEventHandlers as DB}from"@excalidraw/common";import{round as cB}from"@excalidraw/math";import dB from"clsx";import mB from"lodash.debounce";import{Fragment as pB,memo as uB,useEffect as fl,useMemo as oT,useRef as Rg,useState as nT}from"react";import{CLASSES as hB,EVENT as gB,FONT_FAMILY as Ng,FRAME_STYLE as Bg,getLineHeight as fB}from"@excalidraw/common";import{isElementCompletelyInViewport as bB}from"@excalidraw/element";import{measureText as bl}from"@excalidraw/element";import{KEYS as zi,randomInteger as rT,addEventListener as xB,getFontString as zd}from"@excalidraw/common";import{newTextElement as EB}from"@excalidraw/element";import{isTextElement as sT,isFrameLikeElement as Hd}from"@excalidraw/element";import{getDefaultFrameName as cT}from"@excalidraw/element/frame";import{Fragment as PB,jsx as Je,jsxs as So}from"react/jsx-runtime";var yB=he(""),Fg=he(null),wB=350,dT=()=>{let e=Be(),o=ae(),t=Rg(null),[n,r]=le(yB),i=n.trim(),[a,l]=nT(!1),[s,m]=nT({nonce:null,items:[]}),d=Rg(null),c=Rg(void 0),[p,u]=le(Fg),f=e.scene.getNonDeletedElementsMap();fl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==c.current)&&(d.current=null,lT(i,e,(w,v)=>{m({nonce:rT(),items:w}),d.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:w.length?{focusedId:null,matches:w.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(w=>w===null?0:(w+1)%s.items.length)},x=()=>{s.items.length>0&&u(w=>w===null?0:w-1<0?s.items.length-1:w-1)};fl(()=>{o(w=>w.searchMatches?{searchMatches:{focusedId:p!==null&&w.searchMatches?.matches[p]?.id||null,matches:w.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),fl(()=>{if(s.items.length>0&&p!==null){let w=s.items[p];if(w){let v=e.state.zoom.value,C=EB({text:w.searchQuery,x:w.element.x+(w.matchedLines[0]?.offsetX??0),y:w.element.y+(w.matchedLines[0]?.offsetY??0),width:w.matchedLines[0]?.width,height:w.matchedLines[0]?.height,fontSize:Hd(w.element)?Bg.nameFontSize:w.element.fontSize,fontFamily:Hd(w.element)?Ng.Assistant:w.element.fontFamily}),S=14,L=C.fontSize,P=L*v<S;if(!bB([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())||P){let B;P?L>=S?B={fitToContent:!0}:B={fitToViewport:!0,maxZoom:cB(S/L,1)}:B={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...B,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),fl(()=>()=>{u(null),d.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let y=on({goToNextItem:b,goToPreviousItem:x,searchMatches:s});fl(()=>{let w=v=>{if(v.key===zi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[zi.CTRL_OR_CMD]&&v.key===zi.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")&&y.searchMatches.items.length&&(v.key===zi.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===zi.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===zi.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return xB(window,gB.KEYDOWN,w,{capture:!0,passive:!1})},[o,y,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return So("div",{className:"layer-ui__search",children:[Je("div",{className:"layer-ui__search-header",children:Je(Ci,{className:hB.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Pt,onChange:w=>{r(w),l(!0);let v=w.trim();lT(v,e,(C,S)=>{m({nonce:rT(),items:C}),u(S),d.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})}),So("div",{className:"layer-ui__search-count",children:[s.items.length>0&&So(PB,{children:[p!==null&&p>-1?So("div",{children:[p+1," / ",E]}):Je("div",{children:E}),So("div",{className:"result-nav",children:[Je(Nt,{onSelect:()=>{b()},className:"result-nav-btn",children:fs}),Je(Nt,{onSelect:()=>{x()},className:"result-nav-btn",children:Pb})]})]}),s.items.length===0&&i&&d.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(IB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},iT=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:dB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Je("div",{className:"preview-text",children:o.flatMap((t,n)=>Je(pB,{children:n===2?Je("b",{children:t}):t},n))})})},vB=e=>{let o=oT(()=>e.matches.items.filter(n=>Hd(n.element)),[e.matches]),t=oT(()=>e.matches.items.filter(n=>sT(n.element)),[e.matches]);return So("div",{children:[o.length>0&&So("div",{className:"layer-ui__search-result-container",children:[So("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Zn}),Je("div",{children:g("search.frames")})]}),o.map((n,r)=>Je(iT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&Je("div",{className:"layer-ui__divider"})]}),t.length>0&&So("div",{className:"layer-ui__search-result-container",children:[So("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Ar}),Je("div",{children:g("search.texts")})]}),t.map((n,r)=>Je(iT,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},TB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,IB=uB(vB,TB),aT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),d=20;m=m.length>d?m.slice(-d):m;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:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},CB=(e,o)=>{let t=e.split(`
17
+ `),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,r);if(s>a.length+r){let m=s-(a.length+r);for(;m>0;)a+=" ",m--}}n.push(a),r=r+a.length}return n.join(`
18
+ `)},SB=(e,o,t)=>{let r=CB(e.text,e.originalText).split(`
19
+ `),i=[],a=0,l=0;for(let c of r){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),d=[];for(let c of i){if(m==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=m.slice(0,p);m=m.slice(p);let b=bl(u,zd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=bl(c.line,zd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:y}=bl(f,zd(e),e.lineHeight),E=b.width,w=c.lineNumber*b.height;d.push({offsetX:E,offsetY:w,width:x,height:y,showOnCanvas:!0}),s+=p}}return d},kB=(e,o,t,n)=>{let r=e.name??cT(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=zd({fontSize:Bg.nameFontSize,fontFamily:Ng.Assistant}),s=fB(Ng.Assistant),m=bl(a,l,s);a===""&&(m.width=0);let d=bl(i,l,s),c=m.width,p=-m.height-Bg.strokeWidth,u=d.width;return[{offsetX:c,offsetY:p,width:u,height:d.height,showOnCanvas:c+u<=e.width*n}]},MB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),lT=mB((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(p=>sT(p)),i=n.filter(p=>Hd(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(MB(e),"gi");for(let p of r){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=aT(f,u.index,e),x=SB(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??cT(p);for(;(u=l.exec(f))!==null;){let b=aT(f,u.index,e),x=kB(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let m=new Set(o.visibleElements.map(p=>p.id)),d=[...s,...a],c=d.findIndex(p=>m.has(p.element.id))??null;t(d,c)},wB);import{jsx as co,jsxs as pT}from"react/jsx-runtime";import{createElement as _B}from"react";var uT=Zo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ce();return co(o.In,{children:co($t.Trigger,{...e,className:"default-sidebar-trigger",name:AB.name})})});uT.displayName="DefaultSidebarTrigger";var hT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ce();return co(o.In,{children:e})};hT.displayName="DefaultTabTriggers";var Gd=Object.assign(Zo("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=be(),a=ae(),{DefaultSidebarTabTriggersTunnel:l}=Ce(),s=i.openSidebar?.tab===Og;return _B($t,{...r,name:"default",key:"default",className:LB("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:DB(t,m=>{a({defaultSidebarDockedPreference:m})})},pT($t.Tabs,{children:[co($t.Header,{children:pT($t.TabTriggers,{children:[co($t.TabTrigger,{tab:Og,children:Pt}),co($t.TabTrigger,{tab:mT,children:Pr}),co(l.Out,{})]})}),co($t.Tab,{tab:mT,children:co(L2,{})}),co($t.Tab,{tab:Og,children:co(dT,{})}),e]}))}),{Trigger:uT,TabTriggers:hT});import{useEffect as QB,useRef as Gg,useState as qd}from"react";import{isFiniteNumber as BT}from"@excalidraw/math";import{useState as vT,useRef as TT,useEffect as IT,useDeferredValue as UB}from"react";import{EDITOR_LS_KEYS as YB,debounce as WB,isDevEnv as VB}from"@excalidraw/common";import{useEffect as RB,useRef as gT}from"react";import{EVENT as fT,KEYS as bT}from"@excalidraw/common";import{jsx as NB}from"react/jsx-runtime";var Ud=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n})=>{let r=gT(null),i=gT(n);return i.current=n,RB(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[bT.CTRL_OR_CMD]&&s.key===bT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(fT.KEYDOWN,l),()=>{a.removeEventListener(fT.KEYDOWN,l)}}},[]),NB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:r})};import{jsx as Yd,jsxs as xT}from"react/jsx-runtime";var BB=({error:e})=>xT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Yd("p",{children:e})]}),Wd=({error:e,canvasRef:o,loaded:t})=>xT("div",{className:"ttd-dialog-output-wrapper",children:[e&&Yd(BB,{error:e.message}),t?Yd("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Yd(tt,{size:"2rem"})]});import ET from"clsx";import{jsx as zg,jsxs as xl}from"react/jsx-runtime";var Hi=({label:e,children:o,panelAction:t,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>xl("div",{className:"ttd-dialog-panel",children:[xl("div",{className:"ttd-dialog-panel__header",children:[zg("label",{children:e}),i?.()]}),o,xl("div",{className:ET("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[xl(Nt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:n||r,children:[xl("div",{className:ET({invisible:r}),children:[t?.label,t?.icon&&zg("span",{children:t.icon})]}),r&&zg(tt,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as FB}from"react/jsx-runtime";var Vd=({children:e})=>FB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as yT}from"@excalidraw/common";import{jsx as wT,jsxs as OB}from"react/jsx-runtime";var Xd=()=>OB("div",{className:"ttd-dialog-submit-shortcut",children:[wT("div",{className:"ttd-dialog-submit-shortcut__key",children:yT("CtrlOrCmd")}),wT("div",{className:"ttd-dialog-submit-shortcut__key",children:yT("Enter")})]});import{DEFAULT_EXPORT_PADDING as zB,EDITOR_LS_KEYS as HB}from"@excalidraw/common";var GB=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},Kd=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){GB({canvasRef:e,setError:n});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:d}=s;n(null),r.current={elements:Ni(m,{regenerateIds:!0}),files:d};let c=await gn({elements:r.current.elements,files:r.current.files,exportPadding:zB,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Ao(c)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(c)}catch(l){throw a.style.background="var(--default-bg-color)",t&&n(l),l}}},El=e=>{Wt.set(HB.MERMAID_TO_EXCALIDRAW,e)},Zd=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&El(t))};import{Fragment as ZB,jsx as ko,jsxs as ST}from"react/jsx-runtime";var XB=`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=Wn(hs,300),RM=({mermaidToExcalidrawLib:e})=>{let[o,t]=E3(()=>Ro.get(tn.MERMAID_TO_EXCALIDRAW)||PM),r=DM(o.trim()),[n,i]=E3(null),a=y3(null),l=y3({elements:[],files:null}),s=lt();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(NM,{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=RM;import*as S3 from"@radix-ui/react-tabs";import{useRef as I3}from"react";import{jsx as OM}from"react/jsx-runtime";var k3=e=>{let o=Ie(),t=I3(null),r=I3(0);return OM(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"&&js(["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 BM}from"react/jsx-runtime";var Zg=({children:e,...o})=>BM(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 zM}from"react/jsx-runtime";var Km=({tab:e,children:o,...t})=>zM(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,HM=_e(null),UM=_e(null),jg=e=>{let o=Pe();return o.openDialog?.name!=="ttd"?null:$t(GM,{...e,tab:o.openDialog.tab})},GM=Zr("TTDDialogBase",({tab:e,...o})=>{let t=lt(),r=Ie(),n=Xg(null),[i,a]=ve(UM),[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(HM),b=async()=>{if(c.length>Ya||c.length<$g||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<$g&&C(new Error(`Prompt is too short (min ${$g} characters)`)),c.length>Ya&&C(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}),_){C(_);return}if(!S){C(new Error("Generation failed"));return}try{await Vm({canvasRef:n,data:y,mermaidToExcalidrawLib:E,setError:C,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"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let _=S.message;(!_||_==="Failed to fetch")&&(_="Request failed"),C(new Error(_))}finally{p(!1)}},x=Xg(b);x.current=b;let[E,w]=Zm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});FM(()=>{(async()=>{await E.api,w(_=>({..._,loaded:!0}))})()},[E.api]);let y=Xg({elements:[],files:null}),[v,C]=Zm(null);return $t(ct,{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"&&(hs(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 DL from"clsx";import PL from"lodash.throttle";import{useEffect as K3,useMemo as of,useState as RL,memo as NL}from"react";import VM from"clsx";import{useEffect as R3,useRef as $m,useState as YM}from"react";var P3=.01,co=(e,o)=>!(o==="height"&&Z(e)||o==="width"&&Z(e)||o==="angle"&&ie(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 ki=(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]=se(M(t.x,t.y),M(c,m),t.angle),u=e-d,g=o-p,[b,x]=se(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)=>{ce(e)?ei([e],o,t,r,!0,[],n?.zoom):at(e,o,n)};import{jsx as qg,jsxs as KM}from"react/jsx-runtime";var WM=({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=lt(),p=$m(null),u=$m(null),[g,b]=YM(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,C)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let S=Number(y);if(isNaN(S)){b(r.toString());return}let _=Number(S.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(_-L)>=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:C,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 C=y?.value;C&&v.handleInputValue?.(C,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?KM("div",{className:VM("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 C=null,S=d.scene.getNonDeletedElements().reduce((V,q)=>(V.set(q.id,io(q)),V),new Map),_=n.map(V=>S.get(V.id)),L=oo(c),N=0,P=0,U=V=>{if(C&&S!==null&&_!==null){let q=V.clientX-C.x;q!==0&&(P+=q,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),N+=P,t({accumulatedChange:N,instantChange:P,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:V.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:F=>b(String(F))}),P=0))}C={x:V.clientX,y:V.clientY}},W=()=>{window.removeEventListener("pointermove",U,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),C=null,N=0,P=0,_=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",W,!1)};w.current.onPointerMove=U,w.current.onPointerUp=W,window.addEventListener("pointermove",U,!1),window.addEventListener("pointerup",W,!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=WM;import{jsx as jM}from"react/jsx-runtime";var ZM=15,XM=({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,ZM)),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})}},$M=({element:e,scene:o,appState:t,property:r})=>jM(It,{label:"A",icon:td,value:Math.round(Di(e.angle)%360*100)/100,elements:[e],dragInputCallback:XM,editable:co(e,"angle"),scene:o,appState:t,property:r}),N3=$M;import{jsx as JM}from"react/jsx-runtime";var O3=5,qM=({property:e,scene:o,appState:t,setAppState:r})=>JM(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=qM;import{jsx as oL}from"react/jsx-runtime";var z3=10,QM=e=>e.type==="image",eL=({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||QM(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,C={...v},S=y.scale[0]===-1,_=y.scale[1]===-1,{width:L,height:N}=ni(y),P=v.naturalWidth/L,U=v.naturalHeight/N,W=S?v.width+v.x:v.naturalWidth-v.x,V=_?v.height+v.y:v.naturalHeight-v.y,q=Wp*P,F=Wp*U;if(i!==void 0){if(a==="width"){let le=i*P,be=Tt(le,q,W);C={...C,width:be,x:S?v.x+v.width-be:v.x}}else if(a==="height"){let le=i*U,be=Tt(le,F,V);C={...C,height:be,y:_?v.y+v.height-be:v.y}}B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}let z=a==="width"?s:0,G=a==="height"?s:0,ne=Tt(v.width+z,q,W),X=Tt(v.height+G,q,V);C={...v,x:S?v.x+v.width-ne:v.x,y:_?v.y+v.height-X:v.y,width:ne,height:X},B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*g:d.width,to),v=Math.max(a==="height"?i:u?i/g:d.height,to);mi(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),mi(E,w,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},tL=({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}=ni(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 oL(It,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:eL,value:n,editable:co(o,e),scene:t,appState:r,property:e})},Jg=tL;import{jsx as aL}from"react/jsx-runtime";var F3=4,rL=4,nL=({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,rL))}s&&(B(l,{fontSize:s}),Qe(l,n.getContainerElement(l),n.getNonDeletedElementsMap()))}},iL=({element:e,scene:o,appState:t,property:r})=>{let n=Z(e)?e:mt(e)?ge(e,o.getNonDeletedElementsMap()):null;return n?aL(It,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:nL,icon:hi,appState:t,scene:o,property:r}):null},H3=iL;import{jsx as dL}from"react/jsx-runtime";var lL=15,sL=({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)&&co(c,n)),s=o.filter(c=>!sr(c)&&co(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,lL)),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()},cL=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!sr(s)&&co(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=>co(s,"angle"));return dL(It,{label:"A",icon:td,value:a,elements:e,dragInputCallback:sL,editable:l,appState:t,scene:o,property:r})},U3=cL;import{useMemo as mL}from"react";import{jsx as fL}from"react/jsx-runtime";var Za=10,pL=(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}:{}}},uL=(e,o,t,r,n,i,a,l)=>{let s=pL(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),ul(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];uL(n[0],n[1],i,m,u,p,s,c)}},hL=({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,C=y-E,S=v/C,_=Math.max(to,l==="width"?Math.max(0,i):v),L=Math.max(to,l==="height"?Math.max(0,i):C);G3(_,L,C,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&co(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),mi(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,C=y-E,S=v/C,_=Math.max(0,v+m);l==="width"&&(n?_=je(_,Za):_=Math.round(_));let L=Math.max(0,C+d);l==="height"&&(n?L=je(L,Za):L=Math.round(L)),_=Math.max(to,_),L=Math.max(to,L),G3(_,L,C,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&co(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),mi(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},gL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=mL(()=>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 fL(It,{label:e==="width"?"W":"H",elements:o,dragInputCallback:hL,value:l,editable:s,appState:i,property:e,scene:n})},Qg=gL;import{jsx as vL}from"react/jsx-runtime";var V3=4,bL=4,xL=(e,o)=>e.reduce((t,r)=>{if(!r||sr(r))return t;if(Z(r))return t.push(r),t;if(mt(r)){let n=ge(r,o);if(n)return t.push(n),t}return t},[]),EL=({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,bL)),B(m,{fontSize:g},!1),Qe(m,n.getContainerElement(m),i,!1)}n.triggerUpdate()}},yL=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=xL(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 vL(It,{label:"F",icon:hi,elements:i,dragInputCallback:EL,value:l,editable:s,scene:o,property:r,appState:t})},Y3=yL;import{useMemo as wL}from"react";import{jsx as ML}from"react/jsx-runtime";var TL=10,CL=(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]=se(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;ki(g,b,c,i,r,l,a,!1)}},IL=(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]=se(M(u.x,u.y),M(g,b),u.angle);ki(x+c,E+m,p,r,n,a,i,!1)}}},SL=({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));IL(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&&co(x,i)){let[E,w]=[b.x+b.width/2,b.y+b.height/2],[y,v]=se(M(b.x,b.y),M(E,w),b.angle);ki(i==="x"?n:y,i==="y"?n:v,b,s,c,a,t,!1)}}}a.triggerUpdate();return}let m=r?je(e,TL):e;CL(i,i==="x"?m:0,i==="y"?m:0,o,o,s,t,a),a.triggerUpdate()},kL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=wL(()=>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]=se(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 ML(It,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:SL,value:l,property:e,scene:n,appState:i})},ef=kL;import{jsx as _L}from"react/jsx-runtime";var W3=10,LL=({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]=se(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 C=v.crop,S=C,_=v.scale[0]===-1,L=v.scale[1]===-1,{width:N,height:P}=ni(v);if(i!==void 0){if(a==="x"){let V=i*(C.naturalWidth/N);_?S={...C,x:Tt(C.naturalWidth-V-C.width,0,C.naturalWidth-C.width)}:S={...C,x:Tt(i*(C.naturalWidth/N),0,C.naturalWidth-C.width)}}a==="y"&&(S={...C,y:Tt(i*(C.naturalHeight/P),0,C.naturalHeight-C.height)}),B(v,{crop:S});return}let U=(a==="x"?o:0)*(_?-1:1),W=(a==="y"?o:0)*(L?-1:1);S={...C,x:Tt(C.x+U,0,C.naturalWidth-C.width),y:Tt(C.y+W,0,C.naturalHeight-C.height)},B(v,{crop:S});return}if(i!==void 0){ki(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;ki(w,y,d,c,m,l,r)},AL=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=se(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 _L(It,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:LL,scene:r,value:l,property:e,appState:n})},tf=AL;import{Fragment as rf,jsx as ae,jsxs as mo}from"react/jsx-runtime";var OL=50,gs=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 ae(BL,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Xe=({children:e,columns:o=1,heading:t,style:r,...n})=>ae("div",{className:DL("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Xe.displayName="StatsRow";var jm=({children:e,order:o,style:t,...r})=>ae("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});jm.displayName="StatsRows";gs.StatsRow=Xe;gs.StatsRows=jm;var BL=NL(({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?ni(d):null,[b,x]=RL({width:0,height:0}),E=of(()=>PL(v=>{let C=ye(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},OL),[]);K3(()=>{E(s)},[i,s,E]),K3(()=>()=>E.cancel(),[E]);let w=of(()=>Ka(r,n),[r,n]),y=of(()=>uc(r),[r]);return ae("div",{className:"exc-stats",children:mo(yt,{padding:3,children:[mo("div",{className:"title",children:[ae("h2",{children:f("stats.title")}),ae("div",{className:"close",onClick:o,children:Lo})]}),mo(Kl,{label:ae("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&il.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.generalStats}})),children:[mo(jm,{children:[ae(Xe,{heading:!0,children:f("stats.scene")}),mo(Xe,{columns:2,children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:s.length})]}),mo(Xe,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:b.width})]}),mo(Xe,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:b.height})]}),a&&mo(rf,{children:[ae(Xe,{heading:!0,children:"Canvas"}),ae(Xe,{children:ae(B3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&ae("div",{id:"elementStats",style:{marginTop:12},children:ae(Kl,{label:ae("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&il.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.elementProperties}})),children:mo(jm,{children:[d&&mo(rf,{children:[u&&ae(Xe,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&he(d)&&g&&mo(Xe,{columns:2,children:[ae("div",{children:f("stats.width")}),ae("div",{children:So(g.width,2)})]}),n.croppingElementId&&he(d)&&g&&mo(Xe,{columns:2,children:[ae("div",{children:f("stats.height")}),ae("div",{children:So(g.height,2)})]}),ae(Xe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),ae(Xe,{children:ae(tf,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),ae(Xe,{children:ae(tf,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),ae(Xe,{children:ae(Jg,{property:"width",element:d,scene:l,appState:n})}),ae(Xe,{children:ae(Jg,{property:"height",element:d,scene:l,appState:n})}),!te(d)&&ae(Xe,{children:ae(N3,{property:"angle",element:d,scene:l,appState:n})}),ae(Xe,{children:ae(H3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&mo(rf,{children:[Bb(p)&&ae(Xe,{heading:!0,children:f("element.group")}),mo(Xe,{columns:2,style:{margin:"0.3125rem 0"},children:[ae("div",{children:f("stats.shapes")}),ae("div",{children:r.length})]}),ae(Xe,{children:ae(ef,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Xe,{children:ae(ef,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Xe,{children:ae(Qg,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Xe,{children:ae(Qg,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),ae(Xe,{children:ae(U3,{property:"angle",elements:p,scene:l,appState:n})}),ae(Xe,{children:ae(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 zL,useEffect as Z3,useState as X3}from"react";import{jsx as Xa,jsxs as qm}from"react/jsx-runtime";var FL=({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=zL(()=>{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=FL;import HL,{useState as UL}from"react";import{Fragment as GL,jsx as nf}from"react/jsx-runtime";var j3=({children:e,onClose:o})=>{let[t,r]=UL(!!e),{container:n}=gt(),i=HL.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return nf(GL,{children:t&&nf(ct,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:nf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import VL from"react";import{Fragment as J3,jsx as Y,jsxs as To}from"react/jsx-runtime";var YL=()=>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"]})]}),WL=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*KL(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var ZL=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>Y(XL,{children:ZL(a)},a)));return To("div",{className:"HelpDialog__shortcut",children:[Y("div",{children:e}),Y("div",{className:"HelpDialog__key-container",children:[...KL(r,t?f("helpDialog.or"):null)]})]})},XL=e=>Y("kbd",{className:"HelpDialog__key",...e}),q3=({onClose:e})=>{let o=VL.useCallback(()=>{e&&e()},[e]);return Y(J3,{children:To(ct,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",children:[Y(YL,{}),To(WL,{title:f("helpDialog.shortcuts"),children:[To(af,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Y($,{label:f("toolBar.hand"),shortcuts:[T.H]}),Y($,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),Y($,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),Y($,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),Y($,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),Y($,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),Y($,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),Y($,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),Y($,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),Y($,{label:f("toolBar.image"),shortcuts:[T[9]]}),Y($,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),Y($,{label:f("toolBar.frame"),shortcuts:[T.F]}),Y($,{label:f("toolBar.laser"),shortcuts:[T.K]}),Y($,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),Y($,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),Y($,{label:f("helpDialog.editText"),shortcuts:[R("Enter")]}),Y($,{label:f("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),Y($,{label:f("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),Y($,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y($,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y($,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),R("Enter")],isOr:!0}),Y($,{label:f("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),Y($,{label:f("toolBar.lock"),shortcuts:[T.Q]}),Y($,{label:f("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),Y($,{label:f("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),To(af,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Y($,{label:f("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),Y($,{label:f("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),Y($,{label:f("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),Y($,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),Y($,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),Y($,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Y($,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Y($,{label:f("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),Y($,{label:f("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),Y($,{label:f("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),Y($,{label:f("labels.viewMode"),shortcuts:[R("Alt+R")]}),Y($,{label:f("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),Y($,{label:f("stats.fullTitle"),shortcuts:[R("Alt+/")]}),Y($,{label:f("search.title"),shortcuts:[st("searchMenu")]}),Y($,{label:f("commandPalette.title"),shortcuts:Cr?[st("commandPalette")]:[st("commandPalette"),st("commandPalette",1)]})]}),To(af,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Y($,{label:f("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),Y($,{label:f("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),Y($,{label:f("labels.moveCanvas"),shortcuts:[R(`Space+${f("helpDialog.drag")}`),R(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Y($,{label:f("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),Y($,{label:f("labels.delete"),shortcuts:[R("Delete")]}),Y($,{label:f("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),Y($,{label:f("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),Y($,{label:f("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),Y($,{label:f("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),Y($,{label:f("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),Y($,{label:f("labels.multiSelect"),shortcuts:[R(`Shift+${f("helpDialog.click")}`)]}),Y($,{label:f("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Y($,{label:f("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(va||Cr)&&Y($,{label:f("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),Y($,{label:f("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),Y($,{label:f("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),Y($,{label:f("labels.sendToBack"),shortcuts:[Uo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),Y($,{label:f("labels.bringToFront"),shortcuts:[Uo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),Y($,{label:f("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),Y($,{label:f("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),Y($,{label:f("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),Y($,{label:f("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),Y($,{label:f("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),Y($,{label:f("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),Y($,{label:f("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)]}),Y($,{label:f("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),Y($,{label:f("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),Y($,{label:f("buttons.redo"),shortcuts:As?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),Y($,{label:f("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),Y($,{label:f("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),Y($,{label:f("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),Y($,{label:f("labels.flipVertical"),shortcuts:[R("Shift+V")]}),Y($,{label:f("labels.showStroke"),shortcuts:[R("S")]}),Y($,{label:f("labels.showBackground"),shortcuts:[R("G")]}),Y($,{label:f("labels.showFonts"),shortcuts:[R("Shift+F")]}),Y($,{label:f("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),Y($,{label:f("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as t5,useRef as e8,useState as Pn}from"react";import{useCallback as $L,useRef as jL,useState as qL}from"react";var JL=2e3,Q3=()=>{let[e,o]=qL(null),t=jL(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},JL)},n=$L(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import QL from"clsx";import{jsx as e5}from"react/jsx-runtime";var fs=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>e5("div",{className:QL("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 $e,jsxs as Rn}from"react/jsx-runtime";var t8="filter"in document.createElement("canvas").getContext("2d"),o8=()=>Rn("div",{children:[$e("h3",{children:f("canvasError.cannotShowPreview")}),$e("p",{children:$e("span",{children:f("canvasError.canvasTooBig")})}),Rn("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),r8=({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=e8(null),[v,C]=Pn(null),{onCopy:S,copyStatus:_,resetCopyStatus:L}=Q3();t5(()=>{L()},[l,d,u,E,b,L]);let{exportedElements:N,exportingFrame:P}=Ei(o,e,c);return t5(()=>{let U=y.current;if(!U)return;let W=U.offsetWidth,V=U.offsetHeight;W&&Tn({elements:N,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:en,maxWidthOrHeight:Math.max(W,V),exportingFrame:P}).then(q=>(C(null),Nr(q).then(()=>{U.replaceChildren(q)}).catch(F=>{throw F.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):F}))).catch(q=>{console.error(q),C(q)})},[e,t,N,P,l,d,u,E,b]),Rn("div",{className:"ImageExportModal",children:[$e("h3",{children:f("imageExportDialog.header")}),Rn("div",{className:"ImageExportModal__preview",children:[$e("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&$e(o8,{})}),$e("div",{className:"ImageExportModal__preview__filename",children:!Qi&&$e("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:U=>{s(U.target.value),r.executeAction(wh,"ui",U.target.value)}})})]}),Rn("div",{className:"ImageExportModal__settings",children:[$e("h3",{children:f("imageExportDialog.header")}),a&&$e(bs,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:$e(fs,{name:"exportOnlySelected",checked:c,onChange:U=>{m(U)}})}),$e(bs,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:$e(fs,{name:"exportBackgroundSwitch",checked:d,onChange:U=>{p(U),r.executeAction(Th,"ui",U)}})}),t8&&$e(bs,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:$e(fs,{name:"exportDarkModeSwitch",checked:u,onChange:U=>{g(U),r.executeAction(t2,"ui",U)}})}),$e(bs,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:$e(fs,{name:"exportEmbedSwitch",checked:b,onChange:U=>{x(U),r.executeAction(Od,"ui",U)}})}),$e(bs,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:$e(Dm,{name:"exportScale",value:E,onChange:U=>{w(U),r.executeAction(e2,"ui",U)},choices:Fs.map(U=>({value:U,label:`${U}\xD7`}))})}),Rn("div",{className:"ImageExportModal__settings__buttons",children:[$e(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(Os.png,N,{exportingFrame:P}),icon:zu,children:f("imageExportDialog.button.exportToPng")}),$e(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(Os.svg,N,{exportingFrame:P}),icon:zu,children:f("imageExportDialog.button.exportToSvg")}),(va||Cr)&&$e(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:_,onClick:async()=>{await n(Os.clipboard,N,{exportingFrame:P}),S()},icon:ca,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},bs=({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&&$e(bo,{label:t,long:!0,children:lE})]}),$e("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 $e(ct,{onCloseRequest:i,size:"wide",title:!1,children:$e(r8,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import i8 from"react";import lf from"open-color";import{jsx as n8}from"react/jsx-runtime";var sf=({children:e,color:o})=>n8("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 l8,jsx as tr,jsxs as Jm}from"react/jsx-runtime";var a8=({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(ql,"ui")}})]}),s&&Jm(sf,{color:"pink",children:[tr("div",{className:"Card-icon",children:Rl}),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=i8.useCallback(()=>{a({openDialog:null})},[a]);return tr(l8,{children:o.openDialog?.name==="jsonExport"&&tr(ct,{onCloseRequest:l,title:f("buttons.export"),children:tr(a8,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import s8 from"clsx";import{jsx as n5,jsxs as d8}from"react/jsx-runtime";var c8="small",i5=e=>d8("label",{className:s8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${c8}`,{"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:Bl})]});import{Fragment as l5,jsx as re,jsxs as Co}from"react/jsx-runtime";var p8=({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,{})]}),u8=()=>Co(Om,{__fallback:!0,children:[re(Om.Actions.SaveToDisk,{}),re(Om.Actions.ExportToImage,{})]}),h8=({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(),C=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,{})]}),U=()=>re(Mn,{heading:"selectedShapeActions",className:xs("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})})}),W=()=>{let z=Ta(o,n),G=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:xs("App-menu_top__left"),children:[P(),z&&U()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&re(Mn,{heading:"shapes",className:"shapes-section",children:ne=>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:xs("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Co(yt,{padding:1,className:xs("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[re(Im,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),ne,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:xs("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,{}),G&&re(gs,{app:x,onClose:()=>{e.executeAction(La)},renderCustomStats:d})]})]})})},V=()=>re(Bm,{__fallback:!0,onDock:z=>{xe("sidebar",`toggleDock (${z?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),q=Gc(ds),F=Co(l5,{children:[b,re(p8,{UIOptions:p}),re(Bm.Trigger,{__fallback:!0,icon:ia,title:on(f("toolBar.library")),onToggle:z=>{z&&xe("sidebar",`${At.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:At.defaultTab,children:f("toolBar.library")}),re(u8,{}),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:(z,G,ne,{altKey:X})=>{if(!(z!=="elementBackground"&&z!=="elementStroke"))if(ne.length){for(let le of ne)B(le,{[X&&S.swapPreviewOnAlt?z==="elementBackground"?"strokeColor":"backgroundColor":z==="elementBackground"?"backgroundColor":"strokeColor"]:G},!1),pn.delete(le);dn.getScene(ne[0])?.triggerUpdate()}else r(z==="elementBackground"?{currentItemBackgroundColor:G}:{currentItemStrokeColor:G})},onSelect:(z,G)=>{_(ne=>ne?.keepOpenOnAlt&&G.altKey?ne:null),S?.onSelect?.(z,G)}}),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:V,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,{}),W(),re(Aw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),o.scrolledOutside&&re("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(z=>({...li(n,z)}))},children:f("buttons.scrollBackToContent")})]}),V()]})]});return re(qu.Provider,{value:o,children:re(C,{children:re(ng.Provider,{value:v,children:F})})})},a5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},g8=(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=m8.memo(h8,g8);import f8 from"clsx";import{jsx as c5,jsxs as x8}from"react/jsx-runtime";var b8="small",Qm=e=>x8("label",{className:f8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${b8}`,{"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 E8,useRef as y8}from"react";import{jsx as d5}from"react/jsx-runtime";var m5=({trails:e})=>{let o=y8(null);return E8(()=>{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 v8,{useEffect as w8,useRef as T8}from"react";import{jsx as S8}from"react/jsx-runtime";var C8=e=>{let o=T8(!1);return w8(()=>{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())}),S8("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}),I8=(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=v8.memo(C8,I8);import k8,{useEffect as M8,useRef as u5}from"react";import{jsx as _8}from"react/jsx-runtime";var L8=e=>{let o=u5(null),t=u5(!1);return M8(()=>{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())}),_8("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}),A8=(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=k8.memo(L8,A8);import{useEffect as P8,useRef as R8}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)}},D8=Pi(e=>{g5(e)},{trailing:!0}),f5=(e,o)=>{if(o){D8(e);return}g5(e)};import{jsx as O8}from"react/jsx-runtime";var N8=e=>{let o=R8(null);return P8(()=>{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())}),O8("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=N8;import{useCallback as B8,useEffect as z8,useRef as F8}from"react";import{jsx as x5,jsxs as U8}from"react/jsx-runtime";var H8=5e3,E5=({message:e,onClose:o,closable:t=!1,duration:r=H8,style:n})=>{let i=F8(0),a=r!==1/0,l=B8(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return z8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),U8("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 K8,jsx as Oe,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 lt=()=>Bn(T5),hr=()=>Bn(C5),Ce=()=>Bn(ff),gt=()=>Bn(bf),xn=()=>Bn(xf),ur=()=>Bn(Ef),Ie=()=>Bn(yf),ft=()=>Bn(vf),Es=!1,mf=0,Mi=!1,ys=!1,pf=!1,uf={horizontal:null,vertical:null},On=0,vs=!1,hf=new Map,ep=!1,v5=0,w5=!1,ws=null,Ae={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},gf=class e extends Tr.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",I5);I(this,"excalidrawContainerRef",Tr.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new Hc);I(this,"flowChartNavigator",new Fc);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 um);I(this,"laserTrails",new bm(this.animationFrameHandler,this));I(this,"eraserTrail",new ym(this.animationFrameHandler,this));I(this,"lassoTrail",new Em(this.animationFrameHandler,this));I(this,"onChangeEmitter",new Pt);I(this,"onPointerDownEmitter",new Pt);I(this,"onPointerUpEmitter",new Pt);I(this,"onUserFollowEmitter",new Pt);I(this,"onScrollChangeEmitter",new Pt);I(this,"missingPointerEventCleanupEmitter",new Pt);I(this,"onRemoveEventListenersEmitter",new Pt);I(this,"getEffectiveGridSize",()=>Sn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),pn.delete(t)});I(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 $n(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=Ye({clientX:i.x,clientY:i.y},this.state),l=Ye({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&B(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===de.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!xl(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=Ib(r);if(r.id===this.state.editingFrame){let c=s;l=Oe("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 Oe("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?Un.disabled:Un.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:l},r.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{xe("export",t,"ui");let i=await yi(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Xs).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Dc(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?B(t,{customData:{generationData:void 0}},!1):B(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:it.magicframe}),xe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&ec(t[0])&&t[0];if(!r&&t.some(i=>ie(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=vl({...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")}});I(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})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});I(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()}));I(this,"onBlur",tt(()=>{Mi=!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",tt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...mr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async 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,...li(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)}),ai(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<i1||r<l1&&t<a1);I(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});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: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});I(this,"onResize",tt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>pn.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),qa||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&&(uf=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",Wn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},o1));I(this,"onCut",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ir(t.target)||(this.actionManager.executeAction(Fd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ir(t.target)||(this.actionManager.executeAction(ka,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(_s&&t.preventDefault(),!Es){Es=!0,clearTimeout(mf),mf=window.setTimeout(e.resetTapTwice,e1);return}if(Es&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Es=!1,clearTimeout(mf)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):Ae.pointers.clear()});I(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}=Ye({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)||ii(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()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=tu(t.elements,null,void 0),[n,i,a,l]=ye(r),s=Kn(n,a)/2,c=Kn(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}=Ye({clientX:m,clientY:d},this.state),g=p-s,b=u-c,[x,E]=ut(g,b,this.getEffectiveGridSize()),{duplicatedElements:w}=si({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=Tb(w,S);Wi(v,L,S,this.state)}this.scene.replaceAllElements(v),w.forEach(L=>{if(Z(L)&&Be(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 _=Sb(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&St.get(ds)?this.state.openSidebar:null,...ht({editingGroupId:null,selectedElementIds:_.reduce((L,N)=>(Be(N)||(L[N.id]=!0),L),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{On&&this.resetContextMenuTimer(),Ae.pointers.delete(t.pointerId)});I(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}}))});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(zy)});I(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)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(ai(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}):ai(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}=Zl({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=li(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})});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,Ja,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",tt(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===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}});I(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})}));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",tt(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 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}});I(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=Gn(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&qn(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:st("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||Gn(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}),Gn(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])ce(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 ie(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(Ii,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,i=t.key===T.I||r===T.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",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}),Gn(t.key)&&(ei(this.scene.getSelectedElements(this.state).filter(ce),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Qn(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})}}));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=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}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{Le(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{xo(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>Ae.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Ip()}`);I(this,"onGestureStart",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),Ae.initialScale=this.state.zoom.value}));I(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)}))}));I(this,"onGestureEnd",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),Ae.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(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})});I(this,"startImageCropping",t=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Ye(t,this.state);if(r.length===1&&ce(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,...ht({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&&(mt(s)||!Zn(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})}});I(this,"getElementLinkAtPosition",(t,r)=>{let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Mc(l,this.scene.getNonDeletedElementsMap(),this.state,M(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=Vn(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Hn)return;let i=Ye(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=Ye(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=$s("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)}}}});I(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});I(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||ys||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=Ye(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&&Nn(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):Nn(()=>{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)Vn(M(l-g,s-b),w)>=Ds?B(u,{points:[...x,M(l-g,s-b)]},!1):Le(this.interactiveCanvas,Se.POINTER);else if(x.length>2&&E&&Vn(M(l-g,s-b),E)<Ds)Le(this.interactiveCanvas,Se.POINTER),B(u,{points:x.slice(0,-1)},!1);else{let[y,v]=ut(l,s,t[T.CTRL_OR_CMD]||te(u)?null:this.getEffectiveGridSize()),[C,S]=u?.lastCommittedPoint??[0,0],_=y-g-C,L=v-b-S;Ys(t)&&({width:_,height:L}=Rp(C+g,S+b,y,v)),El(x,this.state.zoom.value)&&Le(this.interactiveCanvas,Se.POINTER),B(u,{points:[...x.slice(0,-1),M(C+_,S+L)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&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,ht({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,{})})))});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=>{vs=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches.map(p=>({...p,focus:!1}))})),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})),ys||(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=We(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==nr.MAIN&&t.button!==nr.TOUCH&&t.button!==nr.ERASER||Ae.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.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}=Ye(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)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=Ye({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:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(vs=!1,On?vs=!0:On=window.setTimeout(()=>{On=0,vs||this.handleCanvasContextMenu(t)},t1))});I(this,"resetContextMenuTimer",()=>{clearTimeout(On),On=0,vs=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{ws?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(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;ys=!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(ws=()=>{ws=null,ys=!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});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!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&&ce(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)}),ie(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=>ie(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})),{...ht({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});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);mt(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"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=ut(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:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=ut(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});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=ut(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ii(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});I(this,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=ut(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})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&El(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&&Vn(M(n.origin.x-a,n.origin.y-l),s)<Ds){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]=ut(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:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=ut(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}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=ut(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?vl(a):$i(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)||Be(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))});I(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 Il(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)}})});I(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return B(t,{isDeleted:!0}),this.actionManager.executeAction(yo),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});I(this,"setImagePreviewCursor",async t=>{let n;try{n=await Il(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`)});I(this,"onImageAction",async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:i,y:a}=Ye({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)})}});I(this,"initializeImageDimensions",(t,r=!1)=>{let n=Ar(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<Hn/this.state.zoom.value&&t.height<Hn/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<Hn/this.state.zoom.value&&t.height<Hn/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=t.x+t.width/2-s/2,m=t.y+t.height/2-l/2;B(t,{x:c,y:m,width:s,height:l,crop:null})}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await 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}});I(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()}});I(this,"scheduleImageRefresh",G8(()=>{this.addNewImagesToImageCache()},Qf));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=sb(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(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]:[]})});I(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})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await T0(t),{x:i,y:a}=Ye(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)||ii(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Wo(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});I(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})}});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!==nr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=Ye(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,...ht({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ce(i)?new j(i):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){bu({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Kn(t.origin.x,a.x),height:Kn(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]=ut(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:Kn(t.originInGrid.x,s),height:Kn(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())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=ut(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]=ut(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});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ie(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]=ut(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]=ut(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,Ys(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});I(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,Ql,Wd,bt,$u,Gh,bt,Hl])});I(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(),ys)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}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=Ye({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:Ae.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Wn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:d}=this.state;if(n===s&&i===c&&a===d&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=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=Y8(),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=V8.canvas(this.canvas),this.renderer=new ss(this.scene),this.visibleElements=[],this.store=new Kc,this.history=new is,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 is,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),$n(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||$n(a));return Oe(K8,{children:i.map(a=>{let{x:l,y:s}=zt({sceneX:a.x,sceneY:a.y},this.state),c=xl(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($n(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]`,CT=WB(El,300),KB=({mermaidToExcalidrawLib:e})=>{let[o,t]=vT(()=>Wt.get(YB.MERMAID_TO_EXCALIDRAW)||XB),n=UB(o.trim()),[r,i]=vT(null),a=TT(null),l=TT({elements:[],files:null}),s=Be();IT(()=>{Kd({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(d=>{VB()&&console.error("Failed to parse mermaid definition",d)}),CT(n)},[n,e]),IT(()=>()=>{CT.flush()},[]);let m=()=>{Zd({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return ST(ZB,{children:[ko("div",{className:"ttd-dialog-desc",children:ko(ft,{i18nKey:"mermaid.description",flowchartLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>ko("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),ST(Vd,{children:[ko(Hi,{label:g("mermaid.syntax"),children:ko(Ud,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>t(d.target.value),onKeyboardSubmit:()=>{m()}})}),ko(Hi,{label:g("mermaid.preview"),panelAction:{action:()=>{m()},label:g("mermaid.button"),icon:Nr},renderSubmitShortcut:()=>ko(Xd,{}),children:ko(Wd,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},kT=KB;import*as PT from"@radix-ui/react-tabs";import{useRef as MT}from"react";import{isMemberOf as $B}from"@excalidraw/common";import{jsx as jB}from"react/jsx-runtime";var LT=e=>{let o=ae(),t=MT(null),n=MT(0);return jB(PT.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>n.current&&(n.current=a,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&$B(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};LT.displayName="TTDDialogTabs";var AT=LT;import*as DT from"@radix-ui/react-tabs";import{jsx as qB}from"react/jsx-runtime";var Hg=({children:e,...o})=>qB(DT.List,{className:"ttd-dialog-triggers",...o,children:e});Hg.displayName="TTDDialogTabTriggers";import*as RT from"@radix-ui/react-tabs";import{jsx as _T}from"react/jsx-runtime";var $d=({children:e,tab:o,onSelect:t,...n})=>_T(RT.Trigger,{value:o,asChild:!0,onSelect:t,children:_T("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});$d.displayName="TTDDialogTabTrigger";import*as NT from"@radix-ui/react-tabs";import{jsx as JB}from"react/jsx-runtime";var jd=({tab:e,children:o,...t})=>JB(NT.Content,{...t,value:e,children:o});jd.displayName="TTDDialogTab";import{jsx as xt,jsxs as Mn}from"react/jsx-runtime";var Ug=3,Gi=1e3,eF=he(null),tF=he(null),Yg=e=>{let o=be();return o.openDialog?.name!=="ttd"?null:xt(oF,{...e,tab:o.openDialog.tab})},oF=Zo("TTDDialogBase",({tab:e,...o})=>{let t=Be(),n=ae(),r=Gg(null),[i,a]=le(tF),[l,s]=qd(i?.prompt??""),m=l.trim(),d=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[c,p]=qd(!1),[u,f]=le(eF),b=async()=>{if(m.length>Gi||m.length<Ug||c||u?.rateLimitRemaining===0||"__fallback"in o){m.length<Ug&&C(new Error(`Prompt is too short (min ${Ug} characters)`)),m.length>Gi&&C(new Error(`Prompt is too long (max ${Gi} characters)`));return}try{p(!0),re("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:P,rateLimitRemaining:B}=await o.onTextSubmit(m);if(typeof S=="string"&&a(k=>({generatedResponse:S,prompt:k?.prompt??null})),BT(P)&&BT(B)&&f({rateLimit:P,rateLimitRemaining:B}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await Kd({canvasRef:r,data:w,mermaidToExcalidrawLib:y,setError:C,mermaidDefinition:S}),re("ai","mermaid parse success","ttd")}catch(k){console.info(`%cTTD mermaid render errror: ${k.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
25
+ TTD mermaid definition render errror: ${k.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=Gg(b);x.current=b;let[y,E]=qd({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});QB(()=>{(async()=>{await y.api,E(L=>({...L,loaded:!0}))})()},[y.api]);let w=Gg({elements:[],files:null}),[v,C]=qd(null);return xt(Oe,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Mn(AT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?xt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):Mn(Hg,{children:[xt($d,{tab:"text-to-diagram",children:Mn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),xt("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"})]})}),xt($d,{tab:"mermaid",children:"Mermaid"})]}),xt(jd,{className:"ttd-dialog-content",tab:"mermaid",children:xt(kT,{mermaidToExcalidrawLib:y})}),!("__fallback"in o)&&Mn(jd,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[xt("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."}),Mn(Vd,{children:[xt(Hi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Nr},onTextSubmitInProgess:c,panelActionDisabled:m.length>Gi||u?.rateLimitRemaining===0,renderTopRight:()=>u?Mn("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:()=>xt(Xd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Mn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(El(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",xt(dn,{icon:Nr})]});let S=m.length/Gi;return S>.8?Mn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Gi]}):null},children:xt(Ud,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),xt(Hi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Zd({app:t,data:w})},label:"Insert",icon:Nr},children:xt(Wd,{canvasRef:r,error:v,loaded:y.loaded})})]})]})]})})});import{round as w5}from"@excalidraw/math";import gO from"clsx";import fO from"lodash.throttle";import{useEffect as v5,useMemo as nf,useState as bO,memo as xO}from"react";import{STATS_PANELS as im}from"@excalidraw/common";import{getCommonBounds as EO}from"@excalidraw/element";import{getUncroppedWidthAndHeight as yO}from"@excalidraw/element";import{isElbowArrow as wO,isImageElement as rf}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as vO}from"@excalidraw/element";import{elementsAreInSameGroup as TO}from"@excalidraw/element";import{degreesToRadians as UT,radiansToDegrees as XT}from"@excalidraw/math";import{getBoundTextElement as YT}from"@excalidraw/element";import{isArrowElement as WT,isElbowArrow as hF}from"@excalidraw/element";import{updateBindings as VT}from"@excalidraw/element";import sF from"clsx";import{useEffect as HT,useRef as Qd,useState as cF}from"react";import{EVENT as Wi,KEYS as dF,cloneJSON as Wg}from"@excalidraw/common";import{deepCopyElement as mF}from"@excalidraw/element";import{CaptureUpdateAction as GT}from"@excalidraw/element";import{pointFrom as Pn,pointRotateRads as Jd}from"@excalidraw/math";import{getBoundTextElement as nF}from"@excalidraw/element";import{isFrameLikeElement as OT}from"@excalidraw/element";import{getSelectedGroupIds as rF,getElementsInGroup as iF,isInGroup as aF}from"@excalidraw/element";import{getFrameChildren as lF}from"@excalidraw/element";import{updateBindings as FT}from"@excalidraw/element";var zT=.01,yl=10,Ct=(e,o)=>!(o==="angle"&&OT(e)),Pe=(e,o)=>{let t=e+o/2;return t-t%o},Ui=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var pr=(e,o,t,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[d,c]=Jd(Pn(t.x,t.y),Pn(s,m),t.angle),p=e-d,u=o-c,[f,b]=Jd(Pn(e,o),Pn(s+p,m+u),-t.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),FT(l,n);let x=nF(t,r);if(x){let y=a.get(x.id);y&&n.mutateElement(y,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(OT(t)){let y=lF(r,t.id);y.forEach(E=>{let w=a.get(E.id);if(!w)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=Jd(Pn(E.x,E.y),Pn(v,C),E.angle),P=Math.round(S+p),B=Math.round(L+u),[k,A]=Jd(Pn(P,B),Pn(v+p,C+u),-E.angle);n.mutateElement(w,{x:k,y:A},{informMutation:i,isDragging:!1}),FT(w,n,{simultaneouslyUpdated:y})})}},Yi=(e,o)=>{let n=rF(o).map(r=>iF(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!aF(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Vg,jsxs as uF}from"react/jsx-runtime";var pF=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:d=1,dragFinishedCallback:c})=>{let p=Be(),u=ae(),f=Qd(null),b=Qd(null),[x,y]=cF(n.toString()),E=Qd(null);E.current||(E.current={originalAppState:Wg(m),originalElements:r,lastUpdatedValue:x,updatePending:!1}),HT(()=>{let C=n.toString();y(C),E.current.lastUpdatedValue=C},[n]);let w=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let P=Number(C);if(isNaN(P)){y(n.toString());return}let B=Number(P.toFixed(2)),k=Number(n);(isNaN(k)||Math.abs(B-k)>=zT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:B,property:l,originalAppState:L,setInputValue:A=>y(String(A)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:GT.IMMEDIATELY}))},v=Qd({});return v.current.handleInputValue=w,HT(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(Wi.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(Wi.POINTER_UP,S.onPointerUp,!1)}},[i]),i?uF("div",{className:sF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Vg("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,P=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,mF(R)),_),new Map),B=r.map(_=>P.get(_.id)),k=Wg(m),A=0,F=0,Y=_=>{if(L&&P!==null&&B!==null){let R=_.clientX-L.x;R!==0&&(F+=R,Math.abs(F)>=d&&(F=Math.sign(F)*Math.floor(Math.abs(F)/d),A+=F,t({accumulatedChange:A,instantChange:F,originalElements:B,originalElementsMap:P,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:k,setInputValue:W=>y(String(W)),app:p,setAppState:u}),F=0))}L={x:_.clientX,y:_.clientY}},Q=()=>{window.removeEventListener(Wi.POINTER_MOVE,Y,!1),p.syncActionResult({captureUpdate:GT.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:B,originalAppState:k}),L=null,A=0,F=0,B=null,P=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Wi.POINTER_UP,Q,!1)};v.current.onPointerMove=Y,v.current.onPointerUp=Q,window.addEventListener(Wi.POINTER_MOVE,Y,!1),window.addEventListener(Wi.POINTER_UP,Q,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Vg(dn,{icon:o}):e}),Vg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===dF.ENTER&&(w(S.value,r,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,y(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=r,E.current.originalAppState=Wg(m)},onBlur:C=>{x?i&&w(C.target.value,E.current.originalElements,E.current.originalAppState):y(n.toString())},disabled:!i})]}):null},Qe=pF;import{jsx as xF}from"react/jsx-runtime";var gF=15,fF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a&&!hF(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=UT(n);r.mutateElement(l,{angle:u}),VT(l,r);let f=YT(l,i);f&&!WT(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(XT(a.angle)*100)/100,m=Math.round(e),d=(s+m)%360;t&&(d=Pe(d,gF)),d=d<0?d+360:d;let c=UT(d);r.mutateElement(l,{angle:c}),VT(l,r);let p=YT(l,i);p&&!WT(l)&&r.mutateElement(p,{angle:c})}},bF=({element:e,scene:o,appState:t,property:n})=>xF(Qe,{label:"A",icon:ms,value:Math.round(XT(e.angle)%360*100)/100,elements:[e],dragInputCallback:fF,editable:Ct(e,"angle"),scene:o,appState:t,property:n}),KT=bF;import{jsx as yF}from"react/jsx-runtime";var ZT=5,EF=({property:e,scene:o,appState:t,setAppState:n})=>yF(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let m;return r?m=r:i&&(m=a?Pe(s.gridStep+ZT*Math.sign(i),ZT):s.gridStep+i),m?(m=g1(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),$T=EF;import{clamp as em,round as Xg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as tm}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as jT,getUncroppedWidthAndHeight as QT}from"@excalidraw/element";import{resizeSingleElement as qT}from"@excalidraw/element";import{isImageElement as e5}from"@excalidraw/element";import{isFrameLikeElement as Kg}from"@excalidraw/element";import{getElementsInResizingFrame as Zg}from"@excalidraw/element";import{replaceAllElementsInFrame as t5}from"@excalidraw/element";import{jsx as CF}from"react/jsx-runtime";var JT=10,wF=e=>e.type==="image",vF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:d,setAppState:c})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=n||wF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let y=p.get(u.id);if(!y||!e5(y)||!y.crop)return;let E=y.crop,w={...E},v=y.scale[0]===-1,C=y.scale[1]===-1,{width:S,height:L}=QT(y),P=E.naturalWidth/S,B=E.naturalHeight/L,k=v?E.width+E.x:E.naturalWidth-E.x,A=C?E.height+E.y:E.naturalHeight-E.y,F=jT*P,Y=jT*B;if(i!==void 0){if(a==="width"){let X=i*P,G=em(X,F,k);w={...w,width:G,x:v?E.x+E.width-G:E.x}}else if(a==="height"){let X=i*B,G=em(X,Y,A);w={...w,height:G,y:C?E.y+E.height-G:E.y}}m.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/S),height:w.height/(E.naturalHeight/L)});return}let Q=a==="width"?s:0,_=a==="height"?s:0,R=em(E.width+Q,F,k),W=em(E.height+_,F,A);w={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-W:E.y,width:R,height:W},m.mutateElement(y,{crop:w,width:w.width/(E.naturalWidth/S),height:w.height/(E.naturalHeight/L)});return}if(i!==void 0){let y=Math.max(a==="width"?i:b?i*x:u.width,tm),E=Math.max(a==="height"?i:b?i/x:u.height,tm);if(qT(y,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Kg(f)){let w=Zg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=t5(m.getElementsIncludingDeleted(),w,f,d);m.replaceAllElements(v)}return}{let y=a==="width"?e:0,E=a==="height"?e:0,w=Math.max(0,u.width+y);a==="width"&&(r?w=Pe(w,JT):w=Math.round(w));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=Pe(v,JT):v=Math.round(v)),b&&(a==="width"?v=Math.round(w/x*100)/100:w=Math.round(v*x*100)/100),v=Math.max(tm,v),w=Math.max(tm,w),qT(w,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Kg(f)){let C=Zg(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},TF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Kg(a)){let l=Zg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=t5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},IF=({property:e,element:o,scene:t,appState:n})=>{let r=Xg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&e5(o)&&o.crop){let{width:i,height:a}=QT(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Xg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Xg(o.crop.height*l,2)}}return CF(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:vF,value:r,editable:Ct(o,e),scene:t,appState:n,property:e,dragFinishedCallback:TF})},$g=IF;import{getBoundTextElement as SF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{hasBoundTextElement as MF,isTextElement as n5}from"@excalidraw/element";import{jsx as DF}from"react/jsx-runtime";var o5=4,PF=4,LF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!n5(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),o5);else if(a.type==="text"){let m=Math.round(a.fontSize),d=Math.round(e);s=Math.max(m+d,o5),t&&(s=Pe(s,PF))}s&&(r.mutateElement(l,{fontSize:s}),kF(l,r.getContainerElement(l),r))}},AF=({element:e,scene:o,appState:t,property:n})=>{let r=n5(e)?e:MF(e)?SF(e,o.getNonDeletedElementsMap()):null;return r?DF(Qe,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:LF,icon:Kn,appState:t,scene:o,property:n}):null},r5=AF;import{degreesToRadians as i5,radiansToDegrees as s5}from"@excalidraw/math";import{getBoundTextElement as a5}from"@excalidraw/element";import{isArrowElement as l5}from"@excalidraw/element";import{isInGroup as jg}from"@excalidraw/element";import{jsx as BF}from"react/jsx-runtime";var _F=15,RF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!jg(m)&&Ct(m,r)),s=o.filter(m=>!jg(m)&&Ct(m,r));if(n!==void 0){let m=i5(n);for(let d of l){if(!d)continue;i.mutateElement(d,{angle:m});let c=a5(d,a);c&&!l5(d)&&i.mutateElement(c,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let d=l[m];if(!d)continue;let c=s[m],p=Math.round(s5(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Pe(f,_F)),f=f<0?f+360:f;let b=i5(f);i.mutateElement(d,{angle:b});let x=a5(d,a);x&&!l5(d)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},NF=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!jg(s)&&Ct(s,"angle")),i=r.map(s=>Math.round(s5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Ct(s,"angle"));return BF(Qe,{label:"A",icon:ms,value:a,elements:e,dragInputCallback:RF,editable:l,appState:t,scene:o,property:n})},c5=NF;import{pointFrom as d5}from"@excalidraw/math";import{useMemo as FF}from"react";import{MIN_WIDTH_OR_HEIGHT as Ln}from"@excalidraw/common";import{getElementsInResizingFrame as qg,isFrameLikeElement as Jg,replaceAllElementsInFrame as u5,updateBoundElements as OF}from"@excalidraw/element";import{rescalePointsInElement as zF,resizeSingleElement as m5}from"@excalidraw/element";import{getBoundTextElement as HF,handleBindTextResize as GF}from"@excalidraw/element";import{isTextElement as h5}from"@excalidraw/element";import{getCommonBounds as om}from"@excalidraw/element";import{jsx as KF}from"react/jsx-runtime";var Vi=10,UF=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...zF(n,a,l,!1),...h5(n)?{fontSize:n.fontSize*t}:{}}},YF=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=UF(e,o,n,i);l.mutateElement(r,m);let d=HF(i,a);if(d){let c=d.fontSize*n;OF(r,l,{newSize:{width:m.width,height:m.height}});let p=s.get(d.id);p&&h5(p)&&(l.mutateElement(p,{fontSize:c}),GF(r,l,t==="width"?"e":"s",!0))}},p5=(e,o,t,n,r,i,a,l,s,m)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let d=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];YF(r[0],r[1],i,d,u,p,s,m)}},WF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let d=a.getNonDeletedElementsMap(),c=Yi(o,n);if(i!==void 0){for(let b of c){let x=Ui(b,d,t);if(x.length>1){let y=x.map(F=>F.latest),E=x.map(F=>F.original),[w,v,C,S]=om(E),L=C-w,P=S-v,B=L/P,k=Math.max(Ln,l==="width"?Math.max(0,i):L),A=Math.max(Ln,l==="height"?Math.max(0,i):P);p5(k,A,P,B,d5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&Ct(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=Pe(v,Vi):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?C=Pe(C,Vi):C=Math.round(C)),v=Math.max(Ln,v),C=Math.max(Ln,C),m5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jg(E)){let S=qg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),L=u5(a.getElementsIncludingDeleted(),S,E,m);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=Ui(b,d,t);if(x.length>1){let y=x.map(F=>F.latest),E=x.map(F=>F.original),[w,v,C,S]=om(E),L=C-w,P=S-v,B=L/P,k=Math.max(0,L+p);l==="width"&&(r?k=Pe(k,Vi):k=Math.round(k));let A=Math.max(0,P+u);l==="height"&&(r?A=Pe(A,Vi):A=Math.round(A)),k=Math.max(Ln,k),A=Math.max(Ln,A),p5(k,A,P,B,d5(w,v),l,y,E,t,a)}else{let[y]=x,E=y?.latest,w=y?.original;if(E&&w&&Ct(E,l)){let v=Math.max(0,w.width+p);l==="width"&&(r?v=Pe(v,Vi):v=Math.round(v));let C=Math.max(0,w.height+u);if(l==="height"&&(r?C=Pe(C,Vi):C=Math.round(C)),v=Math.max(Ln,v),C=Math.max(Ln,C),m5(v,C,E,w,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Jg(E)){let S=qg(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},VF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Jg(a)){let l=qg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=u5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},XF=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=FF(()=>n.map(m=>{let d=Ui(m,t);if(d.length>1){let[p,u,f,b]=om(d.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=d;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return KF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:WF,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:VF})},Qg=XF;import{getBoundTextElement as ZF,redrawTextBoundingBox as g5}from"@excalidraw/element";import{hasBoundTextElement as $F,isTextElement as jF}from"@excalidraw/element";import{isInGroup as qF}from"@excalidraw/element";import{jsx as oO}from"react/jsx-runtime";var f5=4,JF=4,QF=(e,o)=>e.reduce((t,n)=>{if(!n||qF(n))return t;if(jF(n))return t.push(n),t;if($F(n)){let r=ZF(n,o);if(r)return t.push(r),t}return t},[]),eO=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),f5);for(let s of a)r.mutateElement(s,{fontSize:l}),g5(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let d=a[m],c=s[m],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,f5);t&&(f=Pe(f,JF)),r.mutateElement(d,{fontSize:f}),g5(d,r.getContainerElement(d),r)}r.triggerUpdate()}},tO=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=QF(e,r);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return oO(Qe,{label:"F",icon:Kn,elements:i,dragInputCallback:eO,value:l,editable:s,scene:o,property:n,appState:t})},b5=tO;import{pointFrom as An,pointRotateRads as nm}from"@excalidraw/math";import{useMemo as nO}from"react";import{isTextElement as rO}from"@excalidraw/element";import{getCommonBounds as ef}from"@excalidraw/element";import{jsx as cO}from"react/jsx-runtime";var iO=(e,o,t,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[d,c]=nm(An(l.x,l.y),An(s,m),l.angle),p=e==="x"?Math.round(d+o):d,u=e==="y"?Math.round(c+t):c;pr(p,u,l,i,r,!1)}},aO=(e,o,t,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=ef(t),s=e-a,m=o-l;for(let d=0;d<t.length;d++){let c=t[d],p=i.get(c.id);if(p&&(!rO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=nm(An(p.x,p.y),An(u,f),p.angle);pr(b+s,x+m,c,r,n,!1)}}},lO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of Yi(o,l)){let u=Ui(p,s,t);if(u.length>1){let[f,b,,]=ef(u.map(E=>E.latest));aO(i==="x"?r:f,i==="y"?r:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Ct(b,i)){let[x,y]=[f.x+f.width/2,f.y+f.height/2],[E,w]=nm(An(f.x,f.y),An(x,y),f.angle);pr(i==="x"?r:E,i==="y"?r:w,f,a,t,!1)}}}a.triggerUpdate();return}let m=n?Pe(e,yl):e;iO(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},sO=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=nO(()=>n.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=ef(m);return Math.round((e==="x"?b:x)*100)/100}let[d]=m,[c,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=nm(An(d.x,d.y),An(c,p),d.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return cO(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:lO,value:l,property:e,scene:r,appState:i})},tf=sO;import{clamp as wl,pointFrom as rm,pointRotateRads as E5,round as x5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as dO,getUncroppedWidthAndHeight as mO}from"@excalidraw/element";import{isImageElement as y5}from"@excalidraw/element";import{jsx as hO}from"react/jsx-runtime";var pO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),d=t[0],[c,p]=[d.x+d.width/2,d.y+d.height/2],[u,f]=E5(rm(d.x,d.y),rm(c,p),d.angle);if(s.croppingElementId===d.id){let w=m.get(d.id);if(!w||!y5(w)||!w.crop)return;let v=w.crop,C=v,S=w.scale[0]===-1,L=w.scale[1]===-1,{width:P,height:B}=mO(w);if(i!==void 0){if(a==="x"){let F=i*(v.naturalWidth/P);S?C={...v,x:wl(v.naturalWidth-F-v.width,0,v.naturalWidth-v.width)}:C={...v,x:wl(i*(v.naturalWidth/P),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:wl(i*(v.naturalHeight/B),0,v.naturalHeight-v.height)}),l.mutateElement(w,{crop:C});return}let k=(a==="x"?o:0)*(S?-1:1),A=(a==="y"?o:0)*(L?-1:1);C={...v,x:wl(v.x+k,0,v.naturalWidth-v.width),y:wl(v.y+A,0,v.naturalHeight-v.height)},l.mutateElement(w,{crop:C});return}if(i!==void 0){pr(a==="x"?i:u,a==="y"?i:f,d,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,y=a==="x"?Math.round(r?Pe(d.x+b,yl):u+b):u,E=a==="y"?Math.round(r?Pe(d.y+x,yl):f+x):f;pr(y,E,d,l,n)},uO=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=E5(rm(o.x,o.y),rm(o.x+o.width/2,o.y+o.height/2),o.angle),l=x5(e==="x"?i:a,2);if(r.croppingElementId===o.id&&y5(o)&&o.crop){let s=dO(o);s&&(l=x5(e==="x"?s.x:s.y,2))}return hO(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:pO,scene:n,value:l,property:e,appState:r})},of=uO;import{Fragment as af,jsx as q,jsxs as St}from"react/jsx-runtime";var IO=50,vl=e=>{let o=bo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=yn(e.app);return q(CO,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Se=({children:e,columns:o=1,heading:t,style:n,...r})=>q("div",{className:gO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Se.displayName="StatsRow";var am=({children:e,order:o,style:t,...n})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});am.displayName="StatsRows";vl.StatsRow=Se;vl.StatsRows=am;var CO=xO(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),d=ae(),c=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&rf(c),f=u?yO(c):null,[b,x]=bO({width:0,height:0}),y=nf(()=>fO(v=>{let C=EO(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},IO),[]);v5(()=>{y(s)},[i,s,y]),v5(()=>()=>y.cancel(),[y]);let E=nf(()=>Yi(n,r),[n,r]),w=nf(()=>vO(n),[n]);return q("div",{className:"exc-stats",children:St(Ye,{padding:3,children:[St("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:zt})]}),St(ka,{label:q("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&im.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^im.generalStats}})),children:[St(am,{children:[q(Se,{heading:!0,children:g("stats.scene")}),St(Se,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),St(Se,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),St(Se,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&St(af,{children:[q(Se,{heading:!0,children:"Canvas"}),q(Se,{children:q($T,{property:"gridStep",scene:l,appState:r,setAppState:d})})]})]}),t?.(s,r)]}),!w&&n.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(ka,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&im.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^im.elementProperties}})),children:St(am,{children:[c&&St(af,{children:[u&&q(Se,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&rf(c)&&f&&St(Se,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:w5(f.width,2)})]}),r.croppingElementId&&rf(c)&&f&&St(Se,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:w5(f.height,2)})]}),q(Se,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),q(Se,{children:q(of,{element:c,property:"x",elementsMap:m,scene:l,appState:r})}),q(Se,{children:q(of,{element:c,property:"y",elementsMap:m,scene:l,appState:r})}),q(Se,{children:q($g,{property:"width",element:c,scene:l,appState:r})}),q(Se,{children:q($g,{property:"height",element:c,scene:l,appState:r})}),!wO(c)&&q(Se,{children:q(KT,{property:"angle",element:c,scene:l,appState:r})}),q(Se,{children:q(r5,{property:"fontSize",element:c,scene:l,appState:r})})]}),p&&St(af,{children:[TO(p)&&q(Se,{heading:!0,children:g("element.group")}),St(Se,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:n.length})]}),q(Se,{children:q(tf,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(tf,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(Qg,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(Qg,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:r})}),q(Se,{children:q(c5,{property:"angle",elements:p,scene:l,appState:r})}),q(Se,{children:q(b5,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:m})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as SO,useEffect as T5,useState as I5}from"react";import{normalizeLink as kO,KEYS as lf}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as MO,getLinkIdAndTypeFromSelection as PO}from"@excalidraw/element";import{jsx as Xi,jsxs as lm}from"react/jsx-runtime";var LO=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=MO})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=I5(a),[m,d]=I5(!1);T5(()=>{let p=j(i,t),u=a;if(p.length>0&&r){let f=PO(p,t);f&&(u=kO(r(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let c=SO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}o?.()},[e,l,i,m,n,o]);return T5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===lf.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===lf.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),lm("div",{className:"ElementLinkDialog",children:[lm("div",{className:"ElementLinkDialog__header",children:[Xi("h2",{children:g("elementLink.title")}),Xi("p",{children:g("elementLink.desc")})]}),lm("div",{className:"ElementLinkDialog__input",children:[Xi(Ci,{value:l??"",onChange:p=>{m||d(!0),s(p)},onKeyDown:p=>{p.key===lf.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Xi(Z,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),d(!0)},className:"ElementLinkDialog__remove",icon:Mt})]}),lm("div",{className:"ElementLinkDialog__actions",children:[Xi(Ho,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Xi(Ho,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},C5=LO;import AO,{useState as DO}from"react";import{Fragment as _O,jsx as sf}from"react/jsx-runtime";var S5=({children:e,onClose:o})=>{let[t,n]=DO(!!e),{container:r}=Ne(),i=AO.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return sf(_O,{children:t&&sf(Oe,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:sf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import RO from"react";import{isDarwin as k5,isFirefox as M5,isWindows as NO}from"@excalidraw/common";import{KEYS as De,getShortcutKey as K}from"@excalidraw/common";import{Fragment as L5,jsx as z,jsxs as Ft}from"react/jsx-runtime";var BO=()=>Ft("div",{className:"HelpDialog__header",children:[Ft("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Gm}),g("helpDialog.documentation")]}),Ft("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[z("div",{className:"HelpDialog__link-icon",children:Gm}),g("helpDialog.blog")]}),Ft("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:as}),g("helpDialog.github")]}),Ft("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[z("div",{className:"HelpDialog__link-icon",children:Cb}),"YouTube"]})]}),FO=e=>Ft(L5,{children:[z("h3",{children:e.title}),z("div",{className:"HelpDialog__islands-container",children:e.children})]}),cf=e=>Ft("div",{className:`HelpDialog__island ${e.className}`,children:[z("h4",{className:"HelpDialog__island-title",children:e.caption}),z("div",{className:"HelpDialog__island-content",children:e.children})]});function*OO(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var zO=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),U=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>z(HO,{children:zO(a)},a)));return Ft("div",{className:"HelpDialog__shortcut",children:[z("div",{children:e}),z("div",{className:"HelpDialog__key-container",children:[...OO(n,t?g("helpDialog.or"):null)]})]})},HO=e=>z("kbd",{className:"HelpDialog__key",...e}),P5=({onClose:e})=>{let o=RO.useCallback(()=>{e&&e()},[e]);return z(L5,{children:Ft(Oe,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[z(BO,{}),Ft(FO,{title:g("helpDialog.shortcuts"),children:[Ft(cf,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[z(U,{label:g("toolBar.hand"),shortcuts:[De.H]}),z(U,{label:g("toolBar.selection"),shortcuts:[De.V,De[1]]}),z(U,{label:g("toolBar.rectangle"),shortcuts:[De.R,De[2]]}),z(U,{label:g("toolBar.diamond"),shortcuts:[De.D,De[3]]}),z(U,{label:g("toolBar.ellipse"),shortcuts:[De.O,De[4]]}),z(U,{label:g("toolBar.arrow"),shortcuts:[De.A,De[5]]}),z(U,{label:g("toolBar.line"),shortcuts:[De.L,De[6]]}),z(U,{label:g("toolBar.freedraw"),shortcuts:[De.P,De[7]]}),z(U,{label:g("toolBar.text"),shortcuts:[De.T,De[8]]}),z(U,{label:g("toolBar.image"),shortcuts:[De[9]]}),z(U,{label:g("toolBar.eraser"),shortcuts:[De.E,De[0]]}),z(U,{label:g("toolBar.frame"),shortcuts:[De.F]}),z(U,{label:g("toolBar.laser"),shortcuts:[De.K]}),z(U,{label:g("labels.eyeDropper"),shortcuts:[De.I,"Shift+S","Shift+G"]}),z(U,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[K("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.editText"),shortcuts:[K("Enter")]}),z(U,{label:g("helpDialog.textNewLine"),shortcuts:[K("Enter"),K("Shift+Enter")]}),z(U,{label:g("helpDialog.textFinish"),shortcuts:[K("Esc"),K("CtrlOrCmd+Enter")]}),z(U,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),z(U,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),K("Enter")],isOr:!0}),z(U,{label:g("helpDialog.cropFinish"),shortcuts:[K("Enter"),K("Escape")],isOr:!0}),z(U,{label:g("toolBar.lock"),shortcuts:[De.Q]}),z(U,{label:g("helpDialog.preventBinding"),shortcuts:[K("CtrlOrCmd")]}),z(U,{label:g("toolBar.link"),shortcuts:[K("CtrlOrCmd+K")]}),z(U,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ft(cf,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[z(U,{label:g("buttons.zoomIn"),shortcuts:[K("CtrlOrCmd++")]}),z(U,{label:g("buttons.zoomOut"),shortcuts:[K("CtrlOrCmd+-")]}),z(U,{label:g("buttons.resetZoom"),shortcuts:[K("CtrlOrCmd+0")]}),z(U,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),z(U,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),z(U,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),z(U,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),z(U,{label:g("buttons.zenMode"),shortcuts:[K("Alt+Z")]}),z(U,{label:g("buttons.objectsSnapMode"),shortcuts:[K("Alt+S")]}),z(U,{label:g("labels.toggleGrid"),shortcuts:[K("CtrlOrCmd+'")]}),z(U,{label:g("labels.viewMode"),shortcuts:[K("Alt+R")]}),z(U,{label:g("labels.toggleTheme"),shortcuts:[K("Alt+Shift+D")]}),z(U,{label:g("stats.fullTitle"),shortcuts:[K("Alt+/")]}),z(U,{label:g("search.title"),shortcuts:[Fe("searchMenu")]}),z(U,{label:g("commandPalette.title"),shortcuts:M5?[Fe("commandPalette")]:[Fe("commandPalette"),Fe("commandPalette",1)]})]}),Ft(cf,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[z(U,{label:g("helpDialog.createFlowchart"),shortcuts:[K("CtrlOrCmd+Arrow Key")],isOr:!0}),z(U,{label:g("helpDialog.navigateFlowchart"),shortcuts:[K("Alt+Arrow Key")],isOr:!0}),z(U,{label:g("labels.moveCanvas"),shortcuts:[K(`Space+${g("helpDialog.drag")}`),K(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),z(U,{label:g("buttons.clearReset"),shortcuts:[K("CtrlOrCmd+Delete")]}),z(U,{label:g("labels.delete"),shortcuts:[K("Delete")]}),z(U,{label:g("labels.cut"),shortcuts:[K("CtrlOrCmd+X")]}),z(U,{label:g("labels.copy"),shortcuts:[K("CtrlOrCmd+C")]}),z(U,{label:g("labels.paste"),shortcuts:[K("CtrlOrCmd+V")]}),z(U,{label:g("labels.pasteAsPlaintext"),shortcuts:[K("CtrlOrCmd+Shift+V")]}),z(U,{label:g("labels.selectAll"),shortcuts:[K("CtrlOrCmd+A")]}),z(U,{label:g("labels.multiSelect"),shortcuts:[K(`Shift+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.click")}`)]}),z(U,{label:g("helpDialog.deepBoxSelect"),shortcuts:[K(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(oi||M5)&&z(U,{label:g("labels.copyAsPng"),shortcuts:[K("Shift+Alt+C")]}),z(U,{label:g("labels.copyStyles"),shortcuts:[K("CtrlOrCmd+Alt+C")]}),z(U,{label:g("labels.pasteStyles"),shortcuts:[K("CtrlOrCmd+Alt+V")]}),z(U,{label:g("labels.sendToBack"),shortcuts:[k5?K("CtrlOrCmd+Alt+["):K("CtrlOrCmd+Shift+[")]}),z(U,{label:g("labels.bringToFront"),shortcuts:[k5?K("CtrlOrCmd+Alt+]"):K("CtrlOrCmd+Shift+]")]}),z(U,{label:g("labels.sendBackward"),shortcuts:[K("CtrlOrCmd+[")]}),z(U,{label:g("labels.bringForward"),shortcuts:[K("CtrlOrCmd+]")]}),z(U,{label:g("labels.alignTop"),shortcuts:[K("CtrlOrCmd+Shift+Up")]}),z(U,{label:g("labels.alignBottom"),shortcuts:[K("CtrlOrCmd+Shift+Down")]}),z(U,{label:g("labels.alignLeft"),shortcuts:[K("CtrlOrCmd+Shift+Left")]}),z(U,{label:g("labels.alignRight"),shortcuts:[K("CtrlOrCmd+Shift+Right")]}),z(U,{label:g("labels.duplicateSelection"),shortcuts:[K("CtrlOrCmd+D"),K(`Alt+${g("helpDialog.drag")}`)]}),z(U,{label:g("helpDialog.toggleElementLock"),shortcuts:[K("CtrlOrCmd+Shift+L")]}),z(U,{label:g("buttons.undo"),shortcuts:[K("CtrlOrCmd+Z")]}),z(U,{label:g("buttons.redo"),shortcuts:NO?[K("CtrlOrCmd+Y"),K("CtrlOrCmd+Shift+Z")]:[K("CtrlOrCmd+Shift+Z")]}),z(U,{label:g("labels.group"),shortcuts:[K("CtrlOrCmd+G")]}),z(U,{label:g("labels.ungroup"),shortcuts:[K("CtrlOrCmd+Shift+G")]}),z(U,{label:g("labels.flipHorizontal"),shortcuts:[K("Shift+H")]}),z(U,{label:g("labels.flipVertical"),shortcuts:[K("Shift+V")]}),z(U,{label:g("labels.showStroke"),shortcuts:[K("S")]}),z(U,{label:g("labels.showBackground"),shortcuts:[K("G")]}),z(U,{label:g("labels.showFonts"),shortcuts:[K("Shift+F")]}),z(U,{label:g("labels.decreaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+<")]}),z(U,{label:g("labels.increaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as _5,useRef as XO,useState as Dn}from"react";import{DEFAULT_EXPORT_PADDING as KO,EXPORT_IMAGE_TYPES as df,isFirefox as ZO,EXPORT_SCALES as $O,cloneJSON as R5}from"@excalidraw/common";import{useCallback as GO,useRef as UO,useState as YO}from"react";var WO=2e3,A5=()=>{let[e,o]=YO(null),t=UO(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},WO)},r=GO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import VO from"clsx";import{jsx as D5}from"react/jsx-runtime";var Tl=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>D5("div",{className:VO("Switch",{toggled:t,disabled:r}),children:D5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as ke,jsxs as _n}from"react/jsx-runtime";var jO="filter"in document.createElement("canvas").getContext("2d"),qO=()=>_n("div",{children:[ke("h3",{children:g("canvasError.cannotShowPreview")}),ke("p",{children:ke("span",{children:g("canvasError.canvasTooBig")})}),_n("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),JO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=we(o,e),[l,s]=Dn(i),[m,d]=Dn(a),[c,p]=Dn(e.exportBackground),[u,f]=Dn(e.exportWithDarkMode),[b,x]=Dn(e.exportEmbedScene),[y,E]=Dn(e.exportScale),w=XO(null),[v,C]=Dn(null),{onCopy:S,copyStatus:L,resetCopyStatus:P}=A5();_5(()=>{P()},[l,c,u,y,b,P]);let{exportedElements:B,exportingFrame:k}=er(o,e,m);return _5(()=>{let A=w.current;if(!A)return;let F=A.offsetWidth,Y=A.offsetHeight;F&&gn({elements:B,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:y,exportEmbedScene:b},files:t,exportPadding:KO,maxWidthOrHeight:Math.max(F,Y),exportingFrame:k}).then(Q=>(C(null),Ao(Q).then(()=>{A.replaceChildren(Q)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(Q=>{console.error(Q),C(Q)})},[e,t,B,k,l,c,u,y,b]),_n("div",{className:"ImageExportModal",children:[ke("h3",{children:g("imageExportDialog.header")}),_n("div",{className:"ImageExportModal__preview",children:[ke("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&ke(qO,{})}),ke("div",{className:"ImageExportModal__preview__filename",children:!Ir&&ke("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:A=>{s(A.target.value),n.executeAction(su,"ui",A.target.value)}})})]}),_n("div",{className:"ImageExportModal__settings",children:[ke("h3",{children:g("imageExportDialog.header")}),a&&ke(Il,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ke(Tl,{name:"exportOnlySelected",checked:m,onChange:A=>{d(A)}})}),ke(Il,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ke(Tl,{name:"exportBackgroundSwitch",checked:c,onChange:A=>{p(A),n.executeAction(cu,"ui",A)}})}),jO&&ke(Il,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ke(Tl,{name:"exportDarkModeSwitch",checked:u,onChange:A=>{f(A),n.executeAction(TE,"ui",A)}})}),ke(Il,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ke(Tl,{name:"exportEmbedSwitch",checked:b,onChange:A=>{x(A),n.executeAction(rc,"ui",A)}})}),ke(Il,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:ke(Rd,{name:"exportScale",value:y,onChange:A=>{E(A),n.executeAction(vE,"ui",A)},choices:$O.map(A=>({value:A,label:`${A}\xD7`}))})}),_n("div",{className:"ImageExportModal__settings__buttons",children:[ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(df.png,B,{exportingFrame:k}),icon:np,children:g("imageExportDialog.button.exportToPng")}),ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(df.svg,B,{exportingFrame:k}),icon:np,children:g("imageExportDialog.button.exportToSvg")}),(oi||ZO)&&ke(Sn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await r(df.clipboard,B,{exportingFrame:k}),S()},icon:Rr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Il=({label:e,children:o,tooltip:t,name:n})=>_n("div",{className:"ImageExportModal__settings__setting",title:e,children:[_n("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&ke(At,{label:t,long:!0,children:rb})]}),ke("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),N5=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Dn(()=>({appStateSnapshot:R5(o),elementsSnapshot:R5(e)}));return ke(Oe,{onCloseRequest:i,size:"wide",title:!1,children:ke(JO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import ez from"react";import{getFrame as tz}from"@excalidraw/common";import mf from"open-color";import{jsx as QO}from"react/jsx-runtime";var pf=({children:e,color:o})=>QO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":mf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":mf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":mf[o][9]},children:e});import{Fragment as nz,jsx as mo,jsxs as sm}from"react/jsx-runtime";var oz=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return mo("div",{className:"ExportDialog ExportDialog--json",children:sm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&sm(pf,{color:"lime",children:[mo("div",{className:"Card-icon",children:p0}),mo("h2",{children:g("exportDialog.disk_title")}),sm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Ir&&r.renderAction("changeProjectName")]}),mo(Z,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(za,"ui")}})]}),s&&sm(pf,{color:"pink",children:[mo("div",{className:"Card-icon",children:da}),mo("h2",{children:g("exportDialog.link_title")}),mo("div",{className:"Card-details",children:g("exportDialog.link_details")}),mo(Z,{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 (${tz()})`),await s(e,o,n),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},B5=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=ez.useCallback(()=>{a({openDialog:null})},[a]);return mo(nz,{children:o.openDialog?.name==="jsonExport"&&mo(Oe,{onCloseRequest:l,title:g("buttons.export"),children:mo(oz,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import rz from"clsx";import{jsx as F5,jsxs as az}from"react/jsx-runtime";var iz="small",O5=e=>az("label",{className:rz("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${iz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[F5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),F5("div",{className:"ToolIcon__icon",children:pa})]});import{Fragment as G5,jsx as $,jsxs as Ot}from"react/jsx-runtime";var gz=({UIOptions:e})=>Ot(mt,{__fallback:!0,children:[$(mt.DefaultItems.LoadScene,{}),$(mt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(mt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(mt.DefaultItems.SaveAsImage,{}),$(mt.DefaultItems.SearchMenu,{}),$(mt.DefaultItems.Help,{}),$(mt.DefaultItems.ClearCanvas,{}),$(mt.Separator,{}),$(mt.Group,{title:"Excalidraw links",children:$(mt.DefaultItems.Socials,{})}),$(mt.Separator,{}),$(mt.DefaultItems.ToggleTheme,{}),$(mt.DefaultItems.ChangeCanvasBackground,{})]}),fz=()=>Ot(Od,{__fallback:!0,children:[$(Od.Actions.SaveToDisk,{}),$(Od.Actions.ExportToImage,{})]}),bz=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:d,renderCustomStats:c,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:y,generateLinkForSelection:E})=>{let w=de(),v=B2(),C=o.stylesPanelMode==="compact"?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},S=v.tunnelsJotai.Provider,[L,P]=le(rn),B=()=>p.canvasActions.export?$(B5,{elements:r,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,k=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(N5,{elements:r,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:x.getName()}),A=()=>Ot("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>{let W=o.stylesPanelMode==="compact";return $(Tn,{heading:"selectedShapeActions",className:ur("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:W?$(Ye,{className:ur("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:$(X2,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x,setAppState:n})}):$(Ye,{className:sz.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Zc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})})},Y=()=>{let W=uz(o,r),X=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(Sd,{side:"top",children:Ot("div",{className:"App-menu App-menu_top",children:[Ot(qe.Col,{gap:C.menuTopGap,className:ur("App-menu_top__left"),children:[A(),$("div",{className:ur("selected-shape-actions-container",{"selected-shape-actions-container--compact":o.stylesPanelMode==="compact"}),children:W&&F()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(Tn,{heading:"shapes",className:"shapes-section",children:G=>Ot("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:C.toolbarColGap,align:"start",children:Ot(qe.Row,{gap:C.toolbarRowGap,className:ur("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Ot(Ye,{padding:C.islandPadding,className:ur("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":o.stylesPanelMode==="compact"}),children:[$(Md,{appState:o,isMobile:w.editor.isMobile,device:w,app:x}),G,Ot(qe.Row,{gap:C.toolbarInnerRowGap,children:[$(Pd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(Cd,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(kd,{checked:Qt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$($c,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),y&&$(Ye,{style:{marginLeft:C.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:$(O5,{title:g("toolBar.laser"),checked:o.activeTool.type===z5.laser,onChange:()=>x.setActiveTool({type:z5.laser}),isMobile:!0})})]})})]})}),Ot("div",{className:ur("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":o.stylesPanelMode==="compact"}),children:[o.collaborators.size>0&&$(Dd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),d?.(w.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!_||o.openSidebar?.name!==uf.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),X&&$(vl,{app:x,onClose:()=>{e.executeAction(pi)},renderCustomStats:c})]})]})})},Q=()=>$(Gd,{__fallback:!0,onDock:W=>{re("sidebar",`toggleDock (${W?"dock":"undock"})`,`(${w.editor.isMobile?"mobile":"desktop"})`)}}),_=ql(gl),R=Ot(G5,{children:[b,$(gz,{UIOptions:p}),$(Gd.Trigger,{__fallback:!0,icon:Pr,title:mz(g("toolBar.library")),onToggle:W=>{W&&re("sidebar",`${uf.name} (open)`,`button (${w.editor.isMobile?"mobile":"desktop"})`)},tab:uf.defaultTab,children:o.stylesPanelMode==="full"&&o.width>=cz&&g("toolBar.library")}),$(fz,{}),o.openDialog?.name==="ttd"&&$(Yg,{__fallback:!0}),o.isLoading&&$(Id,{delay:250}),o.errorMessage&&$(S5,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),L&&!w.editor.isMobile&&$(Xb,{colorPickerType:L.colorPickerType,onCancel:()=>{P(null)},onChange:(W,X,G,{altKey:me})=>{if(!(W!=="elementBackground"&&W!=="elementStroke"))if(G.length){for(let ue of G)pz(ue,dz(r),{[me&&L.swapPreviewOnAlt?W==="elementBackground"?"strokeColor":"backgroundColor":W==="elementBackground"?"backgroundColor":"strokeColor"]:X}),hz.delete(ue);x.scene.triggerUpdate()}else n(W==="elementBackground"?{currentItemBackgroundColor:X}:{currentItemStrokeColor:X})},onSelect:(W,X)=>{P(G=>G?.keepOpenOnAlt&&X.altKey?G:null),L?.onSelect?.(W,X)}}),o.openDialog?.name==="help"&&$(P5,{onClose:()=>{n({openDialog:null})}}),$(j2,{}),o.openDialog?.name==="elementLinkSelector"&&$(C5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),k(),B(),o.pasteDialog.shown&&$(x3,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),w.editor.isMobile&&$(f3,{app:x,appState:o,elements:r,actionManager:e,renderJSONExportDialog:B,renderImageExportDialog:k,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:c,renderSidebars:Q,device:w,renderWelcomeScreen:f,UIOptions:p}),!w.editor.isMobile&&Ot(G5,{children:[Ot("div",{className:"layer-ui__wrapper",style:o.openSidebar&&_&&w.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),Y(),$(v3,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(W=>({...Gn(r,W)}))},children:g("buttons.scrollBackToContent")})]}),Q()]})]});return $(xp.Provider,{value:o,children:$(S,{children:$(bh.Provider,{value:v,children:R})})})},H5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},xz=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return cm(H5(n),H5(a),{selectedElementIds:cm,selectedGroupIds:cm})&&cm(r,l)},U5=lz.memo(bz,xz);import Ez from"clsx";import{jsx as Y5,jsxs as wz}from"react/jsx-runtime";var yz="small",dm=e=>wz("label",{className:Ez("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${yz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Y5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Y5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as vz,useRef as Tz}from"react";import{jsx as W5}from"react/jsx-runtime";var V5=({trails:e})=>{let o=Tz(null);return vz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),W5("div",{className:"SVGLayer",children:W5("svg",{ref:o})})};import Iz,{useEffect as Cz,useRef as Sz}from"react";import{CURSOR_TYPE as X5,isShallowEqual as kz,sceneCoordsToViewportCoords as Mz}from"@excalidraw/common";import{jsx as Az}from"react/jsx-runtime";var Pz=e=>{let o=Sz(!1);return Cz(()=>{if(!o.current){o.current=!0;return}let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))r.has(d)||r.set(d,[]),r.get(d).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),n.set(m,Mz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Sv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:t,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Bi())}),Az("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?X5.GRAB:X5.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")})},K5=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}),Lz=(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:kz(K5(e.appState),K5(o.appState)),hf=Iz.memo(Pz,Lz);import Dz,{useEffect as Z5,useRef as $5}from"react";import{isShallowEqual as j5}from"@excalidraw/common";import{jsx as Nz}from"react/jsx-runtime";var _z=e=>{let o=$5(null),t=$5(!1);return Z5(()=>{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]),Z5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),S1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Bi())}),Nz("div",{className:"excalidraw__canvas-wrapper",ref:o})},q5=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}),Rz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:j5(q5(e.appState),q5(o.appState))&&j5(e.renderConfig,o.renderConfig),gf=Dz.memo(_z,Rz);import{useEffect as Uz,useRef as Yz}from"react";import{throttleRAF as Bz}from"@excalidraw/common";import{getTargetFrame as Fz,isInvisiblySmallElement as Oz,renderElement as zz,shouldApplyFrameClip as Hz}from"@excalidraw/element";var J5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=Vl(e,i),d=Xl({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(Oz(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=Fz(t,n,a);p&&Hz(t,p,a,n)&&I1(p,d,l,a)}zz(t,n,r,o,d,l,a)}else d.clearRect(0,0,s,m);d.restore()}},Gz=Bz(e=>{J5(e)},{trailing:!0}),Q5=(e,o)=>{if(o){Gz(e);return}J5(e)};import{jsx as Vz}from"react/jsx-runtime";var Wz=e=>{let o=Yz(null);return Uz(()=>{o.current&&Q5({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},Bi())}),Vz("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})},eI=Wz;import{useCallback as Xz,useEffect as Kz,useRef as Zz}from"react";import{jsx as tI,jsxs as jz}from"react/jsx-runtime";var $z=5e3,oI=({message:e,onClose:o,closable:t=!1,duration:n=$z,style:r})=>{let i=Zz(0),a=n!==1/0,l=Xz(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return Kz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),jz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[tI("p",{className:"Toast__message",children:e}),t&&tI(Z,{icon:zt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as qz,getElementsInGroup as Jz,selectGroupsFromGivenElements as Qz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as eH}from"@excalidraw/common";import{flushSync as tH}from"react-dom";import{jsx as nH}from"react/jsx-runtime";var oH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:Jz(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=qz(n),{x:a,y:l}=eH({sceneX:r,sceneY:i},e.state);return nH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{tH(()=>{let s=Qz(n,e.state);e.setState({selectedElementIds:n.reduce((m,d)=>({...m,[d.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Wa)},title:g("labels.elementLock.unlock"),children:Z1})},nI=oH;import{Fragment as eU,jsx as fe,jsxs as Em}from"react/jsx-runtime";var rC=Lo.createContext(null),iC=Lo.createContext(null),aC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Zf=Lo.createContext(aC);Zf.displayName="DeviceContext";var $f=Lo.createContext({container:null,id:null});$f.displayName="ExcalidrawContainerContext";var jf=Lo.createContext([]);jf.displayName="ExcalidrawElementsContext";var qf=Lo.createContext({...Qo(),width:0,height:0,offsetLeft:0,offsetTop:0});qf.displayName="ExcalidrawAppStateContext";var Jf=Lo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Jf.displayName="ExcalidrawSetAppStateContext";var Qf=Lo.createContext(null);Qf.displayName="ExcalidrawActionManagerContext";var Be=()=>zn(rC),xo=()=>zn(iC),de=()=>zn(Zf),Ne=()=>zn($f),an=()=>zn(jf),bo=()=>zn(qf),ae=()=>zn(Jf),We=()=>zn(Qf),Dl=!1,Uf=0,_l=null,Er=!1,Rl=!1,Yf=!1,Nl={horizontal:null,vertical:null},On=0,Bl=!1,Wf=new Map,Vf=!1,eC=0,tC=!1,Fl=null,ge={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Kf=class e extends Lo.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",aC);I(this,"excalidrawContainerRef",Lo.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 kG);I(this,"flowChartNavigator",new MG);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 dd);I(this,"laserTrails",new Ed(this.animationFrameHandler,this));I(this,"eraserTrail",new Td(this.animationFrameHandler,this));I(this,"lassoTrail",new vd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new gr);I(this,"onPointerDownEmitter",new gr);I(this,"onPointerUpEmitter",new gr);I(this,"onUserFollowEmitter",new gr);I(this,"onScrollChangeEmitter",new gr);I(this,"missingPointerEventCleanupEmitter",new gr);I(this,"onRemoveEventListenersEmitter",new gr);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...n)=>{let r=Ue.set(t,...n);return this.triggerRender(),r});I(this,"getEffectiveGridSize",()=>yn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),Al.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(jo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=Rf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else qi(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=He({clientX:i.x,clientY:i.y},this.state),l=He({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===um.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!_I(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}=gm({sceneX:i.x,sceneY:i.y},this.state),s=6,m,d=wG(i);if(i.id===this.state.editingFrame){let c=d;m=fe("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===V.ESCAPE||p.key===V.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?yH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Nn.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 m=d;return fe("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Nn.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Nn.nameFontSize,color:t?Nn.nameColorDarkTheme:Nn.nameColorLightTheme,lineHeight:Nn.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:_e.MOVE,pointerEvents:this.state.viewModeEnabled?Zi.disabled:Zi.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,n,r)=>{re("export",t,"ui");let i=await tr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(BH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Zl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Po.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&Df(t[0])&&t[0];if(!n&&t.some(i=>kt(i)||i.frameId)){this.setActiveTool({type:Po.magicframe});return}re("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ji(t),m=50;r=SI({...Nn,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let d of t)this.scene.mutateElement(d,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(rn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Et.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Et.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Fn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:Et.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ae(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||um.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(d=>{r?.id===d.id&&r!==d&&jI(d)&&po(d)&&(r=d)}),r?.isDeleted&&(r=null),this.setState(d=>{let c=t.appState||{};return{...d,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),n=!0}n||this.scene.triggerUpdate()}));I(this,"onBlur",Ae(()=>{Er=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ae(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Qo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let n=Sr(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=n.appState.activeTool;n.appState={...n.appState,theme:this.props.theme||n.appState.theme,openSidebar:n.appState?.openSidebar||this.state.openSidebar,activeTool:r.type==="image"||r.type==="lasso"||r.type==="selection"?{...r,type:this.defaultSelectionTool}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(n.appState={...n.appState,...Gn(n.elements,{...n.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...n,captureUpdate:Et.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Gf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,n)=>t<=YH||n<XH&&t<KH);I(this,"isTabletBreakpoint",(t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);return r>=WH&&i<=VH});I(this,"refreshViewportBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.device.viewport,a=Tf(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:fH,a=this.device.editor,l=Tf(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return this.setState({stylesPanelMode:this.isTabletBreakpoint(n,r)&&fr()?"compact":"full"}),a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Ae(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Al.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),gI||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Nl=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",xI(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},bH));I(this,"onCut",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Sl(t.target)||(this.actionManager.executeAction(uc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Sl(t.target)||(this.actionManager.executeAction(di,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(IH&&t.preventDefault(),!Dl){Dl=!0,t.touches.length===1&&(_l={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Uf),Uf=window.setTimeout(e.resetTapTwice,xH);return}if(Dl&&t.touches.length===1&&_l){let n=t.touches[0];Rn(ie(n.clientX,n.clientY),ie(_l.x,_l.y))<=UH&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),Dl=!1,clearTimeout(Uf)}t.touches.length===2&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}):ge.pointers.clear()});I(this,"pasteFromClipboard",Ae(async t=>{let n=!!Vf,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||Sl(r)))return;let l=await Oa(t),s=l.getFiles(),m=await EE(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(m,s,n),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let n=Lm(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=ji(n),s=$i(r,a)/2,m=$i(i,l)/2,d=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}=He({clientX:d,clientY:c},this.state),f=p-s,b=u-m,[x,y]=rt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=Mf({type:"everything",elements:n.map(P=>Fn(P,{x:P.x+x-r,y:P.y+y-i})),randomizeSeed:!t.retainSeed}),w=this.scene.getElementsIncludingDeleted(),v=[...w,...E];v=this.props.onDuplicate?.(v,w)||v,VI(v,fm(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let P=TG(E,S);Of(v,P,S,this.state)}this.scene.replaceAllElements(v),E.forEach(P=>{if(po(P)&&Af(P)){let B=OI(P,this.scene.getElementsMapIncludingDeleted());gG(P,B,this.scene)}}),kH&&Jo.loadElementsFonts(E).then(P=>{this.fonts.onLoaded(P)}),t.files&&this.addMissingFiles(t.files);let L=YG(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ue.get(gl)?this.state.openSidebar:null,...qt({editingGroupId:null,selectedElementIds:L.reduce((P,B)=>(Af(B)||(P[B.id]=!0),P),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,n)=>{this.setState(t,n)});I(this,"removePointer",t=>{On&&this.resetContextMenuTimer(),ge.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(n=>({activeTool:{...n.activeTool,...$o(this.state,n.activeTool.locked?{type:this.defaultSelectionTool}:n.activeTool),locked:!n.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Kx)});I(this,"zoomCanvas",t=>{this.setState({...Bo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:ho(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(Gf(t)?s=AG(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):Gf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=La({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Gn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,m=this.state.scrollY,d=this.state.zoom.value,c=NH({fromValues:{scrollX:s,scrollY:m,zoom:d},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,FH(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{c(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,cH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ae(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Mo.svg))try{let s=R1(FI(N1(l.dataURL)),Mo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ae(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?ZH({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));I(this,"applyDeltas",(t,n)=>{let r=JI.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return JI.applyTo(r,a,i,n)});I(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Ae(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Do().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});I(this,"onKeyDown",Ae(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!EI(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&br(a[0])&&t.key===V.ENTER){this.startImageCropping(a[0]);return}if(t.key===V.ESCAPE)this.updateEditorAtom(ao,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(GH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=xi(a);Ue.get(ao)?.type==="panel"&&Zu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(ao,{type:"panel"})}if(t.key===V.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=mm(t.key);if(t[V.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&lG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,UI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!_f(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=j(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),UI(t.key));if(m){this.setState(c=>({selectedElementIds:ve({[m]:!0},c)}));let d=this.scene.getNonDeletedElementsMap().get(m);d&&!_f([d],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(d,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[V.CTRL_OR_CMD]&&t.key===V.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Fe("commandPalette")})}),t.preventDefault();return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(Vf=t.shiftKey,clearTimeout(eC),eC=window.setTimeout(()=>{Vf=!1},100)),t[V.CTRL_OR_CMD]&&Sl(t.target)&&(t.code===dI.MINUS||t.code===dI.EQUAL)){t.preventDefault();return}if(Sl(t.target)&&t.key!==V.ESCAPE||mm(t.key)&&EI(t.target))return;if(t.key===V.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===V.E&&t.shiftKey&&t[V.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===V.PAGE_UP||t.key===V.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===V.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),mm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(Xe),s=new Set;a.filter(Xe).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let m=this.getEffectiveGridSize()&&(t.shiftKey?uI:this.getEffectiveGridSize())||(t.shiftKey?pH:uI),d=0,c=0;t.key===V.ARROW_LEFT?d=-m:t.key===V.ARROW_RIGHT?d=m:t.key===V.ARROW_UP?c=-m:t.key===V.ARROW_DOWN&&(c=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+d,y:p.y+c},{informMutation:!1,isDragging:!1}),Sf(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:kf(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[V.CTRL_OR_CMD]||xm(l))jt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Xe(l)||this.actionManager.executeAction(Di));else if(po(l)||hG(l)){let s;po(l)||(s=l);let m=Bf(l,this.state,this.scene.getNonDeletedElementsMap()),d=m.x,c=m.y;this.startTextEditing({sceneX:d,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=N2(t.key,this);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===Bn.sharp?Bn.round:l.currentItemArrowType===Bn.round?Bn.elbow:Bn.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===V.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===V.SPACE&&ge.pointers.size===0&&(Er=!0,ye(this.interactiveCanvas,_e.GRAB),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===V.G&&(go(this.state.activeTool.type)||a.some(l=>go(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===V.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[V.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===V.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>po(l)||Nf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===V.K&&!t.altKey&&!t[V.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[V.CTRL_OR_CMD]&&(t.key===V.BACKSPACE||t.key===V.DELETE)&&this.updateEditorAtom(lr,"clearCanvas");let n=t.key.toLocaleLowerCase(),r=n===V.S&&t.shiftKey,i=t.key===V.I||n===V.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));I(this,"onKeyUp",Ae(t=>{if(t.key===V.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,_e.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Ut(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Er=!1),!t[V.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),mm(t.key)&&(II(this.scene.getSelectedElements(this.state).filter(jt),Cf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Et.IMMEDIATELY})),!t[V.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ve({[n.id]:!0},r)})),_f([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Et.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=$o(this.state,t);r.type==="hand"?ye(this.interactiveCanvas,_e.GRAB):Er||Dt(this.interactiveCanvas,{...this.state,activeTool:r}),AH(document.activeElement)&&this.focusContainer(),iG(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,activeTool:r,...n?{}:{selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{ye(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Ut(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>ge.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${yI()}`);I(this,"onGestureStart",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null}),ge.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Ae(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=ge.initialScale;n&&this.setState(r=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ho(n*t.scale)},r)}))}));I(this,"onGestureEnd",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}),ge.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(Nf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,d=this.scene.getSelectedElements(this.state);d.length===1?po(d[0])?m=d[0]:i?m=Nf(d[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,n):m=this.getTextElementAtPosition(t,n);let c=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||bI(c),u=this.state.currentItemFontSize;if(!m&&l&&i&&!Pf(i)){let y=NG(wf({fontSize:u,fontFamily:c}),p),E=BG(u,p),w=Math.max(i.height,E),v=Math.max(i.width,y);this.scene.mutateElement(i,{height:w,width:v}),t=i.x+v/2,n=i.y+w/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=m||kI({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?vH.MIDDLE:pI,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Pf(i)?0:i.angle:0,frameId:f?f.id:null});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=He(t,this.state);if(n.length===1&&jt(n[0])){let l=n[0];if((t[V.CTRL_OR_CMD]&&JG(l)||xm(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Di);return}else if(this.state.selectedLinearElement&&Xe(n[0])){let s=Ie.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Ie.deleteFixedSegment(n[0],this.scene,m);let d=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=d?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&xm(l))return}if(n.length===1&&br(n[0])){this.startImageCropping(n[0]);return}if(Ut(this.interactiveCanvas),GG(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&HG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...qt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(Ut(this.interactiveCanvas),!t[V.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Pl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(PI(s)||!RH(s.backgroundColor)||Ll({point:ie(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=Bf(s,this.state,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&Wl(l,this.scene.getNonDeletedElementsMap(),this.state,ie(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,n)=>{let r=Rn(ie(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ie(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>mH)return;let i=He(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Wl(this.hitLinkElement,a,this.state,ie(i.x,i.y),this.device.editor.isMobile),s=He(this.lastPointerUpEvent,this.state),m=Wl(this.hitLinkElement,a,this.state,ie(s.x,s.y),this.device.editor.isMobile);if(l&&m){Fu();let d=this.hitLinkElement.link;if(d){d=yf(d);let c;if(this.props.onLinkOpen&&(c=DH(te.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:d},c)),!c?.defaultPrevented){let p=MH(d)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=d)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&zI(t,i,n));return r.length?r[r.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ge.pointers.has(t.pointerId)&&ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let n=ge.initialScale;if(ge.pointers.size===2&&ge.lastCenter&&n&&ge.initialDistance){let f=Xh(ge.pointers),b=f.x-ge.lastCenter.x,x=f.y-ge.lastCenter.y;ge.lastCenter=f;let y=Kh(Array.from(ge.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/ge.initialDistance,w=E?ho(n*E):this.state.zoom.value;this.setState(v=>{let C=Bo({viewportX:f.x,viewportY:f.y,nextZoom:w},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/w),scrollY:C.scrollY+2*(x/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ge.lastCenter=ge.initialDistance=ge.initialScale=null;if(Er||Rl||Yf||Qt(this.state))return;let i=tg(Nl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Ut(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state));let a=He(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&iv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=rv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let y=kl(x.snapLines,b),E=x.originSnapOffset?kl(x.originSnapOffset,f):f;return x.snapLines===y&&x.originSnapOffset===E?null:{snapLines:y,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=Ie.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Ki(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&LI(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(LI(this.state.activeTool.type)){let{newElement:f}=this.state;Lf(f,!1)?this.setState({suggestedBindings:vI(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:y,lastCommittedPoint:E}=f,w=y[y.length-1];if(Dt(this.interactiveCanvas,this.state),w===E)Rn(ie(l-b,s-x),w)>=Ef?this.scene.mutateElement(f,{points:[...y,ie(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,_e.POINTER);else if(y.length>2&&E&&Rn(ie(l-b,s-x),E)<Ef)ye(this.interactiveCanvas,_e.POINTER),this.scene.mutateElement(f,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=rt(l,s,t[V.CTRL_OR_CMD]||Xe(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],P=v-b-S,B=C-x-L;xf(t)&&({width:P,height:B}=DI(S+b,L+x,v,C)),NI(y,this.state.zoom.value)&&ye(this.interactiveCanvas,_e.POINTER),this.scene.mutateElement(f,{points:[...y.slice(0,-1),ie(S+P,L+B)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=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&&Xe(c[0]))){let f=KI(d,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){ye(this.interactiveCanvas,XI(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=ZI(ji(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){ye(this.interactiveCanvas,XI({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),!yt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,_e.POINTER),fy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Fu(),u&&(u.link||jo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,po(u)?_e.TEXT:_e.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,_e.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,_e.AUTO):i?ye(this.interactiveCanvas,_e.AUTO):t[V.CTRL_OR_CMD]?ye(this.interactiveCanvas,_e.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&Pl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(ye(this.interactiveCanvas,_e.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!Xe(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&ye(this.interactiveCanvas,_e.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:kl(f.hoveredElementIds,qt({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:kl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{Bl=!0});I(this,"handleCanvasPointerDown",t=>{let n=t.target;if(n.setPointerCapture&&n.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Fg,null)),Ue.get(ao)&&this.updateEditorAtom(ao,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:ve(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"?Et.EVENTUALLY:Et.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Tf(this.device,{isTouchScreen:!0})),Rl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===hr.ERASER&&this.state.activeTool.type!==Po.eraser){this.setState({activeTool:$o(this.state,{type:Po.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),yt(this.state)&&this.setState({activeTool:$o(this.state,{...this.state.activeTool.lastActiveTool||{type:Po.selection},lastActiveToolBeforeEraser:null})})},p=Re(window,te.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==hr.MAIN&&t.button!==hr.TOUCH&&t.button!==hr.ERASER||ge.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let c=i.hit.element&&this.isASelectedElement(i.hit.element);!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!fr()),fr()&&i.hit.element&&!c&&(this.setState(p=>{let u={...p.selectedElementIds,[i.hit.element.id]:!0},f=[];Object.keys(p.selectedElementIds).forEach(x=>{let y=this.scene.getElement(x);y&&f.push(y)});let b=i.hit.element;if(kt(b))Ff(f,b.id).forEach(x=>{delete u[x.id]});else if(b.frameId)u[b.frameId]&&delete u[b.id];else{let x=b.groupIds,y=new Set(x.flatMap(E=>xr(this.scene.getNonDeletedElements(),E)).filter(E=>kt(E)).map(E=>E.id));y.size>0&&f.forEach(E=>{E.frameId&&y.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(w=>xr(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return{...qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:b.link||jo(b)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Dt(this.interactiveCanvas,this.state):this.state.activeTool.type===Po.frame||this.state.activeTool.type===Po.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),m=this.onKeyDownFromPointerDownHandler(i),d=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(te.POINTER_MOVE,l),window.addEventListener(te.POINTER_UP,s),window.addEventListener(te.KEYDOWN,m),window.addEventListener(te.KEYUP,d),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=d,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let n=He({clientX:t.clientX,clientY:t.clientY},this.state),r=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(Pl(i)&&this.isIframeLikeElementCenter(i,t,n.x,n.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?r<300&&Pl(this.hitLinkElement)&&!y1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ie(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Bl=!1,On?Bl=!0:On=window.setTimeout(()=>{On=0,Bl||this.handleCanvasContextMenu(t)},wH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(On),On=0,Bl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Fl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ge.pointers.size<=1&&(t.button===hr.WHEEL||t.button===hr.MAIN&&Er||Qt(this.state)||this.state.viewModeEnabled)))return!1;Rl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,_e.GRABBING);let{clientX:i,clientY:a}=t,l=yd(m=>{let d=i-m.clientX,c=a-m.clientY;if(i=m.clientX,a=m.clientY,r&&!n&&(Math.abs(d)>1||Math.abs(c)>1)){n=!0;let p=f=>{document.body.removeEventListener(te.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(te.PASTE,p),window.removeEventListener(te.POINTER_UP,u)},100)};document.body.addEventListener(te.PASTE,p),window.addEventListener(te.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=Ae(Fl=()=>{Fl=null,Rl=!1,Er||(this.state.viewModeEnabled?ye(this.interactiveCanvas,_e.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(te.POINTER_MOVE,l),window.removeEventListener(te.POINTER_UP,s),window.removeEventListener(te.BLUR,s),l.flush()});return window.addEventListener(te.BLUR,s),window.addEventListener(te.POINTER_MOVE,l,{passive:!0}),window.addEventListener(te.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,n)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Xe(a[0])&&!(xm(a[0])&&Ie.getPointIndexUnderCursor(a[0],i,this.state.zoom,n.origin.x,n.origin.y)!==-1)&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=KI(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=ZI(ji(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=vf(VG(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&jt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=XG(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ie.handlePointerDown(t,this,this.store,n.origin,p,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let d=n.hit.element,c=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!c)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ve({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(d!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...zG(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!WI(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),kt(d))Ff(f,d.id).forEach(b=>{delete u[b.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let b=d.groupIds,x=new Set(b.flatMap(y=>xr(this.scene.getNonDeletedElements(),y)).filter(y=>kt(y)).map(y=>y.id));x.size>0&&f.forEach(y=>{y.frameId&&x.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(E=>xr(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(b=>p.selectedGroupIds[b])||(u={[d.id]:!0})),{...qt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||jo(d)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);PI(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Ut(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:$o(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=rt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,m=JH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[ie(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(m),this.setState(c=>{let p={...c.selectedElementIds};return delete p[m.id],{selectedElementIds:ve(p,c)}});let d=If(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:m,startBoundElement:d,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=QH({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=bm(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=CI({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=rt(t,n,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return oG({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&NI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(_t);return}if(Xe(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(_t);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Rn(ie(r.origin.x-a,r.origin.y-l),s)<Ef){this.actionManager.executeAction(_t);return}this.setState(m=>({selectedElementIds:ve({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,_e.POINTER)}else{let[i,a]=rt(r.origin.x,r.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[d,c]=n==="arrow"?[s,m]:[null,null],p=n==="arrow"?eG({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Bn.round?{type:pm.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Bn.elbow,fixedSegments:this.state.currentItemArrowType===Bn.elbow?[]:null}):nG({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:pm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ve(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,ie(0,0)]});let u=If(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,Xe(p),Xe(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=rt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=CI({type:"embeddable",...l}):s=tG({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=rt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Nn},l=n===Po.magicframe?SI(a):qH(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Af(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Fn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});I(this,"initializeImage",async(t,n)=>{if(!Am(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(ye(this.interactiveCanvas,"wait"),r===Mo.svg)try{n=Nm(FI(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||_1(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await jl(n,{maxWidthOrHeight:dH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>hI)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(hI/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Rm(n);return new Promise(async(s,m)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([d]);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!==d.id){d=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(d,c);Object.assign(d,p)}s(d)}catch(d){console.error(d),m(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Fn(r,{fileId:n})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=He({clientX:t,clientY:n},this.state),a=await Ul({description:"Image",extensions:Object.keys(uH),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:$o(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(_t)})}});I(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await uG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Et.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ml(a)&&i.has(a.fileId)?Fn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=pG(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&Al.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",rH(()=>{this.addNewImagesToImageCache()},hH));I(this,"updateBindingEnabledOnPointerMove",t=>{let n=jH(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});I(this,"maybeSuggestBindingAtCursor",(t,n)=>{let r=If(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(te.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(te.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(te.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(te.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=QI(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,await ia(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Fn(p,{isDeleted:!0})}})),s=fm(l),m=QI(l.filter(p=>!p.isDeleted),n,r,i),d=fm(m),c=this.scene.getElementsIncludingDeleted().map(p=>d.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ve(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:c,captureUpdate:Et.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(_t)})});I(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=He(t,this.state),i=await Oa(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:p}=a[0];if(c&&(c.type===Mo.png||c.type===Mo.svg))try{let u=await $l(c,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Et.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Am(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(Mo.excalidrawlibIds),m=i.getData(Mo.excalidrawlib);if(s||m){try{let c=null;if(s){let{itemIds:p}=JSON.parse(s);c=(await this.library.getLatestLibrary()).filter(f=>p.includes(f.id))}else m&&(c=D1(m));c?.length&&(c=c.map(p=>({...p,elements:Mf({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Lc(c),position:t,files:null}))}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:p}=a[0];c&&await this.loadFileToCanvas(c,p)}let d=i.findByType(Mo.text);if(d){let c=d.value;if(c&&Rf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||bm(c)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:yf(c)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,n)=>{t=await ia(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Dm(t,this.state,r,n)}catch(a){let l=a instanceof b1;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===Mo.excalidraw?(nC(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Et.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Et.IMMEDIATELY})):i.type===Mo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==hr.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:n,y:r}=He(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:d,left:c}=m.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-d;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...qt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:jt(i)?new Ie(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){$I({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:$i(t.origin.x,a.x),height:$i(t.origin.y,a.y),shouldMaintainAspectRatio:Cl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=rt(a.x,a.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Ml(l)&&this.imageCache.get(l.fileId)?.image,c=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=nv(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),$I({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:$i(t.originInGrid.x,s),height:$i(t.originInGrid.y,m),shouldMaintainAspectRatio:br(l)?!Cl(n):Cl(n),shouldResizeFromCenter:mI(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Po.frame||this.state.activeTool.type===Po.magicframe)&&this.setState({elementsToHighlight:zf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=rt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&br(s)){let m=t.originalElements.get(s.id),d=Ml(s)&&this.imageCache.get(s.fileId)?.image;if(m&&br(m)&&d&&!(d instanceof Promise)){let[c,p]=rt(i.x,i.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=qh([s],[m],this,n,u,r);this.scene.mutateElement(s,PG(s,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+f.x,l+f.y,n.shiftKey?m.width/m.height:void 0)),Sf(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(c=>kt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Xe(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=rt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(c=>{Ff(this.scene.getNonDeletedElements(),c.id).forEach(u=>{d.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=rt(l.x,l.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=qh(r,j(f,this.state),this,n,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(KG(t.originalElements,a,r,this.scene,xf(n),mI(n),r.some(c=>br(c))?!Cl(n):Cl(n),s,m,t.resize.center.x,t.resize.center.y)){let c=kf(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{zf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});I(this,"getContextMenuItems",t=>{let n=[];return n.push(gc,hc),t==="canvas"?this.state.viewModeEnabled?[...n,bc,mi,Wh,pi]:[Tu,Ve,gc,hc,fc,Ve,gp,vy,Ve,bc,Iu,mi,Wh,pi]:(n.push(fc),this.state.viewModeEnabled?[di,...n]:[Ve,uc,di,Tu,Ve,Nw,Bw,Fw,Ve,Hh,Ve,...n,Ve,pu,uu,Ve,fu,Ww,ku,Mu,ly,bu,Ve,yu,Ve,mp,pp,up,hp,Ve,wu,vu,Ve,Di,Ve,Ya,Cc,Ve,fp,Wa,Ve,fa])});I(this,"handleWheel",Ae(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Rl)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=TH*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(d=>({...Bo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:ho(m)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));I(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=He({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:ge.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",xI(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:m,offsetTop:d,offsetLeft:c}=this.state;if(r===s&&i===m&&a===c&&l===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=Qo();this.defaultSelectionTool=fr()?"lasso":"selection";let{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=n.theme,name:d=`${g("labels.untitled")}-${yI()}`}=t;if(this.state={...n,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight},this.id=aH(),this.library=new Zy(this),this.actionManager=new cd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new qI,this.canvas=document.createElement("canvas"),this.rc=iH.canvas(this.canvas),this.renderer=new pl(this.scene),this.visibleElements=[],this.store=new jG(this),this.history=new ll(this.store),r){let c={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof r=="function"?r(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Jo(this.scene),this.history=new ll(this.store),this.actionManager.registerAll(xs),this.actionManager.registerAction(Hw(this.history)),this.actionManager.registerAction(Gw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(hm).includes(i)&&Wf.set(r,i)}break}}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),qi(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=Wf.get(t.id);switch(r||(Wf.set(t.id,hm.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case hm.PLAYING:case hm.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>jo(a)&&this.embedsValidationStatus.get(a.id)===!0||qi(a));return fe(eU,{children:i.map(a=>{let{x:l,y:s}=gm({sceneX:a.x,sceneY:a.y},this.state),m=_I(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(m&&!d&&this.initializedEmbeds.add(a.id),!(m||d))return null;let p;if(qi(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:()=>BI(`
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===um.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:()=>BI(`
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: ${sH.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=ii(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 Oe("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,oi(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?Un.enabled:Un.disabled},children:[g&&Oe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Oe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ft(a)?this.props.renderEmbeddable?.(a,this.state):null)??Oe("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 Oe("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?Un.disabled:Un.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:Oe(T5.Provider,{value:this,children:Oe(C5.Provider,{value:this.props,children:Oe(bf.Provider,{value:this.excalidrawContainerValue,children:Oe(ff.Provider,{value:this.device,children:Oe(yf.Provider,{value:this.setAppState,children:Oe(Ef.Provider,{value:this.state,children:tp(xf.Provider,{value:this.scene.getNonDeletedElements(),children:[tp(vf.Provider,{value:this.actionManager,children:[Oe(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}),Oe("div",{className:"excalidraw-textEditorContainer"}),Oe("div",{className:"excalidraw-contextMenuContainer"}),Oe("div",{className:"excalidraw-eye-dropper-container"}),Oe(m5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Oe(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)&&Oe(Ig,{element:m,elementsMap:a,children:Oe(Qm,{title:f("labels.convertToCode"),icon:nd,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&$n(m)&&m.customData?.generationData?.status==="done"&&tp(Ig,{element:m,elementsMap:a,children:[Oe(Qm,{title:f("labels.copySource"),icon:ca,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Oe(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&&Oe(E5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Oe(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?.()})}}),Oe(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&&Oe(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}}),Oe(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&&Oe(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,dt()||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(),dt()||(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:Oe(pw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new dn,this.fonts=new un(this.scene),this.renderer=new ss(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(On),ze.clearCache(),ht.clearCache(),On=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(We(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(We(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),We(window,"message",this.onWindowMessage,!1),We(document,"pointerup",this.removePointer,{passive:!1}),We(document,"copy",this.onCopy,{passive:!1}),We(document,"keyup",this.onKeyUp,{passive:!0}),We(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),We(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),We(document,"gesturestart",this.onGestureStart,!1),We(document,"gesturechange",this.onGestureChange,!1),We(document,"gestureend",this.onGestureEnd,!1),We(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(We(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),We(document,"paste",this.pasteFromClipboard,{passive:!1}),We(document,"cut",this.onCut,{passive:!1}),We(window,"resize",this.onResize,!1),We(window,"unload",this.onUnload,!1),We(window,"blur",this.onBlur,!1),We(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),We(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),We(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(We(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&&Qn(this.state)&&_r(s,!1)&&hl(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(){Es=!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=bm(PH(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return fe("div",{className:rI("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:OG(a,Hf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?SH:1),"--embeddable-radius":`${dG(Math.min(a.width,a.height),a)}px`},children:Em("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Zi.enabled:Zi.disabled},children:[f&&fe("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),fe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(jo(a)?this.props.renderEmbeddable?.(a,this.state):null)??fe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderCustomStats:r}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",d=t[0],c=Ue.get(ao)?.type==="panel";return fe("div",{className:rI("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?Zi.disabled:Zi.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:fe(rC.Provider,{value:this,children:fe(iC.Provider,{value:this.props,children:fe($f.Provider,{value:this.excalidrawContainerValue,children:fe(Zf.Provider,{value:this.device,children:fe(Jf.Provider,{value:this.setAppState,children:fe(qf.Provider,{value:this.state,children:Em(jf.Provider,{value:this.scene.getNonDeletedElements(),children:[Em(Qf.Provider,{value:this.actionManager,children:[fe(U5,{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:Do().code,renderTopRightUI:n,renderCustomStats:r,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),fe("div",{className:"excalidraw-textEditorContainer"}),fe("div",{className:"excalidraw-contextMenuContainer"}),fe("div",{className:"excalidraw-eye-dropper-container"}),fe(V5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&fe(hy,{element:d,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),this.props.aiEnabled!==!1&&t.length===1&&Df(d)&&fe(dg,{element:d,elementsMap:a,children:fe(dm,{title:g("labels.convertToCode"),icon:hs,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,"button")})}),t.length===1&&qi(d)&&d.customData?.generationData?.status==="done"&&Em(dg,{element:d,elementsMap:a,children:[fe(dm,{title:g("labels.copySource"),icon:Rr,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),fe(dm,{title:"Enter fullscreen",icon:cb,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(d);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:"active"},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&fe(oI,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&fe(i3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),fe(gf,{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:yn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&fe(eI,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),fe(hf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&fe(l3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&fe(nI,{app:this,activeLockedId:this.state.activeLockedId}),c&&fe(Ay,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=vG(this.scene.getNonDeletedElements(),t).filter(l=>!Df(l));if(!i.length){n==="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 r({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"&&(ro(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ml(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),Al.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Xf()||oC()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Xf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),gI&&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),gH()&&!DG()&&this.setState({errorMessage:fe(t3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new qI,this.fonts=new Jo(this.scene),this.renderer=new pl(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(),Al.destroy(),Xt.destroy(),clearTimeout(On),we.clearCache(),qt.clearCache(),On=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Re(document,te.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Re(this.excalidrawContainerRef.current,te.WHEEL,this.handleWheel,{passive:!1}),Re(window,te.MESSAGE,this.onWindowMessage,!1),Re(document,te.POINTER_UP,this.removePointer,{passive:!1}),Re(document,te.COPY,this.onCopy,{passive:!1}),Re(document,te.KEYUP,this.onKeyUp,{passive:!0}),Re(document,te.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Re(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Re(document,te.GESTURE_START,this.onGestureStart,!1),Re(document,te.GESTURE_CHANGE,this.onGestureChange,!1),Re(document,te.GESTURE_END,this.onGestureEnd,!1),Re(window,te.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Re(document,te.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Re(document,te.PASTE,this.pasteFromClipboard,{passive:!1}),Re(document,te.CUT,this.onCut,{passive:!1}),Re(window,te.RESIZE,this.onResize,!1),Re(window,te.UNLOAD,this.onUnload,!1),Re(window,te.BLUR,this.onBlur,!1),Re(this.excalidrawContainerRef.current,te.WHEEL,this.handleWheel,{passive:!1}),Re(this.excalidrawContainerRef.current,te.DRAG_OVER,this.disableEvent,!1),Re(this.excalidrawContainerRef.current,te.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Re(LH(this.excalidrawContainerRef.current),te.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&yt(this.state)&&this.setState({activeTool:$o(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&qp(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),yt(n)&&!yt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===um.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(_t)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Dl=!1,_l=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=He({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!r){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=n.map(d=>d.file);if(l.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&l.push(Nm(d))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let d=t.programmaticAPI?Ni(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:fr()?"center":"cursor",retainSeed:r});return}if(!t.text)return;if(!r&&zv(t.text)){let d=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:c,files:p}=await d.parseMermaidToExcalidraw(t.text),u=Ni(c,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:fr()?"center":"cursor"});return}catch(c){console.warn(`parsing pasted text as mermaid definition failed: ${c.message}`)}}let s=OH(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),m=s.map(d=>mG(d)).filter(d=>Rf(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||bm(d)?.type==="video"));if(!r&&m.length>0&&m.length===s.length){let d=[];for(let c of m){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:yf(c)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(c=>[c.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),l=await Promise.all(a.map(async d=>{try{return{file:await B1(d)}}catch(c){let p=c.message;return c.cause==="FETCH_ERROR"?p=g("errors.failedToFetchImage"):c.cause==="UNSUPPORTED"&&(p=g("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(s,r,i);let m=l.find(d=>!!d.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
109
117
 
110
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=Ye({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:Rs,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=Jn(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=Ht(y,l,s),S=C.width>d,_=S?Hi(y,l,d):y;C=S?Ht(_,l,s):C;let L=n-C.width/2,N=u-C.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;Nn(()=>{this.setState(m=>({selectedElementIds:Me({...m.selectedElementIds,[c]:!0},m)}))})}s&&lc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),Nn(()=>{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:ie(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=oi(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?zp({x:t,y:r},m,l):!0}).filter(c=>$n(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:ie(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]=Ke(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=Ye(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(ut(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,io(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;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(()=>{ws=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 ws=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=Ye(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=ut(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());Nn(()=>{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]=ut(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")&&Vn(M(n.x,n.y),M(t.origin.x,t.origin.y))<Hn)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;Nn(()=>{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=>ie(x)),g=this.getTopLayerFrameAtSceneCoords(n),b=g&&!u?g:null;if(this.state.frameToHighlight!==b&&Nn(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let C=Math.abs(x.x),S=Math.abs(x.y),_=w&&C<S,L=w&&C>S;_&&(x.x=0),L&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&he(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,_=Ar(C)&&this.imageCache.get(C.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,U,W,V,q]=Ke(C,c),F=Ws(se(M(N,P),M(V,q),C.angle)),z=Ws(se(M(U,P),M(V,q),C.angle)),G=Ws(se(M(N,W),M(V,q),C.angle)),ne=vp(yp(z,F)),X=vp(yp(G,F)),le=xp(Ep(L,ne),Ep(L,X)),be={...S,x:Tt(S.x-le[0]*Math.sign(C.scale[0]),0,_.naturalWidth-S.width),y:Tt(S.y-le[1]*Math.sign(C.scale[1]),0,_.naturalHeight-S.height)};B(C,{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 C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,_=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!_.find(z=>z.id===S.id)&&_.push(S);let L=new Map(_.map(z=>[z.id,z])),{duplicatedElements:N,duplicateElementsMap:P,elementsWithDuplicates:U,origIdToDuplicateId:W}=si({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:L,overrides:({duplicateElement:z,origElement:G})=>({frameId:z.frameId??G.frameId,seed:Lr()})});N.forEach(z=>{t.originalElements.set(z.id,io(z))});let V=U.map(z=>{if(L.has(z.id)){let G=t.originalElements.get(z.id);if(G)return oe(z,{x:G.x,y:G.y})}return z}),q=this.props.onDuplicate?.(V,C),F=Ut(q||V,ee(N));Nn(()=>{if(t.hit.element){let z=W.get(t.hit.element.id),G=z&&P.get(z);t.hit.element=G||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,G)=>{let ne=W.get(G.id),X=ne&&P.get(ne);return X&&z.push(X),z},[]),t.drag.origin=Ye(r,this.state),this.setState(z=>({...gc(N,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(F),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(ce(p)){t.drag.hasOccurred=!0;let u=p.points,g=l-p.x,b=s-p.y;Ys(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=>ht({...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},{...ht({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:g.length===1&&ce(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);jn(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=Ye(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(ce(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let x=Ye(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&&(Qn(this.state)&&_r(n,!1)&&hl(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&&ti(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ie(n)){let x=wb(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Wi(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(B(n,fb(n)),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ye(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=oi(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=C=>{if(C.length>0){for(let S of C){let _=S.groupIds.indexOf(this.state.editingGroupId);B(S,{groupIds:S.groupIds.slice(0,_)},!1)}y.forEach(S=>{S.groupIds.length&&Fe(y,S.groupIds[S.groupIds.length-1]).length<2&&B(S,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let C=w.filter(S=>S.frameId!==E.id&&Fp(S,y,this.state));this.state.editingGroupId&&v(C),y=Wi(y,C,E,this.state)}else if(!E&&this.state.editingGroupId){let C=w.filter(S=>S.frameId&&!Fp(S,y,this.state));v(C)}y=lr(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.shouldCaptureIncrement(),i&&ti(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=>ie(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&&ce(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(),Vn(M(g.clientX,g.clientY),M(b.clientX,b.clientY))===0){let E=Ye({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{...ht({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&ce(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]}),{...ht({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=>({...ht({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:ce(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:ie(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(ce);ei(x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Qn(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({})}},W8=()=>{(dt()||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}}}))};W8();var S5=gf;import{useEffect as Z8,useState as X8}from"react";import{jsx as $8}from"react/jsx-runtime";var k5=e=>{let[o,t]=X8(!0);return Z8(()=>{let r=async()=>{await Wc(n),t(!1)},n=na.find(i=>i.code===e.langCode)||pr;r()},[e.langCode]),o?$8(vm,{theme:e.theme}):e.children};import j8 from"clsx";import{jsx as M5}from"react/jsx-runtime";var L5=({children:e})=>{let{FooterCenterTunnel:o}=Ze(),t=Pe();return M5(o.In,{children:M5("div",{className:j8("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},q8=L5;L5.displayName="FooterCenter";import J8 from"clsx";import{jsx as eA,jsxs as tA}from"react/jsx-runtime";var A5=({isCollaborating:e,onSelect:o,...t})=>{let r=Pe(),n=r.width<830;return tA(vo,{...t,className:J8("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&&eA("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},Q8=A5;A5.displayName="LiveCollaborationTrigger";import{jsx as zn,jsxs as D5}from"react/jsx-runtime";var oA=()=>zn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:zn("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"})}),rA=()=>D5("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[zn("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)"}),zn("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)"}),zn("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)"}),zn("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:[zn(oA,{}),t&&zn(rA,{})]});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 Ts=({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})});Ts.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}=Ze();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(Ts,{onSelect:()=>e.executeAction(wi),shortcut:"?",icon:la,children:f("helpDialog.title")})};kf.displayName="MenuItemHelp";var Mf=()=>{let e=Pe(),o=ft();return e.viewModeEnabled?null:xt(Ts,{onSelect:()=>o.executeAction(wa),shortcut:st("loadScene"),icon:sa,children:f("buttons.load")})};Mf.displayName="MenuItemLoadScene";var R5=({onSelect:e})=>{let{t:o}=pt();return xt(Ts,{shortcut:null,onSelect:e,icon:Qc,children:o("labels.liveCollaboration")})};R5.displayName="MenuItemLiveCollaborationTrigger";Fo.Logo=Cf;Fo.Heading=If;Fo.Menu=Sf;Fo.MenuItem=Ts;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}=Ze();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}=Ze();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}=Ze();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 Cs,jsxs as iA}from"react/jsx-runtime";var ip=e=>Cs(O5,{children:e.children||iA(O5,{children:[Cs(Fo,{}),Cs(op,{}),Cs(rp,{}),Cs(np,{})]})});ip.displayName="WelcomeScreen";ip.Center=Fo;ip.Hints={MenuHint:op,ToolbarHint:rp,HelpHint:np};var nA=ip;var aA=()=>{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=aA;import lA from"lodash.throttle";var sA=(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)),cA=lA((e,o,t)=>{if(Ue()||dt()||window?.DEBUG_FRACTIONAL_INDICES){let r=Pr(e.map(n=>({...n})));Fb(r,{shouldThrow:dt()||Ue(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),dA=(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=sA(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 cA(a,e,o),Pr(a),a};import{jsx as z5,jsxs as mA}from"react/jsx-runtime";var F5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ze(),r=Ie();return z5(t.In,{children:mA(Re.Item,{onSelect:()=>{xe("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??hE,children:[e??f("labels.textToDiagram"),z5(Re.Item.Badge,{children:"AI"})]})})};F5.displayName="TTDDialogTrigger";import{useLayoutEffect as pA}from"react";var uA=e=>{let o=lt();return pA(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as Af}from"react/jsx-runtime";B5();var fA=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:C,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,children:U,validateEmbeddable:W,renderEmbeddable:V,aiEnabled:q,showDeprecatedFonts:F}=e,z=e.UIOptions?.canvasActions,G={...e.UIOptions,canvasActions:{...pp.canvasActions,...z},tools:{image:e.UIOptions?.tools?.image??!0}};return z?.export&&(G.canvasActions.export.saveFileToDisk=z.export?.saveFileToDisk??pp.canvasActions.export.saveFileToDisk),G.canvasActions.toggleTheme===null&&typeof p>"u"&&(G.canvasActions.toggleTheme=!0),gA(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let X=le=>{typeof le.scale=="number"&&le.scale!==1&&le.preventDefault()};return document.addEventListener("touchmove",X,{passive:!1}),()=>{document.removeEventListener("touchmove",X)}},[]),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:G,onPaste:b,detectScroll:x,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:y,generateIdForFile:v,onLinkOpen:C,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,validateEmbeddable:W,renderEmbeddable:V,aiEnabled:q!==!1,showDeprecatedFonts:F,children:U})})})},bA=(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)},xA=hA.memo(fA,bA);xA.displayName="Excalidraw";export{vo as Button,A as CaptureUpdateAction,lp as DEFAULT_LASER_COLOR,Bm as DefaultSidebar,uA as DiagramToCodePlugin,xA as Excalidraw,Bt as FONT_FAMILY,q8 as Footer,Q8 as LiveCollaborationTrigger,ue as MIME_TYPES,Ot as MainMenu,eo as ROUNDNESS,zo as Sidebar,gs as Stats,de as THEME,jg as TTDDialog,F5 as TTDDialogTrigger,h1 as UserIdleState,nA as WelcomeScreen,bl as bumpVersion,Fa as convertToExcalidrawElements,pr as defaultLang,V5 as elementPartiallyOverlapsWithOrContainsBBox,Y5 as elementsOverlappingBBox,I2 as exportToBlob,Tn as exportToCanvas,AC 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,ai as isElementLink,ti as isInvisiblySmallElement,ce 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,dA as reconcileElements,ta as restore,K5 as restoreAppState,tu as restoreElements,Cl as restoreLibraryItems,zt as sceneCoordsToViewportCoords,wl as serializeAsJSON,eu as serializeLibraryAsJSON,H5 as setCustomTextMetricsProvider,Ce as useDevice,OC as useHandleLibrary,pt as useI18n,Ye as viewportCoordsToSceneCoords,By as zoomToFitBounds};
118
+ `),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=He({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:CH,verticalAlign:pI,locked:!1},l=wf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=bI(a.fontFamily),[m,,d]=SG(this.state),c=Math.max(Math.min((d-m)*.5,800),200),p=10,u=i,f=n?[t]:t.split(`
119
+ `),b=f.reduce((x,y,E)=>{let w=_G(y).trim();if(w.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),C=YI(w,l,s),S=C.width>c,L=S?LG(w,l,c):w;C=S?YI(L,l,s):C;let P=r-C.width/2,B=u-C.height/2,k=kI({...a,x:P,y:B,text:L,originalText:w,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(k),u+=k.height+p}else f[E-1]?.trim()&&(u+=RG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ve(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&tC===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:_H("CtrlOrCmd+Shift+V")}),duration:5e3}),tC=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&po(s)?Fn(s,{originalText:a,isDeleted:l??s.isDeleted,...rG(s,OI(s,r),r,a)}):s)])};Ov({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=gm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Ae(a=>{i(a,!1),jI(t)&&Sf(t,this.scene)}),onSubmit:Ae(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;Ki(()=>{this.setState(d=>({selectedElementIds:ve({...d.selectedElementIds,[m]:!0},d)}))})}s&&$H(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Ki(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Dt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&po(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Ll({point:ie(t,n),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,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(po(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let m=Hf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?zI({x:t,y:n},m,a):!0}).filter(s=>qi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(fI/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&fG([r],this.state)&&qG(ie(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||IG(ie(t,n),r,this.scene.getNonDeletedElementsMap())?!0:Ll({point:ie(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:kt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return AI(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,m,d,c]=TI(r[l],this.scene.getNonDeletedElementsMap());if(Pf(r[l])&&Ll({point:ie(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<d&&m<n&&n<c){a=r[l];break}}return AI(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Ie.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Ll({point:ie(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Ie.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Ie.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Xe(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,_e.POINTER):this.hitElement(n,r,a)&&(!Xe(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,_e.MOVE)):this.hitElement(n,r,a)&&(!Xe(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,_e.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Ie.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ye(this.interactiveCanvas,_e.AUTO)}updateGestureOnPointerDown(t){ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ge.pointers.size===2&&(ge.lastCenter=Xh(ge.pointers),ge.initialScale=this.state.zoom.value,ge.initialDistance=Kh(Array.from(ge.pointers.values())))}initialPointerDownState(t){let n=He(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ji(r),m=r.findIndex(Xe)===0;return{origin:n,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:vf(rt(n.x,n.y,t[V.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:tg(Nl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((d,c)=>(d.set(c.id,MI(c)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;Yf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=yd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Ae(()=>{Fl=null,Yf=!1,Dt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(te.POINTER_MOVE,r),window.removeEventListener(te.POINTER_UP,i),r.flush()});return Fl=i,window.addEventListener(te.POINTER_MOVE,r),window.addEventListener(te.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(fI/this.state.zoom.value,1),[i,a,l,s]=ji(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:aG(t)?pm.ADAPTIVE_RADIUS:pm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){Wo({event:t,app:this,selectedElements:n})&&(r||!Xt.getReferenceSnapPoints())&&Xt.setReferenceSnapPoints(tv(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){Wo({event:t,app:this,selectedElements:n})&&(r||!Xt.getVisibleGaps())&&Xt.setVisibleGaps(ev(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ae(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Ae(n=>{n.key===V.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return yd(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=He(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=rt(r.x,r.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Ie.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Ie.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Ie.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=vf($G(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(yt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=rt(r.x,r.y,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Rn(ie(r.x,r.y),ie(t.origin.x,t.origin.y))*this.state.zoom.value<wI)return;if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Ie.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,m)){let f=Ie.addMidpoint(this.state.selectedLinearElement,r,this,!n[V.CTRL_OR_CMD],this.scene);if(!f)return;Ki(()=>{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=Ie.handlePointDragging(n,this,r.x,r.y,p);if(u){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,this.setState(u);return}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>kt(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Ki(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(fr()&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},y=[...t.originalElements.values()],E=n.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,P=E&&C>S;L&&(x.x=0),P&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&br(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=Ml(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let P=lH(aI(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[B,k,A,F,Y,Q]=TI(C,m),_=bf(ff(ie(B,k),ie(Y,Q),C.angle)),R=bf(ff(ie(A,k),ie(Y,Q),C.angle)),W=bf(ff(ie(B,F),ie(Y,Q),C.angle)),X=cI(lI(R,_)),G=cI(lI(W,_)),me=aI(sI(P,X),sI(P,G)),ue={...S,x:iI(S.x-me[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:iI(S.y-me[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:ue});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:w,snapLines:v}=ov(y,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||ZG(t,p,x,this.scene,w,n[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!Xe(p[0]))&&this.setState({suggestedBindings:kf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let P=new Map(L.map(R=>[R.id,R])),{duplicatedElements:B,duplicateElementsMap:k,elementsWithDuplicates:A,origIdToDuplicateId:F}=Mf({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:R,origElement:W})=>({frameId:R.frameId??W.frameId,seed:HH()})});B.forEach(R=>{t.originalElements.set(R.id,MI(R))});let Y=A.map(R=>{if(P.has(R.id)){let W=t.originalElements.get(R.id);if(W)return Fn(R,{x:W.x,y:W.y})}return R}),Q=this.props.onDuplicate?.(Y,C),_=VI(Q||Y,fm(B));Ki(()=>{if(t.hit.element){let R=F.get(t.hit.element.id),W=R&&k.get(R);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,W)=>{let X=F.get(W.id),G=X&&k.get(X);return G&&R.push(G),R},[]),t.drag.origin=He(n,this.state),this.setState(R=>({...WG(B,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(n,L,!0),this.maybeCacheReferenceSnapPoints(n,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=r.x-p.x,b=r.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,n.pressure];this.scene.mutateElement(p,{points:[...u,ie(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(jt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;xf(n)&&u.length===2&&({width:f,height:b}=DI(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ie(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&Xe(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ie(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Lf(p,!1)&&this.setState({suggestedBindings:vI(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Ie.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>qt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?f1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((y,E)=>(y[E.id]=!0,y),{})};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},{...qt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&jt(f[0])?new Ie(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||jo(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Nl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Nl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ae(n=>{this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:d,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:kl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Xt.setReferenceSnapPoints(null),Xt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=t.hit.allHitElements,u=He({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);sG(E)&&E.boundElements?.filter(w=>w.type==="arrow").map(w=>f.get(w.id)).filter(w=>Xe(w)).forEach(w=>{w&&this.scene.mutateElement(w,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(_t);else{let E=Ie.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Ie.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(_t,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(te.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(te.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(te.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(te.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),r?.type==="freedraw"){let E=He(n,this.state),w=r.points,v=E.x-r.x,C=E.y-r.y;v===w[0][0]&&C===w[0][1]&&(C+=1e-4,v+=1e-4);let S=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...w,ie(v,C)],pressures:S,lastCommittedPoint:ie(v,C)}),this.actionManager.executeAction(_t);return}if(jt(r)){r.points.length>1&&this.store.scheduleCapture();let E=He(n,this.state),w=Rn(ie(E.x,E.y),ie(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||w<wI)&&r&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-v/2,points:[ie(0,0),ie(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(_t)}else{let v=E.x-r.x,C=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,ie(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else t.drag.hasOccurred&&!l&&(Cf(this.state)&&Lf(r,!1)&&this.actionManager.executeAction(_t,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Ut(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:$o(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ve({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Ie(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(po(r)){let E=FG(wf({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<E&&this.scene.mutateElement(r,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(s.type!=="selection"&&r&&RI(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:Et.NEVER});return}if(kt(r)){let E=EG(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Of(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,cG(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=He(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let w=this.scene.getElement(this.state.selectedLinearElement.elementId);if(w?.frameId){let v=Hf(w,f);v&&w&&(yG(w,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(w,{groupIds:[]}),xG([w],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let w=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let P of L){let B=P.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(P,{groupIds:P.groupIds.slice(0,B)},{informMutation:!1,isDragging:!1})}C.forEach(P=>{P.groupIds.length&&xr(C,P.groupIds[P.groupIds.length-1]).length<2&&this.scene.mutateElement(P,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(w&&!this.state.selectedElementIds[w.id]){let L=v.filter(P=>P.frameId!==w.id&&GI(P,C,this.state));this.state.editingGroupId&&S(L),C=Of(C,L,w,this.state)}else if(!w&&this.state.editingGroupId){let L=v.filter(P=>P.frameId&&!GI(P,C,this.state));S(L)}C=HI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&RI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Et.NEVER}),t.resize.isResizing){let E=HI(this.scene.getElementsIncludingDeleted(),this.state,this),w=this.scene.getSelectedElements(this.state).filter(v=>kt(v));for(let v of w)E=bG(E,zf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&jt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ie(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(yt(this.state)&&x&&y){if(this.eraserTrail.endPath(),Rn(ie(x.clientX,x.clientY),ie(y.clientX,y.clientY))===0){let w=He({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(w.x,w.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?UG(this.state,b)?this.setState(E=>{let w={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>xr(this.scene.getNonDeletedElements(),C)))delete w[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ve(w,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let w={...E.selectedElementIds};delete w[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:w});return{...qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&jt(v[0])?new Ie(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let w={...E.selectedElementIds,[b.id]:!0};return delete w[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>xr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete w[v.id]}),{...qt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||jo(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...qt({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:jt(b)&&E.selectedLinearElement?.elementId!==b.id?new Ie(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&Xe(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&CG({point:ie(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(Di):this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,_e.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:jo(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!zH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||d||c){let E=this.scene.getSelectedElements(this.state).filter(jt);II(E,Cf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Ut(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:$o(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ge.pointers.size<=1&&Pl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ve({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&WI(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Bf(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<EH){let{x:c,y:p}=gm({sceneX:a,sceneY:l},r);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Mr.find(n=>n.code===this.props.langCode)||fo;await es(t),this.setAppState({})}},QG=()=>{(Xf()||oC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(nC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};QG();var lC=Kf;import{useEffect as tU,useState as oU}from"react";import{jsx as nU}from"react/jsx-runtime";var sC=e=>{let[o,t]=oU(!0);return tU(()=>{let n=async()=>{await es(r),t(!1)},r=Mr.find(i=>i.code===e.langCode)||fo;n()},[e.langCode]),o?nU(Id,{theme:e.theme}):e.children};import rU from"clsx";import{jsx as cC}from"react/jsx-runtime";var dC=({children:e})=>{let{FooterCenterTunnel:o}=Ce(),t=be();return cC(o.In,{children:cC("div",{className:rU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},iU=dC;dC.displayName="FooterCenter";import aU from"clsx";import{isMobileOrTablet as lU,MQ_MIN_WIDTH_DESKTOP as sU}from"@excalidraw/common";import{jsx as dU,jsxs as mU}from"react/jsx-runtime";var mC=({isCollaborating:e,onSelect:o,...t})=>{let n=be(),r=lU()||n.width<sU;return mU(Nt,{...t,className:aU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?g0:g("labels.share"),n.collaborators.size>0&&dU("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},cU=mC;mC.displayName="LiveCollaborationTrigger";import{jsx as Hn,jsxs as uC}from"react/jsx-runtime";var pU=()=>Hn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Hn("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"})}),uU=()=>uC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Hn("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)"}),Hn("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)"}),Hn("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)"}),Hn("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)"})]}),pC=({style:e,size:o="small",withText:t})=>uC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Hn(pU,{}),t&&Hn(uU,{})]});import{Fragment as fC,jsx as Ke,jsxs as e1}from"react/jsx-runtime";var t1=({icon:e,shortcut:o,children:t})=>{let n=de();return e1(fC,{children:[Ke("div",{className:"welcome-screen-menu-item__icon",children:e}),Ke("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!n.editor.isMobile&&Ke("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};t1.displayName="WelcomeScreenMenuItemContent";var Ol=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ke("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ke(t1,{icon:t,shortcut:n,children:o})});Ol.displayName="WelcomeScreenMenuItem";var hC=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ke("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ke(t1,{icon:t,shortcut:n,children:e})});hC.displayName="WelcomeScreenMenuItemLink";var Jt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ce();return Ke(o.In,{children:Ke("div",{className:"welcome-screen-center",children:e||e1(fC,{children:[Ke(o1,{}),Ke(n1,{children:g("welcomeScreen.defaults.center_heading")}),e1(r1,{children:[Ke(a1,{}),Ke(i1,{})]})]})})})};Jt.displayName="Center";var o1=({children:e})=>Ke("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ke(pC,{withText:!0})});o1.displayName="Logo";var n1=({children:e})=>Ke("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});n1.displayName="Heading";var r1=({children:e})=>Ke("div",{className:"welcome-screen-menu",children:e});r1.displayName="Menu";var i1=()=>{let e=We();return Ke(Ol,{onSelect:()=>e.executeAction(nr),shortcut:"?",icon:Dr,children:g("helpDialog.title")})};i1.displayName="MenuItemHelp";var a1=()=>{let e=be(),o=We();return e.viewModeEnabled?null:Ke(Ol,{onSelect:()=>o.executeAction(ri),shortcut:Fe("loadScene"),icon:_r,children:g("buttons.load")})};a1.displayName="MenuItemLoadScene";var gC=({onSelect:e})=>{let{t:o}=Ge();return Ke(Ol,{shortcut:null,onSelect:e,icon:cs,children:o("labels.liveCollaboration")})};gC.displayName="MenuItemLiveCollaborationTrigger";Jt.Logo=o1;Jt.Heading=n1;Jt.Menu=r1;Jt.MenuItem=Ol;Jt.MenuItemLink=hC;Jt.MenuItemHelp=i1;Jt.MenuItemLoadScene=a1;Jt.MenuItemLiveCollaborationTrigger=gC;import{jsx as Ji,jsxs as l1}from"react/jsx-runtime";var ym=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[$1,Ji("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};ym.displayName="MenuHint";var wm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ji("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),q1]})})};wm.displayName="ToolbarHint";var vm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ce();return Ji(o.In,{children:l1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ji("div",{children:e||g("welcomeScreen.defaults.helpHint")}),j1]})})};vm.displayName="HelpHint";import{Fragment as bC,jsx as zl,jsxs as gU}from"react/jsx-runtime";var Tm=e=>zl(bC,{children:e.children||gU(bC,{children:[zl(Jt,{}),zl(ym,{}),zl(wm,{}),zl(vm,{})]})});Tm.displayName="WelcomeScreen";Tm.Center=Jt;Tm.Hints={MenuHint:ym,ToolbarHint:wm,HelpHint:vm};var hU=Tm;var fU=()=>{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)})},xC=fU;import{getSceneVersion as J7e,hashElementsVersion as Q7e,hashString as eDe,getNonDeletedElements as tDe}from"@excalidraw/element";import{getTextFromElements as nDe}from"@excalidraw/element";import{isInvisiblySmallElement as iDe}from"@excalidraw/element";import bU from"lodash.throttle";import{arrayToMap as xU,isDevEnv as EC,isTestEnv as yC}from"@excalidraw/common";import{orderByFractionalIndex as EU,syncInvalidIndices as wC,validateFractionalIndices as yU}from"@excalidraw/element";var wU=(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)),vU=bU((e,o,t)=>{if(EC()||yC()||window?.DEBUG_FRACTIONAL_INDICES){let n=wC(e.map(r=>({...r})));yU(n,{shouldThrow:yC()||EC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),TU=(e,o,t)=>{let n=xU(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),m=wU(t,s,l);s&&m?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=EU(r);return vU(a,e,o),wC(a),a};import{getFreeDrawSvgPath as uDe}from"@excalidraw/element";import{isLinearElement as fDe}from"@excalidraw/element";import{FONT_FAMILY as xDe,THEME as EDe,MIME_TYPES as yDe,ROUNDNESS as vc,DEFAULT_LASER_COLOR as wDe,UserIdleState as vDe,normalizeLink as TDe}from"@excalidraw/common";import{mutateElement as Ic,newElementWith as CDe,bumpVersion as gi}from"@excalidraw/element";import{CaptureUpdateAction as kDe}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Dy,viewportCoordsToSceneCoords as LDe}from"@excalidraw/common";import{jsx as vC,jsxs as IU}from"react/jsx-runtime";var TC=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ce(),n=ae();return vC(t.In,{children:IU(xe.Item,{onSelect:()=>{re("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??mb,children:[e??g("labels.textToDiagram"),vC(xe.Item.Badge,{children:"AI"})]})})};TC.displayName="TTDDialogTrigger";import{getCommonBounds as UDe,getVisibleSceneBounds as YDe}from"@excalidraw/element";import{useLayoutEffect as CU}from"react";var SU=e=>{let o=Be();return CU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as ZDe}from"@excalidraw/element";import{setCustomTextMetricsProvider as jDe}from"@excalidraw/element";import{jsx as s1}from"react/jsx-runtime";xC();var LU=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=fo.code,viewModeEnabled:m,zenModeEnabled:d,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:y=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:P,onPointerUp:B,onScrollChange:k,onDuplicate:A,children:F,validateEmbeddable:Y,renderEmbeddable:Q,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:W}=e,X=e.UIOptions?.canvasActions,G={...e.UIOptions,canvasActions:{...IC.canvasActions,...X},tools:{image:e.UIOptions?.tools?.image??!0}};return X?.export&&(G.canvasActions.export.saveFileToDisk=X.export?.saveFileToDisk??IC.canvasActions.export.saveFileToDisk),G.canvasActions.toggleTheme===null&&typeof u>"u"&&(G.canvasActions.toggleTheme=!0),MU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ue=pe=>{typeof pe.scale=="number"&&pe.scale!==1&&pe.preventDefault()};return document.addEventListener("touchmove",ue,{passive:!1}),()=>{document.removeEventListener("touchmove",ue)}},[]),s1(H1,{store:Ue,children:s1(sC,{langCode:s,theme:u,children:s1(lC,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:d,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:G,onPaste:x,detectScroll:y,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:P,onPointerUp:B,onScrollChange:k,onDuplicate:A,validateEmbeddable:Y,renderEmbeddable:Q,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:W,children:F})})})},AU=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),m=Object.keys(a);return s.length!==m.length?!1:s.every(c=>c==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===a?.canvasActions?.[u]):n[c]===a[c])&&PU(r,l)},DU=kU.memo(LU,AU);DU.displayName="Excalidraw";export{Nt as Button,kDe as CaptureUpdateAction,wDe as DEFAULT_LASER_COLOR,Gd as DefaultSidebar,SU as DiagramToCodePlugin,Ia as Ellipsify,DU as Excalidraw,xDe as FONT_FAMILY,iU as Footer,cU as LiveCollaborationTrigger,yDe as MIME_TYPES,mt as MainMenu,vc as ROUNDNESS,$t as Sidebar,vl as Stats,EDe as THEME,Yg as TTDDialog,TC as TTDDialogTrigger,vDe as UserIdleState,hU as WelcomeScreen,gi as bumpVersion,Ni as convertToExcalidrawElements,fo as defaultLang,hw as elementPartiallyOverlapsWithOrContainsBBox,gw as elementsOverlappingBBox,Fy as exportToBlob,gn as exportToCanvas,wA as exportToClipboard,Ei as exportToSvg,UDe as getCommonBounds,Rm as getDataURL,uDe as getFreeDrawSvgPath,Pc as getLibraryItemsHash,tDe as getNonDeletedElements,J7e as getSceneVersion,nDe as getTextFromElements,YDe as getVisibleSceneBounds,Q7e as hashElementsVersion,eDe as hashString,Bh as isElementInsideBBox,ZDe as isElementLink,iDe as isInvisiblySmallElement,fDe as isLinearElement,Mr as languages,$l as loadFromBlob,_m as loadLibraryFromBlob,Dm as loadSceneOrLibraryFromBlob,Xy as mergeLibraryItems,Ic as mutateElement,CDe as newElementWith,TDe as normalizeLink,nh as parseLibraryTokensFromUrl,TU as reconcileElements,Sr as restore,LC as restoreAppState,PC as restoreElement,Lm as restoreElements,ra as restoreLibraryItems,Dy as sceneCoordsToViewportCoords,ta as serializeAsJSON,MC as serializeLibraryAsJSON,jDe as setCustomTextMetricsProvider,de as useDevice,OA as useHandleLibrary,Ge as useI18n,LDe as viewportCoordsToSceneCoords,Xx as zoomToFitBounds};