@inkeep/open-knowledge 0.0.0-dev-20260422173457 → 0.0.0-dev-20260422182234
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 +4 -4
- package/dist/constants-DUGdkv1q.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-B-dtqUrZ.mjs → init-BK32KR4U.mjs} +2 -2
- package/dist/init-CcDHvVnS.mjs +1 -0
- package/dist/{init-DwAB_xuh.mjs → init-CmWGaCB6.mjs} +1 -1
- package/dist/{init-DZ9zW_3F.mjs → init-D1w1wVpK.mjs} +3 -3
- package/dist/loader-1i_rsm33.mjs +1 -0
- package/dist/{loader-CnFGM2kz.mjs → loader-Dhl0X1BZ.mjs} +2 -2
- package/dist/{paths-BvevnJPJ.mjs → paths-DJK330_s.mjs} +2 -2
- package/dist/paths-PoU3f044.mjs +1 -0
- package/dist/preview-B1UvQUQF.mjs +1 -0
- package/dist/{preview-Mt4N85Jg.mjs → preview-CltqVQj4.mjs} +2 -2
- package/dist/public/assets/index-DGQHaqKr.css +1 -0
- package/dist/public/assets/{index-D8ykkCB-.js → index-l0fisju1.js} +5 -1
- package/dist/public/index.html +2 -2
- package/dist/{src-DRRh4faC.mjs → src-B-CjXHOr.mjs} +1 -1
- package/dist/src-BgsCbkVV.mjs +1 -0
- package/dist/{src-BL9dezHn.mjs → src-CHPbwD29.mjs} +18 -18
- package/dist/start-CHEffnPd.mjs +2 -0
- package/dist/start-DJwKRwUm.mjs +1 -0
- package/package.json +1 -1
- package/dist/constants-CuXFpexA.mjs +0 -2
- package/dist/init-CLNeDBhu.mjs +0 -1
- package/dist/loader-C2Oc8j2H.mjs +0 -1
- package/dist/paths-DHfVldLe.mjs +0 -1
- package/dist/preview-BlqAxZW9.mjs +0 -1
- package/dist/public/assets/index-BMQfimy6.css +0 -1
- package/dist/src-Cen38OjE.mjs +0 -1
- package/dist/start-C1PBejcl.mjs +0 -1
- package/dist/start-CUVYCY6u.mjs +0 -2
|
@@ -14,4 +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`)qt.loading(`${of(n.phase)} — ${n.pct}%`,{id:t});else if(n.type===`complete`){qt.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`){qt.error(`Clone failed: ${n.message}`,{id:t}),v(!1),b(null);return}}catch{}}qt.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`?qt.dismiss(x.current??void 0):qt.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),qt.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=zt,G=n,K=L,R=pn,U=`sm:max-w-lg`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(_n,{children:(0,$.jsx)(Ut,{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)(ct,{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)(ct,{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)(af,{className:`h-4 w-2/3`}),(0,$.jsx)(af,{className:`h-4 w-1/2`}),(0,$.jsx)(af,{className:`h-4 w-3/4`}),(0,$.jsx)(af,{className:`h-4 w-2/5`}),(0,$.jsx)(af,{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)(X,{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 q;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>c(e.target.value),t[47]=q):q=t[47];let ne;t[48]!==_||t[49]!==s?(ne=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[te,(0,$.jsx)(ct,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:s,onChange:q,disabled:_})]}),t[48]=_,t[49]=s,t[50]=ne):ne=t[50];let re;t[51]!==B||t[52]!==V||t[53]!==H||t[54]!==ee||t[55]!==ne?(re=(0,$.jsxs)(`div`,{className:B,children:[V,H,ee,ne]}),t[51]=B,t[52]=V,t[53]=H,t[54]=ee,t[55]=ne,t[56]=re):re=t[56];let ie;t[57]!==_||t[58]!==F||t[59]!==N||t[60]!==L||t[61]!==a?(ie=(0,$.jsx)(en,{children:_?(0,$.jsx)(X,{variant:`outline`,className:`font-mono uppercase`,onClick:F,children:`Cancel`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>L(!1),children:`Cancel`}),(0,$.jsx)(X,{onClick:()=>void N(),disabled:!a.trim(),children:`Clone`})]})}),t[57]=_,t[58]=F,t[59]=N,t[60]=L,t[61]=a,t[62]=ie):ie=t[62];let ae;t[63]!==R||t[64]!==U||t[65]!==W||t[66]!==re||t[67]!==ie?(ae=(0,$.jsxs)(R,{className:U,children:[W,re,ie]}),t[63]=R,t[64]=U,t[65]=W,t[66]=re,t[67]=ie,t[68]=ae):ae=t[68];let oe;return t[69]!==z||t[70]!==G||t[71]!==K||t[72]!==ae?(oe=(0,$.jsx)(z,{open:G,onOpenChange:K,children:ae}),t[69]=z,t[70]=G,t[71]=K,t[72]=ae,t[73]=oe):oe=t[73],oe}function lf(e){return e.json()}function uf(e){let t=(0,Q.c)(9),{onOpenResolver:n}=e,r=Jd();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)(Ki,{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)(X,{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 df=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 ff(e,t,n,r,i,a){if(e==r)return[];let o=Sf(e,t,n,r,i,a),s=Cf(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 df(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new df(t,t+o,i,i),new df(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 df(t,t,i,i+o),new df(n,n,i+o+c,a)]}if(c==1||l==1)return[new df(t,n,i,a)];let u=Tf(e,t,n,r,i,a);if(u){let[o,s,c]=u;return ff(e,t,o,r,i,s).concat(ff(e,o+c,n,r,s+c,a))}return gf(e,t,n,r,i,a)}var pf=1e9,mf=0,hf=!1;function gf(e,t,n,r,i,a){let o=n-t,s=a-i;if(pf<1e9&&Math.min(o,s)>pf*16||mf>0&&Date.now()>mf)return Math.min(o,s)>pf*64?[new df(t,n,i,a)]:Ef(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);vf.reset(c),yf.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:yf,f=d?null:vf;for(let p=0;p<c;p++){if(p>pf||mf>0&&!(p&63)&&Date.now()>mf)return Ef(e,t,n,r,i,a);let m=vf.advance(p,o,s,c,d,!1,l)||yf.advance(p,o,s,c,f,!0,u);if(m)return bf(e,t,n,t+m[0],r,i,a,i+m[1])}return[new df(t,n,i,a)]}var _f=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}},vf=new _f,yf=new _f;function bf(e,t,n,r,i,a,o,s){let c=!1;return!Vf(e,r)&&++r==n&&(c=!0),!Vf(i,s)&&++s==o&&(c=!0),c?[new df(t,n,a,o)]:ff(e,t,r,i,a,s).concat(ff(e,r,n,i,s,o))}function xf(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function Sf(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=xf(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-+!Vf(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function Cf(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=xf(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-+!Vf(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function wf(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;;){Vf(e,s)||s++;let u=s+o;if(Vf(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=Sf(e,u,n,r,i+f+d.length,a),c=Cf(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 Tf(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=Tf(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:wf(e,t,n,r,i,a,Math.floor(o/4),-1)}function Ef(e,t,n,r,i,a){hf=!0;let o=n-t,s=a-i,c;if(o<s){let s=wf(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=wf(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new df(t,n,i,a)];let[l,u,d]=c;return ff(e,t,l,r,i,u).concat(ff(e,l+d,n,r,u+d,a))}function Df(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 df(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Of(e,t,n){for(;;){Df(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=Sf(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new df(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=Cf(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new df(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 df(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 df(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function kf(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=If(t,a.fromA,l),f=Ff(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 df(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Ff(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new df(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=If(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new df(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Rf(n,a.fromB,a.toB),r,o=t<0?-1:Lf(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=Rf(t,a.fromA,a.toA),r,o=n<0?-1:Lf(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 Df(e,3),e}var Af;try{Af=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function jf(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Mf(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!jf(n):Af?!zf(n)||t==e.length-1?+!!Af.test(String.fromCharCode(n)):Af.test(e.slice(t,t+2))?2:0:0}function Nf(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!jf(n):Af?!Bf(n)||t==1?+!!Af.test(String.fromCharCode(n)):Af.test(e.slice(t-2,t))?2:0:0}var Pf=8;function Ff(e,t,n){if(t==e.length||!Nf(e,t))return t;for(let r=t,i=t+n,a=0;a<Pf;a++){let t=Mf(e,r);if(!t||r+t>i)return r;r+=t}return t}function If(e,t,n){if(!t||!Mf(e,t))return t;for(let r=t,i=t-n,a=0;a<Pf;a++){let t=Nf(e,r);if(!t||r-t<i)return r;r-=t}return t}function Lf(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Rf(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var zf=e=>e>=55296&&e<=56319,Bf=e=>e>=56320&&e<=57343;function Vf(e,t){return!t||t==e.length||!zf(e.charCodeAt(t-1))||!Bf(e.charCodeAt(t))}function Hf(e,t,n){let r=n?.override;return r?r(e,t):(pf=(n?.scanLimit??1e9)>>1,mf=n?.timeout?Date.now()+n.timeout:0,hf=!1,Of(e,t,ff(e,0,e.length,t,0,t.length)))}function Uf(){return!hf}function Wf(e,t,n){return kf(Hf(e,t,n),e,t)}var Gf=Kn.define({combine:e=>e[0]}),Kf=Xn.define(),qf=Kn.define(),Jf=Qn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Kf)&&(e=n.value);for(let n of t.state.facet(qf))e=n(e,t);return e}});function Yf(e){let t=e.field(Jf,!1);if(!t)return null;let n=e.facet(Gf);return{chunks:t,side:n?n.side:null}}var Xf=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 $f(Wf(e.toString(),t.toString(),n),e,t,0,0,Uf())}static updateA(e,t,n,r,i){return rp(np(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return rp(np(e,r,!1,t.length),e,t,n,i)}};function Zf(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 Qf(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 $f(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=Zf(c.fromA+r,c.fromB+i,t,n),[d,f]=Qf(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]=Zf(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]=Qf(a.toA+r,a.toB+i,t,n),s++}o.push(new Xf(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var ep=1e3;function tp(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 np(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>ep&&([l,d]=tp(e,a-ep,n,!0)),o<t.length-ep&&([u,f]=tp(e,o+ep,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 rp(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=Wf(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of $f(h,n,r,d,f,Uf()))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 ip={scanLimit:500},ap=rr.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=hp(e))}update(e){(e.docChanged||e.viewportChanged||sp(e.startState,e.state)||cp(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=hp(e.view))}},{decorations:e=>e.deco}),op=or.low(ir({class:`cm-changeGutter`,markers:e=>e.plugin(ap)?.gutter||Wn.empty}));function sp(e,t){return e.field(Jf,!1)!=t.field(Jf,!1)}function cp(e,t){return e.facet(Gf)!=t.facet(Gf)}var lp=sr.line({class:`cm-changedLine`}),up=sr.mark({class:`cm-changedText`}),dp=sr.mark({tagName:`ins`,class:`cm-insertedLine`}),fp=sr.mark({tagName:`del`,class:`cm-deletedLine`}),pp=new class extends tr{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function mp(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,lp),i.add(o,s,n?fp:dp),a&&a.add(o,o,pp);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,lp),a&&a.add(u,u,pp);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,up),s<t)c++;else break}u=t}}}function hp(e){let t=e.state.field(Jf),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Gf),o=n==`a`,s=new ar,c=i?new ar: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))&&mp(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var gp=class extends $n{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}},_p=Xn.define({map:(e,t)=>e.map(t)}),vp=Qn.define({create:()=>sr.none,update:(e,t)=>{for(let e of t.effects)if(e.is(_p))return e.value;return e.map(t.changes)},provide:e=>nr.decorations.from(e)}),yp=.01;function bp(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 xp(e,t,n){let r=new ar,i=new ar,a=e.state.field(vp).iter(),o=t.state.field(vp).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<-yp?(l-=n,r.add(s,s,sr.widget({widget:new gp(-n),block:!0,side:-1}))):n>yp&&(u+=n,i.add(c,c,sr.widget({widget:new gp(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<yp?r.add(e.state.doc.length,e.state.doc.length,sr.widget({widget:new gp(-p),block:!0,side:1})):p>yp&&i.add(t.state.doc.length,t.state.doc.length,sr.widget({widget:new gp(p),block:!0,side:1}));let m=r.finish(),h=i.finish();bp(m,e.state.field(vp))||e.dispatch({effects:_p.of(m)}),bp(h,t.state.field(vp))||t.dispatch({effects:_p.of(h)})}var Sp=Xn.define({map:(e,t)=>t.mapPos(e)}),Cp=class extends $n{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:Sp.of(n)});let{side:r,sibling:i}=e.state.facet(Gf);i&&i().dispatch({effects:Sp.of(wp(n,e.state.field(Jf),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function wp(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 Tp=Qn.define({create(e){return sr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Sp)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>nr.decorations.from(e)});function Ep({margin:e=3,minSize:t=4}){return Tp.init(n=>Dp(n,e,t))}function Dp(e,t,n){let r=new ar,i=e.facet(Gf).side==`a`,a=e.field(Jf),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,sr.replace({widget:new Cp(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var Op=nr.styleModule.of(new lr({".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`}})),kp=nr.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`}}),Ap=new cr,jp=new cr,Mp=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||ip;let t=[or.low(ap),kp,Op,vp,nr.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(_p)))&&this.measure()})],n=[Gf.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(op);let r=qn.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],nr.editorAttributes.of({class:`cm-merge-a`}),jp.of(n),t]}),i=[Gf.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(op);let a=qn.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],nr.editorAttributes.of({class:`cm-merge-b`}),jp.of(i),t]});this.chunks=Xf.build(r.doc,a.doc,this.diffConf);let o=[Jf.init(()=>this.chunks),Ap.of(e.collapseUnchanged?Ep(e.collapseUnchanged):[])];r=r.update({effects:Xn.appendConfig.of(o)}).state,a=a.update({effects:Xn.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 nr({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new nr({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),er.empty(e[0].startState.doc.length));this.chunks=t==this.a?Xf.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):Xf.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Kf.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Kf.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(Gf),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(jp.reconfigure([Gf.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?op:[]])),a.push(jp.reconfigure([Gf.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?op:[]]))}if(r){let t=Ap.reconfigure(e.collapseUnchanged?Ep(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(){xp(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=Np(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=Np(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 Np(e){let t=e.nextSibling;return e.remove(),t}var Pp=new class extends tr{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},Fp=or.low(ir({class:`cm-changeGutter`,markers:e=>e.plugin(ap)?.gutter||Wn.empty,widgetMarker:(e,t)=>t instanceof Bp?Pp:null}));function Ip(e){let t=typeof e.original==`string`?Yn.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||ip;return[or.low(ap),Gp,kp,nr.editorAttributes.of({class:`cm-merge-b`}),qf.of((e,t)=>{let r=t.effects.find(e=>e.is(Lp));return r&&(e=Xf.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=Xf.updateB(e,t.state.field(Rp),t.newDoc,t.changes,n)),e}),Gf.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?Zp:void 0,side:`b`}),Rp.init(()=>t),e.gutter===!1?[]:Fp,e.collapseUnchanged?Ep(e.collapseUnchanged):[],Jf.init(e=>Xf.build(t,e.doc,n))]}var Lp=Xn.define(),Rp=Qn.define({create:()=>Yn.empty,update(e,t){for(let n of t.effects)n.is(Lp)&&(e=n.value.doc);return e}}),zp=new WeakMap,Bp=class extends $n{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 Vp(e,t,n){let r=zp.get(t.changes);if(r)return r;let i=sr.widget({block:!0,side:-1,widget:new Bp(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Gf),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(),Hp(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),Up(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(Rp).sliceString(t.fromA,t.endA),u=a&&e.facet(Zn),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;Jn(t,{style:t=>Gn(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 zp.set(t.changes,i),i}function Hp(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(Jf).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(Rp);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=er.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:Lp.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function Up(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(Jf).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(Rp).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 Wp(e){let t=new ar;for(let n of e.field(Jf)){let r=e.facet(Gf).overrideChunk&&qp(e,n);t.add(n.fromB,n.fromB,Vp(e,n,!!r))}return t.finish()}var Gp=Qn.define({create:e=>Wp(e),update(e,t){return t.state.field(Jf,!1)==t.startState.field(Jf,!1)?e:Wp(t.state)},provide:e=>nr.decorations.from(e)}),Kp=new WeakMap;function qp(e,t){let n=Kp.get(t);if(n!==void 0)return n;n=null;let r=e.field(Rp),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(sr.widget({widget:new Jp(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(up.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return Kp.set(t,n),n}var Jp=class extends $n{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}},Yp=new class extends tr{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},Xp=sr.line({class:`cm-inlineChangedLine`});function Zp(e,t,n,r){let i=qp(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,Yp),n.add(o.from,o.from,Xp);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 Qp=gn({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),$p=$t({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function em(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}=fe(),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`?Qp:$p,t=[nr.editable.of(!1),qn.readOnly.of(!0)],o=[fn,Ht(),...t,e,nr.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new nr({doc:r,extensions:[fn,Ht(),nr.editable.of(!1),e,nr.lineWrapping,Ip({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),nr.updateListener.of(e=>{let t=Yf(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=Yf(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new Mp({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 nr({doc:r,extensions:[...o,Ip({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 nr)||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)(X,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,$.jsx)(X,{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 tm(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`,...n}),t[2]=n,t[3]=r),r}function nm(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)(ut,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function rm(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=b(`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)(ot,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function im(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)(rm,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=b(`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)(ht,{"data-slot":`sheet-close`,asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,$.jsx)(Dt,{}),(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)(nm,{children:[l,(0,$.jsxs)(_t,{"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 am(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=b(`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 om(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=b(`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)(Ct,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function sm(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=b(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(bt,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function cm(){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 lm(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 um(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 dm=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function fm(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 lm(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)(_n,{className:`shrink-0`,children:(0,$.jsxs)(Ut,{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)(pn,{className:dm,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,$.jsx)(zt,{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)(Ut,{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)(_n,{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)(em,{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)(pn,{className:`${dm} 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)(zt,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function pm(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(){cm().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(mm));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&&(qt.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 um(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):qt.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?qt.info(`Merge aborted — sync paused`):qt.error(`Failed to abort merge`)}catch{qt.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)(om,{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)(am,{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)(X,{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)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,$.jsx)(X,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,$.jsx)(X,{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)(X,{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)(im,{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)(tm,{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)(fm,{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 mm(e){return e.file}function hm(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function gm(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function _m(e){return e/100*window.innerHeight}function vm(e){return e/100*window.innerWidth}function ym(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 bm({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=ym(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=gm(t,i);break;case`em`:r=hm(t,i);break;case`vh`:r=_m(i);break;case`vw`:r=vm(i);break}return r}function xm(e){return parseFloat(e.toFixed(3))}function Sm({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 Cm(e){let{panels:t}=e,n=Sm({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=xm(bm({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=xm(bm({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=xm(bm({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=xm(bm({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 wm(e,t=`Assertion error`){if(!e)throw Error(t)}function Tm(e,t){return Array.from(t).sort(e===`horizontal`?Em:Dm)}function Em(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Dm(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Om(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function km(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 Am({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}=km(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return wm(i,`No rect found`),i}var jm;function Mm(){return jm===void 0&&(jm=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),jm}function Nm(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Tm(n,Array.from(t.children).filter(Om).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,Am({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=Mm()?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:Sm({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 Pm=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)}}},Fm=new Map,Im=new Pm;function Lm(e){Fm=new Map(Fm),Fm.delete(e)}function Rm(e,t){for(let[t]of Fm)if(t.id===e)return t}function zm(e,t){for(let[t,n]of Fm)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Bm(){return Fm}function Vm(e,t){return Im.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Hm(e,t){let n=Fm.get(e);Fm=new Map(Fm),Fm.set(e,t),Im.emit(`groupChange`,{group:e,prev:n,next:t})}function Um(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=km(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 Wm(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Gm(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Zm(e),b:Zm(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();wm(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Xm(Ym(n.a)),b:Xm(Ym(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 Km=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function qm(e){let t=getComputedStyle(Qm(e)??e).display;return t===`flex`||t===`inline-flex`}function Jm(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||qm(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`||Km.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Ym(e){let t=e.length;for(;t--;){let n=e[t];if(wm(n,`Missing node`),Jm(n))return n}return null}function Xm(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Zm(e){let t=[];for(;e;)t.push(e),e=Qm(e);return t}function Qm(e){let{parentNode:t}=e;return Wm(t)?t.host:t}function $m(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 eh({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Om(n)||n.contains(e)||e.contains(n))return!0;if(Gm(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if($m(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function th(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Nm(r),a=Um(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&eh({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function nh(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 rh(e,t,n=0){return Math.abs(xm(e)-xm(t))<=n}function ih(e,t){return rh(e,t)?0:e>t?1:-1}function ah({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(ih(r,c)<0)if(a){let e=(i+c)/2;r=ih(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=xm(r),r}function oh({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(rh(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;wm(u!=null,`Invalid first pivot index`),wm(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];wm(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(wm(n!=null,`Previous layout not found for panel index ${t}`),rh(n,i)){let t=o-n;ih(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];wm(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(wm(n!=null,`Previous layout not found for panel index ${t}`),rh(n,o)){let t=n-i;ih(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];wm(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&ih(i,c)<0)if(e>0){let t=c-o,n=t/2;ih(i+e,c)<0&&(e=ih(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;ih(i-e,c)<0&&(e=ih(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];wm(e!=null,`Previous layout not found for panel index ${r}`);let a=ah({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];wm(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=ah({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!rh(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(nh(c,l))return i;{let t=e<0?d:u,r=s[t];wm(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=ah({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!rh(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];wm(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=ah({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(rh(i,s)||(t-=s-i,l[r]=s),rh(t,0))break;e>0?r--:r++}}}if(!rh(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 sh(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||ih(e[n],t[n])!==0)return!1;return!0}function ch({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(!rh(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];wm(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];wm(i!=null,`No layout data found for index ${e}`);let o=r[e];wm(o!=null,`No layout data found for index ${e}`);let s=ah({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!rh(a,0))for(let e=0;e<t.length;e++){let n=r[e];wm(n!=null,`No layout data found for index ${e}`);let i=n+a,o=ah({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,rh(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function lh({groupId:e,panelId:t}){let n=()=>{let t=Bm();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=ch({layout:oh({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});sh(l,p)||Hm(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&&rh(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Sm({group:t});o(xm(bm({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function uh(e){e.defaultPrevented||th(e,Bm()).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=lh({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function dh(e){let t=Bm();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 fh({groupId:e}){let t=()=>{let t=Bm();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=ch({layout:e,panelConstraints:r});return n?o:(sh(o,c)||Hm(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function ph(e,t){let n=dh(e),r=zm(n.id,!0),i=n.separators.find(t=>t.element===e);wm(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);wm(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=fh({groupId:n.id}).getLayout(),c=ch({layout:oh({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});sh(s,c)||Hm(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function mh(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=dh(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&ph(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&ph(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&ph(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&ph(t,-5);break;case`End`:e.preventDefault(),ph(t,100);break;case`Enter`:{e.preventDefault();let n=dh(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=zm(n.id,!0),o=n.separators.find(e=>e.element===t);wm(o,`Matching separator not found`);let s=a.get(o);wm(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(wm(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];ph(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=dh(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);wm(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(),ph(t,-100);break}}var hh={cursorFlags:0,state:`inactive`},gh=new Pm;function _h(){return hh}function vh(e){return gh.addListener(`change`,e)}function yh(e){let t=hh,n={...hh};n.cursorFlags=e,hh=n,gh.emit(`change`,{prev:t,next:n})}function bh(e){let t=hh;hh=e,gh.emit(`change`,{prev:t,next:e})}function xh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Bm(),n=th(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)}),bh({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Sh=e=>e,Ch=()=>{},wh=1,Th=2,Eh=4,Dh=8,Oh=3,kh=12,Ah;function jh(){return Ah===void 0&&(Ah=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Ah=!0)),Ah}function Mh({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&&jh()){let t=(e&wh)!==0,n=(e&Th)!==0,r=(e&Eh)!==0,i=(e&Dh)!==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 jh()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Nh=new WeakMap;function Ph(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Nh.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=_h();switch(r.state){case`active`:case`hover`:{let e=Mh({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}Nh.set(e,{prevStyle:t,styleSheet:n})}function Fh({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=oh({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(sh(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?wh:Th;break;case`vertical`:s|=d<0?Eh:Dh;break}}else Hm(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Oh:c|=s&Oh,t.movementY===0?c|=o&kh:c|=s&kh,yh(c),Ph(e)}function Ih(e){let t=Bm(),n=_h();switch(n.state){case`active`:Fh({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Lh(e){if(e.defaultPrevented)return;let t=_h(),n=Bm();switch(t.state){case`active`:if(e.buttons===0){bh({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=zm(e.group.id,!0);Hm(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)}Fh({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=th(e,n);r.length===0?t.state!==`inactive`&&bh({cursorFlags:0,state:`inactive`}):bh({cursorFlags:0,hitRegions:r,state:`hover`}),Ph(e.currentTarget);break}}}function Rh(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(_h().state){case`hover`:bh({cursorFlags:0,state:`inactive`})}}function zh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=_h();switch(t.state){case`active`:bh({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Ph(e.currentTarget),t.hitRegions.forEach(e=>{let t=zm(e.group.id,!0);Hm(e.group,t)}),e.preventDefault())}}function Bh(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=xm(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=xm((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function Vh(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Sm({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:xm(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Hh(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 Uh({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=xm(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]=xm((r[e]??0)/a*l);else{let e=xm(l/c.length);for(let t of c)u[t]=e}return u}function Wh(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 Gh=new Map;function Kh(e){let t=!0;wm(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=Sm({group:e});if(t===0)return;let n=zm(e.id);if(!n)return;let r=Cm(e),i=n.defaultLayoutDeferred?Bh(r):n.layout,a=ch({layout:Uh({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&sh(n.layout,a)&&Hh(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Hm(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else Vh(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{wm(!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=Sm({group:e}),s=Cm(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Wh(e.panels,l)||(l=void 0));let u=ch({layout:e.mutableState.layouts[c]??l??Bh(s),panelConstraints:s}),d=e.element.ownerDocument;Gh.set(d,(Gh.get(d)??0)+1);let f=new Map;return Nm(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Hm(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{wm(!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`,mh)}),Gh.get(d)===1&&(d.addEventListener(`dblclick`,uh,!0),d.addEventListener(`pointerdown`,xh,!0),d.addEventListener(`pointerleave`,Ih),d.addEventListener(`pointermove`,Lh),d.addEventListener(`pointerout`,Rh),d.addEventListener(`pointerup`,zh,!0)),function(){t=!1,Gh.set(d,Math.max(0,(Gh.get(d)??0)-1)),Lm(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,mh)}),Gh.get(d)||(d.removeEventListener(`dblclick`,uh,!0),d.removeEventListener(`pointerdown`,xh,!0),d.removeEventListener(`pointerleave`,Ih),d.removeEventListener(`pointermove`,Lh),d.removeEventListener(`pointerout`,Rh),d.removeEventListener(`pointerup`,zh,!0)),a.disconnect()}}function qh(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function Jh(e){let t=(0,Z.useId)();return`${e??t}`}var Yh=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function Xh(e){let t=(0,Z.useRef)(e);return Yh(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function Zh(...e){return Xh(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function Qh(e){let t=(0,Z.useRef)({...e});return Yh(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var $h=(0,Z.createContext)(null);function eg(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:Sh});(0,Z.useImperativeHandle)(t,()=>n.current,[]),Yh(()=>{Object.assign(n.current,fh({groupId:e}))})}function tg({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=Xh(e=>{sh(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Xh(e=>{sh(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=Jh(s),v=(0,Z.useRef)(null),[y,b]=qh(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Zh(v,a);eg(_,o);let C=Xh((e,t)=>{let r=_h(),i=Rm(e),a=zm(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=Qh({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=Tm(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Tm(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=Rm(_),i=zm(_);r&&i&&Hm(r,{...i,derivedPanelConstraints:Cm(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 Yh(()=>{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=Kh(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=zm(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=Vm(_,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=rh(t.collapsedSize,i[t.panelId]),a=rh(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=_h().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)($h.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})})}tg.displayName=`Group`;function ng(){let e=(0,Z.useContext)($h);return wm(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function rg(e,t){let{id:n}=ng(),r=(0,Z.useRef)({collapse:Ch,expand:Ch,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ch});(0,Z.useImperativeHandle)(t,()=>r.current,[]),Yh(()=>{Object.assign(r.current,lh({groupId:n,panelId:e}))})}function ig({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=Jh(c),_=Qh({disabled:a}),v=(0,Z.useRef)(null),y=Zh(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=ng(),T=d!==null,E=Xh((e,t,n)=>{d?.(e,c,n)});Yh(()=>{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]),rg(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>Vm(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:{...ag,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})})}ig.displayName=`Panel`;var ag={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function og(){return(0,Z.useRef)(null)}function sg({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=ch({layout:oh({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=ch({layout:oh({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function cg({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=Jh(a),l=Qh({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),m=(0,Z.useRef)(null),h=Zh(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=ng(),x=v===`horizontal`?`vertical`:`horizontal`;Yh(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=vh(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Vm(_,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(sg({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})}cg.displayName=`Separator`;async function lg(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 ug(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=()=>lg(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}=K(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)(Fe,{children:`Backlinks`}),t[13]=_):_=t[13];let v;t[14]!==g||t[15]!==p?(v=!p&&(0,$.jsx)(Ne,{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=Ln(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)(Re,{className:i,children:[y,x]}),t[28]=i,t[29]=y,t[30]=x,t[31]=S):S=t[31],S}function dg(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}async function fg(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 pg(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=()=>fg(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}=K(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:At(_.docName,{pages:o,folderPaths:a});y=e===null?null:e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:Et(e),t[13]=_,t[14]=a,t[15]=o,t[16]=y}else y=t[16];let x=y,S;t[17]!==a||t[18]!==o||t[19]!==s?(S=function(e){if(e.kind===`external`){window.open(e.url,`_blank`,`noopener,noreferrer`);return}let t=At(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]=S):S=t[20];let C=S,w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Fe,{children:`Outgoing Links`}),t[21]=w):w=t[21];let T;t[22]!==p||t[23]!==g?(T=!p&&(0,$.jsx)(Ne,{children:g.length}),t[22]=p,t[23]=g,t[24]=T):T=t[24];let E;t[25]===T?E=t[26]:(E=(0,$.jsxs)(Oe,{children:[w,T]}),t[25]=T,t[26]=E);let D;t[27]!==m||t[28]!==a||t[29]!==C||t[30]!==p||t[31]!==g||t[32]!==o||t[33]!==s?(D=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`?At(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`?dg(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)(X,{variant:`outline`,className:b(`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:()=>C(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)(Hn,{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)(rn,{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)(Wt,{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)(X,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>v(e),children:[(0,$.jsx)(rn,{className:`size-3.5`}),`Create index note`]}):null]},l)})}),t[27]=m,t[28]=a,t[29]=C,t[30]=p,t[31]=g,t[32]=o,t[33]=s,t[34]=D):D=t[34];let O;t[35]!==p||t[36]!==D?(O=(0,$.jsx)(Ee,{"aria-busy":p,children:D}),t[35]=p,t[36]=D,t[37]=O):O=t[37];let k;t[38]!==i||t[39]!==E||t[40]!==O?(k=(0,$.jsxs)(Re,{className:i,children:[E,O]}),t[38]=i,t[39]=E,t[40]=O,t[41]=k):k=t[41];let A=_!==null,j=x?.initialDir??``,M=x?.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)($e,{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]!==k||t[48]!==P?(F=(0,$.jsxs)($.Fragment,{children:[k,P]}),t[47]=k,t[48]=P,t[49]=F):F=t[49],F}var mg=[{id:`outline`,label:`Outline`,icon:vi},{id:`backlinks`,label:`Backlinks`,icon:$r},{id:`forward-links`,label:`Outgoing Links`,icon:ei},{id:`graph`,label:`Graph`,icon:xi}];function hg(){return Qt(()=>import(`./GraphPanel-DqKpB1Tz.js`),__vite__mapDeps([0,1,2,3]))}var gg=(0,Z.lazy)(async()=>({default:(await hg()).GraphPanel}));function _g(e){let t=(0,Q.c)(27),{docName:n,isSourceMode:r}=e,[i,a]=(0,Z.useState)(mg[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=mg.map(vg),t[1]=s):s=t[1];let c;t[2]===i?c=t[3]:(c=(0,$.jsx)(zn,{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)(on,{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)(ug,{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)(pg,{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)(gg,{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 vg(e){let{id:t,label:n,icon:r}=e;return(0,$.jsxs)(jn,{children:[(0,$.jsx)(Pn,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,$.jsx)(Rn,{children:(0,$.jsx)(r,{})})}),(0,$.jsx)(wn,{side:`bottom`,children:n})]},t)}function yg(){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)(af,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,$.jsx)(af,{className:`h-4 w-full`}),(0,$.jsx)(af,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}function bg(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function xg(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=bg(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function Sg(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function Cg(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:xg(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:Sg(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:xg(e,t.pageTitles),children:a}}var wg=dc,Tg=fc,Eg=xc,Dg=_c;function Og(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=b(`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)(Wr,{className:`ml-auto`}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==a||t[11]!==s?(l=(0,$.jsxs)(Sc,{"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 kg(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=b(`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)(Cc,{"data-slot":`dropdown-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ag(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=b(`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)(mc,{"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)(pc,{children:u}),t[11]=u,t[12]=d),d}function jg(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=b(`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)(gc,{"data-slot":`dropdown-menu-item`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function Mg(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=b(`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)(yc,{children:(0,$.jsx)(Hr,{})})}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(vc,{"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 Ng(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=b(`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)(hc,{"data-slot":`dropdown-menu-label`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function Pg(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=b(`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)(bc,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Fg(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=b(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=b(`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 Ig(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=b(`[&_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 Lg(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=b(`[&_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 Rg(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=b(`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 zg(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=b(`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 Bg(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=b(`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 Vg(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 Hg(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 Ug(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)(Ir,{className:`ml-1 size-3`}):(0,$.jsx)(Mr,{className:`ml-1 size-3`}):(0,$.jsx)(Fr,{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)(X,{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 Wg(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)(af,{className:`size-5 rounded`}),(0,$.jsx)(af,{className:`h-7 w-48`})]}),(0,$.jsx)(af,{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)(af,{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)(af,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(Jg)]})]})}),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=Cg(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=Hg(e.children,h,_),l;t[21]===h?l=t[22]:(l=function(e){e===h?v(qg):(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(Kg);if(!t.ok||!i?.ok){m(i?.error??`Server error (HTTP ${t.status})`),f(!1);return}let a=i.docName??`${n}/index`;r(a),Be([`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)(Wt,{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)(ki,{className:`size-4`}),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{children:[M,`New`,(0,$.jsx)(Ur,{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)(jg,{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)(jg,{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)(wg,{children:[N,(0,$.jsxs)(Ag,{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=Fg;let H=h===`name`?_===`asc`?`ascending`:`descending`:`none`,U;t[47]!==D||t[48]!==_||t[49]!==h?(U=(0,$.jsx)(Ug,{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)(zg,{"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)(Ug,{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)(zg,{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)(Ig,{children:(0,$.jsxs)(Rg,{children:[W,ee]})}),t[61]=W,t[62]=ee,t[63]=S):S=t[63],y=Lg,x=a.length?a.map(Gg):(0,$.jsx)(Rg,{children:(0,$.jsx)(Bg,{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)($e,{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 Gg(e){return(0,$.jsxs)(Rg,{children:[(0,$.jsx)(Bg,{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)(ci,{className:`size-4 shrink-0 text-muted-foreground`}):(0,$.jsx)(mn,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,$.jsx)(Bg,{className:`text-muted-foreground`,children:e.kind===`file`?Vg(e.modified):`—`})]},e.path)}function Kg(){return null}function qg(e){return e===`asc`?`desc`:`asc`}function Jg(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,$.jsx)(af,{className:`size-4 rounded`}),(0,$.jsx)(af,{className:`h-4 w-40`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(af,{className:`h-4 w-16`})})]},e)}var Yg=1e3,Xg=3;function Zg(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??Xg;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var Qg={0:{count:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,baseDistance:14,distanceVariance:5.5,sizeMin:.45,sizeMax:1.2,maxDelay:130,durationMin:620,durationMax:920}},$g=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-agent)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`];function e_(e,t={}){let n=t.rng??Math.random,r=t.colors??$g,i=Qg[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);a.push({id:e,dx:Math.cos(t)*s,dy:Math.sin(t)*s,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var t_=.8,n_=9.2736,r_=18.1799,i_=14.5244,a_={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function o_(e,t){let{halfWidth:n,apexLift:r}=a_[t];return`M${e-n} ${i_+.3} Q${e} ${i_-r}, ${e+n} ${i_+.3}`}var s_=15,c_=13;function l_(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 u_(e){let t=(0,Q.c)(51),{size:n,className:r,trackMouse:i}=e,a=n===void 0?48:n,o=i===void 0?!0:i,s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[u,d]=(0,Z.useState)(0),[f,p]=(0,Z.useState)(0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],t[0]=m):m=t[0];let[h,g]=(0,Z.useState)(m),_=(0,Z.useRef)(0),v=(0,Z.useRef)(0),y=(0,Z.useRef)(void 0),x;t[1]===u?x=t[2]:(x=function(){let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=_.current===0?1/0:e-_.current;_.current=e;let n=Zg(u,t);d(n),p(f_),g(e_(n)),clearTimeout(y.current),y.current=setTimeout(()=>{d(0),g([])},Yg)},t[1]=u,t[2]=x);let S=x,C,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>()=>clearTimeout(y.current),w=[],t[3]=C,t[4]=w):(C=t[3],w=t[4]),(0,Z.useEffect)(C,w);let T,E;t[5]===o?(T=t[6],E=t[7]):(T=()=>{if(!o||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=function(e){v.current&&cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{let t=s.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,u=Math.hypot(a,o),d=0,f=0;if(u>=1){let e=Math.min(u/150,1)*t_;d=a/u*e,f=o/u*e}c.current?.setAttribute(`cx`,String(n_+d)),c.current?.setAttribute(`cy`,String(i_+f)),l.current?.setAttribute(`cx`,String(r_+d)),l.current?.setAttribute(`cy`,String(i_+f))})};return document.addEventListener(`mousemove`,e,{passive:!0}),()=>{document.removeEventListener(`mousemove`,e),v.current&&cancelAnimationFrame(v.current)}},E=[o],t[5]=o,t[6]=T,t[7]=E),(0,Z.useEffect)(T,E);let D=u>0,O=D?u:1,k=D?`ok-blob-clicked-${u}`:null,A;t[8]===r?A=t[9]:(A=b(`cursor-pointer`,r),t[8]=r,t[9]=A);let j=`body-${f}`,M;t[10]===k?M=t[11]:(M=b(`ok-blob-group`,k),t[10]=k,t[11]=M);let N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=(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[12]=N):N=t[12];let P=D&&`ok-blob-eye-hidden`,F;t[13]===P?F=t[14]:(F=b(`ok-blob-eye`,P),t[13]=P,t[14]=F);let I;t[15]===F?I=t[16]:(I=(0,$.jsx)(`ellipse`,{ref:c,cx:n_,cy:i_,rx:1.2722,ry:1.9083,className:F}),t[15]=F,t[16]=I);let L=D&&`ok-blob-eye-hidden`,R;t[17]===L?R=t[18]:(R=b(`ok-blob-eye ok-blob-eye-right`,L),t[17]=L,t[18]=R);let z;t[19]===R?z=t[20]:(z=(0,$.jsx)(`ellipse`,{ref:l,cx:r_,cy:i_,rx:1.2722,ry:1.9083,className:R}),t[19]=R,t[20]=z);let B;t[21]===O?B=t[22]:(B=o_(n_,O),t[21]=O,t[22]=B);let V=!D&&`ok-blob-eye-hidden`,H;t[23]===V?H=t[24]:(H=b(`ok-blob-happy-eye`,V),t[23]=V,t[24]=H);let U;t[25]!==B||t[26]!==H?(U=(0,$.jsx)(`path`,{d:B,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:H}),t[25]=B,t[26]=H,t[27]=U):U=t[27];let W;t[28]===O?W=t[29]:(W=o_(r_,O),t[28]=O,t[29]=W);let G=!D&&`ok-blob-eye-hidden`,K;t[30]===G?K=t[31]:(K=b(`ok-blob-happy-eye`,G),t[30]=G,t[31]=K);let ee;t[32]!==W||t[33]!==K?(ee=(0,$.jsx)(`path`,{d:W,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:K}),t[32]=W,t[33]=K,t[34]=ee):ee=t[34];let te;t[35]!==j||t[36]!==M||t[37]!==I||t[38]!==z||t[39]!==U||t[40]!==ee?(te=(0,$.jsxs)(`g`,{className:M,children:[N,I,z,U,ee]},j),t[35]=j,t[36]=M,t[37]=I,t[38]=z,t[39]=U,t[40]=ee,t[41]=te):te=t[41];let q;t[42]!==f||t[43]!==h?(q=h.length>0&&(0,$.jsx)(`g`,{children:h.map(d_)},`firework-${f}`),t[42]=f,t[43]=h,t[44]=q):q=t[44];let ne;return t[45]!==S||t[46]!==a||t[47]!==te||t[48]!==q||t[49]!==A?(ne=(0,$.jsxs)(`svg`,{ref:s,width:a,height:a,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:A,"aria-hidden":`true`,onClick:S,children:[te,q]}),t[45]=S,t[46]=a,t[47]=te,t[48]=q,t[49]=A,t[50]=ne):ne=t[50],ne}function d_(e){return(0,$.jsx)(`circle`,{cx:s_,cy:c_,r:e.size,className:`ok-blob-firework`,style:l_(e)},e.id)}function f_(e){return e+1}function p_(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=b(`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)(tg,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function m_(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)(ig,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function h_(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=b(`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)(cg,{"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 g_=960,__=1024;function v_(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(b_),[r,i]=(0,Z.useState)(y_),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${g_-1}px)`),t=window.matchMedia(`(max-width: ${__-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 y_(){return window.innerWidth>=g_&&window.innerWidth<__}function b_(){return window.innerWidth<g_?`sheet`:`panel`}var x_=v;function S_(){let[e]=(0,Z.useState)(M);return e}function C_(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 w_=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&&ie(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(f(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Me(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(j(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(h(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Je(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(I(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(B(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=P(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof s){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 k){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():C_(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&R(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()}},T_=e=>new T({key:typeof e.pluginKey==`string`?new xe(e.pluginKey):e.pluginKey,view:t=>new w_({view:t,...e})});Ce.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[T_({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 E_=z(Te(),1),D_=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 pe(e,{textSerializers:ee(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(f(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Me(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(j(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(h(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(Je(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(I(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(B(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=P(this.view,e.from,e.to);R({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()}},O_=e=>new T({key:typeof e.pluginKey==`string`?new xe(e.pluginKey):e.pluginKey,view:t=>new D_({view:t,...e})});Ce.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?[O_({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 k_(e,t){return e??new xe(t)}var A_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,j_=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),M_=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(`.`)),N_=new Set([`children`,`className`,`style`]),P_=new Set([`tabIndex`]),F_=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),I_={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function L_(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function R_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function z_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||F_.has(e)}function B_(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function V_(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:I_[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function H_(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 U_(e){return P_.has(e)}function W_(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function G_(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 K_(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||M_.has(e)?String(t):`${t}px`}function q_(e,t){j_.has(t)||e.style.removeProperty(B_(t))}function J_(e,t,n){j_.has(t)||e.style.setProperty(B_(t),K_(t,n))}function Y_(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(N_.has(r)||!z_(r)||L_(r,t[r])||L_(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=R_(r);if(a==null||a===!1){U_(r)&&G_(e,r),e.removeAttribute(o);return}if(a===!0){U_(r)&&W_(e,r,!0),e.setAttribute(o,``);return}if(U_(r)){W_(e,r,a);return}e.setAttribute(o,String(a))})}function X_(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Z_(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){q_(e,t);return}J_(e,t,a)}})}function Q_(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(!L_(t,n))return;let{eventName:i,options:a}=V_(t),o=t=>{n(H_(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function $_(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);A_(()=>{let i=n.current;return X_(e,i.className,t.className),Z_(e,i.style,t.style),Y_(e,i,t),r.current=Q_(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 ev=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)(k_(e,`bubbleMenu`)).current;$_(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=rt(),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=T_({...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,E_.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)(k_(e,`floatingMenu`)).current;$_(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=rt(),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=O_({...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,E_.createPortal)(s,u.current)});function tv(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=b(`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)(al,{"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 nv=[{name:`paragraph`,label:`Text`,icon:Ei,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Xe,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:xt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:Lt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:dt,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:Nt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:Ft,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:st,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Bi,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function rv(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:iv},t[0]=n,t[1]=r);let{current:i,activeStates:a}=yt(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)(Ur,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{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=nv.map(e=>{let t=e.icon,r=a[e.name];return(0,$.jsxs)(jg,{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)(Ag,{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)(wg,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function iv(e){let t=Object.fromEntries(nv.map(t=>[t.name,t.isActive(e.editor)]));return{current:nv.find(e=>t[e.name])??nv[0],activeStates:t}}var av=[{name:`bold`,icon:Rr,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:mi,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Ji,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Ui,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:Jr,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:di,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function ov(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=yt(r),a;t[2]!==i||t[3]!==n?(a=av.map(e=>{let t=e.icon,r=i[e.name];return(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(wn,{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(av.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)($r,{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)(X,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(Hn,{className:`size-3.5`})})}),(0,$.jsx)(wn,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,$.jsx)(jt,{className:`size-3.5`})})}),(0,$.jsx)(wn,{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)(gi,{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)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(wn,{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)(jn,{children:[T,E]}),t[44]=T,t[45]=D),D}function lv({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 uv(e){let t=(0,Q.c)(25),{editor:n}=e,r=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(0),s=(0,Z.useRef)(null),c;t[0]!==n.state||t[1]!==n.view?(c=()=>{try{let{from:e,to:t}=n.state.selection;return P(n.view,e,t)}catch{return new DOMRect}},t[0]=n.state,t[1]=n.view,t[2]=c):c=t[2];let l;if(t[3]!==n.view.dom||t[4]!==c){let e={getBoundingClientRect:c,contextElement:n.view.dom};l=()=>{let t=r.current;t&&(s.current?.(),s.current=i(e,t,()=>{R(e,t,{placement:`top`,strategy:`fixed`,middleware:[_(8),f(),Me({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(pv)}))},t[3]=n.view.dom,t[4]=c,t[5]=l}else l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{s.current?.(),s.current=null,o(fv)},t[6]=d):d=t[6];let p=d,m;t[7]===u?m=t[8]:(m={onShow:u,onHide:p,strategy:`fixed`},t[7]=u,t[8]=m);let h;t[9]===n?h=t[10]:(h=(0,$.jsx)(rv,{editor:n}),t[9]=n,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(tv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=g):g=t[11];let v;t[12]!==n||t[13]!==a?(v=(0,$.jsx)(ov,{editor:n},a),t[12]=n,t[13]=a,t[14]=v):v=t[14];let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(tv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=y):y=t[15];let b=`${a}-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]!==m||t[22]!==h||t[23]!==v?(S=(0,$.jsxs)(ev,{ref:r,editor:n,appendTo:dv,shouldShow:lv,updateDelay:250,options:m,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[h,g,v,y,x]}),t[19]=n,t[20]=x,t[21]=m,t[22]=h,t[23]=v,t[24]=S):S=t[24],S}function dv(){return document.body}function fv(e){return e+1}function pv(){}var mv=[{name:`addRowBefore`,icon:Ir,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Mr,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:jt,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],hv=[{name:`addColumnBefore`,icon:Nr,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Pr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:jt,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],gv=[{name:`toggleHeaderRow`,icon:Gi,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:Xr,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:ui,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function _v({editor:e}){return e.isActive(`table`)}function vv(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)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(wn,{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)(jn,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function yv(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=mv.map(e=>(0,$.jsx)(vv,{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)(tv,{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=hv.map(e=>(0,$.jsx)(vv,{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)(tv,{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=gv.map(e=>(0,$.jsx)(vv,{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)(ev,{editor:n,shouldShow:_v,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 bv=new WeakMap;function xv(e){let t=document.createElement(`span`);if(e.type===`agent`)return t.style.display=`none`,t;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=We(e.color),n.textContent=e.name,t.append(n),t}var Sv={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},Cv=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)(Sv),s=S_(),[c]=(0,Z.useState)(wv),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);if(d)throw d;let p=(0,Z.useRef)(null),h=n.configuration.name??``,g;t[0]!==c||t[1]!==h||t[2]!==r||t[3]!==n?(g=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=Ye({docName:h,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new se({element:e,onBeforeCreate:e=>{let{editor:n}=e;bv.set(n,t)},onCreate:e=>{let{editor:t}=e,r=bv.get(t);if(bv.delete(t),r==null)return;let i=performance.now();Xt(`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:[...mt.map(e=>e.name===`link`?e.configure({docName:n.configuration.name??``}):e),x_.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),Pt.configure({document:n.document}),Ce.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[It]}}),Ce.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[Gt(e,{cursorBuilder:xv})]}})]}),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&&hn(e),p.current=null,u(null)}},t[0]=c,t[1]=h,t[2]=r,t[3]=n,t[4]=g):g=t[4];let _;t[5]!==c||t[6]!==h||t[7]!==n?(_=[h,n,c],t[5]=c,t[6]=h,t[7]=n,t[8]=_):_=t[8],(0,Z.useEffect)(g,_);let v;t[9]===n.configuration.name?v=t[10]:(v=()=>{let e=n.configuration.name;return Mt(e??null),Tv},t[9]=n.configuration.name,t[10]=v);let y;t[11]===n?y=t[12]:(y=[n],t[11]=n,t[12]=y),(0,Z.useEffect)(v,y);let b;t[13]!==l||t[14]!==n.configuration.name?(b=()=>{},t[13]=l,t[14]=n.configuration.name,t[15]=b):b=t[15];let x;t[16]!==l||t[17]!==n?(x=[l,n],t[16]=l,t[17]=n,t[18]=x):x=t[18],(0,Z.useEffect)(b,x);let S,C;t[19]===l?(S=t[20],C=t[21]):(S=()=>{if(!l)return;let e=Ev,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()}},C=[l],t[19]=l,t[20]=S,t[21]=C),(0,Z.useEffect)(S,C);let w,T;t[22]!==l||t[23]!==n.document?(T=()=>{if(!l)return;let e=n.document.getMap(`activity`),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)},je)};d(Sv);let p=()=>{if(m(e),!H(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 h=()=>{document.visibilityState===`visible`?H(e,t)&&(t=Date.now(),r=Date.now(),f()):t=Date.now()};return document.addEventListener(`visibilitychange`,h),()=>{e.unobserve(p),document.removeEventListener(`visibilitychange`,h),i&&clearTimeout(i),s&&clearTimeout(s),c&&clearTimeout(c)}},w=[l,n.document],t[22]=l,t[23]=n.document,t[24]=w,t[25]=T):(w=t[24],T=t[25]),(0,Z.useEffect)(T,w);let E,D;t[26]===n?(E=t[27],D=t[28]):(E=()=>{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)}},D=[n],t[26]=n,t[27]=E,t[28]=D),(0,Z.useEffect)(E,D);let O,k;t[29]===l?(O=t[30],k=t[31]):(O=()=>{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(Rt,e),()=>window.removeEventListener(Rt,e)},k=[l],t[29]=l,t[30]=O,t[31]=k),(0,Z.useEffect)(O,k);let A,j;t[32]===n.document?(A=t[33],j=t[34]):(A=()=>{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)},j=[n.document],t[32]=n.document,t[33]=A,t[34]=j),(0,Z.useEffect)(A,j);let M;t[35]!==s||t[36]!==n.awareness?(M=()=>{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]=M):M=t[37];let N;t[38]!==s||t[39]!==n?(N=[n,s],t[38]=s,t[39]=n,t[40]=N):N=t[40],(0,Z.useEffect)(M,N);let P;t[41]===l?P=t[42]:(P=l&&(0,$.jsx)(uv,{editor:l}),t[41]=l,t[42]=P);let F;t[43]===l?F=t[44]:(F=l&&(0,$.jsx)(yv,{editor:l}),t[43]=l,t[44]=F);let I,L;t[45]===l?(I=t[46],L=t[47]):(I=(0,$.jsx)(at,{editor:l,className:`h-full`}),L=l&&(0,$.jsx)(xn,{store:St(l).store}),t[45]=l,t[46]=I,t[47]=L);let R;return t[48]!==P||t[49]!==F||t[50]!==I||t[51]!==L?(R=(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:[P,F,I,L]}),t[48]=P,t[49]=F,t[50]=I,t[51]=L,t[52]=R):R=t[52],R};function wv(){let e=new ye({extensions:S});return{mdManager:e,text:ln({mdManager:e}),html:nn({mdManager:e}),paste:Kt({mdManager:e})}}function Tv(){return Mt(null)}function Ev(){return Ze()}function Dv(e){let t=(0,Q.c)(2),{docName:n,provider:r,children:i}=e;(0,Z.use)(vt(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 Ov=(0,Z.createContext)(null),kv={didCatch:!1,error:null},Av=class extends Z.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=kv}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(kv))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&jv(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(kv))}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)(Ov.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function jv(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var Mv=`__back-nav__`;function Nv(e){return e instanceof it||e instanceof Tt||e instanceof vn||e instanceof tt?e.docName:null}function Pv(e){return e instanceof it?{title:`Couldn't load document`,summary:`"${e.docName}" took too long to load. Check your connection and try again.`}:e instanceof Tt?{title:`Connection dropped`,summary:`Lost connection while loading "${e.docName}".`}:e instanceof vn?{title:`Document not found`,summary:`"${e.docName}" could not be found.`}:e instanceof tt?{title:`Couldn't open document`,summary:`Failed to set up the editor for "${e.docName}". Try again or reopen.`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function Fv(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=Pv(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]===i?m=t[5]:(m=(0,$.jsx)(`p`,{className:`text-xs font-mono text-muted-foreground`,children:i}),t[4]=i,t[5]=m);let h;t[6]===c?h=t[7]:(h=(0,$.jsx)(`h2`,{id:`document-error-title`,className:`text-lg font-semibold`,children:c}),t[6]=c,t[7]=h);let g;t[8]===l?g=t[9]:(g=(0,$.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:l}),t[8]=l,t[9]=g);let _;t[10]===r?_=t[11]:(_=(0,$.jsx)(X,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[10]=r,t[11]=_);let v;t[12]!==i||t[13]!==u||t[14]!==n||t[15]!==o||t[16]!==a||t[17]!==r?(v=u?(0,$.jsx)(X,{variant:`ghost`,onClick:()=>{!a||!o||(nt(Nv(n)??i),o(a),r(Mv))},children:`Back to previous document`}):null,t[12]=i,t[13]=u,t[14]=n,t[15]=o,t[16]=a,t[17]=r,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,$.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==m||t[23]!==h||t[24]!==g||t[25]!==y?(b=(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-3 p-8 text-center`,children:[m,h,g,y]}),t[22]=m,t[23]=h,t[24]=g,t[25]=y,t[26]=b):b=t[26],b}function Iv(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)(Fv,{...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]===Mv){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}: ${Pv(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)(Av,{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 Lv(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 Rv(){return Qt(()=>import(`./SourceEditor-CV7AqTwb.js`),__vite__mapDeps([4,1,2,5,6,7,8]))}var zv=(0,Z.lazy)(async()=>({default:(await Rv()).SourceEditor}));function Bv(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Yt(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 Vv(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Qe,{name:`activity-pool`,children:(0,$.jsx)(Hv,{...e})}),t[0]=e,t[1]=n),n}function Hv(e){let t=(0,Q.c)(11),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c}=yn(),{pages:l,loading:u}=Se(),d=Bv(c,n,3),f=(0,Z.useRef)(``),p=d.map(Uv).join(`,`);(0,Z.useLayoutEffect)(()=>{if(f.current===p)return;let e=f.current?f.current.split(`,`):[],t=p?p.split(`,`):[];Xt(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),f.current=p,an(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)(Kv,{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 Uv(e){return e.docName}function Wv(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 Gv(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)(yg,{}),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)(zv,{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 Kv(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 _=Lv({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&&Xt(`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)(yg,{}),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)(Gv,{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)(Cv,{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)(Dv,{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)(Iv,{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)(Wv,{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 qv(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(Qe,{name:`editor-area`,children:(0,$.jsx)(Jv,{...e})}),t[0]=e,t[1]=n),n}function Jv(e){let t=(0,Q.c)(93),{editorMode:n,previewEntry:r,diffLayout:i,onNoDiff:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l}=yn(),{openDocumentTransition:d}=wt(),f=(0,Z.useDeferredValue)(o),p=c?.kind===`missing`?`Start writing to create this page…`:void 0,m=og(),[h,g]=(0,Z.useState)(!1),{layout:_,autoCollapse:v}=v_(),y=_===`sheet`,[b,x]=(0,Z.useState)(!1),S=(0,Z.useRef)(!1),C,w;t[0]!==v||t[1]!==_||t[2]!==m?(C=()=>{_===`panel`&&(v?(S.current=!1,m.current?.collapse()):S.current||m.current?.expand())},w=[v,_,m],t[0]=v,t[1]=_,t[2]=m,t[3]=C,t[4]=w):(C=t[3],w=t[4]),(0,Z.useEffect)(C,w);let T=(0,Z.useRef)(null),[E,D]=(0,Z.useState)(null),O,k;t[5]===o?(O=t[6],k=t[7]):(O=()=>{if(o&&o!==T.current){let e=T.current;T.current=o,D(e)}},k=[o],t[5]=o,t[6]=O,t[7]=k),(0,Z.useEffect)(O,k);let[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),P;t[8]!==o||t[9]!==s||t[10]!==a||t[11]!==r?(P=()=>{if(!r?.sha||!o){j(null);return}let e=!1,t=r.sha,n=o;return N(!0),j(null),(async function(){try{let r=await fetch(`/api/history/${t}?docName=${encodeURIComponent(n)}`);if(e)return;if(!r.ok){j(null),N(!1);return}let i=await r.json();if(!e){let e=u(i.content??``).body,t=u(s?.document.getText(`source`).toString()??``).body,n=Xv;if(n(e)===n(t)){N(!1),a?.();return}j({old:e,new:t}),N(!1)}}catch{e||(j(null),N(!1))}})(),()=>{e=!0}},t[8]=o,t[9]=s,t[10]=a,t[11]=r,t[12]=P):P=t[12];let F=r?.sha,I;if(t[13]!==o||t[14]!==s||t[15]!==a||t[16]!==F?(I=[F,o,s,a],t[13]=o,t[14]=s,t[15]=a,t[16]=F,t[17]=I):I=t[17],(0,Z.useEffect)(P,I),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,$.jsx)(Wg,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(!s||!o){if((typeof window<`u`?we(window.location.hash):null)!==null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(yg,{}),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)(u_,{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 L=n===`diff`,R=n===`source`,z=y?!b:h,B;t[22]!==h||t[23]!==y||t[24]!==m?(B=()=>{y?x(Yv):h?(S.current=!1,m.current?.expand()):(S.current=!0,m.current?.collapse())},t[22]=h,t[23]=y,t[24]=m,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)(Ti,{className:`size-4`}):(0,$.jsx)(wi,{className:`size-4`}),t[26]=z,t[27]=H);let U;t[28]!==H||t[29]!==B||t[30]!==V?(U=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(wn,{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)(jn,{children:[U,G]})}),t[34]=U,t[35]=G,t[36]=K):K=t[36];let ee=K,te;t[37]!==L||t[38]!==M?(te=L&&M&&(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]=L,t[38]=M,t[39]=te):te=t[39];let q;t[40]!==A||t[41]!==i||t[42]!==L||t[43]!==M?(q=L&&!M&&A!==null&&(0,$.jsx)(em,{oldContent:A.old,newContent:A.new,layout:i}),t[40]=A,t[41]=i,t[42]=L,t[43]=M,t[44]=q):q=t[44];let ne=L?`none`:void 0,re;t[45]===ne?re=t[46]:(re={display:ne},t[45]=ne,t[46]=re);let ie=f??o,ae=E??void 0,oe;t[47]===d?oe=t[48]:(oe=e=>{let t=me(e);window.location.hash===t?d(e):window.location.hash=t},t[47]=d,t[48]=oe);let se;t[49]!==p||t[50]!==R||t[51]!==l||t[52]!==ie||t[53]!==ae||t[54]!==oe?(se=(0,$.jsx)(Vv,{activeDocName:ie,isSourceMode:R,editorPlaceholder:p,previousDocName:ae,onNavigateBack:oe,onRecycle:l}),t[49]=p,t[50]=R,t[51]=l,t[52]=ie,t[53]=ae,t[54]=oe,t[55]=se):se=t[55];let ce;t[56]!==o||t[57]!==f?(ce=o&&o!==f?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(yg,{})}):null,t[56]=o,t[57]=f,t[58]=ce):ce=t[58];let le;t[59]!==re||t[60]!==se||t[61]!==ce?(le=(0,$.jsxs)(`div`,{className:`relative h-full`,style:re,children:[se,ce]}),t[59]=re,t[60]=se,t[61]=ce,t[62]=le):le=t[62];let ue;t[63]!==te||t[64]!==q||t[65]!==le||t[66]!==ee?(ue=(0,$.jsxs)(`div`,{className:`relative h-full`,children:[te,q,le,ee]}),t[63]=te,t[64]=q,t[65]=le,t[66]=ee,t[67]=ue):ue=t[67];let de=ue;if(y){let e;t[68]===de?e=t[69]:(e=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:de}),t[68]=de,t[69]=e);let n;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(am,{className:`sr-only`,children:(0,$.jsx)(om,{children:`Document panel`})}),t[70]=n):n=t[70];let r;t[71]!==o||t[72]!==R?(r=(0,$.jsxs)(im,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,$.jsx)(_g,{docName:o,isSourceMode:R})]}),t[71]=o,t[72]=R,t[73]=r):r=t[73];let i;t[74]!==b||t[75]!==r?(i=(0,$.jsx)(tm,{open:b,onOpenChange:x,children:r}),t[74]=b,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 J;t[80]===de?J=t[81]:(J=(0,$.jsx)(m_,{minSize:`30%`,defaultSize:`75%`,children:de}),t[80]=de,t[81]=J);let fe;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(h_,{withHandle:!0}),t[82]=fe):fe=t[82];let pe;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>g(e.asPercentage===0),t[83]=pe):pe=t[83];let he;t[84]!==o||t[85]!==R?(he=(0,$.jsx)(_g,{docName:o,isSourceMode:R}),t[84]=o,t[85]=R,t[86]=he):he=t[86];let ge;t[87]!==m||t[88]!==he?(ge=(0,$.jsx)(m_,{panelRef:m,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:pe,className:`flex flex-col bg-muted/20`,children:he}),t[87]=m,t[88]=he,t[89]=ge):ge=t[89];let _e;return t[90]!==J||t[91]!==ge?(_e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,$.jsxs)(p_,{orientation:`horizontal`,children:[J,fe,ge]})}),t[90]=J,t[91]=ge,t[92]=_e):_e=t[92],_e}function Yv(e){return!e}function Xv(e){return e.replace(/\r\n/g,`
|
|
17
|
-
`).replace(/[ \t]+$/gm,``).trimEnd()}function Zv(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function Qv(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function $v(e,t){let n=Zv(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function ey(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 ty(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function ny(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var ry=1280;function iy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(ay),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ry-1}px)`),t=()=>{n(window.innerWidth<ry)};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 ay(){return window.innerWidth<ry}var oy=`sidebar_state`,sy=3600*24*7,cy=`18rem`,ly=`18rem`,uy=`3rem`,dy=`\\`,fy=Z.createContext(null);function py(){let e=Z.use(fy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function my(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=iy(),[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=`${oy}=${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(gy):_(hy)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,x,S;t[14]===y?(x=t[15],S=t[16]):(x=()=>{let e=e=>{e.key===dy&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},S=[y],t[14]=y,t[15]=x,t[16]=S),Z.useEffect(x,S);let C=h?`expanded`:`collapsed`,w;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==C||t[22]!==y?(w={state:C,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=C,t[22]=y,t[23]=w):w=t[23];let T;t[24]===s?T=t[25]:(T={"--sidebar-width":cy,"--sidebar-width-icon":uy,...s},t[24]=s,t[25]=T);let E=T,D;t[26]===r?D=t[27]:(D=b(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=D);let O;t[28]!==n||t[29]!==a||t[30]!==E||t[31]!==D?(O=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:E,className:D,...a,children:n}),t[28]=n,t[29]=a,t[30]=E,t[31]=D,t[32]=O):O=t[32];let k;return t[33]!==O||t[34]!==w?(k=(0,$.jsx)(fy.Provider,{value:w,children:O}),t[33]=O,t[34]=w,t[35]=k):k=t[35],k}function hy(e){return!e}function gy(e){return!e}function _y(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}=py();if(d===`none`){let e;t[8]===r?e=t[9]:(e=b(`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":ly},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(am,{className:`sr-only`,children:[(0,$.jsx)(om,{children:`Sidebar`}),(0,$.jsx)(sm,{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)(im,{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)(tm,{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=b(`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 x=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`,S;t[32]!==r||t[33]!==x?(S=b(`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`,x,r),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]===n?C=t[36]:(C=(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]=C);let w;t[37]!==a||t[38]!==l||t[39]!==C||t[40]!==S?(w=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:S,...a,children:C}),t[37]=a,t[38]=l,t[39]=C,t[40]=S,t[41]=w):w=t[41];let T;return t[42]!==l||t[43]!==p||t[44]!==w||t[45]!==g||t[46]!==y||t[47]!==u?(T=(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,w]}),t[42]=l,t[43]=p,t[44]=w,t[45]=g,t[46]=y,t[47]=u,t[48]=T):T=t[48],T}function vy(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}=py(),o;t[4]===n?o=t[5]:(o=b(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)(Ci,{}),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)(X,{"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 yy(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=b(`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 by(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=b(`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 xy(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=b(`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 Sy(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=b(`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 Cy(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=b(`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 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=b(`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 Ty=Le(`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 Ey(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?Ie:`button`,{isMobile:m,state:h}=py(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=b(Ty({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)(Rn,{asChild:!0,children:v}),t[20]=v,t[21]=y);let x=h!==`collapsed`||m,S;t[22]!==x||t[23]!==c?(S=(0,$.jsx)(wn,{side:`right`,align:`center`,hidden:x,...c}),t[22]=x,t[23]=c,t[24]=S):S=t[24];let C;return t[25]!==y||t[26]!==S?(C=(0,$.jsxs)(jn,{children:[y,S]}),t[25]=y,t[26]=S,t[27]=C):C=t[27],C}function Dy(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?Ie:`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=b(`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 Oy(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=b(`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 ky(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=b(`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 Ay(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?Ie:`a`,d;t[6]===n?d=t[7]:(d=b(`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 jy(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 My(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 Ny(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 Py(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 Fy(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 Iy(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 Ly(e){let t=(0,Q.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(!e)return;let t=e.awareness;if(!t)return;let n=()=>{let e=Array.from(t.getStates().entries()),n=[];for(let[t,r]of e){let e=r;e.user&&typeof e.user==`object`&&n.push({clientId:t,user:e.user,mode:e.mode??`wysiwyg`})}i(n)};return n(),t.on(`change`,n),()=>{t.off(`change`,n)}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r}function Ry(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`?zy: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 zy(e){return e===`synced`?`synced`:`connected`}var By=`sync-status`;function Vy(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,qt.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:By,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,qt.success(`Reconnected`,{id:By,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)}var Hy={Bird:Lr,Cat:Vr,Dog:ni,Fish:ai,Mouse:ji,Rabbit:Ai,Shrimp:Li,Snail:Ri,Squirrel:Hi,Turtle:qi};function Uy(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)(jy,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Fy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Iy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(Ny,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(My,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Py,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(zi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}var Wy={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function Gy(e){return(e.icon?Wy[e.icon]:void 0)??e.name}function Ky(e){let t=(0,Q.c)(36),{user:n,mode:r}=e;if(n.type===`agent`){let e;t[0]===n.color?e=t[1]:(e={backgroundColor:n.color},t[0]=n.color,t[1]=e);let i;t[2]===n.icon?i=t[3]:(i=(0,$.jsx)(Uy,{icon:n.icon,width:16,height:16,className:`text-white`}),t[2]=n.icon,t[3]=i);let a;t[4]!==r||t[5]!==e||t[6]!==i||t[7]!==n.name?(a=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`agent`,"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:e,children:i})}),t[4]=r,t[5]=e,t[6]=i,t[7]=n.name,t[8]=a):a=t[8];let o;t[9]===n?o=t[10]:(o=Gy(n),t[9]=n,t[10]=o);let s;t[11]===o?s=t[12]:(s=(0,$.jsx)(wn,{children:o}),t[11]=o,t[12]=s);let c;return t[13]!==a||t[14]!==s?(c=(0,$.jsxs)(jn,{children:[a,s]}),t[13]=a,t[14]=s,t[15]=c):c=t[15],c}let i=n.name.split(` `)[1],a=i?Hy[i]:void 0,o;t[16]===n.name?o=t[17]:(o=n.name.split(` `).map(qy).join(``),t[16]=n.name,t[17]=o);let s=o,c;t[18]===n.color?c=t[19]:(c=We(n.color),t[18]=n.color,t[19]=c);let l=c,u;t[20]===n.color?u=t[21]:(u={backgroundColor:n.color},t[20]=n.color,t[21]=u);let d;t[22]!==a||t[23]!==l||t[24]!==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[22]=a,t[23]=l,t[24]=s,t[25]=d):d=t[25];let f;t[26]!==r||t[27]!==u||t[28]!==d||t[29]!==n.name?(f=(0,$.jsx)(Rn,{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[26]=r,t[27]=u,t[28]=d,t[29]=n.name,t[30]=f):f=t[30];let p;t[31]===n.name?p=t[32]:(p=(0,$.jsx)(wn,{children:n.name}),t[31]=n.name,t[32]=p);let m;return t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(jn,{children:[f,p]}),t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function qy(e){return e[0]}function Jy(){let e=(0,Q.c)(4),{activeProvider:t,activeDocName:n}=yn(),r=Ly(t);Vy(Ry(t),n);let i;e[0]===r?i=e[1]:(i=r.map(Yy),e[0]=r,e[1]=i);let a;return e[2]===i?a=e[3]:(a=(0,$.jsx)(`div`,{"data-slot":`presence-bar`,className:`flex items-center gap-2 px-1 py-1.5`,children:(0,$.jsx)(`div`,{className:`flex items-center -space-x-1.5`,children:i})}),e[2]=i,e[3]=a),a}function Yy(e){return(0,$.jsx)(Ky,{user:e.user,mode:e.mode},e.clientId)}function Xy(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)(Xc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Zy(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)(Zc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Qy(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=b(`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)(Qc,{children:(0,$.jsx)($c,{"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 $y(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 eb(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 tb=[{label:`Documentation`,href:`https://docs.inkeep.com/overview`,icon:zr},{label:`Homepage`,href:`https://inkeep.com/`,icon:Un},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:eb},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:$y}],nb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(Zy,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Gr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)(wn,{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)(Xy,{children:[t,(0,$.jsxs)(Qy,{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:tb.map(rb)})})]})]}),e[2]=r):r=e[2],r};function rb(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 ib=`https://github.com/inkeep/open-knowledge/releases`;function ab(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 ob(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:ib}}};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 sb(e){return ed(e)}function cb(e){return`Opened ${e} in your browser.`}function lb(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??sd,c=e.onWebFallbackSuccess??db,l=e.onWebFallbackError??ub,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=ob({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=ab({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(sb(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)(jg,{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)(jg,{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)(Og,{"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)(Ng,{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)(Pg,{}),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)(jg,{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)(jg,{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)(kg,{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)(Eg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function ub(){}function db(){}function fb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Rd(),{dispatch:a}=Dd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=mb,u=pb,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?``:$u(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)(ri,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsx)(X,{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=td.map(e=>{let t=r[e.id];return(0,$.jsx)(lb,{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)(Ag,{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)(wg,{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 pb(e){qt.error(`Couldn't open ${e.displayName} in your browser.`)}function mb(e){qt.success(cb(e.displayName))}var hb={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`},gb=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`,...hb,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},_b=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)(gb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},vb=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)(gb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},yb=(e,t,n)=>Er(e,t,n,`ProjectSwitcher`);function bb(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=wg,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Wt,{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)(Ur,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{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=Ag,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ng,{children:`Switch project`}),_=(0,$.jsx)(Pg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(Ng,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(jg,{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)(Pg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(si,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(jg,{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 xb(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=b(`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)(vl,{"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)(_l,{"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 Sb(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 Cb(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function wb(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 Tb(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)(qr,{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)(Mi,{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)(qr,{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)(Mi,{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)(Ki,{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)(Kr,{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)(yi,{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)(Kr,{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)(qr,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function Eb(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 Db(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 Ob(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 kb(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`}`:Db(e.state):`Sync off`}function Ab(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 wb(e)}catch(t){console.error(`[sync] toggle failed`,t),qt.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)(Tb,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=Db(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)(xb,{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:Ob(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: `,Sb(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)(Xi,{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)(X,{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)(X,{variant:`outline`,size:`xs`,onClick:Mb,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)(X,{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)(X,{variant:`outline`,size:`xs`,onClick:jb,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)(X,{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 jb(){Cb(`sync`)}function Mb(){Cb(`sync`)}function Nb(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}=Yd();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(Kr,{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)(jn,{children:[e,(0,$.jsx)(wn,{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=Eb(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Db(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)(Tb,{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)(Rn,{asChild:!0,children:(0,$.jsx)(Zy,{asChild:!0,children:(0,$.jsxs)(X,{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]:(_=kb(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)(wn,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(jn,{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)(Qy,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(Ab,{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)(Xy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var Pb=[{value:`light`,label:`Light`,icon:Wi},{value:`dark`,label:`Dark`,icon:bi},{value:`system`,label:`System`,icon:Zr}],Fb=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=fe(),r=t===`system`?Zr:t===`dark`?bi:Wi,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)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{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=Pb.map(Ib),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Ag,{align:`end`,children:(0,$.jsx)(Dg,{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)(wg,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function Ib(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Mg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}var Lb=Le(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Rb(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,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?Ie:`span`,c;t[5]!==n||t[6]!==o?(c=b(Lb({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,$.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function zb(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function Bb(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(zb)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function Vb(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}=yn(),{state:T}=py(),E=nd(),D=Ry(y),O;t[0]!==v||t[1]!==E?(O=vd({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,q]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(!1),oe=(0,Z.useRef)(null),se=(0,Z.useRef)(!1),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),de;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>{ce.current=!0,le.current=null,ue.current=null,ee(!1),re(null)},t[16]=de):de=t[16];let J;t[17]===v?J=t[18]:(J=[v],t[17]=v,t[18]=J),(0,Z.useEffect)(de,J);let fe,pe;t[19]===K?(fe=t[20],pe=t[21]):(fe=()=>{if(K){let e=setTimeout(()=>{let e=oe.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},pe=[K],t[19]=K,t[20]=fe,t[21]=pe),(0,Z.useEffect)(fe,pe);let he;t[22]!==v||t[23]!==j?(he=function(){if(!v||j)return;let e=v.split(`/`);ce.current=!1,le.current=v,q(e[e.length-1]),re(null),ue.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=he):he=t[24];let ge=he,_e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(_e=function(){ce.current=!0,le.current=null,ue.current=null,ee(!1),q(``),re(null)},t[25]=_e):_e=t[25];let ve=_e,ye;t[26]!==x||t[27]!==te?(ye=async function(){if(ce.current){ce.current=!1;return}if(se.current)return;let e=le.current;if(!e){ve();return}let t=Zv(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){ve();return}if(t===ue.current)return;if(!Qv(t)){re(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=$v({kind:`file`,path:e,name:r},t);se.current=!0,ae(!0),re(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(ce.current){ae(!1),se.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}),re(`Server error (HTTP ${n.status})`),ae(!1),se.current=!1,ue.current=t;return}if(!n.ok||!Bb(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),re(a?.error||`Server error (HTTP ${n.status})`),ae(!1),se.current=!1,ue.current=t;return}if(!r.ok){re(r.error||`Failed to rename path`),ae(!1),se.current=!1,ue.current=t;return}let a=r.renamed,o=ny(e,a);for(let e of a)x(e.fromDocName);Be([`files`,`backlinks`,`graph`]),ee(!1),q(``),ae(!1),se.current=!1,ue.current=null,le.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}),re(`Network error — please try again`),ae(!1),se.current=!1,ue.current=t}},t[26]=x,t[27]=te,t[28]=ye):ye=t[28];let be=ye,xe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>{G(!1)},t[29]=xe):xe=t[29];let Se;t[30]===s?Se=t[31]:(Se=[s],t[30]=s,t[31]=Se),(0,Z.useEffect)(xe,Se);let Ce;t[32]===d?Ce=t[33]:(Ce=function(){G(!1),d()},t[32]=d,t[33]=Ce);let we=Ce,Te;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(vy,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Te):Te=t[34];let Ee=T===`expanded`?`Hide Files`:`Show Files`,Y;t[35]===Ee?Y=t[36]:(Y=(0,$.jsxs)(jn,{children:[Te,(0,$.jsx)(wn,{children:Ee})]}),t[35]=Ee,t[36]=Y);let De,Oe;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(De=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(bb,{bridge:window.okDesktop})]}):null,Oe=(0,$.jsx)(tv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=De,t[38]=Oe):(De=t[37],Oe=t[38]);let ke;t[39]!==v||t[40]!==be||t[41]!==N||t[42]!==ge||t[43]!==z||t[44]!==j||t[45]!==ie||t[46]!==K||t[47]!==L||t[48]!==ne||t[49]!==te?(ke=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Wt,{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)(ct,{ref:oe,value:te,disabled:ie,"aria-label":`Rename ${v}`,"aria-invalid":ne?!0:void 0,"aria-describedby":ne?`editor-header-rename-error`:void 0,"aria-busy":ie||void 0,onChange:e=>{q(e.target.value),re(null),ue.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),be()):e.key===`Escape`&&(e.preventDefault(),ve())},onBlur:()=>void be(),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`})]}),ne&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:ne})]}):(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:ge,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]=be,t[41]=N,t[42]=ge,t[43]=z,t[44]=j,t[45]=ie,t[46]=K,t[47]=L,t[48]=ne,t[49]=te,t[50]=ke):ke=t[50];let Ae;t[51]!==v||t[52]!==B||t[53]!==H?(Ae=v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(Oi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(Di,{className:`size-4`})})}),(0,$.jsx)(wn,{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]=Ae):Ae=t[54];let je;t[55]===M?je=t[56]:(je=M&&(0,$.jsx)(Rb,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=je);let Me;t[57]!==Y||t[58]!==ke||t[59]!==Ae||t[60]!==je?(Me=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Y,De,Oe,ke,Ae,je]}),t[57]=Y,t[58]=ke,t[59]=Ae,t[60]=je,t[61]=Me):Me=t[61];let Ne;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Ne=!U&&v&&(0,$.jsxs)(zn,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(vb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(Pn,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(_b,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)(wn,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)(wn,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Ne):Ne=t[67];let Pe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Pe=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)(zn,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Pi,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Yr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ni,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(Dt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)(wn,{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]=Pe):Pe=t[75];let Fe;t[76]!==W||t[77]!==we||t[78]!==U||t[79]!==s||t[80]!==c?(Fe=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)(X,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(X,{variant:`default`,size:`xs`,onClick:we,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=we,t[78]=U,t[79]=s,t[80]=c,t[81]=Fe):Fe=t[81];let Ie;t[82]!==U||t[83]!==_?(Ie=!U&&_&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(li,{className:`size-3.5`})})}),(0,$.jsx)(wn,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Ie):Ie=t[84];let Le;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Le=!U&&v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Fi,{className:`size-3.5`})})}),(0,$.jsx)(wn,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Le):Le=t[89];let Re;t[90]!==v||t[91]!==i?(Re=v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(fi,{className:`size-4`})})}),(0,$.jsx)(wn,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Re):Re=t[92];let ze;t[93]!==v||t[94]!==k||t[95]!==U?(ze=!U&&v&&(0,$.jsx)(fb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=ze):ze=t[96];let Ve;t[97]!==g||t[98]!==h||t[99]!==m?(Ve=(0,$.jsx)(Nb,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=Ve):Ve=t[100];let He,Ue,We,Ge;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(He=(0,$.jsx)(Jy,{}),Ue=(0,$.jsx)(tv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),We=(0,$.jsx)(nb,{}),Ge=(0,$.jsx)(Fb,{}),t[101]=He,t[102]=Ue,t[103]=We,t[104]=Ge):(He=t[101],Ue=t[102],We=t[103],Ge=t[104]);let Ke;t[105]!==Ie||t[106]!==Le||t[107]!==Re||t[108]!==ze||t[109]!==Ve?(Ke=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Ie,Le,Re,ze,Ve,He,Ue,We,Ge]}),t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze,t[109]=Ve,t[110]=Ke):Ke=t[110];let qe;return t[111]!==Me||t[112]!==Ne||t[113]!==Pe||t[114]!==Fe||t[115]!==Ke?(qe=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Me,Ne,Pe,Fe,Ke]}),t[111]=Me,t[112]=Ne,t[113]=Pe,t[114]=Fe,t[115]=Ke,t[116]=qe):qe=t[116],qe}function Hb(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 Ub(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 Wb(e){if(e.contributors.length>0){let t=e.contributors[0];return{hex:ne(t.colorSeed??t.name)}}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 Gb(e){let t=Wb(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 Kb(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(qb),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ur,{className:`size-3`}):(0,$.jsx)(Wr,{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)(Zb,{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 qb(e){return!e}function Jb(e){return e.checkpoint?e.checkpoint.kind:`save`}function Yb(e){let t=Jb(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${Xb(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function Xb(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function Zb(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=Hb(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=Ub(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(Qb);_=`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=Jb(n);return e===`bridge-merge-loss`?(0,$.jsx)(Ki,{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)(ii,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(ti,{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:Gb(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:Yb(n)}),Gb(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 Qb(e){return e.docs}function $b(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(tx),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)(om,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(X,{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)(am,{className:`border-b px-4 py-3 pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,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(ex)}),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)(Zb,{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)(Zb,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(Kb,{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)(X,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ni,{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)(im,{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)(tm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function ex(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(af,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(af,{className:`h-3 w-24`}),(0,$.jsx)(af,{className:`h-3 w-40`})]}),(0,$.jsx)(af,{className:`h-3 w-14`})]},e)}function tx(e){return e.type===`checkpoint`}function nx(){let e=(0,Q.c)(71),[t,n]=(0,Z.useState)(`wysiwyg`),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`auth`),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(`unified`),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=(0,Z.useRef)(!1),D=(0,Z.useRef)(`wysiwyg`),O=Jd(),k,A;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>()=>{T.current&&clearTimeout(T.current)},A=[],e[0]=k,e[1]=A):(k=e[0],A=e[1]),(0,Z.useEffect)(k,A);let{activeDocName:j,activeTarget:M}=yn(),N;e[2]===t?N=e[3]:(N=function(e){e.sha?(t!==`diff`&&(D.current=t===`source`?`source`:`wysiwyg`),g(e),n(`diff`)):(g(null),n(D.current)),S(null)},e[2]=t,e[3]=N);let P=N,F;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(){g(null),n(D.current),S(null)},e[4]=F):F=e[4];let I=F,L;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(){I(),qt.info(`No changes since this version`)},e[5]=L):L=e[5];let R=L,z,B;e[6]===j?(z=e[7],B=e[8]):(z=()=>{let e=function(e){let t=e.detail;t&&j&&bn(j,{kind:`raw-mdx`,detail:t}),n(`source`)};return window.addEventListener(gt,e),()=>window.removeEventListener(gt,e)},B=[j],e[6]=j,e[7]=z,e[8]=B),(0,Z.useEffect)(z,B);let V;e[9]!==M?.kind||e[10]!==t?(V=()=>{M?.kind===`folder`&&(g(null),i(!1),t===`diff`&&n(D.current))},e[9]=M?.kind,e[10]=t,e[11]=V):V=e[11];let H;e[12]!==M||e[13]!==t?(H=[M,t],e[12]=M,e[13]=t,e[14]=H):H=e[14],(0,Z.useEffect)(V,H);let U;e[15]===O?U=e[16]:(U=()=>{!E.current&&O?.state===`dormant`&&O.hasRemote&&(E.current=!0,qt.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>c(!0)}}))},e[15]=O,e[16]=U);let W=O?.state,G=O?.hasRemote,K;e[17]!==W||e[18]!==G?(K=[W,G],e[17]=W,e[18]=G,e[19]=K):K=e[19],(0,Z.useEffect)(U,K);let ee;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(ee=function(e){n(e)},e[20]=ee):ee=e[20];let te=ee,q;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(q=async function(){w(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?qt.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),qt.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),qt.error(`Checkpoint failed — try again`)}w(!1)},e[21]=q):q=e[21];let ne=q,re;e[22]!==j||e[23]!==h?(re=async function(){if(!(!h?.sha||!j)){b(!0);try{(await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:j,commitSha:h.sha})})).ok?(g(null),n(D.current),S(null)):(S(`Restore failed — document unchanged`),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(null),4e3))}catch{S(`Restore failed — document unchanged`),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(null),4e3)}b(!1)}},e[22]=j,e[23]=h,e[24]=re):re=e[24];let ie=re,ae;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(uf,{onOpenResolver:()=>o(!0)}),e[25]=ae):ae=e[25];let oe;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>i(rx),e[26]=oe):oe=e[26];let se,ce,le,ue;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{u(`auth`),c(!0)},ce=()=>{u(`identity`),c(!0)},le=()=>o(!0),ue=()=>f(!0),e[27]=se,e[28]=ce,e[29]=le,e[30]=ue):(se=e[27],ce=e[28],le=e[29],ue=e[30]);let de;e[31]!==_||e[32]!==t||e[33]!==ie||e[34]!==h||e[35]!==x||e[36]!==y||e[37]!==C?(de=(0,$.jsx)(Vb,{editorMode:t,onModeChange:te,onTimelineToggle:oe,onSaveVersion:ne,saving:C,previewEntry:h,restoring:y,restoreError:x,onExitPreview:I,onRestore:ie,diffLayout:_,onDiffLayoutChange:v,onSignIn:se,onSetIdentity:ce,onOpenConflictResolver:le,onOpenClone:ue}),e[31]=_,e[32]=t,e[33]=ie,e[34]=h,e[35]=x,e[36]=y,e[37]=C,e[38]=de):de=e[38];let J;e[39]!==t||e[40]!==h?(J=t===`diff`&&h&&(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: `,Hb(h.timestamp),` — `,Ub(h)]})}),e[39]=t,e[40]=h,e[41]=J):J=e[41];let fe;e[42]!==_||e[43]!==t||e[44]!==h?(fe=(0,$.jsx)(qv,{editorMode:t,previewEntry:h,diffLayout:_,onNoDiff:R}),e[42]=_,e[43]=t,e[44]=h,e[45]=fe):fe=e[45];let pe=j??``,me=h?.sha,he;e[46]!==P||e[47]!==pe||e[48]!==me||e[49]!==r?(he=(0,$.jsx)($b,{open:r,onOpenChange:i,docName:pe,onEntrySelect:P,selectedSha:me}),e[46]=P,e[47]=pe,e[48]=me,e[49]=r,e[50]=he):he=e[50];let ge;e[51]===a?ge=e[52]:(ge=(0,$.jsx)(pm,{open:a,onOpenChange:o}),e[51]=a,e[52]=ge);let _e;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>{c(e),e||m(!1)},e[53]=_e):_e=e[53];let ve=l===`identity`,ye;e[54]===p?ye=e[55]:(ye=()=>{c(!1),p&&(m(!1),f(!0))},e[54]=p,e[55]=ye);let be;e[56]!==s||e[57]!==ve||e[58]!==ye?(be=(0,$.jsx)(nf,{open:s,onOpenChange:_e,identityPrompt:ve,onSuccess:ye}),e[56]=s,e[57]=ve,e[58]=ye,e[59]=be):be=e[59];let xe;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[60]=xe):xe=e[60];let Se;e[61]===d?Se=e[62]:(Se=(0,$.jsx)(cf,{open:d,onOpenChange:f,onSignIn:xe}),e[61]=d,e[62]=Se);let Ce;return e[63]!==de||e[64]!==J||e[65]!==fe||e[66]!==he||e[67]!==ge||e[68]!==be||e[69]!==Se?(Ce=(0,$.jsxs)($.Fragment,{children:[ae,de,J,fe,he,ge,be,Se]}),e[63]=de,e[64]=J,e[65]=fe,e[66]=he,e[67]=ge,e[68]=be,e[69]=Se,e[70]=Ce):Ce=e[70],Ce}function rx(e){return!e}function ix(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)(Ut,{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)(Vt,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(X,{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)(cn,{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)(X,{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)(en,{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)(pn,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function ax(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 ox(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)(bs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function sx(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=b(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(xs,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function cx(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)(Es,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function lx(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=b(`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)(Ss,{children:(0,$.jsx)(Cs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ux(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=b(`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)(ws,{"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 dx(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=b(`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)(Wr,{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)(Ds,{"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 fx(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=b(`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)(Os,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function px(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=b(`-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)(Ts,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mx(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 hx(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)(dx,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=td.map(e=>{let t=r[e.id],o=ob({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=mx(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)(ux,{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)(cx,{children:[o,(0,$.jsx)(fx,{children:s})]}),t[6]=s,t[7]=c),c}var gx=80,_x=3,vx=20,yx=new Map,bx=new Set,xx=[],Sx=new Map;function Cx(e){for(Sx.delete(e),Sx.set(e,!0);Sx.size>vx;){let e=Sx.keys().next().value;if(e===void 0)break;Sx.delete(e)}}function wx(e){bx.delete(e),Tx()}function Tx(){for(;bx.size<_x&&xx.length>0;){let e=xx.shift();if(!e)break;if(!Sx.has(e.docName)){bx.add(e.docName),Cx(e.docName);try{e.prewarm(e.docName)}catch(t){Xt(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{wx(e.docName)}}}}function Ex(e,t){if(Yt(e)||Sx.has(e))return;let n=yx.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(yx.delete(e),bx.size>=_x){xx.push({docName:e,prewarm:t});return}Cx(e),bx.add(e);try{t(e)}catch(t){Xt(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{wx(e)}},gx);yx.set(e,{timer:r,prewarm:t})}function Dx(e){let t=yx.get(e);t&&(clearTimeout(t.timer),yx.delete(e))}function Ox(e){window.location.hash=me(e)}function kx(e){return e.kind===`file`?`${e.path}.md`:e.path}async function Ax(e,t){try{await navigator.clipboard.writeText(e),qt.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),qt.error(`Could not copy ${t}`)}}var jx=new Set([`agents`,`agent`,`claude`,`skill`]);function Mx(e){return e.kind===`file`&&jx.has(e.name.toLowerCase())}function Nx(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=b(`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)(ci,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(mn,{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=b(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let x;t[7]!==i||t[8]!==a||t[9]!==c?(x=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=x):x=t[10];let S;t[11]===o?S=t[12]:(S=e=>o(e.target.value),t[11]=o,t[12]=S);let C;t[13]!==c||t[14]!==s?(C=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=C):C=t[15];let w;t[16]!==i||t[17]!==y||t[18]!==x||t[19]!==S||t[20]!==C||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(w=(0,$.jsx)(ct,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:x,onChange:S,onKeyDown:C}),t[16]=i,t[17]=y,t[18]=x,t[19]=S,t[20]=C,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=w):w=t[26];let T;t[27]===n?T=t[28]:(T=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=T);let E;t[29]!==w||t[30]!==T||t[31]!==p?(E=(0,$.jsxs)(`div`,{className:f,children:[p,w,T]}),t[29]=w,t[30]=T,t[31]=p,t[32]=E):E=t[32];let D;t[33]===a?D=t[34]:(D=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=D);let O;return t[35]!==E||t[36]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[E,D]}),t[35]=E,t[36]=D,t[37]=O):O=t[37],O}var Px=e=>{let t=(0,Q.c)(146),{node:n,nested:r,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,workspace:f,handoff:p,onNavigate:m,prewarm:h,onStartRename:g,onEditingValueChange:_,onCommitRename:v,onCancelRename:y,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:T,getInlineCreate:E}=e,D=r===void 0?!1:r,O=(0,Z.useRef)(!1),k=(0,Z.useRef)(null),A=n.kind===`file`,j=!A&&o.has(n.path),M=A?n.path===i:n.path===a,N=l===n.path,P,F;t[0]===N?(P=t[1],F=t[2]):(P=()=>{if(!N)return;let e=setTimeout(()=>{let e=k.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)},F=[N],t[0]=N,t[1]=P,t[2]=F),(0,Z.useEffect)(P,F);let I=d===n.path,L=d!==null,R=A?mn:j?Wt:ci,z=D?ky:wy,B=D?Ay:Ey,V;t[3]!==n.kind||t[4]!==n.name||t[5]!==n.path?(V={kind:n.kind,path:n.path,name:n.name},t[3]=n.kind,t[4]=n.name,t[5]=n.path,t[6]=V):V=t[6];let H=V,U=A&&n.isSymlink,W;t[7]===n?W=t[8]:(W=Mx(n),t[7]=n,t[8]=W);let G=W,K;t[9]!==A||t[10]!==n.path||t[11]!==h?(K=A?()=>{Ex(n.path,e=>{h(e)})}:void 0,t[9]=A,t[10]=n.path,t[11]=h,t[12]=K):K=t[12];let ee=K,te;t[13]!==A||t[14]!==n.path?(te=A?()=>{Dx(n.path)}:void 0,t[13]=A,t[14]=n.path,t[15]=te):te=t[15];let q=te,ne=M?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,re;t[16]!==R||t[17]!==ne?(re=(0,$.jsx)(R,{className:`size-4 shrink-0`,stroke:ne}),t[16]=R,t[17]=ne,t[18]=re):re=t[18];let ie=M?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,ae;t[19]===ie?ae=t[20]:(ae=b(`min-w-0 flex-1 truncate text-sm`,ie),t[19]=ie,t[20]=ae);let oe=A&&`.md`,se;t[21]!==n.name||t[22]!==ae||t[23]!==oe?(se=(0,$.jsxs)(`span`,{className:ae,children:[n.name,oe]}),t[21]=n.name,t[22]=ae,t[23]=oe,t[24]=se):se=t[24];let ce;t[25]!==n.canonicalDocName||t[26]!==n.targetPath||t[27]!==U?(ce=U&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(hi,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)(wn,{side:`right`,className:`text-center leading-relaxed`,children:[`Symlink → `,n.targetPath,(0,$.jsx)(`br`,{}),`Opens the same document as `,n.canonicalDocName]})]}),t[25]=n.canonicalDocName,t[26]=n.targetPath,t[27]=U,t[28]=ce):ce=t[28];let le;t[29]===G?le=t[30]:(le=G&&(0,$.jsx)(Br,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[29]=G,t[30]=le);let ue;t[31]!==se||t[32]!==ce||t[33]!==le||t[34]!==re?(ue=(0,$.jsxs)($.Fragment,{children:[re,se,ce,le]}),t[31]=se,t[32]=ce,t[33]=le,t[34]=re,t[35]=ue):ue=t[35];let de=ue,J=!D&&`ml-2`,fe=M&&`bg-sidebar-accent text-sidebar-accent-foreground`,pe;t[36]!==J||t[37]!==fe?(pe=b(`flex h-8 items-center gap-2 rounded-md px-2`,J,fe),t[36]=J,t[37]=fe,t[38]=pe):pe=t[38];let me;t[39]===R?me=t[40]:(me=(0,$.jsx)(R,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[39]=R,t[40]=me);let he=`Rename ${n.kind}`,ge;t[41]===_?ge=t[42]:(ge=e=>_(e.target.value),t[41]=_,t[42]=ge);let _e;t[43]!==y||t[44]!==v||t[45]!==H?(_e=e=>{e.key===`Enter`?(e.preventDefault(),v(H)):e.key===`Escape`&&(e.preventDefault(),y())},t[43]=y,t[44]=v,t[45]=H,t[46]=_e):_e=t[46];let ve;t[47]!==u||t[48]!==I||t[49]!==y||t[50]!==he||t[51]!==ge||t[52]!==_e?(ve=(0,$.jsx)(ct,{ref:k,value:u,disabled:I,"aria-label":he,onBlur:y,onChange:ge,onKeyDown:_e,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[47]=u,t[48]=I,t[49]=y,t[50]=he,t[51]=ge,t[52]=_e,t[53]=ve):ve=t[53];let ye;t[54]===A?ye=t[55]:(ye=A&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[54]=A,t[55]=ye);let be;t[56]!==pe||t[57]!==me||t[58]!==ve||t[59]!==ye?(be=(0,$.jsxs)(`div`,{className:pe,children:[me,ve,ye]}),t[56]=pe,t[57]=me,t[58]=ve,t[59]=ye,t[60]=be):be=t[60];let xe=N?be:A?(0,$.jsx)(B,{isActive:M,onClick:()=>m(n.path),className:`cursor-pointer`,"aria-current":M?`page`:void 0,children:de}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(B,{isActive:M,className:`w-full cursor-pointer pr-8`,"aria-current":M?`page`:void 0,onClick:()=>m(n.path),children:de}),(0,$.jsx)(Dy,{type:`button`,className:b(`top-1`,j&&`rotate-90`),"aria-label":`${j?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":j,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Wr,{className:`size-4 text-muted-foreground/50`})})]}),Se=M?c:void 0,Ce;t[61]!==ee||t[62]!==q||t[63]!==Se||t[64]!==xe?(Ce=(0,$.jsx)(sx,{asChild:!0,children:(0,$.jsx)(`div`,{role:`presentation`,ref:Se,onMouseEnter:ee,onMouseLeave:q,children:xe})}),t[61]=ee,t[62]=q,t[63]=Se,t[64]=xe,t[65]=Ce):Ce=t[65];let we;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>{O.current&&(O.current=!1,e.preventDefault())},t[66]=we):we=t[66];let Te;t[67]!==L||t[68]!==A||t[69]!==n||t[70]!==w||t[71]!==C||t[72]!==S?(Te=!A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ux,{disabled:L,onSelect:()=>{L||(O.current=!0,S(`file`,n.path))},children:[(0,$.jsx)(Vi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)(ux,{disabled:L,onSelect:()=>{L||(O.current=!0,S(`folder`,n.path))},children:[(0,$.jsx)(si,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(px,{}),(0,$.jsxs)(ux,{onSelect:()=>C(n),children:[(0,$.jsx)(Yi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)(ux,{onSelect:()=>w(n),children:[(0,$.jsx)(oi,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(px,{})]}),t[67]=L,t[68]=A,t[69]=n,t[70]=w,t[71]=C,t[72]=S,t[73]=Te):Te=t[73];let Ee;t[74]!==L||t[75]!==g||t[76]!==H?(Ee=()=>{L||(O.current=!0,g(H))},t[74]=L,t[75]=g,t[76]=H,t[77]=Ee):Ee=t[77];let Y;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(ft,{"aria-hidden":`true`}),t[78]=Y):Y=t[78];let De;t[79]!==L||t[80]!==Ee?(De=(0,$.jsxs)(ux,{disabled:L,onSelect:Ee,children:[Y,`Rename`]}),t[79]=L,t[80]=Ee,t[81]=De):De=t[81];let Oe;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsxs)(dx,{children:[(0,$.jsx)(Qr,{"aria-hidden":`true`}),`Copy Path`]}),t[82]=Oe):Oe=t[82];let ke=!f,X;t[83]!==n||t[84]!==f?(X=()=>{f&&Ax(gd(f.contentDir,kx(n),f.pathSeparator),`full path`)},t[83]=n,t[84]=f,t[85]=X):X=t[85];let Ae;t[86]!==ke||t[87]!==X?(Ae=(0,$.jsx)(ux,{disabled:ke,onSelect:X,children:`Full Path`}),t[86]=ke,t[87]=X,t[88]=Ae):Ae=t[88];let je;t[89]===n?je=t[90]:(je=(0,$.jsx)(ux,{onSelect:()=>{Ax(kx(n),`relative path`)},children:`Relative Path`}),t[89]=n,t[90]=je);let Me;t[91]!==Ae||t[92]!==je?(Me=(0,$.jsxs)(cx,{children:[Oe,(0,$.jsxs)(fx,{children:[Ae,je]})]}),t[91]=Ae,t[92]=je,t[93]=Me):Me=t[93];let Ne;t[94]!==p||t[95]!==A||t[96]!==n.path||t[97]!==f?(Ne=A&&(0,$.jsx)(hx,{input:vd({docName:n.path,workspace:f}),installStates:p.installStates,isElectronHost:p.isElectronHost,dispatch:p.dispatch}),t[94]=p,t[95]=A,t[96]=n.path,t[97]=f,t[98]=Ne):Ne=t[98];let Pe;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,$.jsx)(px,{}),t[99]=Pe):Pe=t[99];let Fe;t[100]!==L||t[101]!==x||t[102]!==H?(Fe=()=>{L||x(H)},t[100]=L,t[101]=x,t[102]=H,t[103]=Fe):Fe=t[103];let Ie;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,$.jsx)(jt,{"aria-hidden":`true`}),t[104]=Ie):Ie=t[104];let Le;t[105]!==L||t[106]!==Fe?(Le=(0,$.jsxs)(ux,{variant:`destructive`,disabled:L,onSelect:Fe,children:[Ie,`Delete`]}),t[105]=L,t[106]=Fe,t[107]=Le):Le=t[107];let Re;t[108]!==Te||t[109]!==De||t[110]!==Me||t[111]!==Ne||t[112]!==Le?(Re=(0,$.jsxs)(lx,{onCloseAutoFocus:we,children:[Te,De,Me,Ne,Pe,Le]}),t[108]=Te,t[109]=De,t[110]=Me,t[111]=Ne,t[112]=Le,t[113]=Re):Re=t[113];let ze;t[114]!==Ce||t[115]!==Re?(ze=(0,$.jsxs)(ox,{children:[Ce,Re]}),t[114]=Ce,t[115]=Re,t[116]=ze):ze=t[116];let Be;t[117]!==c||t[118]!==d||t[119]!==l||t[120]!==u||t[121]!==j||t[122]!==o||t[123]!==E||t[124]!==p||t[125]!==T||t[126]!==n.children||t[127]!==y||t[128]!==w||t[129]!==v||t[130]!==x||t[131]!==_||t[132]!==C||t[133]!==m||t[134]!==S||t[135]!==g||t[136]!==s||t[137]!==h||t[138]!==i||t[139]!==a||t[140]!==f?(Be=j&&(n.children.length>0||!!T)&&(0,$.jsxs)(Oy,{className:`mr-0 pr-0`,children:[T&&(0,$.jsx)(ky,{children:(0,$.jsx)(Nx,{...T})}),n.children.map(e=>(0,$.jsx)(Px,{node:e,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,workspace:f,handoff:p,onNavigate:m,prewarm:h,onStartRename:g,onEditingValueChange:_,onCommitRename:v,onCancelRename:y,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:E(e.path),getInlineCreate:E,nested:!0},e.path))]}),t[117]=c,t[118]=d,t[119]=l,t[120]=u,t[121]=j,t[122]=o,t[123]=E,t[124]=p,t[125]=T,t[126]=n.children,t[127]=y,t[128]=w,t[129]=v,t[130]=x,t[131]=_,t[132]=C,t[133]=m,t[134]=S,t[135]=g,t[136]=s,t[137]=h,t[138]=i,t[139]=a,t[140]=f,t[141]=Be):Be=t[141];let Ve;return t[142]!==z||t[143]!==ze||t[144]!==Be?(Ve=(0,$.jsxs)(z,{children:[ze,Be]}),t[142]=z,t[143]=ze,t[144]=Be,t[145]=Ve):Ve=t[145],Ve};function Fx(t){let n=(0,Q.c)(65),{ref:r}=t,{activeDocName:i,activeTarget:a,closeDocument:o,prewarm:s}=yn(),{addPage:c}=Se(),l;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],n[0]=l):l=n[0];let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(Hx),[w,T]=(0,Z.useState)(Vx),{selectedFilePath:E,selectedFolderPath:O,navigationPath:k}=ax(a,i),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)(null),{states:H}=Rd(),{dispatch:U}=Dd(),W=typeof window<`u`&&window.okDesktop!=null,G;n[1]!==U||n[2]!==H?(G={installStates:H,isElectronHost:W,dispatch:U},n[1]=U,n[2]=H,n[3]=G):G=n[3];let K=G,ee=Bx,te,q;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(zx);e&&(t.ok&&n?.ok?(d(n.documents),h(null)):h(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&h(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&p(!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()}},q=[],n[4]=te,n[5]=q):(te=n[4],q=n[5]),(0,Z.useEffect)(te,q);let ne,re;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(Rx);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&V({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(Lx),()=>{e=!1}},re=[],n[6]=ne,n[7]=re):(ne=n[6],re=n[7]),(0,Z.useEffect)(ne,re);let ie;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(ie=function(e,t){N({kind:e,parentDir:t}),F(``),z(null),t&&(C(e=>new Set(e).add(t)),T(e=>{let n=new Set(e);return n.delete(t),n}))},n[8]=ie):ie=n[8];let ae=ie,oe;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(oe=function(t){let n=e([t]);(0,Z.startTransition)(()=>{C(e=>{let t=new Set(e);for(let e of n)t.add(e);return t}),T(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t})})},n[9]=oe):oe=n[9];let se=oe,le;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(t){let n=e([t]);(0,Z.startTransition)(()=>{T(e=>{let t=new Set(e);for(let e of n)t.add(e);return t}),C(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t})})},n[10]=le):le=n[10];let ue=le,J;n[11]===u?J=n[12]:(J=()=>({startCreating:ae,expandAll(){let t=e(D(u));(0,Z.startTransition)(()=>{C(t),T(new Set)})},collapseAll(){let t=e(D(u));(0,Z.startTransition)(()=>{T(t),C(new Set)})}}),n[11]=u,n[12]=J),(0,Z.useImperativeHandle)(r,J);let fe;n[13]===I?fe=n[14]:(fe=function(){I||(N(null),F(``),z(null))},n[13]=I,n[14]=fe);let pe=fe,me;n[15]!==c||n[16]!==M||n[17]!==P?(me=async function(){if(!M)return;let e=P.trim();if(!e){z(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){z(`Invalid name`);return}let t=M.kind===`file`?de(M.parentDir,e):ze(M.parentDir,e);L(!0),z(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 ${M.kind}`;qt.error(e),z(e),L(!1);return}let r=n.docName??t.replace(/\.md$/,``);N(null),F(``),z(null),L(!1),r&&Ox(r),c(r),Be([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),qt.error(`Network error — please try again`),z(`Network error — please try again`),L(!1)}},n[15]=c,n[16]=M,n[17]=P,n[18]=me):me=n[18];let he=me,ge;n[19]!==i||n[20]!==o||n[21]!==v?(ge=async function(e){let t=Zv(e.kind,v);if(!Qv(t)){h(`Name must be a single path segment`);return}let n=$v(e,t);if(n===e.path){_(null),y(``),h(null);return}x(e.path),h(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,r=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),s=await a.json();if(!a.ok||!s.ok){h(s.error??`Failed to rename path`),x(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=ny(i,c);for(let e of c)o(e.fromDocName);d(e=>ey(e,c)),Be([`files`,`backlinks`,`graph`]),_(null),y(``),i&&l!==i&&(window.location.hash=`#/${l}`),x(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),h(`Network error — please try again`),x(null)}},n[19]=i,n[20]=o,n[21]=v,n[22]=ge):ge=n[22];let _e=ge,ve;n[23]!==i||n[24]!==o||n[25]!==g||n[26]!==j?(ve=async function(e){x(e.path),j(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){qt.error(n.error??`Failed to delete path`),x(null);return}let r=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],a=new Set(r);for(let e of a)o(e);d(e=>ty(e,r)),Be([`files`,`backlinks`,`graph`]),i&&a.has(i)&&(window.location.hash=``),g&&(a.has(g)||e.path===g)&&(_(null),y(``)),x(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),qt.error(`Network error — please try again`),x(null)}},n[23]=i,n[24]=o,n[25]=g,n[26]=j,n[27]=ve):ve=n[27];let ye=ve;if(f){let e;return n[28]===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...`})}),n[28]=e):e=n[28],e}if(m&&u.length===0){let e;return n[29]===m?e=n[30]:(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:m})}),n[29]=m,n[30]=e),e}if(u.length===0&&!M){let e;n[31]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),n[31]=e):e=n[31];let t;return n[32]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(X,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>ae(`file`,``),children:`Create your first file`})]}),n[32]=t):t=n[32],t}let be=u.length>0?D(u):[],xe=e(be),Ce=De(k),we=new Set(Ce),Te=new Set;for(let e of we)xe.has(e)&&Te.add(e);for(let e of S)xe.has(e)&&Te.add(e);for(let e of w)xe.has(e)&&!we.has(e)&&Te.delete(e);let Ee=function(e){we.has(e)||(Te.has(e)?(T(t=>new Set(t).add(e)),C(t=>{let n=new Set(t);return n.delete(e),n})):(C(t=>new Set(t).add(e)),T(t=>{let n=new Set(t);return n.delete(e),n})))},Y;n[33]!==I||n[34]!==R||n[35]!==M||n[36]!==P||n[37]!==pe||n[38]!==he?(Y=function(e){return!M||M.parentDir!==e?null:{kind:M.kind,value:P,busy:I,error:R,onChange:F,onCommit:()=>void he(),onCancel:pe}},n[33]=I,n[34]=R,n[35]=M,n[36]=P,n[37]=pe,n[38]=he,n[39]=Y):Y=n[39];let Oe=Y,ke;n[40]===Oe?ke=n[41]:(ke=Oe(``),n[40]=Oe,n[41]=ke);let Ae=ke,je;n[42]===m?je=n[43]:(je=m&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:m}),n[42]=m,n[43]=je);let Me=Cy,Ne;n[44]===Ae?Ne=n[45]:(Ne=Ae&&(0,$.jsx)(wy,{children:(0,$.jsx)(Nx,{...Ae})}),n[44]=Ae,n[45]=Ne);let Pe=be.map(e=>(0,$.jsx)(Px,{node:e,selectedFilePath:E,selectedFolderPath:O,expandedPaths:Te,onToggle:Ee,activeRowRef:ee,editingPath:g,editingValue:v,busyPath:b,onNavigate:Ix,prewarm:s,onStartRename:e=>{_(e.path),y(e.name),h(null)},onEditingValueChange:y,onCommitRename:e=>void _e(e),onCancelRename:()=>{b||(_(null),y(``))},onDelete:e=>j(e),onStartCreating:ae,onExpandSubtree:se,onCollapseSubtree:ue,inlineCreate:Oe(e.path),getInlineCreate:Oe,workspace:B,handoff:K},e.path)),Fe;n[46]!==Me||n[47]!==Ne||n[48]!==Pe?(Fe=(0,$.jsxs)(Me,{children:[Ne,Pe]}),n[46]=Me,n[47]=Ne,n[48]=Pe,n[49]=Fe):Fe=n[49];let Ie=!!A,Le;n[50]!==b||n[51]!==j?(Le=e=>{!e&&!b&&j(null)},n[50]=b,n[51]=j,n[52]=Le):Le=n[52];let Re;n[53]!==b||n[54]!==A||n[55]!==ye?(Re=A&&(0,$.jsx)(ix,{itemName:`${A.name}${A.kind===`file`?`.md`:`/`}`,isSubmitting:b===A.path,onDelete:()=>ye(A),customDescription:A.kind===`folder`?`Are you sure you want to delete ${A.name}/ and all files inside? This action cannot be undone.`:void 0}),n[53]=b,n[54]=A,n[55]=ye,n[56]=Re):Re=n[56];let Ve;n[57]!==Ie||n[58]!==Le||n[59]!==Re?(Ve=(0,$.jsx)(zt,{open:Ie,onOpenChange:Le,children:Re}),n[57]=Ie,n[58]=Le,n[59]=Re,n[60]=Ve):Ve=n[60];let He;return n[61]!==je||n[62]!==Fe||n[63]!==Ve?(He=(0,$.jsxs)($.Fragment,{children:[je,Fe,Ve]}),n[61]=je,n[62]=Fe,n[63]=Ve,n[64]=He):He=n[64],He}function Ix(e){Ox(e)}function Lx(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function Rx(){return null}function zx(){return null}function Bx(e){e&&e.scrollIntoView({block:`nearest`})}function Vx(){return new Set}function Hx(){return new Set}function Ux(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)(Dt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(X,{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 Wx(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 Gx(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Ul,Hl,Hl),n;e[0]===t?n=e[1]:(n=Wx(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{Vl(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)(Ux,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function Kx(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Qe,{name:`file-sidebar`,children:(0,$.jsx)(qx,{})}),e[0]=t):t=e[0],t}function qx(){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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(_i,{"aria-hidden":`true`})})})}),(0,$.jsx)(wn,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(jg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Yi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(wg,{children:[r,(0,$.jsxs)(Ag,{align:`end`,children:[i,(0,$.jsxs)(jg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)(oi,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Vi,{"aria-hidden":`true`})})}),(0,$.jsx)(wn,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(by,{children:(0,$.jsx)(Cy,{children:(0,$.jsx)(wy,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(si,{"aria-hidden":`true`})})}),(0,$.jsx)(wn,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Sy,{children:(0,$.jsx)(Fx,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(_y,{variant:`inset`,children:[s,c,(0,$.jsx)(xy,{children:(0,$.jsx)(Gx,{})})]}),e[7]=l):l=e[7],l}function Jx(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentFocus;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)}function Yx(){let e=(0,Q.c)(10),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i}=yn(),a=(0,Z.useRef)(n),o=(0,Z.useRef)(r),s,c;e[0]===n?(s=e[1],c=e[2]):(s=()=>{a.current=n},c=[n],e[0]=n,e[1]=s,e[2]=c),(0,Z.useEffect)(s,c);let l=(0,Z.useRef)(null),u,d;e[3]===r?(u=e[4],d=e[5]):(u=()=>{let e=o.current!==null;if(o.current=r,!(e&&r===null)||Date.now()-Zt()<3e3)return;let t=l.current?.awareness;if(!t)return;let n=Jx(t,Date.now());n&&n!==a.current&&(window.location.hash=me(n))},d=[r],e[3]=r,e[4]=u,e[5]=d),(0,Z.useEffect)(u,d);let f,p;return e[6]!==i||e[7]!==t?(f=()=>{if(i===null)return;let e=new tn,n=new dn({url:i,name:g,document:e,onStateless:$x,onClose:Qx,onDisconnect:Zx}),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`,Xx);let s=null,c=()=>{if(s=null,o.current!==null||Date.now()-Zt()<3e3)return;let e=n.awareness;if(!e)return;let t=Jx(e,Date.now());t&&t!==a.current&&(window.location.hash=me(t))},u=()=>{s!==null&&clearTimeout(s),s=setTimeout(c,300)};return n.awareness?.on(`change`,u),l.current=n,()=>{r(),s!==null&&clearTimeout(s),n.awareness?.off(`change`,u),n.destroy(),e.destroy(),l.current=null}},p=[t,i],e[6]=i,e[7]=t,e[8]=f,e[9]=p):(f=e[8],p=e[9]),(0,Z.useEffect)(f,p),null}function Xx(){Be([`files`,`backlinks`,`graph`])}function Zx(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function Qx(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function $x(e){let{payload:t}=e,n=Jt(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}Be([n.ch])}function eS(){let e=(0,Q.c)(7),{clearTarget:t}=yn(),{openTargetTransition:n}=wt(),{folderPaths:r,loading:i,pages:a}=Se(),o,s;return e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a?(o=()=>{e();function e(){let e=we(window.location.hash);if(!e){Xt(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(i){Xt(`ok/nav/hash-change`,{docName:e,kind:`deferred-loading`});return}let o=W(e,{pages:a,folderPaths:r});Xt(`ok/nav/hash-change`,{docName:e,kind:o.kind}),n(o)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},s=[t,r,i,n,a],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s):(o=e[5],s=e[6]),(0,Z.useEffect)(o,s),null}function tS(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=yn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:Pe(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;Ot({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)($e,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function nS(){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)(Kd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Yx,{}),i=(0,$.jsx)(eS,{}),a=(0,$.jsx)(tS,{}),o=t?(0,$.jsx)(Vd,{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)(Kx,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Qe,{name:`app`,children:(0,$.jsxs)(Bt,{children:[n,(0,$.jsxs)(ae,{children:[r,i,a,o,(0,$.jsxs)(my,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(yy,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(nx,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&yl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&Cl({bridge:window.okDesktop}),Wl(),typeof window<`u`&&Sl({bridge:window.okDesktop});var rS=new vr({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),iS=document.getElementById(`root`);if(!iS)throw Error(`Root element not found`);var aS=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Cr.createRoot)(iS).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(He,{client:rS,children:(0,$.jsxs)(he,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(Fn,{children:aS&&window.okDesktop?(0,$.jsx)(Or,{bridge:window.okDesktop}):(0,$.jsx)(nS,{})}),(0,$.jsx)(Zi,{richColors:!0})]})})}));
|
|
17
|
+
`).replace(/[ \t]+$/gm,``).trimEnd()}function Zv(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function Qv(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function $v(e,t){let n=Zv(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function ey(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 ty(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function ny(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var ry=1280;function iy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(ay),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ry-1}px)`),t=()=>{n(window.innerWidth<ry)};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 ay(){return window.innerWidth<ry}var oy=`sidebar_state`,sy=3600*24*7,cy=`18rem`,ly=`18rem`,uy=`3rem`,dy=`\\`,fy=Z.createContext(null);function py(){let e=Z.use(fy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function my(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=iy(),[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=`${oy}=${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(gy):_(hy)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,x,S;t[14]===y?(x=t[15],S=t[16]):(x=()=>{let e=e=>{e.key===dy&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},S=[y],t[14]=y,t[15]=x,t[16]=S),Z.useEffect(x,S);let C=h?`expanded`:`collapsed`,w;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==C||t[22]!==y?(w={state:C,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=C,t[22]=y,t[23]=w):w=t[23];let T;t[24]===s?T=t[25]:(T={"--sidebar-width":cy,"--sidebar-width-icon":uy,...s},t[24]=s,t[25]=T);let E=T,D;t[26]===r?D=t[27]:(D=b(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=D);let O;t[28]!==n||t[29]!==a||t[30]!==E||t[31]!==D?(O=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:E,className:D,...a,children:n}),t[28]=n,t[29]=a,t[30]=E,t[31]=D,t[32]=O):O=t[32];let k;return t[33]!==O||t[34]!==w?(k=(0,$.jsx)(fy.Provider,{value:w,children:O}),t[33]=O,t[34]=w,t[35]=k):k=t[35],k}function hy(e){return!e}function gy(e){return!e}function _y(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}=py();if(d===`none`){let e;t[8]===r?e=t[9]:(e=b(`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":ly},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(am,{className:`sr-only`,children:[(0,$.jsx)(om,{children:`Sidebar`}),(0,$.jsx)(sm,{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)(im,{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)(tm,{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=b(`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 x=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`,S;t[32]!==r||t[33]!==x?(S=b(`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`,x,r),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]===n?C=t[36]:(C=(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]=C);let w;t[37]!==a||t[38]!==l||t[39]!==C||t[40]!==S?(w=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:S,...a,children:C}),t[37]=a,t[38]=l,t[39]=C,t[40]=S,t[41]=w):w=t[41];let T;return t[42]!==l||t[43]!==p||t[44]!==w||t[45]!==g||t[46]!==y||t[47]!==u?(T=(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,w]}),t[42]=l,t[43]=p,t[44]=w,t[45]=g,t[46]=y,t[47]=u,t[48]=T):T=t[48],T}function vy(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}=py(),o;t[4]===n?o=t[5]:(o=b(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)(Ci,{}),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)(X,{"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 yy(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=b(`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 by(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=b(`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 xy(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=b(`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 Sy(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=b(`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 Cy(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=b(`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 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=b(`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 Ty=Le(`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 Ey(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?Ie:`button`,{isMobile:m,state:h}=py(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=b(Ty({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)(Rn,{asChild:!0,children:v}),t[20]=v,t[21]=y);let x=h!==`collapsed`||m,S;t[22]!==x||t[23]!==c?(S=(0,$.jsx)(wn,{side:`right`,align:`center`,hidden:x,...c}),t[22]=x,t[23]=c,t[24]=S):S=t[24];let C;return t[25]!==y||t[26]!==S?(C=(0,$.jsxs)(jn,{children:[y,S]}),t[25]=y,t[26]=S,t[27]=C):C=t[27],C}function Dy(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?Ie:`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=b(`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 Oy(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=b(`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 ky(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=b(`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 Ay(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?Ie:`a`,d;t[6]===n?d=t[7]:(d=b(`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 jy(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 My(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 Ny(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 Py(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 Fy(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 Iy(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 Ly(e){let t=(0,Q.c)(4),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,Z.useState)(n),a,o;return t[1]===e?(a=t[2],o=t[3]):(a=()=>{if(!e)return;let t=e.awareness;if(!t)return;let n=()=>{let e=Array.from(t.getStates().entries()),n=[];for(let[t,r]of e){let e=r;e.user&&typeof e.user==`object`&&n.push({clientId:t,user:e.user,mode:e.mode??`wysiwyg`})}i(n)};return n(),t.on(`change`,n),()=>{t.off(`change`,n)}},o=[e],t[1]=e,t[2]=a,t[3]=o),(0,Z.useEffect)(a,o),r}function Ry(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`?zy: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 zy(e){return e===`synced`?`synced`:`connected`}var By=`sync-status`;function Vy(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,qt.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:By,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,qt.success(`Reconnected`,{id:By,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)}var Hy={Bird:Lr,Cat:Vr,Dog:ni,Fish:ai,Mouse:ji,Rabbit:Ai,Shrimp:Li,Snail:Ri,Squirrel:Hi,Turtle:qi};function Uy(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)(jy,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Fy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Iy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(Ny,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(My,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Py,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(zi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}var Wy={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function Gy(e){return(e.icon?Wy[e.icon]:void 0)??e.name}function Ky(e){let t=(0,Q.c)(36),{user:n,mode:r}=e;if(n.type===`agent`){let e;t[0]===n.color?e=t[1]:(e={backgroundColor:n.color},t[0]=n.color,t[1]=e);let i;t[2]===n.icon?i=t[3]:(i=(0,$.jsx)(Uy,{icon:n.icon,width:16,height:16,className:`text-white`}),t[2]=n.icon,t[3]=i);let a;t[4]!==r||t[5]!==e||t[6]!==i||t[7]!==n.name?(a=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`agent`,"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:e,children:i})}),t[4]=r,t[5]=e,t[6]=i,t[7]=n.name,t[8]=a):a=t[8];let o;t[9]===n?o=t[10]:(o=Gy(n),t[9]=n,t[10]=o);let s;t[11]===o?s=t[12]:(s=(0,$.jsx)(wn,{children:o}),t[11]=o,t[12]=s);let c;return t[13]!==a||t[14]!==s?(c=(0,$.jsxs)(jn,{children:[a,s]}),t[13]=a,t[14]=s,t[15]=c):c=t[15],c}let i=n.name.split(` `)[1],a=i?Hy[i]:void 0,o;t[16]===n.name?o=t[17]:(o=n.name.split(` `).map(qy).join(``),t[16]=n.name,t[17]=o);let s=o,c;t[18]===n.color?c=t[19]:(c=We(n.color),t[18]=n.color,t[19]=c);let l=c,u;t[20]===n.color?u=t[21]:(u={backgroundColor:n.color},t[20]=n.color,t[21]=u);let d;t[22]!==a||t[23]!==l||t[24]!==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[22]=a,t[23]=l,t[24]=s,t[25]=d):d=t[25];let f;t[26]!==r||t[27]!==u||t[28]!==d||t[29]!==n.name?(f=(0,$.jsx)(Rn,{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[26]=r,t[27]=u,t[28]=d,t[29]=n.name,t[30]=f):f=t[30];let p;t[31]===n.name?p=t[32]:(p=(0,$.jsx)(wn,{children:n.name}),t[31]=n.name,t[32]=p);let m;return t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(jn,{children:[f,p]}),t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function qy(e){return e[0]}function Jy(){let e=(0,Q.c)(4),{activeProvider:t,activeDocName:n}=yn(),r=Ly(t);Vy(Ry(t),n);let i;e[0]===r?i=e[1]:(i=r.map(Yy),e[0]=r,e[1]=i);let a;return e[2]===i?a=e[3]:(a=(0,$.jsx)(`div`,{"data-slot":`presence-bar`,className:`flex items-center gap-2 px-1 py-1.5`,children:(0,$.jsx)(`div`,{className:`flex items-center -space-x-1.5`,children:i})}),e[2]=i,e[3]=a),a}function Yy(e){return(0,$.jsx)(Ky,{user:e.user,mode:e.mode},e.clientId)}function Xy(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)(Xc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Zy(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)(Zc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Qy(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=b(`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)(Qc,{children:(0,$.jsx)($c,{"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 $y(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 eb(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 tb=[{label:`Documentation`,href:`https://docs.inkeep.com/overview`,icon:zr},{label:`Homepage`,href:`https://inkeep.com/`,icon:Un},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:eb},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:$y}],nb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(Zy,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Gr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)(wn,{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)(Xy,{children:[t,(0,$.jsxs)(Qy,{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:tb.map(rb)})})]})]}),e[2]=r):r=e[2],r};function rb(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 ib=`https://github.com/inkeep/open-knowledge/releases`;function ab(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 ob(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:ib}}};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 sb(e){return ed(e)}function cb(e){return`Opened ${e} in your browser.`}function lb(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??sd,c=e.onWebFallbackSuccess??db,l=e.onWebFallbackError??ub,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=ob({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=ab({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(sb(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)(jg,{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)(jg,{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)(Og,{"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)(Ng,{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)(Pg,{}),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)(jg,{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)(jg,{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)(kg,{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)(Eg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function ub(){}function db(){}function fb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Rd(),{dispatch:a}=Dd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=mb,u=pb,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?``:$u(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)(ri,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsx)(X,{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=td.map(e=>{let t=r[e.id];return(0,$.jsx)(lb,{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)(Ag,{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)(wg,{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 pb(e){qt.error(`Couldn't open ${e.displayName} in your browser.`)}function mb(e){qt.success(cb(e.displayName))}var hb={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`},gb=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`,...hb,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},_b=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)(gb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},vb=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)(gb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},yb=(e,t,n)=>Er(e,t,n,`ProjectSwitcher`);function bb(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=wg,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Wt,{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)(Ur,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{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=Ag,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ng,{children:`Switch project`}),_=(0,$.jsx)(Pg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(Ng,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(jg,{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)(Pg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(si,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(jg,{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 xb(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=b(`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)(vl,{"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)(_l,{"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 Sb(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 Cb(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function wb(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 Tb(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)(qr,{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)(Mi,{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)(qr,{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)(Mi,{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)(Ki,{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)(Kr,{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)(yi,{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)(Kr,{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)(qr,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function Eb(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 Db(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 Ob(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 kb(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`}`:Db(e.state):`Sync off`}function Ab(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 wb(e)}catch(t){console.error(`[sync] toggle failed`,t),qt.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)(Tb,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=Db(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)(xb,{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:Ob(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: `,Sb(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)(Xi,{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)(X,{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)(X,{variant:`outline`,size:`xs`,onClick:Mb,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)(X,{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)(X,{variant:`outline`,size:`xs`,onClick:jb,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)(X,{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 jb(){Cb(`sync`)}function Mb(){Cb(`sync`)}function Nb(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}=Yd();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(Kr,{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)(jn,{children:[e,(0,$.jsx)(wn,{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=Eb(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Db(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)(Tb,{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)(Rn,{asChild:!0,children:(0,$.jsx)(Zy,{asChild:!0,children:(0,$.jsxs)(X,{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]:(_=kb(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)(wn,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(jn,{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)(Qy,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(Ab,{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)(Xy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var Pb=[{value:`light`,label:`Light`,icon:Wi},{value:`dark`,label:`Dark`,icon:bi},{value:`system`,label:`System`,icon:Zr}],Fb=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=fe(),r=t===`system`?Zr:t===`dark`?bi:Wi,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)(Tg,{asChild:!0,children:(0,$.jsxs)(X,{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=Pb.map(Ib),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Ag,{align:`end`,children:(0,$.jsx)(Dg,{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)(wg,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function Ib(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Mg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}var Lb=Le(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3! font-mono uppercase`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`,dashed:`border-dashed border-border text-muted-foreground rounded-sm`}},defaultVariants:{variant:`default`}});function Rb(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,variant:i,asChild:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a!==void 0&&a?Ie:`span`,c;t[5]!==n||t[6]!==o?(c=b(Lb({variant:o}),n),t[5]=n,t[6]=o,t[7]=c):c=t[7];let l;return t[8]!==s||t[9]!==r||t[10]!==c||t[11]!==o?(l=(0,$.jsx)(s,{"data-slot":`badge`,"data-variant":o,className:c,...r}),t[8]=s,t[9]=r,t[10]=c,t[11]=o,t[12]=l):l=t[12],l}function zb(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function Bb(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(zb)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function Vb(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}=yn(),{state:T}=py(),E=nd(),D=Ry(y),O;t[0]!==v||t[1]!==E?(O=vd({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,q]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(!1),oe=(0,Z.useRef)(null),se=(0,Z.useRef)(!1),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),de;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>{ce.current=!0,le.current=null,ue.current=null,ee(!1),re(null)},t[16]=de):de=t[16];let J;t[17]===v?J=t[18]:(J=[v],t[17]=v,t[18]=J),(0,Z.useEffect)(de,J);let fe,pe;t[19]===K?(fe=t[20],pe=t[21]):(fe=()=>{if(K){let e=setTimeout(()=>{let e=oe.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},pe=[K],t[19]=K,t[20]=fe,t[21]=pe),(0,Z.useEffect)(fe,pe);let he;t[22]!==v||t[23]!==j?(he=function(){if(!v||j)return;let e=v.split(`/`);ce.current=!1,le.current=v,q(e[e.length-1]),re(null),ue.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=he):he=t[24];let ge=he,_e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(_e=function(){ce.current=!0,le.current=null,ue.current=null,ee(!1),q(``),re(null)},t[25]=_e):_e=t[25];let ve=_e,ye;t[26]!==x||t[27]!==te?(ye=async function(){if(ce.current){ce.current=!1;return}if(se.current)return;let e=le.current;if(!e){ve();return}let t=Zv(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){ve();return}if(t===ue.current)return;if(!Qv(t)){re(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=$v({kind:`file`,path:e,name:r},t);se.current=!0,ae(!0),re(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(ce.current){ae(!1),se.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}),re(`Server error (HTTP ${n.status})`),ae(!1),se.current=!1,ue.current=t;return}if(!n.ok||!Bb(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),re(a?.error||`Server error (HTTP ${n.status})`),ae(!1),se.current=!1,ue.current=t;return}if(!r.ok){re(r.error||`Failed to rename path`),ae(!1),se.current=!1,ue.current=t;return}let a=r.renamed,o=ny(e,a);for(let e of a)x(e.fromDocName);Be([`files`,`backlinks`,`graph`]),ee(!1),q(``),ae(!1),se.current=!1,ue.current=null,le.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}),re(`Network error — please try again`),ae(!1),se.current=!1,ue.current=t}},t[26]=x,t[27]=te,t[28]=ye):ye=t[28];let be=ye,xe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>{G(!1)},t[29]=xe):xe=t[29];let Se;t[30]===s?Se=t[31]:(Se=[s],t[30]=s,t[31]=Se),(0,Z.useEffect)(xe,Se);let Ce;t[32]===d?Ce=t[33]:(Ce=function(){G(!1),d()},t[32]=d,t[33]=Ce);let we=Ce,Te;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(vy,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Te):Te=t[34];let Ee=T===`expanded`?`Hide Files`:`Show Files`,Y;t[35]===Ee?Y=t[36]:(Y=(0,$.jsxs)(jn,{children:[Te,(0,$.jsx)(wn,{children:Ee})]}),t[35]=Ee,t[36]=Y);let De,Oe;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(De=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(bb,{bridge:window.okDesktop})]}):null,Oe=(0,$.jsx)(tv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=De,t[38]=Oe):(De=t[37],Oe=t[38]);let ke;t[39]!==v||t[40]!==be||t[41]!==N||t[42]!==ge||t[43]!==z||t[44]!==j||t[45]!==ie||t[46]!==K||t[47]!==L||t[48]!==ne||t[49]!==te?(ke=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Wt,{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)(ct,{ref:oe,value:te,disabled:ie,"aria-label":`Rename ${v}`,"aria-invalid":ne?!0:void 0,"aria-describedby":ne?`editor-header-rename-error`:void 0,"aria-busy":ie||void 0,onChange:e=>{q(e.target.value),re(null),ue.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),be()):e.key===`Escape`&&(e.preventDefault(),ve())},onBlur:()=>void be(),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`})]}),ne&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:ne})]}):(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:ge,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]=be,t[41]=N,t[42]=ge,t[43]=z,t[44]=j,t[45]=ie,t[46]=K,t[47]=L,t[48]=ne,t[49]=te,t[50]=ke):ke=t[50];let Ae;t[51]!==v||t[52]!==B||t[53]!==H?(Ae=v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{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)(Oi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(Di,{className:`size-4`})})}),(0,$.jsx)(wn,{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]=Ae):Ae=t[54];let je;t[55]===M?je=t[56]:(je=M&&(0,$.jsx)(Rb,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=je);let Me;t[57]!==Y||t[58]!==ke||t[59]!==Ae||t[60]!==je?(Me=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Y,De,Oe,ke,Ae,je]}),t[57]=Y,t[58]=ke,t[59]=Ae,t[60]=je,t[61]=Me):Me=t[61];let Ne;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Ne=!U&&v&&(0,$.jsxs)(zn,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(vb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(Pn,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(_b,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)(wn,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)(wn,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Ne):Ne=t[67];let Pe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Pe=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)(zn,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Pi,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(Pn,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Yr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ni,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)(wn,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(Dt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)(wn,{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]=Pe):Pe=t[75];let Fe;t[76]!==W||t[77]!==we||t[78]!==U||t[79]!==s||t[80]!==c?(Fe=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)(X,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(X,{variant:`default`,size:`xs`,onClick:we,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=we,t[78]=U,t[79]=s,t[80]=c,t[81]=Fe):Fe=t[81];let Ie;t[82]!==U||t[83]!==_?(Ie=!U&&_&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(li,{className:`size-3.5`})})}),(0,$.jsx)(wn,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Ie):Ie=t[84];let Le;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Le=!U&&v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Fi,{className:`size-3.5`})})}),(0,$.jsx)(wn,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Le):Le=t[89];let Re;t[90]!==v||t[91]!==i?(Re=v&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(fi,{className:`size-4`})})}),(0,$.jsx)(wn,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Re):Re=t[92];let ze;t[93]!==v||t[94]!==k||t[95]!==U?(ze=!U&&v&&(0,$.jsx)(fb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=ze):ze=t[96];let Ve;t[97]!==g||t[98]!==h||t[99]!==m?(Ve=(0,$.jsx)(Nb,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=Ve):Ve=t[100];let He,Ue,We,Ge;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(He=(0,$.jsx)(Jy,{}),Ue=(0,$.jsx)(tv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),We=(0,$.jsx)(nb,{}),Ge=(0,$.jsx)(Fb,{}),t[101]=He,t[102]=Ue,t[103]=We,t[104]=Ge):(He=t[101],Ue=t[102],We=t[103],Ge=t[104]);let Ke;t[105]!==Ie||t[106]!==Le||t[107]!==Re||t[108]!==ze||t[109]!==Ve?(Ke=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Ie,Le,Re,ze,Ve,He,Ue,We,Ge]}),t[105]=Ie,t[106]=Le,t[107]=Re,t[108]=ze,t[109]=Ve,t[110]=Ke):Ke=t[110];let qe;return t[111]!==Me||t[112]!==Ne||t[113]!==Pe||t[114]!==Fe||t[115]!==Ke?(qe=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Me,Ne,Pe,Fe,Ke]}),t[111]=Me,t[112]=Ne,t[113]=Pe,t[114]=Fe,t[115]=Ke,t[116]=qe):qe=t[116],qe}function Hb(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 Ub(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 Wb(e){if(e.contributors.length>0){let t=e.contributors[0];return{hex:ne(t.colorSeed??t.name)}}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 Gb(e){let t=Wb(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 Kb(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(qb),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ur,{className:`size-3`}):(0,$.jsx)(Wr,{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)(Zb,{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 qb(e){return!e}function Jb(e){return e.checkpoint?e.checkpoint.kind:`save`}function Yb(e){let t=Jb(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${Xb(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function Xb(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function Zb(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=Hb(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=Ub(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(Qb);_=`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=Jb(n);return e===`bridge-merge-loss`?(0,$.jsx)(Ki,{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)(ii,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(ti,{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:Gb(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:Yb(n)}),Gb(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 Qb(e){return e.docs}function $b(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(tx),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)(om,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(X,{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)(am,{className:`border-b px-4 py-3 pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,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(ex)}),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)(Zb,{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)(Zb,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(Kb,{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)(X,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ni,{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)(im,{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)(tm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function ex(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(af,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(af,{className:`h-3 w-24`}),(0,$.jsx)(af,{className:`h-3 w-40`})]}),(0,$.jsx)(af,{className:`h-3 w-14`})]},e)}function tx(e){return e.type===`checkpoint`}function nx(){let e=(0,Q.c)(71),[t,n]=(0,Z.useState)(`wysiwyg`),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`auth`),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(`unified`),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),E=(0,Z.useRef)(!1),D=(0,Z.useRef)(`wysiwyg`),O=Jd(),k,A;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>()=>{T.current&&clearTimeout(T.current)},A=[],e[0]=k,e[1]=A):(k=e[0],A=e[1]),(0,Z.useEffect)(k,A);let{activeDocName:j,activeTarget:M}=yn(),N;e[2]===t?N=e[3]:(N=function(e){e.sha?(t!==`diff`&&(D.current=t===`source`?`source`:`wysiwyg`),g(e),n(`diff`)):(g(null),n(D.current)),S(null)},e[2]=t,e[3]=N);let P=N,F;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=function(){g(null),n(D.current),S(null)},e[4]=F):F=e[4];let I=F,L;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(){I(),qt.info(`No changes since this version`)},e[5]=L):L=e[5];let R=L,z,B;e[6]===j?(z=e[7],B=e[8]):(z=()=>{let e=function(e){let t=e.detail;t&&j&&bn(j,{kind:`raw-mdx`,detail:t}),n(`source`)};return window.addEventListener(gt,e),()=>window.removeEventListener(gt,e)},B=[j],e[6]=j,e[7]=z,e[8]=B),(0,Z.useEffect)(z,B);let V;e[9]!==M?.kind||e[10]!==t?(V=()=>{M?.kind===`folder`&&(g(null),i(!1),t===`diff`&&n(D.current))},e[9]=M?.kind,e[10]=t,e[11]=V):V=e[11];let H;e[12]!==M||e[13]!==t?(H=[M,t],e[12]=M,e[13]=t,e[14]=H):H=e[14],(0,Z.useEffect)(V,H);let U;e[15]===O?U=e[16]:(U=()=>{!E.current&&O?.state===`dormant`&&O.hasRemote&&(E.current=!0,qt.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>c(!0)}}))},e[15]=O,e[16]=U);let W=O?.state,G=O?.hasRemote,K;e[17]!==W||e[18]!==G?(K=[W,G],e[17]=W,e[18]=G,e[19]=K):K=e[19],(0,Z.useEffect)(U,K);let ee;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(ee=function(e){n(e)},e[20]=ee):ee=e[20];let te=ee,q;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(q=async function(){w(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?qt.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),qt.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),qt.error(`Checkpoint failed — try again`)}w(!1)},e[21]=q):q=e[21];let ne=q,re;e[22]!==j||e[23]!==h?(re=async function(){if(!(!h?.sha||!j)){b(!0);try{(await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:j,commitSha:h.sha})})).ok?(g(null),n(D.current),S(null)):(S(`Restore failed — document unchanged`),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(null),4e3))}catch{S(`Restore failed — document unchanged`),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(null),4e3)}b(!1)}},e[22]=j,e[23]=h,e[24]=re):re=e[24];let ie=re,ae;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(uf,{onOpenResolver:()=>o(!0)}),e[25]=ae):ae=e[25];let oe;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>i(rx),e[26]=oe):oe=e[26];let se,ce,le,ue;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{u(`auth`),c(!0)},ce=()=>{u(`identity`),c(!0)},le=()=>o(!0),ue=()=>f(!0),e[27]=se,e[28]=ce,e[29]=le,e[30]=ue):(se=e[27],ce=e[28],le=e[29],ue=e[30]);let de;e[31]!==_||e[32]!==t||e[33]!==ie||e[34]!==h||e[35]!==x||e[36]!==y||e[37]!==C?(de=(0,$.jsx)(Vb,{editorMode:t,onModeChange:te,onTimelineToggle:oe,onSaveVersion:ne,saving:C,previewEntry:h,restoring:y,restoreError:x,onExitPreview:I,onRestore:ie,diffLayout:_,onDiffLayoutChange:v,onSignIn:se,onSetIdentity:ce,onOpenConflictResolver:le,onOpenClone:ue}),e[31]=_,e[32]=t,e[33]=ie,e[34]=h,e[35]=x,e[36]=y,e[37]=C,e[38]=de):de=e[38];let J;e[39]!==t||e[40]!==h?(J=t===`diff`&&h&&(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: `,Hb(h.timestamp),` — `,Ub(h)]})}),e[39]=t,e[40]=h,e[41]=J):J=e[41];let fe;e[42]!==_||e[43]!==t||e[44]!==h?(fe=(0,$.jsx)(qv,{editorMode:t,previewEntry:h,diffLayout:_,onNoDiff:R}),e[42]=_,e[43]=t,e[44]=h,e[45]=fe):fe=e[45];let pe=j??``,me=h?.sha,he;e[46]!==P||e[47]!==pe||e[48]!==me||e[49]!==r?(he=(0,$.jsx)($b,{open:r,onOpenChange:i,docName:pe,onEntrySelect:P,selectedSha:me}),e[46]=P,e[47]=pe,e[48]=me,e[49]=r,e[50]=he):he=e[50];let ge;e[51]===a?ge=e[52]:(ge=(0,$.jsx)(pm,{open:a,onOpenChange:o}),e[51]=a,e[52]=ge);let _e;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>{c(e),e||m(!1)},e[53]=_e):_e=e[53];let ve=l===`identity`,ye;e[54]===p?ye=e[55]:(ye=()=>{c(!1),p&&(m(!1),f(!0))},e[54]=p,e[55]=ye);let be;e[56]!==s||e[57]!==ve||e[58]!==ye?(be=(0,$.jsx)(nf,{open:s,onOpenChange:_e,identityPrompt:ve,onSuccess:ye}),e[56]=s,e[57]=ve,e[58]=ye,e[59]=be):be=e[59];let xe;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[60]=xe):xe=e[60];let Se;e[61]===d?Se=e[62]:(Se=(0,$.jsx)(cf,{open:d,onOpenChange:f,onSignIn:xe}),e[61]=d,e[62]=Se);let Ce;return e[63]!==de||e[64]!==J||e[65]!==fe||e[66]!==he||e[67]!==ge||e[68]!==be||e[69]!==Se?(Ce=(0,$.jsxs)($.Fragment,{children:[ae,de,J,fe,he,ge,be,Se]}),e[63]=de,e[64]=J,e[65]=fe,e[66]=he,e[67]=ge,e[68]=be,e[69]=Se,e[70]=Ce):Ce=e[70],Ce}function rx(e){return!e}var ix=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function ax(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function ox(e){return`nodeType`in e}function sx(e){return e?ax(e)?e:ox(e)?e.ownerDocument?.defaultView??window:window:window}function cx(e){let{Document:t}=sx(e);return e instanceof t}function lx(e){return ax(e)?!1:e instanceof sx(e).HTMLElement}function ux(e){return e instanceof sx(e).SVGElement}function dx(e){return e?ax(e)?e.document:ox(e)?cx(e)?e:lx(e)||ux(e)?e.ownerDocument:document:document:document}var fx=ix?Z.useLayoutEffect:Z.useEffect;function px(e){let t=(0,Z.useRef)(e);return fx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function mx(){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 hx(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return fx(()=>{n.current!==e&&(n.current=e)},t),n}function gx(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function _x(e){let t=px(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function vx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var yx={};function bx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=yx[e]==null?0:yx[e]+1;return yx[e]=n,e+`-`+n},[e,t])}function xx(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 Sx=xx(1),Cx=xx(-1);function wx(e){return`clientX`in e&&`clientY`in e}function Tx(e){if(!e)return!1;let{KeyboardEvent:t}=sx(e.target);return t&&e instanceof t}function Ex(e){if(!e)return!1;let{TouchEvent:t}=sx(e.target);return t&&e instanceof t}function Dx(e){if(Ex(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 wx(e)?{x:e.clientX,y:e.clientY}:null}var Ox=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[Ox.Translate.toString(e),Ox.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),kx=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Ax(e){return e.matches(kx)?e:e.querySelector(kx)}var jx={display:`none`};function Mx(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:jx},n)}function Nx(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 Px(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Fx=(0,Z.createContext)(null);function Ix(e){let t=(0,Z.useContext)(Fx);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Lx(){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 Rx={draggable:`
|
|
18
|
+
To pick up a draggable item, press the space bar.
|
|
19
|
+
While dragging, use the arrow keys to move the item.
|
|
20
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
21
|
+
`},zx={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 Bx(e){let{announcements:t=zx,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Rx}=e,{announce:a,announcement:o}=Px(),s=bx(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),Ix((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(Mx,{id:r,value:i.draggable}),Z.createElement(Nx,{id:s,announcement:o}));return n?(0,E_.createPortal)(u,n):u}var Vx;(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`})(Vx||={});function Hx(){}function Ux(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Wx(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Gx=Object.freeze({x:0,y:0});function Kx(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function qx(e,t){let n=Dx(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 Jx(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yx(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Xx(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 Zx(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Qx(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 $x=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=Qx(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Yx)};function eS(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 tS=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&&eS(r,a)){let n=Xx(a).reduce((e,t)=>e+Kx(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(Jx)};function nS(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function rS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Gx}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 aS=iS(1);function oS(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 sS(e,t,n){let r=oS(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 cS={ignoreTransform:!1};function lS(e,t){t===void 0&&(t=cS);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=sx(e).getComputedStyle(e);t&&(n=sS(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 uS(e){return lS(e,{ignoreTransform:!0})}function dS(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function fS(e,t){return t===void 0&&(t=sx(e).getComputedStyle(e)),t.position===`fixed`}function pS(e,t){t===void 0&&(t=sx(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 mS(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(cx(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!lx(i)||ux(i)||n.includes(i))return n;let a=sx(e).getComputedStyle(i);return i!==e&&pS(i,a)&&n.push(i),fS(i,a)?n:r(i.parentNode)}return e?r(e):n}function hS(e){let[t]=mS(e,1);return t??null}function gS(e){return!ix||!e?null:ax(e)?e:ox(e)?cx(e)||e===dx(e).scrollingElement?window:lx(e)?e:null:null}function _S(e){return ax(e)?e.scrollX:e.scrollLeft}function vS(e){return ax(e)?e.scrollY:e.scrollTop}function yS(e){return{x:_S(e),y:vS(e)}}var bS;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(bS||={});function xS(e){return!ix||!e?!1:e===document.scrollingElement}function SS(e){let t={x:0,y:0},n=xS(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 CS={x:.2,y:.2};function wS(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=CS);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=SS(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=bS.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=bS.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=bS.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=bS.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function TS(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 ES(e){return e.reduce((e,t)=>Sx(e,yS(t)),Gx)}function DS(e){return e.reduce((e,t)=>e+_S(t),0)}function OS(e){return e.reduce((e,t)=>e+vS(t),0)}function kS(e,t){if(t===void 0&&(t=lS),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);hS(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var AS=[[`x`,[`left`,`right`],DS],[`y`,[`top`,`bottom`],OS]],jS=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=mS(t),r=ES(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of AS)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})}},MS=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 NS(e){let{EventTarget:t}=sx(e);return e instanceof t?e:dx(e)}function PS(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 FS;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(FS||={});function IS(e){e.preventDefault()}function LS(e){e.stopPropagation()}var RS;(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`})(RS||={});var zS={start:[RS.Space,RS.Enter],cancel:[RS.Esc],end:[RS.Space,RS.Enter,RS.Tab]},BS=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case RS.Right:return{...n,x:n.x+25};case RS.Left:return{...n,x:n.x-25};case RS.Down:return{...n,y:n.y+25};case RS.Up:return{...n,y:n.y-25}}},VS=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 MS(dx(t)),this.windowListeners=new MS(sx(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(FS.Resize,this.handleCancel),this.windowListeners.add(FS.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(FS.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&kS(n),t(Gx)}handleKeyDown(e){if(Tx(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=zS,coordinateGetter:a=BS,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}:Gx;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Cx(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}=SS(n),p=TS(n),m={x:Math.min(i===RS.Right?p.right-p.width/2:p.right,Math.max(i===RS.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===RS.Down?p.bottom-p.height/2:p.bottom,Math.max(i===RS.Down?p.top:p.top+p.height/2,u.y))},h=i===RS.Right&&!s||i===RS.Left&&!c,g=i===RS.Down&&!l||i===RS.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===RS.Right&&e<=d.x||i===RS.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===RS.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===RS.Down&&e<=d.y||i===RS.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===RS.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Sx(Cx(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()}};VS.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=zS,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 HS(e){return!!(e&&`distance`in e)}function US(e){return!!(e&&`delay`in e)}var WS=class{constructor(e,t,n){n===void 0&&(n=NS(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=dx(i),this.documentListeners=new MS(this.document),this.listeners=new MS(n),this.windowListeners=new MS(sx(i)),this.initialCoordinates=Dx(r)??Gx,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(FS.Resize,this.handleCancel),this.windowListeners.add(FS.DragStart,IS),this.windowListeners.add(FS.VisibilityChange,this.handleCancel),this.windowListeners.add(FS.ContextMenu,IS),this.documentListeners.add(FS.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(US(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(HS(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(FS.Click,LS,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(FS.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=Dx(e)??Gx,s=Cx(n,o);if(!t&&a){if(HS(a)){if(a.tolerance!=null&&PS(s,a.tolerance))return this.handleCancel();if(PS(s,a.distance))return this.handleStart()}if(US(a)&&PS(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===RS.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},GS={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},KS=class extends WS{constructor(e){let{event:t}=e,n=dx(t.target);super(e,GS,n)}};KS.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 qS={move:{name:`mousemove`},end:{name:`mouseup`}},JS;(function(e){e[e.RightClick=2]=`RightClick`})(JS||={});var YS=class extends WS{constructor(e){super(e,qS,dx(e.event.target))}};YS.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===JS.RightClick?!1:(r?.({event:n}),!0)}}];var XS={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},ZS=class extends WS{constructor(e){super(e,XS)}static setup(){return window.addEventListener(XS.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(XS.move.name,e)};function e(){}}};ZS.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 QS;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(QS||={});var $S;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})($S||={});function eC(e){let{acceleration:t,activator:n=QS.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=$S.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=nC({delta:d,disabled:!a}),[m,h]=mx(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case QS.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case QS.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===$S.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}=wS(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 tC={x:{[bS.Backward]:!1,[bS.Forward]:!1},y:{[bS.Backward]:!1,[bS.Forward]:!1}};function nC(e){let{delta:t,disabled:n}=e,r=vx(t);return gx(e=>{if(n||!r||!e)return tC;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[bS.Backward]:e.x[bS.Backward]||i.x===-1,[bS.Forward]:e.x[bS.Forward]||i.x===1},y:{[bS.Backward]:e.y[bS.Backward]||i.y===-1,[bS.Forward]:e.y[bS.Forward]||i.y===1}}},[n,t,r])}function rC(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return gx(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 aC;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(aC||={});var oC;(function(e){e.Optimized=`optimized`})(oC||={});var sC=new Map;function cC(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=hx(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=gx(t=>{if(d&&!n)return sC;if(!t||t===sC||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 jS(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 aC.Always:return!1;case aC.BeforeDragging:return n;default:return!n}}}function lC(e,t){return gx(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function uC(e,t){return lC(e,t)}function dC(e){let{callback:t,disabled:n}=e,r=px(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 fC(e){let{callback:t,disabled:n}=e,r=px(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 pC(e){return new jS(lS(e),e)}function mC(e,t,n){t===void 0&&(t=pC);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=dC({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=fC({callback:a});return fx(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function hC(e){return rS(e,lC(e))}var gC=[];function _C(e){let t=(0,Z.useRef)(e),n=gx(n=>e?n&&n!==gC&&e&&t.current&&e.parentNode===t.current.parentNode?n:mS(e):gC,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function vC(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=gS(e.target);t&&n(e=>e?(e.set(t,yS(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=gS(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,yS(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=>{gS(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Sx(e,t),Gx):ES(e):Gx,[e,t])}function yC(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!==Gx;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Cx(e,n.current):Gx}function bC(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 xC(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 SC(e){return(0,Z.useMemo)(()=>e?dS(e):null,[e])}var CC=[];function wC(e,t){t===void 0&&(t=lS);let[n]=e,r=SC(n?sx(n):null),[i,a]=(0,Z.useState)(CC);function o(){a(()=>e.length?e.map(e=>xS(e)?r:new jS(t(e),e)):CC)}let s=fC({callback:o});return fx(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function TC(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return lx(t)?t:e}function EC(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=fC({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]=_x((0,Z.useCallback)(e=>{let n=TC(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 DC=[{sensor:KS,options:{}},{sensor:VS,options:{}}],OC={current:{}},kC={draggable:{measure:uS},droppable:{measure:uS,strategy:aC.WhileDragging,frequency:oC.Optimized},dragOverlay:{measure:lS}},AC=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}},jC={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new AC,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Hx},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kC,measureDroppableContainers:Hx,windowRect:null,measuringScheduled:!1},MC={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Hx,draggableNodes:new Map,over:null,measureDroppableContainers:Hx},NC=(0,Z.createContext)(MC),PC=(0,Z.createContext)(jC);function FC(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new AC}}}function IC(e,t){switch(t.type){case Vx.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Vx.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 Vx.DragEnd:case Vx.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Vx.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new AC(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Vx.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 AC(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Vx.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new AC(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function LC(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(NC),a=vx(r),o=vx(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Tx(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=Ax(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function RC(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function zC(e){return(0,Z.useMemo)(()=>({draggable:{...kC.draggable,...e?.draggable},droppable:{...kC.droppable,...e?.droppable},dragOverlay:{...kC.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function BC(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;fx(()=>{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=rS(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=hS(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var VC=(0,Z.createContext)({...Gx,scaleX:1,scaleY:1}),HC;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(HC||={});var UC=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=DC,collisionDetection:o=$x,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(IC,void 0,FC),[f,p]=Lx(),[m,h]=(0,Z.useState)(HC.Uninitialized),g=m===HC.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??OC,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=hx(l,Object.values(l)),A=bx(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=zC(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=cC(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=rC(v,_),L=(0,Z.useMemo)(()=>D?Dx(D):null,[D]),R=be(),z=uC(I,M.draggable.measure);BC({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=mC(I,M.draggable.measure,z),V=mC(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=EC({measure:M.dragOverlay.measure}),G=W.nodeRef.current??I,K=g?W.rect??B:null,ee=!!(W.nodeRef.current&&W.rect),te=hC(ee?null:B),q=SC(G?sx(G):null),ne=_C(g?U??I:null),re=wC(ne),ie=RC(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:ne,scrollableAncestorRects:re,windowRect:q}),ae=L?Sx(L,y):null,oe=vC(ne),se=yC(oe),ce=yC(oe,[B]),le=Sx(ie,se),ue=K?aS(K,ie):null,de=C&&ue?o({active:C,collisionRect:ue,droppableRects:N,droppableContainers:j,pointerCoordinates:ae}):null,J=Zx(de,`id`),[fe,pe]=(0,Z.useState)(null),me=nS(ee?ie:Sx(ie,ce),fe?.rect??null,B),he=(0,Z.useRef)(null),ge=(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;he.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,E_.unstable_batchedUpdates)(()=>{r?.(i),h(HC.Initializing),d({type:Vx.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(he.current),O(a)})},onMove(e){d({type:Vx.DragMove,coordinates:e})},onEnd:o(Vx.DragEnd),onCancel:o(Vx.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===Vx.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Vx.DragCancel)}w.current=null,(0,E_.unstable_batchedUpdates)(()=>{d({type:e}),h(HC.Uninitialized),pe(null),E(null),O(null),he.current=null;let t=e===Vx.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),_e=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,ge(n,t))},[v,ge]));bC(a),fx(()=>{B&&m===HC.Initializing&&h(HC.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,E_.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(J),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,E_.unstable_batchedUpdates)(()=>{pe(s),a?.(c),f({type:`onDragOver`,event:c})})},[J]),fx(()=>{H.current={activatorEvent:D,active:C,activeNode:I,collisionRect:ue,collisions:de,droppableRects:N,draggableNodes:v,draggingNode:G,draggingNodeRect:K,droppableContainers:b,over:fe,scrollableAncestors:ne,scrollAdjustedTranslate:le},S.current={initial:K,translated:ue}},[C,I,de,ue,v,G,K,N,b,fe,ne,le]),eC({...R,delta:y,draggingRect:ue,pointerCoordinates:ae,scrollableAncestors:ne,scrollableAncestorRects:re});let ve=(0,Z.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:de,containerNodeRect:V,dragOverlay:W,draggableNodes:v,droppableContainers:b,droppableRects:N,over:fe,measureDroppableContainers:P,scrollableAncestors:ne,scrollableAncestorRects:re,measuringConfiguration:M,measuringScheduled:F,windowRect:q}),[C,I,B,D,de,V,W,v,b,N,fe,P,ne,re,M,F,q]),ye=(0,Z.useMemo)(()=>({activatorEvent:D,activators:_e,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:fe,measureDroppableContainers:P}),[D,_e,C,B,d,A,v,fe,P]);return Z.createElement(Fx.Provider,{value:p},Z.createElement(NC.Provider,{value:ye},Z.createElement(PC.Provider,{value:ve},Z.createElement(VC.Provider,{value:me},i)),Z.createElement(LC,{disabled:n?.restoreFocus===!1})),Z.createElement(Bx,{...n,hiddenTextDescribedById:A}));function be(){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}}}),WC=(0,Z.createContext)(null),GC=`button`,KC=`Draggable`;function qC(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=bx(KC),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(NC),{role:p=GC,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?VC:WC),[v,y]=_x(),[b,x]=_x(),S=xC(o,t),C=hx(n);return fx(()=>(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===GC?!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 JC(){return(0,Z.useContext)(PC)}var YC=`Droppable`,XC={timeout:25};function ZC(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=bx(YC),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(NC),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}={...XC,...i},_=hx(h??r),v=fC({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]=_x((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=hx(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:Vx.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Vx.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:Vx.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 QC(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=vx(n);return!n&&!r&&s&&i(s),fx(()=>{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 $C={x:0,y:0,scaleX:1,scaleY:1};function ew(e){let{children:t}=e;return Z.createElement(NC.Provider,{value:MC},Z.createElement(VC.Provider,{value:$C},t))}var tw={position:`fixed`,touchAction:`none`},nw=e=>Tx(e)?`transform 250ms ease`:void 0,rw=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=nw}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...tw,width:s.width,height:s.height,top:s.top,left:s.left,transform:Ox.Transform.toString(d),transformOrigin:i&&r?qx(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:Ox.Transform.toString(t)},{transform:Ox.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 aw(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return px((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=TC(a);if(!c)return;let{transform:l}=sx(a).getComputedStyle(a),u=oS(l);if(!u)return;let d=typeof t==`function`?t:ow(t);return kS(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 ow(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 sw=0;function cw(e){return(0,Z.useMemo)(()=>{if(e!=null)return sw++,sw},[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}=JC(),S=(0,Z.useContext)(VC),C=cw(d?.id),w=RC(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=aw({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(ew,null,Z.createElement(QC,{animation:E},d&&C?Z.createElement(rw,{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 uw(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)(Ut,{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)(Vt,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(X,{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)(cn,{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)(X,{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)(en,{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)(pn,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function dw(e){let t=e.lastIndexOf(`/`);return t<=0?``:e.slice(0,t)}function fw(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function pw(e,t){return e?`${e}/${t}`:t}function mw(e,t){return pw(t,fw(e.path))}function hw(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=mw(e,t);return n===e.path?{ok:!1,reason:`no_op`}:{ok:!0,destinationPath:n}}function gw(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 _w(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)(bs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function vw(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=b(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(xs,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}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)(Es,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function bw(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=b(`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)(Ss,{children:(0,$.jsx)(Cs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xw(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=b(`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)(ws,{"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 Sw(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=b(`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)(Wr,{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)(Ds,{"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 Cw(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=b(`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)(Os,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ww(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=b(`-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)(Ts,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Tw(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 Ew(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)(Sw,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=td.map(e=>{let t=r[e.id],o=ob({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=Tw(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)(xw,{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)(yw,{children:[o,(0,$.jsx)(Cw,{children:s})]}),t[6]=s,t[7]=c),c}var Dw=80,Ow=3,kw=20,Aw=new Map,jw=new Set,Mw=[],Nw=new Map;function Pw(e){for(Nw.delete(e),Nw.set(e,!0);Nw.size>kw;){let e=Nw.keys().next().value;if(e===void 0)break;Nw.delete(e)}}function Fw(e){jw.delete(e),Iw()}function Iw(){for(;jw.size<Ow&&Mw.length>0;){let e=Mw.shift();if(!e)break;if(!Nw.has(e.docName)){jw.add(e.docName),Pw(e.docName);try{e.prewarm(e.docName)}catch(t){Xt(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{Fw(e.docName)}}}}function Lw(e,t){if(Yt(e)||Nw.has(e))return;let n=Aw.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(Aw.delete(e),jw.size>=Ow){Mw.push({docName:e,prewarm:t});return}Pw(e),jw.add(e);try{t(e)}catch(t){Xt(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{Fw(e)}},Dw);Aw.set(e,{timer:r,prewarm:t})}function Rw(e){let t=Aw.get(e);t&&(clearTimeout(t.timer),Aw.delete(e))}var zw=(0,Z.createContext)(null);function Bw(){return(0,Z.use)(zw)}function Vw(e){window.location.hash=me(e)}function Hw(e){return e.kind===`file`?`${e.path}.md`:e.path}async function Uw(e,t){try{await navigator.clipboard.writeText(e),qt.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),qt.error(`Could not copy ${t}`)}}var Ww=new Set([`agents`,`agent`,`claude`,`skill`]);function Gw(e){return e.kind===`file`&&Ww.has(e.name.toLowerCase())}function Kw(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=b(`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)(ci,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(mn,{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=b(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let x;t[7]!==i||t[8]!==a||t[9]!==c?(x=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=x):x=t[10];let S;t[11]===o?S=t[12]:(S=e=>o(e.target.value),t[11]=o,t[12]=S);let C;t[13]!==c||t[14]!==s?(C=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=C):C=t[15];let w;t[16]!==i||t[17]!==y||t[18]!==x||t[19]!==S||t[20]!==C||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(w=(0,$.jsx)(ct,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:x,onChange:S,onKeyDown:C}),t[16]=i,t[17]=y,t[18]=x,t[19]=S,t[20]=C,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=w):w=t[26];let T;t[27]===n?T=t[28]:(T=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=T);let E;t[29]!==w||t[30]!==T||t[31]!==p?(E=(0,$.jsxs)(`div`,{className:f,children:[p,w,T]}),t[29]=w,t[30]=T,t[31]=p,t[32]=E):E=t[32];let D;t[33]===a?D=t[34]:(D=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=D);let O;return t[35]!==E||t[36]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[E,D]}),t[35]=E,t[36]=D,t[37]=O):O=t[37],O}function qw(e,t){if(!e)return``;let n=hw(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 Jw(e){let t=(0,Q.c)(11),{treeActionsLocked:n}=e,r=Bw(),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}=ZC(a);if(!r)return null;let c;t[3]!==r||t[4]!==s?(c=s&&qw(r,``),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=b(`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)(wy,{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 Yw=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:x,onDelete:S,onStartCreating:C,onExpandSubtree:w,onCollapseSubtree:T,inlineCreate:E,getInlineCreate:D}=e,O=r===void 0?!1:r,k=(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?mn:M?Wt:ci,B=O?ky:wy,V=O?Ay:Ey,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?dw(n.path):n.path,t[7]=j,t[8]=n.path,t[9]=W):W=t[9];let G=W,K=Bw(),ee=`drag-${n.kind}-${n.path}`,te=f||P,q;t[10]===U?q=t[11]:(q={source:U},t[10]=U,t[11]=q);let ne;t[12]!==ee||t[13]!==te||t[14]!==q?(ne={id:ee,disabled:te,data:q},t[12]=ee,t[13]=te,t[14]=q,t[15]=ne):ne=t[15];let{attributes:re,listeners:ie,setNodeRef:ae,isDragging:oe}=qC(ne),se=`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]!==se||t[19]!==ce||t[20]!==f?(le={id:se,disabled:f,data:ce},t[18]=se,t[19]=ce,t[20]=f,t[21]=le):le=t[21];let{setNodeRef:ue,isOver:de}=ZC(le),J;t[22]!==c||t[23]!==N||t[24]!==ae||t[25]!==ue?(J=e=>{ae(e),ue(e),N&&c(e)},t[22]=c,t[23]=N,t[24]=ae,t[25]=ue,t[26]=J):J=t[26];let fe=J,pe=de&&K?qw(K,G):``,me=j&&n.isSymlink,he;t[27]===n?he=t[28]:(he=Gw(n),t[27]=n,t[28]=he);let ge=he,_e;t[29]!==j||t[30]!==n.path||t[31]!==g?(_e=j?()=>{Lw(n.path,e=>{g(e)})}:void 0,t[29]=j,t[30]=n.path,t[31]=g,t[32]=_e):_e=t[32];let ve=_e,ye;t[33]!==j||t[34]!==n.path?(ye=j?()=>{Rw(n.path)}:void 0,t[33]=j,t[34]=n.path,t[35]=ye):ye=t[35];let be=ye,xe=N?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,Se;t[36]!==z||t[37]!==xe?(Se=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:xe}),t[36]=z,t[37]=xe,t[38]=Se):Se=t[38];let Ce=N?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,we;t[39]===Ce?we=t[40]:(we=b(`min-w-0 flex-1 truncate text-sm`,Ce),t[39]=Ce,t[40]=we);let Te=n.name+(j?`.md`:``),Ee;t[41]!==we||t[42]!==Te?(Ee=(0,$.jsx)(`span`,{className:we,children:Te}),t[41]=we,t[42]=Te,t[43]=Ee):Ee=t[43];let Y;t[44]!==n.canonicalDocName||t[45]!==n.targetPath||t[46]!==me?(Y=me&&(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(hi,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)(wn,{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]=me,t[47]=Y):Y=t[47];let De;t[48]===ge?De=t[49]:(De=ge&&(0,$.jsx)(Br,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[48]=ge,t[49]=De);let Oe;t[50]!==Se||t[51]!==Ee||t[52]!==Y||t[53]!==De?(Oe=(0,$.jsxs)($.Fragment,{children:[Se,Ee,Y,De]}),t[50]=Se,t[51]=Ee,t[52]=Y,t[53]=De,t[54]=Oe):Oe=t[54];let ke=Oe,X=!O&&`ml-2`,Ae=N&&`bg-sidebar-accent text-sidebar-accent-foreground`,je;t[55]!==X||t[56]!==Ae?(je=b(`flex h-8 items-center gap-2 rounded-md px-2`,X,Ae),t[55]=X,t[56]=Ae,t[57]=je):je=t[57];let Me;t[58]===z?Me=t[59]:(Me=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[58]=z,t[59]=Me);let Ne=`Rename ${n.kind}`,Pe;t[60]===v?Pe=t[61]:(Pe=e=>v(e.target.value),t[60]=v,t[61]=Pe);let Fe;t[62]!==x||t[63]!==y||t[64]!==U?(Fe=e=>{e.key===`Enter`?(e.preventDefault(),y(U)):e.key===`Escape`&&(e.preventDefault(),x())},t[62]=x,t[63]=y,t[64]=U,t[65]=Fe):Fe=t[65];let Ie;t[66]!==u||t[67]!==L||t[68]!==x||t[69]!==Ne||t[70]!==Pe||t[71]!==Fe?(Ie=(0,$.jsx)(ct,{ref:A,value:u,disabled:L,"aria-label":Ne,onBlur:x,onChange:Pe,onKeyDown:Fe,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[66]=u,t[67]=L,t[68]=x,t[69]=Ne,t[70]=Pe,t[71]=Fe,t[72]=Ie):Ie=t[72];let Le;t[73]===j?Le=t[74]:(Le=j&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[73]=j,t[74]=Le);let Re;t[75]!==je||t[76]!==Me||t[77]!==Ie||t[78]!==Le?(Re=(0,$.jsxs)(`div`,{className:je,children:[Me,Ie,Le]}),t[75]=je,t[76]=Me,t[77]=Ie,t[78]=Le,t[79]=Re):Re=t[79];let ze=P?Re:j?(0,$.jsx)(V,{isActive:N,onClick:()=>h(n.path),className:`cursor-pointer`,"aria-current":N?`page`:void 0,children:ke}):(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:ke}),(0,$.jsx)(Dy,{type:`button`,className:b(`top-1`,M&&`rotate-90`),"aria-label":`${M?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":M,onPointerDown:rT,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Wr,{className:`size-4 text-muted-foreground/50`})})]}),Be=_w,Ve=vw,He=b(`rounded-md transition-[opacity,box-shadow] duration-150 ease-out`,oe&&`opacity-40`,pe),Ue=!P&&ie,We=!P&&re,Ge;t[80]!==ve||t[81]!==be||t[82]!==fe||t[83]!==He||t[84]!==Ue||t[85]!==We||t[86]!==ze?(Ge=(0,$.jsx)(`div`,{ref:fe,className:He,onMouseEnter:ve,onMouseLeave:be,...Ue,...We,role:`presentation`,tabIndex:void 0,children:ze}),t[80]=ve,t[81]=be,t[82]=fe,t[83]=He,t[84]=Ue,t[85]=We,t[86]=ze,t[87]=Ge):Ge=t[87];let Ke;t[88]!==Ve||t[89]!==Ge?(Ke=(0,$.jsx)(Ve,{asChild:!0,children:Ge}),t[88]=Ve,t[89]=Ge,t[90]=Ke):Ke=t[90];let qe;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(qe=e=>{k.current&&(k.current=!1,e.preventDefault())},t[91]=qe):qe=t[91];let Je;t[92]!==R||t[93]!==j||t[94]!==n||t[95]!==T||t[96]!==w||t[97]!==C?(Je=!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(xw,{disabled:R,onSelect:()=>{k.current=!0,C(`file`,n.path)},children:[(0,$.jsx)(Vi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)(xw,{disabled:R,onSelect:()=>{k.current=!0,C(`folder`,n.path)},children:[(0,$.jsx)(si,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(ww,{}),(0,$.jsxs)(xw,{onSelect:()=>w(n),children:[(0,$.jsx)(Yi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)(xw,{onSelect:()=>T(n),children:[(0,$.jsx)(oi,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(ww,{})]}),t[92]=R,t[93]=j,t[94]=n,t[95]=T,t[96]=w,t[97]=C,t[98]=Je):Je=t[98];let Ye;t[99]!==_||t[100]!==U?(Ye=()=>{k.current=!0,_(U)},t[99]=_,t[100]=U,t[101]=Ye):Ye=t[101];let Xe;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,$.jsx)(ft,{"aria-hidden":`true`}),t[102]=Xe):Xe=t[102];let Ze;t[103]!==R||t[104]!==Ye?(Ze=(0,$.jsxs)(xw,{disabled:R,onSelect:Ye,children:[Xe,`Rename`]}),t[103]=R,t[104]=Ye,t[105]=Ze):Ze=t[105];let Qe;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=(0,$.jsxs)(Sw,{children:[(0,$.jsx)(Qr,{"aria-hidden":`true`}),`Copy Path`]}),t[106]=Qe):Qe=t[106];let $e=!p,et;t[107]!==n||t[108]!==p?(et=()=>{p&&Uw(gd(p.contentDir,Hw(n),p.pathSeparator),`full path`)},t[107]=n,t[108]=p,t[109]=et):et=t[109];let tt;t[110]!==$e||t[111]!==et?(tt=(0,$.jsx)(xw,{disabled:$e,onSelect:et,children:`Full Path`}),t[110]=$e,t[111]=et,t[112]=tt):tt=t[112];let nt;t[113]===n?nt=t[114]:(nt=(0,$.jsx)(xw,{onSelect:()=>{Uw(Hw(n),`relative path`)},children:`Relative Path`}),t[113]=n,t[114]=nt);let rt;t[115]!==tt||t[116]!==nt?(rt=(0,$.jsxs)(yw,{children:[Qe,(0,$.jsxs)(Cw,{children:[tt,nt]})]}),t[115]=tt,t[116]=nt,t[117]=rt):rt=t[117];let it;t[118]!==m||t[119]!==j||t[120]!==n.path||t[121]!==p?(it=j&&(0,$.jsx)(Ew,{input:vd({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]=it):it=t[122];let at;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(at=(0,$.jsx)(ww,{}),t[123]=at):at=t[123];let ot;t[124]!==S||t[125]!==U?(ot=()=>{S(U)},t[124]=S,t[125]=U,t[126]=ot):ot=t[126];let st;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(st=(0,$.jsx)(jt,{"aria-hidden":`true`}),t[127]=st):st=t[127];let lt;t[128]!==R||t[129]!==ot?(lt=(0,$.jsxs)(xw,{variant:`destructive`,disabled:R,onSelect:ot,children:[st,`Delete`]}),t[128]=R,t[129]=ot,t[130]=lt):lt=t[130];let ut;t[131]!==Je||t[132]!==Ze||t[133]!==rt||t[134]!==it||t[135]!==lt?(ut=(0,$.jsxs)(bw,{onCloseAutoFocus:qe,children:[Je,Ze,rt,it,at,lt]}),t[131]=Je,t[132]=Ze,t[133]=rt,t[134]=it,t[135]=lt,t[136]=ut):ut=t[136];let dt;t[137]!==Be||t[138]!==Ke||t[139]!==ut?(dt=(0,$.jsxs)(Be,{children:[Ke,ut]}),t[137]=Be,t[138]=Ke,t[139]=ut,t[140]=dt):dt=t[140];let pt;t[141]!==c||t[142]!==d||t[143]!==l||t[144]!==u||t[145]!==M||t[146]!==o||t[147]!==D||t[148]!==m||t[149]!==E||t[150]!==n.children||t[151]!==x||t[152]!==T||t[153]!==y||t[154]!==S||t[155]!==v||t[156]!==w||t[157]!==h||t[158]!==C||t[159]!==_||t[160]!==s||t[161]!==g||t[162]!==i||t[163]!==a||t[164]!==f||t[165]!==p?(pt=M&&(n.children.length>0||!!E)&&(0,$.jsxs)(Oy,{className:`mr-0 pr-0`,children:[E&&(0,$.jsx)(ky,{children:(0,$.jsx)(Kw,{...E})}),n.children.map(e=>(0,$.jsx)(Yw,{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:x,onDelete:S,onStartCreating:C,onExpandSubtree:w,onCollapseSubtree:T,inlineCreate:D(e.path),getInlineCreate:D,nested:!0},e.path))]}),t[141]=c,t[142]=d,t[143]=l,t[144]=u,t[145]=M,t[146]=o,t[147]=D,t[148]=m,t[149]=E,t[150]=n.children,t[151]=x,t[152]=T,t[153]=y,t[154]=S,t[155]=v,t[156]=w,t[157]=h,t[158]=C,t[159]=_,t[160]=s,t[161]=g,t[162]=i,t[163]=a,t[164]=f,t[165]=p,t[166]=pt):pt=t[166];let mt;return t[167]!==B||t[168]!==dt||t[169]!==pt?(mt=(0,$.jsxs)(B,{children:[dt,pt]}),t[167]=B,t[168]=dt,t[169]=pt,t[170]=mt):mt=t[170],mt};function Xw(t){let n=(0,Q.c)(91),{ref:r}=t,{activeDocName:i,activeTarget:a,closeDocument:o,prewarm:s}=yn(),{addPage:c}=Se(),l;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],n[0]=l):l=n[0];let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(nT),[w,T]=(0,Z.useState)(tT),{selectedFilePath:E,selectedFolderPath:O,navigationPath:k}=gw(a,i),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(null),[B,V]=(0,Z.useState)(null),H;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(H={activationConstraint:{distance:12}},n[1]=H):H=n[1];let U=Wx(Ux(KS,H)),[W,G]=(0,Z.useState)(null),{states:K}=Rd(),{dispatch:ee}=Dd(),te=typeof window<`u`&&window.okDesktop!=null,q;n[2]!==ee||n[3]!==K?(q={installStates:K,isElectronHost:te,dispatch:ee},n[2]=ee,n[3]=K,n[4]=q):q=n[4];let ne=q,re=eT,ie,ae;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch($w);e&&(t.ok&&n?.ok?(d(n.documents),h(null)):h(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&h(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&p(!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()}},ae=[],n[5]=ie,n[6]=ae):(ie=n[5],ae=n[6]),(0,Z.useEffect)(ie,ae);let oe,se;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(Qw);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&G({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(Zw),()=>{e=!1}},se=[],n[7]=oe,n[8]=se):(oe=n[7],se=n[8]),(0,Z.useEffect)(oe,se);let le;n[9]===Symbol.for(`react.memo_cache_sentinel`)?(le=function(e,t){N({kind:e,parentDir:t}),F(``),z(null),t&&(C(e=>new Set(e).add(t)),T(e=>{let n=new Set(e);return n.delete(t),n}))},n[9]=le):le=n[9];let ue=le,J;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(J=function(t){let n=e([t]);(0,Z.startTransition)(()=>{C(e=>{let t=new Set(e);for(let e of n)t.add(e);return t}),T(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t})})},n[10]=J):J=n[10];let fe=J,pe;n[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(t){let n=e([t]);(0,Z.startTransition)(()=>{T(e=>{let t=new Set(e);for(let e of n)t.add(e);return t}),C(e=>{let t=new Set(e);for(let e of n)t.delete(e);return t})})},n[11]=pe):pe=n[11];let me=pe,he;n[12]===u?he=n[13]:(he=()=>({startCreating:ue,expandAll(){let t=e(D(u));(0,Z.startTransition)(()=>{C(t),T(new Set)})},collapseAll(){let t=e(D(u));(0,Z.startTransition)(()=>{T(t),C(new Set)})}}),n[12]=u,n[13]=he),(0,Z.useImperativeHandle)(r,he);let ge;n[14]===I?ge=n[15]:(ge=function(){I||(N(null),F(``),z(null))},n[14]=I,n[15]=ge);let _e=ge,ve;n[16]!==c||n[17]!==M||n[18]!==P?(ve=async function(){if(!M)return;let e=P.trim();if(!e){z(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){z(`Invalid name`);return}let t=M.kind===`file`?de(M.parentDir,e):ze(M.parentDir,e);L(!0),z(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 ${M.kind}`;qt.error(e),z(e),L(!1);return}let r=n.docName??t.replace(/\.md$/,``);N(null),F(``),z(null),L(!1),r&&Vw(r),c(r),Be([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),qt.error(`Network error — please try again`),z(`Network error — please try again`),L(!1)}},n[16]=c,n[17]=M,n[18]=P,n[19]=ve):ve=n[19];let ye=ve,be;n[20]!==i||n[21]!==o||n[22]!==v?(be=async function(e){let t=Zv(e.kind,v);if(!Qv(t)){h(`Name must be a single path segment`);return}let n=$v(e,t);if(n===e.path){_(null),y(``),h(null);return}x(e.path),h(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,r=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),s=await a.json();if(!a.ok||!s.ok){h(s.error??`Failed to rename path`),x(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=ny(i,c);for(let e of c)o(e.fromDocName);d(e=>ey(e,c)),Be([`files`,`backlinks`,`graph`]),_(null),y(``),i&&l!==i&&(window.location.hash=`#/${l}`),x(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),h(`Network error — please try again`),x(null)}},n[20]=i,n[21]=o,n[22]=v,n[23]=be):be=n[23];let xe=be,Ce;n[24]!==i||n[25]!==o||n[26]!==g||n[27]!==j?(Ce=async function(e){x(e.path),j(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){qt.error(n.error??`Failed to delete path`),x(null);return}let r=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],a=new Set(r);for(let e of a)o(e);d(e=>ty(e,r)),Be([`files`,`backlinks`,`graph`]),i&&a.has(i)&&(window.location.hash=``),g&&(a.has(g)||e.path===g)&&(_(null),y(``)),x(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),qt.error(`Network error — please try again`),x(null)}},n[24]=i,n[25]=o,n[26]=g,n[27]=j,n[28]=Ce):Ce=n[28];let we=Ce,Te;n[29]!==i||n[30]!==o?(Te=async function(e,t){let n=hw(e,t);if(!n.ok){if(n.reason===`no_op`)return;qt.error(n.reason===`self`?`Cannot move a folder into itself`:`Cannot move a folder into one of its subfolders`);return}let r=n.destinationPath;x(e.path),h(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,n=e.kind===`file`?{docName:e.path,newDocName:r}:{kind:`folder`,fromPath:e.path,toPath:r},a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),s=await a.json();if(!a.ok||!s.ok){let e=s.error??`Failed to move`;qt.error(e),h(e),x(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=ny(i,c);for(let e of c)o(e.fromDocName);d(e=>ey(e,c)),Be([`files`,`backlinks`,`graph`]);let u=r.split(`/`).filter(Boolean);u.length>1&&C(e=>{let t=new Set(e);for(let e=0;e<u.length-1;e++)t.add(u.slice(0,e+1).join(`/`));return t}),i&&l!==i&&(window.location.hash=`#/${l}`),x(null)}catch(e){console.warn(`[FileTree] move failed:`,e),qt.error(`Network error — please try again`),x(null)}},n[29]=i,n[30]=o,n[31]=Te):Te=n[31];let Ee=Te;if(f){let e;return n[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...`})}),n[32]=e):e=n[32],e}if(m&&u.length===0){let e;return n[33]===m?e=n[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:m})}),n[33]=m,n[34]=e),e}if(u.length===0&&!M){let e;n[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),n[35]=e):e=n[35];let t;return n[36]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(X,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>ue(`file`,``),children:`Create your first file`})]}),n[36]=t):t=n[36],t}let Y=u.length>0?D(u):[],Oe=e(Y),ke=De(k),Ae=new Set(ke),je=new Set;for(let e of Ae)Oe.has(e)&&je.add(e);for(let e of S)Oe.has(e)&&je.add(e);for(let e of w)Oe.has(e)&&!Ae.has(e)&&je.delete(e);let Me=function(e){if(Ae.has(e))return;let[t,n]=je.has(e)?[T,C]:[C,T];t(t=>new Set(t).add(e)),n(t=>{let n=new Set(t);return n.delete(e),n})},Ne;n[37]!==I||n[38]!==R||n[39]!==M||n[40]!==P||n[41]!==_e||n[42]!==ye?(Ne=function(e){return!M||M.parentDir!==e?null:{kind:M.kind,value:P,busy:I,error:R,onChange:F,onCommit:()=>void ye(),onCancel:_e}},n[37]=I,n[38]=R,n[39]=M,n[40]=P,n[41]=_e,n[42]=ye,n[43]=Ne):Ne=n[43];let Pe=Ne,Fe;n[44]===Pe?Fe=n[45]:(Fe=Pe(``),n[44]=Pe,n[45]=Fe);let Ie=Fe,Le=b!==null||g!==null||M!==null,Re=UC,Ve=tS,He;n[46]===Symbol.for(`react.memo_cache_sentinel`)?(He=e=>{let{active:t}=e;V(t.data.current?.source??null)},n[46]=He):He=n[46];let Ue;n[47]===Ee?Ue=n[48]:(Ue=e=>{let{active:t,over:n}=e;if(V(null),!n)return;let r=t.data.current?.source,i=n.data.current?.destinationFolderPath;!r||typeof i!=`string`||Ee(r,i)},n[47]=Ee,n[48]=Ue);let We;n[49]===Symbol.for(`react.memo_cache_sentinel`)?(We=()=>V(null),n[49]=We):We=n[49];let Ge=zw,Ke;n[50]===m?Ke=n[51]:(Ke=m&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:m}),n[50]=m,n[51]=Ke);let qe=Cy,Je;n[52]===Ie?Je=n[53]:(Je=Ie&&(0,$.jsx)(wy,{children:(0,$.jsx)(Kw,{...Ie})}),n[52]=Ie,n[53]=Je);let Ye;n[54]===Le?Ye=n[55]:(Ye=(0,$.jsx)(Jw,{treeActionsLocked:Le}),n[54]=Le,n[55]=Ye);let Xe=Y.map(e=>(0,$.jsx)(Yw,{node:e,selectedFilePath:E,selectedFolderPath:O,expandedPaths:je,onToggle:Me,activeRowRef:re,editingPath:g,editingValue:v,busyPath:b,treeActionsLocked:Le,workspace:W,handoff:ne,onNavigate:Vw,prewarm:s,onStartRename:e=>{_(e.path),y(e.name),h(null)},onEditingValueChange:y,onCommitRename:e=>void xe(e),onCancelRename:()=>{b||(_(null),y(``))},onDelete:e=>j(e),onStartCreating:ue,onExpandSubtree:fe,onCollapseSubtree:me,inlineCreate:Pe(e.path),getInlineCreate:Pe},e.path)),Ze;n[56]!==qe||n[57]!==Je||n[58]!==Ye||n[59]!==Xe?(Ze=(0,$.jsxs)(qe,{children:[Je,Ye,Xe]}),n[56]=qe,n[57]=Je,n[58]=Ye,n[59]=Xe,n[60]=Ze):Ze=n[60];let Qe=!!A,$e;n[61]!==b||n[62]!==j?($e=e=>{!e&&!b&&j(null)},n[61]=b,n[62]=j,n[63]=$e):$e=n[63];let et;n[64]!==b||n[65]!==A||n[66]!==we?(et=A&&(0,$.jsx)(uw,{itemName:`${A.name}${A.kind===`file`?`.md`:`/`}`,isSubmitting:b===A.path,onDelete:()=>we(A),customDescription:A.kind===`folder`?`Are you sure you want to delete ${A.name}/ and all files inside? This action cannot be undone.`:void 0}),n[64]=b,n[65]=A,n[66]=we,n[67]=et):et=n[67];let tt;n[68]!==Qe||n[69]!==$e||n[70]!==et?(tt=(0,$.jsx)(zt,{open:Qe,onOpenChange:$e,children:et}),n[68]=Qe,n[69]=$e,n[70]=et,n[71]=tt):tt=n[71];let nt;n[72]===B?nt=n[73]:(nt=B?(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:[B.kind===`file`?(0,$.jsx)(mn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(ci,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sidebar-foreground`,children:[B.name,B.kind===`file`?`.md`:``]})]}):null,n[72]=B,n[73]=nt);let rt;n[74]===nt?rt=n[75]:(rt=(0,$.jsx)(lw,{dropAnimation:null,children:nt}),n[74]=nt,n[75]=rt);let it;n[76]!==B||n[77]!==Ge.Provider||n[78]!==Ke||n[79]!==Ze||n[80]!==tt||n[81]!==rt?(it=(0,$.jsxs)(Ge.Provider,{value:B,children:[Ke,Ze,tt,rt]}),n[76]=B,n[77]=Ge.Provider,n[78]=Ke,n[79]=Ze,n[80]=tt,n[81]=rt,n[82]=it):it=n[82];let at;return n[83]!==Re||n[84]!==U||n[85]!==Ve||n[86]!==He||n[87]!==Ue||n[88]!==We||n[89]!==it?(at=(0,$.jsx)(Re,{sensors:U,collisionDetection:Ve,onDragStart:He,onDragEnd:Ue,onDragCancel:We,children:it}),n[83]=Re,n[84]=U,n[85]=Ve,n[86]=He,n[87]=Ue,n[88]=We,n[89]=it,n[90]=at):at=n[90],at}function Zw(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function Qw(){return null}function $w(){return null}function eT(e){e&&e.scrollIntoView({block:`nearest`})}function tT(){return new Set}function nT(){return new Set}function rT(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)(Dt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(X,{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 aT(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 oT(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Ul,Hl,Hl),n;e[0]===t?n=e[1]:(n=aT(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{Vl(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 sT(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Qe,{name:`file-sidebar`,children:(0,$.jsx)(cT,{})}),e[0]=t):t=e[0],t}function cT(){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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(Tg,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(_i,{"aria-hidden":`true`})})})}),(0,$.jsx)(wn,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(jg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Yi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(wg,{children:[r,(0,$.jsxs)(Ag,{align:`end`,children:[i,(0,$.jsxs)(jg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)(oi,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Vi,{"aria-hidden":`true`})})}),(0,$.jsx)(wn,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(by,{children:(0,$.jsx)(Cy,{children:(0,$.jsx)(wy,{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)(jn,{children:[(0,$.jsx)(Rn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(si,{"aria-hidden":`true`})})}),(0,$.jsx)(wn,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Sy,{children:(0,$.jsx)(Xw,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(_y,{variant:`inset`,children:[s,c,(0,$.jsx)(xy,{children:(0,$.jsx)(oT,{})})]}),e[7]=l):l=e[7],l}function lT(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentFocus;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)}function uT(){let e=(0,Q.c)(10),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i}=yn(),a=(0,Z.useRef)(n),o=(0,Z.useRef)(r),s,c;e[0]===n?(s=e[1],c=e[2]):(s=()=>{a.current=n},c=[n],e[0]=n,e[1]=s,e[2]=c),(0,Z.useEffect)(s,c);let l=(0,Z.useRef)(null),u,d;e[3]===r?(u=e[4],d=e[5]):(u=()=>{let e=o.current!==null;if(o.current=r,!(e&&r===null)||Date.now()-Zt()<3e3)return;let t=l.current?.awareness;if(!t)return;let n=lT(t,Date.now());n&&n!==a.current&&(window.location.hash=me(n))},d=[r],e[3]=r,e[4]=u,e[5]=d),(0,Z.useEffect)(u,d);let f,p;return e[6]!==i||e[7]!==t?(f=()=>{if(i===null)return;let e=new tn,n=new dn({url:i,name:g,document:e,onStateless:mT,onClose:pT,onDisconnect:fT}),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`,dT);let s=null,c=()=>{if(s=null,o.current!==null||Date.now()-Zt()<3e3)return;let e=n.awareness;if(!e)return;let t=lT(e,Date.now());t&&t!==a.current&&(window.location.hash=me(t))},u=()=>{s!==null&&clearTimeout(s),s=setTimeout(c,300)};return n.awareness?.on(`change`,u),l.current=n,()=>{r(),s!==null&&clearTimeout(s),n.awareness?.off(`change`,u),n.destroy(),e.destroy(),l.current=null}},p=[t,i],e[6]=i,e[7]=t,e[8]=f,e[9]=p):(f=e[8],p=e[9]),(0,Z.useEffect)(f,p),null}function dT(){Be([`files`,`backlinks`,`graph`])}function fT(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function pT(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function mT(e){let{payload:t}=e,n=Jt(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}Be([n.ch])}function hT(){let e=(0,Q.c)(7),{clearTarget:t}=yn(),{openTargetTransition:n}=wt(),{folderPaths:r,loading:i,pages:a}=Se(),o,s;return e[0]!==t||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==a?(o=()=>{e();function e(){let e=we(window.location.hash);if(!e){Xt(`ok/nav/hash-change`,{docName:null,kind:`clear`}),t();return}if(i){Xt(`ok/nav/hash-change`,{docName:e,kind:`deferred-loading`});return}let o=W(e,{pages:a,folderPaths:r});Xt(`ok/nav/hash-change`,{docName:e,kind:o.kind}),n(o)}return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},s=[t,r,i,n,a],e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s):(o=e[5],s=e[6]),(0,Z.useEffect)(o,s),null}function gT(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=yn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:Pe(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;Ot({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)($e,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function _T(){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)(Kd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(uT,{}),i=(0,$.jsx)(hT,{}),a=(0,$.jsx)(gT,{}),o=t?(0,$.jsx)(Vd,{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)(sT,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Qe,{name:`app`,children:(0,$.jsxs)(Bt,{children:[n,(0,$.jsxs)(ae,{children:[r,i,a,o,(0,$.jsxs)(my,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(yy,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(nx,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&yl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&Cl({bridge:window.okDesktop}),Wl(),typeof window<`u`&&Sl({bridge:window.okDesktop});var vT=new vr({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),yT=document.getElementById(`root`);if(!yT)throw Error(`Root element not found`);var bT=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Cr.createRoot)(yT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(He,{client:vT,children:(0,$.jsxs)(he,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(Fn,{children:bT&&window.okDesktop?(0,$.jsx)(Or,{bridge:window.okDesktop}):(0,$.jsx)(_T,{})}),(0,$.jsx)(Zi,{richColors:!0})]})})}));
|