Files
fad_oa/ruoyi-ui/public/file-viewer/assets/prod-B0HxyDM0.js

149 lines
567 KiB
JavaScript
Raw Normal View History

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ar-SA-G6X2FPQ2-DIej4228.js","./chunk-SRAX5OIU-w1svEpmY.js","./package-Bop5TfAT.js","./runtime-core.esm-bundler-DO-WTVbd.js","./package-OvxnQO7z.css","./az-AZ-76LH7QW2-CS2qXUFa.js","./bg-BG-XCXSNQG7-9ujIdMwb.js","./bn-BD-2XOGV67Q-Bz4MKzNd.js","./ca-ES-6MX7JW3Y-CQ0i-M2m.js","./cs-CZ-2BRQDIVT-CNJY03Br.js","./da-DK-5WZEPLOC-kycNORr2.js","./de-DE-XR44H4JA-DgEFBHUE.js","./el-GR-BZB4AONW-DQbI2D0z.js","./en-B4ZKOASM-gYELMyZ6.js","./chunk-6U3AYISY-C6-Mtja1.js","./es-ES-U4NZUMDT-e1S39Ti1.js","./eu-ES-A7QVB2H4-BFR4rl79.js","./fa-IR-HGAKTJCU-D9rZqekR.js","./fi-FI-Z5N7JZ37-LaYcmFdb.js","./fr-FR-RHASNOE6-DaN_dVyx.js","./gl-ES-HMX3MZ6V-Dw-96yV4.js","./he-IL-6SHJWFNN-DSze4qOo.js","./hi-IN-IWLTKZ5I-BrDOKcx0.js","./hu-HU-A5ZG7DT2-B5MZHRE0.js","./id-ID-SAP4L64H-CLeuopyl.js","./it-IT-JPQ66NNP-CU1apqHk.js","./ja-JP-DBVTYXUO-B39Q-cJE.js","./kaa-6HZHGXH3-DNr0Hbws.js","./kab-KAB-ZGHBKWFO-DUqxtUd5.js","./kk-KZ-P5N5QNE5-oAQRY--4.js","./km-KH-HSX4SM5Z-aIsalLJg.js","./ko-KR-MTYHY66A-Dxxq4OHv.js","./ku-TR-6OUDTVRD-cGosJj47.js","./lt-LT-XHIRWOB4-BrbcDiBa.js","./lv-LV-5QDEKY6T-BJB3sRF-.js","./mr-IN-CRQNXWMA-DYl82JZe.js","./my-MM-5M5IBNSE-CdnDB-54.js","./nb-NO-T6EIAALU-T-ly9gG2.js","./nl-NL-IS3SIHDZ-CZqPZnHj.js","./nn-NO-6E72VCQL-CvMupQbc.js","./oc-FR-POXYY2M6-BRlPd_BR.js","./pa-IN-N4M65BXN-BfVUAlRi.js","./percentages-BXMCSKIN-C5NgCvxl.js","./chunk-Z3N5DIM6-D9TMVU7m.js","./pl-PL-T2D74RX3-CXvOHlyd.js","./pt-BR-5N22H2LF-CAHMJIN0.js","./pt-PT-UZXXM6DQ-9stw3O1j.js","./ro-RO-JPDTUUEW-_Ym6U2of.js","./ru-RU-B4JR7IUQ-DWUO9__j.js","./si-LK-N5RQ5JYF-DOuaKjIP.js","./sk-SK-C5VTKIMK-D04wnRn8.js","./sl-SI-NN7IZMDC-DlSoyI38.js","./sv-SE-XGPEYMSR-y8nUmsTq.js","./ta-IN-2NMHFXQM-BTlY1MOo.js","./th-TH-HPSO5L25-B0-Jm0dR.js","./tr-TR-DEFEU3FU-CuiTnA8n.js","./uk-UA-QMV73CPH-za143PJQ.js","./vi-VN-M7AON7JQ-BkwUlhW4.js","./zh-CN-LNUGB5OW-CLMN5wFH.js","./zh-HK-E62DVLB3-BQAhIarC.js","./zh-TW-RAJ6MFWO-D3o6FRFS.js","./image-GAAHSSAO-Di-5eHoS.js","./chunk-K2UTITRG-BEkZoneJ.js","./chunk-ZUYEQ4TG-BzFOpW--.js","./dist-Bgk0P6Wx.js","./chunk-O5CBEL6O-Bu7jDUJy.js","./src-BrOGWJpF.js","./chunk-5ZQYHXKU-D-OgLpMs.js","./dist-idVqPIzq.js","./chunk-AGHRB4JF-Fz9kp2Fp.js","./chunk-CSCIHK7Q-VDPd5eNJ.js","./chunk-3OPIFGDE-BBTvqaNI.js","./chunk-L5ZTLDWV-CzNJ_8is.js","./chunk-NZK2D7GU-Cte2JwiA.js","./rough.esm-DjrMDdlL.js","./chunk-BSJP7CBP-BkJdmh17.js","./chunk-KSCS5N6A-BuXf0YOu.js","./chunk-LZXEDZCA-n9zJSIw5.js","./chunk-WU5MYG2G-h67ucwKy.js","./chunk-XPW4576I-SsWL9gHk.js"])))=>i.map(i=>d[i]);
import{D as e,M as t,r as n}from"./package-Bop5TfAT.js";import{t as r}from"./chunk-ZUYEQ4TG-BzFOpW--.js";import{i,n as a,r as o}from"./chunk-SRAX5OIU-w1svEpmY.js";import{$ as s,$a as c,$c as l,$i as u,$l as d,$n as f,$o as p,$r as m,$s as h,$t as g,$u as _,A as v,Aa as y,Ac as b,Ai as x,Al as S,An as C,Ao as w,Ar as T,As as ee,At as te,B as ne,Ba as re,Bc as ie,Bi as ae,Bl as oe,Bn as se,Bo as ce,Br as le,Bs as ue,Bt as de,Bu as fe,C as pe,Ca as me,Cc as he,Ci as ge,Cl as _e,Cn as ve,Co as ye,Cr as be,Cs as xe,Ct as Se,Cu as Ce,D as we,Da as Te,Dc as Ee,Di as De,Dl as Oe,Dn as ke,Do as Ae,Dr as je,Ds as Me,Dt as Ne,Du as Pe,E as Fe,Ea as Ie,Ec as Le,Ei as Re,El as ze,En as Be,Eo as Ve,Er as He,Es as Ue,Et as We,Eu as Ge,F as Ke,Fc as qe,Fi as Je,Fl as Ye,Fn as Xe,Fo as Ze,Fr as Qe,Fs as $e,Ft as et,Fu as tt,G as nt,Gc as rt,Gi as it,Gl as at,Gn as ot,Go as st,Gr as ct,Gs as lt,Gt as ut,Gu as dt,H as ft,Ha as pt,Hc as mt,Hi as ht,Hl as gt,Hn as _t,Ho as vt,Hr as E,Hs as yt,Ht as bt,Hu as xt,I as St,Ia as Ct,Ic as wt,Ii as Tt,Il as Et,In as Dt,Io as Ot,Ir as kt,Is as At,It as jt,Iu as Mt,J as Nt,Ja as Pt,Jc as Ft,Ji as It,Jl as Lt,Jn as Rt,Jo as zt,Jr as Bt,Js as Vt,Jt as Ht,Ju as Ut,K as D,Ka as Wt,Kc as Gt,Ki as Kt,Kl as qt,Kn as Jt,Ko as Yt,Kr as Xt,Ks as Zt,Kt as Qt,Ku as $t,L as en,La as tn,Lc as nn,Li as rn,Ll as an,Ln as O,Lo as on,Lr as sn,Ls as cn,Lt as ln,Lu as un,M as dn,Ma as fn,Mc as pn,Mi as mn,Ml as hn,Mn as gn,Mo as _n,Mr as vn,Ms as yn,Mt as bn,Mu as xn,N as Sn,Na as Cn,Nc as wn,Ni as Tn,Nl as k,Nn as En,No as A,Nr as Dn,Ns as On,Nt as kn,Nu as An,O as jn,Oa as Mn,Oc as Nn,Oi as Pn,Ol as Fn,On as In,Oo as Ln,Or as Rn,Os as zn,Ot as Bn,Ou as Vn,P as Hn,Pa as Un,Pc as Wn,Pi as Gn,Pl as Kn,Pn as qn,Po as Jn,Pr as Yn,Pt as Xn,Pu as Zn,Q as Qn,Qa as $n,Qc as er,Qi as tr,Ql as nr,Qn as rr,Qo as ir,Qr as ar,Qs as or,Qt as sr,Qu as cr,R as lr,Ra as ur,Rc as dr,Ri as fr,Rl as pr,Rn as mr,Ro as j,Rr as hr,Rs as gr,Rt as _r,Ru as vr,S as yr,Sa as br,Sc as xr,Si as Sr,Sl as Cr,Sn as wr,So as M,Sr as Tr,Ss as Er,St as Dr,Su as Or,Ta as kr,Tc as N,Ti as Ar,Tl as jr,Tn as Mr,To as Nr,Tr as Pr,Ts as Fr,Tt as Ir,Tu as Lr,U as Rr,Ua as zr,Uc as Br,Ui as Vr,Ul as Hr,Un as Ur,Uo as Wr,Ur as Gr,Us as Kr,Ut as qr,Uu as Jr,V as Yr,Va as Xr,Vc as Zr,Vi as Qr,Vl as P,Vn as $r,Vo as ei,Vr as ti,Vs as ni,Vt as ri,Vu as ii,W as ai,Wa as oi,Wc as si,Wi as ci,Wl as li,Wn as ui,Wo as di,Wr as fi,Ws as pi,Wt as F,Wu as mi,X as hi,Xa as gi,Xc as _i,Xi as vi,Xl as yi,Xn as bi,Xo as xi,Xr as Si,Xs as I,Xt as Ci,Xu as wi,Y as Ti,Yc as Ei,Yi as Di,Yl as Oi,Yn as ki,Yo as Ai,Yr as ji,Ys as Mi,Yu as Ni,Z as Pi,Za as Fi,Zc as Ii,Zi as Li,Zl as Ri,Zn as zi,Zo as Bi,Zr as Vi,Zs as Hi,Zt as Ui,Zu as L,_ as Wi,_a as Gi,_c as Ki,_i as qi,_l as Ji,_n as Yi,_o as Xi,_r as Zi,_s as Qi,_t as R,_u as $i,a as ea,aa as ta,ac as na,ai as ra,al as ia,an as aa,ao as oa,ar as sa,as as ca,at as la,au as ua,b as da,ba as fa,bc as pa,bi as ma,bl as ha,bn as ga,bo as _a,br as va,bs as ya,bt as ba,bu as xa,c as Sa,ca as Ca,cc as wa,ci as Ta,cl as Ea,cn as Da,co as Oa,cr as ka,cs as Aa,cu as z,d as ja,da as Ma,dc as Na,di as Pa,dl as Fa,dn as Ia,do as La,dr as Ra,ds as za,dt as Ba,du as Va,ea as Ha,ec as B,ed as Ua,ei as Wa,el as Ga,en as Ka,eo as qa,er as Ja,es as Ya,et as Xa,eu as Za,f as Qa,fa as $a,fc as eo,fi as to,fl as no,fn as ro,fo as io,fr as ao,fs as oo,ft as so,fu as co,g as lo,ga as uo,gc as fo,gi as po,gl as mo,gn as ho,go,gr as _o,gs as vo,gt as yo,gu as bo,h as xo,ha as V,hc as So,hi as Co,hl as wo,hn as H,ho as To,hr as Eo,hs as Do,ht as Oo,hu as ko,i as Ao,ic as jo,ii as Mo,il as No,in as Po,io as Fo,ir as Io,is as Lo,it as Ro,iu as zo,j as Bo,ja as Vo,jc as Ho,ji as Uo,jl as Wo,jn as Go,jo as Ko,jr as qo,js as Jo,jt as Yo,ju as Xo,k as Zo,ka as Qo,ki as $o,kl as es,kn as ts,ko as ns,kr as rs,ks as is,kt as as,ku as os,l as ss,la as cs,lc as ls,li as us,ll as ds,ln as fs,lo as ps,lr as ms,ls as hs,lt as gs,lu as _s,m as vs,ma as ys,mc as bs,mi as xs,ml as Ss,mn as Cs,mo as ws,mr as Ts,ms as Es,mt as Ds,na as Os,nc as ks,nd as As,ni as js,nl as Ms,n
.${th} {
overflow: hidden ${r};
padding-right: ${s}px ${r};
}
body[${kh}] {
overflow: hidden ${r};
overscroll-behavior: contain;
${[t&&`position: relative ${r};`,n===`margin`&&`
padding-left: ${i}px;
padding-top: ${a}px;
padding-right: ${o}px;
margin-left:0;
margin-top:0;
margin-right: ${s}px ${r};
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
}
.${$m} {
right: ${s}px ${r};
}
.${eh} {
margin-right: ${s}px ${r};
}
.${$m} .${$m} {
right: 0 ${r};
}
.${eh} .${eh} {
margin-right: 0 ${r};
}
body[${kh}] {
${nh}: ${s}px;
}
`},jh=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Mh=function(){K.useEffect(function(){return document.body.setAttribute(kh,(jh()+1).toString()),function(){var e=jh()-1;e<=0?document.body.removeAttribute(kh):document.body.setAttribute(kh,e.toString())}},[])},Nh=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Mh();var a=K.useMemo(function(){return Dh(i)},[i]);return K.createElement(Oh,{styles:Ah(a,!t,i,n?``:`!important`)})},Ph=!1;if(typeof window<`u`)try{var Fh=Object.defineProperty({},"passive",{get:function(){return Ph=!0,!0}});window.addEventListener(`test`,Fh,Fh),window.removeEventListener(`test`,Fh,Fh)}catch{Ph=!1}var Ih=Ph?{passive:!1}:!1,Lh=function(e){return e.tagName===`TEXTAREA`},Rh=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Lh(e)&&n[t]===`visible`)},zh=function(e){return Rh(e,`overflowY`)},Bh=function(e){return Rh(e,`overflowX`)},Vh=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Wh(e,r)){var i=Gh(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Hh=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Uh=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Wh=function(e,t){return e===`v`?zh(t):Bh(t)},Gh=function(e,t){return e===`v`?Hh(t):Uh(t)},Kh=function(e,t){return e===`h`&&t===`rtl`?-1:1},qh=function(e,t,n,r,i){var a=Kh(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Gh(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Wh(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Jh=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Yh=function(e){return[e.deltaX,e.deltaY]},Xh=function(e){return e&&`current`in e?e.current:e},Zh=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qh=function(e){return`
.block-interactivity-${e} {pointer-events: none;}
.allow-interactivity-${e} {pointer-events: all;}
`},$h=0,eg=[];function tg(e){var t=K.useRef([]),n=K.useRef([0,0]),r=K.useRef(),i=K.useState($h++)[0],a=K.useState(Ch)[0],o=K.useRef(e);K.useEffect(function(){o.current=e},[e]),K.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Qm([e.lockRef.current],(e.shards||[]).map(Xh),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=K.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Jh(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Vh(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Vh(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return qh(h,t,e,h===`h`?s:c,!0)},[]),c=K.useCallback(function(e){var n=e;if(!(!eg.length||eg[eg.length-1]!==a)){var r=`deltaY`in n?Yh(n):Jh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Zh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Xh).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=K.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ng(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=K.useCallback(function(e){n.current=Jh(e),r.current=void 0},[]),d=K.useCallback(function(t){l(t.type,Yh(t),t.target,s(t,e.lockRef.current))},[]),f=K.useCallback(function(t){l(t.type,Jh(t),t.target,s(t,e.lockRef.current))},[]);K.useEffect(function(){return eg.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ih),document.addEventListener(`touchmove`,c,Ih),document.addEventListener(`touchstart`,u,Ih),function(){eg=eg.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ih),document.removeEventListener(`touchmove`,c,Ih),document.removeEventListener(`touchstart`,u,Ih)}},[]);var p=e.removeScrollBar,m=e.inert;return K.createElement(K.Fragment,null,m?K.createElement(a,{styles:Qh(i)}):null,p?K.createElement(Nh,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ng(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var rg=fh(ph,tg),ig=K.forwardRef(function(e,t){return K.createElement(hh,Xm({},e,{ref:t,sideCar:rg}))});ig.classNames=hh.classNames;var ag=`Popover`,[og,sg]=$u(ag,[fm]),cg=fm(),[lg,ug]=og(ag),dg=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=cg(t),c=K.useRef(null),[l,u]=K.useState(!1),[d=!1,f]=zm({prop:r,defaultProp:i,onChange:a});return(0,q.jsx)(Om,{...s,children:(0,q.jsx)(lg,{scope:t,contentId:Kd(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:K.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:K.useCallback(()=>u(!0),[]),onCustomAnchorRemove:K.useCallback(()=>u(!1),[]),modal:o,children:n})})};dg.displayName=ag;var fg=`PopoverAnchor`,pg=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ug(fg,n),a=cg(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return K.useEffect(()=>(o(),()=>s()),[o,s]),(0,q.jsx)(km,{...a,...r,ref:t})});pg.displayName=fg;var mg=`PopoverTrigger`,hg=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ug(mg,n),a=cg(n),o=Qu(t,i.triggerRef),s=(0,q.jsx)(sd.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":kg(i.open),...r,ref:o,onClick:Yu(e.onClick,i.onOpenToggle)});retur
${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),mb=(e,t)=>{let n=(0,K.useContext)(fb);return Rl(e,e=>{let r=new CustomEvent(`menu.itemSelect`,{bubbles:!0,cancelable:!0});t?.(r),r.defaultPrevented||n.onSelect?.(r)})},hb=({textStyle:e,icon:t,shortcut:n,children:r})=>{let i=Dk();return(0,q.jsxs)(q.Fragment,{children:[t&&(0,q.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,q.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:r}),n&&!i.editor.isMobile&&(0,q.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},gb=({icon:e,value:t,order:n,children:r,shortcut:i,className:a,hovered:o,selected:s,textStyle:c,onSelect:l,onClick:u,...d})=>{let f=mb(u,l),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>{o&&(n===0?p.current?.scrollIntoView({block:`end`}):p.current?.scrollIntoView({block:`nearest`}))},[o,n]),(0,q.jsx)(`button`,{...d,ref:p,value:t,onClick:f,className:pb(a,s,o),title:d.title??d[`aria-label`],children:(0,q.jsx)(hb,{textStyle:c,icon:e,shortcut:i,children:r})})};gb.displayName=`DropdownMenuItem`;var _b={GREEN:`green`,RED:`red`,BLUE:`blue`},vb=({type:e=_b.BLUE,children:t})=>{let{theme:n}=Ak(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===B.LIGHT?`1.5px solid white`:`none`};switch(e){case _b.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case _b.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case _b.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,q.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};vb.displayName=`DropdownMenuItemBadge`,gb.Badge=vb;var yb=gb,bb=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===E.F)return t.current?.focus(),!0;if(e.key===E.ESCAPE)return i(),!0;if(e.key===E.ENTER)return n?.value&&a(n.value),!0;if(e.key===E.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===E.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},xb=K.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=Ok(),{fonts:c}=Tk(),{showDeprecatedFonts:l}=Ek(),[u,d]=(0,K.useState)(``),f=(0,K.useRef)(null),p=(0,K.useMemo)(()=>Array.from(Eo.registered.entries()).filter(([e,{metadata:t}])=>!t.serverSide&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:t.icon??bs,text:n[0]?.fontFace?.family??`Unknown`};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:_b.RED,placeholder:J(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),m=(0,K.useMemo)(()=>new Set(c.getSceneFamilies()),[e]),h=(0,K.useMemo)(()=>p.filter(e=>m.has(e.value)),[p,m]),g=(0,K.useMemo)(()=>p.filter(e=>!m.has(e.value)&&(l||!e.deprecated)),[p,m,l]),_=(0,K.useMemo)(()=>Ce([...h,...g].filter(e=>e.text?.toLowerCase().includes(u))),[h,g,u]),v=(0,K.useMemo)(()=>{let n;return t?n=_.find(e=>e.value===t):e&&(n=_.find(t=>t.value===e)),!n&&u&&(_[0]?.value?r(_[0].value):i()),n},[t,e,u,_,r,i]),y=(0,K.useCallback)(e=>{bb({event:e,inputRef:f,hoveredFont:v,filteredFonts:_,onSelect:n,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[v,_,n,r,o]);(0,K.useEffect)(()=>(a(),()=>{o()}),[]);let b=(0,K.useMemo)(()=>_.filter(e=>m.has(e.value)),[_,m]),x=(0,K.useMemo)(()=>_.filter(e=>!m.has(e.value)),[_,m]),S=(t,i)=>(0,q.jsxs)(yb,{icon:t.icon,value:t.value,order:i,textStyle:{fontFamily:di({fontFamily:t.value})},hovered:t.value===v?.value,selected:t.value===e,tabIndex:t.value===e?0:-1,onClick:e=>{n(Number(e.currentTarget.value))},onMouseMove:()=>{v?.value!==t.value&&r(t.value)},children:[t.text,t.badge&&(0,q.jsx)(vb,{type:t.badge.type,children:t.badge.placeholder})]},t.value),C=[];return b.length&&C.push((0,q.jsx)(db,{title:J(`fontList.sceneFonts`),children:b.map(S)}
${J(`hints.firefox_clipboard_write`)}`):Error(J(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},nx=async(e,t,n,r)=>{let{exportBackground:i,viewBackgroundColor:a,fileHandle:o}=t,s=ve(o);if(!o||!Qn(s))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);t={...t,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:l}=ex(e,t,!1);return await tx(s,c,t,n,{exportBackground:i,viewBackgroundColor:a,name:r,fileHandle:o,exportingFrame:l}),{fileHandle:o}},rx=({children:e,checked:t,onChange:n,className:r})=>(0,q.jsxs)(`div`,{className:L(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,q.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:hl}),(0,q.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),ix=O({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,q.jsx)(Zb,{label:J(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),ax=O({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=R(e),i=xc(r,t)?W(r,t):r;return(0,q.jsx)(q.Fragment,{children:nt.map(e=>{let[r,a]=xs(i,10,e),o=`${J(`imageExportDialog.label.scale`)} ${e}x (${r}x${a})`;return(0,q.jsx)(Y,{size:`small`,type:`radio`,icon:`${e}x`,name:`export-canvas-scale`,title:o,"aria-label":o,id:`export-canvas-scale`,checked:e===t.exportScale,onChange:()=>n(e)},e)})})}}),ox=O({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,q.jsx)(rx,{checked:e.exportBackground,onChange:e=>t(e),children:J(`imageExportDialog.label.withBackground`)})}),sx=O({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,q.jsxs)(rx,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[J(`imageExportDialog.label.embedScene`),(0,q.jsx)(Bb,{label:J(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,q.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:Yt})})]})}),cx=O({name:`saveToActiveFile`,label:`buttons.save`,icon:ss,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{let i=!!t.fileHandle;try{let{fileHandle:n}=it(t.fileHandle)?await nx(e,t,r.files,r.getName()):await Cl(e,t,r.files,r.getName());return{captureUpdate:j.EVENTUALLY,appState:{...t,fileHandle:n,toast:i?{message:n?.name?J(`toast.fileSavedToFilename`).replace(`{filename}`,`"${n.name}"`):J(`toast.fileSaved`)}:null}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.EVENTUALLY}}},keyTest:e=>e.key===E.S&&e[E.CTRL_OR_CMD]&&!e.shiftKey}),lx=O({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:ss,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{try{let{fileHandle:n}=await Cl(e,{...t,fileHandle:null},r.files,r.getName());return{captureUpdate:j.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:n,toast:{message:J(`toast.fileSaved`)}}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.EVENTUALLY}}},keyTest:e=>e.key===E.S&&e.shiftKey&&e[E.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,q.jsx)(Y,{type:`button`,icon:Al,title:J(`buttons.saveAs`),"aria-label":J(`buttons.saveAs`),showAriaLabel:Dk().editor.isMobile,hidden:!Ni,onClick:()=>e(null),"data-testid":`save-as-but
`),r=[],i=0;for(let e=0;e<n.length;e++){let a=n[e],o=n[e+1];if(o){let e=t.indexOf(o,i);if(e>a.length+i){let t=e-(a.length+i);for(;t>0;)a+=` `,t--}}r.push(a),i+=a.length}return r.join(`
`)},bE=(e,t,n)=>{let r=yE(e.text,e.originalText).split(`
`),i=[],a=0,o=0;for(let e of r){let t=a,n=t+e.length-1;i.push({line:e,startIndex:t,endIndex:n,lineNumber:o}),a=n+1,o++}let s=n,c=e.originalText.slice(n,n+t.length),l=[];for(let t of i){if(c===``)break;if(s>=t.startIndex&&s<=t.endIndex){let n=t.endIndex+1-s,r=t.line.slice(0,s-t.startIndex),i=c.slice(0,n);c=c.slice(n);let a=yn(r,Ds(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=yn(t.line,Ds(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=yn(i,Ds(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u}),s+=n}}return l},xE=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),SE=(0,lv.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements().filter(e=>I(e));r.sort((e,t)=>e.y-t.y);let i=[],a=new RegExp(xE(e),`gi`);for(let t of r){let n=null,r=t.originalText;for(;(n=a.exec(r))!==null;){let a=vE(r,n.index,e),o=bE(t,e,n.index);o.length>0&&i.push({textElement:t,searchQuery:e,preview:a,index:n.index,matchedLines:o})}}let o=new Set(t.visibleElements.map(e=>e.id));n(i,i.findIndex(e=>o.has(e.textElement.id))??null)},mE),CE=sE(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsx)(UT.Trigger,{...e,className:`default-sidebar-trigger`,name:Bs.name})})});CE.displayName=`DefaultSidebarTrigger`;var wE=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=RC();return(0,q.jsx)(t.In,{children:e})};wE.displayName=`DefaultTabTriggers`;var TE=Object.assign(sE(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=Uy(),o=jk(),{DefaultSidebarTabTriggersTunnel:s}=RC(),c=a.openSidebar?.tab===qr;return(0,K.createElement)(UT,{...i,name:`default`,key:`default`,className:L(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:Rl(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,q.jsxs)(UT.Tabs,{children:[(0,q.jsx)(UT.Header,{children:(0,q.jsxs)(UT.TabTriggers,{children:[(0,q.jsx)(UT.TabTrigger,{tab:qr,children:ja}),(0,q.jsx)(UT.TabTrigger,{tab:Mc,children:mn}),(0,q.jsx)(s.Out,{})]})}),(0,q.jsx)(UT.Tab,{tab:Mc,children:(0,q.jsx)(EC,{})}),(0,q.jsx)(UT.Tab,{tab:qr,children:(0,q.jsx)(hE,{})}),e]}))}),{Trigger:CE,TabTriggers:wE}),EE=`small`,DE=e=>(0,q.jsxs)(`label`,{className:L(`ToolIcon ToolIcon__LaserPointer`,`ToolIcon_size_${EE}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":`toolbar-LaserPointer`}),(0,q.jsx)(`div`,{className:`ToolIcon__icon`,children:Vc})]}),OE=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},kE=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i})=>{let a=e.current,o=a?.parentElement;if(!(!a||!o)){if(!n){OE({canvasRef:e,setError:r});return}try{let e=await t.api,s;try{s=await e.parseMermaidToExcalidraw(n)}catch{s=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}let{elements:c,files:l={}}=s;r(null),i.current={elements:dO(c,{regenerateIds:!0}),files:l};let u=await es({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(o.offsetWidth,o.offsetHeight)*window.devicePixelRatio});try{await zo(u)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(J(`canvasError.canvasTooBig`)):e}o.style.background=`var(--default-bg-color)`,a.replaceChildren(u)}catch(e){throw o.style.background=`var(--default-bg-color)`,n&&r(e),e}}},AE=e=>{GS.set(al.MERMAID_TO_EXCALIDRAW,e)},jE=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{let{elements:i,files:a}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:a,position:`center`,fitToContent:!0}),e.setOpenDialog(null),r&&n&&AE(n))},ME=({children:e})=>(0,q.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),NE=({label:e,children:t,panelAction:n,panelActionDisabled:r=!1,onTextSubmi
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]`,zE=Ec(AE,300),BE=({mermaidToExcalidrawLib:e})=>{let[t,n]=(0,K.useState)(()=>GS.get(al.MERMAID_TO_EXCALIDRAW)||RE),r=(0,K.useDeferredValue)(t.trim()),[i,a]=(0,K.useState)(null),o=(0,K.useRef)(null),s=(0,K.useRef)({elements:[],files:null}),c=Tk();(0,K.useEffect)(()=>{kE({canvasRef:o,data:s,mermaidToExcalidrawLib:e,setError:a,mermaidDefinition:r}).catch(e=>{Me()&&console.error(`Failed to parse mermaid definition`,e)}),zE(r)},[r,e]),(0,K.useEffect)(()=>()=>{zE.flush()},[]);let l=()=>{jE({app:c,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,q.jsx)(HS,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,children:e}),sequenceLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,children:e}),classLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,children:e})})}),(0,q.jsxs)(ME,{children:[(0,q.jsx)(NE,{label:J(`mermaid.syntax`),children:(0,q.jsx)(PE,{input:t,placeholder:`Write Mermaid diagram defintion here...`,onChange:e=>n(e.target.value),onKeyboardSubmit:()=>{l()}})}),(0,q.jsx)(NE,{label:J(`mermaid.preview`),panelAction:{action:()=>{l()},label:J(`mermaid.button`),icon:oc},renderSubmitShortcut:()=>(0,q.jsx)(LE,{}),children:(0,q.jsx)(IE,{canvasRef:o,loaded:e.loaded,error:i})})]})]})},VE=e=>{let t=jk(),n=(0,K.useRef)(null),r=(0,K.useRef)(0);return(0,q.jsx)(av,{ref:n,className:`ttd-dialog-tabs-root`,value:e.tab,onValueChange:i=>{if(!i)return;let a=n.current?.closest(`.Modal__content`);if(a){let e=a.offsetHeight||0;e>r.current&&(r.current=e,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog===`ttd`&&ic([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};VE.displayName=`TTDDialogTabs`;var HE=VE,UE=({children:e,...t})=>(0,q.jsx)(ov,{className:`ttd-dialog-triggers`,...t,children:e});UE.displayName=`TTDDialogTabTriggers`;var WE=({children:e,tab:t,onSelect:n,...r})=>(0,q.jsx)(sv,{value:t,asChild:!0,onSelect:n,children:(0,q.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});WE.displayName=`TTDDialogTabTrigger`;var GE=({tab:e,children:t,...n})=>(0,q.jsx)(cv,{...n,value:e,children:t});GE.displayName=`TTDDialogTab`;var KE=3,qE=1e3,JE=au(null),YE=au(null),XE=e=>{let t=Uy();return t.openDialog?.name===`ttd`?(0,q.jsx)(ZE,{...e,tab:t.openDialog.tab}):null},ZE=sE(`TTDDialogBase`,({tab:e,...t})=>{let r=Tk(),i=jk(),a=(0,K.useRef)(null),[o,s]=Dv(YE),[c,l]=(0,K.useState)(o?.prompt??``),u=c.trim(),d=e=>{l(e.target.value),s(t=>({generatedResponse:t?.generatedResponse??null,prompt:e.target.value}))},[f,p]=(0,K.useState)(!1),[m,h]=Dv(JE),g=async()=>{if(u.length>qE||u.length<KE||f||m?.rateLimitRemaining===0||`__fallback`in t){u.length<KE&&S(Error(`Prompt is too short (min ${KE} characters)`)),u.length>qE&&S(Error(`Prompt is too long (max ${qE} characters)`));return}try{p(!0),X(`ai`,`generate`,`ttd`);let{generatedResponse:e,error:n,rateLimit:r,rateLimitRemaining:i}=await t.onTextSubmit(u);if(typeof e==`string`&&s(t=>({generatedResponse:e,prompt:t?.prompt??null})),Io(r)&&Io(i)&&h({rateLimit:r,rateLimitRemaining:i}),n){S(n);return}if(!e){S(Error(`Generation failed`));return}try{await kE({canvasRef:a,data:b,mermaidToExcalidrawLib:v,setError:S,mermaidDefinition:e}),X(`ai`,`mermaid parse success`,`ttd`)}catch(e){console.info(`%cTTD mermaid render errror: ${e.message}`,`color: red`),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
TTD mermaid definition render errror: ${e.message}`,`color: yellow`),X(`ai`,`mermaid parse failed`,`ttd`),S(Error(`Generated an invalid diagram :(. You may also try a different prompt.`))}}catch(e){let t=e.message;(!t||t===`Failed to fetch`)&&(t=`Request failed`),S(Error(t))}finally{p(!1)}},_=(0,K.useRef)(g);_.current=g;let[v,y]=(0,K.useState)({loaded:!1,api:n(()=>import(`./dist-Bgk0P6Wx.js`),__vite__mapDeps([64,2,3,4,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79]),import.meta.url)});(0,K.useEffect)(()=>{(async()=>{await v.api,y(e=>({...e,loaded:!0}))})()},[v.api]);let b=(0,K.useRef)({elements:[],files:null}),[x,S]=(0,K.useState)(null);return(0,q.jsx)(OC,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:(0,q.jsxs)(HE,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,q.jsx)(`p`,{className:`dialog-mermaid-title`,children:J(`mermaid.title`)}):(0,q.jsxs)(UE,{children:[(0,q.jsx)(WE,{tab:`text-to-diagram`,children:(0,q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[J(`labels.textToDiagram`),(0,q.jsx)(`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`})]})}),(0,q.jsx)(WE,{tab:`mermaid`,children:`Mermaid`})]}),(0,q.jsx)(GE,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,q.jsx)(BE,{mermaidToExcalidrawLib:v})}),!(`__fallback`in t)&&(0,q.jsxs)(GE,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:[(0,q.jsx)(`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.`}),(0,q.jsxs)(ME,{children:[(0,q.jsx)(NE,{label:J(`labels.prompt`),panelAction:{action:g,label:`Generate`,icon:oc},onTextSubmitInProgess:f,panelActionDisabled:u.length>qE||m?.rateLimitRemaining===0,renderTopRight:()=>m?(0,q.jsxs)(`div`,{className:`ttd-dialog-rate-limit`,style:{fontSize:12,marginLeft:`auto`,color:m.rateLimitRemaining===0?`var(--color-danger)`:void 0},children:[m.rateLimitRemaining,` requests left today`]}):null,renderSubmitShortcut:()=>(0,q.jsx)(LE,{}),renderBottomRight:()=>{if(typeof o?.generatedResponse==`string`)return(0,q.jsxs)(`div`,{className:`excalidraw-link`,style:{marginLeft:`auto`,fontSize:14},onClick:()=>{typeof o?.generatedResponse==`string`&&(AE(o.generatedResponse),i({openDialog:{name:`ttd`,tab:`mermaid`}}))},children:[`View as Mermaid`,(0,q.jsx)(rb,{icon:oc})]});let e=u.length/qE;return e>.8?(0,q.jsxs)(`div`,{style:{marginLeft:`auto`,fontSize:12,fontFamily:`monospace`,color:e>1?`var(--color-danger)`:void 0},children:[`Length: `,u.length,`/`,qE]}):null},children:(0,q.jsx)(PE,{onChange:d,input:c,placeholder:`Describe what you want to see...`,onKeyboardSubmit:()=>{_.current()}})}),(0,q.jsx)(NE,{label:`Preview`,panelAction:{action:()=>{console.info(`Panel action clicked`),jE({app:r,data:b})},label:`Insert`,icon:oc},children:(0,q.jsx)(IE,{canvasRef:a,error:x,loaded:v.loaded})})]})]})]})})}),QE=.01,$E=(e,t)=>!(t===`height`&&I(e)||t===`width`&&I(e)||t===`angle`&&A(e)),eD=(e,t)=>{let n=e+t/2;return n-n%t},tD=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>e.original!==void 0&&e.latest!==void 0),nD=(e,t,n,r,i,a,o,s=!0)=>{let c=r.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=Zc(P(n.x,n.y),P(l,u),n.angle),p=e-d,m=t-f,[h,g]=Zc(P(e,t),P(l+p,u+m),-n.angle);V(c,{x:h,y:g},s),iD(c,r,i,a);let _=dr(n,o);if(_){let e=r.get(_.id);e&&V(e,{x:_.x+p,y:_.y+m},s)}},rD=(e,t)=>{let n=_n(t).map(t=>Wc(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!qs(e)).forEach(e=>{n.push({[e.id]:!0})}),n},iD=(e,t,n,r,i)=>{c(e)?jn([e],t,n,r,!0,[],i?.zoom):ga(e,t,i)},aD=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1})=>{let d=Tk(),f=(0,K.useRef)(null),p=(0,K.useRef)(null),[m,h]=(0,K.useState)(r.toString()),g=(0,K.useRef)
`).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},b=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},x=!1,S=()=>{if(re)return;re=!0,C();let e=Ol.getScene(i)?.getElement(i.id);if(!e)return;let t=ia(e,c.scene.getNonDeletedElementsMap());if(t){if(f.value.trim()){let e=me(t);!e||e!==i.id?V(t,{boundElements:(t.boundElements||[]).concat({type:`text`,id:i.id})}):st(t)&&na(t)}else V(t,{boundElements:t.boundElements?.filter(e=>!I(e))});cs(e,t,c.scene.getNonDeletedElementsMap())}n({viaKeyboard:x,nextOriginalText:f.value})},C=()=>{f.onblur=null,f.oninput=null,f.onkeydown=null,ie&&ie.disconnect(),window.removeEventListener(`resize`,d),window.removeEventListener(`wheel`,b,!0),window.removeEventListener(`pointerdown`,ee),window.removeEventListener(`pointerup`,w),window.removeEventListener(`blur`,S),window.removeEventListener(`beforeunload`,S),te(),ne(),f.remove()},w=e=>{window.removeEventListener(`pointerup`,w);let t=e?.target,n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);setTimeout(()=>{f.onblur=S,n||f.focus()})},T=()=>{f.onblur=null,window.addEventListener(`pointerup`,w),window.addEventListener(`blur`,S)},ee=e=>{let t=e?.target;if(e.button===Ll.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),c.handleCanvasPanUsingWheelOrSpaceDrag(e)),T();return}let n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);(e.target instanceof HTMLElement||e.target instanceof SVGElement)&&e.target.closest(`.${oo.SHAPE_ACTIONS_MENU}, .${oo.ZOOM_ACTIONS}`)&&!qa(e.target)||n?T():e.target instanceof HTMLCanvasElement&&!qo()&&requestAnimationFrame(()=>{S()})},te=c.scene.onUpdate(()=>{d(),document.activeElement?.closest(`.properties-content`)||f.focus()}),ne=c.onScrollChangeEmitter.on(()=>{d()}),re=!1;l&&f.select(),w();let ie=null;a&&`ResizeObserver`in window?(ie=new window.ResizeObserver(()=>{d()}),ie.observe(a)):window.addEventListener(`resize`,d),f.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener(`pointerdown`,ee,{capture:!0})}),window.addEventListener(`beforeunload`,S),o?.querySelector(`.excalidraw-textEditorContainer`).appendChild(f)},uk=O({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=W(e,t);return i.length===1&&I(i[0])&&!i[0].autoResize},perform:(e,t,n,r)=>{let i=W(e,t);return{appState:t,elements:e.map(e=>{if(e.id===i[0].id&&I(e)){let t=yn(e.originalText,Ds(e),e.lineHeight);return z(e,{autoResize:!0,width:t.width,height:t.height,text:e.originalText})}return e}),captureUpdate:j.IMMEDIATELY}}}),dk=e=>RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${[`flowchart`,`graph`,`sequenceDiagram`,`classDiagram`,`stateDiagram`,`stateDiagram-v2`,`erDiagram`,`journey`,`gantt`,`pie`,`quadrantChart`,`requirementDiagram`,`gitGraph`,`C4Context`,`mindmap`,`timeline`,`zenuml`,`sankey`,`xychart`,`block`].map(e=>`\\s*${e}(-beta)?`).join(`|`)})\\b`).test(e.trim()),fk=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let[c,l]=Wn(e,a),u=cl({canvas:e,scale:a,normalizedWidth:c,normalizedHeight:l});u.save(),u.scale(o.zoom.value,o.zoom.value),n&&n.type!==`selection`?Bn(n,r,i,t,u,s,o):u.clearRect(0,0,c,l)}},pk=cc(e=>{fk(e)},{trailing:!0}),mk=(e,t)=>{if(t){pk(e);return}fk(e)},hk=e=>{let t=(0,K.useRef)(null);return(0,K.useEffect)(()=>{t.current&&mk({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},mO())}),(0,q.jsx)(`canvas`,{className:`excalidraw__canvas`,style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},gk=K.createContext(null),_k=K.createContext(null),vk={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},yk=K.createContext(vk);yk.displayName=`DeviceContext`;var bk=K.createContext({container:null,id:null});bk.displayName=`ExcalidrawContainerContext`;var xk=K.createContext([]
<style>
html, body {
width: 100%;
height: 100%;
color: ${this.state.theme===B.DARK?`white`:`black`};
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1rem;
}
.Spinner {
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
margin-right: auto;
}
.Spinner svg {
animation: rotate 1.6s linear infinite;
transform-origin: center center;
width: 40px;
height: 40px;
}
.Spinner circle {
stroke: currentColor;
animation: dash 1.6s linear 0s infinite;
stroke-linecap: round;
}
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}
@keyframes dash {
0% {
stroke-dasharray: 1, 300;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 150, 300;
stroke-dashoffset: -200;
}
100% {
stroke-dasharray: 1, 300;
stroke-dashoffset: -280;
}
}
</style>
<div class="Spinner">
<svg
viewBox="0 0 100 100"
>
<circle
cx="50"
cy="50"
r="46"
stroke-width="8"
fill="none"
stroke-miter-limit="10"
/>
</svg>
</div>
<div>Generating...</div>
`)};else{let t;t=e.code===`ERR_GENERATION_INTERRUPTED`?`Generation was interrupted...`:e.message||`Generation failed`,c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Jr(`
<style>
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: ${kr.red[3]};
}
h1, h3 {
margin-top: 0;
margin-bottom: 0.5rem;
}
</style>
<h1>Error!</h1>
<h3>${t}</h3>
`)}}}else c=Je(Pa(r.link||``));let l=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`,u=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`hover`;return(0,q.jsx)(`div`,{className:L(`excalidraw__embeddable-container`,{"is-hovered":u}),style:{transform:o?`translate(${i-this.state.offsetLeft}px, ${a-this.state.offsetTop}px) scale(${e})`:`none`,display:o?`block`:`none`,opacity:$l(r,Li(r,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name===`elementLinkSelector`?Ut:1),"--embeddable-radius":`${Kr(Math.min(r.width,r.height),r)}px`},children:(0,q.jsxs)(`div`,{className:`excalidraw__embeddable-container__inner`,style:{width:o?`${r.width}px`:0,height:o?`${r.height}px`:0,transform:o?`rotate(${r.angle}rad)`:`none`,pointerEvents:l?ps.enabled:ps.disabled},children:[u&&(0,q.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:J(`buttons.embeddableInteractionButton`)}),(0,q.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(St(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,q.jsx)(`iframe`,{ref:e=>this.cacheEmbeddableRef(r,e),className:`excalidraw__embeddable`,srcDoc:c?.type===`document`?c.srcdoc(this.state.theme):void 0,src:c?.type===`document`?void 0:c?.link??``,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:`${c?.sandbox?.allowSameOrigin?`allow-same-origin`:``} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},r.id)})})}toggleOverscrollBehavior(e){document.documentElement.style.overscrollBehaviorX=e.type===`pointerenter`?`none`:`auto`}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderCustomStats:n}=this.props,r=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:r,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=a;let o=this.scene.getNonDeletedElementsMap(),s=`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`,c=e[0];return(0,q.jsx)(`div`,{className:L(`excalidraw excalidraw-container`,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?ps.disabled:ps.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:(0,q.jsx)(gk.Provider,{value:this,children:(0,q.jsx)(_k.Provider,{value:this.props,children:(0,q.jsx)(bk.Provider,{value:this.excalidrawContainerValue,children:(0,q.jsx)(yk.Provider,{value:this.device,children:(0,q.jsx)(Ck.Provider,{value:this.setAppState,children:(0,q.jsx)(Sk.Provider,{value:this.state,children:(0,q.jsxs)(xk.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,q.jsxs)(wk.Provider,{value:this.actionManager,children:[(0,q.jsx)(ZD,{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:Vv().code,renderTopRightUI:t,renderCustomStats:n,showExi
`),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=Ls({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:n,y:r,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:e,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:Qr,verticalAlign:`top`,locked:!1},a=Ds({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=vc(i.fontFamily),[s,,c]=Cc(this.state),l=Math.max(Math.min((c-s)*.5,800),200),u=r,d=t?[e]:e.split(`
`),f=d.reduce((e,t,r)=>{let s=gr(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=yn(s,a,o),c=r.width>l,d=c?fc(s,a,l):s;r=c?yn(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=ds({...i,x:f,y:p,text:d,originalText:s,lineHeight:o,autoResize:!c,frameId:t?t.id:null});e.push(m),u+=m.height+10}else d[r-1]?.trim()&&(u+=Cn(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.scene.insertElements(f),this.setState({selectedElementIds:F(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&Wk===!1&&!this.device.editor.isMobile&&(this.setToast({message:J(`toast.pasteAsSingleElement`,{shortcut:M(`CtrlOrCmd+Shift+V`)}),duration:5e3}),Wk=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(e,{isExistingElement:t=!1}){let n=this.scene.getElementsMapIncludingDeleted(),r=(t,r)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(i=>i.id===e.id&&I(i)?z(i,{originalText:t,isDeleted:r??i.isDeleted,...et(i,ia(i,n),n,t)}):i)])};lk({id:e.id,canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=Wo({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:fO(t=>{r(t,!1),gc(e)&&ga(e,this.scene.getNonDeletedElementsMap())}),onSubmit:fO(({viaKeyboard:n,nextOriginalText:i})=>{let a=!i.trim();if(r(i,a),!a&&n){let t=e.containerId?e.containerId:e.id;(0,Ju.flushSync)(()=>{this.setState(e=>({selectedElementIds:F({...e.selectedElementIds,[t]:!0},e)}))})}a&&Mr(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.shouldCaptureIncrement(),(0,Ju.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Lc(this.interactiveCanvas,this.state),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),r(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&I(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let r=this.getElementsAtPosition(e,t,n?.includeBoundTextElement,n?.includeLockedElements);if(r.length>1){if(n?.preferSelected){for(let e=r.length-1;e>-1;e--)if(this.state.selectedElementIds[r[e].id])return r[e]}let i=r[r.length-1];return Lr({x:e,y:t,element:i,shape:Ye(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:A(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n=!1,r=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(n&&r?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(r||!e.locked)&&(n||!(I(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Li(n,a);return r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?pa({x:e,y:t},r,a):!0}).filter(e=>oi(e)?(i.push(e),!1):!0).concat(i)}getElementHitThreshold(){return Pl/this.state.zoom.value}hitElement(e,t,n,r=!0){if(r&&this.state.selectedElementIds[n.id]&&Is([n],this.state)){let r=Bi(n,this.scene.getNonDeletedElementsMap(),El(n)?0:this.getElementHitThreshold());if(u(P(e,t),r))return!0}return is(e,t,Dt(n,this.scene.getNonDeletedElementsMap()))?!0:Lr({x:e,y:t,element:n,shape:Ye(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:A(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(e,t){let n=this.scene.getNonDeletedElements(),r=this.scene.getSelectedElements(this.state);if(r.length===1)return ba(r[0],!1)?r[0]:null;let i=null;for(let r=n.length-1;r>=0;--r){if(n[r].isDeleted)continue;let[a,o,s,c]=Kl(n[r],this.scene.getNonDeletedElementsMap());if(st(n[r])&&Lr({x:e,y:t,element:n[r],shape:Ye(n[r],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){i=n[r];break}else if(a<e&&e<s&&o<t&&t<c){i=n[r];break}}return ba(i,!1)?i:null}handleHoverSelectedLinearElement(e,t,