UNPKG

@excalidraw/excalidraw

Version:
2 lines 502 kB
import{$ as Fn,$a as Oh,$b as Zh,$c as D,$d as bm,$e as Ib,$f as ni,$g as li,$h as pn,$i as pi,$j as op,A as To,Aa as kt,Ab as sa,Ac as af,Ad as rn,Ae as nb,Af as Gb,Ag as gx,Ah as vs,Ai as tE,Aj as Qt,Ak as Ao,B as Wr,Ba as cr,Bb as Dl,Bc as lf,Bd as qn,Be as ib,Bf as Yb,Bg as hx,Bh as Dx,Bi as ko,Bj as Us,Bk as GE,C as ta,Ca as _h,Cb as Pl,Cc as DT,Cd as Af,Ce as ab,Cf as Vb,Cg as Ea,Ch as Px,Ci as oE,Cj as wE,D as Rn,Da as aa,Db as Hn,Dc as sf,Dd as sm,De as lb,Df as Wb,Dg as fx,Dh as Rx,Di as rE,Dj as TE,E as co,Ea as Lt,Eb as Vh,Ec as Ol,Ed as Yl,Ee as sb,Ef as Kb,Eg as bx,Eh as wa,Ei as di,Ej as CE,F as Kr,Fa as Je,Fb as Gn,Fc as $n,Fd as _f,Fe as cb,Ff as Xb,Fg as sn,Fh as Fm,Fi as nE,Fj as IE,G as re,Ga as Mh,Gb as ca,Gc as $t,Gd as Mf,Ge as db,Gf as $b,Gg as xx,Gh as Nx,Gi as Ps,Gj as ui,H as mo,Ha as Dh,Hb as rt,Hc as Xo,Hd as Df,He as mb,Hf as Zb,Hg as Ex,Hh as Ox,Hi as iE,Hj as qm,I as Nn,Ia as ot,Ib as ur,Ic as cf,Id as fa,Ie as pb,If as jb,Ig as us,Ih as Fx,Ii as mi,Ij as SE,J as On,Ja as Xt,Jb as Rl,Jc as We,Jd as Pf,Je as ub,Jf as Jb,Jg as cn,Jh as Bm,Ji as Rs,Jj as Qm,K as yl,Ka as Ph,Kb as Io,Kc as Fl,Kd as Rf,Ke as gb,Kf as qb,Kg as gs,Kh as ws,Ki as aE,Kj as kE,L as Vd,La as Jd,Lb as Wh,Lc as df,Ld as Qn,Le as hb,Lf as os,Lg as ya,Lh as zm,Li as Ns,Lj as LE,M as vl,Ma as Bn,Mb as Kh,Mc as po,Md as Nf,Me as fb,Mf as Qb,Mg as Zo,Mh as Um,Mi as Lo,Mj as fo,N as uh,Na as zn,Nb as At,Nc as mf,Nd as Vl,Ne as nn,Nf as ex,Ng as yx,Nh as Bx,Ni as Vm,Nj as Jo,O as oa,Oa as qd,Ob as Yn,Oc as pf,Od as Wl,Oe as Xl,Of as Sm,Og as Er,Oh as zx,Oi as lE,Oj as bo,P as gh,Pa as Al,Pb as Ae,Pc as Zn,Pd as Of,Pe as bb,Pf as rs,Pg as Jt,Ph as Ux,Pi as Os,Pj as P,Q as hh,Qa as Qd,Qb as Xh,Qc as Le,Qd as Ff,Qe as xb,Qf as br,Qg as Lm,Qh as Hx,Qi as Fs,Qj as q,R as Wd,Ra as em,Rb as $h,Rc as uf,Rd as cm,Re as Eb,Rf as $o,Rg as Am,Rh as Hm,Ri as sE,Rj as ep,S as ra,Sa as Rh,Sb as Vn,Sc as gf,Sd as dm,Se as yb,Sf as ho,Sg as hs,Sh as Gx,Si as cE,Sj as hn,T as je,Ta as tm,Tb as da,Tc as hf,Td as Bf,Te as vb,Tf as km,Tg as fs,Th as Yx,Ti as dE,Tj as ka,U as wl,Ua as z,Ub as im,Uc as Bl,Ud as zf,Ue as wb,Uf as tx,Ug as vx,Uh as Ts,Ui as zT,Uj as gi,V as fh,Va as bt,Vb as qr,Vc as ff,Vd as mm,Ve as Tb,Vf as ri,Vg as qt,Vh as Ta,Vi as vr,Vj as tp,W as bh,Wa as dr,Wb as xe,Wc as hr,Wd as pm,We as $l,Wf as ba,Wg as L,Wh as Cs,Wi as Ia,Wj as AE,X as xh,Xa as om,Xb as Et,Xc as uo,Xd as um,Xe as Cb,Xf as So,Xg as wx,Xh as Is,Xi as Wm,Xj as Hs,Y as Eh,Ya as mr,Yb as Qr,Yc as zl,Yd as gm,Ye as Zl,Yf as ox,Yg as _m,Yh as Ss,Yi as Km,Yj as _E,Z as yh,Za as Nh,Zb as Wn,Zc as Ul,Zd as hm,Ze as Cm,Zf as rx,Zg as dn,Zh as ks,Zi as Xm,Zj as ME,_ as vh,_a as rm,_b as Y,_c as bf,_d as fm,_e as ei,_f as ns,_g as Tx,_h as Ls,_i as $m,_j as Gs,a as oh,aa as Kd,ab as Co,ac as Nl,ad as Zt,ae as xm,af as Sb,ag as is,ah as Mm,ai as Vx,aj as yt,ak as rp,b as Yr,ba as Xd,bb as Xr,bc as ie,bd as Te,be as Uf,bf as kb,bg as xr,bh as Cx,bi as Wx,bj as Se,bk as np,c as rh,ca as wh,cb as lt,cc as he,cd as xf,ce as Hf,cf as Lb,cg as as,ch as mn,ci as Kx,cj as Bt,ck as DE,d as nh,da as Th,db as $r,dc as Ne,dd as go,de as Em,df as Ab,dg as ls,dh as Ix,di as Xx,dj as Zm,dk as PE,e as Ho,ea as Tl,eb as Un,ec as ee,ed as fr,ee as ym,ef as _b,eg as nx,eh as si,ei as As,ej as wr,ek as RE,f as hl,fa as Cl,fb as Zr,fc as jh,fd as jn,fe as Kl,ff as jl,fg as ix,fh as bs,fi as $x,fj as gn,fk as NE,g as fl,ga as $d,gb as Fh,gc as Wo,gd as Ef,ge as jt,gf as Jl,gg as te,gh as Dm,gi as Zx,gj as jm,gk as hi,h as bl,ha as Ch,hb as Bh,hc as Jh,hd as yf,he as vm,hf as ti,hg as y,hh as Sx,hi as Gm,hj as mE,hk as OE,i as ih,ia as Ih,ib as jr,ic as ma,id as vf,ie as wm,if as ql,ig as ss,ih as kx,ii as ci,ij as pE,ik as FE,j as ah,ja as Sh,jb as Be,jc as Ko,jd as on,je as Gf,jf as Ql,jg as an,jh as Pm,ji as jx,jj as uE,jk as BE,k as lh,ka as kh,kb as A,kc as qh,kd as Jn,ke as Yf,kf as Mb,kg as cs,kh as PT,ki as Jx,kj as Jm,kk as ip,l as so,la as Il,lb as Re,lc as en,ld as wf,le as Vf,lf as oi,lg as ii,lh as Rm,li as qx,lj as gE,lk as fi,m as xl,ma as sr,mb as xt,mc as ut,md as Tf,me as Wf,mf as Db,mg as ds,mh as va,mi as _s,mj as hE,mk as UT,n as Go,na as Lh,nb as la,nc as qe,nd as Cf,ne as Tm,nf as Pb,ng as ai,ni as Qx,nj as fE,nk as ap,o as sh,oa as Zd,ob as pr,oc as Kn,od as If,oe as Kf,of as Rb,og as ax,oi as yr,oj as nt,ok as lp,p as ch,pa as Ah,pb as _l,pc as Qh,pd as Hl,pe as Xf,pf as Ft,pg as lx,pi as un,pj as K,pk as se,q as dh,qa as Sl,qb as nm,qc as ef,qd as Sf,qe as $f,qf as Nb,qg as sx,qh as Lx,qi as RT,qj as bE,qk as sp,r as Qi,ra as jd,rb as Vo,rc as pa,rd as am,re as Zf,rf as Ob,rg as ms,rh as Ax,ri as Ca,rj as Sa,rk as Ys,s as ea,sa as Kt,sb as Jr,sc as gr,sd as lm,se as jf,sf as Fb,sg as cx,sh as xs,si as NT,sj as xE,sk as zE,t as Vr,ta as na,tb as Ml,tc as Xn,td as kf,te as Jf,tf as es,tg as ln,th as Es,ti as OT,tj as EE,tk as ke,u as El,ua as St,ub as zh,uc as tf,ud as Ot,ue as qf,uf as Bb,ug as dx,uh as Nm,ui as FT,uj as Ue,uk as UE,v as mh,va as kl,vb as Uh,vc as Nt,vd as Lf,ve as Qf,vf as zb,vg as mx,vh as ys,vi as BT,vj as Bs,vk as $,w as Gd,wa as ia,wb as Hh,wc as of,wd as ua,we as eb,wf as Ub,wg as ps,wh as _x,wi as Ms,wj as yE,wk as Vs,x as ph,xa as Yo,xb as Q,xc as rf,xd as ga,xe as tb,xf as Hb,xg as xa,xh as Om,xi as eE,xj as zs,xk as Ee,y as Yd,ya as pt,yb as Gh,yc as nf,yd as ha,ye as ob,yf as Im,yg as px,yh as jo,yi as Ds,yj as vE,yk as HE,z as we,za as Ll,zb as Yh,zc as tn,zd as Gl,ze as rb,zf as ts,zg as ux,zh as Mx,zi as Ym,zj as ue,zk as fn}from"./chunk-FX7ZIABN.js";import{a as v}from"./chunk-SQ5PDB2P.js";import{J as Hd}from"./chunk-6U3AYISY.js";import{c as th}from"./chunk-Z3N5DIM6.js";import{b as Qg,c as eh,d as C}from"./chunk-SRAX5OIU.js";import vM,{useEffect as wM}from"react";import{useEffect as JT,useState as qT}from"react";import{atom as ye,createStore as HT}from"jotai";import{createIsolation as GT}from"jotai-scope";var YE=GT();var{useAtom:ce,useSetAtom:Tr,useAtomValue:Ws,useStore:LM}=YE,VE=YE.Provider,st=HT();var YT=Qg({"./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-B4ZKOASM.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 VT=85,_o={code:"en",label:"English"},xi=[_o,...[{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=>th[e.code]>=VT).sort((e,o)=>e.label>o.label?1:-1)],Xs="__test__";v.DEV&&xi.unshift({code:Xs,label:"test language"},{code:`${Xs}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var bi=_o,Ks={},$s=async e=>{if(bi=e,document.documentElement.dir=bi.rtl?"rtl":"ltr",document.documentElement.lang=bi.code,e.code.startsWith(Xs))Ks={};else try{Ks=await YT(`./locales/${bi.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Ks=Hd}st.set(KE,e.code)},qo=()=>bi,WE=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},g=(e,o,t)=>{if(bi.code.startsWith(Xs))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=WE(Ks,r)||WE(Hd,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(v.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},KE=ye(_o.code),Ve=()=>{let e=Ws(KE);return{t:g,langCode:e}};import{useState as XT,useEffect as $T}from"react";import WT from"react";import{jsx as cp}from"react/jsx-runtime";var KT=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(WT.useRef(Date.now()).current%1600);return cp("div",{className:`Spinner ${r}`,children:cp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:cp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},ct=KT;import ZT from"clsx";import{jsx as dp,jsxs as jT}from"react/jsx-runtime";var Zs=({delay:e,theme:o})=>{let[t,r]=XT(!!e);return $T(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:jT("div",{className:ZT("LoadingMessage",{"LoadingMessage--dark":o===re.DARK}),children:[dp("div",{children:dp(ct,{})}),dp("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import{jsx as QT}from"react/jsx-runtime";var XE=e=>{let[o,t]=qT(!0);return JT(()=>{let r=async()=>{await $s(n),t(!1)},n=xi.find(i=>i.code===e.langCode)||_o;r()},[e.langCode]),o?QT(Zs,{theme:e.theme}):e.children};import Uo,{useContext as Hr}from"react";import{flushSync as _n}from"react-dom";import q5 from"roughjs/bin/rough";import mT from"clsx";import{nanoid as Q5}from"nanoid";import mp,{useEffect as eC,useRef as $E,useState as tC}from"react";import ZE from"clsx";import{jsx as La,jsxs as Aa}from"react/jsx-runtime";var X=mp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=Ke(),a=mp.useRef(null);mp.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=tC(!1),m=$E(!0),d=async u=>{let h="onClick"in r&&r.onClick?.(u);if(Gn(h))try{c(!0),await h}catch(f){if(f instanceof Xn)console.warn(f);else throw f}finally{m.current&&c(!1)}};eC(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=$E(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Aa("button",{className:ZE("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)&&Aa("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&La("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&La(ct,{})]}),r.showAriaLabel&&Aa("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&La(ct,{})]}),r.children]})}return Aa("label",{className:ZE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[La("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}),Aa("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&La("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});X.displayName="ToolButton";import{jsx as rC}from"react/jsx-runtime";var oC=(e,o,t)=>{let r=new Set($(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=ko(e,m);for(let p of d)if(!a.has(p.id)){if(qe(p)){let u=Qt(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=qe(m)?Qt(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&&ee(u)&&(P(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding}),P(u,{points:u.points}))}),q(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,qe(m)||(n[m.id]=!0),q(m,{frameId:null})):qe(m)&&o.selectedElementIds[m.containerId]?q(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Le(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(h=>h===o.editingGroupId),u=d.groupIds[p+1];if(u){let h=Le(s,u).filter(f=>!f.isDeleted);h.length>1&&(c=u,h.forEach(f=>{n[f.id]=!0}))}}}}return{elements:s,appState:{...o,...We({selectedElementIds:n,editingGroupId:c},s,o,null)}}},jE=(e,o)=>{if(e.editingGroupId){let t=Le(se(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},_a=D({name:"deleteSelectedElements",label:"labels.delete",icon:Ot,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=K.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(f=>f.id===d.id?q(f,{isDeleted:!0}):f),h=jE(o,u);return{elements:u,appState:{...h,editingLinearElement:null},captureUpdate:L.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return K.deletePoints(d,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:L.IMMEDIATELY}}let{elements:n,appState:i}=oC(e,o,r);return fs(n,n.filter(a=>a.isDeleted)),i=jE(i,n),{elements:n,appState:{...i,activeTool:Be(o,{type:"selection"}),multiElement:null,activeEmbeddable:null},captureUpdate:ke(se(e),o)?L.IMMEDIATELY:L.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===y.BACKSPACE||e.key===y.DELETE)&&!e[y.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>rC(X,{type:"button",icon:Ot,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:ke(se(e),o)})});var pp=(e,o)=>e.frameId===o||e.id===o,qE=(e,o,t)=>{let r=[],n=[],i=null,a=-1,l=Q(t||$(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},nC=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),[])},JE=(e,o,t)=>{if("containerId"in e&&e.containerId){let r=bo.getScene(e).getElement(e.containerId);if(r)return t==="left"?Math.min(o.indexOf(r),o.indexOf(e)):Math.max(o.indexOf(r),o.indexOf(e))}else{let r=e.boundElements?.find(n=>n.type!=="arrow")?.id;if(r){let n=bo.getScene(e).getElement(r);if(n)return t==="left"?Math.min(o.indexOf(n),o.indexOf(e)):Math.max(o.indexOf(n),o.indexOf(e))}}},iC=(e,o)=>{let t=-1,r=-1;return e.forEach((n,i)=>{pp(n,o)&&(t===-1&&(t=i),r=i)}),t===-1?[]:e.slice(t,r+1)},aC=(e,o,t,r,n)=>{let i=o[t],a=d=>d.isDeleted?!1:n?d.frameId===n:e.editingGroupId?d.groupIds.includes(e.editingGroupId):!0,l=r==="left"?Vo(o,d=>a(d),Math.max(0,t-1)):nm(o,d=>a(d),t+1),s=o[l];if(!s)return-1;if(e.editingGroupId){if(i?.groupIds.join("")===s?.groupIds.join(""))return JE(s,o,r)??l;if(!s?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(s.frameId||ie(s))){let d=iC(o,s.frameId||s.id);return r==="left"?o.indexOf(d[0]):o.indexOf(d[d.length-1])}if(!s.groupIds.length)return JE(s,o,r)??l;let c=e.editingGroupId?s.groupIds[s.groupIds.indexOf(e.editingGroupId)-1]:s.groupIds[s.groupIds.length-1],m=Le(o,c);return m.length?r==="left"?o.indexOf(m[0]):o.indexOf(m[m.length-1]):l},QE=(e,o)=>o.reduce((t,r)=>{let n=e[r];return t.set(n.id,n),t},new Map),ey=(e,o,t)=>{let r=qE(e,o),n=QE(e,r),i=nC(r);t==="right"&&(i=i.reverse());let a=new Set(r.filter(l=>ie(e[l])).map(l=>e[l].id));return i.forEach((l,s)=>{let c=l[0],m=l[l.length-1],d=t==="left"?c:m,p=l.some(T=>{let E=e[T];return E.frameId&&a.has(E.frameId)})?null:e[d]?.frameId,u=aC(o,e,d,t,p);if(u===-1||d===u)return;let h=t==="left"?e.slice(0,u):e.slice(0,c),f=e.slice(c,m+1),b=t==="left"?e.slice(u,c):e.slice(m+1,u+1),x=t==="left"?e.slice(m+1):e.slice(u+1);e=t==="left"?[...h,...f,...b,...x]:[...h,...b,...f,...x]}),fo(e,n),e},ty=(e,o,t,r,n)=>{let i=qE(e,o,n),a=QE(e,i),l=[],s,c;if(t==="left"){if(r)s=nm(e,h=>pp(h,r));else if(o.editingGroupId){let h=Le(e,o.editingGroupId);if(!h.length)return e;s=e.indexOf(h[0])}else s=0;c=i[i.length-1]}else{if(r)c=Vo(e,h=>pp(h,r));else if(o.editingGroupId){let h=Le(e,o.editingGroupId);if(!h.length)return e;c=e.indexOf(h[h.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let h=s;h<c+1;h++)i.includes(h)||l.push(e[h]);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 fo(u,a),u};function oy(e,o,t,r){let n=Q($(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 ry=(e,o)=>ey(e,o,"left"),ny=(e,o)=>ey(e,o,"right"),iy=(e,o)=>oy(e,o,"left",ty),ay=(e,o)=>oy(e,o,"right",ty);import{jsx as js}from"react/jsx-runtime";var up=D({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:pm,trackEvent:{category:"element"},perform:(e,o)=>({elements:ry(e,o),appState:o,captureUpdate:L.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[y.CTRL_OR_CMD]&&!e.shiftKey&&e.code===te.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${A("CtrlOrCmd+[")}`,children:pm})}),gp=D({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:mm,trackEvent:{category:"element"},perform:(e,o)=>({elements:ny(e,o),appState:o,captureUpdate:L.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[y.CTRL_OR_CMD]&&!e.shiftKey&&e.code===te.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${A("CtrlOrCmd+]")}`,children:mm})}),hp=D({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:gm,trackEvent:{category:"element"},perform:(e,o)=>({elements:iy(e,o),appState:o,captureUpdate:L.IMMEDIATELY}),keyTest:e=>so?e[y.CTRL_OR_CMD]&&e.altKey&&e.code===te.BRACKET_LEFT:e[y.CTRL_OR_CMD]&&e.shiftKey&&e.code===te.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${so?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")}`,children:gm})}),fp=D({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:um,trackEvent:{category:"element"},perform:(e,o)=>({elements:ay(e,o),appState:o,captureUpdate:L.IMMEDIATELY}),keyTest:e=>so?e[y.CTRL_OR_CMD]&&e.altKey&&e.code===te.BRACKET_RIGHT:e[y.CTRL_OR_CMD]&&e.shiftKey&&e.code===te.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${so?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")}`,children:um})});var bp=D({name:"selectAll",label:"labels.selectAll",icon:Bb,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Y(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...We({editingGroupId:null,selectedElementIds:n},se(e),o,r),selectedLinearElement:Object.keys(n).length===1&&he(e[0])?new K(e[0]):null},captureUpdate:L.IMMEDIATELY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.A});var lC=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]},sC=e=>{let o=Gh(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]},ly=e=>sC(lC(e));import{jsx as dC}from"react/jsx-runtime";var xp=D({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ua,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.editingLinearElement)try{let i=K.duplicateSelectedPoints(o,r.scene.getNonDeletedElementsMap());return{elements:e,appState:i,captureUpdate:L.IMMEDIATELY}}catch{return!1}let n=cC(e,o);if(r.props.onDuplicate&&n.elements){let i=r.props.onDuplicate(n.elements,e);i&&(n.elements=i)}return{...n,captureUpdate:L.IMMEDIATELY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.D,PanelComponent:({elements:e,appState:o,updateData:t})=>dC(X,{type:"button",icon:ua,title:`${g("labels.duplicateSelection")} \u2014 ${A("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:ke(se(e),o)})}),cC=(e,o)=>{let t=new Map,r=[],n=[],i=new Map,a=new Map,l=Q(e),s=f=>{let x=im(f).reduce((T,E)=>{if(m.has(E.id))return T;m.set(E.id,!0);let w=as(o.editingGroupId,t,E,{x:E.x+Wd/2,y:E.y+Wd/2});return m.set(w.id,!0),a.set(w.id,w),i.set(E.id,w.id),n.push(E),r.push(w),T.push(w),T},[]);return Array.isArray(f)?x:x[0]||null};e=ly(e);let c=Q($(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),m=new Map,d=e.slice(),p=(f,b)=>{Io(f!==-1,"targetIndex === -1 "),!(!Array.isArray(b)&&!b)&&d.splice(f+1,0,...im(b))},u=new Set(e.filter(f=>c.has(f.id)&&ie(f)).map(f=>f.id));for(let f of e){if(m.has(f.id)||!c.has(f.id))continue;let b=df(o,f);if(b){let x=Le(e,b).flatMap(E=>ie(E)?[...ko(e,E.id),E]:[E]),T=Vo(d,E=>E.groupIds?.includes(b));p(T,s(x));continue}if(!(f.frameId&&u.has(f.frameId))){if(ie(f)){let x=f.id,T=ko(e,x),E=Vo(d,w=>w.frameId===x||w.id===x);p(E,s([...T,f]));continue}if(ut(f)){let x=ue(f,l),T=Vo(d,E=>E.id===f.id||"containerId"in E&&E.containerId===f.id);x?p(T,s([f,x])):p(T,s(f));continue}if(qe(f)){let x=Qt(f,l),T=Vo(d,E=>E.id===f.id||E.id===x?.id);x?p(T,s([x,f])):p(T,s(f));continue}p(Vo(d,x=>x.id===f.id),s(f))}}Bs(d,n,i),hs(d,n,i),Ms(d,n,i);let h=Ys(r);return{elements:d,appState:{...o,...We({editingGroupId:o.editingGroupId,selectedElementIds:h.reduce((f,b)=>(qe(b)||(f[b.id]=!0),f),{})},se(d),o,null)}}};import{useEffect as Fp,useMemo as F2,useRef as Bp,useState as B2}from"react";var mC=new Set(["command_palette","export"]),le=(e,o,t,r)=>{try{if(typeof window>"u"||v.VITE_WORKER_ID||v.VITE_APP_ENABLE_TRACKING!=="true"||!mC.has(e)||v.DEV)return;v.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 hC from"clsx";import{forwardRef as pC}from"react";import uC from"clsx";import{jsx as gC}from"react/jsx-runtime";var Js=pC((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return gC("button",{type:"button",ref:o,title:t,"data-testid":n,className:uC(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as Ep,jsxs as fC}from"react/jsx-runtime";var eo=e=>Ep("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?Ep(Js,{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):fC("label",{className:hC({active:e.value===o.value}),title:o.text,children:[Ep("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 bC from"clsx";import{jsx as yp}from"react/jsx-runtime";var sy=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=hl),o==="elementBackground"&&(n=fl),o==="canvasBackground"&&(n=bl),r&&(n=r),n?yp("div",{className:"color-picker__top-picks",children:n.map(i=>yp("button",{className:bC("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:yp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as xC}from"react/jsx-runtime";var qs=()=>xC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import by,{useEffect as xy,useState as OC}from"react";import vC from"clsx";import{useEffect as wC,useRef as TC}from"react";var Cr=({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},Ma=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),vp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),dy=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return vp({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,oh)},to=ye(null),cy=(e,o,t)=>(e*299+o*587+t*114)/1e3>=160?"black":"white",my=(e,o)=>{if(o){let i=new Option().style;if(i.color=e,i.color){let a=i.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),l=parseInt(a[0]),s=parseInt(a[1]),c=parseInt(a[2]);return cy(l,s,c)}}if(e==="transparent")return"black";let t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return cy(t,r,n)};import{jsxs as yC}from"react/jsx-runtime";var EC=({color:e,keyLabel:o,isCustomColor:t=!1,isShade:r=!1})=>yC("div",{className:"color-picker__button__hotkey-label",style:{color:my(e,t)},children:[r&&"\u21E7",o]}),Ei=EC;import{jsx as Da,jsxs as py}from"react/jsx-runtime";var uy=({hex:e,onChange:o,palette:t})=>{let r=Cr({color:e||"transparent",palette:t}),[n,i]=ce(to),a=TC(null);if(wC(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return Da("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>py("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:vC("color-picker__button color-picker__button--large",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[Da("div",{className:"color-picker__button-outline"}),Da(Ei,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return py("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Da("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Da("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 CC from"clsx";import{useEffect as IC,useRef as SC}from"react";import{jsx as wp,jsxs as LC}from"react/jsx-runtime";var kC=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=Cr({color:o||"transparent",palette:e}),[a,l]=ce(to),s=SC(null);return IC(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),wp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=Ma[d],h=g(`colors.${c.replace(/\d+/,"")}`,null,"");return LC("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:CC("color-picker__button color-picker__button--large",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${h}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${h} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[wp("div",{className:"color-picker__button-outline"}),wp(Ei,{color:p,keyLabel:u})]},c)})})},gy=kC;import AC from"clsx";import{useEffect as _C,useRef as MC}from"react";import{jsx as Tp,jsxs as DC}from"react/jsx-runtime";var hy=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ce(to),a=MC(null);return _C(()=>{a.current&&a.current.focus()},[o,n]),Tp("div",{className:"color-picker-content--default",children:e.map((l,s)=>DC("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:AC("color-picker__button color-picker__button--large",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Tp("div",{className:"color-picker__button-outline"}),Tp(Ei,{color:l,keyLabel:s+1,isCustomColor:!0})]},s))})};var Cp=(e,o,t)=>{let r=Math.ceil(t/Yr);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+Yr;return n>=t?o%Yr:n}case"ArrowUp":{let n=o-Yr,i=n<0?Yr*r+n:n;return i>=t?void 0:i}}},PC=({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(Ma.includes(e.key)){let l=Ma.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},fy=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[y.CTRL_OR_CMD])return!1;if(e.key===y.ESCAPE)return m(e),!0;if(e.key===y.ALT)return c(!0),!0;if(e.key===y.I)return c(),!0;let d=Cr({color:r,palette:t});if(e.key===y.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((T,[E,w])=>(w&&T.push(E),T),[]),h=u.indexOf(o),f=e.shiftKey?-1:1,b=h+f>u.length-1?0:h+f<0?u.length-1:h+f,x=u[b];return x&&a(x),x==="custom"?n(i[0]):x==="baseColors"&&(Object.entries(t).find(([E,w])=>Array.isArray(w)?w.includes(r):w===r?E:null)||n(Ho.black)),e.preventDefault(),e.stopPropagation(),!0}if(PC({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=Cp(e.key,p,Yr);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),h=u.indexOf(p),f=Cp(e.key,h,u.length);if(f!==void 0){let b=u[f],x=t[b];return n(Array.isArray(x)?x[s]:x),!0}}if(o==="custom"){let p=i.indexOf(r),u=Cp(e.key,p,i.length);if(u!==void 0){let h=i[u];return n(h),!0}}return!1};import{jsx as NC}from"react/jsx-runtime";var RC=({children:e})=>NC("div",{className:"color-picker__heading",children:e}),yi=RC;import{jsx as bn,jsxs as Qs}from"react/jsx-runtime";var Ey=({color:e,onChange:o,label:t,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=by.useState(()=>r==="canvasBackground"?[]:dy(n,r,i)),[d,p]=ce(to),u=Cr({color:e,palette:i});xy(()=>{if(!d){let x=vp({color:e,palette:i}),T=x&&!m.includes(e);p(T?"hex":x?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[h,f]=OC(u?.shade??(r==="elementBackground"?nh:rh));xy(()=>{u?.shade!=null&&f(u.shade);let x=T=>{T.key===y.ALT&&s(!1)};return document.addEventListener("keyup",x,{capture:!0}),()=>{document.removeEventListener("keyup",x,{capture:!0})}},[u,s]);let b=by.useRef(null);return bn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Qs("div",{ref:b,onKeyDown:x=>{fy({event:x,activeColorPickerSection:d,palette:i,color:e,onChange:o,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:h,onEscape:c})&&(x.preventDefault(),x.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&Qs("div",{children:[bn(yi,{children:g("colorPicker.mostUsedCustomColors")}),bn(hy,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Qs("div",{children:[bn(yi,{children:g("colorPicker.colors")}),bn(gy,{color:e,label:t,palette:i,onChange:o,activeShade:h})]}),Qs("div",{children:[bn(yi,{children:g("colorPicker.shades")}),bn(uy,{hex:e,onChange:o,palette:i})]}),l]})})};import*as rc from"@radix-ui/react-popover";import e2 from"clsx";import{useRef as t2}from"react";import{useCallback as VC,useEffect as Sp,useRef as Ty,useState as WC}from"react";import{useEffect as UC,useRef as HC}from"react";import{createPortal as GC}from"react-dom";import yy from"react";var Ip=yy.createContext(null),ve=()=>yy.useContext(Ip);import{useState as FC,useLayoutEffect as vy}from"react";var ec=e=>{let[o,t]=FC(null),r=me(),{theme:n}=ve(),{container:i}=Ke();return vy(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===re.DARK))},[o,n,r.editor.isMobile,e?.className]),vy(()=>{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 BC}from"react";function vi(e,o,t){BC(()=>{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 zC}from"react";var Ir=e=>{let o=zC(e);return Object.assign(o.current,e),o.current};import{jsx as YC}from"react/jsx-runtime";var Sr=ye(null),wy=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=ec({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ve(),a=kr(),l=He(),s=$(a,i),c=Ir({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Ke();UC(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,h=l.canvas.getContext("2d"),f=({clientX:I,clientY:_})=>{let k=h.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return lh(k[0],k[1],k[2])},b=({clientX:I,clientY:_,altKey:k})=>{p.style.top=`${_+20}px`,p.style.left=`${I+20}px`;let R=f({clientX:I,clientY:_});u&&c.onChange(r,R,c.selectedElements,{altKey:k}),p.style.background=R},x=()=>{c.onCancel()},T=(I,_)=>{c.onSelect(I,_)},E=I=>{u=!0,I.stopImmediatePropagation()},w=I=>{u=!1,m?.focus(),I.stopImmediatePropagation(),I.preventDefault(),T(f(I),I)},S=I=>{I.key===y.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),x())};return n.tabIndex=-1,n.focus(),b({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",S),n.addEventListener("pointerdown",E),n.addEventListener("pointerup",w),window.addEventListener("pointermove",b,{passive:!0}),window.addEventListener("blur",x),()=>{u=!1,n.removeEventListener("keydown",S),n.removeEventListener("pointerdown",E),n.removeEventListener("pointerup",w),window.removeEventListener("pointermove",b),window.removeEventListener("blur",x)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=HC(null);return vi(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?GC(YC("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import KC from"clsx";import{Fragment as XC,jsx as tc,jsxs as Cy}from"react/jsx-runtime";var Iy=({color:e,onChange:o,label:t,colorPickerType:r})=>{let n=me(),[i,a]=WC(e),[l,s]=ce(to);Sp(()=>{a(e)},[e]);let c=VC(h=>{let f=h.toLowerCase(),b=Sy(f);b&&o(b),a(f)},[o]),m=Ty(null),d=Ty(null);Sp(()=>{m.current&&m.current.focus()},[l]);let[p,u]=ce(Sr);return Sp(()=>()=>{u(null)},[u]),Cy("div",{className:"color-picker__input-label",children:[tc("div",{className:"color-picker__input-hash",children:"#"}),tc("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:h=>{c(h.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:h=>{h.key!==y.TAB&&(h.key===y.ESCAPE&&d.current?.focus(),h.stopPropagation())}}),!n.editor.isMobile&&Cy(XC,{children:[tc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),tc("div",{ref:d,className:KC("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(h=>h?null:{keepOpenOnAlt:!1,onSelect:f=>o(f),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${y.I.toLocaleUpperCase()} or ${A("Alt")} `,children:Ab})]})]})};import JC from"react";import qC from"clsx";import*as wi from"@radix-ui/react-popover";import $C from"react";import ZC from"clsx";import{jsx as jC}from"react/jsx-runtime";var Qe=$C.forwardRef(({children:e,padding:o,className:t,style:r},n)=>jC("div",{className:ZC("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as kp,jsxs as QC}from"react/jsx-runtime";var oc=JC.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=me();return kp(wi.Portal,{container:o,children:QC(wi.Content,{ref:c,className:qC("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&&!Oh(document.activeElement)&&o.focus(),n()},children:[kp(Qe,{padding:3,style:r,children:t}),kp(wi.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{jsx as xo,jsxs as Lp}from"react/jsx-runtime";var ky=e=>{let o=new Option().style;return o.color=e,!!o.color},Sy=e=>Jr(e)?e:ky(`#${e}`)?`#${e}`:ky(e)?e:null,o2=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Ho,updateData:a})=>{let{container:l}=Ke(),[,s]=ce(to),[c,m]=ce(Sr),d=Lp("div",{children:[xo(yi,{children:g("colorPicker.hexCode")}),xo(Iy,{color:o,label:r,onChange:h=>{t(h)},colorPickerType:e})]}),p=t2(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return xo(oc,{container:l,style:{maxWidth:"13rem"},onFocusOutside:h=>{u(),h.preventDefault()},onPointerDownOutside:h=>{c&&h.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?xo(Ey,{palette:i,color:o,onChange:h=>{t(h)},onEyeDropperToggle:h=>{m(f=>h?(f=f||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},f.keepOpenOnAlt=!0,f):h===!1||f?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:h=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},r2=({label:e,color:o,type:t})=>xo(rc.Trigger,{type:"button",className:e2("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:xo("div",{className:"color-picker__button-outline"})}),Pa=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Ho,topPicks:a,updateData:l,appState:s})=>xo("div",{children:Lp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[xo(sy,{activeColor:o,onChange:t,type:e,topPicks:a}),xo(qs,{}),Lp(rc.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[xo(r2,{color:o,label:r,type:e}),s.openPopup===e&&xo(o2,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import nc,{useEffect as l2}from"react";import*as Ti from"@radix-ui/react-popover";import s2 from"clsx";import{jsx as n2}from"react/jsx-runtime";var Lr=({icon:e})=>n2("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as a2,jsx as Ly,jsxs as Ay}from"react/jsx-runtime";var i2=({label:e,open:o,openTrigger:t,children:r,className:n})=>Ay(a2,{children:[Ay("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,Ly(Lr,{icon:o?Qb:os})]}),o&&Ly("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Ra=i2;import{jsx as xn,jsxs as Ap}from"react/jsx-runtime";var c2=ye(!1);function d2({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=me(),l=u=>{let h=e.find(f=>f.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&h)r(h.value),u.preventDefault();else if(u.key===y.TAB){let f=e.findIndex(x=>x.value===o),b=u.shiftKey?(e.length+f-1)%e.length:(f+1)%e.length;r(e[b].value)}else if(an(u.key)){let f=qo().rtl,b=e.findIndex(x=>x.value===o);if(b!==-1){let x=e.length,T=b;switch(u.key){case(f?y.ARROW_LEFT:y.ARROW_RIGHT):T=(b+1)%x;break;case(f?y.ARROW_RIGHT:y.ARROW_LEFT):T=(x+b-1)%x;break;case y.ARROW_DOWN:{T=(b+(i??1))%x;break}case y.ARROW_UP:{T=(x+b-(i??1))%x;break}}r(e[T].value)}u.preventDefault()}else(u.key===y.ESCAPE||u.key===y.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ce(c2),m=nc.useMemo(()=>e.slice(0,i),[e,i]),d=nc.useMemo(()=>e.slice(i),[e,i]);l2(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>xn("div",{className:"picker-content",children:u.map((h,f)=>Ap("button",{type:"button",className:s2("picker-option",{active:o===h.value}),onClick:b=>{r(h.value)},title:`${h.text} ${h.keyBinding&&`\u2014 ${h.keyBinding.toUpperCase()}`}`,"aria-label":h.text||"none","aria-keyshortcuts":h.keyBinding||void 0,ref:b=>{o===h.value&&setTimeout(()=>{b?.focus()},0)},children:[h.icon,h.keyBinding&&xn("span",{className:"picker-keybinding",children:h.keyBinding})]},h.text))});return xn(Ti.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Ap("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&xn(Ra,{label:g("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function _p({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=nc.useState(!1),s=nc.useRef(null);return xn("div",{children:Ap(Ti.Root,{open:a,onOpenChange:c=>l(c),children:[xn(Ti.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&&xn(d2,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import D2,{useCallback as P2,useMemo as R2}from"react";import*as zy from"@radix-ui/react-popover";import S2,{useMemo as Ar,useState as k2,useRef as L2,useEffect as A2,useCallback as _2}from"react";import m2 from"clsx";import p2 from"react";import{jsx as u2,jsxs as g2}from"react/jsx-runtime";var ic=p2.forwardRef(({className:e,placeholder:o,onChange:t},r)=>g2("div",{className:m2("QuickSearch__wrapper",e),children:[Ft,u2("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import h2 from"clsx";import{Children as f2}from"react";import{jsx as _y}from"react/jsx-runtime";var ac=({className:e,placeholder:o,children:t})=>{let r=!f2.count(t);return _y("div",{className:h2("ScrollableList__wrapper",e),role:"menu",children:r?_y("div",{className:"empty",children:o}):t})};import{jsx as b2,jsxs as x2}from"react/jsx-runtime";var My=({children:e,className:o="",style:t,title:r})=>x2("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&b2("p",{className:"dropdown-menu-group-title",children:r}),e]}),Na=My;My.displayName="DropdownMenuGroup";import{useEffect as C2,useRef as I2}from"react";import E2,{useContext as y2}from"react";var Mp=E2.createContext({}),lc=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--sele