@inkeep/open-knowledge 0.0.0-dev-20260423025054 → 0.0.0-dev-20260423140112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +58 -56
- package/dist/constants-Db6innzo.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CXgpPYnX.mjs → init-BKZIAmeG.mjs} +2 -2
- package/dist/init-BVm9-dJ5.mjs +1 -0
- package/dist/init-DC3u6eEj.mjs +1 -0
- package/dist/{init-B3ycweHs.mjs → init-DpLpfyFd.mjs} +3 -3
- package/dist/loader-C4s8gzSJ.mjs +1 -0
- package/dist/{loader-DC05jP_i.mjs → loader-coix-kRo.mjs} +2 -2
- package/dist/paths-DWkDeU2T.mjs +1 -0
- package/dist/{paths-DjCE6HsL.mjs → paths-NbAS6ppU.mjs} +2 -2
- package/dist/preview-Bf1RdMGh.mjs +1 -0
- package/dist/{preview-D89OyWfK.mjs → preview-DT-EPBgG.mjs} +2 -2
- package/dist/public/assets/index-D8GnBO4u.css +1 -0
- package/dist/public/assets/{index-BzYIvdsQ.js → index-JVP7Gc1X.js} +2 -2
- package/dist/public/index.html +2 -2
- package/dist/{src-y0OBZgkE.mjs → src-4QBkn9Bx.mjs} +48 -47
- package/dist/src-BbmdRAJb.mjs +1 -0
- package/dist/{src-FL3Ydra9.mjs → src-DaFsir-C.mjs} +1 -1
- package/dist/{start-B5aAHuCo.mjs → start-B-7ZLww6.mjs} +2 -2
- package/dist/start-BY96E7WU.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-CctQOxTv.mjs +0 -2
- package/dist/init-BBEtdFbt.mjs +0 -1
- package/dist/init-CfiW8yzl.mjs +0 -1
- package/dist/loader-CRv6YUEt.mjs +0 -1
- package/dist/paths-DKYbHoVz.mjs +0 -1
- package/dist/preview-C9MefMSi.mjs +0 -1
- package/dist/public/assets/index-lYAAGLdq.css +0 -1
- package/dist/src-C9R5iE4n.mjs +0 -1
- package/dist/start-AX9SNvdk.mjs +0 -1
|
@@ -14,8 +14,8 @@ Error generating stack: `+e.message+`
|
|
|
14
14
|
`);c=a.pop()??``;for(let e of a)if(e.trim())try{let n=JSON.parse(e);if(n.type===`progress`)X.loading(`${bf(n.phase)} — ${n.pct}%`,{id:t});else if(n.type===`complete`){X.success(`Clone complete — opening project`,{id:t}),r(!1),v(!1),b(null),window.location.href=`http://localhost:${n.port}`;return}else if(n.type===`error`){X.error(`Clone failed: ${n.message}`,{id:t}),v(!1),b(null);return}}catch{}}X.error(`Clone stream ended unexpectedly — check if the clone completed`,{id:t}),v(!1),b(null)}catch(e){let n=e;n instanceof Error&&n.name===`AbortError`?X.dismiss(x.current??void 0):X.error(`Clone failed — connection error`,{id:t}),v(!1),b(null)}},t[10]=s,t[11]=r,t[12]=a,t[13]=M):M=t[13];let N=M,P;t[14]===y?P=t[15]:(P=function(){y?.abort(),v(!1),b(null),X.dismiss(x.current??void 0)},t[14]=y,t[15]=P);let F=P,I;t[16]!==_||t[17]!==r?(I=function(e){_||(r(e),e||(o(``),c(``),m(``)))},t[16]=_,t[17]=r,t[18]=I):I=t[18];let L=I,R,z,B,V,H,U,W,G,K;if(t[19]!==_||t[20]!==L||t[21]!==h||t[22]!==d||t[23]!==n||t[24]!==p||t[25]!==l||t[26]!==a){let e=l?.filter(e=>e.full_name.toLowerCase().includes(p.toLowerCase()));z=ln,G=n,K=L,R=In,U=`sm:max-w-lg`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Bn,{children:(0,$.jsx)(pn,{children:`Clone from GitHub`})}),t[36]=W):W=t[36],B=`flex flex-col gap-4`;let r;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`label`,{htmlFor:`clone-url`,className:`text-sm font-medium`,children:`Repository URL or owner/repo`}),t[37]=r):r=t[37];let i;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(i=e=>k(e.target.value),t[38]=i):i=t[38],t[39]!==_||t[40]!==a?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[r,(0,$.jsx)(Mt,{id:`clone-url`,placeholder:`https://github.com/owner/repo or owner/repo`,value:a,onChange:i,disabled:_})]}),t[39]=_,t[40]=a,t[41]=V):V=t[41],H=h&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`repo-filter`,className:`text-sm font-medium`,children:`Your repositories`}),(0,$.jsx)(Mt,{id:`repo-filter`,"aria-label":`Filter repositories`,placeholder:`Filter repositories…`,value:p,onChange:e=>m(e.target.value),disabled:_||d&&l===null}),(0,$.jsx)(`div`,{className:`border rounded-md max-h-40 overflow-y-auto subtle-scrollbar`,"aria-busy":d&&l===null,children:d&&l===null?(0,$.jsxs)(`output`,{className:`flex flex-col gap-1.5 px-3 py-2`,"aria-label":`Loading repositories`,children:[(0,$.jsx)(yf,{className:`h-4 w-2/3`}),(0,$.jsx)(yf,{className:`h-4 w-1/2`}),(0,$.jsx)(yf,{className:`h-4 w-3/4`}),(0,$.jsx)(yf,{className:`h-4 w-2/5`}),(0,$.jsx)(yf,{className:`h-4 w-3/5`})]}):e?.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?.length===0?`No repositories found.`:`No matches.`}):e?.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-sm hover:bg-muted flex items-center gap-2 truncate disabled:opacity-50`,onClick:()=>j(e),disabled:_,children:[e.private&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`🔒`}),e.full_name]},e.full_name))})]}),t[19]=_,t[20]=L,t[21]=h,t[22]=d,t[23]=n,t[24]=p,t[25]=l,t[26]=a,t[27]=R,t[28]=z,t[29]=B,t[30]=V,t[31]=H,t[32]=U,t[33]=W,t[34]=G,t[35]=K}else R=t[27],z=t[28],B=t[29],V=t[30],H=t[31],U=t[32],W=t[33],G=t[34],K=t[35];let ee;t[42]!==_||t[43]!==h||t[44]!==i?(ee=!h&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Browse your repos:`}),(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:()=>i?.(),disabled:_,children:`Sign in to GitHub`})]}),t[42]=_,t[43]=h,t[44]=i,t[45]=ee):ee=t[45];let te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(`label`,{htmlFor:`clone-path`,className:`text-sm font-medium`,children:`Local path`}),t[46]=te):te=t[46];let ne;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>c(e.target.value),t[47]=ne):ne=t[47];let re;t[48]!==_||t[49]!==s?(re=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[te,(0,$.jsx)(Mt,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:s,onChange:ne,disabled:_})]}),t[48]=_,t[49]=s,t[50]=re):re=t[50];let ie;t[51]!==B||t[52]!==V||t[53]!==H||t[54]!==ee||t[55]!==re?(ie=(0,$.jsxs)(`div`,{className:B,children:[V,H,ee,re]}),t[51]=B,t[52]=V,t[53]=H,t[54]=ee,t[55]=re,t[56]=ie):ie=t[56];let ae;t[57]!==_||t[58]!==F||t[59]!==N||t[60]!==L||t[61]!==a?(ae=(0,$.jsx)(wn,{children:_?(0,$.jsx)(q,{variant:`outline`,className:`font-mono uppercase`,onClick:F,children:`Cancel`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>L(!1),children:`Cancel`}),(0,$.jsx)(q,{onClick:()=>void N(),disabled:!a.trim(),children:`Clone`})]})}),t[57]=_,t[58]=F,t[59]=N,t[60]=L,t[61]=a,t[62]=ae):ae=t[62];let oe;t[63]!==R||t[64]!==U||t[65]!==W||t[66]!==ie||t[67]!==ae?(oe=(0,$.jsxs)(R,{className:U,children:[W,ie,ae]}),t[63]=R,t[64]=U,t[65]=W,t[66]=ie,t[67]=ae,t[68]=oe):oe=t[68];let se;return t[69]!==z||t[70]!==G||t[71]!==K||t[72]!==oe?(se=(0,$.jsx)(z,{open:G,onOpenChange:K,children:oe}),t[69]=z,t[70]=G,t[71]=K,t[72]=oe,t[73]=se):se=t[73],se}function Cf(e){return e.json()}function wf(e){let t=(0,Q.c)(9),{onOpenResolver:n}=e,r=lf();if(!r||r.state!==`conflict`)return null;let i=r.conflictCount,a=i>0?`${i} page${i===1?``:`s`}`:`Some pages`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(zi,{className:`size-4 shrink-0`}),t[0]=o):o=t[0];let s=i===1?`has`:`have`,c;t[1]!==a||t[2]!==s?(c=(0,$.jsxs)(`span`,{className:`flex-1`,children:[a,` `,s,` conflicting changes.`]}),t[1]=a,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`shrink-0 border-amber-400 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50`,onClick:n,children:`Review and resolve`}),t[4]=n,t[5]=l);let u;return t[6]!==c||t[7]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm border-b bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 shrink-0`,children:[o,c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u}var Tf=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(t,n=t){return new e(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}};function Ef(e,t,n,r,i,a){if(e==r)return[];let o=If(e,t,n,r,i,a),s=Lf(e,t+o,n,r,i+o,a);t+=o,n-=s,i+=o,a-=s;let c=n-t,l=a-i;if(!c||!l)return[new Tf(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new Tf(t,t+o,i,i),new Tf(t+o+l,n,a,a)]}else if(l>c){let o=r.slice(i,a).indexOf(e.slice(t,n));if(o>-1)return[new Tf(t,t,i,i+o),new Tf(n,n,i+o+c,a)]}if(c==1||l==1)return[new Tf(t,n,i,a)];let u=zf(e,t,n,r,i,a);if(u){let[o,s,c]=u;return Ef(e,t,o,r,i,s).concat(Ef(e,o+c,n,r,s+c,a))}return Af(e,t,n,r,i,a)}var Df=1e9,Of=0,kf=!1;function Af(e,t,n,r,i,a){let o=n-t,s=a-i;if(Df<1e9&&Math.min(o,s)>Df*16||Of>0&&Date.now()>Of)return Math.min(o,s)>Df*64?[new Tf(t,n,i,a)]:Bf(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);Mf.reset(c),Nf.reset(c);let l=(n,a)=>e.charCodeAt(t+n)==r.charCodeAt(i+a),u=(t,i)=>e.charCodeAt(n-t-1)==r.charCodeAt(a-i-1),d=(o-s)%2==0?null:Nf,f=d?null:Mf;for(let p=0;p<c;p++){if(p>Df||Of>0&&!(p&63)&&Date.now()>Of)return Bf(e,t,n,r,i,a);let m=Mf.advance(p,o,s,c,d,!1,l)||Nf.advance(p,o,s,c,f,!0,u);if(m)return Pf(e,t,n,t+m[0],r,i,a,i+m[1])}return[new Tf(t,n,i,a)]}var jf=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let e=0;e<this.len;e++)this.vec[e]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,r,i,a,o){for(let s=-e+this.start;s<=e-this.end;s+=2){let c=r+s,l=s==-e||s!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,u=l-s;for(;l<t&&u<n&&o(l,u);)l++,u++;if(this.vec[c]=l,l>t)this.end+=2;else if(u>n)this.start+=2;else if(i){let e=r+(t-n)-s;if(e>=0&&e<this.len&&i.vec[e]!=-1)if(a){let n=i.vec[e];if(n>=t-l)return[n,r+n-e]}else{let n=t-i.vec[e];if(l>=n)return[l,u]}}}return null}},Mf=new jf,Nf=new jf;function Pf(e,t,n,r,i,a,o,s){let c=!1;return!tp(e,r)&&++r==n&&(c=!0),!tp(i,s)&&++s==o&&(c=!0),c?[new Tf(t,n,a,o)]:Ef(e,t,r,i,a,s).concat(Ef(e,r,n,i,s,o))}function Ff(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function If(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=Ff(n-t,a-i);for(let s=t,c=i;;){let i=s+o,l=c+o;if(i>n||l>a||e.slice(s,i)!=r.slice(c,l)){if(o==1)return s-t-+!tp(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function Lf(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=Ff(n-t,a-i);for(let s=n,c=a;;){let a=s-o,l=c-o;if(a<t||l<i||e.slice(a,s)!=r.slice(l,c)){if(o==1)return n-s-+!tp(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function Rf(e,t,n,r,i,a,o,s){let c=r.slice(i,a),l=null;for(;;){if(l||o<s)return l;for(let s=t+o;;){tp(e,s)||s++;let u=s+o;if(tp(e,u)||(u+=u==s+1?1:-1),u>=n)break;let d=e.slice(s,u),f=-1;for(;(f=c.indexOf(d,f+1))!=-1;){let o=If(e,u,n,r,i+f+d.length,a),c=Lf(e,t,s,r,i,i+f),p=d.length+o+c;(!l||l[2]<p)&&(l=[s-c,i+f-c,p])}s=u}if(s<0)return l;o>>=1}}function zf(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=zf(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:Rf(e,t,n,r,i,a,Math.floor(o/4),-1)}function Bf(e,t,n,r,i,a){kf=!0;let o=n-t,s=a-i,c;if(o<s){let s=Rf(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=Rf(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new Tf(t,n,i,a)];let[l,u,d]=c;return Ef(e,t,l,r,i,u).concat(Ef(e,l+d,n,r,u+d,a))}function Vf(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];r.toA>i.fromA-t&&r.toB>i.fromB-t&&(e[n-1]=new Tf(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Hf(e,t,n){for(;;){Vf(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=If(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new Tf(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=Lf(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new Tf(a.fromA,a.toA-s,a.fromB,a.toB-s));let c=a.toA-a.fromA,l=a.toB-a.fromB;if(c&&l)continue;let u=a.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:e.length)-a.toA;if(!u||!d)continue;let f=c?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);u<=f.length&&e.slice(a.fromA-u,a.fromA)==f.slice(f.length-u)?(n[i]=new Tf(a.fromA-u,a.toA-u,a.fromB-u,a.toB-u),r=!0):d<=f.length&&e.slice(a.toA,a.toA+d)==f.slice(0,d)&&(n[i]=new Tf(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function Uf(e,t,n){for(let r=0,i=0;i<e.length;i++){let a=e[i],o=a.toA-a.fromA,s=a.toB-a.fromB;if(o&&s||o>3||s>3){let c=i==e.length-1?t.length:e[i+1].fromA,l=a.fromA-r,u=c-a.toA,d=Xf(t,a.fromA,l),f=Yf(t,a.toA,u),p=a.fromA-d,m=f-a.toA;if((!o||!s)&&p&&m){let l=Math.max(o,s),[u,h,g]=o?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];l>p&&t.slice(d,a.fromA)==u.slice(g-p,g)?(a=e[i]=new Tf(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Yf(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new Tf(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Xf(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new Tf(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Qf(n,a.fromB,a.toB),r,o=t<0?-1:Zf(n,a.toB,a.fromB);t>-1&&(r=t-a.fromB)<=u&&n.slice(a.fromB,t)==n.slice(a.toB,a.toB+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toB-o)<=l&&n.slice(a.fromB-r,a.fromB)==n.slice(o,a.toB)&&(a=e[i]=a.offset(-r))}else if(!s){let n=Qf(t,a.fromA,a.toA),r,o=n<0?-1:Zf(t,a.toA,a.fromA);n>-1&&(r=n-a.fromA)<=u&&t.slice(a.fromA,n)==t.slice(a.toA,a.toA+r)?a=e[i]=a.offset(r):o>-1&&(r=a.toA-o)<=l&&t.slice(a.fromA-r,a.fromA)==t.slice(o,a.toA)&&(a=e[i]=a.offset(-r))}}r=a.toA}return Vf(e,3),e}var Wf;try{Wf=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function Gf(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Kf(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!Gf(n):Wf?!$f(n)||t==e.length-1?+!!Wf.test(String.fromCharCode(n)):Wf.test(e.slice(t,t+2))?2:0:0}function qf(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!Gf(n):Wf?!ep(n)||t==1?+!!Wf.test(String.fromCharCode(n)):Wf.test(e.slice(t-2,t))?2:0:0}var Jf=8;function Yf(e,t,n){if(t==e.length||!qf(e,t))return t;for(let r=t,i=t+n,a=0;a<Jf;a++){let t=Kf(e,r);if(!t||r+t>i)return r;r+=t}return t}function Xf(e,t,n){if(!t||!Kf(e,t))return t;for(let r=t,i=t-n,a=0;a<Jf;a++){let t=qf(e,r);if(!t||r-t<i)return r;r-=t}return t}function Zf(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Qf(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var $f=e=>e>=55296&&e<=56319,ep=e=>e>=56320&&e<=57343;function tp(e,t){return!t||t==e.length||!$f(e.charCodeAt(t-1))||!ep(e.charCodeAt(t))}function np(e,t,n){let r=n?.override;return r?r(e,t):(Df=(n?.scanLimit??1e9)>>1,Of=n?.timeout?Date.now()+n.timeout:0,kf=!1,Hf(e,t,Ef(e,0,e.length,t,0,t.length)))}function rp(){return!kf}function ip(e,t,n){return Uf(np(e,t,n),e,t)}var ap=Jn.define({combine:e=>e[0]}),op=Qn.define(),sp=Jn.define(),cp=er.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(op)&&(e=n.value);for(let n of t.state.facet(sp))e=n(e,t);return e}});function lp(e){let t=e.field(cp,!1);if(!t)return null;let n=e.facet(ap);return{chunks:t,side:n?n.side:null}}var up=class e{constructor(e,t,n,r,i,a=!0){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=i,this.precise=a}offset(t,n){return t||n?new e(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return pp(ip(e.toString(),t.toString(),n),e,t,0,0,rp())}static updateA(e,t,n,r,i){return _p(gp(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return _p(gp(e,r,!1,t.length),e,t,n,i)}};function dp(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.to==e&&a.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[i.from,a.from]}function fp(e,t,n,r){let i=n.lineAt(e),a=r.lineAt(t);return i.from==e&&a.from==t?[e,t]:[i.to+1,a.to+1]}function pp(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=dp(c.fromA+r,c.fromB+i,t,n),[d,f]=fp(c.toA+r,c.toB+i,t,n),p=[c.offset(-l+r,-u+i)];for(;s<e.length-1;){let a=e[s+1],[o,c]=dp(a.fromA+r,a.fromB+i,t,n);if(o>d+1&&c>f+1)break;p.push(a.offset(-l+r,-u+i)),[d,f]=fp(a.toA+r,a.toB+i,t,n),s++}o.push(new up(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var mp=1e3;function hp(e,t,n,r){let i=0,a=e.length;for(;;){if(i==a){let r=0,a=0;i&&({toA:r,toB:a}=e[i-1]);let o=t-(n?r:a);return[r+o,a+o]}let o=i+a>>1,s=e[o],[c,l]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(c>t)a=o;else if(l<=t)i=o+1;else return r?[s.fromA,s.fromB]:[s.toA,s.toB]}}function gp(e,t,n,r){let i=[];return t.iterChangedRanges((a,o,s,c)=>{let l=0,u=n?t.length:r,d=0,f=n?r:t.length;a>mp&&([l,d]=hp(e,a-mp,n,!0)),o<t.length-mp&&([u,f]=hp(e,o+mp,n,!1));let p=c-s-(o-a),m,[h,g]=n?[p,0]:[0,p];i.length&&(m=i[i.length-1]).toA>=l?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+h,diffB:m.diffB+g}:i.push({fromA:l,toA:u,fromB:d,toB:f,diffA:h,diffB:g})}),i}function _p(e,t,n,r,i){if(!e.length)return t;let a=[];for(let o=0,s=0,c=0,l=0;;o++){let u=o==e.length?null:e[o],d=u?u.fromA+s:n.length,f=u?u.fromB+c:r.length;for(;l<t.length;){let e=t[l];if(u&&(e.toA+s>d||e.toB+c>f))break;a.push(e.offset(s,c)),l++}if(!u)break;let p=u.toA+s+u.diffA,m=u.toB+c+u.diffB,h=ip(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of pp(h,n,r,d,f,rp()))a.push(e);for(s+=u.diffA,c+=u.diffB;l<t.length;){let e=t[l];if(e.fromA+s>p&&e.fromB+c>m)break;l++}}return a}var vp={scanLimit:500},yp=ar.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=kp(e))}update(e){(e.docChanged||e.viewportChanged||xp(e.startState,e.state)||Sp(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=kp(e.view))}},{decorations:e=>e.deco}),bp=cr.low(or({class:`cm-changeGutter`,markers:e=>e.plugin(yp)?.gutter||Kn.empty}));function xp(e,t){return e.field(cp,!1)!=t.field(cp,!1)}function Sp(e,t){return e.facet(ap)!=t.facet(ap)}var Cp=lr.line({class:`cm-changedLine`}),wp=lr.mark({class:`cm-changedText`}),Tp=lr.mark({tagName:`ins`,class:`cm-insertedLine`}),Ep=lr.mark({tagName:`del`,class:`cm-deletedLine`}),Dp=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function Op(e,t,n,r,i,a){let o=n?e.fromA:e.fromB,s=n?e.toA:e.toB,c=0;if(o!=s){i.add(o,o,Cp),i.add(o,s,n?Ep:Tp),a&&a.add(o,o,Dp);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,Cp),a&&a.add(u,u,Dp);continue}let t=u+l.value.length;if(r)for(;c<e.changes.length;){let r=e.changes[c],a=o+(n?r.fromA:r.fromB),s=o+(n?r.toA:r.toB),l=Math.max(u,a),d=Math.min(t,s);if(l<d&&i.add(l,d,wp),s<t)c++;else break}u=t}}}function kp(e){let t=e.state.field(cp),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(ap),o=n==`a`,s=new sr,c=i?new sr:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&Op(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var Ap=class extends tr{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},jp=Qn.define({map:(e,t)=>e.map(t)}),Mp=er.define({create:()=>lr.none,update:(e,t)=>{for(let e of t.effects)if(e.is(jp))return e.value;return e.map(t.changes)},provide:e=>ir.decorations.from(e)}),Np=.01;function Pp(e,t){if(e.size!=t.size)return!1;let n=e.iter(),r=t.iter();for(;n.value;){if(n.from!=r.from||Math.abs(n.value.spec.widget.height-r.value.spec.widget.height)>1)return!1;n.next(),r.next()}return!0}function Fp(e,t,n){let r=new sr,i=new sr,a=e.state.field(Mp).iter(),o=t.state.field(Mp).iter(),s=0,c=0,l=0,u=0,d=e.viewport,f=t.viewport;for(let p=0;;p++){let m=p<n.length?n[p]:null,h=m?m.fromA:e.state.doc.length,g=m?m.fromB:t.state.doc.length;if(s<h){let n=e.lineBlockAt(s).top+l-(t.lineBlockAt(c).top+u);n<-Np?(l-=n,r.add(s,s,lr.widget({widget:new Ap(-n),block:!0,side:-1}))):n>Np&&(u+=n,i.add(c,c,lr.widget({widget:new Ap(n),block:!0,side:-1})))}if(h>s+1e3&&s<d.from&&h>d.from&&c<f.from&&g>f.from){let e=Math.min(d.from-s,f.from-c);s+=e,c+=e,p--}else if(m)s=m.toA,c=m.toB;else break;for(;a.value&&a.from<s;)l-=a.value.spec.widget.height,a.next();for(;o.value&&o.from<c;)u-=o.value.spec.widget.height,o.next()}for(;a.value;)l-=a.value.spec.widget.height,a.next();for(;o.value;)u-=o.value.spec.widget.height,o.next();let p=e.contentHeight+l-(t.contentHeight+u);p<Np?r.add(e.state.doc.length,e.state.doc.length,lr.widget({widget:new Ap(-p),block:!0,side:1})):p>Np&&i.add(t.state.doc.length,t.state.doc.length,lr.widget({widget:new Ap(p),block:!0,side:1}));let m=r.finish(),h=i.finish();Pp(m,e.state.field(Mp))||e.dispatch({effects:jp.of(m)}),Pp(h,t.state.field(Mp))||t.dispatch({effects:jp.of(h)})}var Ip=Qn.define({map:(e,t)=>t.mapPos(e)}),Lp=class extends tr{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Ip.of(n)});let{side:r,sibling:i}=e.state.facet(ap);i&&i().dispatch({effects:Ip.of(Rp(n,e.state.field(cp),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Rp(e,t,n){let r=0,i=0;for(let a=0;;a++){let o=a<t.length?t[a]:null;if(!o||(n?o.fromA:o.fromB)>=e)return i+(e-r);[r,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}var zp=er.define({create(e){return lr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ip)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>ir.decorations.from(e)});function Bp({margin:e=3,minSize:t=4}){return zp.init(n=>Vp(n,e,t))}function Vp(e,t,n){let r=new sr,i=e.facet(ap).side==`a`,a=e.field(cp),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,lr.replace({widget:new Lp(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var Hp=ir.styleModule.of(new dr({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),Up=ir.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),Wp=new ur,Gp=new ur,Kp=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||vp;let t=[cr.low(yp),Up,Hp,Mp,ir.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(jp)))&&this.measure()})],n=[ap.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(bp);let r=Yn.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],ir.editorAttributes.of({class:`cm-merge-a`}),Gp.of(n),t]}),i=[ap.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(bp);let a=Yn.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],ir.editorAttributes.of({class:`cm-merge-b`}),Gp.of(i),t]});this.chunks=up.build(r.doc,a.doc,this.diffConf);let o=[cp.init(()=>this.chunks),Wp.of(e.collapseUnchanged?Bp(e.collapseUnchanged):[])];r=r.update({effects:Qn.appendConfig.of(o)}).state,a=a.update({effects:Qn.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new ir({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new ir({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),nr.empty(e[0].startState.doc.length));this.chunks=t==this.a?up.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):up.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:op.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:op.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if(`diffConfig`in e&&(this.diffConf=e.diffConfig),`orientation`in e){let t=e.orientation!=`b-a`;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent=``)}}if(`revertControls`in e||`renderRevertControl`in e){let t=!!this.revertDOM,n=this.revertToA,r=this.renderRevert;`revertControls`in e&&(t=!!e.revertControls,n=e.revertControls==`b-to-a`),`renderRevertControl`in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t=`highlightChanges`in e,n=`gutter`in e,r=`collapseUnchanged`in e;if(t||n||r){let i=[],a=[];if(t||n){let r=this.a.state.facet(ap),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Gp.reconfigure([ap.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?bp:[]])),a.push(Gp.reconfigure([ap.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?bp:[]]))}if(r){let t=Wp.reconfigure(e.collapseUnchanged?Bp(e.collapseUnchanged):[]);i.push(t),a.push(t)}this.a.dispatch({effects:i}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement(`div`),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener(`mousedown`,e=>this.revertClicked(e)),this.revertDOM.className=`cm-merge-revert`):this.revertDOM&&(this.revertDOM.textContent=``)}scheduleMeasure(){this.measuring<0&&(this.measuring=(this.dom.ownerDocument.defaultView||window).requestAnimationFrame(()=>{this.measuring=-1,this.measure()}))}measure(){Fp(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let i=0;i<this.chunks.length;i++){let a=this.chunks[i];if(a.fromA>n.to||a.fromB>r.to)break;if(a.fromA<n.from||a.fromB<r.from)continue;let o=this.a.lineBlockAt(a.fromA).top+`px`;for(;t&&+t.dataset.chunk<i;)t=qp(t);t&&t.dataset.chunk==String(i)?(t.style.top!=o&&(t.style.top=o),t=t.nextSibling):e.insertBefore(this.renderRevertButton(o,i),t)}for(;t;)t=qp(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement(`button`);let e=this.a.state.phrase(`Revert this chunk`);n.setAttribute(`aria-label`,e),n.setAttribute(`title`,e),n.textContent=this.revertToLeft?`⇜`:`⇝`}return n.style.top=e,n.setAttribute(`data-chunk`,String(t)),n}revertClicked(e){let t=e.target,n;for(;t&&t.parentNode!=this.revertDOM;)t=t.parentNode;if(t&&(n=this.chunks[t.dataset.chunk])){let[t,r,i,a,o,s]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],c=t.state.sliceDoc(i,Math.max(i,a-1));i!=a&&s<=r.state.doc.length&&(c+=t.state.lineBreak),r.dispatch({changes:{from:o,to:Math.min(r.state.doc.length,s),insert:c},userEvent:`revert`}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}};function qp(e){let t=e.nextSibling;return e.remove(),t}var Jp=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},Yp=cr.low(or({class:`cm-changeGutter`,markers:e=>e.plugin(yp)?.gutter||Kn.empty,widgetMarker:(e,t)=>t instanceof em?Jp:null}));function Xp(e){let t=typeof e.original==`string`?Zn.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||vp;return[cr.low(yp),am,Up,ir.editorAttributes.of({class:`cm-merge-b`}),sp.of((e,t)=>{let r=t.effects.find(e=>e.is(Zp));return r&&(e=up.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=up.updateB(e,t.state.field(Qp),t.newDoc,t.changes,n)),e}),ap.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?dm:void 0,side:`b`}),Qp.init(()=>t),e.gutter===!1?[]:Yp,e.collapseUnchanged?Bp(e.collapseUnchanged):[],cp.init(e=>up.build(t,e.doc,n))]}var Zp=Qn.define(),Qp=er.define({create:()=>Zn.empty,update(e,t){for(let n of t.effects)n.is(Zp)&&(e=n.value.doc);return e}}),$p=new WeakMap,em=class extends tr{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||=this.buildDOM(e)}};function tm(e,t,n){let r=$p.get(t.changes);if(r)return r;let i=lr.widget({block:!0,side:-1,widget:new em(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(ap),c=document.createElement(`div`);if(c.className=`cm-deletedChunk`,s){let t=c.appendChild(document.createElement(`div`));t.className=`cm-chunkButtons`;let n=e=>{e.preventDefault(),nm(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),rm(r,r.posAtDOM(c))};if(typeof s==`function`)t.appendChild(s(`accept`,n)),t.appendChild(s(`reject`,i));else{let r=t.appendChild(document.createElement(`button`));r.name=`accept`,r.textContent=e.phrase(`Accept`),r.onmousedown=n;let a=t.appendChild(document.createElement(`button`));a.name=`reject`,a.textContent=e.phrase(`Reject`),a.onmousedown=i}}if(n||t.fromA>=t.toA)return c;let l=r.state.field(Qp).sliceString(t.fromA,t.endA),u=a&&e.facet($n),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
|
|
15
15
|
`){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
|
|
16
16
|
`,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;Xn(t,{style:t=>qn(e,t)},(e,t,r)=>{e>n&&g(n,e,``),g(e,t,r),n=t}),g(n,l.length,``)}else g(0,l.length,``);return d.firstChild||d.appendChild(document.createElement(`br`)),c})});return $p.set(t.changes,i),i}function nm(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(cp).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=e.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=e.state.field(Qp);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=nr.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:Zp.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function rm(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(cp).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(Qp).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(a+=n.lineBreak),e.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:a},userEvent:`revert`}),!0}function im(e){let t=new sr;for(let n of e.field(cp)){let r=e.facet(ap).overrideChunk&&sm(e,n);t.add(n.fromB,n.fromB,tm(e,n,!!r))}return t.finish()}var am=er.define({create:e=>im(e),update(e,t){return t.state.field(cp,!1)==t.startState.field(cp,!1)?e:im(t.state)},provide:e=>ir.decorations.from(e)}),om=new WeakMap;function sm(e,t){let n=om.get(t);if(n!==void 0)return n;n=null;let r=e.field(Qp),i=e.doc,a=r.lineAt(t.endA).number-r.lineAt(t.fromA).number+1,o=i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1;abort:if(a==o&&a<10){let e=[],i=0,o=t.fromA,s=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=r.sliceString(o+n.fromA,o+n.toA);if(/\n/.test(t))break abort;e.push(lr.widget({widget:new cm(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(wp.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return om.set(t,n),n}var cm=class extends tr{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement(`del`);return t.className=`cm-deletedText`,t.textContent=this.text,t}},lm=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},um=lr.line({class:`cm-inlineChangedLine`});function dm(e,t,n,r){let i=sm(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,lm),n.add(o.from,o.from,um);a<i.length&&i[a].to<=o.to;){let e=i[a++];n.add(e.from,e.to,e.value)}if(o.to>=t.endB)break;o=e.doc.lineAt(o.to+1)}return!0}var fm=zn({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),pm=Cn({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function mm(e){let t=(0,Q.c)(20),{oldContent:n,newContent:r,layout:i,conflictMode:a,onResolve:o,onAbort:s}=e,c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),{resolvedTheme:u}=Ve(),d=(0,Z.useRef)(o),f=(0,Z.useRef)(s),[p,m]=(0,Z.useState)(null),h;t[0]!==s||t[1]!==o?(h=()=>{d.current=o,f.current=s},t[0]=s,t[1]=o,t[2]=h):h=t[2],(0,Z.useEffect)(h);let g,_;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==u?(g=()=>{if(!c.current)return;let e=u===`dark`?fm:pm,t=[ir.editable.of(!1),Yn.readOnly.of(!0)],o=[Fn,fn(),...t,e,ir.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new ir({doc:r,extensions:[Fn,fn(),ir.editable.of(!1),e,ir.lineWrapping,Xp({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),ir.updateListener.of(e=>{let t=lp(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=lp(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new Kp({a:{doc:n,extensions:o},b:{doc:r,extensions:o},parent:c.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):l.current=new ir({doc:r,extensions:[...o,Xp({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:c.current});return()=>{l.current&&=(l.current.destroy(),null)}},_=[n,r,i,u,a],t[3]=a,t[4]=i,t[5]=r,t[6]=n,t[7]=u,t[8]=g,t[9]=_):(g=t[8],_=t[9]),(0,Z.useEffect)(g,_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=function(){let e=l.current;!e||!(e instanceof ir)||d.current?.(e.state.doc.toString())},t[10]=v):v=t[10];let y=v,b=p===0,x=p===null?``:p===0?`All hunks resolved`:`${p} unresolved hunk${p===1?``:`s`}`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(`div`,{ref:c,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[11]=S):S=t[11];let C;t[12]!==b||t[13]!==a||t[14]!==x||t[15]!==s||t[16]!==o?(C=a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs ${b?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:x}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,$.jsx)(q,{variant:`default`,size:`sm`,disabled:!b,onClick:y,children:`Save resolution`})]})]}),t[12]=b,t[13]=a,t[14]=x,t[15]=s,t[16]=o,t[17]=C):C=t[17];let w;return t[18]===C?w=t[19]:(w=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[S,C]}),t[18]=C,t[19]=w),w}function hm(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Lt,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function gm(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Pt,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function _m(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(At,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vm(e){let t=(0,Q.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(_m,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=k(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,$.jsx)(zt,{"data-slot":`sheet-close`,asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,$.jsx)(jt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(gm,{children:[l,(0,$.jsxs)(Vt,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function ym(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(qt,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Wt,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function Sm(){try{let e=await fetch(`/api/sync/conflicts`);return e.ok?{conflicts:(await e.json()).conflicts??[]}:{conflicts:[],error:`server`}}catch{return{conflicts:[],error:`network`}}}async function Cm(e){try{let t=await fetch(`/api/sync/conflict-content?file=${encodeURIComponent(e)}`);if(!t.ok)return{ours:``,theirs:``,base:``};let n=await t.json();return{ours:n.ours??``,theirs:n.theirs??``,base:n.base??``}}catch{return{ours:``,theirs:``,base:``}}}async function wm(e,t,n){try{let r={file:e,strategy:t};return n!==void 0&&(r.content=n),(await fetch(`/api/sync/resolve-conflict`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})).ok}catch{return!1}}var Tm=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function Em(e){let t=(0,Q.c)(31),{file:n,onResolve:r,onAbort:i}=e,[a,o]=(0,Z.useState)(null),s,c;if(t[0]===n?(s=t[1],c=t[2]):(s=()=>{let e=!1;return Cm(n).then(t=>{e||o(t)}),()=>{e=!0}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c),a===null){let e;t[3]===i?e=t[4]:(e=e=>!e&&i(),t[3]=i,t[4]=e);let r;t[5]===n?r=t[6]:(r=(0,$.jsx)(Bn,{className:`shrink-0`,children:(0,$.jsxs)(pn,{children:[`Resolving: `,n]})}),t[5]=n,t[6]=r);let a;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`}),t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=(0,$.jsxs)(In,{className:Tm,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,$.jsx)(ln,{open:!0,onOpenChange:e,children:o}),t[10]=e,t[11]=o,t[12]=s):s=t[12],s}let l;t[13]===i?l=t[14]:(l=e=>!e&&i(),t[13]=i,t[14]=l);let u;t[15]===n?u=t[16]:(u=(0,$.jsxs)(pn,{className:`text-sm font-medium`,children:[`Resolving: `,n]}),t[15]=n,t[16]=u);let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Red = your version (ours). Green = team's version (theirs). Accept each hunk to take theirs, reject to keep yours, then save.`}),t[17]=d):d=t[17];let f;t[18]===u?f=t[19]:(f=(0,$.jsxs)(Bn,{className:`px-4 pt-4 pb-2 shrink-0`,children:[u,d]}),t[18]=u,t[19]=f);let p;t[20]!==i||t[21]!==r||t[22]!==a.ours||t[23]!==a.theirs?(p=(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(mm,{oldContent:a.ours,newContent:a.theirs,layout:`unified`,conflictMode:!0,onResolve:r,onAbort:i})}),t[20]=i,t[21]=r,t[22]=a.ours,t[23]=a.theirs,t[24]=p):p=t[24];let m;t[25]!==f||t[26]!==p?(m=(0,$.jsxs)(In,{className:`${Tm} p-0`,children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;return t[28]!==l||t[29]!==m?(h=(0,$.jsx)(ln,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function Dm(e){let t=(0,Q.c)(50),{open:n,onOpenChange:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),[s,c]=(0,Z.useState)(null),l;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[1]=l):l=t[1];let[u,d]=(0,Z.useState)(l),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Set,t[2]=f):f=t[2];let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(null),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=function(){Sm().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(Om));return new Set([...e].filter(e=>!n.has(e)))})})},t[3]=_):_=t[3];let v=_,y,b;t[4]===n?(y=t[5],b=t[6]):(y=()=>{n&&v()},b=[n],t[4]=n,t[5]=y,t[6]=b),(0,Z.useEffect)(y,b);let x,S;t[7]===n?(x=t[8],S=t[9]):(x=()=>ce(e=>{e.includes(`sync-status`)&&n&&v()}),S=[n],t[7]=n,t[8]=x,t[9]=S),(0,Z.useEffect)(x,S);let C,w;t[10]!==a.length||t[11]!==r||t[12]!==n||t[13]!==u.size?(w=()=>{n&&a.length>0&&u.size>=a.length&&(X.success(`All conflicts resolved — sync resuming`),r(!1),d(new Set))},C=[n,a.length,u.size,r],t[10]=a.length,t[11]=r,t[12]=n,t[13]=u.size,t[14]=C,t[15]=w):(C=t[14],w=t[15]),(0,Z.useEffect)(w,C);let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=async function(e,t,n){m(t=>new Set([...t,e]));let r=await wm(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):X.error(`Failed to resolve ${e}`)},t[16]=T):T=t[16];let E=T,D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e){g(e)},t[17]=D):D=t[17];let O=D,k;t[18]===h?k=t[19]:(k=async function(e){if(!h)return;let t=h;g(null),await E(t,`content`,e)},t[18]=h,t[19]=k);let A=k,j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){g(null)},t[20]=j):j=t[20];let M=j,N;t[21]===r?N=t[22]:(N=async function(){try{(await fetch(`/api/sync/abort-merge`,{method:`POST`})).ok?X.info(`Merge aborted — sync paused`):X.error(`Failed to abort merge`)}catch{X.error(`Failed to abort merge — connection error`)}r(!1),d(new Set)},t[21]=r,t[22]=N);let P=N,F=a.length,I=u.size,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(bm,{className:`text-sm font-medium`,children:`Resolve conflicts`}),t[23]=L):L=t[23];let R;t[24]!==I||t[25]!==F?(R=F>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[I,` of `,F,` resolved`]}),t[24]=I,t[25]=F,t[26]=R):R=t[26];let z;t[27]===R?z=t[28]:(z=(0,$.jsxs)(ym,{className:`px-4 py-3 border-b shrink-0`,children:[L,R]}),t[27]=R,t[28]=z);let B;t[29]!==a||t[30]!==s||t[31]!==u||t[32]!==p?(B=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:s?(0,$.jsxs)(`div`,{className:`px-4 py-6 text-sm text-center space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:s===`network`?`Could not reach the sync server — check your connection.`:`Sync server error — try again in a moment.`}),(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:v,children:`Retry`})]}):a.length===0?(0,$.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No conflicts found.`}):(0,$.jsx)(`ul`,{className:`divide-y`,children:a.map(e=>{let t=u.has(e.file),n=p.has(e.file),r=e.file.split(`/`).pop()??e.file;return(0,$.jsxs)(`li`,{className:`px-4 py-3 ${t?`opacity-50`:``}`,children:[(0,$.jsxs)(`p`,{className:`text-sm font-medium truncate mb-2`,title:e.file,children:[t?`✓ `:``,r]}),!t&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,disabled:n,onClick:()=>O(e.file),children:`Resolve manually`})]})]},e.file)})})}),t[29]=a,t[30]=s,t[31]=u,t[32]=p,t[33]=B):B=t[33];let V;t[34]===P?V=t[35]:(V=(0,$.jsx)(`div`,{className:`px-4 py-3 border-t shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:P,children:`Exit merge`})}),t[34]=P,t[35]=V);let H;t[36]!==z||t[37]!==B||t[38]!==V?(H=(0,$.jsxs)(vm,{side:`right`,className:`w-80 sm:w-96 flex flex-col gap-0 p-0`,children:[z,B,V]}),t[36]=z,t[37]=B,t[38]=V,t[39]=H):H=t[39];let U;t[40]!==r||t[41]!==n||t[42]!==H?(U=(0,$.jsx)(hm,{open:n,onOpenChange:r,children:H}),t[40]=r,t[41]=n,t[42]=H,t[43]=U):U=t[43];let W;t[44]!==A||t[45]!==h?(W=h&&(0,$.jsx)(Em,{file:h,onResolve:e=>void A(e),onAbort:M}),t[44]=A,t[45]=h,t[46]=W):W=t[46];let G;return t[47]!==U||t[48]!==W?(G=(0,$.jsxs)($.Fragment,{children:[U,W]}),t[47]=U,t[48]=W,t[49]=G):G=t[49],G}function Om(e){return e.file}function km(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Am(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function jm(e){return e/100*window.innerHeight}function Mm(e){return e/100*window.innerWidth}function Nm(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Pm({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Nm(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Am(t,i);break;case`em`:r=km(t,i);break;case`vh`:r=jm(i);break;case`vw`:r=Mm(i);break}return r}function Fm(e){return parseFloat(e.toFixed(3))}function Im({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Lm(e){let{panels:t}=e,n=Im({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Fm(Pm({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Fm(Pm({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Fm(Pm({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Fm(Pm({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function Rm(e,t=`Assertion error`){if(!e)throw Error(t)}function zm(e,t){return Array.from(t).sort(e===`horizontal`?Bm:Vm)}function Bm(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Vm(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Hm(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Um(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Wm({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Um(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Rm(i,`No rect found`),i}var Gm;function Km(){return Gm===void 0&&(Gm=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Gm}function qm(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=zm(n,Array.from(t.children).filter(Hm).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Wm({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Km()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Im({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Jm=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},Ym=new Map,Xm=new Jm;function Zm(e){Ym=new Map(Ym),Ym.delete(e)}function Qm(e,t){for(let[t]of Ym)if(t.id===e)return t}function $m(e,t){for(let[t,n]of Ym)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function eh(){return Ym}function th(e,t){return Xm.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function nh(e,t){let n=Ym.get(e);Ym=new Map(Ym),Ym.set(e,t),Xm.emit(`groupChange`,{group:e,prev:n,next:t})}function rh(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Um(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function ih(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ah(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:dh(e),b:dh(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Rm(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:uh(lh(n.a)),b:uh(lh(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var oh=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function sh(e){let t=getComputedStyle(fh(e)??e).display;return t===`flex`||t===`inline-flex`}function ch(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||sh(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||oh.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function lh(e){let t=e.length;for(;t--;){let n=e[t];if(Rm(n,`Missing node`),ch(n))return n}return null}function uh(e){return e&&Number(getComputedStyle(e).zIndex)||0}function dh(e){let t=[];for(;e;)t.push(e),e=fh(e);return t}function fh(e){let{parentNode:t}=e;return ih(t)?t.host:t}function ph(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function mh({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Hm(n)||n.contains(e)||e.contains(n))return!0;if(ah(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(ph(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function hh(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=qm(r),a=rh(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&mh({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function gh(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _h(e,t,n=0){return Math.abs(Fm(e)-Fm(t))<=n}function vh(e,t){return _h(e,t)?0:e>t?1:-1}function yh({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(vh(r,c)<0)if(a){let e=(i+c)/2;r=vh(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Fm(r),r}function bh({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(_h(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Rm(u!=null,`Invalid first pivot index`),Rm(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Rm(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Rm(n!=null,`Previous layout not found for panel index ${t}`),_h(n,i)){let t=o-n;vh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Rm(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Rm(n!=null,`Previous layout not found for panel index ${t}`),_h(n,o)){let t=n-i;vh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Rm(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&vh(i,c)<0)if(e>0){let t=c-o,n=t/2;vh(i+e,c)<0&&(e=vh(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;vh(i-e,c)<0&&(e=vh(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Rm(e!=null,`Previous layout not found for panel index ${r}`);let a=yh({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Rm(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=yh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!_h(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(gh(c,l))return i;{let t=e<0?d:u,r=s[t];Rm(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=yh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!_h(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Rm(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=yh({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(_h(i,s)||(t-=s-i,l[r]=s),_h(t,0))break;e>0?r--:r++}}}if(!_h(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function xh(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||vh(e[n],t[n])!==0)return!1;return!0}function Sh({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!_h(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Rm(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Rm(i!=null,`No layout data found for index ${e}`);let o=r[e];Rm(o!=null,`No layout data found for index ${e}`);let s=yh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!_h(a,0))for(let e=0;e<t.length;e++){let n=r[e];Rm(n!=null,`No layout data found for index ${e}`);let i=n+a,o=yh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,_h(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ch({groupId:e,panelId:t}){let n=()=>{let t=eh();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=Sh({layout:bh({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});xh(l,p)||nh(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&_h(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Im({group:t});o(Fm(Pm({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function wh(e){e.defaultPrevented||hh(e,eh()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Ch({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Th(e){let t=eh();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Eh({groupId:e}){let t=()=>{let t=eh();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Sh({layout:e,panelConstraints:r});return n?o:(xh(o,c)||nh(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Dh(e,t){let n=Th(e),r=$m(n.id,!0),i=n.separators.find(t=>t.element===e);Rm(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Rm(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Eh({groupId:n.id}).getLayout(),c=Sh({layout:bh({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});xh(s,c)||nh(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Oh(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Th(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Dh(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Dh(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Dh(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Dh(t,-5);break;case`End`:e.preventDefault(),Dh(t,100);break;case`Enter`:{e.preventDefault();let n=Th(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=$m(n.id,!0),o=n.separators.find(e=>e.element===t);Rm(o,`Matching separator not found`);let s=a.get(o);Rm(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Rm(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Dh(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Th(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Rm(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Dh(t,-100);break}}var kh={cursorFlags:0,state:`inactive`},Ah=new Jm;function jh(){return kh}function Mh(e){return Ah.addListener(`change`,e)}function Nh(e){let t=kh,n={...kh};n.cursorFlags=e,kh=n,Ah.emit(`change`,{prev:t,next:n})}function Ph(e){let t=kh;kh=e,Ah.emit(`change`,{prev:t,next:e})}function Fh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=eh(),n=hh(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Ph({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Ih=e=>e,Lh=()=>{},Rh=1,zh=2,Bh=4,Vh=8,Hh=3,Uh=12,Wh;function Gh(){return Wh===void 0&&(Wh=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Wh=!0)),Wh}function Kh({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&Gh()){let t=(e&Rh)!==0,n=(e&zh)!==0,r=(e&Bh)!==0,i=(e&Vh)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return Gh()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var qh=new WeakMap;function Jh(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=qh.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=jh();switch(r.state){case`active`:case`hover`:{let e=Kh({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}qh.set(e,{prevStyle:t,styleSheet:n})}function Yh({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=bh({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(xh(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Rh:zh;break;case`vertical`:s|=d<0?Bh:Vh;break}}else nh(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Hh:c|=s&Hh,t.movementY===0?c|=o&Uh:c|=s&Uh,Nh(c),Jh(e)}function Xh(e){let t=eh(),n=jh();switch(n.state){case`active`:Yh({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Zh(e){if(e.defaultPrevented)return;let t=jh(),n=eh();switch(t.state){case`active`:if(e.buttons===0){Ph({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=$m(e.group.id,!0);nh(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}Yh({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=hh(e,n);r.length===0?t.state!==`inactive`&&Ph({cursorFlags:0,state:`inactive`}):Ph({cursorFlags:0,hitRegions:r,state:`hover`}),Jh(e.currentTarget);break}}}function Qh(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(jh().state){case`hover`:Ph({cursorFlags:0,state:`inactive`})}}function $h(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=jh();switch(t.state){case`active`:Ph({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Jh(e.currentTarget),t.hitRegions.forEach(e=>{let t=$m(e.group.id,!0);nh(e.group,t)}),e.preventDefault())}}function eg(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Fm(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Fm((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function tg(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Im({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Fm(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function ng(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function rg({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Fm(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Fm((r[e]??0)/a*l);else{let e=Fm(l/c.length);for(let t of c)u[t]=e}return u}function ig(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var ag=new Map;function og(e){let t=!0;Rm(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Im({group:e});if(t===0)return;let n=$m(e.id);if(!n)return;let r=Lm(e),i=n.defaultLayoutDeferred?eg(r):n.layout,a=Sh({layout:rg({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&xh(n.layout,a)&&ng(n.derivedPanelConstraints,r)&&n.groupSize===t)return;nh(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else tg(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Rm(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Im({group:e}),s=Lm(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(ig(e.panels,l)||(l=void 0));let u=Sh({layout:e.mutableState.layouts[c]??l??eg(s),panelConstraints:s}),d=e.element.ownerDocument;ag.set(d,(ag.get(d)??0)+1);let f=new Map;return qm(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),nh(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Rm(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Oh)}),ag.get(d)===1&&(d.addEventListener(`dblclick`,wh,!0),d.addEventListener(`pointerdown`,Fh,!0),d.addEventListener(`pointerleave`,Xh),d.addEventListener(`pointermove`,Zh),d.addEventListener(`pointerout`,Qh),d.addEventListener(`pointerup`,$h,!0)),function(){t=!1,ag.set(d,Math.max(0,(ag.get(d)??0)-1)),Zm(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Oh)}),ag.get(d)||(d.removeEventListener(`dblclick`,wh,!0),d.removeEventListener(`pointerdown`,Fh,!0),d.removeEventListener(`pointerleave`,Xh),d.removeEventListener(`pointermove`,Zh),d.removeEventListener(`pointerout`,Qh),d.removeEventListener(`pointerup`,$h,!0)),a.disconnect()}}function sg(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function cg(e){let t=(0,Z.useId)();return`${e??t}`}var lg=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function ug(e){let t=(0,Z.useRef)(e);return lg(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function dg(...e){return ug(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function fg(e){let t=(0,Z.useRef)({...e});return lg(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var pg=(0,Z.createContext)(null);function mg(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:Ih});(0,Z.useImperativeHandle)(t,()=>n.current,[]),lg(()=>{Object.assign(n.current,Eh({groupId:e}))})}function hg({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=ug(e=>{xh(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=ug(e=>{xh(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=cg(s),v=(0,Z.useRef)(null),[y,b]=sg(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=dg(v,a);mg(_,o);let C=ug((e,t)=>{let r=jh(),i=Qm(e),a=$m(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=fg({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=zm(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=zm(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Qm(_),i=$m(_);r&&i&&nh(r,{...i,derivedPanelConstraints:Lm(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,Z.useRef)(null);return lg(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=og(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=$m(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=th(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=_h(t.collapsedSize,i[t.panelId]),a=_h(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=jh().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,$.jsx)(pg.Provider,{value:T,children:(0,$.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}hg.displayName=`Group`;function gg(){let e=(0,Z.useContext)(pg);return Rm(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function _g(e,t){let{id:n}=gg(),r=(0,Z.useRef)({collapse:Lh,expand:Lh,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Lh});(0,Z.useImperativeHandle)(t,()=>r.current,[]),lg(()=>{Object.assign(r.current,Ch({groupId:n,panelId:e}))})}function vg({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=cg(c),_=fg({disabled:a}),v=(0,Z.useRef)(null),y=dg(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=gg(),T=d!==null,E=ug((e,t,n)=>{d?.(e,c,n)});lg(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),_g(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>th(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,$.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...yg,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,$.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}vg.displayName=`Panel`;var yg={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function bg(){return(0,Z.useRef)(null)}function xg({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Sh({layout:bh({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Sh({layout:bh({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Sg({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=cg(a),l=fg({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),m=(0,Z.useRef)(null),h=dg(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=gg(),x=v===`horizontal`?`vertical`:`horizontal`;lg(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=Mh(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=th(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(xg({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,Z.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,$.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Sg.displayName=`Separator`;async function Cg(e){let t=await fetch(`/api/backlinks?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load backlinks`);return n.backlinks??[]}function wg(e){let t=(0,Q.c)(32),{docName:n,className:r}=e,i=r===void 0?``:r,{folderPaths:a,pages:o,loading:s}=Se(),c,l;t[0]===n?(c=t[1],l=t[2]):(c=[`backlinks`,n],l=()=>Cg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==s||t[5]!==o?(u=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=u):u=t[6];let d;t[7]!==c||t[8]!==l||t[9]!==u?(d={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=d):d=t[10];let{data:f,isLoading:p,error:m}=Je(d),h;t[11]===f?h=t[12]:(h=f===void 0?[]:f,t[11]=f,t[12]=h);let g=h,_;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Pe,{children:`Backlinks`}),t[13]=_):_=t[13];let v;t[14]!==g||t[15]!==p?(v=!p&&(0,$.jsx)(Me,{children:g.length}),t[14]=g,t[15]=p,t[16]=v):v=t[16];let y;t[17]===v?y=t[18]:(y=(0,$.jsxs)(Oe,{children:[_,v]}),t[17]=v,t[18]=y);let b;t[19]!==g||t[20]!==m||t[21]!==a||t[22]!==p||t[23]!==o?(b=m?(0,$.jsx)(te,{children:m instanceof Error?m.message:`Failed to load backlinks`}):g.length===0&&!p?(0,$.jsx)(ge,{children:`No pages link here yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`block w-full rounded-lg border border-border bg-background/80 px-3 py-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:()=>{let t=ft(e.source,{pages:o,folderPaths:a});window.location.assign(me(t.hashDocName,e.anchor))},children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source}),e.snippet?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.snippet}):null]},`${e.source}-${t}`))}),t[19]=g,t[20]=m,t[21]=a,t[22]=p,t[23]=o,t[24]=b):b=t[24];let x;t[25]!==p||t[26]!==b?(x=(0,$.jsx)(Ee,{"aria-busy":p,children:b}),t[25]=p,t[26]=b,t[27]=x):x=t[27];let S;return t[28]!==i||t[29]!==y||t[30]!==x?(S=(0,$.jsxs)(Ie,{className:i,children:[y,x]}),t[28]=i,t[29]=y,t[30]=x,t[31]=S):S=t[31],S}function Tg(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}async function Eg(e){let t=await fetch(`/api/forward-links?docName=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Server error: ${t.status} ${t.statusText}`);let n=await t.json();if(!n.ok)throw Error(n.error??`Failed to load outgoing links`);return n.forwardLinks??[]}function Dg(e){let t=(0,Q.c)(50),{docName:n,className:r}=e,i=r===void 0?``:r,{folderPaths:a,pages:o,loading:s}=Se(),c,l;t[0]===n?(c=t[1],l=t[2]):(c=[`forward-links`,n],l=()=>Eg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==o||t[5]!==s?(u=!s&&o.has(n),t[3]=n,t[4]=o,t[5]=s,t[6]=u):u=t[6];let d;t[7]!==c||t[8]!==l||t[9]!==u?(d={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=d):d=t[10];let{data:f,isLoading:p,error:m}=Je(d),h;t[11]===f?h=t[12]:(h=f===void 0?[]:f,t[11]=f,t[12]=h);let g=h,[_,v]=(0,Z.useState)(null),y;if(t[13]!==_||t[14]!==a||t[15]!==o){let e=_===null?null:en(_.docName,{pages:o,folderPaths:a});y=e===null?null:e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:Xt(e),t[13]=_,t[14]=a,t[15]=o,t[16]=y}else y=t[16];let b=y,x;t[17]!==a||t[18]!==o||t[19]!==s?(x=function(e){if(e.kind===`external`){window.open(e.url,`_blank`,`noopener,noreferrer`);return}let t=en(e.docName,{pages:o,folderPaths:a});if(!s&&t.kind===`create`){v(e);return}let n=t.kind===`navigate`?t.hashDocName:e.docName;window.location.assign(me(n,e.anchor))},t[17]=a,t[18]=o,t[19]=s,t[20]=x):x=t[20];let S=x,C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Pe,{children:`Outgoing Links`}),t[21]=C):C=t[21];let w;t[22]!==p||t[23]!==g?(w=!p&&(0,$.jsx)(Me,{children:g.length}),t[22]=p,t[23]=g,t[24]=w):w=t[24];let T;t[25]===w?T=t[26]:(T=(0,$.jsxs)(Oe,{children:[C,w]}),t[25]=w,t[26]=T);let E;t[27]!==m||t[28]!==a||t[29]!==S||t[30]!==p||t[31]!==g||t[32]!==o||t[33]!==s?(E=m?(0,$.jsx)(te,{children:m instanceof Error?m.message:`Failed to load outgoing links`}):g.length===0&&!p?(0,$.jsx)(ge,{children:`This page doesn't link to anything yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>{let t=e.kind===`doc`?en(e.docName,{pages:o,folderPaths:a}):null,n=e.kind===`doc`&&!s&&t?.kind===`create`,r=e.kind===`doc`&&!s&&t?.kind===`navigate`&&t.displayState===`folder`,i=e.kind===`doc`?Tg(e.docName):e.url,c=e.kind===`doc`&&e.title===e.docName?i:e.title,l=e.kind===`doc`?`doc:${e.docName}:${e.anchor??``}`:`ext:${e.url}`;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(q,{variant:`outline`,className:k(`h-auto w-full items-start justify-start whitespace-normal px-3 py-2 text-left`,n&&`border-amber-300 bg-amber-50/70 text-amber-950 hover:bg-amber-100 dark:border-amber-900 dark:bg-amber-950/20 dark:text-amber-200 dark:hover:bg-amber-950/35`,r&&`border-sky-300 bg-sky-50/70 text-sky-950 hover:bg-sky-100 dark:border-sky-900 dark:bg-sky-950/20 dark:text-sky-100 dark:hover:bg-sky-950/35`),onClick:()=>S(e),children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,title:e.kind===`doc`&&e.title===e.docName?e.docName:e.kind===`external`?e.url:void 0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{children:c}),e.kind===`external`?(0,$.jsx)(_t,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}):null]})}),e.kind===`doc`&&e.title!==e.docName?(0,$.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,title:e.docName,children:i}):null,e.kind===`external`?(0,$.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:e.url}):null,n?(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(_n,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Missing page. Click to create.`})]}):null,r?(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-sky-700 dark:text-sky-300`,children:[(0,$.jsx)(Dn,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Folder target. Click to open the overview.`})]}):null,e.snippet?(0,$.jsx)(`p`,{className:`mt-1 break-words text-sm text-muted-foreground`,children:e.snippet}):null]})}),r?(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>v(e),children:[(0,$.jsx)(_n,{className:`size-3.5`}),`Create index note`]}):null]},l)})}),t[27]=m,t[28]=a,t[29]=S,t[30]=p,t[31]=g,t[32]=o,t[33]=s,t[34]=E):E=t[34];let D;t[35]!==p||t[36]!==E?(D=(0,$.jsx)(Ee,{"aria-busy":p,children:E}),t[35]=p,t[36]=E,t[37]=D):D=t[37];let O;t[38]!==i||t[39]!==T||t[40]!==D?(O=(0,$.jsxs)(Ie,{className:i,children:[T,D]}),t[38]=i,t[39]=T,t[40]=D,t[41]=O):O=t[41];let A=_!==null,j=b?.initialDir??``,M=b?.suggestedName,N;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||v(null)},t[42]=N):N=t[42];let P;t[43]!==A||t[44]!==j||t[45]!==M?(P=(0,$.jsx)(Ct,{open:A,kind:`file`,initialDir:j,suggestedName:M,onOpenChange:N}),t[43]=A,t[44]=j,t[45]=M,t[46]=P):P=t[46];let F;return t[47]!==O||t[48]!==P?(F=(0,$.jsxs)($.Fragment,{children:[O,P]}),t[47]=O,t[48]=P,t[49]=F):F=t[49],F}var Og=[{id:`outline`,label:`Outline`,icon:di},{id:`backlinks`,label:`Backlinks`,icon:Kr},{id:`forward-links`,label:`Outgoing Links`,icon:qr},{id:`graph`,label:`Graph`,icon:mi}];function kg(){return Sn(()=>import(`./GraphPanel-DW_Dc6tS.js`),__vite__mapDeps([0,1,2,3]))}var Ag=(0,Z.lazy)(async()=>({default:(await kg()).GraphPanel}));function jg(e){let t=(0,Q.c)(27),{docName:n,isSourceMode:r}=e,[i,a]=(0,Z.useState)(Og[0].id),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{e&&a(e)},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=Og.map(Mg),t[1]=s):s=t[1];let c;t[2]===i?c=t[3]:(c=(0,$.jsx)(mt,{type:`single`,variant:`outline`,value:i,onValueChange:o,className:`mx-auto p-2`,"aria-label":`Document panels`,children:s}),t[2]=i,t[3]=c);let l=`panel-${i}`,u=`tab-${i}`,d;t[4]!==i||t[5]!==n||t[6]!==r?(d=i===`outline`&&(0,$.jsx)(kn,{docName:n,isSourceMode:r}),t[4]=i,t[5]=n,t[6]=r,t[7]=d):d=t[7];let f;t[8]!==i||t[9]!==n?(f=i===`backlinks`&&(0,$.jsx)(wg,{docName:n}),t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==i||t[12]!==n?(p=i===`forward-links`&&(0,$.jsx)(Dg,{docName:n}),t[11]=i,t[12]=n,t[13]=p):p=t[13];let m;t[14]!==i||t[15]!==n?(m=i===`graph`&&(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading graph…`}),children:(0,$.jsx)(Ag,{activeDocName:n})}),t[14]=i,t[15]=n,t[16]=m):m=t[16];let h;t[17]!==l||t[18]!==u||t[19]!==d||t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,$.jsxs)(`div`,{role:`tabpanel`,id:l,"aria-labelledby":u,className:`min-h-0 flex-1`,children:[d,f,p,m]}),t[17]=l,t[18]=u,t[19]=d,t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;return t[24]!==h||t[25]!==c?(g=(0,$.jsxs)($.Fragment,{children:[c,h]}),t[24]=h,t[25]=c,t[26]=g):g=t[26],g}function Mg(e){let{id:t,label:n,icon:r}=e;return(0,$.jsxs)(ot,{children:[(0,$.jsx)(lt,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,$.jsx)(pt,{children:(0,$.jsx)(r,{})})}),(0,$.jsx)($e,{side:`bottom`,children:n})]},t)}function Ng(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`tiptap-editor pt-10`,role:`status`,"aria-busy":`true`,"aria-label":`Loading document`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(yf,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,$.jsx)(yf,{className:`h-4 w-full`}),(0,$.jsx)(yf,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}function Pg(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function Fg(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=Pg(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function Ig(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function Lg(e,t){let n=`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:Fg(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:Ig(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:Fg(e,t.pageTitles),children:a}}var Rg=lc,zg=uc,Bg=yc,Vg=hc;function Hg(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i&&`pl-8`,s;t[5]!==r||t[6]!==o?(s=k(`focus:bg-accent data-[state=open]:bg-accent flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,o,r),t[5]=r,t[6]=o,t[7]=s):s=t[7];let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Lr,{className:`ml-auto`}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==a||t[11]!==s?(l=(0,$.jsxs)(bc,{"data-slot":`dropdown-menu-sub-trigger`,className:s,...a,children:[n,c]}),t[9]=n,t[10]=a,t[11]=s,t[12]=l):l=t[12],l}function Ug(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(xc,{"data-slot":`dropdown-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wg(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,sideOffset:i,portal:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?4:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=k(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md`,n),t[5]=n,t[6]=c);let l;t[7]!==r||t[8]!==o||t[9]!==c?(l=(0,$.jsx)(fc,{"data-slot":`dropdown-menu-content`,sideOffset:o,className:c,...r}),t[7]=r,t[8]=o,t[9]=c,t[10]=l):l=t[10];let u=l;if(!s)return u;let d;return t[11]===u?d=t[12]:(d=(0,$.jsx)(dc,{children:u}),t[11]=u,t[12]=d),d}function Gg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=r&&`pl-8`,o;t[4]!==n||t[5]!==a?(o=k(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,$.jsx)(mc,{"data-slot":`dropdown-menu-item`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function Kg(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,inset:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,$.jsx)(_c,{children:(0,$.jsx)(Fr,{})})}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(gc,{"data-slot":`dropdown-menu-radio-item`,"data-inset":i,className:o,...a,children:[s,n]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function qg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=r&&`pl-8`,o;t[4]!==n||t[5]!==a?(o=k(`px-2 py-1.5 text-sm font-semibold`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,$.jsx)(pc,{"data-slot":`dropdown-menu-label`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function Jg(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`bg-muted -mx-1 my-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(vc,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yg(e){let t=(0,Q.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=k(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=k(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,$.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,$.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function Xg(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zg(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=k(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function $g(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=k(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,$.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function e_(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function t_(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function n_(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function r_(e){let t=(0,Q.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,$.jsx)(kr,{className:`ml-1 size-3`}):(0,$.jsx)(Tr,{className:`ml-1 size-3`}):(0,$.jsx)(Or,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function i_(e){let t=(0,Q.c)(87),{folderPath:n}=e,{addPage:r,folderPaths:i,loading:a,pages:o,pageTitles:s,pageMeta:c}=Se(),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`name`),[_,v]=(0,Z.useState)(`asc`);if(a){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(yf,{className:`size-5 rounded`}),(0,$.jsx)(yf,{className:`h-7 w-48`})]}),(0,$.jsx)(yf,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(yf,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,$.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(yf,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(c_)]})]})}),t[2]=r):r=t[2],r}let y,b,x,S,C,w,T,E;if(t[3]!==r||t[4]!==p||t[5]!==d||t[6]!==n||t[7]!==i||t[8]!==c||t[9]!==s||t[10]!==o||t[11]!==_||t[12]!==h){let e=Lg(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=n_(e.children,h,_),l;t[21]===h?l=t[22]:(l=function(e){e===h?v(s_):(g(e),v(`asc`))},t[21]=h,t[22]=l);let D=l,O;t[23]!==r||t[24]!==n?(O=async function(){f(!0),m(null);try{let e=`${n}/index.md`,t=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),i=await t.json().catch(o_);if(!t.ok||!i?.ok){m(i?.error??`Server error (HTTP ${t.status})`),f(!1);return}let a=i.docName??`${n}/index`;r(a),ze([`files`,`backlinks`,`graph`]),window.location.hash=me(a)}catch(e){console.warn(`[FolderOverview] create index note failed:`,e),m(`Network error — please try again`)}f(!1)},t[23]=r,t[24]=n,t[25]=O):O=t[25];let k=O;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,w=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Dn,{className:`size-5 text-muted-foreground`}),t[26]=A):A=t[26];let j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Si,{className:`size-4`}),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{children:[M,`New`,(0,$.jsx)(Ir,{className:`size-3`})]})}),t[28]=N):N=t[28];let P;t[29]===k?P=t[30]:(P=()=>void k(),t[29]=k,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-medium`,children:`Index note`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Landing page for this folder`})]}),t[31]=F):F=t[31];let I;t[32]!==d||t[33]!==P?(I=(0,$.jsx)(Gg,{disabled:d,onSelect:P,children:F}),t[32]=d,t[33]=P,t[34]=I):I=t[34];let L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(Gg,{onSelect:()=>u(!0),children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-medium`,children:`Note`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`New note inside this folder`})]})}),t[35]=L):L=t[35];let R;t[36]===I?R=t[37]:(R=(0,$.jsxs)(Rg,{children:[N,(0,$.jsxs)(Wg,{align:`end`,children:[I,L]})]}),t[36]=I,t[37]=R);let z;t[38]!==j||t[39]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[j,R]}),t[38]=j,t[39]=R,t[40]=z):z=t[40];let B;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This folder has no landing note yet. Choose an explicit action to add one or open a note inside the folder.`}),t[41]=B):B=t[41];let V;t[42]===p?V=t[43]:(V=p?(0,$.jsx)(`span`,{role:`alert`,className:`text-sm text-destructive`,children:p}):null,t[42]=p,t[43]=V),t[44]!==z||t[45]!==V?(T=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[z,B,V]}),t[44]=z,t[45]=V,t[46]=T):T=t[46],C=`rounded-lg border`,b=Yg;let H=h===`name`?_===`asc`?`ascending`:`descending`:`none`,U;t[47]!==D||t[48]!==_||t[49]!==h?(U=(0,$.jsx)(r_,{label:`Name`,sortKey:`name`,activeKey:h,activeDir:_,onSort:D}),t[47]=D,t[48]=_,t[49]=h,t[50]=U):U=t[50];let W;t[51]!==H||t[52]!==U?(W=(0,$.jsx)($g,{"aria-sort":H,children:U}),t[51]=H,t[52]=U,t[53]=W):W=t[53];let G=h===`modified`?_===`asc`?`ascending`:`descending`:`none`,K;t[54]!==D||t[55]!==_||t[56]!==h?(K=(0,$.jsx)(r_,{label:`Modified`,sortKey:`modified`,activeKey:h,activeDir:_,onSort:D}),t[54]=D,t[55]=_,t[56]=h,t[57]=K):K=t[57];let ee;t[58]!==G||t[59]!==K?(ee=(0,$.jsx)($g,{className:`w-32`,"aria-sort":G,children:K}),t[58]=G,t[59]=K,t[60]=ee):ee=t[60],t[61]!==W||t[62]!==ee?(S=(0,$.jsx)(Xg,{children:(0,$.jsxs)(Qg,{children:[W,ee]})}),t[61]=W,t[62]=ee,t[63]=S):S=t[63],y=Zg,x=a.length?a.map(a_):(0,$.jsx)(Qg,{children:(0,$.jsx)(e_,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=r,t[4]=p,t[5]=d,t[6]=n,t[7]=i,t[8]=c,t[9]=s,t[10]=o,t[11]=_,t[12]=h,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E}else y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20];let D;t[64]!==y||t[65]!==x?(D=(0,$.jsx)(y,{children:x}),t[64]=y,t[65]=x,t[66]=D):D=t[66];let O;t[67]!==b||t[68]!==S||t[69]!==D?(O=(0,$.jsxs)(b,{children:[S,D]}),t[67]=b,t[68]=S,t[69]=D,t[70]=O):O=t[70];let k;t[71]!==C||t[72]!==O?(k=(0,$.jsx)(`div`,{className:C,children:O}),t[71]=C,t[72]=O,t[73]=k):k=t[73];let A;t[74]!==w||t[75]!==T||t[76]!==k?(A=(0,$.jsxs)(`div`,{className:w,children:[T,k]}),t[74]=w,t[75]=T,t[76]=k,t[77]=A):A=t[77];let j;t[78]!==A||t[79]!==E?(j=(0,$.jsx)(`div`,{className:E,children:A}),t[78]=A,t[79]=E,t[80]=j):j=t[80];let M;t[81]!==l||t[82]!==n?(M=(0,$.jsx)(Ct,{open:l,onOpenChange:u,kind:`file`,initialDir:n}),t[81]=l,t[82]=n,t[83]=M):M=t[83];let N;return t[84]!==j||t[85]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[84]=j,t[85]=M,t[86]=N):N=t[86],N}function a_(e){return(0,$.jsxs)(Qg,{children:[(0,$.jsx)(e_,{children:(0,$.jsxs)(`a`,{href:me(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0 text-muted-foreground`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,$.jsx)(e_,{className:`text-muted-foreground`,children:e.kind===`file`?t_(e.modified):`—`})]},e.path)}function o_(){return null}function s_(e){return e===`asc`?`desc`:`asc`}function c_(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,$.jsx)(yf,{className:`size-4 rounded`}),(0,$.jsx)(yf,{className:`h-4 w-40`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(yf,{className:`h-4 w-16`})})]},e)}var l_=1e3,u_=3;function d_(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??u_;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var f_={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:130,durationMin:620,durationMax:920}},p_=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function m_(e,t={}){let n=t.rng??Math.random,r=t.colors??p_,i=f_[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var h_=.8,g_=9.2736,__=18.1799,v_=14.5244,y_={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function b_(e,t){let{halfWidth:n,apexLift:r}=y_[t];return`M${e-n} ${v_+.3} Q${e} ${v_-r}, ${e+n} ${v_+.3}`}function x_(e){let t=1.5,n=.3;return`M${e-t} ${v_-n} Q${e} ${v_+1.4}, ${e+t} ${v_-n}`}var S_=15,C_=15;function w_(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function T_(e){let t=(0,Q.c)(61),{size:n,className:r,trackMouse:i,variant:a}=e,o=n===void 0?48:n,s=i===void 0?!0:i,c=a===void 0?`default`:a,l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,Z.useState)(g),y=(0,Z.useRef)(0),b=(0,Z.useRef)(0),x=(0,Z.useRef)(void 0),S=c===`sleeping`,C;t[1]!==f||t[2]!==S?(C=function(){if(S)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=y.current===0?1/0:e-y.current;y.current=e;let n=d_(f,t);p(n),h(D_),v(m_(n)),clearTimeout(x.current),x.current=setTimeout(()=>{p(0),v([])},l_)},t[1]=f,t[2]=S,t[3]=C):C=t[3];let w=C,T,E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>clearTimeout(x.current),E=[],t[4]=T,t[5]=E):(T=t[4],E=t[5]),(0,Z.useEffect)(T,E);let D,O;t[6]!==S||t[7]!==s?(D=()=>{if(!s||S||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=function(e){b.current&&cancelAnimationFrame(b.current),b.current=requestAnimationFrame(()=>{let t=l.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height*.48,a=e.clientX-r,o=e.clientY-i,s=Math.hypot(a,o),c=0,f=0;if(s>=1){let e=Math.min(s/150,1)*h_;c=a/s*e,f=o/s*e}u.current?.setAttribute(`cx`,String(g_+c)),u.current?.setAttribute(`cy`,String(v_+f)),d.current?.setAttribute(`cx`,String(__+c)),d.current?.setAttribute(`cy`,String(v_+f))})};return document.addEventListener(`mousemove`,e,{passive:!0}),()=>{document.removeEventListener(`mousemove`,e),b.current&&cancelAnimationFrame(b.current)}},O=[s,S],t[6]=S,t[7]=s,t[8]=D,t[9]=O):(D=t[8],O=t[9]),(0,Z.useEffect)(D,O);let A=f>0,j=A?f:1,M=A?`ok-blob-clicked-${f}`:null,N=S?`cursor-default`:`cursor-pointer`,P;t[10]!==r||t[11]!==N?(P=k(N,r),t[10]=r,t[11]=N,t[12]=P):P=t[12];let F=`body-${m}`,I=S&&`ok-blob-sleeping`,L;t[13]!==M||t[14]!==I?(L=k(`ok-blob-group`,I,M),t[13]=M,t[14]=I,t[15]=L):L=t[15];let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[16]=R):R=t[16];let z=(A||S)&&`ok-blob-eye-hidden`,B;t[17]===z?B=t[18]:(B=k(`ok-blob-eye`,z),t[17]=z,t[18]=B);let V;t[19]===B?V=t[20]:(V=(0,$.jsx)(`ellipse`,{ref:u,cx:g_,cy:v_,rx:1.2722,ry:1.9083,className:B}),t[19]=B,t[20]=V);let H=(A||S)&&`ok-blob-eye-hidden`,U;t[21]===H?U=t[22]:(U=k(`ok-blob-eye ok-blob-eye-right`,H),t[21]=H,t[22]=U);let W;t[23]===U?W=t[24]:(W=(0,$.jsx)(`ellipse`,{ref:d,cx:__,cy:v_,rx:1.2722,ry:1.9083,className:U}),t[23]=U,t[24]=W);let G;t[25]===j?G=t[26]:(G=b_(g_,j),t[25]=j,t[26]=G);let K=(!A||S)&&`ok-blob-eye-hidden`,ee;t[27]===K?ee=t[28]:(ee=k(`ok-blob-happy-eye`,K),t[27]=K,t[28]=ee);let te;t[29]!==G||t[30]!==ee?(te=(0,$.jsx)(`path`,{d:G,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ee}),t[29]=G,t[30]=ee,t[31]=te):te=t[31];let ne;t[32]===j?ne=t[33]:(ne=b_(__,j),t[32]=j,t[33]=ne);let re=(!A||S)&&`ok-blob-eye-hidden`,ie;t[34]===re?ie=t[35]:(ie=k(`ok-blob-happy-eye`,re),t[34]=re,t[35]=ie);let ae;t[36]!==ne||t[37]!==ie?(ae=(0,$.jsx)(`path`,{d:ne,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ie}),t[36]=ne,t[37]=ie,t[38]=ae):ae=t[38];let oe;t[39]===S?oe=t[40]:(oe=S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`path`,{d:x_(g_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,$.jsx)(`path`,{d:x_(__),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[39]=S,t[40]=oe);let se;t[41]!==F||t[42]!==L||t[43]!==V||t[44]!==W||t[45]!==te||t[46]!==ae||t[47]!==oe?(se=(0,$.jsxs)(`g`,{className:L,children:[R,V,W,te,ae,oe]},F),t[41]=F,t[42]=L,t[43]=V,t[44]=W,t[45]=te,t[46]=ae,t[47]=oe,t[48]=se):se=t[48];let q;t[49]===S?q=t[50]:(q=S?(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,$.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[49]=S,t[50]=q);let ce;t[51]!==m||t[52]!==_?(ce=_.length>0&&(0,$.jsx)(`g`,{children:_.map(E_)},`firework-${m}`),t[51]=m,t[52]=_,t[53]=ce):ce=t[53];let le;return t[54]!==w||t[55]!==o||t[56]!==P||t[57]!==se||t[58]!==q||t[59]!==ce?(le=(0,$.jsxs)(`svg`,{ref:l,width:o,height:o,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:P,"aria-hidden":`true`,onClick:w,children:[se,q,ce]}),t[54]=w,t[55]=o,t[56]=P,t[57]=se,t[58]=q,t[59]=ce,t[60]=le):le=t[60],le}function E_(e){return(0,$.jsx)(`circle`,{cx:S_+e.originDx,cy:C_+e.originDy,r:e.size,className:`ok-blob-firework`,style:w_(e)},e.id)}function D_(e){return e+1}function O_(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(hg,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function k_(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(vg,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function A_(e){let t=(0,Q.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=k(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,$.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,$.jsx)(Sg,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var j_=960,M_=1024;function N_(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(F_),[r,i]=(0,Z.useState)(P_),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${j_-1}px)`),t=window.matchMedia(`(max-width: ${M_-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Z.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={layout:t,autoCollapse:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function P_(){return window.innerWidth>=j_&&window.innerWidth<M_}function F_(){return window.innerWidth<j_?`sheet`:`panel`}var I_=Ye;function L_(){let[e]=(0,Z.useState)(s);return e}function R_(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var z_=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&qe(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(P(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(y(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(je(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Ze(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(U(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(o(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(z(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(m(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=l(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof T){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof i){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():R_(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&g(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},B_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new z_({view:t,...e})});Be.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[B_({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var V_=b(pe(),1),H_=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return ee(e,{textSerializers:He(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(P(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(y(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(je(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Ze(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(U(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(o(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(z(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(m(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=l(this.view,e.from,e.to);g({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},U_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new H_({view:t,...e})});Be.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[U_({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function W_(e,t){return e??new r(t)}var G_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,K_=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),q_=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),J_=new Set([`children`,`className`,`style`]),Y_=new Set([`tabIndex`]),X_=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),Z_={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function Q_(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function $_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ev(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||X_.has(e)}function tv(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function nv(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:Z_[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function rv(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function iv(e){return Y_.has(e)}function av(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function ov(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function sv(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||q_.has(e)?String(t):`${t}px`}function cv(e,t){K_.has(t)||e.style.removeProperty(tv(t))}function lv(e,t,n){K_.has(t)||e.style.setProperty(tv(t),sv(t,n))}function uv(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(J_.has(r)||!ev(r)||Q_(r,t[r])||Q_(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=$_(r);if(a==null||a===!1){iv(r)&&ov(e,r),e.removeAttribute(o);return}if(a===!0){iv(r)&&av(e,r,!0),e.setAttribute(o,``);return}if(iv(r)){av(e,r,a);return}e.setAttribute(o,String(a))})}function dv(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function fv(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){cv(e,t);return}lv(e,t,a)}})}function pv(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!Q_(t,n))return;let{eventName:i,options:a}=nv(t),o=t=>{n(rv(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function mv(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);G_(()=>{let i=n.current;return dv(e,i.className,t.className),fv(e,i.style,t.style),uv(e,i,t),r.current=pv(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var hv=Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Z.useRef)(document.createElement(`div`)),f=(0,Z.useRef)(W_(e,`bubbleMenu`)).current;mv(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Dt(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Z.useRef)(h);g.current=h;let[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=B_({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Z.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,V_.createPortal)(c,d.current)});Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Z.useRef)(document.createElement(`div`)),d=(0,Z.useRef)(W_(e,`floatingMenu`)).current;mv(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Dt(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Z.useRef)(m);h.current=m;let[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=U_({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Z.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,V_.createPortal)(s,u.current)});function gv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,$.jsx)(rl,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var _v=[{name:`paragraph`,label:`Text`,icon:yi,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Ln,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:mn,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:bt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:nn,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:Gt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:sn,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:jn,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Ni,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function vv(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:yv},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Ut(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,$.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=_v.map(e=>{let t=e.icon,r=a[e.name];return(0,$.jsxs)(Gg,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,$.jsx)(t,{className:`size-4`}),(0,$.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,$.jsx)(Wg,{align:`start`,sideOffset:8,portal:!1,className:`w-44 max-h-[var(--radix-dropdown-menu-content-available-height)] overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,$.jsxs)(Rg,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function yv(e){let t=Object.fromEntries(_v.map(t=>[t.name,t.isActive(e.editor)]));return{current:_v.find(e=>t[e.name])??_v[0],activeStates:t}}var bv=[{name:`bold`,icon:jr,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:si,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Vi,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Ii,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:Vr,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:ii,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function xv(e){let t=(0,Q.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Sv},t[0]=n,t[1]=r);let i=Ut(r),a;t[2]!==i||t[3]!==n?(a=bv.map(e=>{let t=e.icon,r=i[e.name];return(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,$.jsx)(t,{className:`size-3.5`})})}),(0,$.jsxs)($e,{side:`bottom`,sideOffset:8,children:[(0,$.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,$.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function Sv(e){return Object.fromEntries(bv.map(t=>[t.name,t.isActive(e.editor)]))}function Cv(e){let t=(0,Q.c)(46),{editor:n}=e,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),s=(0,Z.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Z.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Z.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,$.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link...`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),window.open(d,`_blank`,`noopener,noreferrer`)},children:(0,$.jsx)(_t,{className:`size-3.5`})})}),(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,$.jsx)(It,{className:`size-3.5`})})}),(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,$.jsx)(li,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsxs)($e,{side:`bottom`,sideOffset:8,children:[`Link`,(0,$.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,$.jsxs)(ot,{children:[T,E]}),t[44]=T,t[45]=D),D}function wv({editor:e}){if(e.state.selection.empty||e.isActive(`codeBlock`))return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function Tv(e){let t=(0,Q.c)(25),{editor:n}=e,r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),o=(0,Z.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return l(n.view,e,t)}catch{return new DOMRect}},t[0]=n.state,t[1]=n.view,t[2]=s):s=t[2];let c;if(t[3]!==n.view.dom||t[4]!==s){let e={getBoundingClientRect:s,contextElement:n.view.dom};c=()=>{let t=r.current;t&&(o.current?.(),o.current=I(e,t,()=>{g(e,t,{placement:`top`,strategy:`fixed`,middleware:[je(8),P(),y({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch(Ov)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let u=c,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{o.current?.(),o.current=null,a(Dv)},t[6]=d):d=t[6];let f=d,p;t[7]===u?p=t[8]:(p={onShow:u,onHide:f,strategy:`fixed`},t[7]=u,t[8]=p);let m;t[9]===n?m=t[10]:(m=(0,$.jsx)(vv,{editor:n}),t[9]=n,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=h):h=t[11];let _;t[12]!==n||t[13]!==i?(_=(0,$.jsx)(xv,{editor:n},i),t[12]=n,t[13]=i,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=v):v=t[15];let b=`${i}-link`,x;t[16]!==n||t[17]!==b?(x=(0,$.jsx)(Cv,{editor:n},b),t[16]=n,t[17]=b,t[18]=x):x=t[18];let S;return t[19]!==n||t[20]!==x||t[21]!==p||t[22]!==m||t[23]!==_?(S=(0,$.jsxs)(hv,{ref:r,editor:n,appendTo:Ev,shouldShow:wv,updateDelay:250,options:p,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[m,h,_,v,x]}),t[19]=n,t[20]=x,t[21]=p,t[22]=m,t[23]=_,t[24]=S):S=t[24],S}function Ev(){return document.body}function Dv(e){return e+1}function Ov(){}var kv=[{name:`addRowBefore`,icon:kr,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Tr,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:It,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],Av=[{name:`addColumnBefore`,icon:Er,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Dr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:It,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],jv=[{name:`toggleHeaderRow`,icon:Ri,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:Ur,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:ri,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function Mv({editor:e}){return e.isActive(`table`)}function Nv(e){let t=(0,Q.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,$.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,$.jsxs)(ot,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Pv(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=kv.map(e=>(0,$.jsx)(Nv,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=Av.map(e=>(0,$.jsx)(Nv,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=jv.map(e=>(0,$.jsx)(Nv,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,$.jsxs)(hv,{editor:n,shouldShow:Mv,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var Fv=new WeakMap;function Iv(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=A(e.color),n.textContent=e.name,t.append(n),t}var Lv={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},Rv=e=>{let t=(0,Q.c)(53),{provider:n,placeholder:r}=e,i=(0,Z.useRef)(``),a=(0,Z.useRef)(null),o=(0,Z.useRef)(Lv),s=L_(),[c]=(0,Z.useState)(zv),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);if(d)throw d;let p=(0,Z.useRef)(null),m=n.configuration.name??``,h;t[0]!==c||t[1]!==m||t[2]!==r||t[3]!==n?(h=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=yt({docName:m,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new we({element:e,onBeforeCreate:e=>{let{editor:n}=e;Fv.set(n,t)},onCreate:e=>{let{editor:t}=e,r=Fv.get(t);if(Fv.delete(t),r==null)return;let i=performance.now();bn(`ok/editor/create-tiptap`,{docName:n.configuration.name??`unknown`,ytextLength:n.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-10 pb-16 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=c.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>c.text(e,t),clipboardSerializer:c.html,handlePaste:(e,t)=>c.paste(e,t)},extensions:[...Rt.map(e=>e.name===`link`?e.configure({docName:n.configuration.name??``}):e),I_.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),rn.configure({document:n.document}),Be.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[on]}}),Be.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[hn(e,{cursorBuilder:Iv})]}})]}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),p.current=e,u(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),p.current=null,u(null),f(t instanceof Error?t:Error(String(t)))}return()=>{let e=p.current;e&&Rn(e),p.current=null,u(null)}},t[0]=c,t[1]=m,t[2]=r,t[3]=n,t[4]=h):h=t[4];let g;t[5]!==c||t[6]!==m||t[7]!==n?(g=[m,n,c],t[5]=c,t[6]=m,t[7]=n,t[8]=g):g=t[8],(0,Z.useEffect)(h,g);let _;t[9]===n.configuration.name?_=t[10]:(_=()=>{let e=n.configuration.name;return tn(e??null),Bv},t[9]=n.configuration.name,t[10]=_);let v;t[11]===n?v=t[12]:(v=[n],t[11]=n,t[12]=v),(0,Z.useEffect)(_,v);let y;t[13]!==l||t[14]!==n.configuration.name?(y=()=>{},t[13]=l,t[14]=n.configuration.name,t[15]=y):y=t[15];let b;t[16]!==l||t[17]!==n?(b=[l,n],t[16]=l,t[17]=n,t[18]=b):b=t[18],(0,Z.useEffect)(y,b);let x,S;t[19]===l?(x=t[20],S=t[21]):(x=()=>{if(!l)return;let e=Vv,t=null,n=()=>{t||!l||l.isDestroyed||(t=l.view.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return l.editorView?n():l.on(`create`,n),()=>{l.off(`create`,n),r()}},S=[l],t[19]=l,t[20]=x,t[21]=S),(0,Z.useEffect)(x,S);let C,w;t[22]!==l||t[23]!==n.document?(w=()=>{if(!l)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,s=null,c=null,u=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},d=e=>{o.current=e;let t=a.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},f=()=>{let e=u(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(o.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};d(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),s&&clearTimeout(s),c&&clearTimeout(c),s=window.setTimeout(()=>{let e={...n,state:`settled`};d(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{d({...e,state:`idle`})},300)},H)};d(Lv);let p=()=>{if(B(e),!W(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),f()},e)}return}r=n,f()};e.observe(p);let m=()=>{document.visibilityState===`visible`?W(e,t)&&(t=Date.now(),r=Date.now(),f()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(p),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),s&&clearTimeout(s),c&&clearTimeout(c)}},C=[l,n.document],t[22]=l,t[23]=n.document,t[24]=C,t[25]=w):(C=t[24],w=t[25]),(0,Z.useEffect)(w,C);let T,E;t[26]===n?(T=t[27],E=t[28]):(T=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},E=[n],t[26]=n,t[27]=T,t[28]=E),(0,Z.useEffect)(T,E);let D,O;t[29]===l?(D=t[30],O=t[31]):(D=()=>{if(!l)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!l||l.isDestroyed)return;let n=l.editorView;if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(cn,e),()=>window.removeEventListener(cn,e)},O=[l],t[29]=l,t[30]=D,t[31]=O),(0,Z.useEffect)(D,O);let k,A;t[32]===n.document?(k=t[33],A=t[34]):(k=()=>{let e=n.document.getMap(`metadata`),t=e.get(`frontmatter`);typeof t==`string`&&t&&(i.current=t);let r=()=>{let t=e.get(`frontmatter`);typeof t==`string`&&(i.current=t)};return e.observe(r),()=>e.unobserve(r)},A=[n.document],t[32]=n.document,t[33]=k,t[34]=A),(0,Z.useEffect)(k,A);let j;t[35]!==s||t[36]!==n.awareness?(j=()=>{let e=n.awareness;e&&(e.setLocalStateField(`user`,{name:s.name,color:s.color,type:`human`,coeditor:s.coeditor,tabId:s.tabId}),e.setLocalStateField(`mode`,`wysiwyg`))},t[35]=s,t[36]=n.awareness,t[37]=j):j=t[37];let M;t[38]!==s||t[39]!==n?(M=[n,s],t[38]=s,t[39]=n,t[40]=M):M=t[40],(0,Z.useEffect)(j,M);let N;t[41]===l?N=t[42]:(N=l&&(0,$.jsx)(Tv,{editor:l}),t[41]=l,t[42]=N);let P;t[43]===l?P=t[44]:(P=l&&(0,$.jsx)(Pv,{editor:l}),t[43]=l,t[44]=P);let F,I;t[45]===l?(F=t[46],I=t[47]):(F=(0,$.jsx)(kt,{editor:l,className:`h-full`}),I=l&&(0,$.jsx)(Wn,{store:Kt(l).store}),t[45]=l,t[46]=F,t[47]=I);let L;return t[48]!==N||t[49]!==P||t[50]!==F||t[51]!==I?(L=(0,$.jsxs)(`div`,{ref:a,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[N,P,F,I]}),t[48]=N,t[49]=P,t[50]=F,t[51]=I,t[52]=L):L=t[52],L};function zv(){let e=new ve({extensions:f});return{mdManager:e,text:Mn({mdManager:e}),html:En({mdManager:e}),paste:gn({mdManager:e})}}function Bv(){return tn(null)}function Vv(){return xt()}function Hv(e){let t=(0,Q.c)(2),{docName:n,provider:r,children:i}=e;(0,Z.use)(Ht(n,r));let a;return t[0]===i?a=t[1]:(a=(0,$.jsx)($.Fragment,{children:i}),t[0]=i,t[1]=a),a}var Uv=(0,Z.createContext)(null),Wv={didCatch:!1,error:null},Gv=class extends Z.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Wv}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(Wv))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&Kv(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(Wv))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,Z.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,Z.createElement)(Uv.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function Kv(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var qv=`__back-nav__`;function Jv(e){return e instanceof Ot||e instanceof Yt||e instanceof Vn||e instanceof Tt?e.docName:null}function Yv(e){return e instanceof Ot?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof Yt?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Vn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Tt?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function Xv(e){let t=(0,Q.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=Yv(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(T_,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,$.jsx)(`h2`,{id:`document-error-title`,className:`text-lg font-medium`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(q,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,$.jsx)(q,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(Et(Jv(n)??i),o(a),r(qv))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,$.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,$.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function Zv(e){let t=(0,Q.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,$.jsx)(Xv,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===qv){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.warn(`[DocumentErrorBoundary] rendered fallback for ${n}: ${Yv(e).title}`)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,$.jsx)(Gv,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Qv(e){let t=e.threshold??5e5;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function $v(){return Sn(()=>import(`./SourceEditor-BKyWQ7mW.js`),__vite__mapDeps([4,1,2,5,6,7,8]))}var ey=(0,Z.lazy)(async()=>({default:(await $v()).SourceEditor}));function ty(e,t,n){if(n<=0)return[];let r=e.filter(e=>!yn(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function ny(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(St,{name:`activity-pool`,children:(0,$.jsx)(ry,{...e})}),t[0]=e,t[1]=n),n}function ry(e){let t=(0,Q.c)(11),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c}=Hn(),{pages:l,loading:u}=Se(),d=ty(c,n,3),f=(0,Z.useRef)(``),p=d.map(iy).join(`,`);(0,Z.useLayoutEffect)(()=>{if(f.current===p)return;let e=f.current?f.current.split(`,`):[],t=p?p.split(`,`):[];bn(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),f.current=p,On(t)},[p,n]);let m;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==u||t[4]!==o||t[5]!==s||t[6]!==l||t[7]!==a?(m=e=>(0,$.jsx)(sy,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!u&&!l.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s},e.docName),t[0]=n,t[1]=i,t[2]=r,t[3]=u,t[4]=o,t[5]=s,t[6]=l,t[7]=a,t[8]=m):m=t[8];let h=d.map(m),g;return t[9]===h?g=t[10]:(g=(0,$.jsx)($.Fragment,{children:h}),t[9]=h,t[10]=g),g}function iy(e){return e.docName}function ay(e){let t=(0,Q.c)(8),{isActive:n,children:r}=e,i=(0,Z.useRef)(null),a=(0,Z.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Z.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Z.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,$.jsx)(`div`,{ref:i,className:`subtle-scrollbar h-full overflow-y-auto`,style:u,children:r}),t[6]=r,t[7]=d),d}function oy(e){let t=(0,Q.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Z.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Z.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Ng,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,$.jsx)(Z.Suspense,{fallback:d,children:(0,$.jsx)(ey,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function sy(e){let t=(0,Q.c)(48),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l}=e,u=n.provider.document.getText(`source`).length,[d,f]=(0,Z.useState)(i),[p,m]=(0,Z.useState)(!i),h,g;t[0]!==i||t[1]!==d||t[2]!==p?(h=()=>{i&&!d?f(!0):!i&&!p&&m(!0)},g=[i,d,p],t[0]=i,t[1]=d,t[2]=p,t[3]=h,t[4]=g):(h=t[3],g=t[4]),(0,Z.useEffect)(h,g);let _=Qv({ytextLength:u,isSourceMode:i,visitedSource:d,visitedVisual:p}),v=(0,Z.useRef)(``),y=`${_.isLarge}-${_.renderSource}-${_.renderVisual}`,b,x;t[5]!==n.docName||t[6]!==_.isLarge||t[7]!==_.renderSource||t[8]!==_.renderVisual||t[9]!==y||t[10]!==i||t[11]!==u?(b=()=>{v.current!==y&&(v.current=y,_.isLarge&&bn(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:u,isSourceMode:i,renderSource:_.renderSource,renderVisual:_.renderVisual}))},x=[y,_.isLarge,_.renderSource,_.renderVisual,n.docName,u,i],t[5]=n.docName,t[6]=_.isLarge,t[7]=_.renderSource,t[8]=_.renderVisual,t[9]=y,t[10]=i,t[11]=u,t[12]=b,t[13]=x):(b=t[12],x=t[13]),(0,Z.useEffect)(b,x);let S=r?`visible`:`hidden`,C=`editor:${n.docName}`,w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Ng,{}),t[14]=w):w=t[14];let T;t[15]!==a||t[16]!==n||t[17]!==_.renderSource||t[18]!==r||t[19]!==i?(T=_.renderSource?(0,$.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,$.jsx)(oy,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,t[15]=a,t[16]=n,t[17]=_.renderSource,t[18]=r,t[19]=i,t[20]=T):T=t[20];let E;t[21]!==a||t[22]!==n.docName||t[23]!==n.provider||t[24]!==_.renderVisual||t[25]!==o||t[26]!==i?(E=_.renderVisual?(0,$.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,$.jsx)(Rv,{provider:n.provider,placeholder:a},`${n.docName}-${String(o)}`)}):null,t[21]=a,t[22]=n.docName,t[23]=n.provider,t[24]=_.renderVisual,t[25]=o,t[26]=i,t[27]=E):E=t[27];let D;t[28]!==T||t[29]!==E?(D=(0,$.jsxs)(`div`,{className:`relative h-full`,children:[T,E]}),t[28]=T,t[29]=E,t[30]=D):D=t[30];let O;t[31]!==n.docName||t[32]!==n.provider||t[33]!==D?(O=(0,$.jsx)(Z.Suspense,{fallback:w,children:(0,$.jsx)(Hv,{docName:n.docName,provider:n.provider,children:D})}),t[31]=n.docName,t[32]=n.provider,t[33]=D,t[34]=O):O=t[34];let k;t[35]!==n.docName||t[36]!==c||t[37]!==l||t[38]!==s||t[39]!==O?(k=(0,$.jsx)(Zv,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:O}),t[35]=n.docName,t[36]=c,t[37]=l,t[38]=s,t[39]=O,t[40]=k):k=t[40];let A;t[41]!==r||t[42]!==k?(A=(0,$.jsx)(ay,{isActive:r,children:k}),t[41]=r,t[42]=k,t[43]=A):A=t[43];let j;return t[44]!==A||t[45]!==S||t[46]!==C?(j=(0,$.jsx)(Z.Activity,{mode:S,name:C,children:A}),t[44]=A,t[45]=S,t[46]=C,t[47]=j):j=t[47],j}function cy(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(St,{name:`editor-area`,children:(0,$.jsx)(ly,{...e})}),t[0]=e,t[1]=n),n}function ly(e){let t=(0,Q.c)(93),{editorMode:n,previewEntry:r,diffLayout:i,onNoDiff:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l}=Hn(),{openDocumentTransition:u}=Jt(),d=(0,Z.useDeferredValue)(o),f=c?.kind===`missing`?`Start writing to create this page…`:void 0,p=bg(),[m,h]=(0,Z.useState)(!1),{layout:g,autoCollapse:_}=N_(),v=g===`sheet`,[y,b]=(0,Z.useState)(!1),x=(0,Z.useRef)(!1),S,C;t[0]!==_||t[1]!==g||t[2]!==p?(S=()=>{g===`panel`&&(_?(x.current=!1,p.current?.collapse()):x.current||p.current?.expand())},C=[_,g,p],t[0]=_,t[1]=g,t[2]=p,t[3]=S,t[4]=C):(S=t[3],C=t[4]),(0,Z.useEffect)(S,C);let w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),D,O;t[5]===o?(D=t[6],O=t[7]):(D=()=>{if(o&&o!==w.current){let e=w.current;w.current=o,E(e)}},O=[o],t[5]=o,t[6]=D,t[7]=O),(0,Z.useEffect)(D,O);let[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N;t[8]!==o||t[9]!==s||t[10]!==a||t[11]!==r?(N=()=>{if(!r?.sha||!o){A(null);return}let e=!1,t=r.sha,n=o;return M(!0),A(null),(async function(){try{let r=await fetch(`/api/history/${t}?docName=${encodeURIComponent(n)}`);if(e)return;if(!r.ok){A(null),M(!1);return}let i=await r.json();if(!e){let e=L(i.content??``).body,t=L(s?.document.getText(`source`).toString()??``).body,n=dy;if(n(e)===n(t)){M(!1),a?.();return}A({old:e,new:t}),M(!1)}}catch{e||(A(null),M(!1))}})(),()=>{e=!0}},t[8]=o,t[9]=s,t[10]=a,t[11]=r,t[12]=N):N=t[12];let P=r?.sha,F;if(t[13]!==o||t[14]!==s||t[15]!==a||t[16]!==P?(F=[P,o,s,a],t[13]=o,t[14]=s,t[15]=a,t[16]=P,t[17]=F):F=t[17],(0,Z.useEffect)(N,F),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,$.jsx)(i_,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(!s||!o){if((typeof window<`u`?Te(window.location.hash):null)!==null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ng,{}),t[20]=e):e=t[20],e}let e;return t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4`,children:[(0,$.jsx)(T_,{size:80}),(0,$.jsx)(`span`,{className:`select-none text-sm text-muted-foreground`,children:`Select a document to edit`})]}),t[21]=e):e=t[21],e}let I=n===`diff`,R=n===`source`,z=v?!y:m,B;t[22]!==m||t[23]!==v||t[24]!==p?(B=()=>{v?b(uy):m?(x.current=!1,p.current?.expand()):(x.current=!0,p.current?.collapse())},t[22]=m,t[23]=v,t[24]=p,t[25]=B):B=t[25];let V=z?`Show document panel`:`Hide document panel`,H;t[26]===z?H=t[27]:(H=z?(0,$.jsx)(vi,{className:`size-4`}):(0,$.jsx)(_i,{className:`size-4`}),t[26]=z,t[27]=H);let U;t[28]!==H||t[29]!==B||t[30]!==V?(U=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:B,"aria-label":V,className:`text-muted-foreground`,children:H})}),t[28]=H,t[29]=B,t[30]=V,t[31]=U):U=t[31];let W=z?`Show panel`:`Hide panel`,G;t[32]===W?G=t[33]:(G=(0,$.jsx)($e,{side:`left`,children:W}),t[32]=W,t[33]=G);let K;t[34]!==U||t[35]!==G?(K=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,$.jsxs)(ot,{children:[U,G]})}),t[34]=U,t[35]=G,t[36]=K):K=t[36];let ee=K,te;t[37]!==I||t[38]!==j?(te=I&&j&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,role:`status`,"aria-label":`Loading version`,children:(0,$.jsx)(`div`,{className:`size-5 animate-spin rounded-full border-2 border-muted border-t-foreground`})}),t[37]=I,t[38]=j,t[39]=te):te=t[39];let ne;t[40]!==k||t[41]!==i||t[42]!==I||t[43]!==j?(ne=I&&!j&&k!==null&&(0,$.jsx)(mm,{oldContent:k.old,newContent:k.new,layout:i}),t[40]=k,t[41]=i,t[42]=I,t[43]=j,t[44]=ne):ne=t[44];let re=I?`none`:void 0,ie;t[45]===re?ie=t[46]:(ie={display:re},t[45]=re,t[46]=ie);let ae=d??o,oe=T??void 0,se;t[47]===u?se=t[48]:(se=e=>{let t=me(e);window.location.hash===t?u(e):window.location.hash=t},t[47]=u,t[48]=se);let ce;t[49]!==f||t[50]!==R||t[51]!==l||t[52]!==ae||t[53]!==oe||t[54]!==se?(ce=(0,$.jsx)(ny,{activeDocName:ae,isSourceMode:R,editorPlaceholder:f,previousDocName:oe,onNavigateBack:se,onRecycle:l}),t[49]=f,t[50]=R,t[51]=l,t[52]=ae,t[53]=oe,t[54]=se,t[55]=ce):ce=t[55];let le;t[56]!==o||t[57]!==d?(le=o&&o!==d?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Ng,{})}):null,t[56]=o,t[57]=d,t[58]=le):le=t[58];let ue;t[59]!==ie||t[60]!==ce||t[61]!==le?(ue=(0,$.jsxs)(`div`,{className:`relative h-full`,style:ie,children:[ce,le]}),t[59]=ie,t[60]=ce,t[61]=le,t[62]=ue):ue=t[62];let de;t[63]!==te||t[64]!==ne||t[65]!==ue||t[66]!==ee?(de=(0,$.jsxs)(`div`,{className:`relative h-full`,children:[te,ne,ue,ee]}),t[63]=te,t[64]=ne,t[65]=ue,t[66]=ee,t[67]=de):de=t[67];let fe=de;if(v){let e;t[68]===fe?e=t[69]:(e=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:fe}),t[68]=fe,t[69]=e);let n;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ym,{className:`sr-only`,children:(0,$.jsx)(bm,{children:`Document panel`})}),t[70]=n):n=t[70];let r;t[71]!==o||t[72]!==R?(r=(0,$.jsxs)(vm,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,$.jsx)(jg,{docName:o,isSourceMode:R})]}),t[71]=o,t[72]=R,t[73]=r):r=t[73];let i;t[74]!==y||t[75]!==r?(i=(0,$.jsx)(hm,{open:y,onOpenChange:b,children:r}),t[74]=y,t[75]=r,t[76]=i):i=t[76];let a;return t[77]!==e||t[78]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,i]}),t[77]=e,t[78]=i,t[79]=a):a=t[79],a}let pe;t[80]===fe?pe=t[81]:(pe=(0,$.jsx)(k_,{minSize:`30%`,defaultSize:`75%`,children:fe}),t[80]=fe,t[81]=pe);let he;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(A_,{withHandle:!0}),t[82]=he):he=t[82];let ge;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>h(e.asPercentage===0),t[83]=ge):ge=t[83];let _e;t[84]!==o||t[85]!==R?(_e=(0,$.jsx)(jg,{docName:o,isSourceMode:R}),t[84]=o,t[85]=R,t[86]=_e):_e=t[86];let ve;t[87]!==p||t[88]!==_e?(ve=(0,$.jsx)(k_,{panelRef:p,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:ge,className:`flex flex-col bg-muted/20`,children:_e}),t[87]=p,t[88]=_e,t[89]=ve):ve=t[89];let ye;return t[90]!==pe||t[91]!==ve?(ye=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,$.jsxs)(O_,{orientation:`horizontal`,children:[pe,he,ve]})}),t[90]=pe,t[91]=ve,t[92]=ye):ye=t[92],ye}function uy(e){return!e}function dy(e){return e.replace(/\r\n/g,`
|
|
17
|
-
`).replace(/[ \t]+$/gm,``).trimEnd()}function fy(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function py(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function my(e,t){let n=fy(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function hy(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>({...e,docName:n.get(e.docName)??e.docName}))}function gy(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function _y(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var vy=1280;function yy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(by),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${vy-1}px)`),t=()=>{n(window.innerWidth<vy)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function by(){return window.innerWidth<vy}var xy=`sidebar_state`,Sy=3600*24*7,Cy=`18rem`,wy=`18rem`,Ty=`3rem`,Ey=`\\`,Dy=Z.createContext(null);function Oy(){let e=Z.use(Dy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function ky(e){let t=(0,Q.c)(36),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?!0:c,u=yy(),[d,f]=Z.useState(!1),[p,m]=Z.useState(l),h=i??p,g;t[8]!==h||t[9]!==o?(g=e=>{let t=typeof e==`function`?e(h):e;o?o(t):m(t),document.cookie=`${xy}=${t}; path=/; max-age=${Sy}`},t[8]=h,t[9]=o,t[10]=g):g=t[10];let _=g,v;t[11]!==u||t[12]!==_?(v=function(){return u?f(jy):_(Ay)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,b,x;t[14]===y?(b=t[15],x=t[16]):(b=()=>{let e=e=>{e.key===Ey&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},x=[y],t[14]=y,t[15]=b,t[16]=x),Z.useEffect(b,x);let S=h?`expanded`:`collapsed`,C;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==S||t[22]!==y?(C={state:S,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=S,t[22]=y,t[23]=C):C=t[23];let w;t[24]===s?w=t[25]:(w={"--sidebar-width":Cy,"--sidebar-width-icon":Ty,...s},t[24]=s,t[25]=w);let T=w,E;t[26]===r?E=t[27]:(E=k(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=E);let D;t[28]!==n||t[29]!==a||t[30]!==T||t[31]!==E?(D=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:T,className:E,...a,children:n}),t[28]=n,t[29]=a,t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==D||t[34]!==C?(O=(0,$.jsx)(Dy.Provider,{value:C,children:D}),t[33]=D,t[34]=C,t[35]=O):O=t[35],O}function Ay(e){return!e}function jy(e){return!e}function My(e){let t=(0,Q.c)(49),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({side:o,variant:s,collapsible:c,className:r,children:n,dir:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{isMobile:f,state:p,openMobile:m,setOpenMobile:h}=Oy();if(d===`none`){let e;t[8]===r?e=t[9]:(e=k(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e||t[13]!==u?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=u,t[14]=i):i=t[14],i}if(f){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":wy},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ym,{className:`sr-only`,children:[(0,$.jsx)(bm,{children:`Sidebar`}),(0,$.jsx)(xm,{children:`Displays the mobile sidebar.`})]}),t[16]=r):r=t[16];let o;t[17]===n?o=t[18]:(o=(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:n}),t[17]=n,t[18]=o);let s;t[19]!==i||t[20]!==l||t[21]!==o?(s=(0,$.jsxs)(vm,{dir:i,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:e,side:l,children:[r,o]}),t[19]=i,t[20]=l,t[21]=o,t[22]=s):s=t[22];let c;return t[23]!==m||t[24]!==a||t[25]!==h||t[26]!==s?(c=(0,$.jsx)(hm,{open:m,onOpenChange:h,...a,children:s}),t[23]=m,t[24]=a,t[25]=h,t[26]=s,t[27]=c):c=t[27],c}let g=p===`collapsed`?d:``,_=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,v;t[28]===_?v=t[29]:(v=k(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,_),t[28]=_,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:v}),t[30]=v,t[31]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[32]!==r||t[33]!==b?(x=k(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,b,r),t[32]=r,t[33]=b,t[34]=x):x=t[34];let S;t[35]===n?S=t[36]:(S=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=S);let C;t[37]!==a||t[38]!==l||t[39]!==S||t[40]!==x?(C=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[37]=a,t[38]=l,t[39]=S,t[40]=x,t[41]=C):C=t[41];let w;return t[42]!==l||t[43]!==p||t[44]!==C||t[45]!==g||t[46]!==y||t[47]!==u?(w=(0,$.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":g,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[y,C]}),t[42]=l,t[43]=p,t[44]=C,t[45]=g,t[46]=y,t[47]=u,t[48]=w):w=t[48],w}function Ny(e){let t=(0,Q.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a}=Oy(),o;t[4]===n?o=t[5]:(o=k(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(gi,{}),l=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,$.jsxs)(q,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:o,onClick:s,...i,children:[c,l]}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function Py(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Fy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Iy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ly(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ry(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var By=Ae(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function Vy(e){let t=(0,Q.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?se:`button`,{isMobile:m,state:h}=Oy(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=k(By({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,$.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,$.jsx)(pt,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,$.jsx)($e,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,$.jsxs)(ot,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Hy(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?se:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=k(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,$.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Uy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-sub-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Gy(e){let t=(0,Q.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?se:`a`,d;t[6]===n?d=t[7]:(d=k(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,$.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Ky(e){let t=(0,Q.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Claude icon`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`g`,{clipPath:`url(#clip0_claude)`,children:(0,$.jsx)(`path`,{d:`M4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.36 12.72L1.08 12.6L0.504 12.48L0 11.76L0.048 11.4L0.528 11.088L1.224 11.136L2.736 11.256L5.016 11.4L6.672 11.496L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.696L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.408 6.768L8.88 8.64L9.24 8.928L9.384 8.832L9.408 8.76L9.24 8.496L7.92 6L6.48 3.504L5.832 2.472L5.664 1.848C5.592 1.608 5.568 1.368 5.568 1.128L6.288 0.12L6.72 0L7.728 0.144L8.112 0.48L8.736 1.92L9.72 4.152L11.28 7.176L11.76 8.088L12 8.904L12.072 9.144H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.84L14.016 0.36L14.64 0.624L15.12 1.32L15.048 1.752L14.784 3.6L14.16 6.504L13.8 8.472H14.016L14.256 8.208L15.24 6.912L16.896 4.848L17.616 4.008L18.48 3.12L19.032 2.688H20.064L20.808 3.816L20.472 4.992L19.416 6.336L18.528 7.464L17.256 9.168L16.488 10.536L16.56 10.632H16.728L19.608 10.008L21.144 9.744L22.968 9.432L23.808 9.816L23.904 10.2L23.568 11.016L21.6 11.496L19.296 11.976L15.864 12.768L15.816 12.792L15.864 12.864L17.4 13.008L18.072 13.056H19.704L22.728 13.296L23.52 13.776L23.976 14.424L23.904 14.904L22.68 15.528L21.048 15.144L17.208 14.232L15.912 13.92H15.72V14.016L16.824 15.096L18.816 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.832L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.2L17.184 22.056L15.792 20.136L14.352 17.976L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24L10.776 23.52L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336V15.288H11.76L10.32 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.76 20.64L8.16 17.568L9.6 15.672L10.56 14.568L10.536 14.448H10.464L4.128 18.576L3 18.72L2.52 18.24L2.568 17.52L2.808 17.28L4.728 15.96H4.704Z`,fill:`currentColor`})}),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsx)(`clipPath`,{id:`clip0_claude`,children:(0,$.jsx)(`rect`,{width:`24`,height:`24`,fill:`white`})})}),t[2]=i):i=t[2];let a;return t[3]===e?a=t[4]:(a=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Claude icon`,fill:`none`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r,i]}),t[3]=e,t[4]=a),a}function qy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Cline icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M463.6,275.08l-29.26-58.75v-33.83c0-56.08-45.01-101.5-100.53-101.5h-50.01c3.62-7.43,5.61-15.79,5.61-24.61,0-31.17-25.08-56.39-56.07-56.39s-56.07,25.22-56.07,56.39c0,8.82,1.99,17.17,5.61,24.61h-50.01c-55.51,0-100.52,45.42-100.52,101.5v33.83l-29.87,58.59c-3.01,5.9-3.01,12.92,0,18.81l29.87,57.93v33.83c0,56.08,45.01,101.5,100.52,101.5h200.95c55.51,0,100.53-45.42,100.53-101.5v-33.83l29.21-58.13c2.9-5.79,2.9-12.61.05-18.46ZM202.75,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02ZM350.58,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Cline icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 466.73 487.04`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Jy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Codex icon`}),r=(0,$.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`2.484`,d:`M22.356 19.797H17.17M9.662 12.29l1.979 3.576a.511.511 0 0 1-.005.504l-1.974 3.409M30.758 16c0 8.15-6.607 14.758-14.758 14.758-8.15 0-14.758-6.607-14.758-14.758C1.242 7.85 7.85 1.242 16 1.242c8.15 0 14.758 6.608 14.758 14.758Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Codex icon`,xmlns:`http://www.w3.org/2000/svg`,width:32,height:32,fill:`none`,viewBox:`0 0 32 32`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Yy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`GitHub Copilot icon`}),r=(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,fill:`currentColor`,d:`M9.6225 2.682C10.2835 3.362 10.561 4.29 10.6775 5.5905C10.9885 5.5905 11.2775 5.658 11.4735 5.9175L11.8385 6.3995C11.9435 6.5385 12 6.7045 12 6.877V8.187C12 8.3565 11.9135 8.5215 11.7735 8.621C10.1195 9.801 8.0785 10.75 6 10.75C3.7 10.75 1.3975 9.4585 0.2265 8.621C0.0865 8.521 0.0005 8.356 0 8.187V6.877C0 6.7045 0.0565 6.5375 0.1605 6.399L0.5255 5.9175C0.7215 5.659 1.0125 5.5905 1.322 5.5905L1.3365 5.442C1.4615 4.219 1.7415 3.3355 2.3775 2.682C3.608 1.412 5.2325 1.2565 5.9505 1.25H6.0495C6.7675 1.2565 8.392 1.4115 9.6225 2.682ZM6.0005 4.846C5.8585 4.846 5.694 4.854 5.5195 4.871C5.458 5.0945 5.367 5.296 5.2345 5.425C4.7095 5.9365 4.0765 6.015 3.7375 6.015C3.4185 6.015 3.0845 5.95 2.812 5.783C2.554 5.8655 2.306 5.9845 2.29 6.281C2.26898 6.76138 2.25847 7.24216 2.2585 7.723L2.2575 7.963C2.2565 8.2445 2.255 8.526 2.251 8.808C2.252 8.971 2.353 9.123 2.506 9.1905C3.747 9.7415 4.921 10.019 6.001 10.019C7.079 10.019 8.253 9.7415 9.4935 9.1905C9.56814 9.15767 9.63181 9.10416 9.677 9.03628C9.72219 8.96841 9.747 8.88902 9.7485 8.8075C9.7635 7.9665 9.7515 7.1215 9.7105 6.281C9.695 5.983 9.4465 5.866 9.1875 5.783C8.9145 5.9495 8.5815 6.015 8.2625 6.015C7.924 6.015 7.2915 5.9365 6.766 5.425C6.633 5.296 6.5425 5.0945 6.481 4.871C6.321 4.855 6.1605 4.8465 6.0005 4.846ZM4.738 6.8525C5.0075 6.8525 5.226 7.0655 5.226 7.3275V8.204C5.226 8.4665 5.0075 8.679 4.738 8.679C4.61033 8.6806 4.48725 8.63149 4.39576 8.54243C4.30426 8.45338 4.25184 8.33166 4.25 8.204V7.328C4.25 7.0655 4.4685 6.8525 4.738 6.8525ZM7.238 6.8525C7.5075 6.8525 7.726 7.0655 7.726 7.3275V8.204C7.726 8.4665 7.5075 8.679 7.238 8.679C7.11033 8.6806 6.98725 8.63149 6.89576 8.54243C6.80426 8.45338 6.75184 8.33166 6.75 8.204V7.328C6.75 7.0655 6.9685 6.8525 7.238 6.8525ZM3.8175 2.5435C3.2925 2.5945 2.85 2.7625 2.625 2.9965C2.1375 3.515 2.2425 4.8305 2.52 5.1085C2.7225 5.3055 3.105 5.437 3.5175 5.437H3.5625C3.887 5.4305 4.455 5.349 4.9275 4.882C5.145 4.677 5.28 4.1655 5.265 3.647C5.25 3.23 5.13 2.887 4.95 2.7405C4.755 2.5725 4.3125 2.4995 3.8175 2.5435ZM7.05 2.7405C6.87 2.8865 6.75 3.2305 6.735 3.647C6.72 4.1655 6.855 4.677 7.0725 4.882C7.5565 5.3605 8.1405 5.434 8.4605 5.437H8.4825C8.895 5.437 9.2775 5.3055 9.48 5.1085C9.7575 4.8305 9.8625 3.515 9.375 2.9965C9.15 2.7625 8.7075 2.5945 8.1825 2.5435C7.6875 2.4995 7.245 2.5725 7.05 2.7405ZM6 3.8075C5.88 3.8075 5.7375 3.815 5.58 3.8295C5.595 3.9095 5.6025 3.9975 5.61 4.0925L5.6095 4.172C5.60894 4.21375 5.60661 4.25545 5.6025 4.297C5.715 4.286 5.815 4.2835 5.9085 4.283H6.0915C6.185 4.283 6.285 4.286 6.3975 4.297C6.39 4.224 6.39 4.1585 6.39 4.0925C6.3975 3.9975 6.405 3.91 6.42 3.8295C6.2804 3.81583 6.14026 3.80849 6 3.8075Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`GitHub Copilot icon`,xmlns:`http://www.w3.org/2000/svg`,width:12,height:12,viewBox:`0 0 12 12`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Xy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Cursor icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Cursor icon`,fill:`none`,height:24,width:24,viewBox:`0 0 466.73 532.09`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Zy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Windsurf icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M21.3192 4.9697H21.1203C20.0734 4.96806 19.2238 5.81589 19.2238 6.86264V11.0961C19.2238 11.9415 18.525 12.6263 17.6934 12.6263C17.1993 12.6263 16.706 12.3777 16.4133 11.9603L12.0896 5.78492C11.7308 5.27214 11.1471 4.96643 10.5152 4.96643C9.52943 4.96643 8.64234 5.80448 8.64234 6.83902V11.0969C8.64234 11.9423 7.94932 12.6271 7.11197 12.6271C6.61625 12.6271 6.12376 12.3785 5.83105 11.9611L0.992853 5.0504C0.883594 4.89387 0.638184 4.97133 0.638184 5.1621V8.85424C0.638184 9.04094 0.695264 9.22193 0.802059 9.37517L5.56362 16.175C5.84492 16.5769 6.25994 16.8753 6.73852 16.9837C7.93627 17.256 9.03861 16.334 9.03861 15.1592V10.9037C9.03861 10.0583 9.7235 9.37354 10.569 9.37354H10.5714C11.081 9.37354 11.5588 9.62219 11.8515 10.0396L16.1761 16.2141C16.5356 16.7277 17.0892 17.0326 17.7497 17.0326C18.7574 17.0326 19.6209 16.1937 19.6209 15.16V10.9029C19.6209 10.0575 20.3058 9.37273 21.1512 9.37273H21.32C21.426 9.37273 21.5116 9.28713 21.5116 9.18116V5.16127C21.5116 5.05531 21.426 4.9697 21.32 4.9697H21.3192Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Windsurf icon`,xmlns:`http://www.w3.org/2000/svg`,width:22,height:22,viewBox:`0 0 22 22`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Qy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Jc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function $y(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Yc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function eb(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=k(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,$.jsx)(Xc,{children:(0,$.jsx)(Zc,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function tb(e){return typeof e==`object`&&!!e&&typeof e.getStates==`function`}function nb(e,t,n){let r=[],i=[];for(let a of e.getStates().values()){let e=a.agentPresence;if(e)for(let[a,o]of Object.entries(e))o.currentDoc&&(n-o.ts>=5e3||(o.currentDoc===t?r.push({agentId:a,entry:o}):i.push({agentId:a,entry:o})))}return{current:r,crossDoc:i}}function rb(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentPresence;if(e)for(let r of Object.values(e))r.currentDoc&&(t-r.ts>=5e3||n.push(r))}return n.length===0?null:(n.sort((e,t)=>t.ts-e.ts),n[0].currentDoc)}var ib=1e3,ab=!1;function ob(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function sb(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:tb(i)?a=i:(a=void 0,ab||(ab=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`})}let{current:t,crossDoc:i}=a?nb(a,n,Date.now()):{current:[],crossDoc:[]},s=cb,c=t.map(s),l=i.map(s),u=[...e,...c],d=l;o(e=>ob(e.current,u)&&ob(e.crossDoc,d)?e:{current:u,crossDoc:d})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,ib);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function cb(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function lb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?ub:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Z.useEffect)(i,a),n}function ub(e){return e===`synced`?`synced`:`connected`}var db=`sync-status`;function fb(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:db,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:db,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}function pb(e){window.location.hash=me(e)}var mb=4,hb=3,gb={Bird:Ar,Cat:Pr,Dog:Yr,Fish:Qr,Mouse:wi,Rabbit:Ci,Shrimp:Ai,Snail:ji,Squirrel:Fi,Turtle:Bi},_b={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function vb(e){let t=(0,Q.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,$.jsx)(Ky,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Xy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Zy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(Jy,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(qy,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Yy,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(Mi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function yb(e){let t=(0,Q.c)(20),{user:n,mode:r}=e,i=n.name.split(` `)[1],a=i?gb[i]:void 0,o;t[0]===n.name?o=t[1]:(o=n.name.split(` `).map(bb).join(``),t[0]=n.name,t[1]=o);let s=o,c;t[2]===n.color?c=t[3]:(c=A(n.color),t[2]=n.color,t[3]=c);let l=c,u;t[4]===n.color?u=t[5]:(u={backgroundColor:n.color},t[4]=n.color,t[5]=u);let d;t[6]!==a||t[7]!==l||t[8]!==s?(d=a?(0,$.jsx)(a,{size:18,color:l,strokeWidth:1.5}):(0,$.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:l},children:s}),t[6]=a,t[7]=l,t[8]=s,t[9]=d):d=t[9];let f;t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==n.name?(f=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":n.name,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:u,children:d})}),t[10]=r,t[11]=u,t[12]=d,t[13]=n.name,t[14]=f):f=t[14];let p;t[15]===n.name?p=t[16]:(p=(0,$.jsx)($e,{children:n.name}),t[15]=n.name,t[16]=p);let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(ot,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function bb(e){return e[0]}function xb(e){let t=_b[e.icon];return e.displayName||t||`Agent`}function Sb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function Cb(e){let t=(0,Q.c)(30),{participant:n,crossDoc:r,onNavigate:i}=e,{presence:a}=n,o;t[0]===a?o=t[1]:(o=xb(a),t[0]=a,t[1]=o);let s=o,c=r&&a.currentDoc!==null,l=Sb(a.mode),u=!c&&!r&&l,d=c?`cursor-pointer`:`cursor-default`,f=u?`ring-primary/40 animate-pulse`:``,p;t[2]!==d||t[3]!==f?(p=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 ring-background`,d,f].filter(Boolean),t[2]=d,t[3]=f,t[4]=p):p=t[4];let m=p.join(` `),h=r?`true`:void 0,g;t[5]!==a.mode||t[6]!==h?(g={"data-presence-badge":`agent`,"data-presence-mode":a.mode,"data-presence-crossdoc":h},t[5]=a.mode,t[6]=h,t[7]=g):g=t[7];let _=g,v;t[8]!==_||t[9]!==c||t[10]!==i||t[11]!==a.color||t[12]!==a.currentDoc||t[13]!==a.icon||t[14]!==m||t[15]!==s?(v=c?(0,$.jsx)(`button`,{type:`button`,..._,"aria-label":`${s}, editing ${a.currentDoc}`,className:m,style:{backgroundColor:a.color},onClick:()=>{a.currentDoc&&i(a.currentDoc)},children:(0,$.jsx)(vb,{icon:a.icon,width:16,height:16,className:`text-white`})}):(0,$.jsx)(`div`,{..._,role:`img`,"aria-label":s,className:m,style:{backgroundColor:a.color},children:(0,$.jsx)(vb,{icon:a.icon,width:16,height:16,className:`text-white`})}),t[8]=_,t[9]=c,t[10]=i,t[11]=a.color,t[12]=a.currentDoc,t[13]=a.icon,t[14]=m,t[15]=s,t[16]=v):v=t[16];let y=v,b;t[17]===y?b=t[18]:(b=(0,$.jsx)(pt,{asChild:!0,children:y}),t[17]=y,t[18]=b);let x;t[19]===s?x=t[20]:(x=(0,$.jsx)(`span`,{className:`font-medium`,children:s}),t[19]=s,t[20]=x);let S;t[21]!==r||t[22]!==a.currentDoc?(S=r&&a.currentDoc?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,a.currentDoc,`]]`]}):null,t[21]=r,t[22]=a.currentDoc,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==x?(C=(0,$.jsxs)($e,{className:`flex flex-col gap-0.5`,children:[x,S]}),t[24]=S,t[25]=x,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==b?(w=(0,$.jsxs)(ot,{children:[b,C]}),t[27]=C,t[28]=b,t[29]=w):w=t[29],w}function wb(e){let t=(0,Q.c)(16),{count:n,remainder:r,crossDoc:i,onNavigate:a}=e,o=i?`true`:void 0,s=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,c;t[0]!==n||t[1]!==o||t[2]!==s?(c=(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":o,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":s,children:[`+`,n]})}),t[0]=n,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l;if(t[4]!==i||t[5]!==a||t[6]!==r){let e;t[8]!==i||t[9]!==a?(e=e=>e.kind===`human`?(0,$.jsx)(yb,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(Cb,{participant:e,crossDoc:i,onNavigate:a},e.agentId),t[8]=i,t[9]=a,t[10]=e):e=t[10],l=r.map(e),t[4]=i,t[5]=a,t[6]=r,t[7]=l}else l=t[7];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(eb,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:l})}),t[11]=l,t[12]=u);let d;return t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(Qy,{children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],d}function Tb(e,t,n){return e.kind===`human`?(0,$.jsx)(yb,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(Cb,{participant:e,crossDoc:n,onNavigate:t},e.agentId)}function Eb(){let e=(0,Q.c)(12),{activeProvider:t,activeDocName:n,systemProvider:r}=Hn(),{current:i,crossDoc:a}=sb(t,r,n);fb(lb(t),n);let o;if(e[0]!==a||e[1]!==i){let t=i.slice(0,mb),n;e[3]===i?n=e[4]:(n=i.slice(mb),e[3]=i,e[4]=n);let r=n,s=a.slice(0,hb),c;e[5]===a?c=e[6]:(c=a.slice(hb),e[5]=a,e[6]=c);let l=c,u=t.map(Ob),d;e[7]===r?d=e[8]:(d=r.length>0?(0,$.jsx)(wb,{count:r.length,remainder:r,crossDoc:!1,onNavigate:pb}):null,e[7]=r,e[8]=d);let f;e[9]!==u||e[10]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[u,d]}),e[9]=u,e[10]=d,e[11]=f):f=e[11],o=(0,$.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[f,a.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[s.map(Db),l.length>0?(0,$.jsx)(wb,{count:l.length,remainder:l,crossDoc:!0,onNavigate:pb}):null]})]}):null]}),e[0]=a,e[1]=i,e[2]=o}else o=e[2];return o}function Db(e){return Tb(e,pb,!0)}function Ob(e){return Tb(e,pb,!1)}function kb(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`LinkedIn`}),r=(0,$.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Ab(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`X (Twitter)`}),r=(0,$.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var jb=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Mr},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:vt},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:Ab},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:kb}],Mb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Rr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)($e,{children:`Help & resources`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:`Need help?`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(Qy,{children:[t,(0,$.jsxs)(eb,{align:`end`,className:`w-56 p-3`,children:[n,(0,$.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:jb.map(Nb)})})]})]}),e[2]=r):r=e[2],r};function Nb(e){let{label:t,href:n,icon:r}=e;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,$.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var Pb=`https://github.com/inkeep/open-knowledge/releases`;function Fb(e){let{target:t,installState:n,isElectronHost:r}=e;return t.id===`cursor`&&!r?`Desktop only`:n.installed===null?`Detecting…`:n.installed===!1?`Not installed`:null}function Ib(e){let{target:t,installState:n,isElectronHost:r}=e;if(t.id===`cursor`&&!r)return{enabled:!1,tooltip:{message:`Cursor handoff requires the desktop build.`,installAction:{label:`Install the Open Knowledge desktop app →`,url:Pb}}};if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function Lb(e){return od(e)}function Rb(e){return`Opened ${e} in your browser.`}function zb(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??pd,c=e.onWebFallbackSuccess??Vb,l=e.onWebFallbackError??Bb,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Ib({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=Fb({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(Lb(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r;t[17]===n.displayName?r=t[18]:(r=(0,$.jsxs)(`span`,{children:[`Open in `,n.displayName]}),t[17]=n.displayName,t[18]=r);let i;return t[19]!==o||t[20]!==e||t[21]!==r?(i=(0,$.jsx)(Gg,{onSelect:o,"data-testid":e,children:r}),t[19]=o,t[20]=e,t[21]=r,t[22]=i):i=t[22],i}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[23]===n.displayName?i=t[24]:(i=(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,n.displayName]}),t[23]=n.displayName,t[24]=i);let a;t[25]===p?a=t[26]:(a=p?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[25]=p,t[26]=a);let o;return t[27]!==e||t[28]!==r||t[29]!==i||t[30]!==a?(o=(0,$.jsxs)(Gg,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a]}),t[27]=e,t[28]=r,t[29]=i,t[30]=a,t[31]=o):o=t[31],o}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[32]===n.displayName?b=t[33]:(b=(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,n.displayName]}),t[32]=n.displayName,t[33]=b);let x;t[34]===p?x=t[35]:(x=p?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[34]=p,t[35]=x);let S;t[36]!==v||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,$.jsxs)(Hg,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x]}),t[36]=v,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C=`open-in-agent-submenu-${n.id}`,w=`open-in-agent-message-${n.id}`,T;t[41]!==d.tooltip.message||t[42]!==w?(T=(0,$.jsx)(qg,{className:`font-normal text-muted-foreground text-xs`,"data-testid":w,children:d.tooltip.message}),t[41]=d.tooltip.message,t[42]=w,t[43]=T):T=t[43];let E;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Jg,{}),t[44]=E):E=t[44];let D=`open-in-agent-install-${n.id}`,O;t[45]===d.tooltip.installAction.label?O=t[46]:(O=(0,$.jsx)(`span`,{children:d.tooltip.installAction.label}),t[45]=d.tooltip.installAction.label,t[46]=O);let k;t[47]!==h||t[48]!==D||t[49]!==O?(k=(0,$.jsx)(Gg,{onSelect:h,"data-testid":D,children:O}),t[47]=h,t[48]=D,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==_||t[52]!==d.tooltip.webFallback||t[53]!==n.id?(A=d.tooltip.webFallback?(0,$.jsxs)(Gg,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,$.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[51]=_,t[52]=d.tooltip.webFallback,t[53]=n.id,t[54]=A):A=t[54];let j;t[55]!==T||t[56]!==k||t[57]!==A||t[58]!==C?(j=(0,$.jsxs)(Ug,{className:`min-w-[260px]`,"data-testid":C,children:[T,E,k,A]}),t[55]=T,t[56]=k,t[57]=A,t[58]=C,t[59]=j):j=t[59];let M;return t[60]!==j||t[61]!==S?(M=(0,$.jsxs)(Bg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function Bb(){}function Vb(){}function Hb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Wd(),{dispatch:a}=Nd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=Wb,u=Ub,d;t[0]===i?d=t[1]:(d=e=>{s(e),e&&i()},t[0]=i,t[1]=d);let f=d,p=n===null,m;t[2]===n?m=t[3]:(m=n===null?``:ad(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Xr,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in…`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})}),t[8]=p,t[9]=y);let b;t[10]!==_||t[11]!==h||t[12]!==r?(b=sd.map(e=>{let t=r[e.id];return(0,$.jsx)(zb,{target:e,installState:t,isElectronHost:c,prompt:h,onSelect:()=>_(e),onWebFallbackSuccess:l,onWebFallbackError:u},e.id)}),t[10]=_,t[11]=h,t[12]=r,t[13]=b):b=t[13];let x;t[14]===b?x=t[15]:(x=(0,$.jsx)(Wg,{align:`end`,className:`min-w-[220px]`,"data-testid":`open-in-agent-menu`,children:b}),t[14]=b,t[15]=x);let S;return t[16]!==f||t[17]!==o||t[18]!==y||t[19]!==x?(S=(0,$.jsxs)(Rg,{open:o,onOpenChange:f,children:[y,x]}),t[16]=f,t[17]=o,t[18]=y,t[19]=x,t[20]=S):S=t[20],S}function Ub(e){X.error(`Couldn't open ${e.displayName} in your browser.`)}function Wb(e){X.success(Rb(e.displayName))}var Gb={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},Kb=e=>{let t=(0,Q.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,$.jsx)(`svg`,{"aria-hidden":`true`,...Gb,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},qb=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Markdown`}),r=(0,$.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(Kb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Jb=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Textbox`}),r=(0,$.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(Kb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Yb=(e,t,n)=>qi(e,t,n,`ProjectSwitcher`);function Xb(e){let t=(0,Q.c)(57),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(!1),c;t[1]!==n.project||t[2]!==o?(c=()=>{if(!o)return;let e=!1;return Yb(async()=>{let t=await n.project.listRecent();e||a(t)},`Failed to load recent projects.`),()=>{e=!0}},t[1]=n.project,t[2]=o,t[3]=c):c=t[3];let l;t[4]!==n||t[5]!==o?(l=[o,n],t[4]=n,t[5]=o,t[6]=l):l=t[6],(0,Z.useEffect)(c,l);let u;t[7]===n.project?u=t[8]:(u=e=>{s(!1),Yb(()=>n.project.open({path:e,target:`new-window`}),`Failed to open project.`)},t[7]=n.project,t[8]=u);let d=u,f;t[9]!==n.dialog||t[10]!==n.project?(f=()=>{s(!1),Yb(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`})},`Failed to open folder.`)},t[9]=n.dialog,t[10]=n.project,t[11]=f):f=t[11];let p=f,m=n.config.projectPath,h,g,_,v,y,b,x,S,C,w,T;if(t[12]!==n.config.projectName||t[13]!==m||t[14]!==o||t[15]!==d||t[16]!==i){let e;t[28]===m?e=t[29]:(e=e=>e.path!==m,t[28]=m,t[29]=e);let r=i.filter(e);g=Rg,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),t[30]=a):a=t[30];let c;t[31]===n.config.projectName?c=t[32]:(c=(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:n.config.projectName}),t[31]=n.config.projectName,t[32]=c);let l;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1.5 px-2 text-muted-foreground hover:text-foreground`,"data-testid":`project-switcher-trigger`,title:`Switch project`,children:[a,c,l]})}),t[34]=c,t[35]=x),h=Wg,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(qg,{children:`Switch project`}),_=(0,$.jsx)(Jg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(qg,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(Gg,{disabled:e.missing,onSelect:()=>d(e.path),className:`flex flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,$.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,$.jsxs)(`span`,{className:`max-w-[240px] truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]},e.path)),t[12]=n.config.projectName,t[13]=m,t[14]=o,t[15]=d,t[16]=i,t[17]=h,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S,t[25]=C,t[26]=w,t[27]=T}else h=t[17],g=t[18],_=t[19],v=t[20],y=t[21],b=t[22],x=t[23],S=t[24],C=t[25],w=t[26],T=t[27];let E;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Jg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ei,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(Gg,{onSelect:p,"data-testid":`project-switcher-open-folder`,children:[D,`Open folder…`]}),t[40]=p,t[41]=O);let k;t[42]!==h||t[43]!==_||t[44]!==v||t[45]!==O||t[46]!==S||t[47]!==C||t[48]!==w||t[49]!==T?(k=(0,$.jsxs)(h,{align:S,className:C,"data-testid":w,children:[T,_,v,E,O]}),t[42]=h,t[43]=_,t[44]=v,t[45]=O,t[46]=S,t[47]=C,t[48]=w,t[49]=T,t[50]=k):k=t[50];let A;return t[51]!==g||t[52]!==y||t[53]!==b||t[54]!==x||t[55]!==k?(A=(0,$.jsxs)(g,{open:y,onOpenChange:b,children:[x,k]}),t[51]=g,t[52]=y,t[53]=b,t[54]=x,t[55]=k,t[56]=A):A=t[56],A}function Zb(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=k(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(gl,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,$.jsx)(hl,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function Qb(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function $b(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function ex(e){let t=await fetch(`/api/sync/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})});if(!t.ok)throw Error(`set-enabled failed: HTTP ${t.status}`)}function tx(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zi,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fi,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function nx(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;case`disabled`:return``;default:return``}}function rx(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching…`;case`pulling`:return`Pulling…`;case`pushing`:return`Pushing…`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function ix(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function ax(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:rx(e.state):`Sync off`}function ox(e){let t=(0,Q.c)(72),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,[o,s]=(0,Z.useState)(!1),c=n.syncEnabled,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=async function(e){s(!0);try{await ex(e)}catch(t){console.error(`[sync] toggle failed`,t),X.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,$.jsx)(tx,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=rx(n.state),t[3]=n.state,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[5]=f,t[6]=p);let m;t[7]!==d||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[7]=d,t[8]=p,t[9]=m):m=t[9];let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>void u(e),t[10]=h):h=t[10];let g=c?`Disable sync`:`Enable sync`,_;t[11]!==c||t[12]!==g||t[13]!==o?(_=(0,$.jsx)(Zb,{checked:c,disabled:o,onCheckedChange:h,"aria-label":g}),t[11]=c,t[12]=g,t[13]=o,t[14]=_):_=t[14];let v;t[15]!==m||t[16]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,_]}),t[15]=m,t[16]=_,t[17]=v):v=t[17];let y;t[18]===n.error?y=t[19]:(y=n.error&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[18]=n.error,t[19]=y);let b;t[20]===n.pausedReason?b=t[21]:(b=n.pausedReason&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ix(n.pausedReason)}),t[20]=n.pausedReason,t[21]=b);let x;t[22]===n.state?x=t[23]:(x=n.state===`conflict`&&(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[22]=n.state,t[23]=x);let S;t[24]!==c||t[25]!==n.lastSyncUtc||t[26]!==n.state?(S=c&&n.state!==`dormant`&&(0,$.jsxs)(`div`,{children:[`Last synced: `,Qb(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,$.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,$.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,$.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,$.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,$.jsx)(Ui,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:cx,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:sx,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function sx(){$b(`sync`)}function cx(){$b(`sync`)}function lx(e){let t=(0,Q.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=uf();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(zr,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,$.jsxs)(ot,{children:[e,(0,$.jsx)($e,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=nx(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=rx(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,$.jsx)(tx,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=ax(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)($e,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(ot,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,$.jsx)(eb,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(ox,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,$.jsxs)(Qy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var ux=[{value:`light`,label:`Light`,icon:Li},{value:`dark`,label:`Dark`,icon:pi},{value:`system`,label:`System`,icon:Wr}],dx=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=Ve(),r=t===`system`?Wr:t===`dark`?pi:Li,i;e[0]===r?i=e[1]:(i=(0,$.jsx)(r,{}),e[0]=r,e[1]=i);let a=t??`system`,o;e[2]===a?o=e[3]:(o=(0,$.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,a,`)`]}),e[2]=a,e[3]=o);let s;e[4]!==i||e[5]!==o?(s=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[i,o]})}),e[4]=i,e[5]=o,e[6]=s):s=e[6];let c;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=ux.map(fx),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Wg,{align:`end`,children:(0,$.jsx)(Vg,{value:t,onValueChange:n,children:c})}),e[8]=n,e[9]=t,e[10]=l):l=e[10];let u;return e[11]!==s||e[12]!==l?(u=(0,$.jsxs)(Rg,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function fx(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Kg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function px(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function mx(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(px)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function hx(e){let t=(0,Q.c)(117),{editorMode:n,onModeChange:r,onTimelineToggle:i,onSaveVersion:a,saving:o,previewEntry:s,restoring:c,restoreError:l,onExitPreview:u,onRestore:d,diffLayout:f,onDiffLayoutChange:p,onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g,onOpenClone:_}=e,{activeDocName:v,activeProvider:y,activeTarget:b,closeDocument:x,pinnedDoc:S,pin:C,unpin:w}=Hn(),{state:T}=Oy(),E=cd(),D=lb(y),O;t[0]!==v||t[1]!==E?(O=wd({docName:v,workspace:E}),t[0]=v,t[1]=E,t[2]=O):O=t[2];let k=O,A=!v||!(D===`connected`||D===`synced`),j=b?.kind===`folder`,M=b?.kind===`missing`,N=j?`${b.folderPath}/`:v?`${v}.md`:``,P;t[3]===v?P=t[4]:(P=v?.lastIndexOf(`/`)??-1,t[3]=v,t[4]=P);let F=P,I;t[5]!==v||t[6]!==F?(I=v&&F!==-1?`${v.substring(0,F+1)}`:``,t[5]=v,t[6]=F,t[7]=I):I=t[7];let L=I,R;t[8]!==v||t[9]!==F?(R=v?v.substring(F+1):``,t[8]=v,t[9]=F,t[10]=R):R=t[10];let z=R,B=S!==null,V;t[11]!==v||t[12]!==B||t[13]!==C||t[14]!==w?(V=function(){v&&(B?w():C(v))},t[11]=v,t[12]=B,t[13]=C,t[14]=w,t[15]=V):V=t[15];let H=V,U=n===`diff`,[W,G]=(0,Z.useState)(!1),[K,ee]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{le.current=!0,ue.current=null,de.current=null,ee(!1),ie(null)},t[16]=fe):fe=t[16];let pe;t[17]===v?pe=t[18]:(pe=[v],t[17]=v,t[18]=pe),(0,Z.useEffect)(fe,pe);let he,ge;t[19]===K?(he=t[20],ge=t[21]):(he=()=>{if(K){let e=setTimeout(()=>{let e=se.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},ge=[K],t[19]=K,t[20]=he,t[21]=ge),(0,Z.useEffect)(he,ge);let _e;t[22]!==v||t[23]!==j?(_e=function(){if(!v||j)return;let e=v.split(`/`);le.current=!1,ue.current=v,ne(e[e.length-1]),ie(null),de.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=_e):_e=t[24];let ve=_e,ye;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ye=function(){le.current=!0,ue.current=null,de.current=null,ee(!1),ne(``),ie(null)},t[25]=ye):ye=t[25];let be=ye,xe;t[26]!==x||t[27]!==te?(xe=async function(){if(le.current){le.current=!1;return}if(ce.current)return;let e=ue.current;if(!e){be();return}let t=fy(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){be();return}if(t===de.current)return;if(!py(t)){ie(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=my({kind:`file`,path:e,name:r},t);ce.current=!0,oe(!0),ie(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(le.current){oe(!1),ce.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),ie(`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!n.ok||!mx(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),ie(a?.error||`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!r.ok){ie(r.error||`Failed to rename path`),oe(!1),ce.current=!1,de.current=t;return}let a=r.renamed,o=_y(e,a);for(let e of a)x(e.fromDocName);ze([`files`,`backlinks`,`graph`]),ee(!1),ne(``),oe(!1),ce.current=!1,de.current=null,ue.current=null,o&&o!==e&&(window.location.hash=me(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),ie(`Network error — please try again`),oe(!1),ce.current=!1,de.current=t}},t[26]=x,t[27]=te,t[28]=xe):xe=t[28];let Se=xe,Ce;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{G(!1)},t[29]=Ce):Ce=t[29];let we;t[30]===s?we=t[31]:(we=[s],t[30]=s,t[31]=we),(0,Z.useEffect)(Ce,we);let Te;t[32]===d?Te=t[33]:(Te=function(){G(!1),d()},t[32]=d,t[33]=Te);let J=Te,Ee;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Ny,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Ee):Ee=t[34];let De=T===`expanded`?`Hide Files`:`Show Files`,Oe;t[35]===De?Oe=t[36]:(Oe=(0,$.jsxs)(ot,{children:[Ee,(0,$.jsx)($e,{children:De})]}),t[35]=De,t[36]=Oe);let ke,Ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ke=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(Xb,{bridge:window.okDesktop})]}):null,Ae=(0,$.jsx)(gv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=ke,t[38]=Ae):(ke=t[37],Ae=t[38]);let je;t[39]!==v||t[40]!==Se||t[41]!==N||t[42]!==ve||t[43]!==z||t[44]!==j||t[45]!==ae||t[46]!==K||t[47]!==L||t[48]!==re||t[49]!==te?(je=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:N})]}):v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[L&&(0,$.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:K?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,$.jsx)(`span`,{className:`truncate`,children:L.slice(0,-1)}),(0,$.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),K?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Mt,{ref:se,value:te,disabled:ae,"aria-label":`Rename ${v}`,"aria-invalid":re?!0:void 0,"aria-describedby":re?`editor-header-rename-error`:void 0,"aria-busy":ae||void 0,onChange:e=>{ne(e.target.value),ie(null),de.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Se()):e.key===`Escape`&&(e.preventDefault(),be())},onBlur:()=>void Se(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:`.md`})]}),re&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:re})]}):(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ve,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:[z,`.md`]})]}):(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:N}),t[39]=v,t[40]=Se,t[41]=N,t[42]=ve,t[43]=z,t[44]=j,t[45]=ae,t[46]=K,t[47]=L,t[48]=re,t[49]=te,t[50]=je):je=t[50];let Me;t[51]!==v||t[52]!==B||t[53]!==H?(Me=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:H,"aria-label":B?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":B,"data-pinned":B?`true`:`false`,children:B?(0,$.jsx)(xi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(bi,{className:`size-4`})})}),(0,$.jsx)($e,{children:B?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[51]=v,t[52]=B,t[53]=H,t[54]=Me):Me=t[54];let Y;t[55]===M?Y=t[56]:(Y=M&&(0,$.jsx)(vl,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=Y);let Ne;t[57]!==Oe||t[58]!==je||t[59]!==Me||t[60]!==Y?(Ne=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Oe,ke,Ae,je,Me,Y]}),t[57]=Oe,t[58]=je,t[59]=Me,t[60]=Y,t[61]=Ne):Ne=t[61];let Pe;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Pe=!U&&v&&(0,$.jsxs)(mt,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!v,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(Jb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(lt,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(qb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)($e,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)($e,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Pe):Pe=t[67];let Fe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Fe=U&&s&&!W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[l&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,$.jsxs)(mt,{type:`single`,value:f,onValueChange:e=>{e&&p(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Di,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Hr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ei,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(jt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Exit preview`})]})]}),t[68]=W,t[69]=f,t[70]=U,t[71]=p,t[72]=u,t[73]=s,t[74]=l,t[75]=Fe):Fe=t[75];let Ie;t[76]!==W||t[77]!==J||t[78]!==U||t[79]!==s||t[80]!==c?(Ie=U&&s&&W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Replace current content with this version?`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(q,{variant:`default`,size:`xs`,onClick:J,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=J,t[78]=U,t[79]=s,t[80]=c,t[81]=Ie):Ie=t[81];let Le;t[82]!==U||t[83]!==_?(Le=!U&&_&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(ni,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Le):Le=t[84];let Re;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Re=!U&&v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Oi,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Re):Re=t[89];let Be;t[90]!==v||t[91]!==i?(Be=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(ai,{className:`size-4`})})}),(0,$.jsx)($e,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Be):Be=t[92];let Ve;t[93]!==v||t[94]!==k||t[95]!==U?(Ve=!U&&v&&(0,$.jsx)(Hb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=Ve):Ve=t[96];let He;t[97]!==g||t[98]!==h||t[99]!==m?(He=(0,$.jsx)(lx,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=He):He=t[100];let Ue,We,Ge,Ke;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(Eb,{}),We=(0,$.jsx)(gv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ge=(0,$.jsx)(Mb,{}),Ke=(0,$.jsx)(dx,{}),t[101]=Ue,t[102]=We,t[103]=Ge,t[104]=Ke):(Ue=t[101],We=t[102],Ge=t[103],Ke=t[104]);let qe;t[105]!==Le||t[106]!==Re||t[107]!==Be||t[108]!==Ve||t[109]!==He?(qe=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Le,Re,Be,Ve,He,Ue,We,Ge,Ke]}),t[105]=Le,t[106]=Re,t[107]=Be,t[108]=Ve,t[109]=He,t[110]=qe):qe=t[110];let Je;return t[111]!==Ne||t[112]!==Pe||t[113]!==Fe||t[114]!==Ie||t[115]!==qe?(Je=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Ne,Pe,Fe,Ie,qe]}),t[111]=Ne,t[112]=Pe,t[113]=Fe,t[114]=Ie,t[115]=qe,t[116]=Je):Je=t[116],Je}function gx(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function _x(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function vx(e){if(e.contributors.length>0){let t=e.contributors[0],n=t.colorSeed??t.name;return{hex:ie[Ue(n)]??Ge(n)}}return e.type===`upstream`?{className:`bg-muted-foreground/50`}:(e.authorEmail.includes(`openknowledge.local`)||e.type===`wip`)&&(e.authorEmail.includes(`agent`)||e.author.includes(`agent`)||e.authorEmail.includes(`cursor`)||e.authorEmail.includes(`claude`))?{className:`bg-[--color-agent]`}:{className:`bg-[--color-azure-blue]`}}function yx(e){let t=vx(e);return(0,$.jsx)(`span`,{"aria-hidden":`true`,style:t.hex?{backgroundColor:t.hex}:void 0,className:`inline-block size-2 rounded-full shrink-0 ${t.className??``}`})}function bx(e){let t=(0,Q.c)(15),{entries:n,defaultExpanded:r,selectedSha:i,onSelect:a}=e,[o,s]=(0,Z.useState)(r);if(n.length===0)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>s(xx),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ir,{className:`size-3`}):(0,$.jsx)(Lr,{className:`size-3`}),t[1]=o,t[2]=l);let u=o?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,d;t[3]!==o||t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex items-center gap-1 px-4 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors text-left`,onClick:c,children:[l,u]}),t[3]=o,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==n||t[8]!==o||t[9]!==a||t[10]!==i?(f=o&&n.map(e=>(0,$.jsx)(Tx,{entry:e,selected:e.sha===i,onSelect:a},e.sha)),t[7]=n,t[8]=o,t[9]=a,t[10]=i,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}function xx(e){return!e}function Sx(e){return e.checkpoint?e.checkpoint.kind:`save`}function Cx(e){let t=Sx(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${wx(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function wx(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function Tx(e){let t=(0,Q.c)(48),{entry:n,selected:r,onSelect:i,prominent:a}=e,o=a===void 0?!1:a,s;t[0]===n.timestamp?s=t[1]:(s=gx(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=_x(n),t[2]=n,t[3]=l);let u=l,d,f,p,m,h,g,_,v;if(t[4]!==u||t[5]!==n||t[6]!==i||t[7]!==o||t[8]!==r){let e=n.contributors.flatMap(Ex);_=`button`;let a=r?`bg-muted`:`hover:bg-muted/40`,s=o?`border-b border-border/50`:``,c;t[17]!==a||t[18]!==s?(c=[`group flex w-full items-start gap-2.5 px-4 py-2.5 text-left transition-colors`,a,s].filter(Boolean),t[17]=a,t[18]=s,t[19]=c):c=t[19],v=c.join(` `),t[20]!==n||t[21]!==i?(d=()=>i?.(n),t[20]=n,t[21]=i,t[22]=d):d=t[22],t[23]!==n||t[24]!==o?(f=o?(()=>{let e=Sx(n);return e===`bridge-merge-loss`?(0,$.jsx)(zi,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,$.jsx)(Zr,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(Jr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})})():(0,$.jsx)(`div`,{className:`mt-1.5 flex shrink-0 items-center`,children:yx(n)}),t[23]=n,t[24]=o,t[25]=f):f=t[25],p=`min-w-0 flex-1`,t[26]!==u||t[27]!==n||t[28]!==o?(m=o&&(0,$.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:Cx(n)}),yx(n),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:u})]}),t[26]=u,t[27]=n,t[28]=o,t[29]=m):m=t[29],t[30]!==u||t[31]!==o?(h=!o&&(0,$.jsx)(`p`,{className:`truncate text-xs text-foreground`,children:u}),t[30]=u,t[31]=o,t[32]=h):h=t[32],g=e.length>0?(0,$.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e.join(`, `),children:e.join(`, `)}):(0,$.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),t[4]=u,t[5]=n,t[6]=i,t[7]=o,t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v}else d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16];let y;t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(y=(0,$.jsxs)(`div`,{className:p,children:[m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=y):y=t[37];let b;t[38]!==n.timestamp||t[39]!==c?(b=(0,$.jsx)(`time`,{className:`shrink-0 text-xs text-muted-foreground`,dateTime:n.timestamp,title:n.timestamp,children:c}),t[38]=n.timestamp,t[39]=c,t[40]=b):b=t[40];let x;return t[41]!==d||t[42]!==f||t[43]!==y||t[44]!==b||t[45]!==_||t[46]!==v?(x=(0,$.jsxs)(`button`,{type:_,className:v,onClick:d,children:[f,y,b]}),t[41]=d,t[42]=f,t[43]=y,t[44]=b,t[45]=_,t[46]=v,t[47]=x):x=t[47],x}function Ex(e){return e.docs}function Dx(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,docName:i,onEntrySelect:a,selectedSha:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),h,g;t[1]!==i||t[2]!==n?(h=()=>{if(!n){m.current&&clearInterval(m.current);return}let e=async function(){if(i)try{let e=await fetch(`/api/history?docName=${encodeURIComponent(i)}&limit=100`);if(!e.ok){p(`History unavailable`);return}l((await e.json()).entries??[]),p(null)}catch(e){let t=e;p(`History unavailable`),console.error(`[timeline]`,t)}};return d(!0),e().finally(()=>d(!1)),m.current=setInterval(e,1e4),()=>{m.current&&clearInterval(m.current)}},g=[n,i],t[1]=i,t[2]=n,t[3]=h,t[4]=g):(h=t[3],g=t[4]),(0,Z.useEffect)(h,g);let _,v;if(t[5]!==c){_=[];let e=[],n=!1;for(let t of c)t.type===`checkpoint`?(e.length>0&&(_.push({kind:`wip-group`,entries:e,isPreCheckpoint:!n}),e=[]),_.push({kind:`checkpoint`,entry:t}),n=!0):e.push(t);if(e.length>0){let r=!n,i;t[8]!==e||t[9]!==r?(i={kind:`wip-group`,entries:e,isPreCheckpoint:r},t[8]=e,t[9]=r,t[10]=i):i=t[10],_.push(i)}v=c.some(kx),t[5]=c,t[6]=_,t[7]=v}else _=t[6],v=t[7];let y=!v,b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(bm,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),className:`text-xs text-muted-foreground`,children:`Now`}),t[12]=a,t[13]=o,t[14]=x):x=t[14];let S;t[15]===x?S=t[16]:(S=(0,$.jsx)(ym,{className:`border-b px-4 py-3 pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between pr-10`,children:[b,x]})}),t[15]=x,t[16]=S);let C;t[17]===u?C=t[18]:(C=u&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3,4].map(Ox)}),t[17]=u,t[18]=C);let w;t[19]!==f||t[20]!==u?(w=!u&&f&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[19]=f,t[20]=u,t[21]=w):w=t[21];let T;t[22]!==c.length||t[23]!==f||t[24]!==u?(T=!u&&!f&&c.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[22]=c.length,t[23]=f,t[24]=u,t[25]=T):T=t[25];let E;t[26]!==c||t[27]!==f||t[28]!==y||t[29]!==u||t[30]!==a||t[31]!==o?(E=!u&&!f&&y&&c.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col`,children:c.map(e=>(0,$.jsx)(Tx,{entry:e,selected:e.sha===o,onSelect:a},e.sha))}),t[26]=c,t[27]=f,t[28]=y,t[29]=u,t[30]=a,t[31]=o,t[32]=E):E=t[32];let D;t[33]!==f||t[34]!==_||t[35]!==y||t[36]!==u||t[37]!==a||t[38]!==o?(D=!u&&!f&&!y&&(0,$.jsx)(`div`,{className:`flex flex-col`,children:_.map((e,t)=>e.kind===`checkpoint`?(0,$.jsx)(Tx,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(bx,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,selectedSha:o,onSelect:a},e.entries[0]?.sha??`wip-${t}`))}),t[33]=f,t[34]=_,t[35]=y,t[36]=u,t[37]=a,t[38]=o,t[39]=D):D=t[39];let O;t[40]!==T||t[41]!==E||t[42]!==D||t[43]!==C||t[44]!==w?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[C,w,T,E,D]}),t[40]=T,t[41]=E,t[42]=D,t[43]=C,t[44]=w,t[45]=O):O=t[45];let k;t[46]!==a||t[47]!==o?(k=o&&(0,$.jsxs)(`div`,{className:`border-t p-3 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground `,children:`Viewing historical version`}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ei,{className:`size-3`}),`Exit`]})]}),t[46]=a,t[47]=o,t[48]=k):k=t[48];let A;t[49]!==O||t[50]!==k||t[51]!==S?(A=(0,$.jsxs)(vm,{side:`right`,className:`w-[350px] p-0 flex flex-col overflow-hidden sm:max-w-[350px]`,showCloseButton:!0,children:[S,O,k]}),t[49]=O,t[50]=k,t[51]=S,t[52]=A):A=t[52];let j;return t[53]!==r||t[54]!==n||t[55]!==A?(j=(0,$.jsx)(hm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function Ox(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(yf,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(yf,{className:`h-3 w-24`}),(0,$.jsx)(yf,{className:`h-3 w-40`})]}),(0,$.jsx)(yf,{className:`h-3 w-14`})]},e)}function kx(e){return e.type===`checkpoint`}function Ax(){let e=(0,Q.c)(73),[t,n]=sf(),[r,i]=(0,Z.useState)(t),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`auth`),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(`unified`),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),D=(0,Z.useRef)(null),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(`wysiwyg`),A=lf(),j,M;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>()=>{D.current&&clearTimeout(D.current)},M=[],e[0]=j,e[1]=M):(j=e[0],M=e[1]),(0,Z.useEffect)(j,M);let{activeDocName:N,activeTarget:P}=Hn(),F;e[2]===r?F=e[3]:(F=function(e){e.sha?(r!==`diff`&&(k.current=r),v(e),i(`diff`)):(v(null),i(k.current)),w(null)},e[2]=r,e[3]=F);let I=F,L;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(){v(null),i(k.current),w(null)},e[4]=L):L=e[4];let R=L,z;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(){R(),X.info(`No changes since this version`)},e[5]=z):z=e[5];let B=z,V,H;e[6]===N?(V=e[7],H=e[8]):(V=()=>{let e=function(e){let t=e.detail;t&&N&&Un(N,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Bt,e),()=>window.removeEventListener(Bt,e)},H=[N],e[6]=N,e[7]=V,e[8]=H),(0,Z.useEffect)(V,H);let U;e[9]!==P?.kind||e[10]!==r?(U=()=>{P?.kind===`folder`&&(v(null),o(!1),r===`diff`&&i(k.current))},e[9]=P?.kind,e[10]=r,e[11]=U):U=e[11];let W;e[12]!==P||e[13]!==r?(W=[P,r],e[12]=P,e[13]=r,e[14]=W):W=e[14],(0,Z.useEffect)(U,W);let G;e[15]===A?G=e[16]:(G=()=>{!O.current&&A?.state===`dormant`&&A.hasRemote&&(O.current=!0,X.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>u(!0)}}))},e[15]=A,e[16]=G);let K=A?.state,ee=A?.hasRemote,te;e[17]!==K||e[18]!==ee?(te=[K,ee],e[17]=K,e[18]=ee,e[19]=te):te=e[19],(0,Z.useEffect)(G,te);let ne;e[20]===n?ne=e[21]:(ne=function(e){i(e),n(e)},e[20]=n,e[21]=ne);let re=ne,ie;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(ie=async function(){E(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}E(!1)},e[22]=ie):ie=e[22];let ae=ie,oe;e[23]!==N||e[24]!==_?(oe=async function(){if(!(!_?.sha||!N)){S(!0);try{(await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:N,commitSha:_.sha})})).ok?(v(null),i(k.current),w(null)):(w(`Restore failed — document unchanged`),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>w(null),4e3))}catch{w(`Restore failed — document unchanged`),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>w(null),4e3)}S(!1)}},e[23]=N,e[24]=_,e[25]=oe):oe=e[25];let se=oe,q;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(wf,{onOpenResolver:()=>c(!0)}),e[26]=q):q=e[26];let ce;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>o(jx),e[27]=ce):ce=e[27];let le,ue,de,fe;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{f(`auth`),u(!0)},ue=()=>{f(`identity`),u(!0)},de=()=>c(!0),fe=()=>m(!0),e[28]=le,e[29]=ue,e[30]=de,e[31]=fe):(le=e[28],ue=e[29],de=e[30],fe=e[31]);let pe;e[32]!==y||e[33]!==r||e[34]!==re||e[35]!==se||e[36]!==_||e[37]!==C||e[38]!==x||e[39]!==T?(pe=(0,$.jsx)(hx,{editorMode:r,onModeChange:re,onTimelineToggle:ce,onSaveVersion:ae,saving:T,previewEntry:_,restoring:x,restoreError:C,onExitPreview:R,onRestore:se,diffLayout:y,onDiffLayoutChange:b,onSignIn:le,onSetIdentity:ue,onOpenConflictResolver:de,onOpenClone:fe}),e[32]=y,e[33]=r,e[34]=re,e[35]=se,e[36]=_,e[37]=C,e[38]=x,e[39]=T,e[40]=pe):pe=e[40];let me;e[41]!==r||e[42]!==_?(me=r===`diff`&&_&&(0,$.jsx)(`div`,{className:`flex h-8 shrink-0 items-center border-b bg-muted/30 px-3 justify-center`,children:(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`Viewing: `,gx(_.timestamp),` — `,_x(_)]})}),e[41]=r,e[42]=_,e[43]=me):me=e[43];let he;e[44]!==y||e[45]!==r||e[46]!==_?(he=(0,$.jsx)(cy,{editorMode:r,previewEntry:_,diffLayout:y,onNoDiff:B}),e[44]=y,e[45]=r,e[46]=_,e[47]=he):he=e[47];let ge=N??``,_e=_?.sha,ve;e[48]!==I||e[49]!==ge||e[50]!==_e||e[51]!==a?(ve=(0,$.jsx)(Dx,{open:a,onOpenChange:o,docName:ge,onEntrySelect:I,selectedSha:_e}),e[48]=I,e[49]=ge,e[50]=_e,e[51]=a,e[52]=ve):ve=e[52];let ye;e[53]===s?ye=e[54]:(ye=(0,$.jsx)(Dm,{open:s,onOpenChange:c}),e[53]=s,e[54]=ye);let be;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>{u(e),e||g(!1)},e[55]=be):be=e[55];let xe=d===`identity`,Se;e[56]===h?Se=e[57]:(Se=()=>{u(!1),h&&(g(!1),m(!0))},e[56]=h,e[57]=Se);let Ce;e[58]!==l||e[59]!==xe||e[60]!==Se?(Ce=(0,$.jsx)(_f,{open:l,onOpenChange:be,identityPrompt:xe,onSuccess:Se}),e[58]=l,e[59]=xe,e[60]=Se,e[61]=Ce):Ce=e[61];let we;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{m(!1),f(`auth`),g(!0),u(!0)},e[62]=we):we=e[62];let Te;e[63]===p?Te=e[64]:(Te=(0,$.jsx)(Sf,{open:p,onOpenChange:m,onSignIn:we}),e[63]=p,e[64]=Te);let J;return e[65]!==pe||e[66]!==me||e[67]!==he||e[68]!==ve||e[69]!==ye||e[70]!==Ce||e[71]!==Te?(J=(0,$.jsxs)($.Fragment,{children:[q,pe,me,he,ve,ye,Ce,Te]}),e[65]=pe,e[66]=me,e[67]=he,e[68]=ve,e[69]=ye,e[70]=Ce,e[71]=Te,e[72]=J):J=e[72],J}function jx(e){return!e}var Mx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Nx(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Px(e){return`nodeType`in e}function Fx(e){return e?Nx(e)?e:Px(e)?e.ownerDocument?.defaultView??window:window:window}function Ix(e){let{Document:t}=Fx(e);return e instanceof t}function Lx(e){return Nx(e)?!1:e instanceof Fx(e).HTMLElement}function Rx(e){return e instanceof Fx(e).SVGElement}function zx(e){return e?Nx(e)?e.document:Px(e)?Ix(e)?e:Lx(e)||Rx(e)?e.ownerDocument:document:document:document}var Bx=Mx?Z.useLayoutEffect:Z.useEffect;function Vx(e){let t=(0,Z.useRef)(e);return Bx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Hx(){let e=(0,Z.useRef)(null);return[(0,Z.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Z.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Ux(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return Bx(()=>{n.current!==e&&(n.current=e)},t),n}function Wx(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Gx(e){let t=Vx(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Kx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var qx={};function Jx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=qx[e]==null?0:qx[e]+1;return qx[e]=n,e+`-`+n},[e,t])}function Yx(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Xx=Yx(1),Zx=Yx(-1);function Qx(e){return`clientX`in e&&`clientY`in e}function $x(e){if(!e)return!1;let{KeyboardEvent:t}=Fx(e.target);return t&&e instanceof t}function eS(e){if(!e)return!1;let{TouchEvent:t}=Fx(e.target);return t&&e instanceof t}function tS(e){if(eS(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Qx(e)?{x:e.clientX,y:e.clientY}:null}var nS=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[nS.Translate.toString(e),nS.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),rS=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function iS(e){return e.matches(rS)?e:e.querySelector(rS)}var aS={display:`none`};function oS(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:aS},n)}function sS(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Z.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function cS(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var lS=(0,Z.createContext)(null);function uS(e){let t=(0,Z.useContext)(lS);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function dS(){let[e]=(0,Z.useState)(()=>new Set),t=(0,Z.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Z.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var fS={draggable:`
|
|
17
|
+
`).replace(/[ \t]+$/gm,``).trimEnd()}function fy(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function py(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function my(e,t){let n=fy(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function hy(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>({...e,docName:n.get(e.docName)??e.docName}))}function gy(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function _y(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var vy=1280;function yy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(by),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${vy-1}px)`),t=()=>{n(window.innerWidth<vy)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function by(){return window.innerWidth<vy}var xy=`sidebar_state`,Sy=3600*24*7,Cy=`18rem`,wy=`18rem`,Ty=`3rem`,Ey=`\\`,Dy=Z.createContext(null);function Oy(){let e=Z.use(Dy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function ky(e){let t=(0,Q.c)(36),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?!0:c,u=yy(),[d,f]=Z.useState(!1),[p,m]=Z.useState(l),h=i??p,g;t[8]!==h||t[9]!==o?(g=e=>{let t=typeof e==`function`?e(h):e;o?o(t):m(t),document.cookie=`${xy}=${t}; path=/; max-age=${Sy}`},t[8]=h,t[9]=o,t[10]=g):g=t[10];let _=g,v;t[11]!==u||t[12]!==_?(v=function(){return u?f(jy):_(Ay)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,b,x;t[14]===y?(b=t[15],x=t[16]):(b=()=>{let e=e=>{e.key===Ey&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},x=[y],t[14]=y,t[15]=b,t[16]=x),Z.useEffect(b,x);let S=h?`expanded`:`collapsed`,C;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==S||t[22]!==y?(C={state:S,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=S,t[22]=y,t[23]=C):C=t[23];let w;t[24]===s?w=t[25]:(w={"--sidebar-width":Cy,"--sidebar-width-icon":Ty,...s},t[24]=s,t[25]=w);let T=w,E;t[26]===r?E=t[27]:(E=k(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=E);let D;t[28]!==n||t[29]!==a||t[30]!==T||t[31]!==E?(D=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:T,className:E,...a,children:n}),t[28]=n,t[29]=a,t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==D||t[34]!==C?(O=(0,$.jsx)(Dy.Provider,{value:C,children:D}),t[33]=D,t[34]=C,t[35]=O):O=t[35],O}function Ay(e){return!e}function jy(e){return!e}function My(e){let t=(0,Q.c)(49),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({side:o,variant:s,collapsible:c,className:r,children:n,dir:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{isMobile:f,state:p,openMobile:m,setOpenMobile:h}=Oy();if(d===`none`){let e;t[8]===r?e=t[9]:(e=k(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e||t[13]!==u?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=u,t[14]=i):i=t[14],i}if(f){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":wy},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ym,{className:`sr-only`,children:[(0,$.jsx)(bm,{children:`Sidebar`}),(0,$.jsx)(xm,{children:`Displays the mobile sidebar.`})]}),t[16]=r):r=t[16];let o;t[17]===n?o=t[18]:(o=(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:n}),t[17]=n,t[18]=o);let s;t[19]!==i||t[20]!==l||t[21]!==o?(s=(0,$.jsxs)(vm,{dir:i,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:e,side:l,children:[r,o]}),t[19]=i,t[20]=l,t[21]=o,t[22]=s):s=t[22];let c;return t[23]!==m||t[24]!==a||t[25]!==h||t[26]!==s?(c=(0,$.jsx)(hm,{open:m,onOpenChange:h,...a,children:s}),t[23]=m,t[24]=a,t[25]=h,t[26]=s,t[27]=c):c=t[27],c}let g=p===`collapsed`?d:``,_=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,v;t[28]===_?v=t[29]:(v=k(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,_),t[28]=_,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:v}),t[30]=v,t[31]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[32]!==r||t[33]!==b?(x=k(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,b,r),t[32]=r,t[33]=b,t[34]=x):x=t[34];let S;t[35]===n?S=t[36]:(S=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=S);let C;t[37]!==a||t[38]!==l||t[39]!==S||t[40]!==x?(C=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[37]=a,t[38]=l,t[39]=S,t[40]=x,t[41]=C):C=t[41];let w;return t[42]!==l||t[43]!==p||t[44]!==C||t[45]!==g||t[46]!==y||t[47]!==u?(w=(0,$.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":g,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[y,C]}),t[42]=l,t[43]=p,t[44]=C,t[45]=g,t[46]=y,t[47]=u,t[48]=w):w=t[48],w}function Ny(e){let t=(0,Q.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a}=Oy(),o;t[4]===n?o=t[5]:(o=k(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(gi,{}),l=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,$.jsxs)(q,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:o,onClick:s,...i,children:[c,l]}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function Py(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Fy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Iy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ly(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ry(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var By=Ae(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function Vy(e){let t=(0,Q.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?se:`button`,{isMobile:m,state:h}=Oy(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=k(By({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,$.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,$.jsx)(pt,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,$.jsx)($e,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,$.jsxs)(ot,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Hy(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?se:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=k(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,$.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Uy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-sub-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Gy(e){let t=(0,Q.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?se:`a`,d;t[6]===n?d=t[7]:(d=k(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,$.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Ky(e){let t=(0,Q.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Claude icon`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`g`,{clipPath:`url(#clip0_claude)`,children:(0,$.jsx)(`path`,{d:`M4.704 15.96L9.432 13.32L9.504 13.08L9.432 12.96H9.192L8.4 12.912L5.712 12.84L3.36 12.72L1.08 12.6L0.504 12.48L0 11.76L0.048 11.4L0.528 11.088L1.224 11.136L2.736 11.256L5.016 11.4L6.672 11.496L9.12 11.784H9.504L9.552 11.616L9.432 11.52L9.336 11.424L6.96 9.84L4.416 8.16L3.072 7.176L2.352 6.696L1.992 6.216L1.848 5.208L2.496 4.488L3.384 4.56L3.6 4.608L4.488 5.304L6.408 6.768L8.88 8.64L9.24 8.928L9.384 8.832L9.408 8.76L9.24 8.496L7.92 6L6.48 3.504L5.832 2.472L5.664 1.848C5.592 1.608 5.568 1.368 5.568 1.128L6.288 0.12L6.72 0L7.728 0.144L8.112 0.48L8.736 1.92L9.72 4.152L11.28 7.176L11.76 8.088L12 8.904L12.072 9.144H12.24V9.024L12.36 7.296L12.6 5.208L12.84 2.52L12.912 1.752L13.296 0.84L14.016 0.36L14.64 0.624L15.12 1.32L15.048 1.752L14.784 3.6L14.16 6.504L13.8 8.472H14.016L14.256 8.208L15.24 6.912L16.896 4.848L17.616 4.008L18.48 3.12L19.032 2.688H20.064L20.808 3.816L20.472 4.992L19.416 6.336L18.528 7.464L17.256 9.168L16.488 10.536L16.56 10.632H16.728L19.608 10.008L21.144 9.744L22.968 9.432L23.808 9.816L23.904 10.2L23.568 11.016L21.6 11.496L19.296 11.976L15.864 12.768L15.816 12.792L15.864 12.864L17.4 13.008L18.072 13.056H19.704L22.728 13.296L23.52 13.776L23.976 14.424L23.904 14.904L22.68 15.528L21.048 15.144L17.208 14.232L15.912 13.92H15.72V14.016L16.824 15.096L18.816 16.896L21.36 19.224L21.48 19.8L21.168 20.28L20.832 20.232L18.624 18.552L17.76 17.832L15.84 16.2H15.72V16.368L16.152 17.016L18.504 20.544L18.624 21.624L18.456 21.96L17.832 22.2L17.184 22.056L15.792 20.136L14.352 17.976L13.224 16.008L13.104 16.104L12.408 23.352L12.096 23.712L11.376 24L10.776 23.52L10.44 22.8L10.776 21.312L11.16 19.392L11.472 17.856L11.76 15.96L11.928 15.336V15.288H11.76L10.32 17.28L8.16 20.232L6.432 22.056L6.024 22.224L5.304 21.864L5.376 21.192L5.76 20.64L8.16 17.568L9.6 15.672L10.56 14.568L10.536 14.448H10.464L4.128 18.576L3 18.72L2.52 18.24L2.568 17.52L2.808 17.28L4.728 15.96H4.704Z`,fill:`currentColor`})}),t[1]=r):r=t[1];let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsx)(`clipPath`,{id:`clip0_claude`,children:(0,$.jsx)(`rect`,{width:`24`,height:`24`,fill:`white`})})}),t[2]=i):i=t[2];let a;return t[3]===e?a=t[4]:(a=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Claude icon`,fill:`none`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r,i]}),t[3]=e,t[4]=a),a}function qy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Cline icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M463.6,275.08l-29.26-58.75v-33.83c0-56.08-45.01-101.5-100.53-101.5h-50.01c3.62-7.43,5.61-15.79,5.61-24.61,0-31.17-25.08-56.39-56.07-56.39s-56.07,25.22-56.07,56.39c0,8.82,1.99,17.17,5.61,24.61h-50.01c-55.51,0-100.52,45.42-100.52,101.5v33.83l-29.87,58.59c-3.01,5.9-3.01,12.92,0,18.81l29.87,57.93v33.83c0,56.08,45.01,101.5,100.52,101.5h200.95c55.51,0,100.53-45.42,100.53-101.5v-33.83l29.21-58.13c2.9-5.79,2.9-12.61.05-18.46ZM202.75,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02ZM350.58,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Cline icon`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 466.73 487.04`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Jy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Codex icon`}),r=(0,$.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:`2.484`,d:`M22.356 19.797H17.17M9.662 12.29l1.979 3.576a.511.511 0 0 1-.005.504l-1.974 3.409M30.758 16c0 8.15-6.607 14.758-14.758 14.758-8.15 0-14.758-6.607-14.758-14.758C1.242 7.85 7.85 1.242 16 1.242c8.15 0 14.758 6.608 14.758 14.758Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Codex icon`,xmlns:`http://www.w3.org/2000/svg`,width:32,height:32,fill:`none`,viewBox:`0 0 32 32`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Yy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`GitHub Copilot icon`}),r=(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,fill:`currentColor`,d:`M9.6225 2.682C10.2835 3.362 10.561 4.29 10.6775 5.5905C10.9885 5.5905 11.2775 5.658 11.4735 5.9175L11.8385 6.3995C11.9435 6.5385 12 6.7045 12 6.877V8.187C12 8.3565 11.9135 8.5215 11.7735 8.621C10.1195 9.801 8.0785 10.75 6 10.75C3.7 10.75 1.3975 9.4585 0.2265 8.621C0.0865 8.521 0.0005 8.356 0 8.187V6.877C0 6.7045 0.0565 6.5375 0.1605 6.399L0.5255 5.9175C0.7215 5.659 1.0125 5.5905 1.322 5.5905L1.3365 5.442C1.4615 4.219 1.7415 3.3355 2.3775 2.682C3.608 1.412 5.2325 1.2565 5.9505 1.25H6.0495C6.7675 1.2565 8.392 1.4115 9.6225 2.682ZM6.0005 4.846C5.8585 4.846 5.694 4.854 5.5195 4.871C5.458 5.0945 5.367 5.296 5.2345 5.425C4.7095 5.9365 4.0765 6.015 3.7375 6.015C3.4185 6.015 3.0845 5.95 2.812 5.783C2.554 5.8655 2.306 5.9845 2.29 6.281C2.26898 6.76138 2.25847 7.24216 2.2585 7.723L2.2575 7.963C2.2565 8.2445 2.255 8.526 2.251 8.808C2.252 8.971 2.353 9.123 2.506 9.1905C3.747 9.7415 4.921 10.019 6.001 10.019C7.079 10.019 8.253 9.7415 9.4935 9.1905C9.56814 9.15767 9.63181 9.10416 9.677 9.03628C9.72219 8.96841 9.747 8.88902 9.7485 8.8075C9.7635 7.9665 9.7515 7.1215 9.7105 6.281C9.695 5.983 9.4465 5.866 9.1875 5.783C8.9145 5.9495 8.5815 6.015 8.2625 6.015C7.924 6.015 7.2915 5.9365 6.766 5.425C6.633 5.296 6.5425 5.0945 6.481 4.871C6.321 4.855 6.1605 4.8465 6.0005 4.846ZM4.738 6.8525C5.0075 6.8525 5.226 7.0655 5.226 7.3275V8.204C5.226 8.4665 5.0075 8.679 4.738 8.679C4.61033 8.6806 4.48725 8.63149 4.39576 8.54243C4.30426 8.45338 4.25184 8.33166 4.25 8.204V7.328C4.25 7.0655 4.4685 6.8525 4.738 6.8525ZM7.238 6.8525C7.5075 6.8525 7.726 7.0655 7.726 7.3275V8.204C7.726 8.4665 7.5075 8.679 7.238 8.679C7.11033 8.6806 6.98725 8.63149 6.89576 8.54243C6.80426 8.45338 6.75184 8.33166 6.75 8.204V7.328C6.75 7.0655 6.9685 6.8525 7.238 6.8525ZM3.8175 2.5435C3.2925 2.5945 2.85 2.7625 2.625 2.9965C2.1375 3.515 2.2425 4.8305 2.52 5.1085C2.7225 5.3055 3.105 5.437 3.5175 5.437H3.5625C3.887 5.4305 4.455 5.349 4.9275 4.882C5.145 4.677 5.28 4.1655 5.265 3.647C5.25 3.23 5.13 2.887 4.95 2.7405C4.755 2.5725 4.3125 2.4995 3.8175 2.5435ZM7.05 2.7405C6.87 2.8865 6.75 3.2305 6.735 3.647C6.72 4.1655 6.855 4.677 7.0725 4.882C7.5565 5.3605 8.1405 5.434 8.4605 5.437H8.4825C8.895 5.437 9.2775 5.3055 9.48 5.1085C9.7575 4.8305 9.8625 3.515 9.375 2.9965C9.15 2.7625 8.7075 2.5945 8.1825 2.5435C7.6875 2.4995 7.245 2.5725 7.05 2.7405ZM6 3.8075C5.88 3.8075 5.7375 3.815 5.58 3.8295C5.595 3.9095 5.6025 3.9975 5.61 4.0925L5.6095 4.172C5.60894 4.21375 5.60661 4.25545 5.6025 4.297C5.715 4.286 5.815 4.2835 5.9085 4.283H6.0915C6.185 4.283 6.285 4.286 6.3975 4.297C6.39 4.224 6.39 4.1585 6.39 4.0925C6.3975 3.9975 6.405 3.91 6.42 3.8295C6.2804 3.81583 6.14026 3.80849 6 3.8075Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`GitHub Copilot icon`,xmlns:`http://www.w3.org/2000/svg`,width:12,height:12,viewBox:`0 0 12 12`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Xy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Cursor icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Cursor icon`,fill:`none`,height:24,width:24,viewBox:`0 0 466.73 532.09`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Zy(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Windsurf icon`}),r=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M21.3192 4.9697H21.1203C20.0734 4.96806 19.2238 5.81589 19.2238 6.86264V11.0961C19.2238 11.9415 18.525 12.6263 17.6934 12.6263C17.1993 12.6263 16.706 12.3777 16.4133 11.9603L12.0896 5.78492C11.7308 5.27214 11.1471 4.96643 10.5152 4.96643C9.52943 4.96643 8.64234 5.80448 8.64234 6.83902V11.0969C8.64234 11.9423 7.94932 12.6271 7.11197 12.6271C6.61625 12.6271 6.12376 12.3785 5.83105 11.9611L0.992853 5.0504C0.883594 4.89387 0.638184 4.97133 0.638184 5.1621V8.85424C0.638184 9.04094 0.695264 9.22193 0.802059 9.37517L5.56362 16.175C5.84492 16.5769 6.25994 16.8753 6.73852 16.9837C7.93627 17.256 9.03861 16.334 9.03861 15.1592V10.9037C9.03861 10.0583 9.7235 9.37354 10.569 9.37354H10.5714C11.081 9.37354 11.5588 9.62219 11.8515 10.0396L16.1761 16.2141C16.5356 16.7277 17.0892 17.0326 17.7497 17.0326C18.7574 17.0326 19.6209 16.1937 19.6209 15.16V10.9029C19.6209 10.0575 20.3058 9.37273 21.1512 9.37273H21.32C21.426 9.37273 21.5116 9.28713 21.5116 9.18116V5.16127C21.5116 5.05531 21.426 4.9697 21.32 4.9697H21.3192Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,"aria-label":`Windsurf icon`,xmlns:`http://www.w3.org/2000/svg`,width:22,height:22,viewBox:`0 0 22 22`,fill:`none`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Qy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Jc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function $y(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Yc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function eb(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=k(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,$.jsx)(Xc,{children:(0,$.jsx)(Zc,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function tb(e){return typeof e==`object`&&!!e&&typeof e.getStates==`function`}function nb(e,t,n){let r=[],i=[];for(let a of e.getStates().values()){let e=a.agentPresence;if(e)for(let[a,o]of Object.entries(e))o.currentDoc&&(n-o.ts>=5e3||(o.currentDoc===t?r.push({agentId:a,entry:o}):i.push({agentId:a,entry:o})))}return{current:r,crossDoc:i}}function rb(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentPresence;if(e)for(let r of Object.values(e))r.currentDoc&&(t-r.ts>=5e3||n.push(r))}return n.length===0?null:(n.sort((e,t)=>t.ts-e.ts),n[0].currentDoc)}var ib=1e3,ab=!1;function ob(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function sb(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:tb(i)?a=i:(a=void 0,ab||(ab=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`})}let{current:t,crossDoc:i}=a?nb(a,n,Date.now()):{current:[],crossDoc:[]},s=cb,c=t.map(s),l=i.map(s),u=[...e,...c],d=l;o(e=>ob(e.current,u)&&ob(e.crossDoc,d)?e:{current:u,crossDoc:d})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,ib);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function cb(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function lb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?ub:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Z.useEffect)(i,a),n}function ub(e){return e===`synced`?`synced`:`connected`}var db=`sync-status`;function fb(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:db,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:db,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}function pb(e){window.location.hash=me(e)}var mb=4,hb=3,gb={Bird:Ar,Cat:Pr,Dog:Yr,Fish:Qr,Mouse:wi,Rabbit:Ci,Shrimp:Ai,Snail:ji,Squirrel:Fi,Turtle:Bi},_b={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function vb(e){let t=(0,Q.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,$.jsx)(Ky,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Xy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Zy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(Jy,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(qy,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Yy,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(Mi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function yb(e){let t=(0,Q.c)(20),{user:n,mode:r}=e,i=n.name.split(` `)[1],a=i?gb[i]:void 0,o;t[0]===n.name?o=t[1]:(o=n.name.split(` `).map(bb).join(``),t[0]=n.name,t[1]=o);let s=o,c;t[2]===n.color?c=t[3]:(c=A(n.color),t[2]=n.color,t[3]=c);let l=c,u;t[4]===n.color?u=t[5]:(u={backgroundColor:n.color},t[4]=n.color,t[5]=u);let d;t[6]!==a||t[7]!==l||t[8]!==s?(d=a?(0,$.jsx)(a,{size:18,color:l,strokeWidth:1.5}):(0,$.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:l},children:s}),t[6]=a,t[7]=l,t[8]=s,t[9]=d):d=t[9];let f;t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==n.name?(f=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":n.name,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:u,children:d})}),t[10]=r,t[11]=u,t[12]=d,t[13]=n.name,t[14]=f):f=t[14];let p;t[15]===n.name?p=t[16]:(p=(0,$.jsx)($e,{children:n.name}),t[15]=n.name,t[16]=p);let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(ot,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function bb(e){return e[0]}function xb(e){let t=_b[e.icon];return e.displayName||t||`Agent`}function Sb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function Cb(e){let t=(0,Q.c)(30),{participant:n,crossDoc:r,onNavigate:i}=e,{presence:a}=n,o;t[0]===a?o=t[1]:(o=xb(a),t[0]=a,t[1]=o);let s=o,c=r&&a.currentDoc!==null,l=Sb(a.mode),u=!c&&!r&&l,d=c?`cursor-pointer`:`cursor-default`,f=u?`ring-primary/40 animate-pulse`:``,p;t[2]!==d||t[3]!==f?(p=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 ring-background`,d,f].filter(Boolean),t[2]=d,t[3]=f,t[4]=p):p=t[4];let m=p.join(` `),h=r?`true`:void 0,g;t[5]!==a.mode||t[6]!==h?(g={"data-presence-badge":`agent`,"data-presence-mode":a.mode,"data-presence-crossdoc":h},t[5]=a.mode,t[6]=h,t[7]=g):g=t[7];let _=g,v;t[8]!==_||t[9]!==c||t[10]!==i||t[11]!==a.color||t[12]!==a.currentDoc||t[13]!==a.icon||t[14]!==m||t[15]!==s?(v=c?(0,$.jsx)(`button`,{type:`button`,..._,"aria-label":`${s}, editing ${a.currentDoc}`,className:m,style:{backgroundColor:a.color},onClick:()=>{a.currentDoc&&i(a.currentDoc)},children:(0,$.jsx)(vb,{icon:a.icon,width:16,height:16,className:`text-white`})}):(0,$.jsx)(`div`,{..._,role:`img`,"aria-label":s,className:m,style:{backgroundColor:a.color},children:(0,$.jsx)(vb,{icon:a.icon,width:16,height:16,className:`text-white`})}),t[8]=_,t[9]=c,t[10]=i,t[11]=a.color,t[12]=a.currentDoc,t[13]=a.icon,t[14]=m,t[15]=s,t[16]=v):v=t[16];let y=v,b;t[17]===y?b=t[18]:(b=(0,$.jsx)(pt,{asChild:!0,children:y}),t[17]=y,t[18]=b);let x;t[19]===s?x=t[20]:(x=(0,$.jsx)(`span`,{className:`font-medium`,children:s}),t[19]=s,t[20]=x);let S;t[21]!==r||t[22]!==a.currentDoc?(S=r&&a.currentDoc?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,a.currentDoc,`]]`]}):null,t[21]=r,t[22]=a.currentDoc,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==x?(C=(0,$.jsxs)($e,{className:`flex flex-col gap-0.5`,children:[x,S]}),t[24]=S,t[25]=x,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==b?(w=(0,$.jsxs)(ot,{children:[b,C]}),t[27]=C,t[28]=b,t[29]=w):w=t[29],w}function wb(e){let t=(0,Q.c)(16),{count:n,remainder:r,crossDoc:i,onNavigate:a}=e,o=i?`true`:void 0,s=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,c;t[0]!==n||t[1]!==o||t[2]!==s?(c=(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":o,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":s,children:[`+`,n]})}),t[0]=n,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l;if(t[4]!==i||t[5]!==a||t[6]!==r){let e;t[8]!==i||t[9]!==a?(e=e=>e.kind===`human`?(0,$.jsx)(yb,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(Cb,{participant:e,crossDoc:i,onNavigate:a},e.agentId),t[8]=i,t[9]=a,t[10]=e):e=t[10],l=r.map(e),t[4]=i,t[5]=a,t[6]=r,t[7]=l}else l=t[7];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(eb,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:l})}),t[11]=l,t[12]=u);let d;return t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(Qy,{children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],d}function Tb(e,t,n){return e.kind===`human`?(0,$.jsx)(yb,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(Cb,{participant:e,crossDoc:n,onNavigate:t},e.agentId)}function Eb(){let e=(0,Q.c)(12),{activeProvider:t,activeDocName:n,systemProvider:r}=Hn(),{current:i,crossDoc:a}=sb(t,r,n);fb(lb(t),n);let o;if(e[0]!==a||e[1]!==i){let t=i.slice(0,mb),n;e[3]===i?n=e[4]:(n=i.slice(mb),e[3]=i,e[4]=n);let r=n,s=a.slice(0,hb),c;e[5]===a?c=e[6]:(c=a.slice(hb),e[5]=a,e[6]=c);let l=c,u=t.map(Ob),d;e[7]===r?d=e[8]:(d=r.length>0?(0,$.jsx)(wb,{count:r.length,remainder:r,crossDoc:!1,onNavigate:pb}):null,e[7]=r,e[8]=d);let f;e[9]!==u||e[10]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[u,d]}),e[9]=u,e[10]=d,e[11]=f):f=e[11],o=(0,$.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[f,a.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[s.map(Db),l.length>0?(0,$.jsx)(wb,{count:l.length,remainder:l,crossDoc:!0,onNavigate:pb}):null]})]}):null]}),e[0]=a,e[1]=i,e[2]=o}else o=e[2];return o}function Db(e){return Tb(e,pb,!0)}function Ob(e){return Tb(e,pb,!1)}function kb(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`LinkedIn`}),r=(0,$.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function Ab(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`X (Twitter)`}),r=(0,$.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var jb=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Mr},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:vt},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:Ab},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:kb}],Mb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Rr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)($e,{children:`Help & resources`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:`Need help?`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(Qy,{children:[t,(0,$.jsxs)(eb,{align:`end`,className:`w-56 p-3`,children:[n,(0,$.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:jb.map(Nb)})})]})]}),e[2]=r):r=e[2],r};function Nb(e){let{label:t,href:n,icon:r}=e;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,$.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var Pb=`https://github.com/inkeep/open-knowledge/releases`;function Fb(e){let{target:t,installState:n,isElectronHost:r}=e;return t.id===`cursor`&&!r?`Desktop only`:n.installed===null?`Detecting…`:n.installed===!1?`Not installed`:null}function Ib(e){let{target:t,installState:n,isElectronHost:r}=e;if(t.id===`cursor`&&!r)return{enabled:!1,tooltip:{message:`Cursor handoff requires the desktop build.`,installAction:{label:`Install the Open Knowledge desktop app →`,url:Pb}}};if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function Lb(e){return od(e)}function Rb(e){return`Opened ${e} in your browser.`}function zb(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??pd,c=e.onWebFallbackSuccess??Vb,l=e.onWebFallbackError??Bb,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Ib({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=Fb({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(Lb(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r;t[17]===n.displayName?r=t[18]:(r=(0,$.jsxs)(`span`,{children:[`Open in `,n.displayName]}),t[17]=n.displayName,t[18]=r);let i;return t[19]!==o||t[20]!==e||t[21]!==r?(i=(0,$.jsx)(Gg,{onSelect:o,"data-testid":e,children:r}),t[19]=o,t[20]=e,t[21]=r,t[22]=i):i=t[22],i}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[23]===n.displayName?i=t[24]:(i=(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,n.displayName]}),t[23]=n.displayName,t[24]=i);let a;t[25]===p?a=t[26]:(a=p?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[25]=p,t[26]=a);let o;return t[27]!==e||t[28]!==r||t[29]!==i||t[30]!==a?(o=(0,$.jsxs)(Gg,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a]}),t[27]=e,t[28]=r,t[29]=i,t[30]=a,t[31]=o):o=t[31],o}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[32]===n.displayName?b=t[33]:(b=(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,n.displayName]}),t[32]=n.displayName,t[33]=b);let x;t[34]===p?x=t[35]:(x=p?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[34]=p,t[35]=x);let S;t[36]!==v||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,$.jsxs)(Hg,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x]}),t[36]=v,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C=`open-in-agent-submenu-${n.id}`,w=`open-in-agent-message-${n.id}`,T;t[41]!==d.tooltip.message||t[42]!==w?(T=(0,$.jsx)(qg,{className:`font-normal text-muted-foreground text-xs`,"data-testid":w,children:d.tooltip.message}),t[41]=d.tooltip.message,t[42]=w,t[43]=T):T=t[43];let E;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Jg,{}),t[44]=E):E=t[44];let D=`open-in-agent-install-${n.id}`,O;t[45]===d.tooltip.installAction.label?O=t[46]:(O=(0,$.jsx)(`span`,{children:d.tooltip.installAction.label}),t[45]=d.tooltip.installAction.label,t[46]=O);let k;t[47]!==h||t[48]!==D||t[49]!==O?(k=(0,$.jsx)(Gg,{onSelect:h,"data-testid":D,children:O}),t[47]=h,t[48]=D,t[49]=O,t[50]=k):k=t[50];let A;t[51]!==_||t[52]!==d.tooltip.webFallback||t[53]!==n.id?(A=d.tooltip.webFallback?(0,$.jsxs)(Gg,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,$.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[51]=_,t[52]=d.tooltip.webFallback,t[53]=n.id,t[54]=A):A=t[54];let j;t[55]!==T||t[56]!==k||t[57]!==A||t[58]!==C?(j=(0,$.jsxs)(Ug,{className:`min-w-[260px]`,"data-testid":C,children:[T,E,k,A]}),t[55]=T,t[56]=k,t[57]=A,t[58]=C,t[59]=j):j=t[59];let M;return t[60]!==j||t[61]!==S?(M=(0,$.jsxs)(Bg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function Bb(){}function Vb(){}function Hb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Wd(),{dispatch:a}=Nd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=Wb,u=Ub,d;t[0]===i?d=t[1]:(d=e=>{s(e),e&&i()},t[0]=i,t[1]=d);let f=d,p=n===null,m;t[2]===n?m=t[3]:(m=n===null?``:ad(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Xr,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in…`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})}),t[8]=p,t[9]=y);let b;t[10]!==_||t[11]!==h||t[12]!==r?(b=sd.map(e=>{let t=r[e.id];return(0,$.jsx)(zb,{target:e,installState:t,isElectronHost:c,prompt:h,onSelect:()=>_(e),onWebFallbackSuccess:l,onWebFallbackError:u},e.id)}),t[10]=_,t[11]=h,t[12]=r,t[13]=b):b=t[13];let x;t[14]===b?x=t[15]:(x=(0,$.jsx)(Wg,{align:`end`,className:`min-w-[220px]`,"data-testid":`open-in-agent-menu`,children:b}),t[14]=b,t[15]=x);let S;return t[16]!==f||t[17]!==o||t[18]!==y||t[19]!==x?(S=(0,$.jsxs)(Rg,{open:o,onOpenChange:f,children:[y,x]}),t[16]=f,t[17]=o,t[18]=y,t[19]=x,t[20]=S):S=t[20],S}function Ub(e){X.error(`Couldn't open ${e.displayName} in your browser.`)}function Wb(e){X.success(Rb(e.displayName))}var Gb={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},Kb=e=>{let t=(0,Q.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,$.jsx)(`svg`,{"aria-hidden":`true`,...Gb,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},qb=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Markdown`}),r=(0,$.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(Kb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Jb=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`title`,{children:`Textbox`}),r=(0,$.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,$.jsxs)(Kb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Yb=(e,t,n)=>qi(e,t,n,`ProjectSwitcher`);function Xb(e){let t=(0,Q.c)(57),{bridge:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(!1),c;t[1]!==n.project||t[2]!==o?(c=()=>{if(!o)return;let e=!1;return Yb(async()=>{let t=await n.project.listRecent();e||a(t)},`Failed to load recent projects.`),()=>{e=!0}},t[1]=n.project,t[2]=o,t[3]=c):c=t[3];let l;t[4]!==n||t[5]!==o?(l=[o,n],t[4]=n,t[5]=o,t[6]=l):l=t[6],(0,Z.useEffect)(c,l);let u;t[7]===n.project?u=t[8]:(u=e=>{s(!1),Yb(()=>n.project.open({path:e,target:`new-window`}),`Failed to open project.`)},t[7]=n.project,t[8]=u);let d=u,f;t[9]!==n.dialog||t[10]!==n.project?(f=()=>{s(!1),Yb(async()=>{let e=await n.dialog.openFolder();e&&await n.project.open({path:e,target:`new-window`})},`Failed to open folder.`)},t[9]=n.dialog,t[10]=n.project,t[11]=f):f=t[11];let p=f,m=n.config.projectPath,h,g,_,v,y,b,x,S,C,w,T;if(t[12]!==n.config.projectName||t[13]!==m||t[14]!==o||t[15]!==d||t[16]!==i){let e;t[28]===m?e=t[29]:(e=e=>e.path!==m,t[28]=m,t[29]=e);let r=i.filter(e);g=Rg,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),t[30]=a):a=t[30];let c;t[31]===n.config.projectName?c=t[32]:(c=(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:n.config.projectName}),t[31]=n.config.projectName,t[32]=c);let l;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1.5 px-2 text-muted-foreground hover:text-foreground`,"data-testid":`project-switcher-trigger`,title:`Switch project`,children:[a,c,l]})}),t[34]=c,t[35]=x),h=Wg,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(qg,{children:`Switch project`}),_=(0,$.jsx)(Jg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(qg,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(Gg,{disabled:e.missing,onSelect:()=>d(e.path),className:`flex flex-col items-start gap-0.5`,"data-testid":`project-switcher-recent-${e.path}`,children:[(0,$.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,$.jsxs)(`span`,{className:`max-w-[240px] truncate text-muted-foreground text-xs`,children:[e.path,e.missing?` (missing)`:``]})]},e.path)),t[12]=n.config.projectName,t[13]=m,t[14]=o,t[15]=d,t[16]=i,t[17]=h,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S,t[25]=C,t[26]=w,t[27]=T}else h=t[17],g=t[18],_=t[19],v=t[20],y=t[21],b=t[22],x=t[23],S=t[24],C=t[25],w=t[26],T=t[27];let E;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Jg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ei,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(Gg,{onSelect:p,"data-testid":`project-switcher-open-folder`,children:[D,`Open folder…`]}),t[40]=p,t[41]=O);let k;t[42]!==h||t[43]!==_||t[44]!==v||t[45]!==O||t[46]!==S||t[47]!==C||t[48]!==w||t[49]!==T?(k=(0,$.jsxs)(h,{align:S,className:C,"data-testid":w,children:[T,_,v,E,O]}),t[42]=h,t[43]=_,t[44]=v,t[45]=O,t[46]=S,t[47]=C,t[48]=w,t[49]=T,t[50]=k):k=t[50];let A;return t[51]!==g||t[52]!==y||t[53]!==b||t[54]!==x||t[55]!==k?(A=(0,$.jsxs)(g,{open:y,onOpenChange:b,children:[x,k]}),t[51]=g,t[52]=y,t[53]=b,t[54]=x,t[55]=k,t[56]=A):A=t[56],A}function Zb(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=k(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(gl,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,$.jsx)(hl,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function Qb(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function $b(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function ex(e){let t=await fetch(`/api/sync/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})});if(!t.ok)throw Error(`set-enabled failed: HTTP ${t.status}`)}function tx(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zi,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fi,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function nx(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;case`disabled`:return``;default:return``}}function rx(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching…`;case`pulling`:return`Pulling…`;case`pushing`:return`Pushing…`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function ix(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function ax(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:rx(e.state):`Sync off`}function ox(e){let t=(0,Q.c)(72),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,[o,s]=(0,Z.useState)(!1),c=n.syncEnabled,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=async function(e){s(!0);try{await ex(e)}catch(t){console.error(`[sync] toggle failed`,t),X.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,$.jsx)(tx,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=rx(n.state),t[3]=n.state,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[5]=f,t[6]=p);let m;t[7]!==d||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[7]=d,t[8]=p,t[9]=m):m=t[9];let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>void u(e),t[10]=h):h=t[10];let g=c?`Disable sync`:`Enable sync`,_;t[11]!==c||t[12]!==g||t[13]!==o?(_=(0,$.jsx)(Zb,{checked:c,disabled:o,onCheckedChange:h,"aria-label":g}),t[11]=c,t[12]=g,t[13]=o,t[14]=_):_=t[14];let v;t[15]!==m||t[16]!==_?(v=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,_]}),t[15]=m,t[16]=_,t[17]=v):v=t[17];let y;t[18]===n.error?y=t[19]:(y=n.error&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[18]=n.error,t[19]=y);let b;t[20]===n.pausedReason?b=t[21]:(b=n.pausedReason&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ix(n.pausedReason)}),t[20]=n.pausedReason,t[21]=b);let x;t[22]===n.state?x=t[23]:(x=n.state===`conflict`&&(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[22]=n.state,t[23]=x);let S;t[24]!==c||t[25]!==n.lastSyncUtc||t[26]!==n.state?(S=c&&n.state!==`dormant`&&(0,$.jsxs)(`div`,{children:[`Last synced: `,Qb(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,$.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,$.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,$.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,$.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,$.jsx)(Ui,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:cx,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:sx,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function sx(){$b(`sync`)}function cx(){$b(`sync`)}function lx(e){let t=(0,Q.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=uf();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(zr,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,$.jsxs)(ot,{children:[e,(0,$.jsx)($e,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=nx(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=rx(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,$.jsx)(tx,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)($y,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=ax(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)($e,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(ot,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,$.jsx)(eb,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(ox,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,$.jsxs)(Qy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var ux=[{value:`light`,label:`Light`,icon:Li},{value:`dark`,label:`Dark`,icon:pi},{value:`system`,label:`System`,icon:Wr}],dx=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=Ve(),r=t===`system`?Wr:t===`dark`?pi:Li,i;e[0]===r?i=e[1]:(i=(0,$.jsx)(r,{}),e[0]=r,e[1]=i);let a=t??`system`,o;e[2]===a?o=e[3]:(o=(0,$.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,a,`)`]}),e[2]=a,e[3]=o);let s;e[4]!==i||e[5]!==o?(s=(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[i,o]})}),e[4]=i,e[5]=o,e[6]=s):s=e[6];let c;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=ux.map(fx),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Wg,{align:`end`,children:(0,$.jsx)(Vg,{value:t,onValueChange:n,children:c})}),e[8]=n,e[9]=t,e[10]=l):l=e[10];let u;return e[11]!==s||e[12]!==l?(u=(0,$.jsxs)(Rg,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function fx(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Kg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function px(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function mx(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(px)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function hx(e){let t=(0,Q.c)(117),{editorMode:n,onModeChange:r,onTimelineToggle:i,onSaveVersion:a,saving:o,previewEntry:s,restoring:c,restoreError:l,onExitPreview:u,onRestore:d,diffLayout:f,onDiffLayoutChange:p,onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g,onOpenClone:_}=e,{activeDocName:v,activeProvider:y,activeTarget:b,closeDocument:x,pinnedDoc:S,pin:C,unpin:w}=Hn(),{state:T}=Oy(),E=cd(),D=lb(y),O;t[0]!==v||t[1]!==E?(O=wd({docName:v,workspace:E}),t[0]=v,t[1]=E,t[2]=O):O=t[2];let k=O,A=!v||!(D===`connected`||D===`synced`),j=b?.kind===`folder`,M=b?.kind===`missing`,N=j?`${b.folderPath}/`:v?`${v}.md`:``,P;t[3]===v?P=t[4]:(P=v?.lastIndexOf(`/`)??-1,t[3]=v,t[4]=P);let F=P,I;t[5]!==v||t[6]!==F?(I=v&&F!==-1?`${v.substring(0,F+1)}`:``,t[5]=v,t[6]=F,t[7]=I):I=t[7];let L=I,R;t[8]!==v||t[9]!==F?(R=v?v.substring(F+1):``,t[8]=v,t[9]=F,t[10]=R):R=t[10];let z=R,B=S!==null,V;t[11]!==v||t[12]!==B||t[13]!==C||t[14]!==w?(V=function(){v&&(B?w():C(v))},t[11]=v,t[12]=B,t[13]=C,t[14]=w,t[15]=V):V=t[15];let H=V,U=n===`diff`,[W,G]=(0,Z.useState)(!1),[K,ee]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{le.current=!0,ue.current=null,de.current=null,ee(!1),ie(null)},t[16]=fe):fe=t[16];let pe;t[17]===v?pe=t[18]:(pe=[v],t[17]=v,t[18]=pe),(0,Z.useEffect)(fe,pe);let he,ge;t[19]===K?(he=t[20],ge=t[21]):(he=()=>{if(K){let e=setTimeout(()=>{let e=se.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},ge=[K],t[19]=K,t[20]=he,t[21]=ge),(0,Z.useEffect)(he,ge);let _e;t[22]!==v||t[23]!==j?(_e=function(){if(!v||j)return;let e=v.split(`/`);le.current=!1,ue.current=v,ne(e[e.length-1]),ie(null),de.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=_e):_e=t[24];let ve=_e,ye;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ye=function(){le.current=!0,ue.current=null,de.current=null,ee(!1),ne(``),ie(null)},t[25]=ye):ye=t[25];let be=ye,xe;t[26]!==x||t[27]!==te?(xe=async function(){if(le.current){le.current=!1;return}if(ce.current)return;let e=ue.current;if(!e){be();return}let t=fy(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){be();return}if(t===de.current)return;if(!py(t)){ie(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=my({kind:`file`,path:e,name:r},t);ce.current=!0,oe(!0),ie(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(le.current){oe(!1),ce.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),ie(`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!n.ok||!mx(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),ie(a?.error||`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!r.ok){ie(r.error||`Failed to rename path`),oe(!1),ce.current=!1,de.current=t;return}let a=r.renamed,o=_y(e,a);for(let e of a)x(e.fromDocName);ze([`files`,`backlinks`,`graph`]),ee(!1),ne(``),oe(!1),ce.current=!1,de.current=null,ue.current=null,o&&o!==e&&(window.location.hash=me(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),ie(`Network error — please try again`),oe(!1),ce.current=!1,de.current=t}},t[26]=x,t[27]=te,t[28]=xe):xe=t[28];let Se=xe,Ce;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{G(!1)},t[29]=Ce):Ce=t[29];let we;t[30]===s?we=t[31]:(we=[s],t[30]=s,t[31]=we),(0,Z.useEffect)(Ce,we);let Te;t[32]===d?Te=t[33]:(Te=function(){G(!1),d()},t[32]=d,t[33]=Te);let J=Te,Ee;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Ny,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Ee):Ee=t[34];let De=T===`expanded`?`Hide Files`:`Show Files`,Oe;t[35]===De?Oe=t[36]:(Oe=(0,$.jsxs)(ot,{children:[Ee,(0,$.jsx)($e,{children:De})]}),t[35]=De,t[36]=Oe);let ke,Ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ke=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(Xb,{bridge:window.okDesktop})]}):null,Ae=(0,$.jsx)(gv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=ke,t[38]=Ae):(ke=t[37],Ae=t[38]);let je;t[39]!==v||t[40]!==Se||t[41]!==N||t[42]!==ve||t[43]!==z||t[44]!==j||t[45]!==ae||t[46]!==K||t[47]!==L||t[48]!==re||t[49]!==te?(je=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:N})]}):v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[L&&(0,$.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:K?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,$.jsx)(`span`,{className:`truncate`,children:L.slice(0,-1)}),(0,$.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),K?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Mt,{ref:se,value:te,disabled:ae,"aria-label":`Rename ${v}`,"aria-invalid":re?!0:void 0,"aria-describedby":re?`editor-header-rename-error`:void 0,"aria-busy":ae||void 0,onChange:e=>{ne(e.target.value),ie(null),de.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Se()):e.key===`Escape`&&(e.preventDefault(),be())},onBlur:()=>void Se(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:`.md`})]}),re&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:re})]}):(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ve,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:[z,`.md`]})]}):(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:N}),t[39]=v,t[40]=Se,t[41]=N,t[42]=ve,t[43]=z,t[44]=j,t[45]=ae,t[46]=K,t[47]=L,t[48]=re,t[49]=te,t[50]=je):je=t[50];let Me;t[51]!==v||t[52]!==B||t[53]!==H?(Me=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:H,"aria-label":B?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":B,"data-pinned":B?`true`:`false`,children:B?(0,$.jsx)(xi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(bi,{className:`size-4`})})}),(0,$.jsx)($e,{children:B?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[51]=v,t[52]=B,t[53]=H,t[54]=Me):Me=t[54];let Y;t[55]===M?Y=t[56]:(Y=M&&(0,$.jsx)(vl,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=Y);let Ne;t[57]!==Oe||t[58]!==je||t[59]!==Me||t[60]!==Y?(Ne=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Oe,ke,Ae,je,Me,Y]}),t[57]=Oe,t[58]=je,t[59]=Me,t[60]=Y,t[61]=Ne):Ne=t[61];let Pe;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Pe=!U&&v&&(0,$.jsxs)(mt,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!v,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(Jb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(lt,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(qb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)($e,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)($e,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Pe):Pe=t[67];let Fe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Fe=U&&s&&!W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[l&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,$.jsxs)(mt,{type:`single`,value:f,onValueChange:e=>{e&&p(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Di,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Hr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ei,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(jt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Exit preview`})]})]}),t[68]=W,t[69]=f,t[70]=U,t[71]=p,t[72]=u,t[73]=s,t[74]=l,t[75]=Fe):Fe=t[75];let Ie;t[76]!==W||t[77]!==J||t[78]!==U||t[79]!==s||t[80]!==c?(Ie=U&&s&&W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Replace current content with this version?`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(q,{variant:`default`,size:`xs`,onClick:J,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=J,t[78]=U,t[79]=s,t[80]=c,t[81]=Ie):Ie=t[81];let Le;t[82]!==U||t[83]!==_?(Le=!U&&_&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(ni,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Le):Le=t[84];let Re;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Re=!U&&v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Oi,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Re):Re=t[89];let Be;t[90]!==v||t[91]!==i?(Be=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(ai,{className:`size-4`})})}),(0,$.jsx)($e,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Be):Be=t[92];let Ve;t[93]!==v||t[94]!==k||t[95]!==U?(Ve=!U&&v&&(0,$.jsx)(Hb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=Ve):Ve=t[96];let He;t[97]!==g||t[98]!==h||t[99]!==m?(He=(0,$.jsx)(lx,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=He):He=t[100];let Ue,We,Ge,Ke;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(Eb,{}),We=(0,$.jsx)(gv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ge=(0,$.jsx)(Mb,{}),Ke=(0,$.jsx)(dx,{}),t[101]=Ue,t[102]=We,t[103]=Ge,t[104]=Ke):(Ue=t[101],We=t[102],Ge=t[103],Ke=t[104]);let qe;t[105]!==Le||t[106]!==Re||t[107]!==Be||t[108]!==Ve||t[109]!==He?(qe=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Le,Re,Be,Ve,He,Ue,We,Ge,Ke]}),t[105]=Le,t[106]=Re,t[107]=Be,t[108]=Ve,t[109]=He,t[110]=qe):qe=t[110];let Je;return t[111]!==Ne||t[112]!==Pe||t[113]!==Fe||t[114]!==Ie||t[115]!==qe?(Je=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Ne,Pe,Fe,Ie,qe]}),t[111]=Ne,t[112]=Pe,t[113]=Fe,t[114]=Ie,t[115]=qe,t[116]=Je):Je=t[116],Je}function gx(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function _x(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function vx(e){if(e.contributors.length>0){let t=e.contributors[0],n=t.colorSeed??t.name;return{hex:ie[Ue(n)]??Ge(n)}}return e.type===`upstream`?{className:`bg-muted-foreground/50`}:(e.authorEmail.includes(`openknowledge.local`)||e.type===`wip`)&&(e.authorEmail.includes(`agent`)||e.author.includes(`agent`)||e.authorEmail.includes(`cursor`)||e.authorEmail.includes(`claude`))?{className:`bg-[--color-agent]`}:{className:`bg-[--color-azure-blue]`}}function yx(e){let t=vx(e);return(0,$.jsx)(`span`,{"aria-hidden":`true`,style:t.hex?{backgroundColor:t.hex}:void 0,className:`inline-block size-2 rounded-full shrink-0 ${t.className??``}`})}function bx(e){let t=(0,Q.c)(15),{entries:n,defaultExpanded:r,selectedSha:i,onSelect:a}=e,[o,s]=(0,Z.useState)(r);if(n.length===0)return null;let c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>s(xx),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ir,{className:`size-3`}):(0,$.jsx)(Lr,{className:`size-3`}),t[1]=o,t[2]=l);let u=o?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,d;t[3]!==o||t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex items-center gap-1 px-4 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors text-left`,onClick:c,children:[l,u]}),t[3]=o,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==n||t[8]!==o||t[9]!==a||t[10]!==i?(f=o&&n.map(e=>(0,$.jsx)(kx,{entry:e,selected:e.sha===i,onSelect:a},e.sha)),t[7]=n,t[8]=o,t[9]=a,t[10]=i,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}function xx(e){return!e}function Sx(e){return e.checkpoint?e.checkpoint.kind:`save`}function Cx(e){let t=Sx(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${wx(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function wx(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function Tx(e){let t=[];for(let n of e.contributors)if(n.summaries)for(let e of n.summaries)t.push(e);return t}function Ex(e){let t=(0,Q.c)(20),{summaries:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useId)();if(n.length===0)return null;let o,s;t[0]===n?(o=t[1],s=t[2]):([o,...s]=n,t[0]=n,t[1]=o,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,$.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[c,o]}),t[4]=o,t[5]=l);let u;t[6]!==r||t[7]!==s?(u=r&&s.map(Ox),t[6]=r,t[7]=s,t[8]=u):u=t[8];let d;t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`ul`,{id:a,className:`list-none`,children:[l,u]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==a||t[15]!==s.length?(f=s.length>0&&(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),i(Dx)},children:[r?(0,$.jsx)(Ir,{className:`size-3`}):(0,$.jsx)(Lr,{className:`size-3`}),r?`Hide ${s.length} more`:`Show ${s.length} more`]}),t[13]=r,t[14]=a,t[15]=s.length,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-0.5`,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Dx(e){return!e}function Ox(e,t){return(0,$.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),e]},`${t}-${e}`)}function kx(e){let t=(0,Q.c)(60),{entry:n,selected:r,onSelect:i,prominent:a}=e,o=a===void 0?!1:a,s;t[0]===n.timestamp?s=t[1]:(s=gx(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=_x(n),t[2]=n,t[3]=l);let u=l,d,f,p,m,h,g,_,v,y,b,x;if(t[4]!==u||t[5]!==n||t[6]!==i||t[7]!==o||t[8]!==r){let e=n.contributors.flatMap(Ax),a;t[20]===n?a=t[21]:(a=Tx(n),t[20]=n,t[21]=a);let s=a,c;t[22]!==n||t[23]!==i?(c=()=>i?.(n),t[22]=n,t[23]=i,t[24]=c):c=t[24];let l=c;x=`button`,d=0;let S=r?`bg-muted`:`hover:bg-muted/40`,C=o?`border-b border-border/50`:``,w;t[25]!==S||t[26]!==C?(w=[`group flex w-full items-start gap-2.5 px-4 py-2.5 text-left transition-colors cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,S,C].filter(Boolean),t[25]=S,t[26]=C,t[27]=w):w=t[27],f=w.join(` `),p=l,t[28]===l?m=t[29]:(m=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())},t[28]=l,t[29]=m),t[30]!==n||t[31]!==o?(h=o?(()=>{let e=Sx(n);return e===`bridge-merge-loss`?(0,$.jsx)(zi,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,$.jsx)(Zr,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(Jr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})})():(0,$.jsx)(`div`,{className:`mt-1.5 flex shrink-0 items-center`,children:yx(n)}),t[30]=n,t[31]=o,t[32]=h):h=t[32],g=`min-w-0 flex-1`,t[33]!==u||t[34]!==n||t[35]!==o?(_=o&&(0,$.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:Cx(n)}),yx(n),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:u})]}),t[33]=u,t[34]=n,t[35]=o,t[36]=_):_=t[36],t[37]!==u||t[38]!==o?(v=!o&&(0,$.jsx)(`p`,{className:`truncate text-xs text-foreground`,children:u}),t[37]=u,t[38]=o,t[39]=v):v=t[39],t[40]===s?y=t[41]:(y=s.length>0&&(0,$.jsx)(Ex,{summaries:s}),t[40]=s,t[41]=y),b=e.length>0?(0,$.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:e.join(`, `),children:e.join(`, `)}):(0,$.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),t[4]=u,t[5]=n,t[6]=i,t[7]=o,t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x}else d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19];let S;t[42]!==g||t[43]!==_||t[44]!==v||t[45]!==y||t[46]!==b?(S=(0,$.jsxs)(`div`,{className:g,children:[_,v,y,b]}),t[42]=g,t[43]=_,t[44]=v,t[45]=y,t[46]=b,t[47]=S):S=t[47];let C;t[48]!==n.timestamp||t[49]!==c?(C=(0,$.jsx)(`time`,{className:`shrink-0 text-xs text-muted-foreground`,dateTime:n.timestamp,title:n.timestamp,children:c}),t[48]=n.timestamp,t[49]=c,t[50]=C):C=t[50];let w;return t[51]!==d||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==S||t[57]!==C||t[58]!==x?(w=(0,$.jsxs)(`div`,{role:x,tabIndex:d,className:f,onClick:p,onKeyDown:m,children:[h,S,C]}),t[51]=d,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=S,t[57]=C,t[58]=x,t[59]=w):w=t[59],w}function Ax(e){return e.docs}function jx(e){let t=(0,Q.c)(57),{open:n,onOpenChange:r,docName:i,onEntrySelect:a,selectedSha:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),h,g;t[1]!==i||t[2]!==n?(h=()=>{if(!n){m.current&&clearInterval(m.current);return}let e=async function(){if(i)try{let e=await fetch(`/api/history?docName=${encodeURIComponent(i)}&limit=100`);if(!e.ok){p(`History unavailable`);return}l((await e.json()).entries??[]),p(null)}catch(e){let t=e;p(`History unavailable`),console.error(`[timeline]`,t)}};return d(!0),e().finally(()=>d(!1)),m.current=setInterval(e,1e4),()=>{m.current&&clearInterval(m.current)}},g=[n,i],t[1]=i,t[2]=n,t[3]=h,t[4]=g):(h=t[3],g=t[4]),(0,Z.useEffect)(h,g);let _,v;if(t[5]!==c){_=[];let e=[],n=!1;for(let t of c)t.type===`checkpoint`?(e.length>0&&(_.push({kind:`wip-group`,entries:e,isPreCheckpoint:!n}),e=[]),_.push({kind:`checkpoint`,entry:t}),n=!0):e.push(t);if(e.length>0){let r=!n,i;t[8]!==e||t[9]!==r?(i={kind:`wip-group`,entries:e,isPreCheckpoint:r},t[8]=e,t[9]=r,t[10]=i):i=t[10],_.push(i)}v=c.some(Nx),t[5]=c,t[6]=_,t[7]=v}else _=t[6],v=t[7];let y=!v,b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(bm,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),className:`text-xs text-muted-foreground`,children:`Now`}),t[12]=a,t[13]=o,t[14]=x):x=t[14];let S;t[15]===x?S=t[16]:(S=(0,$.jsx)(ym,{className:`border-b px-4 py-3 pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between pr-10`,children:[b,x]})}),t[15]=x,t[16]=S);let C;t[17]===u?C=t[18]:(C=u&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3,4].map(Mx)}),t[17]=u,t[18]=C);let w;t[19]!==f||t[20]!==u?(w=!u&&f&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[19]=f,t[20]=u,t[21]=w):w=t[21];let T;t[22]!==c.length||t[23]!==f||t[24]!==u?(T=!u&&!f&&c.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[22]=c.length,t[23]=f,t[24]=u,t[25]=T):T=t[25];let E;t[26]!==c||t[27]!==f||t[28]!==y||t[29]!==u||t[30]!==a||t[31]!==o?(E=!u&&!f&&y&&c.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col`,children:c.map(e=>(0,$.jsx)(kx,{entry:e,selected:e.sha===o,onSelect:a},e.sha))}),t[26]=c,t[27]=f,t[28]=y,t[29]=u,t[30]=a,t[31]=o,t[32]=E):E=t[32];let D;t[33]!==f||t[34]!==_||t[35]!==y||t[36]!==u||t[37]!==a||t[38]!==o?(D=!u&&!f&&!y&&(0,$.jsx)(`div`,{className:`flex flex-col`,children:_.map((e,t)=>e.kind===`checkpoint`?(0,$.jsx)(kx,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(bx,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,selectedSha:o,onSelect:a},e.entries[0]?.sha??`wip-${t}`))}),t[33]=f,t[34]=_,t[35]=y,t[36]=u,t[37]=a,t[38]=o,t[39]=D):D=t[39];let O;t[40]!==T||t[41]!==E||t[42]!==D||t[43]!==C||t[44]!==w?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[C,w,T,E,D]}),t[40]=T,t[41]=E,t[42]=D,t[43]=C,t[44]=w,t[45]=O):O=t[45];let k;t[46]!==a||t[47]!==o?(k=o&&(0,$.jsxs)(`div`,{className:`border-t p-3 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground `,children:`Viewing historical version`}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ei,{className:`size-3`}),`Exit`]})]}),t[46]=a,t[47]=o,t[48]=k):k=t[48];let A;t[49]!==O||t[50]!==k||t[51]!==S?(A=(0,$.jsxs)(vm,{side:`right`,className:`w-[350px] p-0 flex flex-col overflow-hidden sm:max-w-[350px]`,showCloseButton:!0,children:[S,O,k]}),t[49]=O,t[50]=k,t[51]=S,t[52]=A):A=t[52];let j;return t[53]!==r||t[54]!==n||t[55]!==A?(j=(0,$.jsx)(hm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function Mx(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(yf,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(yf,{className:`h-3 w-24`}),(0,$.jsx)(yf,{className:`h-3 w-40`})]}),(0,$.jsx)(yf,{className:`h-3 w-14`})]},e)}function Nx(e){return e.type===`checkpoint`}function Px(){let e=(0,Q.c)(73),[t,n]=sf(),[r,i]=(0,Z.useState)(t),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`auth`),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(`unified`),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),D=(0,Z.useRef)(null),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(`wysiwyg`),A=lf(),j,M;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>()=>{D.current&&clearTimeout(D.current)},M=[],e[0]=j,e[1]=M):(j=e[0],M=e[1]),(0,Z.useEffect)(j,M);let{activeDocName:N,activeTarget:P}=Hn(),F;e[2]===r?F=e[3]:(F=function(e){e.sha?(r!==`diff`&&(k.current=r),v(e),i(`diff`)):(v(null),i(k.current)),w(null)},e[2]=r,e[3]=F);let I=F,L;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(){v(null),i(k.current),w(null)},e[4]=L):L=e[4];let R=L,z;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(){R(),X.info(`No changes since this version`)},e[5]=z):z=e[5];let B=z,V,H;e[6]===N?(V=e[7],H=e[8]):(V=()=>{let e=function(e){let t=e.detail;t&&N&&Un(N,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Bt,e),()=>window.removeEventListener(Bt,e)},H=[N],e[6]=N,e[7]=V,e[8]=H),(0,Z.useEffect)(V,H);let U;e[9]!==P?.kind||e[10]!==r?(U=()=>{P?.kind===`folder`&&(v(null),o(!1),r===`diff`&&i(k.current))},e[9]=P?.kind,e[10]=r,e[11]=U):U=e[11];let W;e[12]!==P||e[13]!==r?(W=[P,r],e[12]=P,e[13]=r,e[14]=W):W=e[14],(0,Z.useEffect)(U,W);let G;e[15]===A?G=e[16]:(G=()=>{!O.current&&A?.state===`dormant`&&A.hasRemote&&(O.current=!0,X.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>u(!0)}}))},e[15]=A,e[16]=G);let K=A?.state,ee=A?.hasRemote,te;e[17]!==K||e[18]!==ee?(te=[K,ee],e[17]=K,e[18]=ee,e[19]=te):te=e[19],(0,Z.useEffect)(G,te);let ne;e[20]===n?ne=e[21]:(ne=function(e){i(e),n(e)},e[20]=n,e[21]=ne);let re=ne,ie;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(ie=async function(){E(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}E(!1)},e[22]=ie):ie=e[22];let ae=ie,oe;e[23]!==N||e[24]!==_?(oe=async function(){if(!(!_?.sha||!N)){S(!0);try{(await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:N,commitSha:_.sha})})).ok?(v(null),i(k.current),w(null)):(w(`Restore failed — document unchanged`),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>w(null),4e3))}catch{w(`Restore failed — document unchanged`),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>w(null),4e3)}S(!1)}},e[23]=N,e[24]=_,e[25]=oe):oe=e[25];let se=oe,q;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(wf,{onOpenResolver:()=>c(!0)}),e[26]=q):q=e[26];let ce;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>o(Fx),e[27]=ce):ce=e[27];let le,ue,de,fe;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{f(`auth`),u(!0)},ue=()=>{f(`identity`),u(!0)},de=()=>c(!0),fe=()=>m(!0),e[28]=le,e[29]=ue,e[30]=de,e[31]=fe):(le=e[28],ue=e[29],de=e[30],fe=e[31]);let pe;e[32]!==y||e[33]!==r||e[34]!==re||e[35]!==se||e[36]!==_||e[37]!==C||e[38]!==x||e[39]!==T?(pe=(0,$.jsx)(hx,{editorMode:r,onModeChange:re,onTimelineToggle:ce,onSaveVersion:ae,saving:T,previewEntry:_,restoring:x,restoreError:C,onExitPreview:R,onRestore:se,diffLayout:y,onDiffLayoutChange:b,onSignIn:le,onSetIdentity:ue,onOpenConflictResolver:de,onOpenClone:fe}),e[32]=y,e[33]=r,e[34]=re,e[35]=se,e[36]=_,e[37]=C,e[38]=x,e[39]=T,e[40]=pe):pe=e[40];let me;e[41]!==r||e[42]!==_?(me=r===`diff`&&_&&(0,$.jsx)(`div`,{className:`flex h-8 shrink-0 items-center border-b bg-muted/30 px-3 justify-center`,children:(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[`Viewing: `,gx(_.timestamp),` — `,_x(_)]})}),e[41]=r,e[42]=_,e[43]=me):me=e[43];let he;e[44]!==y||e[45]!==r||e[46]!==_?(he=(0,$.jsx)(cy,{editorMode:r,previewEntry:_,diffLayout:y,onNoDiff:B}),e[44]=y,e[45]=r,e[46]=_,e[47]=he):he=e[47];let ge=N??``,_e=_?.sha,ve;e[48]!==I||e[49]!==ge||e[50]!==_e||e[51]!==a?(ve=(0,$.jsx)(jx,{open:a,onOpenChange:o,docName:ge,onEntrySelect:I,selectedSha:_e}),e[48]=I,e[49]=ge,e[50]=_e,e[51]=a,e[52]=ve):ve=e[52];let ye;e[53]===s?ye=e[54]:(ye=(0,$.jsx)(Dm,{open:s,onOpenChange:c}),e[53]=s,e[54]=ye);let be;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(be=e=>{u(e),e||g(!1)},e[55]=be):be=e[55];let xe=d===`identity`,Se;e[56]===h?Se=e[57]:(Se=()=>{u(!1),h&&(g(!1),m(!0))},e[56]=h,e[57]=Se);let Ce;e[58]!==l||e[59]!==xe||e[60]!==Se?(Ce=(0,$.jsx)(_f,{open:l,onOpenChange:be,identityPrompt:xe,onSuccess:Se}),e[58]=l,e[59]=xe,e[60]=Se,e[61]=Ce):Ce=e[61];let we;e[62]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{m(!1),f(`auth`),g(!0),u(!0)},e[62]=we):we=e[62];let Te;e[63]===p?Te=e[64]:(Te=(0,$.jsx)(Sf,{open:p,onOpenChange:m,onSignIn:we}),e[63]=p,e[64]=Te);let J;return e[65]!==pe||e[66]!==me||e[67]!==he||e[68]!==ve||e[69]!==ye||e[70]!==Ce||e[71]!==Te?(J=(0,$.jsxs)($.Fragment,{children:[q,pe,me,he,ve,ye,Ce,Te]}),e[65]=pe,e[66]=me,e[67]=he,e[68]=ve,e[69]=ye,e[70]=Ce,e[71]=Te,e[72]=J):J=e[72],J}function Fx(e){return!e}var Ix=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Lx(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Rx(e){return`nodeType`in e}function zx(e){return e?Lx(e)?e:Rx(e)?e.ownerDocument?.defaultView??window:window:window}function Bx(e){let{Document:t}=zx(e);return e instanceof t}function Vx(e){return Lx(e)?!1:e instanceof zx(e).HTMLElement}function Hx(e){return e instanceof zx(e).SVGElement}function Ux(e){return e?Lx(e)?e.document:Rx(e)?Bx(e)?e:Vx(e)||Hx(e)?e.ownerDocument:document:document:document}var Wx=Ix?Z.useLayoutEffect:Z.useEffect;function Gx(e){let t=(0,Z.useRef)(e);return Wx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Kx(){let e=(0,Z.useRef)(null);return[(0,Z.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Z.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function qx(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return Wx(()=>{n.current!==e&&(n.current=e)},t),n}function Jx(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Yx(e){let t=Gx(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Xx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var Zx={};function Qx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=Zx[e]==null?0:Zx[e]+1;return Zx[e]=n,e+`-`+n},[e,t])}function $x(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var eS=$x(1),tS=$x(-1);function nS(e){return`clientX`in e&&`clientY`in e}function rS(e){if(!e)return!1;let{KeyboardEvent:t}=zx(e.target);return t&&e instanceof t}function iS(e){if(!e)return!1;let{TouchEvent:t}=zx(e.target);return t&&e instanceof t}function aS(e){if(iS(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return nS(e)?{x:e.clientX,y:e.clientY}:null}var oS=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[oS.Translate.toString(e),oS.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),sS=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function cS(e){return e.matches(sS)?e:e.querySelector(sS)}var lS={display:`none`};function uS(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:lS},n)}function dS(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Z.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function fS(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var pS=(0,Z.createContext)(null);function mS(e){let t=(0,Z.useContext)(pS);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function hS(){let[e]=(0,Z.useState)(()=>new Set),t=(0,Z.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Z.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var gS={draggable:`
|
|
18
18
|
To pick up a draggable item, press the space bar.
|
|
19
19
|
While dragging, use the arrow keys to move the item.
|
|
20
20
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
21
|
-
`},pS={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function mS(e){let{announcements:t=pS,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=fS}=e,{announce:a,announcement:o}=cS(),s=Jx(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),uS((0,Z.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=Z.createElement(Z.Fragment,null,Z.createElement(oS,{id:r,value:i.draggable}),Z.createElement(sS,{id:s,announcement:o}));return n?(0,V_.createPortal)(u,n):u}var hS;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(hS||={});function gS(){}function _S(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function vS(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var yS=Object.freeze({x:0,y:0});function bS(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function xS(e,t){let n=tS(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function SS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function CS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function wS(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function TS(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function ES(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var DS=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=ES(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(CS)};function OS(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var kS=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&OS(r,a)){let n=wS(a).reduce((e,t)=>e+bS(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(SS)};function AS(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function jS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:yS}function MS(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var NS=MS(1);function PS(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function FS(e,t,n){let r=PS(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var IS={ignoreTransform:!1};function LS(e,t){t===void 0&&(t=IS);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Fx(e).getComputedStyle(e);t&&(n=FS(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function RS(e){return LS(e,{ignoreTransform:!0})}function zS(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function BS(e,t){return t===void 0&&(t=Fx(e).getComputedStyle(e)),t.position===`fixed`}function VS(e,t){t===void 0&&(t=Fx(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function HS(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Ix(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Lx(i)||Rx(i)||n.includes(i))return n;let a=Fx(e).getComputedStyle(i);return i!==e&&VS(i,a)&&n.push(i),BS(i,a)?n:r(i.parentNode)}return e?r(e):n}function US(e){let[t]=HS(e,1);return t??null}function WS(e){return!Mx||!e?null:Nx(e)?e:Px(e)?Ix(e)||e===zx(e).scrollingElement?window:Lx(e)?e:null:null}function GS(e){return Nx(e)?e.scrollX:e.scrollLeft}function KS(e){return Nx(e)?e.scrollY:e.scrollTop}function qS(e){return{x:GS(e),y:KS(e)}}var JS;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(JS||={});function YS(e){return!Mx||!e?!1:e===document.scrollingElement}function XS(e){let t={x:0,y:0},n=YS(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var ZS={x:.2,y:.2};function QS(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=ZS);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=XS(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=JS.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=JS.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=JS.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=JS.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function $S(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function eC(e){return e.reduce((e,t)=>Xx(e,qS(t)),yS)}function tC(e){return e.reduce((e,t)=>e+GS(t),0)}function nC(e){return e.reduce((e,t)=>e+KS(t),0)}function rC(e,t){if(t===void 0&&(t=LS),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);US(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var iC=[[`x`,[`left`,`right`],tC],[`y`,[`top`,`bottom`],nC]],aC=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=HS(t),r=eC(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of iC)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},oC=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function sC(e){let{EventTarget:t}=Fx(e);return e instanceof t?e:zx(e)}function cC(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var lC;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(lC||={});function uC(e){e.preventDefault()}function dC(e){e.stopPropagation()}var fC;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(fC||={});var pC={start:[fC.Space,fC.Enter],cancel:[fC.Esc],end:[fC.Space,fC.Enter,fC.Tab]},mC=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case fC.Right:return{...n,x:n.x+25};case fC.Left:return{...n,x:n.x-25};case fC.Down:return{...n,y:n.y+25};case fC.Up:return{...n,y:n.y-25}}},hC=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new oC(zx(t)),this.windowListeners=new oC(Fx(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(lC.Resize,this.handleCancel),this.windowListeners.add(lC.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(lC.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&rC(n),t(yS)}handleKeyDown(e){if($x(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=pC,coordinateGetter:a=mC,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:yS;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Zx(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=XS(n),p=$S(n),m={x:Math.min(i===fC.Right?p.right-p.width/2:p.right,Math.max(i===fC.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===fC.Down?p.bottom-p.height/2:p.bottom,Math.max(i===fC.Down?p.top:p.top+p.height/2,u.y))},h=i===fC.Right&&!s||i===fC.Left&&!c,g=i===fC.Down&&!l||i===fC.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===fC.Right&&e<=d.x||i===fC.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===fC.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===fC.Down&&e<=d.y||i===fC.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===fC.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Xx(Zx(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};hC.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=pC,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function gC(e){return!!(e&&`distance`in e)}function _C(e){return!!(e&&`delay`in e)}var vC=class{constructor(e,t,n){n===void 0&&(n=sC(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=zx(i),this.documentListeners=new oC(this.document),this.listeners=new oC(n),this.windowListeners=new oC(Fx(i)),this.initialCoordinates=tS(r)??yS,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(lC.Resize,this.handleCancel),this.windowListeners.add(lC.DragStart,uC),this.windowListeners.add(lC.VisibilityChange,this.handleCancel),this.windowListeners.add(lC.ContextMenu,uC),this.documentListeners.add(lC.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(_C(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(gC(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(lC.Click,dC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(lC.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=tS(e)??yS,s=Zx(n,o);if(!t&&a){if(gC(a)){if(a.tolerance!=null&&cC(s,a.tolerance))return this.handleCancel();if(cC(s,a.distance))return this.handleStart()}if(_C(a)&&cC(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===fC.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},yC={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},bC=class extends vC{constructor(e){let{event:t}=e,n=zx(t.target);super(e,yC,n)}};bC.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var xC={move:{name:`mousemove`},end:{name:`mouseup`}},SC;(function(e){e[e.RightClick=2]=`RightClick`})(SC||={});var CC=class extends vC{constructor(e){super(e,xC,zx(e.event.target))}};CC.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===SC.RightClick?!1:(r?.({event:n}),!0)}}];var wC={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},TC=class extends vC{constructor(e){super(e,wC)}static setup(){return window.addEventListener(wC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(wC.move.name,e)};function e(){}}};TC.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var EC;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(EC||={});var DC;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(DC||={});function OC(e){let{acceleration:t,activator:n=EC.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=DC.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=AC({delta:d,disabled:!a}),[m,h]=Hx(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case EC.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case EC.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,Z.useMemo)(()=>s===DC.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=QS(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var kC={x:{[JS.Backward]:!1,[JS.Forward]:!1},y:{[JS.Backward]:!1,[JS.Forward]:!1}};function AC(e){let{delta:t,disabled:n}=e,r=Kx(t);return Wx(e=>{if(n||!r||!e)return kC;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[JS.Backward]:e.x[JS.Backward]||i.x===-1,[JS.Forward]:e.x[JS.Forward]||i.x===1},y:{[JS.Backward]:e.y[JS.Backward]||i.y===-1,[JS.Forward]:e.y[JS.Forward]||i.y===1}}},[n,t,r])}function jC(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Wx(e=>t==null?null:r??e??null,[r,t])}function MC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var NC;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(NC||={});var PC;(function(e){e.Optimized=`optimized`})(PC||={});var FC=new Map;function IC(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=Ux(d),p=(0,Z.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,Z.useRef)(null),h=Wx(t=>{if(d&&!n)return FC;if(!t||t===FC||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new aC(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case NC.Always:return!1;case NC.BeforeDragging:return n;default:return!n}}}function LC(e,t){return Wx(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function RC(e,t){return LC(e,t)}function zC(e){let{callback:t,disabled:n}=e,r=Vx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function BC(e){let{callback:t,disabled:n}=e,r=Vx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function VC(e){return new aC(LS(e),e)}function HC(e,t,n){t===void 0&&(t=VC);let[r,i]=(0,Z.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=zC({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=BC({callback:a});return Bx(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function UC(e){return jS(e,LC(e))}var WC=[];function GC(e){let t=(0,Z.useRef)(e),n=Wx(n=>e?n&&n!==WC&&e&&t.current&&e.parentNode===t.current.parentNode?n:HS(e):WC,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function KC(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=WS(e.target);t&&n(e=>e?(e.set(t,qS(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=WS(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,qS(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{WS(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Xx(e,t),yS):eC(e):yS,[e,t])}function qC(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==yS;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Zx(e,n.current):yS}function JC(e){(0,Z.useEffect)(()=>{if(!Mx)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function YC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function XC(e){return(0,Z.useMemo)(()=>e?zS(e):null,[e])}var ZC=[];function QC(e,t){t===void 0&&(t=LS);let[n]=e,r=XC(n?Fx(n):null),[i,a]=(0,Z.useState)(ZC);function o(){a(()=>e.length?e.map(e=>YS(e)?r:new aC(t(e),e)):ZC)}let s=BC({callback:o});return Bx(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function $C(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Lx(t)?t:e}function ew(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=BC({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(Lx(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Gx((0,Z.useCallback)(e=>{let n=$C(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var tw=[{sensor:bC,options:{}},{sensor:hC,options:{}}],nw={current:{}},rw={draggable:{measure:RS},droppable:{measure:RS,strategy:NC.WhileDragging,frequency:PC.Optimized},dragOverlay:{measure:LS}},iw=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},aw={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new iw,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:rw,measureDroppableContainers:gS,windowRect:null,measuringScheduled:!1},ow={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:gS,draggableNodes:new Map,over:null,measureDroppableContainers:gS},sw=(0,Z.createContext)(ow),cw=(0,Z.createContext)(aw);function lw(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new iw}}}function uw(e,t){switch(t.type){case hS.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case hS.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case hS.DragEnd:case hS.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case hS.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new iw(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case hS.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new iw(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case hS.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new iw(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function dw(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(sw),a=Kx(r),o=Kx(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!$x(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=iS(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function fw(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function pw(e){return(0,Z.useMemo)(()=>({draggable:{...rw.draggable,...e?.draggable},droppable:{...rw.droppable,...e?.droppable},dragOverlay:{...rw.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function mw(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Bx(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=jS(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=US(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var hw=(0,Z.createContext)({...yS,scaleX:1,scaleY:1}),gw;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(gw||={});var _w=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=tw,collisionDetection:o=DS,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(uw,void 0,lw),[f,p]=dS(),[m,h]=(0,Z.useState)(gw.Uninitialized),g=m===gw.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??nw,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=Ux(l,Object.values(l)),A=Jx(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=pw(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=IC(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=jC(v,_),L=(0,Z.useMemo)(()=>D?tS(D):null,[D]),R=xe(),z=RC(I,M.draggable.measure);mw({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=HC(I,M.draggable.measure,z),V=HC(I?I.parentElement:null),H=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),U=b.getNodeFor(H.current.over?.id),W=ew({measure:M.dragOverlay.measure}),G=W.nodeRef.current??I,K=g?W.rect??B:null,ee=!!(W.nodeRef.current&&W.rect),te=UC(ee?null:B),ne=XC(G?Fx(G):null),re=GC(g?U??I:null),ie=QC(re),ae=fw(c,{transform:{x:y.x-te.x,y:y.y-te.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:K,over:H.current.over,overlayNodeRect:W.rect,scrollableAncestors:re,scrollableAncestorRects:ie,windowRect:ne}),oe=L?Xx(L,y):null,se=KC(re),q=qC(se),ce=qC(se,[B]),le=Xx(ae,q),ue=K?NS(K,ae):null,de=C&&ue?o({active:C,collisionRect:ue,droppableRects:N,droppableContainers:j,pointerCoordinates:oe}):null,fe=TS(de,`id`),[pe,me]=(0,Z.useState)(null),he=AS(ee?ae:Xx(ae,ce),pe?.rect??null,B),ge=(0,Z.useRef)(null),_e=(0,Z.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;ge.current=new n({active:w.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,V_.unstable_batchedUpdates)(()=>{r?.(i),h(gw.Initializing),d({type:hS.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(ge.current),O(a)})},onMove(e){d({type:hS.DragMove,coordinates:e})},onEnd:o(hS.DragEnd),onCancel:o(hS.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===hS.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=hS.DragCancel)}w.current=null,(0,V_.unstable_batchedUpdates)(()=>{d({type:e}),h(gw.Uninitialized),me(null),E(null),O(null),ge.current=null;let t=e===hS.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ve=MC(a,(0,Z.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,_e(n,t))},[v,_e]));JC(a),Bx(()=>{B&&m===gw.Initializing&&h(gw.Initialized)},[B,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:le.x,y:le.y},over:i};(0,V_.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[le.x,le.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(fe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,V_.unstable_batchedUpdates)(()=>{me(s),a?.(c),f({type:`onDragOver`,event:c})})},[fe]),Bx(()=>{H.current={activatorEvent:D,active:C,activeNode:I,collisionRect:ue,collisions:de,droppableRects:N,draggableNodes:v,draggingNode:G,draggingNodeRect:K,droppableContainers:b,over:pe,scrollableAncestors:re,scrollAdjustedTranslate:le},S.current={initial:K,translated:ue}},[C,I,de,ue,v,G,K,N,b,pe,re,le]),OC({...R,delta:y,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:re,scrollableAncestorRects:ie});let ye=(0,Z.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:de,containerNodeRect:V,dragOverlay:W,draggableNodes:v,droppableContainers:b,droppableRects:N,over:pe,measureDroppableContainers:P,scrollableAncestors:re,scrollableAncestorRects:ie,measuringConfiguration:M,measuringScheduled:F,windowRect:ne}),[C,I,B,D,de,V,W,v,b,N,pe,P,re,ie,M,F,ne]),be=(0,Z.useMemo)(()=>({activatorEvent:D,activators:ve,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:pe,measureDroppableContainers:P}),[D,ve,C,B,d,A,v,pe,P]);return Z.createElement(lS.Provider,{value:p},Z.createElement(sw.Provider,{value:be},Z.createElement(cw.Provider,{value:ye},Z.createElement(hw.Provider,{value:he},i)),Z.createElement(dw,{disabled:n?.restoreFocus===!1})),Z.createElement(mS,{...n,hiddenTextDescribedById:A}));function xe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),vw=(0,Z.createContext)(null),yw=`button`,bw=`Draggable`;function xw(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Jx(bw),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(sw),{role:p=yw,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?hw:vw),[v,y]=Gx(),[b,x]=Gx(),S=YC(o,t),C=Ux(n);return Bx(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===yw?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Sw(){return(0,Z.useContext)(cw)}var Cw=`Droppable`,ww={timeout:25};function Tw(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Jx(Cw),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(sw),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...ww,...i},_=Ux(h??r),v=BC({callback:(0,Z.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Gx((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Ux(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:hS.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:hS.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:hS.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Ew(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=Kx(n);return!n&&!r&&s&&i(s),Bx(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var Dw={x:0,y:0,scaleX:1,scaleY:1};function Ow(e){let{children:t}=e;return Z.createElement(sw.Provider,{value:ow},Z.createElement(hw.Provider,{value:Dw},t))}var kw={position:`fixed`,touchAction:`none`},Aw=e=>$x(e)?`transform 250ms ease`:void 0,jw=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Aw}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...kw,width:s.width,height:s.height,top:s.top,left:s.left,transform:nS.Transform.toString(d),transformOrigin:i&&r?xS(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Mw={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:nS.Transform.toString(t)},{transform:nS.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Nw(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Vx((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=$C(a);if(!c)return;let{transform:l}=Fx(a).getComputedStyle(a),u=PS(l);if(!u)return;let d=typeof t==`function`?t:Pw(t);return rC(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Pw(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Mw,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Fw=0;function Iw(e){return(0,Z.useMemo)(()=>{if(e!=null)return Fw++,Fw},[e])}var Lw=Z.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Sw(),S=(0,Z.useContext)(hw),C=Iw(d?.id),w=fw(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=LC(f),E=Nw({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(Ow,null,Z.createElement(Ew,{animation:E},d&&C?Z.createElement(jw,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Rw(e){let t=(0,Q.c)(20),{itemName:n,isSubmitting:r,onDelete:i,customTitle:a,customDescription:o,children:s}=e,c=n===void 0?`this item`:n,l=a??`Delete ${c}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(pn,{children:l}),t[0]=l,t[1]=u);let d=o??`Are you sure you want to delete ${c}? This action cannot be undone.`,f;t[2]===d?f=t[3]:(f=(0,$.jsx)(dn,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,disabled:r,children:`Cancel`})}),t[4]=r,t[5]=p);let m;t[6]===r?m=t[7]:(m=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(an,{className:`size-4 animate-spin`}),` Deleting...`]}):`Delete`,t[6]=r,t[7]=m);let h;t[8]!==r||t[9]!==i||t[10]!==m?(h=(0,$.jsx)(q,{variant:`destructive`,onClick:i,disabled:r,children:m}),t[8]=r,t[9]=i,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==h?(g=(0,$.jsxs)(wn,{children:[p,h]}),t[12]=p,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==s||t[16]!==u||t[17]!==f||t[18]!==g?(_=(0,$.jsxs)(In,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function zw(e){let t=e.lastIndexOf(`/`);return t<=0?``:e.slice(0,t)}function Bw(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Vw(e,t){return e?`${e}/${t}`:t}function Hw(e,t){return Vw(t,Bw(e.path))}function Uw(e,t){if(e.kind===`folder`){if(t===e.path)return{ok:!1,reason:`self`};if(t.length>e.path.length&&t.startsWith(`${e.path}/`))return{ok:!1,reason:`descendant`}}let n=Hw(e,t);return n===e.path?{ok:!1,reason:`no_op`}:{ok:!0,destinationPath:n}}function Ww(e,t){if(!e)return{selectedFilePath:t,selectedFolderPath:null,navigationPath:t};switch(e.kind){case`doc`:return{selectedFilePath:e.docName,selectedFolderPath:null,navigationPath:e.docName};case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function Gw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(vs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function Kw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(ys,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(ws,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function Jw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(bs,{children:(0,$.jsx)(xs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yw(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=k(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,$.jsx)(Ss,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Xw(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Lr,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(Ts,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Zw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Es,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Cs,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $w(e,t,n,r){return e.id===`cursor`&&!n?`Desktop only`:t.installed===null?`Detecting…`:t.installed===!1?`Not installed`:r?`No workspace`:null}function eT(e){let t=(0,Q.c)(8),{input:n,installStates:r,isElectronHost:i,dispatch:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Xw,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=sd.map(e=>{let t=r[e.id],o=Ib({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=$w(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)(Yw,{disabled:!c,onSelect:()=>{!c||!n||a(e.id,n)},"data-testid":`file-tree-open-in-${e.id}`,"aria-label":u,children:[(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,e.displayName]}),l?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)}),t[1]=a,t[2]=n,t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsxs)(qw,{children:[o,(0,$.jsx)(Zw,{children:s})]}),t[6]=s,t[7]=c),c}var tT=80,nT=3,rT=20,iT=new Map,aT=new Set,oT=[],sT=new Map;function cT(e){for(sT.delete(e),sT.set(e,!0);sT.size>rT;){let e=sT.keys().next().value;if(e===void 0)break;sT.delete(e)}}function lT(e){aT.delete(e),uT()}function uT(){for(;aT.size<nT&&oT.length>0;){let e=oT.shift();if(!e)break;if(!sT.has(e.docName)){aT.add(e.docName),cT(e.docName);try{e.prewarm(e.docName)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{lT(e.docName)}}}}function dT(e,t){if(yn(e)||sT.has(e))return;let n=iT.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(iT.delete(e),aT.size>=nT){oT.push({docName:e,prewarm:t});return}cT(e),aT.add(e);try{t(e)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{lT(e)}},tT);iT.set(e,{timer:r,prewarm:t})}function fT(e){let t=iT.get(e);t&&(clearTimeout(t.timer),iT.delete(e))}var pT=(0,Z.createContext)(null);function mT(){return(0,Z.use)(pT)}function hT(e){window.location.hash=me(e)}function gT(e){return e.kind===`file`?`${e.path}.md`:e.path}async function _T(e,t){try{await navigator.clipboard.writeText(e),X.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),X.error(`Could not copy ${t}`)}}var vT=new Set([`agents`,`agent`,`claude`,`skill`]);function yT(e){return e.kind===`file`&&vT.has(e.name.toLowerCase())}function bT(e){let t=(0,Q.c)(38),{kind:n,value:r,busy:i,error:a,onChange:o,onCommit:s,onCancel:c}=e,l=(0,Z.useRef)(null),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=setTimeout(()=>l.current?.focus(),0);return()=>clearTimeout(e)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,Z.useEffect)(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=k(`flex h-8 items-center gap-2 rounded-md px-2`),t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=n===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[3]=n,t[4]=p);let m=`Create new ${n}`,h=!!a,g=a?`inline-create-error`:void 0,_=n===`folder`?`folder-name`:`file-name`,v=a&&`border-destructive`,y;t[5]===v?y=t[6]:(y=k(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let b;t[7]!==i||t[8]!==a||t[9]!==c?(b=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=b):b=t[10];let x;t[11]===o?x=t[12]:(x=e=>o(e.target.value),t[11]=o,t[12]=x);let S;t[13]!==c||t[14]!==s?(S=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=S):S=t[15];let C;t[16]!==i||t[17]!==y||t[18]!==b||t[19]!==x||t[20]!==S||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(C=(0,$.jsx)(Mt,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:b,onChange:x,onKeyDown:S}),t[16]=i,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=C):C=t[26];let w;t[27]===n?w=t[28]:(w=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=w);let T;t[29]!==C||t[30]!==w||t[31]!==p?(T=(0,$.jsxs)(`div`,{className:f,children:[p,C,w]}),t[29]=C,t[30]=w,t[31]=p,t[32]=T):T=t[32];let E;t[33]===a?E=t[34]:(E=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=E);let D;return t[35]!==T||t[36]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37],D}function xT(e,t){if(!e)return``;let n=Uw(e,t);return!n.ok&&(n.reason===`self`||n.reason===`descendant`)?`bg-destructive/20 ring-2 ring-destructive/50`:n.ok?`bg-primary/10 ring-2 ring-primary/40`:``}function ST(e){let t=(0,Q.c)(11),{treeActionsLocked:n}=e,r=mT(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={destinationFolderPath:``},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a={id:`drop-root`,disabled:n,data:i},t[1]=n,t[2]=a);let{setNodeRef:o,isOver:s}=Tw(a);if(!r)return null;let c;t[3]!==r||t[4]!==s?(c=s&&xT(r,``),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=k(`flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-xs text-muted-foreground transition-colors`,c),t[6]=c,t[7]=l);let u;return t[8]!==o||t[9]!==l?(u=(0,$.jsx)(zy,{children:(0,$.jsx)(`div`,{ref:o,className:l,children:`Drop here to move to library root`})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}var CT=e=>{let t=(0,Q.c)(171),{node:n,nested:r,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:T,getInlineCreate:E}=e,D=r===void 0?!1:r,O=(0,Z.useRef)(!1),A=(0,Z.useRef)(null),j=n.kind===`file`,M=!j&&o.has(n.path),N=j?n.path===i:n.path===a,P=l===n.path,F,I;t[0]===P?(F=t[1],I=t[2]):(F=()=>{P&&requestAnimationFrame(()=>{let e=A.current;e&&(e.focus(),e.select())})},I=[P],t[0]=P,t[1]=F,t[2]=I),(0,Z.useEffect)(F,I);let L=d===n.path,R=d!==null,z=j?Nn:M?Dn:ti,B=D?Wy:zy,V=D?Gy:Vy,H;t[3]!==n.kind||t[4]!==n.name||t[5]!==n.path?(H={kind:n.kind,path:n.path,name:n.name},t[3]=n.kind,t[4]=n.name,t[5]=n.path,t[6]=H):H=t[6];let U=H,W;t[7]!==j||t[8]!==n.path?(W=j?zw(n.path):n.path,t[7]=j,t[8]=n.path,t[9]=W):W=t[9];let G=W,K=mT(),ee=`drag-${n.kind}-${n.path}`,te=f||P,ne;t[10]===U?ne=t[11]:(ne={source:U},t[10]=U,t[11]=ne);let re;t[12]!==ee||t[13]!==te||t[14]!==ne?(re={id:ee,disabled:te,data:ne},t[12]=ee,t[13]=te,t[14]=ne,t[15]=re):re=t[15];let{attributes:ie,listeners:ae,setNodeRef:oe,isDragging:se}=xw(re),q=`drop-${n.kind}-${n.path}`,ce;t[16]===G?ce=t[17]:(ce={destinationFolderPath:G},t[16]=G,t[17]=ce);let le;t[18]!==q||t[19]!==ce||t[20]!==f?(le={id:q,disabled:f,data:ce},t[18]=q,t[19]=ce,t[20]=f,t[21]=le):le=t[21];let{setNodeRef:ue,isOver:de}=Tw(le),fe;t[22]!==c||t[23]!==N||t[24]!==oe||t[25]!==ue?(fe=e=>{oe(e),ue(e),N&&c(e)},t[22]=c,t[23]=N,t[24]=oe,t[25]=ue,t[26]=fe):fe=t[26];let pe=fe,me=de&&K?xT(K,G):``,he=j&&n.isSymlink,ge;t[27]===n?ge=t[28]:(ge=yT(n),t[27]=n,t[28]=ge);let _e=ge,ve;t[29]!==j||t[30]!==n.path||t[31]!==g?(ve=j?()=>{dT(n.path,e=>{g(e)})}:void 0,t[29]=j,t[30]=n.path,t[31]=g,t[32]=ve):ve=t[32];let ye=ve,be;t[33]!==j||t[34]!==n.path?(be=j?()=>{fT(n.path)}:void 0,t[33]=j,t[34]=n.path,t[35]=be):be=t[35];let xe=be,Se=N?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,Ce;t[36]!==z||t[37]!==Se?(Ce=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:Se}),t[36]=z,t[37]=Se,t[38]=Ce):Ce=t[38];let we=N?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,Te;t[39]===we?Te=t[40]:(Te=k(`min-w-0 flex-1 truncate text-sm`,we),t[39]=we,t[40]=Te);let J=n.name+(j?`.md`:``),Ee;t[41]!==Te||t[42]!==J?(Ee=(0,$.jsx)(`span`,{className:Te,children:J}),t[41]=Te,t[42]=J,t[43]=Ee):Ee=t[43];let De;t[44]!==n.canonicalDocName||t[45]!==n.targetPath||t[46]!==he?(De=he&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(ci,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)($e,{side:`right`,className:`text-center leading-relaxed`,children:[`Symlink → `,n.targetPath,(0,$.jsx)(`br`,{}),`Opens the same document as `,n.canonicalDocName]})]}),t[44]=n.canonicalDocName,t[45]=n.targetPath,t[46]=he,t[47]=De):De=t[47];let Oe;t[48]===_e?Oe=t[49]:(Oe=_e&&(0,$.jsx)(Nr,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[48]=_e,t[49]=Oe);let ke;t[50]!==Ce||t[51]!==Ee||t[52]!==De||t[53]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[Ce,Ee,De,Oe]}),t[50]=Ce,t[51]=Ee,t[52]=De,t[53]=Oe,t[54]=ke):ke=t[54];let Ae=ke,je=!D&&`ml-2`,Me=N&&`bg-sidebar-accent text-sidebar-accent-foreground`,Y;t[55]!==je||t[56]!==Me?(Y=k(`flex h-8 items-center gap-2 rounded-md px-2`,je,Me),t[55]=je,t[56]=Me,t[57]=Y):Y=t[57];let Ne;t[58]===z?Ne=t[59]:(Ne=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[58]=z,t[59]=Ne);let Pe=`Rename ${n.kind}`,Fe;t[60]===v?Fe=t[61]:(Fe=e=>v(e.target.value),t[60]=v,t[61]=Fe);let Ie;t[62]!==b||t[63]!==y||t[64]!==U?(Ie=e=>{e.key===`Enter`?(e.preventDefault(),y(U)):e.key===`Escape`&&(e.preventDefault(),b())},t[62]=b,t[63]=y,t[64]=U,t[65]=Ie):Ie=t[65];let Le;t[66]!==u||t[67]!==L||t[68]!==b||t[69]!==Pe||t[70]!==Fe||t[71]!==Ie?(Le=(0,$.jsx)(Mt,{ref:A,value:u,disabled:L,"aria-label":Pe,onBlur:b,onChange:Fe,onKeyDown:Ie,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[66]=u,t[67]=L,t[68]=b,t[69]=Pe,t[70]=Fe,t[71]=Ie,t[72]=Le):Le=t[72];let Re;t[73]===j?Re=t[74]:(Re=j&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[73]=j,t[74]=Re);let ze;t[75]!==Y||t[76]!==Ne||t[77]!==Le||t[78]!==Re?(ze=(0,$.jsxs)(`div`,{className:Y,children:[Ne,Le,Re]}),t[75]=Y,t[76]=Ne,t[77]=Le,t[78]=Re,t[79]=ze):ze=t[79];let Be=P?ze:j?(0,$.jsx)(V,{isActive:N,onClick:()=>h(n.path),className:`cursor-pointer`,"aria-current":N?`page`:void 0,children:Ae}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(V,{isActive:N,className:`w-full cursor-pointer pr-8`,"aria-current":N?`page`:void 0,onClick:()=>h(n.path),children:Ae}),(0,$.jsx)(Hy,{type:`button`,className:k(`top-1`,M&&`rotate-90`),"aria-label":`${M?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":M,onPointerDown:jT,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Lr,{className:`size-4 text-muted-foreground/50`})})]}),Ve=Gw,He=Kw,Ue=k(`rounded-md transition-[opacity,box-shadow] duration-150 ease-out`,se&&`opacity-40`,me),We=!P&&ae,Ge=!P&&ie,Ke;t[80]!==ye||t[81]!==xe||t[82]!==pe||t[83]!==Ue||t[84]!==We||t[85]!==Ge||t[86]!==Be?(Ke=(0,$.jsx)(`div`,{ref:pe,className:Ue,onMouseEnter:ye,onMouseLeave:xe,...We,...Ge,role:`presentation`,tabIndex:void 0,children:Be}),t[80]=ye,t[81]=xe,t[82]=pe,t[83]=Ue,t[84]=We,t[85]=Ge,t[86]=Be,t[87]=Ke):Ke=t[87];let qe;t[88]!==He||t[89]!==Ke?(qe=(0,$.jsx)(He,{asChild:!0,children:Ke}),t[88]=He,t[89]=Ke,t[90]=qe):qe=t[90];let Je;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>{O.current&&(O.current=!1,e.preventDefault())},t[91]=Je):Je=t[91];let Ye;t[92]!==R||t[93]!==j||t[94]!==n||t[95]!==w||t[96]!==C||t[97]!==S?(Ye=!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Yw,{disabled:R,onSelect:()=>{O.current=!0,S(`file`,n.path)},children:[(0,$.jsx)(Pi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)(Yw,{disabled:R,onSelect:()=>{O.current=!0,S(`folder`,n.path)},children:[(0,$.jsx)(ei,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(Qw,{}),(0,$.jsxs)(Yw,{onSelect:()=>C(n),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)(Yw,{onSelect:()=>w(n),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(Qw,{})]}),t[92]=R,t[93]=j,t[94]=n,t[95]=w,t[96]=C,t[97]=S,t[98]=Ye):Ye=t[98];let Xe;t[99]!==_||t[100]!==U?(Xe=()=>{O.current=!0,_(U)},t[99]=_,t[100]=U,t[101]=Xe):Xe=t[101];let Ze;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,$.jsx)(Ft,{"aria-hidden":`true`}),t[102]=Ze):Ze=t[102];let Qe;t[103]!==R||t[104]!==Xe?(Qe=(0,$.jsxs)(Yw,{disabled:R,onSelect:Xe,children:[Ze,`Rename`]}),t[103]=R,t[104]=Xe,t[105]=Qe):Qe=t[105];let et;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsxs)(Xw,{children:[(0,$.jsx)(Gr,{"aria-hidden":`true`}),`Copy Path`]}),t[106]=et):et=t[106];let tt=!p,nt;t[107]!==n||t[108]!==p?(nt=()=>{p&&_T(Sd(p.contentDir,gT(n),p.pathSeparator),`full path`)},t[107]=n,t[108]=p,t[109]=nt):nt=t[109];let rt;t[110]!==tt||t[111]!==nt?(rt=(0,$.jsx)(Yw,{disabled:tt,onSelect:nt,children:`Full Path`}),t[110]=tt,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]===n?it=t[114]:(it=(0,$.jsx)(Yw,{onSelect:()=>{_T(gT(n),`relative path`)},children:`Relative Path`}),t[113]=n,t[114]=it);let at;t[115]!==rt||t[116]!==it?(at=(0,$.jsxs)(qw,{children:[et,(0,$.jsxs)(Zw,{children:[rt,it]})]}),t[115]=rt,t[116]=it,t[117]=at):at=t[117];let st;t[118]!==m||t[119]!==j||t[120]!==n.path||t[121]!==p?(st=j&&(0,$.jsx)(eT,{input:wd({docName:n.path,workspace:p}),installStates:m.installStates,isElectronHost:m.isElectronHost,dispatch:m.dispatch}),t[118]=m,t[119]=j,t[120]=n.path,t[121]=p,t[122]=st):st=t[122];let ct;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(Qw,{}),t[123]=ct):ct=t[123];let lt;t[124]!==x||t[125]!==U?(lt=()=>{x(U)},t[124]=x,t[125]=U,t[126]=lt):lt=t[126];let ut;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(It,{"aria-hidden":`true`}),t[127]=ut):ut=t[127];let dt;t[128]!==R||t[129]!==lt?(dt=(0,$.jsxs)(Yw,{variant:`destructive`,disabled:R,onSelect:lt,children:[ut,`Delete`]}),t[128]=R,t[129]=lt,t[130]=dt):dt=t[130];let ft;t[131]!==Ye||t[132]!==Qe||t[133]!==at||t[134]!==st||t[135]!==dt?(ft=(0,$.jsxs)(Jw,{onCloseAutoFocus:Je,children:[Ye,Qe,at,st,ct,dt]}),t[131]=Ye,t[132]=Qe,t[133]=at,t[134]=st,t[135]=dt,t[136]=ft):ft=t[136];let mt;t[137]!==Ve||t[138]!==qe||t[139]!==ft?(mt=(0,$.jsxs)(Ve,{children:[qe,ft]}),t[137]=Ve,t[138]=qe,t[139]=ft,t[140]=mt):mt=t[140];let ht;t[141]!==c||t[142]!==d||t[143]!==l||t[144]!==u||t[145]!==M||t[146]!==o||t[147]!==E||t[148]!==m||t[149]!==T||t[150]!==n.children||t[151]!==b||t[152]!==w||t[153]!==y||t[154]!==x||t[155]!==v||t[156]!==C||t[157]!==h||t[158]!==S||t[159]!==_||t[160]!==s||t[161]!==g||t[162]!==i||t[163]!==a||t[164]!==f||t[165]!==p?(ht=M&&(n.children.length>0||!!T)&&(0,$.jsxs)(Uy,{className:`mr-0 pr-0`,children:[T&&(0,$.jsx)(Wy,{children:(0,$.jsx)(bT,{...T})}),n.children.map(e=>(0,$.jsx)(CT,{node:e,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:E(e.path),getInlineCreate:E,nested:!0},e.path))]}),t[141]=c,t[142]=d,t[143]=l,t[144]=u,t[145]=M,t[146]=o,t[147]=E,t[148]=m,t[149]=T,t[150]=n.children,t[151]=b,t[152]=w,t[153]=y,t[154]=x,t[155]=v,t[156]=C,t[157]=h,t[158]=S,t[159]=_,t[160]=s,t[161]=g,t[162]=i,t[163]=a,t[164]=f,t[165]=p,t[166]=ht):ht=t[166];let gt;return t[167]!==B||t[168]!==mt||t[169]!==ht?(gt=(0,$.jsxs)(B,{children:[mt,ht]}),t[167]=B,t[168]=mt,t[169]=ht,t[170]=gt):gt=t[170],gt};function wT(e){let t=(0,Q.c)(91),{ref:n}=e,{activeDocName:r,activeTarget:i,closeDocument:a,prewarm:o}=Hn(),{addPage:s}=Se(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(AT),[C,w]=(0,Z.useState)(kT),{selectedFilePath:T,selectedFolderPath:E,navigationPath:D}=Ww(i,r),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(null),B;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(B={activationConstraint:{distance:12}},t[1]=B):B=t[1];let V=vS(_S(bC,B)),[H,U]=(0,Z.useState)(null),{states:W}=Wd(),{dispatch:G}=Nd(),K=typeof window<`u`&&window.okDesktop!=null,ee;t[2]!==G||t[3]!==W?(ee={installStates:W,isElectronHost:K,dispatch:G},t[2]=G,t[3]=W,t[4]=ee):ee=t[4];let te=ee,ne=OT,re,ie;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(DT);e&&(t.ok&&n?.ok?(u(n.documents),m(null)):m(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&m(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&f(!1)});t();let n=()=>{document.visibilityState===`visible`&&t()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=ce(e=>{e.includes(`files`)&&t()});return()=>{e=!1,window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},ie=[],t[5]=re,t[6]=ie):(re=t[5],ie=t[6]),(0,Z.useEffect)(re,ie);let ae,oe;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(ET);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&U({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(TT),()=>{e=!1}},oe=[],t[7]=ae,t[8]=oe):(ae=t[7],oe=t[8]),(0,Z.useEffect)(ae,oe);let se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){j({kind:e,parentDir:t}),N(``),L(null),t&&(S(e=>new Set(e).add(t)),w(e=>{let n=new Set(e);return n.delete(t),n}))},t[9]=se):se=t[9];let le=se,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{S(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),w(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[10]=ue):ue=t[10];let fe=ue,pe;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{w(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),S(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[11]=pe):pe=t[11];let me=pe,he;t[12]===l?he=t[13]:(he=()=>({startCreating:le,expandAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{S(e),w(new Set)})},collapseAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{w(e),S(new Set)})}}),t[12]=l,t[13]=he),(0,Z.useImperativeHandle)(n,he);let ge;t[14]===P?ge=t[15]:(ge=function(){P||(j(null),N(``),L(null))},t[14]=P,t[15]=ge);let ve=ge,ye;t[16]!==s||t[17]!==A||t[18]!==M?(ye=async function(){if(!A)return;let e=M.trim();if(!e){L(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){L(`Invalid name`);return}let t=A.kind===`file`?De(A.parentDir,e):Ne(A.parentDir,e);F(!0),L(null);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})}),n=null;try{n=await e.json()}catch(t){console.warn(`[FileTree] create response JSON parse failed:`,t,`status:`,e.status)}if(!e.ok||!n?.ok){let e=n?.error??`Failed to create ${A.kind}`;X.error(e),L(e),F(!1);return}let r=n.docName??t.replace(/\.md$/,``);j(null),N(``),L(null),F(!1),r&&hT(r),s(r),ze([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),X.error(`Network error — please try again`),L(`Network error — please try again`),F(!1)}},t[16]=s,t[17]=A,t[18]=M,t[19]=ye):ye=t[19];let be=ye,xe;t[20]!==r||t[21]!==a||t[22]!==_?(xe=async function(e){let t=fy(e.kind,_);if(!py(t)){m(`Name must be a single path segment`);return}let n=my(e,t);if(n===e.path){g(null),v(``),m(null);return}b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,i=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),s=await o.json();if(!o.ok||!s.ok){m(s.error??`Failed to rename path`),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=_y(r,c);for(let e of c)a(e.fromDocName);u(e=>hy(e,c)),ze([`files`,`backlinks`,`graph`]),g(null),v(``),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),m(`Network error — please try again`),b(null)}},t[20]=r,t[21]=a,t[22]=_,t[23]=xe):xe=t[23];let Ce=xe,we;t[24]!==r||t[25]!==a||t[26]!==h||t[27]!==k?(we=async function(e){b(e.path),k(null);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),n=await t.json();if(!t.ok||!n.ok){X.error(n.error??`Failed to delete path`),b(null);return}let i=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],o=new Set(i);for(let e of o)a(e);u(e=>gy(e,i)),ze([`files`,`backlinks`,`graph`]),r&&o.has(r)&&(window.location.hash=``),h&&(o.has(h)||e.path===h)&&(g(null),v(``)),b(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),X.error(`Network error — please try again`),b(null)}},t[24]=r,t[25]=a,t[26]=h,t[27]=k,t[28]=we):we=t[28];let Te=we,J;t[29]!==r||t[30]!==a?(J=async function(e,t){let n=Uw(e,t);if(!n.ok){if(n.reason===`no_op`)return;X.error(n.reason===`self`?`Cannot move a folder into itself`:`Cannot move a folder into one of its subfolders`);return}let i=n.destinationPath;b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,n=e.kind===`file`?{docName:e.path,newDocName:i}:{kind:`folder`,fromPath:e.path,toPath:i},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),s=await o.json();if(!o.ok||!s.ok){let e=s.error??`Failed to move`;X.error(e),m(e),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=_y(r,c);for(let e of c)a(e.fromDocName);u(e=>hy(e,c)),ze([`files`,`backlinks`,`graph`]);let d=i.split(`/`).filter(Boolean);d.length>1&&S(e=>{let t=new Set(e);for(let e=0;e<d.length-1;e++)t.add(d.slice(0,e+1).join(`/`));return t}),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),b(null)}},t[29]=r,t[30]=a,t[31]=J):J=t[31];let Ee=J;if(d){let e;return t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`Loading...`})}),t[32]=e):e=t[32],e}if(p&&l.length===0){let e;return t[33]===p?e=t[34]:(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/50`,children:p})}),t[33]=p,t[34]=e),e}if(l.length===0&&!A){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),t[35]=e):e=t[35];let n;return t[36]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>le(`file`,``),children:`Create your first file`})]}),t[36]=n):n=t[36],n}let Oe=l.length>0?de(l):[],ke=Re(Oe),Ae=_e(D),je=new Set(Ae),Me=new Set;for(let e of je)ke.has(e)&&Me.add(e);for(let e of x)ke.has(e)&&Me.add(e);for(let e of C)ke.has(e)&&!je.has(e)&&Me.delete(e);let Y=function(e){if(je.has(e))return;let[t,n]=Me.has(e)?[w,S]:[S,w];t(t=>new Set(t).add(e)),n(t=>{let n=new Set(t);return n.delete(e),n})},Pe;t[37]!==P||t[38]!==I||t[39]!==A||t[40]!==M||t[41]!==ve||t[42]!==be?(Pe=function(e){return!A||A.parentDir!==e?null:{kind:A.kind,value:M,busy:P,error:I,onChange:N,onCommit:()=>void be(),onCancel:ve}},t[37]=P,t[38]=I,t[39]=A,t[40]=M,t[41]=ve,t[42]=be,t[43]=Pe):Pe=t[43];let Fe=Pe,Ie;t[44]===Fe?Ie=t[45]:(Ie=Fe(``),t[44]=Fe,t[45]=Ie);let Le=Ie,Be=y!==null||h!==null||A!==null,Ve=_w,He=kS,Ue;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=e=>{let{active:t}=e;z(t.data.current?.source??null)},t[46]=Ue):Ue=t[46];let We;t[47]===Ee?We=t[48]:(We=e=>{let{active:t,over:n}=e;if(z(null),!n)return;let r=t.data.current?.source,i=n.data.current?.destinationFolderPath;!r||typeof i!=`string`||Ee(r,i)},t[47]=Ee,t[48]=We);let Ge;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>z(null),t[49]=Ge):Ge=t[49];let Ke=pT,qe;t[50]===p?qe=t[51]:(qe=p&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:p}),t[50]=p,t[51]=qe);let Je=Ry,Ye;t[52]===Le?Ye=t[53]:(Ye=Le&&(0,$.jsx)(zy,{children:(0,$.jsx)(bT,{...Le})}),t[52]=Le,t[53]=Ye);let Xe;t[54]===Be?Xe=t[55]:(Xe=(0,$.jsx)(ST,{treeActionsLocked:Be}),t[54]=Be,t[55]=Xe);let Ze=Oe.map(e=>(0,$.jsx)(CT,{node:e,selectedFilePath:T,selectedFolderPath:E,expandedPaths:Me,onToggle:Y,activeRowRef:ne,editingPath:h,editingValue:_,busyPath:y,treeActionsLocked:Be,workspace:H,handoff:te,onNavigate:hT,prewarm:o,onStartRename:e=>{g(e.path),v(e.name),m(null)},onEditingValueChange:v,onCommitRename:e=>void Ce(e),onCancelRename:()=>{y||(g(null),v(``))},onDelete:e=>k(e),onStartCreating:le,onExpandSubtree:fe,onCollapseSubtree:me,inlineCreate:Fe(e.path),getInlineCreate:Fe},e.path)),Qe;t[56]!==Je||t[57]!==Ye||t[58]!==Xe||t[59]!==Ze?(Qe=(0,$.jsxs)(Je,{children:[Ye,Xe,Ze]}),t[56]=Je,t[57]=Ye,t[58]=Xe,t[59]=Ze,t[60]=Qe):Qe=t[60];let $e=!!O,et;t[61]!==y||t[62]!==k?(et=e=>{!e&&!y&&k(null)},t[61]=y,t[62]=k,t[63]=et):et=t[63];let tt;t[64]!==y||t[65]!==O||t[66]!==Te?(tt=O&&(0,$.jsx)(Rw,{itemName:`${O.name}${O.kind===`file`?`.md`:`/`}`,isSubmitting:y===O.path,onDelete:()=>Te(O),customDescription:O.kind===`folder`?`Are you sure you want to delete ${O.name}/ and all files inside? This action cannot be undone.`:void 0}),t[64]=y,t[65]=O,t[66]=Te,t[67]=tt):tt=t[67];let nt;t[68]!==$e||t[69]!==et||t[70]!==tt?(nt=(0,$.jsx)(ln,{open:$e,onOpenChange:et,children:tt}),t[68]=$e,t[69]=et,t[70]=tt,t[71]=nt):nt=t[71];let rt;t[72]===R?rt=t[73]:(rt=R?(0,$.jsxs)(`div`,{className:`pointer-events-none flex max-w-[min(100vw-2rem,280px)] items-center gap-2 rounded-md border border-sidebar-border bg-sidebar px-3 py-1.5 text-sm shadow-lg`,children:[R.kind===`file`?(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sidebar-foreground`,children:[R.name,R.kind===`file`?`.md`:``]})]}):null,t[72]=R,t[73]=rt);let it;t[74]===rt?it=t[75]:(it=(0,$.jsx)(Lw,{dropAnimation:null,children:rt}),t[74]=rt,t[75]=it);let at;t[76]!==R||t[77]!==Ke.Provider||t[78]!==qe||t[79]!==Qe||t[80]!==nt||t[81]!==it?(at=(0,$.jsxs)(Ke.Provider,{value:R,children:[qe,Qe,nt,it]}),t[76]=R,t[77]=Ke.Provider,t[78]=qe,t[79]=Qe,t[80]=nt,t[81]=it,t[82]=at):at=t[82];let ot;return t[83]!==Ve||t[84]!==V||t[85]!==He||t[86]!==Ue||t[87]!==We||t[88]!==Ge||t[89]!==at?(ot=(0,$.jsx)(Ve,{sensors:V,collisionDetection:He,onDragStart:Ue,onDragEnd:We,onDragCancel:Ge,children:at}),t[83]=Ve,t[84]=V,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=at,t[90]=ot):ot=t[90],ot}function TT(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function ET(){return null}function DT(){return null}function OT(e){e&&e.scrollIntoView({block:`nearest`})}function kT(){return new Set}function AT(){return new Set}function jT(e){e.stopPropagation()}function MT(e){let t=(0,Q.c)(13),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a=`update-notice-${n.id}`,o=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,s;t[0]===n.body?s=t[1]:(s=(0,$.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[0]=n.body,t[1]=s);let c;t[2]===n.action?c=t[3]:(c=n.action?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[2]=n.action,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(jt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":a,className:o,children:[s,c,u]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12],d}function NT(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function PT(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Yl,Jl,Jl),n;e[0]===t?n=e[1]:(n=NT(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{ql(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,$.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,$.jsx)(MT,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function FT(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(St,{name:`file-sidebar`,children:(0,$.jsx)(IT,{})}),e[0]=t):t=e[0],t}function IT(){let e=(0,Q.c)(8),t=(0,Z.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}),e[0]=n):n=e[0];let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(ui,{"aria-hidden":`true`})})})}),(0,$.jsx)($e,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(Gg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(Rg,{children:[r,(0,$.jsxs)(Wg,{align:`end`,children:[i,(0,$.jsxs)(Gg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Pi,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Fy,{children:(0,$.jsx)(Ry,{children:(0,$.jsx)(zy,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,o,(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(ei,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ly,{children:(0,$.jsx)(wT,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(My,{variant:`inset`,children:[s,c,(0,$.jsx)(Iy,{children:(0,$.jsx)(PT,{})})]}),e[7]=l):l=e[7],l}function LT(){let e=(0,Q.c)(11),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i,setSystemProvider:a}=Hn(),o=(0,Z.useRef)(n),s=(0,Z.useRef)(r),c,l;e[0]===n?(c=e[1],l=e[2]):(c=()=>{o.current=n},l=[n],e[0]=n,e[1]=c,e[2]=l),(0,Z.useEffect)(c,l);let u=(0,Z.useRef)(null),d,f;e[3]===r?(d=e[4],f=e[5]):(d=()=>{let e=s.current!==null;if(s.current=r,!(e&&r===null)||Date.now()-xn()<3e3)return;let t=u.current?.awareness;if(!t)return;let n=rb(t,Date.now());n&&n!==o.current&&(window.location.hash=me(n))},f=[r],e[3]=r,e[4]=d,e[5]=f),(0,Z.useEffect)(d,f);let p,m;return e[6]!==i||e[7]!==t||e[8]!==a?(p=()=>{if(i===null)return;let e=new Tn,n=new Pn({url:i,name:v,document:e,onStateless:VT,onClose:BT,onDisconnect:zT}),r=ce(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))});n.on(`synced`,RT);let c=null,l=new Set,d=()=>{if(c=null,s.current!==null||Date.now()-xn()<3e3)return;let e=n.awareness;if(!e)return;let t=rb(e,Date.now());t&&t!==o.current&&(window.location.hash=me(t))},f=()=>{if(n.awareness)for(let[e,t]of n.awareness.getStates().entries())l.has(e)||t.user?.type===`agent`&&(l.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`));c!==null&&clearTimeout(c),c=setTimeout(d,300)};return n.awareness?.on(`change`,f),u.current=n,a(n),()=>{r(),c!==null&&clearTimeout(c),n.awareness?.off(`change`,f),a(null),n.destroy(),e.destroy(),u.current=null}},m=[t,i,a],e[6]=i,e[7]=t,e[8]=a,e[9]=p,e[10]=m):(p=e[9],m=e[10]),(0,Z.useEffect)(p,m),null}function RT(){ze([`files`,`backlinks`,`graph`])}function zT(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function BT(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function VT(e){let{payload:t}=e,n=vn(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}ze([n.ch])}function HT(){let t=(0,Q.c)(7),{clearTarget:n}=Hn(),{openTargetTransition:r}=Jt(),{folderPaths:i,loading:a,pages:o}=Se(),s,c;return t[0]!==n||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==o?(s=()=>{t();function t(){let t=Te(window.location.hash);if(!t){bn(`ok/nav/hash-change`,{docName:null,kind:`clear`}),n();return}if(a){bn(`ok/nav/hash-change`,{docName:t,kind:`deferred-loading`});return}let s=e(t,{pages:o,folderPaths:i});bn(`ok/nav/hash-change`,{docName:t,kind:s.kind}),r(s)}return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},c=[n,i,a,r,o],t[0]=n,t[1]=i,t[2]=a,t[3]=r,t[4]=o,t[5]=s,t[6]=c):(s=t[5],c=t[6]),(0,Z.useEffect)(s,c),null}function UT(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=Hn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:re(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Qt({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,$.jsx)(Ct,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function WT(){let e=(0,Q.c)(7),t=typeof window<`u`?window.okDesktop??null:null,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Qd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(LT,{}),i=(0,$.jsx)(HT,{}),a=(0,$.jsx)(UT,{}),o=t?(0,$.jsx)(qd,{bridge:t}):null,e[1]=r,e[2]=i,e[3]=a,e[4]=o):(r=e[1],i=e[2],a=e[3],o=e[4]);let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(FT,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(St,{name:`app`,children:(0,$.jsxs)(un,{children:[n,(0,$.jsxs)(oe,{children:[r,i,a,o,(0,$.jsxs)(ky,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(Py,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(Ax,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Tl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&kl({bridge:window.okDesktop}),Xl(),typeof window<`u`&&Ol({bridge:window.okDesktop});var GT=new br({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),KT=document.getElementById(`root`);if(!KT)throw Error(`Root element not found`);var qT=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Wi.createRoot)(KT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(ae,{client:GT,children:(0,$.jsxs)(K,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(ut,{children:qT&&window.okDesktop?(0,$.jsx)(bl,{bridge:window.okDesktop}):(0,$.jsx)(WT,{})}),(0,$.jsx)(wl,{richColors:!0})]})})}));
|
|
21
|
+
`},_S={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function vS(e){let{announcements:t=_S,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=gS}=e,{announce:a,announcement:o}=fS(),s=Qx(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),mS((0,Z.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=Z.createElement(Z.Fragment,null,Z.createElement(uS,{id:r,value:i.draggable}),Z.createElement(dS,{id:s,announcement:o}));return n?(0,V_.createPortal)(u,n):u}var yS;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(yS||={});function bS(){}function xS(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function SS(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var CS=Object.freeze({x:0,y:0});function wS(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function TS(e,t){let n=aS(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function ES(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function DS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function OS(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function kS(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function AS(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var jS=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=AS(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(DS)};function MS(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var NS=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&MS(r,a)){let n=OS(a).reduce((e,t)=>e+wS(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(ES)};function PS(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function FS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:CS}function IS(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var LS=IS(1);function RS(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function zS(e,t,n){let r=RS(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var BS={ignoreTransform:!1};function VS(e,t){t===void 0&&(t=BS);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=zx(e).getComputedStyle(e);t&&(n=zS(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function HS(e){return VS(e,{ignoreTransform:!0})}function US(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function WS(e,t){return t===void 0&&(t=zx(e).getComputedStyle(e)),t.position===`fixed`}function GS(e,t){t===void 0&&(t=zx(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function KS(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Bx(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Vx(i)||Hx(i)||n.includes(i))return n;let a=zx(e).getComputedStyle(i);return i!==e&&GS(i,a)&&n.push(i),WS(i,a)?n:r(i.parentNode)}return e?r(e):n}function qS(e){let[t]=KS(e,1);return t??null}function JS(e){return!Ix||!e?null:Lx(e)?e:Rx(e)?Bx(e)||e===Ux(e).scrollingElement?window:Vx(e)?e:null:null}function YS(e){return Lx(e)?e.scrollX:e.scrollLeft}function XS(e){return Lx(e)?e.scrollY:e.scrollTop}function ZS(e){return{x:YS(e),y:XS(e)}}var QS;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(QS||={});function $S(e){return!Ix||!e?!1:e===document.scrollingElement}function eC(e){let t={x:0,y:0},n=$S(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var tC={x:.2,y:.2};function nC(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=tC);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=eC(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=QS.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=QS.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=QS.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=QS.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function rC(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function iC(e){return e.reduce((e,t)=>eS(e,ZS(t)),CS)}function aC(e){return e.reduce((e,t)=>e+YS(t),0)}function oC(e){return e.reduce((e,t)=>e+XS(t),0)}function sC(e,t){if(t===void 0&&(t=VS),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);qS(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var cC=[[`x`,[`left`,`right`],aC],[`y`,[`top`,`bottom`],oC]],lC=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=KS(t),r=iC(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of cC)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},uC=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function dC(e){let{EventTarget:t}=zx(e);return e instanceof t?e:Ux(e)}function fC(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var pC;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(pC||={});function mC(e){e.preventDefault()}function hC(e){e.stopPropagation()}var gC;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(gC||={});var _C={start:[gC.Space,gC.Enter],cancel:[gC.Esc],end:[gC.Space,gC.Enter,gC.Tab]},vC=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case gC.Right:return{...n,x:n.x+25};case gC.Left:return{...n,x:n.x-25};case gC.Down:return{...n,y:n.y+25};case gC.Up:return{...n,y:n.y-25}}},yC=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new uC(Ux(t)),this.windowListeners=new uC(zx(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(pC.Resize,this.handleCancel),this.windowListeners.add(pC.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(pC.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&sC(n),t(CS)}handleKeyDown(e){if(rS(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=_C,coordinateGetter:a=vC,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:CS;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=tS(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=eC(n),p=rC(n),m={x:Math.min(i===gC.Right?p.right-p.width/2:p.right,Math.max(i===gC.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===gC.Down?p.bottom-p.height/2:p.bottom,Math.max(i===gC.Down?p.top:p.top+p.height/2,u.y))},h=i===gC.Right&&!s||i===gC.Left&&!c,g=i===gC.Down&&!l||i===gC.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===gC.Right&&e<=d.x||i===gC.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===gC.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===gC.Down&&e<=d.y||i===gC.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===gC.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,eS(tS(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};yC.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=_C,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function bC(e){return!!(e&&`distance`in e)}function xC(e){return!!(e&&`delay`in e)}var SC=class{constructor(e,t,n){n===void 0&&(n=dC(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Ux(i),this.documentListeners=new uC(this.document),this.listeners=new uC(n),this.windowListeners=new uC(zx(i)),this.initialCoordinates=aS(r)??CS,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(pC.Resize,this.handleCancel),this.windowListeners.add(pC.DragStart,mC),this.windowListeners.add(pC.VisibilityChange,this.handleCancel),this.windowListeners.add(pC.ContextMenu,mC),this.documentListeners.add(pC.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(xC(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(bC(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(pC.Click,hC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(pC.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=aS(e)??CS,s=tS(n,o);if(!t&&a){if(bC(a)){if(a.tolerance!=null&&fC(s,a.tolerance))return this.handleCancel();if(fC(s,a.distance))return this.handleStart()}if(xC(a)&&fC(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===gC.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},CC={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},wC=class extends SC{constructor(e){let{event:t}=e,n=Ux(t.target);super(e,CC,n)}};wC.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var TC={move:{name:`mousemove`},end:{name:`mouseup`}},EC;(function(e){e[e.RightClick=2]=`RightClick`})(EC||={});var DC=class extends SC{constructor(e){super(e,TC,Ux(e.event.target))}};DC.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===EC.RightClick?!1:(r?.({event:n}),!0)}}];var OC={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},kC=class extends SC{constructor(e){super(e,OC)}static setup(){return window.addEventListener(OC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(OC.move.name,e)};function e(){}}};kC.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var AC;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(AC||={});var jC;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(jC||={});function MC(e){let{acceleration:t,activator:n=AC.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=jC.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=PC({delta:d,disabled:!a}),[m,h]=Kx(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case AC.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case AC.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,Z.useMemo)(()=>s===jC.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=nC(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var NC={x:{[QS.Backward]:!1,[QS.Forward]:!1},y:{[QS.Backward]:!1,[QS.Forward]:!1}};function PC(e){let{delta:t,disabled:n}=e,r=Xx(t);return Jx(e=>{if(n||!r||!e)return NC;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[QS.Backward]:e.x[QS.Backward]||i.x===-1,[QS.Forward]:e.x[QS.Forward]||i.x===1},y:{[QS.Backward]:e.y[QS.Backward]||i.y===-1,[QS.Forward]:e.y[QS.Forward]||i.y===1}}},[n,t,r])}function FC(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Jx(e=>t==null?null:r??e??null,[r,t])}function IC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var LC;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(LC||={});var RC;(function(e){e.Optimized=`optimized`})(RC||={});var zC=new Map;function BC(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=qx(d),p=(0,Z.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,Z.useRef)(null),h=Jx(t=>{if(d&&!n)return zC;if(!t||t===zC||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new lC(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case LC.Always:return!1;case LC.BeforeDragging:return n;default:return!n}}}function VC(e,t){return Jx(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function HC(e,t){return VC(e,t)}function UC(e){let{callback:t,disabled:n}=e,r=Gx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function WC(e){let{callback:t,disabled:n}=e,r=Gx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function GC(e){return new lC(VS(e),e)}function KC(e,t,n){t===void 0&&(t=GC);let[r,i]=(0,Z.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=UC({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=WC({callback:a});return Wx(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function qC(e){return FS(e,VC(e))}var JC=[];function YC(e){let t=(0,Z.useRef)(e),n=Jx(n=>e?n&&n!==JC&&e&&t.current&&e.parentNode===t.current.parentNode?n:KS(e):JC,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function XC(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=JS(e.target);t&&n(e=>e?(e.set(t,ZS(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=JS(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,ZS(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{JS(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>eS(e,t),CS):iC(e):CS,[e,t])}function ZC(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==CS;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?tS(e,n.current):CS}function QC(e){(0,Z.useEffect)(()=>{if(!Ix)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function $C(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function ew(e){return(0,Z.useMemo)(()=>e?US(e):null,[e])}var tw=[];function nw(e,t){t===void 0&&(t=VS);let[n]=e,r=ew(n?zx(n):null),[i,a]=(0,Z.useState)(tw);function o(){a(()=>e.length?e.map(e=>$S(e)?r:new lC(t(e),e)):tw)}let s=WC({callback:o});return Wx(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function rw(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Vx(t)?t:e}function iw(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=WC({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(Vx(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Yx((0,Z.useCallback)(e=>{let n=rw(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var aw=[{sensor:wC,options:{}},{sensor:yC,options:{}}],ow={current:{}},sw={draggable:{measure:HS},droppable:{measure:HS,strategy:LC.WhileDragging,frequency:RC.Optimized},dragOverlay:{measure:VS}},cw=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},lw={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new cw,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:bS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:sw,measureDroppableContainers:bS,windowRect:null,measuringScheduled:!1},uw={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:bS,draggableNodes:new Map,over:null,measureDroppableContainers:bS},dw=(0,Z.createContext)(uw),fw=(0,Z.createContext)(lw);function pw(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new cw}}}function mw(e,t){switch(t.type){case yS.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case yS.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case yS.DragEnd:case yS.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case yS.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new cw(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case yS.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new cw(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case yS.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new cw(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function hw(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(dw),a=Xx(r),o=Xx(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!rS(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=cS(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function gw(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function _w(e){return(0,Z.useMemo)(()=>({draggable:{...sw.draggable,...e?.draggable},droppable:{...sw.droppable,...e?.droppable},dragOverlay:{...sw.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function vw(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Wx(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=FS(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=qS(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var yw=(0,Z.createContext)({...CS,scaleX:1,scaleY:1}),bw;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(bw||={});var xw=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=aw,collisionDetection:o=jS,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(mw,void 0,pw),[f,p]=hS(),[m,h]=(0,Z.useState)(bw.Uninitialized),g=m===bw.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??ow,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=qx(l,Object.values(l)),A=Qx(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=_w(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=BC(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=FC(v,_),L=(0,Z.useMemo)(()=>D?aS(D):null,[D]),R=xe(),z=HC(I,M.draggable.measure);vw({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=KC(I,M.draggable.measure,z),V=KC(I?I.parentElement:null),H=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),U=b.getNodeFor(H.current.over?.id),W=iw({measure:M.dragOverlay.measure}),G=W.nodeRef.current??I,K=g?W.rect??B:null,ee=!!(W.nodeRef.current&&W.rect),te=qC(ee?null:B),ne=ew(G?zx(G):null),re=YC(g?U??I:null),ie=nw(re),ae=gw(c,{transform:{x:y.x-te.x,y:y.y-te.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:K,over:H.current.over,overlayNodeRect:W.rect,scrollableAncestors:re,scrollableAncestorRects:ie,windowRect:ne}),oe=L?eS(L,y):null,se=XC(re),q=ZC(se),ce=ZC(se,[B]),le=eS(ae,q),ue=K?LS(K,ae):null,de=C&&ue?o({active:C,collisionRect:ue,droppableRects:N,droppableContainers:j,pointerCoordinates:oe}):null,fe=kS(de,`id`),[pe,me]=(0,Z.useState)(null),he=PS(ee?ae:eS(ae,ce),pe?.rect??null,B),ge=(0,Z.useRef)(null),_e=(0,Z.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;ge.current=new n({active:w.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,V_.unstable_batchedUpdates)(()=>{r?.(i),h(bw.Initializing),d({type:yS.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(ge.current),O(a)})},onMove(e){d({type:yS.DragMove,coordinates:e})},onEnd:o(yS.DragEnd),onCancel:o(yS.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===yS.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=yS.DragCancel)}w.current=null,(0,V_.unstable_batchedUpdates)(()=>{d({type:e}),h(bw.Uninitialized),me(null),E(null),O(null),ge.current=null;let t=e===yS.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ve=IC(a,(0,Z.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,_e(n,t))},[v,_e]));QC(a),Wx(()=>{B&&m===bw.Initializing&&h(bw.Initialized)},[B,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:le.x,y:le.y},over:i};(0,V_.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[le.x,le.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(fe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,V_.unstable_batchedUpdates)(()=>{me(s),a?.(c),f({type:`onDragOver`,event:c})})},[fe]),Wx(()=>{H.current={activatorEvent:D,active:C,activeNode:I,collisionRect:ue,collisions:de,droppableRects:N,draggableNodes:v,draggingNode:G,draggingNodeRect:K,droppableContainers:b,over:pe,scrollableAncestors:re,scrollAdjustedTranslate:le},S.current={initial:K,translated:ue}},[C,I,de,ue,v,G,K,N,b,pe,re,le]),MC({...R,delta:y,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:re,scrollableAncestorRects:ie});let ye=(0,Z.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:de,containerNodeRect:V,dragOverlay:W,draggableNodes:v,droppableContainers:b,droppableRects:N,over:pe,measureDroppableContainers:P,scrollableAncestors:re,scrollableAncestorRects:ie,measuringConfiguration:M,measuringScheduled:F,windowRect:ne}),[C,I,B,D,de,V,W,v,b,N,pe,P,re,ie,M,F,ne]),be=(0,Z.useMemo)(()=>({activatorEvent:D,activators:ve,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:pe,measureDroppableContainers:P}),[D,ve,C,B,d,A,v,pe,P]);return Z.createElement(pS.Provider,{value:p},Z.createElement(dw.Provider,{value:be},Z.createElement(fw.Provider,{value:ye},Z.createElement(yw.Provider,{value:he},i)),Z.createElement(hw,{disabled:n?.restoreFocus===!1})),Z.createElement(vS,{...n,hiddenTextDescribedById:A}));function xe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Sw=(0,Z.createContext)(null),Cw=`button`,ww=`Draggable`;function Tw(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Qx(ww),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(dw),{role:p=Cw,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?yw:Sw),[v,y]=Yx(),[b,x]=Yx(),S=$C(o,t),C=qx(n);return Wx(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Cw?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Ew(){return(0,Z.useContext)(fw)}var Dw=`Droppable`,Ow={timeout:25};function kw(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Qx(Dw),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(dw),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Ow,...i},_=qx(h??r),v=WC({callback:(0,Z.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Yx((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=qx(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:yS.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:yS.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:yS.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Aw(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=Xx(n);return!n&&!r&&s&&i(s),Wx(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var jw={x:0,y:0,scaleX:1,scaleY:1};function Mw(e){let{children:t}=e;return Z.createElement(dw.Provider,{value:uw},Z.createElement(yw.Provider,{value:jw},t))}var Nw={position:`fixed`,touchAction:`none`},Pw=e=>rS(e)?`transform 250ms ease`:void 0,Fw=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Pw}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Nw,width:s.width,height:s.height,top:s.top,left:s.left,transform:oS.Transform.toString(d),transformOrigin:i&&r?TS(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Iw={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:oS.Transform.toString(t)},{transform:oS.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Lw(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Gx((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=rw(a);if(!c)return;let{transform:l}=zx(a).getComputedStyle(a),u=RS(l);if(!u)return;let d=typeof t==`function`?t:Rw(t);return sC(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Rw(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Iw,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var zw=0;function Bw(e){return(0,Z.useMemo)(()=>{if(e!=null)return zw++,zw},[e])}var Vw=Z.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Ew(),S=(0,Z.useContext)(yw),C=Bw(d?.id),w=gw(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=VC(f),E=Lw({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(Mw,null,Z.createElement(Aw,{animation:E},d&&C?Z.createElement(Fw,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Hw(e){let t=(0,Q.c)(20),{itemName:n,isSubmitting:r,onDelete:i,customTitle:a,customDescription:o,children:s}=e,c=n===void 0?`this item`:n,l=a??`Delete ${c}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(pn,{children:l}),t[0]=l,t[1]=u);let d=o??`Are you sure you want to delete ${c}? This action cannot be undone.`,f;t[2]===d?f=t[3]:(f=(0,$.jsx)(dn,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,disabled:r,children:`Cancel`})}),t[4]=r,t[5]=p);let m;t[6]===r?m=t[7]:(m=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(an,{className:`size-4 animate-spin`}),` Deleting...`]}):`Delete`,t[6]=r,t[7]=m);let h;t[8]!==r||t[9]!==i||t[10]!==m?(h=(0,$.jsx)(q,{variant:`destructive`,onClick:i,disabled:r,children:m}),t[8]=r,t[9]=i,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==h?(g=(0,$.jsxs)(wn,{children:[p,h]}),t[12]=p,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==s||t[16]!==u||t[17]!==f||t[18]!==g?(_=(0,$.jsxs)(In,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function Uw(e){let t=e.lastIndexOf(`/`);return t<=0?``:e.slice(0,t)}function Ww(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Gw(e,t){return e?`${e}/${t}`:t}function Kw(e,t){return Gw(t,Ww(e.path))}function qw(e,t){if(e.kind===`folder`){if(t===e.path)return{ok:!1,reason:`self`};if(t.length>e.path.length&&t.startsWith(`${e.path}/`))return{ok:!1,reason:`descendant`}}let n=Kw(e,t);return n===e.path?{ok:!1,reason:`no_op`}:{ok:!0,destinationPath:n}}function Jw(e,t){if(!e)return{selectedFilePath:t,selectedFolderPath:null,navigationPath:t};switch(e.kind){case`doc`:return{selectedFilePath:e.docName,selectedFolderPath:null,navigationPath:e.docName};case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function Yw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(vs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function Xw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(ys,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(ws,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function Qw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(bs,{children:(0,$.jsx)(xs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $w(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=k(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,$.jsx)(Ss,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function eT(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Lr,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(Ts,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function tT(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Es,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nT(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Cs,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function rT(e,t,n,r){return e.id===`cursor`&&!n?`Desktop only`:t.installed===null?`Detecting…`:t.installed===!1?`Not installed`:r?`No workspace`:null}function iT(e){let t=(0,Q.c)(8),{input:n,installStates:r,isElectronHost:i,dispatch:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(eT,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=sd.map(e=>{let t=r[e.id],o=Ib({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=rT(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)($w,{disabled:!c,onSelect:()=>{!c||!n||a(e.id,n)},"data-testid":`file-tree-open-in-${e.id}`,"aria-label":u,children:[(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,e.displayName]}),l?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)}),t[1]=a,t[2]=n,t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsxs)(Zw,{children:[o,(0,$.jsx)(tT,{children:s})]}),t[6]=s,t[7]=c),c}var aT=80,oT=3,sT=20,cT=new Map,lT=new Set,uT=[],dT=new Map;function fT(e){for(dT.delete(e),dT.set(e,!0);dT.size>sT;){let e=dT.keys().next().value;if(e===void 0)break;dT.delete(e)}}function pT(e){lT.delete(e),mT()}function mT(){for(;lT.size<oT&&uT.length>0;){let e=uT.shift();if(!e)break;if(!dT.has(e.docName)){lT.add(e.docName),fT(e.docName);try{e.prewarm(e.docName)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{pT(e.docName)}}}}function hT(e,t){if(yn(e)||dT.has(e))return;let n=cT.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(cT.delete(e),lT.size>=oT){uT.push({docName:e,prewarm:t});return}fT(e),lT.add(e);try{t(e)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{pT(e)}},aT);cT.set(e,{timer:r,prewarm:t})}function gT(e){let t=cT.get(e);t&&(clearTimeout(t.timer),cT.delete(e))}var _T=(0,Z.createContext)(null);function vT(){return(0,Z.use)(_T)}function yT(e){window.location.hash=me(e)}function bT(e){return e.kind===`file`?`${e.path}.md`:e.path}async function xT(e,t){try{await navigator.clipboard.writeText(e),X.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),X.error(`Could not copy ${t}`)}}var ST=new Set([`agents`,`agent`,`claude`,`skill`]);function CT(e){return e.kind===`file`&&ST.has(e.name.toLowerCase())}function wT(e){let t=(0,Q.c)(38),{kind:n,value:r,busy:i,error:a,onChange:o,onCommit:s,onCancel:c}=e,l=(0,Z.useRef)(null),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=setTimeout(()=>l.current?.focus(),0);return()=>clearTimeout(e)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,Z.useEffect)(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=k(`flex h-8 items-center gap-2 rounded-md px-2`),t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=n===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[3]=n,t[4]=p);let m=`Create new ${n}`,h=!!a,g=a?`inline-create-error`:void 0,_=n===`folder`?`folder-name`:`file-name`,v=a&&`border-destructive`,y;t[5]===v?y=t[6]:(y=k(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let b;t[7]!==i||t[8]!==a||t[9]!==c?(b=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=b):b=t[10];let x;t[11]===o?x=t[12]:(x=e=>o(e.target.value),t[11]=o,t[12]=x);let S;t[13]!==c||t[14]!==s?(S=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=S):S=t[15];let C;t[16]!==i||t[17]!==y||t[18]!==b||t[19]!==x||t[20]!==S||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(C=(0,$.jsx)(Mt,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:b,onChange:x,onKeyDown:S}),t[16]=i,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=C):C=t[26];let w;t[27]===n?w=t[28]:(w=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=w);let T;t[29]!==C||t[30]!==w||t[31]!==p?(T=(0,$.jsxs)(`div`,{className:f,children:[p,C,w]}),t[29]=C,t[30]=w,t[31]=p,t[32]=T):T=t[32];let E;t[33]===a?E=t[34]:(E=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=E);let D;return t[35]!==T||t[36]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37],D}function TT(e,t){if(!e)return``;let n=qw(e,t);return!n.ok&&(n.reason===`self`||n.reason===`descendant`)?`bg-destructive/20 ring-2 ring-destructive/50`:n.ok?`bg-primary/10 ring-2 ring-primary/40`:``}function ET(e){let t=(0,Q.c)(11),{treeActionsLocked:n}=e,r=vT(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={destinationFolderPath:``},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a={id:`drop-root`,disabled:n,data:i},t[1]=n,t[2]=a);let{setNodeRef:o,isOver:s}=kw(a);if(!r)return null;let c;t[3]!==r||t[4]!==s?(c=s&&TT(r,``),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=k(`flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-xs text-muted-foreground transition-colors`,c),t[6]=c,t[7]=l);let u;return t[8]!==o||t[9]!==l?(u=(0,$.jsx)(zy,{children:(0,$.jsx)(`div`,{ref:o,className:l,children:`Drop here to move to library root`})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}var DT=e=>{let t=(0,Q.c)(171),{node:n,nested:r,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:T,getInlineCreate:E}=e,D=r===void 0?!1:r,O=(0,Z.useRef)(!1),A=(0,Z.useRef)(null),j=n.kind===`file`,M=!j&&o.has(n.path),N=j?n.path===i:n.path===a,P=l===n.path,F,I;t[0]===P?(F=t[1],I=t[2]):(F=()=>{P&&requestAnimationFrame(()=>{let e=A.current;e&&(e.focus(),e.select())})},I=[P],t[0]=P,t[1]=F,t[2]=I),(0,Z.useEffect)(F,I);let L=d===n.path,R=d!==null,z=j?Nn:M?Dn:ti,B=D?Wy:zy,V=D?Gy:Vy,H;t[3]!==n.kind||t[4]!==n.name||t[5]!==n.path?(H={kind:n.kind,path:n.path,name:n.name},t[3]=n.kind,t[4]=n.name,t[5]=n.path,t[6]=H):H=t[6];let U=H,W;t[7]!==j||t[8]!==n.path?(W=j?Uw(n.path):n.path,t[7]=j,t[8]=n.path,t[9]=W):W=t[9];let G=W,K=vT(),ee=`drag-${n.kind}-${n.path}`,te=f||P,ne;t[10]===U?ne=t[11]:(ne={source:U},t[10]=U,t[11]=ne);let re;t[12]!==ee||t[13]!==te||t[14]!==ne?(re={id:ee,disabled:te,data:ne},t[12]=ee,t[13]=te,t[14]=ne,t[15]=re):re=t[15];let{attributes:ie,listeners:ae,setNodeRef:oe,isDragging:se}=Tw(re),q=`drop-${n.kind}-${n.path}`,ce;t[16]===G?ce=t[17]:(ce={destinationFolderPath:G},t[16]=G,t[17]=ce);let le;t[18]!==q||t[19]!==ce||t[20]!==f?(le={id:q,disabled:f,data:ce},t[18]=q,t[19]=ce,t[20]=f,t[21]=le):le=t[21];let{setNodeRef:ue,isOver:de}=kw(le),fe;t[22]!==c||t[23]!==N||t[24]!==oe||t[25]!==ue?(fe=e=>{oe(e),ue(e),N&&c(e)},t[22]=c,t[23]=N,t[24]=oe,t[25]=ue,t[26]=fe):fe=t[26];let pe=fe,me=de&&K?TT(K,G):``,he=j&&n.isSymlink,ge;t[27]===n?ge=t[28]:(ge=CT(n),t[27]=n,t[28]=ge);let _e=ge,ve;t[29]!==j||t[30]!==n.path||t[31]!==g?(ve=j?()=>{hT(n.path,e=>{g(e)})}:void 0,t[29]=j,t[30]=n.path,t[31]=g,t[32]=ve):ve=t[32];let ye=ve,be;t[33]!==j||t[34]!==n.path?(be=j?()=>{gT(n.path)}:void 0,t[33]=j,t[34]=n.path,t[35]=be):be=t[35];let xe=be,Se=N?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,Ce;t[36]!==z||t[37]!==Se?(Ce=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:Se}),t[36]=z,t[37]=Se,t[38]=Ce):Ce=t[38];let we=N?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,Te;t[39]===we?Te=t[40]:(Te=k(`min-w-0 flex-1 truncate text-sm`,we),t[39]=we,t[40]=Te);let J=n.name+(j?`.md`:``),Ee;t[41]!==Te||t[42]!==J?(Ee=(0,$.jsx)(`span`,{className:Te,children:J}),t[41]=Te,t[42]=J,t[43]=Ee):Ee=t[43];let De;t[44]!==n.canonicalDocName||t[45]!==n.targetPath||t[46]!==he?(De=he&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(ci,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)($e,{side:`right`,className:`text-center leading-relaxed`,children:[`Symlink → `,n.targetPath,(0,$.jsx)(`br`,{}),`Opens the same document as `,n.canonicalDocName]})]}),t[44]=n.canonicalDocName,t[45]=n.targetPath,t[46]=he,t[47]=De):De=t[47];let Oe;t[48]===_e?Oe=t[49]:(Oe=_e&&(0,$.jsx)(Nr,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[48]=_e,t[49]=Oe);let ke;t[50]!==Ce||t[51]!==Ee||t[52]!==De||t[53]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[Ce,Ee,De,Oe]}),t[50]=Ce,t[51]=Ee,t[52]=De,t[53]=Oe,t[54]=ke):ke=t[54];let Ae=ke,je=!D&&`ml-2`,Me=N&&`bg-sidebar-accent text-sidebar-accent-foreground`,Y;t[55]!==je||t[56]!==Me?(Y=k(`flex h-8 items-center gap-2 rounded-md px-2`,je,Me),t[55]=je,t[56]=Me,t[57]=Y):Y=t[57];let Ne;t[58]===z?Ne=t[59]:(Ne=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[58]=z,t[59]=Ne);let Pe=`Rename ${n.kind}`,Fe;t[60]===v?Fe=t[61]:(Fe=e=>v(e.target.value),t[60]=v,t[61]=Fe);let Ie;t[62]!==b||t[63]!==y||t[64]!==U?(Ie=e=>{e.key===`Enter`?(e.preventDefault(),y(U)):e.key===`Escape`&&(e.preventDefault(),b())},t[62]=b,t[63]=y,t[64]=U,t[65]=Ie):Ie=t[65];let Le;t[66]!==u||t[67]!==L||t[68]!==b||t[69]!==Pe||t[70]!==Fe||t[71]!==Ie?(Le=(0,$.jsx)(Mt,{ref:A,value:u,disabled:L,"aria-label":Pe,onBlur:b,onChange:Fe,onKeyDown:Ie,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[66]=u,t[67]=L,t[68]=b,t[69]=Pe,t[70]=Fe,t[71]=Ie,t[72]=Le):Le=t[72];let Re;t[73]===j?Re=t[74]:(Re=j&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[73]=j,t[74]=Re);let ze;t[75]!==Y||t[76]!==Ne||t[77]!==Le||t[78]!==Re?(ze=(0,$.jsxs)(`div`,{className:Y,children:[Ne,Le,Re]}),t[75]=Y,t[76]=Ne,t[77]=Le,t[78]=Re,t[79]=ze):ze=t[79];let Be=P?ze:j?(0,$.jsx)(V,{isActive:N,onClick:()=>h(n.path),className:`cursor-pointer`,"aria-current":N?`page`:void 0,children:Ae}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(V,{isActive:N,className:`w-full cursor-pointer pr-8`,"aria-current":N?`page`:void 0,onClick:()=>h(n.path),children:Ae}),(0,$.jsx)(Hy,{type:`button`,className:k(`top-1`,M&&`rotate-90`),"aria-label":`${M?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":M,onPointerDown:FT,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Lr,{className:`size-4 text-muted-foreground/50`})})]}),Ve=Yw,He=Xw,Ue=k(`rounded-md transition-[opacity,box-shadow] duration-150 ease-out`,se&&`opacity-40`,me),We=!P&&ae,Ge=!P&&ie,Ke;t[80]!==ye||t[81]!==xe||t[82]!==pe||t[83]!==Ue||t[84]!==We||t[85]!==Ge||t[86]!==Be?(Ke=(0,$.jsx)(`div`,{ref:pe,className:Ue,onMouseEnter:ye,onMouseLeave:xe,...We,...Ge,role:`presentation`,tabIndex:void 0,children:Be}),t[80]=ye,t[81]=xe,t[82]=pe,t[83]=Ue,t[84]=We,t[85]=Ge,t[86]=Be,t[87]=Ke):Ke=t[87];let qe;t[88]!==He||t[89]!==Ke?(qe=(0,$.jsx)(He,{asChild:!0,children:Ke}),t[88]=He,t[89]=Ke,t[90]=qe):qe=t[90];let Je;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>{O.current&&(O.current=!1,e.preventDefault())},t[91]=Je):Je=t[91];let Ye;t[92]!==R||t[93]!==j||t[94]!==n||t[95]!==w||t[96]!==C||t[97]!==S?(Ye=!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)($w,{disabled:R,onSelect:()=>{O.current=!0,S(`file`,n.path)},children:[(0,$.jsx)(Pi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)($w,{disabled:R,onSelect:()=>{O.current=!0,S(`folder`,n.path)},children:[(0,$.jsx)(ei,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(nT,{}),(0,$.jsxs)($w,{onSelect:()=>C(n),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)($w,{onSelect:()=>w(n),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(nT,{})]}),t[92]=R,t[93]=j,t[94]=n,t[95]=w,t[96]=C,t[97]=S,t[98]=Ye):Ye=t[98];let Xe;t[99]!==_||t[100]!==U?(Xe=()=>{O.current=!0,_(U)},t[99]=_,t[100]=U,t[101]=Xe):Xe=t[101];let Ze;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,$.jsx)(Ft,{"aria-hidden":`true`}),t[102]=Ze):Ze=t[102];let Qe;t[103]!==R||t[104]!==Xe?(Qe=(0,$.jsxs)($w,{disabled:R,onSelect:Xe,children:[Ze,`Rename`]}),t[103]=R,t[104]=Xe,t[105]=Qe):Qe=t[105];let et;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsxs)(eT,{children:[(0,$.jsx)(Gr,{"aria-hidden":`true`}),`Copy Path`]}),t[106]=et):et=t[106];let tt=!p,nt;t[107]!==n||t[108]!==p?(nt=()=>{p&&xT(Sd(p.contentDir,bT(n),p.pathSeparator),`full path`)},t[107]=n,t[108]=p,t[109]=nt):nt=t[109];let rt;t[110]!==tt||t[111]!==nt?(rt=(0,$.jsx)($w,{disabled:tt,onSelect:nt,children:`Full Path`}),t[110]=tt,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]===n?it=t[114]:(it=(0,$.jsx)($w,{onSelect:()=>{xT(bT(n),`relative path`)},children:`Relative Path`}),t[113]=n,t[114]=it);let at;t[115]!==rt||t[116]!==it?(at=(0,$.jsxs)(Zw,{children:[et,(0,$.jsxs)(tT,{children:[rt,it]})]}),t[115]=rt,t[116]=it,t[117]=at):at=t[117];let st;t[118]!==m||t[119]!==j||t[120]!==n.path||t[121]!==p?(st=j&&(0,$.jsx)(iT,{input:wd({docName:n.path,workspace:p}),installStates:m.installStates,isElectronHost:m.isElectronHost,dispatch:m.dispatch}),t[118]=m,t[119]=j,t[120]=n.path,t[121]=p,t[122]=st):st=t[122];let ct;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(nT,{}),t[123]=ct):ct=t[123];let lt;t[124]!==x||t[125]!==U?(lt=()=>{x(U)},t[124]=x,t[125]=U,t[126]=lt):lt=t[126];let ut;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(It,{"aria-hidden":`true`}),t[127]=ut):ut=t[127];let dt;t[128]!==R||t[129]!==lt?(dt=(0,$.jsxs)($w,{variant:`destructive`,disabled:R,onSelect:lt,children:[ut,`Delete`]}),t[128]=R,t[129]=lt,t[130]=dt):dt=t[130];let ft;t[131]!==Ye||t[132]!==Qe||t[133]!==at||t[134]!==st||t[135]!==dt?(ft=(0,$.jsxs)(Qw,{onCloseAutoFocus:Je,children:[Ye,Qe,at,st,ct,dt]}),t[131]=Ye,t[132]=Qe,t[133]=at,t[134]=st,t[135]=dt,t[136]=ft):ft=t[136];let mt;t[137]!==Ve||t[138]!==qe||t[139]!==ft?(mt=(0,$.jsxs)(Ve,{children:[qe,ft]}),t[137]=Ve,t[138]=qe,t[139]=ft,t[140]=mt):mt=t[140];let ht;t[141]!==c||t[142]!==d||t[143]!==l||t[144]!==u||t[145]!==M||t[146]!==o||t[147]!==E||t[148]!==m||t[149]!==T||t[150]!==n.children||t[151]!==b||t[152]!==w||t[153]!==y||t[154]!==x||t[155]!==v||t[156]!==C||t[157]!==h||t[158]!==S||t[159]!==_||t[160]!==s||t[161]!==g||t[162]!==i||t[163]!==a||t[164]!==f||t[165]!==p?(ht=M&&(n.children.length>0||!!T)&&(0,$.jsxs)(Uy,{className:`mr-0 pr-0`,children:[T&&(0,$.jsx)(Wy,{children:(0,$.jsx)(wT,{...T})}),n.children.map(e=>(0,$.jsx)(DT,{node:e,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:E(e.path),getInlineCreate:E,nested:!0},e.path))]}),t[141]=c,t[142]=d,t[143]=l,t[144]=u,t[145]=M,t[146]=o,t[147]=E,t[148]=m,t[149]=T,t[150]=n.children,t[151]=b,t[152]=w,t[153]=y,t[154]=x,t[155]=v,t[156]=C,t[157]=h,t[158]=S,t[159]=_,t[160]=s,t[161]=g,t[162]=i,t[163]=a,t[164]=f,t[165]=p,t[166]=ht):ht=t[166];let gt;return t[167]!==B||t[168]!==mt||t[169]!==ht?(gt=(0,$.jsxs)(B,{children:[mt,ht]}),t[167]=B,t[168]=mt,t[169]=ht,t[170]=gt):gt=t[170],gt};function OT(e){let t=(0,Q.c)(91),{ref:n}=e,{activeDocName:r,activeTarget:i,closeDocument:a,prewarm:o}=Hn(),{addPage:s}=Se(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(PT),[C,w]=(0,Z.useState)(NT),{selectedFilePath:T,selectedFolderPath:E,navigationPath:D}=Jw(i,r),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(null),B;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(B={activationConstraint:{distance:12}},t[1]=B):B=t[1];let V=SS(xS(wC,B)),[H,U]=(0,Z.useState)(null),{states:W}=Wd(),{dispatch:G}=Nd(),K=typeof window<`u`&&window.okDesktop!=null,ee;t[2]!==G||t[3]!==W?(ee={installStates:W,isElectronHost:K,dispatch:G},t[2]=G,t[3]=W,t[4]=ee):ee=t[4];let te=ee,ne=MT,re,ie;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(jT);e&&(t.ok&&n?.ok?(u(n.documents),m(null)):m(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&m(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&f(!1)});t();let n=()=>{document.visibilityState===`visible`&&t()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=ce(e=>{e.includes(`files`)&&t()});return()=>{e=!1,window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},ie=[],t[5]=re,t[6]=ie):(re=t[5],ie=t[6]),(0,Z.useEffect)(re,ie);let ae,oe;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(AT);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&U({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(kT),()=>{e=!1}},oe=[],t[7]=ae,t[8]=oe):(ae=t[7],oe=t[8]),(0,Z.useEffect)(ae,oe);let se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){j({kind:e,parentDir:t}),N(``),L(null),t&&(S(e=>new Set(e).add(t)),w(e=>{let n=new Set(e);return n.delete(t),n}))},t[9]=se):se=t[9];let le=se,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{S(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),w(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[10]=ue):ue=t[10];let fe=ue,pe;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{w(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),S(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[11]=pe):pe=t[11];let me=pe,he;t[12]===l?he=t[13]:(he=()=>({startCreating:le,expandAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{S(e),w(new Set)})},collapseAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{w(e),S(new Set)})}}),t[12]=l,t[13]=he),(0,Z.useImperativeHandle)(n,he);let ge;t[14]===P?ge=t[15]:(ge=function(){P||(j(null),N(``),L(null))},t[14]=P,t[15]=ge);let ve=ge,ye;t[16]!==s||t[17]!==A||t[18]!==M?(ye=async function(){if(!A)return;let e=M.trim();if(!e){L(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){L(`Invalid name`);return}let t=A.kind===`file`?De(A.parentDir,e):Ne(A.parentDir,e);F(!0),L(null);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})}),n=null;try{n=await e.json()}catch(t){console.warn(`[FileTree] create response JSON parse failed:`,t,`status:`,e.status)}if(!e.ok||!n?.ok){let e=n?.error??`Failed to create ${A.kind}`;X.error(e),L(e),F(!1);return}let r=n.docName??t.replace(/\.md$/,``);j(null),N(``),L(null),F(!1),r&&yT(r),s(r),ze([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),X.error(`Network error — please try again`),L(`Network error — please try again`),F(!1)}},t[16]=s,t[17]=A,t[18]=M,t[19]=ye):ye=t[19];let be=ye,xe;t[20]!==r||t[21]!==a||t[22]!==_?(xe=async function(e){let t=fy(e.kind,_);if(!py(t)){m(`Name must be a single path segment`);return}let n=my(e,t);if(n===e.path){g(null),v(``),m(null);return}b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,i=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),s=await o.json();if(!o.ok||!s.ok){m(s.error??`Failed to rename path`),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=_y(r,c);for(let e of c)a(e.fromDocName);u(e=>hy(e,c)),ze([`files`,`backlinks`,`graph`]),g(null),v(``),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),m(`Network error — please try again`),b(null)}},t[20]=r,t[21]=a,t[22]=_,t[23]=xe):xe=t[23];let Ce=xe,we;t[24]!==r||t[25]!==a||t[26]!==h||t[27]!==k?(we=async function(e){b(e.path),k(null);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),n=await t.json();if(!t.ok||!n.ok){X.error(n.error??`Failed to delete path`),b(null);return}let i=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],o=new Set(i);for(let e of o)a(e);u(e=>gy(e,i)),ze([`files`,`backlinks`,`graph`]),r&&o.has(r)&&(window.location.hash=``),h&&(o.has(h)||e.path===h)&&(g(null),v(``)),b(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),X.error(`Network error — please try again`),b(null)}},t[24]=r,t[25]=a,t[26]=h,t[27]=k,t[28]=we):we=t[28];let Te=we,J;t[29]!==r||t[30]!==a?(J=async function(e,t){let n=qw(e,t);if(!n.ok){if(n.reason===`no_op`)return;X.error(n.reason===`self`?`Cannot move a folder into itself`:`Cannot move a folder into one of its subfolders`);return}let i=n.destinationPath;b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,n=e.kind===`file`?{docName:e.path,newDocName:i}:{kind:`folder`,fromPath:e.path,toPath:i},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),s=await o.json();if(!o.ok||!s.ok){let e=s.error??`Failed to move`;X.error(e),m(e),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=_y(r,c);for(let e of c)a(e.fromDocName);u(e=>hy(e,c)),ze([`files`,`backlinks`,`graph`]);let d=i.split(`/`).filter(Boolean);d.length>1&&S(e=>{let t=new Set(e);for(let e=0;e<d.length-1;e++)t.add(d.slice(0,e+1).join(`/`));return t}),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),b(null)}},t[29]=r,t[30]=a,t[31]=J):J=t[31];let Ee=J;if(d){let e;return t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`Loading...`})}),t[32]=e):e=t[32],e}if(p&&l.length===0){let e;return t[33]===p?e=t[34]:(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/50`,children:p})}),t[33]=p,t[34]=e),e}if(l.length===0&&!A){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),t[35]=e):e=t[35];let n;return t[36]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>le(`file`,``),children:`Create your first file`})]}),t[36]=n):n=t[36],n}let Oe=l.length>0?de(l):[],ke=Re(Oe),Ae=_e(D),je=new Set(Ae),Me=new Set;for(let e of je)ke.has(e)&&Me.add(e);for(let e of x)ke.has(e)&&Me.add(e);for(let e of C)ke.has(e)&&!je.has(e)&&Me.delete(e);let Y=function(e){if(je.has(e))return;let[t,n]=Me.has(e)?[w,S]:[S,w];t(t=>new Set(t).add(e)),n(t=>{let n=new Set(t);return n.delete(e),n})},Pe;t[37]!==P||t[38]!==I||t[39]!==A||t[40]!==M||t[41]!==ve||t[42]!==be?(Pe=function(e){return!A||A.parentDir!==e?null:{kind:A.kind,value:M,busy:P,error:I,onChange:N,onCommit:()=>void be(),onCancel:ve}},t[37]=P,t[38]=I,t[39]=A,t[40]=M,t[41]=ve,t[42]=be,t[43]=Pe):Pe=t[43];let Fe=Pe,Ie;t[44]===Fe?Ie=t[45]:(Ie=Fe(``),t[44]=Fe,t[45]=Ie);let Le=Ie,Be=y!==null||h!==null||A!==null,Ve=xw,He=NS,Ue;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=e=>{let{active:t}=e;z(t.data.current?.source??null)},t[46]=Ue):Ue=t[46];let We;t[47]===Ee?We=t[48]:(We=e=>{let{active:t,over:n}=e;if(z(null),!n)return;let r=t.data.current?.source,i=n.data.current?.destinationFolderPath;!r||typeof i!=`string`||Ee(r,i)},t[47]=Ee,t[48]=We);let Ge;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>z(null),t[49]=Ge):Ge=t[49];let Ke=_T,qe;t[50]===p?qe=t[51]:(qe=p&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:p}),t[50]=p,t[51]=qe);let Je=Ry,Ye;t[52]===Le?Ye=t[53]:(Ye=Le&&(0,$.jsx)(zy,{children:(0,$.jsx)(wT,{...Le})}),t[52]=Le,t[53]=Ye);let Xe;t[54]===Be?Xe=t[55]:(Xe=(0,$.jsx)(ET,{treeActionsLocked:Be}),t[54]=Be,t[55]=Xe);let Ze=Oe.map(e=>(0,$.jsx)(DT,{node:e,selectedFilePath:T,selectedFolderPath:E,expandedPaths:Me,onToggle:Y,activeRowRef:ne,editingPath:h,editingValue:_,busyPath:y,treeActionsLocked:Be,workspace:H,handoff:te,onNavigate:yT,prewarm:o,onStartRename:e=>{g(e.path),v(e.name),m(null)},onEditingValueChange:v,onCommitRename:e=>void Ce(e),onCancelRename:()=>{y||(g(null),v(``))},onDelete:e=>k(e),onStartCreating:le,onExpandSubtree:fe,onCollapseSubtree:me,inlineCreate:Fe(e.path),getInlineCreate:Fe},e.path)),Qe;t[56]!==Je||t[57]!==Ye||t[58]!==Xe||t[59]!==Ze?(Qe=(0,$.jsxs)(Je,{children:[Ye,Xe,Ze]}),t[56]=Je,t[57]=Ye,t[58]=Xe,t[59]=Ze,t[60]=Qe):Qe=t[60];let $e=!!O,et;t[61]!==y||t[62]!==k?(et=e=>{!e&&!y&&k(null)},t[61]=y,t[62]=k,t[63]=et):et=t[63];let tt;t[64]!==y||t[65]!==O||t[66]!==Te?(tt=O&&(0,$.jsx)(Hw,{itemName:`${O.name}${O.kind===`file`?`.md`:`/`}`,isSubmitting:y===O.path,onDelete:()=>Te(O),customDescription:O.kind===`folder`?`Are you sure you want to delete ${O.name}/ and all files inside? This action cannot be undone.`:void 0}),t[64]=y,t[65]=O,t[66]=Te,t[67]=tt):tt=t[67];let nt;t[68]!==$e||t[69]!==et||t[70]!==tt?(nt=(0,$.jsx)(ln,{open:$e,onOpenChange:et,children:tt}),t[68]=$e,t[69]=et,t[70]=tt,t[71]=nt):nt=t[71];let rt;t[72]===R?rt=t[73]:(rt=R?(0,$.jsxs)(`div`,{className:`pointer-events-none flex max-w-[min(100vw-2rem,280px)] items-center gap-2 rounded-md border border-sidebar-border bg-sidebar px-3 py-1.5 text-sm shadow-lg`,children:[R.kind===`file`?(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sidebar-foreground`,children:[R.name,R.kind===`file`?`.md`:``]})]}):null,t[72]=R,t[73]=rt);let it;t[74]===rt?it=t[75]:(it=(0,$.jsx)(Vw,{dropAnimation:null,children:rt}),t[74]=rt,t[75]=it);let at;t[76]!==R||t[77]!==Ke.Provider||t[78]!==qe||t[79]!==Qe||t[80]!==nt||t[81]!==it?(at=(0,$.jsxs)(Ke.Provider,{value:R,children:[qe,Qe,nt,it]}),t[76]=R,t[77]=Ke.Provider,t[78]=qe,t[79]=Qe,t[80]=nt,t[81]=it,t[82]=at):at=t[82];let ot;return t[83]!==Ve||t[84]!==V||t[85]!==He||t[86]!==Ue||t[87]!==We||t[88]!==Ge||t[89]!==at?(ot=(0,$.jsx)(Ve,{sensors:V,collisionDetection:He,onDragStart:Ue,onDragEnd:We,onDragCancel:Ge,children:at}),t[83]=Ve,t[84]=V,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=at,t[90]=ot):ot=t[90],ot}function kT(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function AT(){return null}function jT(){return null}function MT(e){e&&e.scrollIntoView({block:`nearest`})}function NT(){return new Set}function PT(){return new Set}function FT(e){e.stopPropagation()}function IT(e){let t=(0,Q.c)(13),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a=`update-notice-${n.id}`,o=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,s;t[0]===n.body?s=t[1]:(s=(0,$.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[0]=n.body,t[1]=s);let c;t[2]===n.action?c=t[3]:(c=n.action?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[2]=n.action,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(jt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":a,className:o,children:[s,c,u]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12],d}function LT(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function RT(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Yl,Jl,Jl),n;e[0]===t?n=e[1]:(n=LT(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{ql(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,$.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,$.jsx)(IT,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function zT(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(St,{name:`file-sidebar`,children:(0,$.jsx)(BT,{})}),e[0]=t):t=e[0],t}function BT(){let e=(0,Q.c)(8),t=(0,Z.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}),e[0]=n):n=e[0];let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(zg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(ui,{"aria-hidden":`true`})})})}),(0,$.jsx)($e,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(Gg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(Rg,{children:[r,(0,$.jsxs)(Wg,{align:`end`,children:[i,(0,$.jsxs)(Gg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Pi,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Fy,{children:(0,$.jsx)(Ry,{children:(0,$.jsx)(zy,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,o,(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(ei,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Ly,{children:(0,$.jsx)(OT,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(My,{variant:`inset`,children:[s,c,(0,$.jsx)(Iy,{children:(0,$.jsx)(RT,{})})]}),e[7]=l):l=e[7],l}function VT(){let e=(0,Q.c)(11),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i,setSystemProvider:a}=Hn(),o=(0,Z.useRef)(n),s=(0,Z.useRef)(r),c,l;e[0]===n?(c=e[1],l=e[2]):(c=()=>{o.current=n},l=[n],e[0]=n,e[1]=c,e[2]=l),(0,Z.useEffect)(c,l);let u=(0,Z.useRef)(null),d,f;e[3]===r?(d=e[4],f=e[5]):(d=()=>{let e=s.current!==null;if(s.current=r,!(e&&r===null)||Date.now()-xn()<3e3)return;let t=u.current?.awareness;if(!t)return;let n=rb(t,Date.now());n&&n!==o.current&&(window.location.hash=me(n))},f=[r],e[3]=r,e[4]=d,e[5]=f),(0,Z.useEffect)(d,f);let p,m;return e[6]!==i||e[7]!==t||e[8]!==a?(p=()=>{if(i===null)return;let e=new Tn,n=new Pn({url:i,name:v,document:e,onStateless:GT,onClose:WT,onDisconnect:UT}),r=ce(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))});n.on(`synced`,HT);let c=null,l=new Set,d=()=>{if(c=null,s.current!==null||Date.now()-xn()<3e3)return;let e=n.awareness;if(!e)return;let t=rb(e,Date.now());t&&t!==o.current&&(window.location.hash=me(t))},f=()=>{if(n.awareness)for(let[e,t]of n.awareness.getStates().entries())l.has(e)||t.user?.type===`agent`&&(l.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`));c!==null&&clearTimeout(c),c=setTimeout(d,300)};return n.awareness?.on(`change`,f),u.current=n,a(n),()=>{r(),c!==null&&clearTimeout(c),n.awareness?.off(`change`,f),a(null),n.destroy(),e.destroy(),u.current=null}},m=[t,i,a],e[6]=i,e[7]=t,e[8]=a,e[9]=p,e[10]=m):(p=e[9],m=e[10]),(0,Z.useEffect)(p,m),null}function HT(){ze([`files`,`backlinks`,`graph`])}function UT(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function WT(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function GT(e){let{payload:t}=e,n=vn(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}ze([n.ch])}function KT(){let t=(0,Q.c)(7),{clearTarget:n}=Hn(),{openTargetTransition:r}=Jt(),{folderPaths:i,loading:a,pages:o}=Se(),s,c;return t[0]!==n||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==o?(s=()=>{t();function t(){let t=Te(window.location.hash);if(!t){bn(`ok/nav/hash-change`,{docName:null,kind:`clear`}),n();return}if(a){bn(`ok/nav/hash-change`,{docName:t,kind:`deferred-loading`});return}let s=e(t,{pages:o,folderPaths:i});bn(`ok/nav/hash-change`,{docName:t,kind:s.kind}),r(s)}return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},c=[n,i,a,r,o],t[0]=n,t[1]=i,t[2]=a,t[3]=r,t[4]=o,t[5]=s,t[6]=c):(s=t[5],c=t[6]),(0,Z.useEffect)(s,c),null}function qT(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=Hn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:re(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Qt({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,$.jsx)(Ct,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function JT(){let e=(0,Q.c)(7),t=typeof window<`u`?window.okDesktop??null:null,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Qd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(VT,{}),i=(0,$.jsx)(KT,{}),a=(0,$.jsx)(qT,{}),o=t?(0,$.jsx)(qd,{bridge:t}):null,e[1]=r,e[2]=i,e[3]=a,e[4]=o):(r=e[1],i=e[2],a=e[3],o=e[4]);let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(zT,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(St,{name:`app`,children:(0,$.jsxs)(un,{children:[n,(0,$.jsxs)(oe,{children:[r,i,a,o,(0,$.jsxs)(ky,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(Py,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(Px,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Tl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&kl({bridge:window.okDesktop}),Xl(),typeof window<`u`&&Ol({bridge:window.okDesktop});var YT=new br({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),XT=document.getElementById(`root`);if(!XT)throw Error(`Root element not found`);var ZT=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Wi.createRoot)(XT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(ae,{client:YT,children:(0,$.jsxs)(K,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(ut,{children:ZT&&window.okDesktop?(0,$.jsx)(bl,{bridge:window.okDesktop}):(0,$.jsx)(JT,{})}),(0,$.jsx)(wl,{richColors:!0})]})})}));
|