@inkeep/open-knowledge 0.0.0-dev-20260422215402 → 0.0.0-dev-20260422220204

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.
@@ -14,7 +14,7 @@ Error generating stack: `+e.message+`
14
14
  `);c=a.pop()??``;for(let e of a)if(e.trim())try{let n=JSON.parse(e);if(n.type===`progress`)X.loading(`${ff(n.phase)} — ${n.pct}%`,{id:t});else if(n.type===`complete`){X.success(`Clone complete — opening project`,{id:t}),r(!1),v(!1),b(null),window.location.href=`http://localhost:${n.port}`;return}else if(n.type===`error`){X.error(`Clone failed: ${n.message}`,{id:t}),v(!1),b(null);return}}catch{}}X.error(`Clone stream ended unexpectedly — check if the clone completed`,{id:t}),v(!1),b(null)}catch(e){let n=e;n instanceof Error&&n.name===`AbortError`?X.dismiss(x.current??void 0):X.error(`Clone failed — connection error`,{id:t}),v(!1),b(null)}},t[10]=s,t[11]=r,t[12]=a,t[13]=M):M=t[13];let N=M,P;t[14]===y?P=t[15]:(P=function(){y?.abort(),v(!1),b(null),X.dismiss(x.current??void 0)},t[14]=y,t[15]=P);let F=P,I;t[16]!==_||t[17]!==r?(I=function(e){_||(r(e),e||(o(``),c(``),m(``)))},t[16]=_,t[17]=r,t[18]=I):I=t[18];let L=I,R,z,B,V,H,U,W,G,K;if(t[19]!==_||t[20]!==L||t[21]!==h||t[22]!==d||t[23]!==n||t[24]!==p||t[25]!==l||t[26]!==a){let e=l?.filter(e=>e.full_name.toLowerCase().includes(p.toLowerCase()));z=ln,G=n,K=L,R=In,U=`sm:max-w-lg`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(Bn,{children:(0,$.jsx)(pn,{children:`Clone from GitHub`})}),t[36]=W):W=t[36],B=`flex flex-col gap-4`;let r;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`label`,{htmlFor:`clone-url`,className:`text-sm font-medium`,children:`Repository URL or owner/repo`}),t[37]=r):r=t[37];let i;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(i=e=>k(e.target.value),t[38]=i):i=t[38],t[39]!==_||t[40]!==a?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[r,(0,$.jsx)(Mt,{id:`clone-url`,placeholder:`https://github.com/owner/repo or owner/repo`,value:a,onChange:i,disabled:_})]}),t[39]=_,t[40]=a,t[41]=V):V=t[41],H=h&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`repo-filter`,className:`text-sm font-medium`,children:`Your repositories`}),(0,$.jsx)(Mt,{id:`repo-filter`,"aria-label":`Filter repositories`,placeholder:`Filter repositories…`,value:p,onChange:e=>m(e.target.value),disabled:_||d&&l===null}),(0,$.jsx)(`div`,{className:`border rounded-md max-h-40 overflow-y-auto subtle-scrollbar`,"aria-busy":d&&l===null,children:d&&l===null?(0,$.jsxs)(`output`,{className:`flex flex-col gap-1.5 px-3 py-2`,"aria-label":`Loading repositories`,children:[(0,$.jsx)(df,{className:`h-4 w-2/3`}),(0,$.jsx)(df,{className:`h-4 w-1/2`}),(0,$.jsx)(df,{className:`h-4 w-3/4`}),(0,$.jsx)(df,{className:`h-4 w-2/5`}),(0,$.jsx)(df,{className:`h-4 w-3/5`})]}):e?.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:l?.length===0?`No repositories found.`:`No matches.`}):e?.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-sm hover:bg-muted flex items-center gap-2 truncate disabled:opacity-50`,onClick:()=>j(e),disabled:_,children:[e.private&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`🔒`}),e.full_name]},e.full_name))})]}),t[19]=_,t[20]=L,t[21]=h,t[22]=d,t[23]=n,t[24]=p,t[25]=l,t[26]=a,t[27]=R,t[28]=z,t[29]=B,t[30]=V,t[31]=H,t[32]=U,t[33]=W,t[34]=G,t[35]=K}else R=t[27],z=t[28],B=t[29],V=t[30],H=t[31],U=t[32],W=t[33],G=t[34],K=t[35];let ee;t[42]!==_||t[43]!==h||t[44]!==i?(ee=!h&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Browse your repos:`}),(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`h-auto p-0`,onClick:()=>i?.(),disabled:_,children:`Sign in to GitHub`})]}),t[42]=_,t[43]=h,t[44]=i,t[45]=ee):ee=t[45];let te;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(`label`,{htmlFor:`clone-path`,className:`text-sm font-medium`,children:`Local path`}),t[46]=te):te=t[46];let ne;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>c(e.target.value),t[47]=ne):ne=t[47];let re;t[48]!==_||t[49]!==s?(re=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[te,(0,$.jsx)(Mt,{id:`clone-path`,placeholder:`~/Documents/repo-name`,value:s,onChange:ne,disabled:_})]}),t[48]=_,t[49]=s,t[50]=re):re=t[50];let ie;t[51]!==B||t[52]!==V||t[53]!==H||t[54]!==ee||t[55]!==re?(ie=(0,$.jsxs)(`div`,{className:B,children:[V,H,ee,re]}),t[51]=B,t[52]=V,t[53]=H,t[54]=ee,t[55]=re,t[56]=ie):ie=t[56];let ae;t[57]!==_||t[58]!==F||t[59]!==N||t[60]!==L||t[61]!==a?(ae=(0,$.jsx)(wn,{children:_?(0,$.jsx)(q,{variant:`outline`,className:`font-mono uppercase`,onClick:F,children:`Cancel`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{variant:`outline`,className:`font-mono uppercase`,onClick:()=>L(!1),children:`Cancel`}),(0,$.jsx)(q,{onClick:()=>void N(),disabled:!a.trim(),children:`Clone`})]})}),t[57]=_,t[58]=F,t[59]=N,t[60]=L,t[61]=a,t[62]=ae):ae=t[62];let oe;t[63]!==R||t[64]!==U||t[65]!==W||t[66]!==ie||t[67]!==ae?(oe=(0,$.jsxs)(R,{className:U,children:[W,ie,ae]}),t[63]=R,t[64]=U,t[65]=W,t[66]=ie,t[67]=ae,t[68]=oe):oe=t[68];let se;return t[69]!==z||t[70]!==G||t[71]!==K||t[72]!==oe?(se=(0,$.jsx)(z,{open:G,onOpenChange:K,children:oe}),t[69]=z,t[70]=G,t[71]=K,t[72]=oe,t[73]=se):se=t[73],se}function hf(e){return e.json()}function gf(e){let t=(0,Q.c)(9),{onOpenResolver:n}=e,r=ef();if(!r||r.state!==`conflict`)return null;let i=r.conflictCount,a=i>0?`${i} page${i===1?``:`s`}`:`Some pages`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(zi,{className:`size-4 shrink-0`}),t[0]=o):o=t[0];let s=i===1?`has`:`have`,c;t[1]!==a||t[2]!==s?(c=(0,$.jsxs)(`span`,{className:`flex-1`,children:[a,` `,s,` conflicting changes.`]}),t[1]=a,t[2]=s,t[3]=c):c=t[3];let l;t[4]===n?l=t[5]:(l=(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`shrink-0 border-amber-400 dark:border-amber-700 text-amber-800 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50`,onClick:n,children:`Review and resolve`}),t[4]=n,t[5]=l);let u;return t[6]!==c||t[7]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm border-b bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 shrink-0`,children:[o,c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8],u}var _f=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 vf(e,t,n,r,i,a){if(e==r)return[];let o=Of(e,t,n,r,i,a),s=kf(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 _f(t,n,i,a)];if(c>l){let o=e.slice(t,n).indexOf(r.slice(i,a));if(o>-1)return[new _f(t,t+o,i,i),new _f(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 _f(t,t,i,i+o),new _f(n,n,i+o+c,a)]}if(c==1||l==1)return[new _f(t,n,i,a)];let u=jf(e,t,n,r,i,a);if(u){let[o,s,c]=u;return vf(e,t,o,r,i,s).concat(vf(e,o+c,n,r,s+c,a))}return Sf(e,t,n,r,i,a)}var yf=1e9,bf=0,xf=!1;function Sf(e,t,n,r,i,a){let o=n-t,s=a-i;if(yf<1e9&&Math.min(o,s)>yf*16||bf>0&&Date.now()>bf)return Math.min(o,s)>yf*64?[new _f(t,n,i,a)]:Mf(e,t,n,r,i,a);let c=Math.ceil((o+s)/2);wf.reset(c),Tf.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:Tf,f=d?null:wf;for(let p=0;p<c;p++){if(p>yf||bf>0&&!(p&63)&&Date.now()>bf)return Mf(e,t,n,r,i,a);let m=wf.advance(p,o,s,c,d,!1,l)||Tf.advance(p,o,s,c,f,!0,u);if(m)return Ef(e,t,n,t+m[0],r,i,a,i+m[1])}return[new _f(t,n,i,a)]}var Cf=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}},wf=new Cf,Tf=new Cf;function Ef(e,t,n,r,i,a,o,s){let c=!1;return!qf(e,r)&&++r==n&&(c=!0),!qf(i,s)&&++s==o&&(c=!0),c?[new _f(t,n,a,o)]:vf(e,t,r,i,a,s).concat(vf(e,r,n,i,s,o))}function Df(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function Of(e,t,n,r,i,a){if(t==n||t==a||e.charCodeAt(t)!=r.charCodeAt(i))return 0;let o=Df(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-+!qf(e,s);o>>=1}else if(i==n||l==a)return i-t;else s=i,c=l}}function kf(e,t,n,r,i,a){if(t==n||i==a||e.charCodeAt(n-1)!=r.charCodeAt(a-1))return 0;let o=Df(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-+!qf(e,s);o>>=1}else if(a==t||l==i)return n-a;else s=a,c=l}}function Af(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;;){qf(e,s)||s++;let u=s+o;if(qf(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=Of(e,u,n,r,i+f+d.length,a),c=kf(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 jf(e,t,n,r,i,a){let o=n-t,s=a-i;if(o<s){let o=jf(r,i,a,e,t,n);return o&&[o[1],o[0],o[2]]}return o<4||s*2<o?null:Af(e,t,n,r,i,a,Math.floor(o/4),-1)}function Mf(e,t,n,r,i,a){xf=!0;let o=n-t,s=a-i,c;if(o<s){let s=Af(r,i,a,e,t,n,Math.floor(o/6),50);c=s&&[s[1],s[0],s[2]]}else c=Af(e,t,n,r,i,a,Math.floor(s/6),50);if(!c)return[new _f(t,n,i,a)];let[l,u,d]=c;return vf(e,t,l,r,i,u).concat(vf(e,l+d,n,r,u+d,a))}function Nf(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 _f(r.fromA,i.toA,r.fromB,i.toB),e.splice(n--,1))}}function Pf(e,t,n){for(;;){Nf(n,1);let r=!1;for(let i=0;i<n.length;i++){let a=n[i],o,s;(o=Of(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new _f(a.fromA+o,a.toA,a.fromB+o,a.toB)),(s=kf(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[i]=new _f(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 _f(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 _f(a.fromA+d,a.toA+d,a.fromB+d,a.toB+d),r=!0)}if(!r)break}return n}function Ff(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=Hf(t,a.fromA,l),f=Vf(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 _f(d,d+o,a.fromB-p,a.toB-p),d=a.fromA,f=Vf(t,a.toA,c-a.toA)):l>m&&t.slice(a.toA,f)==u.slice(h,h+m)&&(a=e[i]=new _f(f-o,f,a.fromB+m,a.toB+m),f=a.toA,d=Hf(t,a.fromA,a.fromA-r)),p=a.fromA-d,m=f-a.toA}if(p||m)a=e[i]=new _f(a.fromA-p,a.toA+m,a.fromB-p,a.toB+m);else if(!o){let t=Wf(n,a.fromB,a.toB),r,o=t<0?-1:Uf(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=Wf(t,a.fromA,a.toA),r,o=n<0?-1:Uf(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 Nf(e,3),e}var If;try{If=RegExp(`[\\p{Alphabetic}\\p{Number}]`,`u`)}catch{}function Lf(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Rf(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?+!!Lf(n):If?!Gf(n)||t==e.length-1?+!!If.test(String.fromCharCode(n)):If.test(e.slice(t,t+2))?2:0:0}function zf(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?+!!Lf(n):If?!Kf(n)||t==1?+!!If.test(String.fromCharCode(n)):If.test(e.slice(t-2,t))?2:0:0}var Bf=8;function Vf(e,t,n){if(t==e.length||!zf(e,t))return t;for(let r=t,i=t+n,a=0;a<Bf;a++){let t=Rf(e,r);if(!t||r+t>i)return r;r+=t}return t}function Hf(e,t,n){if(!t||!Rf(e,t))return t;for(let r=t,i=t-n,a=0;a<Bf;a++){let t=zf(e,r);if(!t||r-t<i)return r;r-=t}return t}function Uf(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Wf(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}var Gf=e=>e>=55296&&e<=56319,Kf=e=>e>=56320&&e<=57343;function qf(e,t){return!t||t==e.length||!Gf(e.charCodeAt(t-1))||!Kf(e.charCodeAt(t))}function Jf(e,t,n){let r=n?.override;return r?r(e,t):(yf=(n?.scanLimit??1e9)>>1,bf=n?.timeout?Date.now()+n.timeout:0,xf=!1,Pf(e,t,vf(e,0,e.length,t,0,t.length)))}function Yf(){return!xf}function Xf(e,t,n){return Ff(Jf(e,t,n),e,t)}var Zf=Jn.define({combine:e=>e[0]}),Qf=Qn.define(),$f=Jn.define(),ep=er.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(Qf)&&(e=n.value);for(let n of t.state.facet($f))e=n(e,t);return e}});function tp(e){let t=e.field(ep,!1);if(!t)return null;let n=e.facet(Zf);return{chunks:t,side:n?n.side:null}}var np=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 ap(Xf(e.toString(),t.toString(),n),e,t,0,0,Yf())}static updateA(e,t,n,r,i){return lp(cp(e,r,!0,n.length),e,t,n,i)}static updateB(e,t,n,r,i){return lp(cp(e,r,!1,t.length),e,t,n,i)}};function rp(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 ip(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 ap(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length;s++){let c=e[s],[l,u]=rp(c.fromA+r,c.fromB+i,t,n),[d,f]=ip(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]=rp(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]=ip(a.toA+r,a.toB+i,t,n),s++}o.push(new np(p,l,Math.max(l,d),u,Math.max(u,f),a))}return o}var op=1e3;function sp(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 cp(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>op&&([l,d]=sp(e,a-op,n,!0)),o<t.length-op&&([u,f]=sp(e,o+op,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 lp(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=Xf(n.sliceString(d,p),r.sliceString(f,m),i);for(let e of ap(h,n,r,d,f,Yf()))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 up={scanLimit:500},dp=ar.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=xp(e))}update(e){(e.docChanged||e.viewportChanged||pp(e.startState,e.state)||mp(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=xp(e.view))}},{decorations:e=>e.deco}),fp=cr.low(or({class:`cm-changeGutter`,markers:e=>e.plugin(dp)?.gutter||Kn.empty}));function pp(e,t){return e.field(ep,!1)!=t.field(ep,!1)}function mp(e,t){return e.facet(Zf)!=t.facet(Zf)}var hp=lr.line({class:`cm-changedLine`}),gp=lr.mark({class:`cm-changedText`}),_p=lr.mark({tagName:`ins`,class:`cm-insertedLine`}),vp=lr.mark({tagName:`del`,class:`cm-deletedLine`}),yp=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-changedLineGutter`}};function bp(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,hp),i.add(o,s,n?vp:_p),a&&a.add(o,o,yp);for(let l=t.iterRange(o,s-1),u=o;!l.next().done;){if(l.lineBreak){u++,i.add(u,u,hp),a&&a.add(u,u,yp);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,gp),s<t)c++;else break}u=t}}}function xp(e){let t=e.state.field(ep),{side:n,highlightChanges:r,markGutter:i,overrideChunk:a}=e.state.facet(Zf),o=n==`a`,s=new sr,c=i?new sr:null,{from:l,to:u}=e.viewport;for(let n of t){if((o?n.fromA:n.fromB)>=u)break;(o?n.toA:n.toB)>l&&(!a||!a(e.state,n,s,c))&&bp(n,e.state.doc,o,r,s,c)}return{deco:s.finish(),gutter:c&&c.finish()}}var Sp=class extends tr{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement(`div`);return e.className=`cm-mergeSpacer`,e.style.height=this.height+`px`,e}updateDOM(e){return e.style.height=this.height+`px`,!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Cp=Qn.define({map:(e,t)=>e.map(t)}),wp=er.define({create:()=>lr.none,update:(e,t)=>{for(let e of t.effects)if(e.is(Cp))return e.value;return e.map(t.changes)},provide:e=>ir.decorations.from(e)}),Tp=.01;function Ep(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 Dp(e,t,n){let r=new sr,i=new sr,a=e.state.field(wp).iter(),o=t.state.field(wp).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<-Tp?(l-=n,r.add(s,s,lr.widget({widget:new Sp(-n),block:!0,side:-1}))):n>Tp&&(u+=n,i.add(c,c,lr.widget({widget:new Sp(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<Tp?r.add(e.state.doc.length,e.state.doc.length,lr.widget({widget:new Sp(-p),block:!0,side:1})):p>Tp&&i.add(t.state.doc.length,t.state.doc.length,lr.widget({widget:new Sp(p),block:!0,side:1}));let m=r.finish(),h=i.finish();Ep(m,e.state.field(wp))||e.dispatch({effects:Cp.of(m)}),Ep(h,t.state.field(wp))||t.dispatch({effects:Cp.of(h)})}var Op=Qn.define({map:(e,t)=>t.mapPos(e)}),kp=class extends tr{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement(`div`);return t.className=`cm-collapsedLines`,t.textContent=e.state.phrase(`$ unchanged lines`,this.lines),t.addEventListener(`click`,t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:Op.of(n)});let{side:r,sibling:i}=e.state.facet(Zf);i&&i().dispatch({effects:Op.of(Ap(n,e.state.field(ep),r==`a`))})}),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return`collapsed-unchanged-code`}};function Ap(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 jp=er.define({create(e){return lr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Op)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>ir.decorations.from(e)});function Mp({margin:e=3,minSize:t=4}){return jp.init(n=>Np(n,e,t))}function Np(e,t,n){let r=new sr,i=e.facet(Zf).side==`a`,a=e.field(ep),o=1;for(let s=0;;s++){let c=s<a.length?a[s]:null,l=s?o+t:1,u=c?e.doc.lineAt(i?c.fromA:c.fromB).number-1-t:e.doc.lines,d=u-l+1;if(d>=n&&r.add(e.doc.line(l).from,e.doc.line(u).to,lr.replace({widget:new kp(d),block:!0})),!c)break;o=e.doc.lineAt(Math.min(e.doc.length,i?c.toA:c.toB)).number}return r.finish()}var Pp=ir.styleModule.of(new dr({".cm-mergeView":{overflowY:`auto`},".cm-mergeViewEditors":{display:`flex`,alignItems:`stretch`},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:`hidden`},".cm-merge-revert":{width:`1.6em`,flexGrow:0,flexShrink:0,position:`relative`},".cm-merge-revert button":{position:`absolute`,display:`block`,width:`100%`,boxSizing:`border-box`,textAlign:`center`,background:`none`,border:`none`,font:`inherit`,cursor:`pointer`}})),Fp=ir.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:`auto !important`,overflowY:`visible !important`},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:`rgba(160, 128, 100, .08)`},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:`rgba(100, 160, 128, .08)`},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat`},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:`linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat`},"&light.cm-merge-b .cm-changedText":{background:`linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat`},"&dark.cm-merge-b .cm-changedText":{background:`linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat`},"&.cm-merge-b .cm-deletedText":{background:`#ff000033`},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:`none`},".cm-deletedChunk":{paddingLeft:`6px`,"& .cm-chunkButtons":{position:`absolute`,insetInlineEnd:`5px`},"& button":{border:`none`,cursor:`pointer`,color:`white`,margin:`0 2px`,borderRadius:`3px`,"&[name=accept]":{background:`#2a2`},"&[name=reject]":{background:`#d43`}}},".cm-collapsedLines":{padding:`5px 5px 5px 10px`,cursor:`pointer`,"&:before":{content:`"⦚"`,marginInlineEnd:`7px`},"&:after":{content:`"⦚"`,marginInlineStart:`7px`}},"&light .cm-collapsedLines":{color:`#444`,background:`linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)`},"&dark .cm-collapsedLines":{color:`#ddd`,background:`linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)`},".cm-changeGutter":{width:`3px`,paddingLeft:`1px`},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:`#e43`},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:`#fa9`},"&light.cm-merge-b .cm-changedLineGutter":{background:`#2b2`},"&dark.cm-merge-b .cm-changedLineGutter":{background:`#8f8`},".cm-inlineChangedLineGutter":{background:`#75d`}}),Ip=new ur,Lp=new ur,Rp=class{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||up;let t=[cr.low(dp),Fp,Pp,wp,ir.updateListener.of(e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some(e=>e.effects.some(e=>e.is(Cp)))&&this.measure()})],n=[Zf.of({side:`a`,sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&n.push(fp);let r=Yn.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],ir.editorAttributes.of({class:`cm-merge-a`}),Lp.of(n),t]}),i=[Zf.of({side:`b`,sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(fp);let a=Yn.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],ir.editorAttributes.of({class:`cm-merge-b`}),Lp.of(i),t]});this.chunks=np.build(r.doc,a.doc,this.diffConf);let o=[ep.init(()=>this.chunks),Ip.of(e.collapseUnchanged?Mp(e.collapseUnchanged):[])];r=r.update({effects:Qn.appendConfig.of(o)}).state,a=a.update({effects:Qn.appendConfig.of(o)}).state,this.dom=document.createElement(`div`),this.dom.className=`cm-mergeView`,this.editorDOM=this.dom.appendChild(document.createElement(`div`)),this.editorDOM.className=`cm-mergeViewEditors`;let s=e.orientation||`a-b`,c=document.createElement(`div`);c.className=`cm-mergeViewEditor`;let l=document.createElement(`div`);l.className=`cm-mergeViewEditor`,this.editorDOM.appendChild(s==`a-b`?c:l),this.editorDOM.appendChild(s==`a-b`?l:c),this.a=new ir({state:r,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new ir({state:a,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls==`b-to-a`,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some(e=>e.docChanged)){let n=e[e.length-1],r=e.reduce((e,t)=>e.compose(t.changes),nr.empty(e[0].startState.doc.length));this.chunks=t==this.a?np.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):np.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:Qf.of(this.chunks)})]);let i=t==this.a?this.b:this.a;i.update([i.state.update({effects:Qf.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(Zf),o=n?e.gutter!==!1:r.markGutter,s=t?e.highlightChanges!==!1:r.highlightChanges;i.push(Lp.reconfigure([Zf.of({side:`a`,sibling:()=>this.b,highlightChanges:s,markGutter:o}),o?fp:[]])),a.push(Lp.reconfigure([Zf.of({side:`b`,sibling:()=>this.a,highlightChanges:s,markGutter:o}),o?fp:[]]))}if(r){let t=Ip.reconfigure(e.collapseUnchanged?Mp(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(){Dp(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=zp(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=zp(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 zp(e){let t=e.nextSibling;return e.remove(),t}var Bp=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-deletedLineGutter`}},Vp=cr.low(or({class:`cm-changeGutter`,markers:e=>e.plugin(dp)?.gutter||Kn.empty,widgetMarker:(e,t)=>t instanceof Kp?Bp:null}));function Hp(e){let t=typeof e.original==`string`?Zn.of(e.original.split(/\r?\n/)):e.original,n=e.diffConfig||up;return[cr.low(dp),Zp,Fp,ir.editorAttributes.of({class:`cm-merge-b`}),$f.of((e,t)=>{let r=t.effects.find(e=>e.is(Up));return r&&(e=np.updateA(e,r.value.doc,t.startState.doc,r.value.changes,n)),t.docChanged&&(e=np.updateB(e,t.state.field(Wp),t.newDoc,t.changes,n)),e}),Zf.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:e.mergeControls??!0,overrideChunk:e.allowInlineDiffs?rm:void 0,side:`b`}),Wp.init(()=>t),e.gutter===!1?[]:Vp,e.collapseUnchanged?Mp(e.collapseUnchanged):[],ep.init(e=>np.build(t,e.doc,n))]}var Up=Qn.define(),Wp=er.define({create:()=>Zn.empty,update(e,t){for(let n of t.effects)n.is(Up)&&(e=n.value.doc);return e}}),Gp=new WeakMap,Kp=class extends tr{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||=this.buildDOM(e)}};function qp(e,t,n){let r=Gp.get(t.changes);if(r)return r;let i=lr.widget({block:!0,side:-1,widget:new Kp(r=>{let{highlightChanges:i,syntaxHighlightDeletions:a,syntaxHighlightDeletionsMaxLength:o,mergeControls:s}=e.facet(Zf),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(),Jp(r,r.posAtDOM(c))},i=e=>{e.preventDefault(),Yp(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(Wp).sliceString(t.fromA,t.endA),u=a&&e.facet($n),d=h(),f=t.changes,p=0,m=!1;function h(){let e=c.appendChild(document.createElement(`div`));return e.className=`cm-deletedLine`,e.appendChild(document.createElement(`del`))}function g(e,t,n){for(let r=e;r<t;){if(l.charAt(r)==`
15
15
  `){d.firstChild||d.appendChild(document.createElement(`br`)),d=h(),r++;continue}let e=t,a=n+(m?` cm-deletedText`:``),o=!1,s=l.indexOf(`
16
16
  `,r);if(s>-1&&s<t&&(e=s),i&&p<f.length){let t=Math.max(0,m?f[p].toA:f[p].fromA);t<=e&&(e=t,m&&p++,o=!0)}if(e>r){let t=document.createTextNode(l.slice(r,e));if(a){let e=d.appendChild(document.createElement(`span`));e.className=a,e.appendChild(t)}else d.appendChild(t);r=e}o&&(m=!m)}}if(u&&t.toA-t.fromA<=o){let t=u.parser.parse(l),n=0;Xn(t,{style:t=>qn(e,t)},(e,t,r)=>{e>n&&g(n,e,``),g(e,t,r),n=t}),g(n,l.length,``)}else g(0,l.length,``);return d.firstChild||d.appendChild(document.createElement(`br`)),c})});return Gp.set(t.changes,i),i}function Jp(e,t){let{state:n}=e,r=t??n.selection.main.head,i=e.state.field(ep).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(Wp);i.fromB!=i.toB&&i.toA<=o.length&&(a+=e.state.lineBreak);let s=nr.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:a},o.length);return e.dispatch({effects:Up.of({doc:s.apply(o),changes:s}),userEvent:`accept`}),!0}function Yp(e,t){let{state:n}=e,r=t??n.selection.main.head,i=n.field(ep).find(e=>e.fromB<=r&&e.endB>=r);if(!i)return!1;let a=n.field(Wp).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 Xp(e){let t=new sr;for(let n of e.field(ep)){let r=e.facet(Zf).overrideChunk&&$p(e,n);t.add(n.fromB,n.fromB,qp(e,n,!!r))}return t.finish()}var Zp=er.define({create:e=>Xp(e),update(e,t){return t.state.field(ep,!1)==t.startState.field(ep,!1)?e:Xp(t.state)},provide:e=>ir.decorations.from(e)}),Qp=new WeakMap;function $p(e,t){let n=Qp.get(t);if(n!==void 0)return n;n=null;let r=e.field(Wp),i=e.doc,a=r.lineAt(t.endA).number-r.lineAt(t.fromA).number+1,o=i.lineAt(t.endB).number-i.lineAt(t.fromB).number+1;abort:if(a==o&&a<10){let e=[],i=0,o=t.fromA,s=t.fromB;for(let n of t.changes){if(n.fromA<n.toA){i+=n.toA-n.fromA;let t=r.sliceString(o+n.fromA,o+n.toA);if(/\n/.test(t))break abort;e.push(lr.widget({widget:new em(t),side:-1}).range(s+n.fromB))}n.fromB<n.toB&&e.push(gp.range(s+n.fromB,s+n.toB))}i<t.endA-t.fromA-a*2&&(n=e)}return Qp.set(t,n),n}var em=class extends tr{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let t=document.createElement(`del`);return t.className=`cm-deletedText`,t.textContent=this.text,t}},tm=new class extends rr{constructor(){super(...arguments),this.elementClass=`cm-inlineChangedLineGutter`}},nm=lr.line({class:`cm-inlineChangedLine`});function rm(e,t,n,r){let i=$p(e,t),a=0;if(!i)return!1;for(let o=e.doc.lineAt(t.fromB);;){for(r&&r.add(o.from,o.from,tm),n.add(o.from,o.from,nm);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 im=zn({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}}),am=Cn({settings:{background:`var(--background)`,gutterBackground:`var(--muted)`}});function om(e){let t=(0,Q.c)(20),{oldContent:n,newContent:r,layout:i,conflictMode:a,onResolve:o,onAbort:s}=e,c=(0,Z.useRef)(null),l=(0,Z.useRef)(null),{resolvedTheme:u}=Ve(),d=(0,Z.useRef)(o),f=(0,Z.useRef)(s),[p,m]=(0,Z.useState)(null),h;t[0]!==s||t[1]!==o?(h=()=>{d.current=o,f.current=s},t[0]=s,t[1]=o,t[2]=h):h=t[2],(0,Z.useEffect)(h);let g,_;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==u?(g=()=>{if(!c.current)return;let e=u===`dark`?im:am,t=[ir.editable.of(!1),Yn.readOnly.of(!0)],o=[Fn,fn(),...t,e,ir.lineWrapping];if(l.current&&=(l.current.destroy(),null),a){let t=new ir({doc:r,extensions:[Fn,fn(),ir.editable.of(!1),e,ir.lineWrapping,Hp({original:n,highlightChanges:!0,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),ir.updateListener.of(e=>{let t=tp(e.state);m(t?t.chunks.length:0)})],parent:c.current});l.current=t;let i=tp(t.state);m(i?i.chunks.length:0)}else i===`split`?l.current=new Rp({a:{doc:n,extensions:o},b:{doc:r,extensions:o},parent:c.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}):l.current=new ir({doc:r,extensions:[...o,Hp({original:n,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}})],parent:c.current});return()=>{l.current&&=(l.current.destroy(),null)}},_=[n,r,i,u,a],t[3]=a,t[4]=i,t[5]=r,t[6]=n,t[7]=u,t[8]=g,t[9]=_):(g=t[8],_=t[9]),(0,Z.useEffect)(g,_);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=function(){let e=l.current;!e||!(e instanceof ir)||d.current?.(e.state.doc.toString())},t[10]=v):v=t[10];let y=v,b=p===0,x=p===null?``:p===0?`All hunks resolved`:`${p} unresolved hunk${p===1?``:`s`}`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(`div`,{ref:c,className:`diff-view min-h-0 flex-1 overflow-y-auto subtle-scrollbar`}),t[11]=S):S=t[11];let C;t[12]!==b||t[13]!==a||t[14]!==x||t[15]!==s||t[16]!==o?(C=a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-t shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs ${b?`text-emerald-600 dark:text-emerald-400`:`text-muted-foreground`}`,children:x}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:`Exit merge`}),o&&(0,$.jsx)(q,{variant:`default`,size:`sm`,disabled:!b,onClick:y,children:`Save resolution`})]})]}),t[12]=b,t[13]=a,t[14]=x,t[15]=s,t[16]=o,t[17]=C):C=t[17];let w;return t[18]===C?w=t[19]:(w=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[S,C]}),t[18]=C,t[19]=w),w}function sm(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Lt,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function cm(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Pt,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function lm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(At,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function um(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)(lm,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=k(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,$.jsx)(zt,{"data-slot":`sheet-close`,asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,$.jsx)(jt,{}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Close`})]})}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(cm,{children:[l,(0,$.jsxs)(Vt,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function dm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(qt,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pm(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Wt,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}async function mm(){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 hm(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 gm(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 _m=`w-[98vw] !max-w-[98vw] h-[96vh] flex flex-col gap-0 sm:!max-w-[98vw]`;function vm(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 hm(n).then(t=>{e||o(t)}),()=>{e=!0}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c),a===null){let e;t[3]===i?e=t[4]:(e=e=>!e&&i(),t[3]=i,t[4]=e);let r;t[5]===n?r=t[6]:(r=(0,$.jsx)(Bn,{className:`shrink-0`,children:(0,$.jsxs)(pn,{children:[`Resolving: `,n]})}),t[5]=n,t[6]=r);let a;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`}),t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=(0,$.jsxs)(In,{className:_m,children:[r,a]}),t[8]=r,t[9]=o);let s;return t[10]!==e||t[11]!==o?(s=(0,$.jsx)(ln,{open:!0,onOpenChange:e,children:o}),t[10]=e,t[11]=o,t[12]=s):s=t[12],s}let l;t[13]===i?l=t[14]:(l=e=>!e&&i(),t[13]=i,t[14]=l);let u;t[15]===n?u=t[16]:(u=(0,$.jsxs)(pn,{className:`text-sm font-medium`,children:[`Resolving: `,n]}),t[15]=n,t[16]=u);let d;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Red = your version (ours). Green = team's version (theirs). Accept each hunk to take theirs, reject to keep yours, then save.`}),t[17]=d):d=t[17];let f;t[18]===u?f=t[19]:(f=(0,$.jsxs)(Bn,{className:`px-4 pt-4 pb-2 shrink-0`,children:[u,d]}),t[18]=u,t[19]=f);let p;t[20]!==i||t[21]!==r||t[22]!==a.ours||t[23]!==a.theirs?(p=(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(om,{oldContent:a.ours,newContent:a.theirs,layout:`unified`,conflictMode:!0,onResolve:r,onAbort:i})}),t[20]=i,t[21]=r,t[22]=a.ours,t[23]=a.theirs,t[24]=p):p=t[24];let m;t[25]!==f||t[26]!==p?(m=(0,$.jsxs)(In,{className:`${_m} p-0`,children:[f,p]}),t[25]=f,t[26]=p,t[27]=m):m=t[27];let h;return t[28]!==l||t[29]!==m?(h=(0,$.jsx)(ln,{open:!0,onOpenChange:l,children:m}),t[28]=l,t[29]=m,t[30]=h):h=t[30],h}function ym(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(){mm().then(e=>{let{conflicts:t,error:n}=e;c(n??null),o(t),d(e=>{let n=new Set(t.map(bm));return new Set([...e].filter(e=>!n.has(e)))})})},t[3]=_):_=t[3];let v=_,y,b;t[4]===n?(y=t[5],b=t[6]):(y=()=>{n&&v()},b=[n],t[4]=n,t[5]=y,t[6]=b),(0,Z.useEffect)(y,b);let x,S;t[7]===n?(x=t[8],S=t[9]):(x=()=>ce(e=>{e.includes(`sync-status`)&&n&&v()}),S=[n],t[7]=n,t[8]=x,t[9]=S),(0,Z.useEffect)(x,S);let C,w;t[10]!==a.length||t[11]!==r||t[12]!==n||t[13]!==u.size?(w=()=>{n&&a.length>0&&u.size>=a.length&&(X.success(`All conflicts resolved — sync resuming`),r(!1),d(new Set))},C=[n,a.length,u.size,r],t[10]=a.length,t[11]=r,t[12]=n,t[13]=u.size,t[14]=C,t[15]=w):(C=t[14],w=t[15]),(0,Z.useEffect)(w,C);let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=async function(e,t,n){m(t=>new Set([...t,e]));let r=await gm(e,t,n);m(t=>{let n=new Set(t);return n.delete(e),n}),r?d(t=>new Set([...t,e])):X.error(`Failed to resolve ${e}`)},t[16]=T):T=t[16];let E=T,D;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(D=function(e){g(e)},t[17]=D):D=t[17];let O=D,k;t[18]===h?k=t[19]:(k=async function(e){if(!h)return;let t=h;g(null),await E(t,`content`,e)},t[18]=h,t[19]=k);let A=k,j;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(){g(null)},t[20]=j):j=t[20];let M=j,N;t[21]===r?N=t[22]:(N=async function(){try{(await fetch(`/api/sync/abort-merge`,{method:`POST`})).ok?X.info(`Merge aborted — sync paused`):X.error(`Failed to abort merge`)}catch{X.error(`Failed to abort merge — connection error`)}r(!1),d(new Set)},t[21]=r,t[22]=N);let P=N,F=a.length,I=u.size,L;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(fm,{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)(dm,{className:`px-4 py-3 border-b shrink-0`,children:[L,R]}),t[27]=R,t[28]=z);let B;t[29]!==a||t[30]!==s||t[31]!==u||t[32]!==p?(B=(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:s?(0,$.jsxs)(`div`,{className:`px-4 py-6 text-sm text-center space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-destructive`,children:s===`network`?`Could not reach the sync server — check your connection.`:`Sync server error — try again in a moment.`}),(0,$.jsx)(q,{variant:`outline`,size:`sm`,onClick:v,children:`Retry`})]}):a.length===0?(0,$.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground text-center`,children:`No conflicts found.`}):(0,$.jsx)(`ul`,{className:`divide-y`,children:a.map(e=>{let t=u.has(e.file),n=p.has(e.file),r=e.file.split(`/`).pop()??e.file;return(0,$.jsxs)(`li`,{className:`px-4 py-3 ${t?`opacity-50`:``}`,children:[(0,$.jsxs)(`p`,{className:`text-sm font-medium truncate mb-2`,title:e.file,children:[t?`✓ `:``,r]}),!t&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`mine`),children:`Keep my version`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,disabled:n,onClick:()=>void E(e.file,`theirs`),children:`Keep team's version`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,disabled:n,onClick:()=>O(e.file),children:`Resolve manually`})]})]},e.file)})})}),t[29]=a,t[30]=s,t[31]=u,t[32]=p,t[33]=B):B=t[33];let V;t[34]===P?V=t[35]:(V=(0,$.jsx)(`div`,{className:`px-4 py-3 border-t shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:P,children:`Exit merge`})}),t[34]=P,t[35]=V);let H;t[36]!==z||t[37]!==B||t[38]!==V?(H=(0,$.jsxs)(um,{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)(sm,{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)(vm,{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 bm(e){return e.file}function xm(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Sm(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Cm(e){return e/100*window.innerHeight}function wm(e){return e/100*window.innerWidth}function Tm(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 Em({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Tm(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Sm(t,i);break;case`em`:r=xm(t,i);break;case`vh`:r=Cm(i);break;case`vw`:r=wm(i);break}return r}function Dm(e){return parseFloat(e.toFixed(3))}function Om({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 km(e){let{panels:t}=e,n=Om({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=Dm(Em({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Dm(Em({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Dm(Em({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Dm(Em({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 Am(e,t=`Assertion error`){if(!e)throw Error(t)}function jm(e,t){return Array.from(t).sort(e===`horizontal`?Mm:Nm)}function Mm(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Nm(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Pm(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Fm(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 Im({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}=Fm(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Am(i,`No rect found`),i}var Lm;function Rm(){return Lm===void 0&&(Lm=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),Lm}function zm(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=jm(n,Array.from(t.children).filter(Pm).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,Im({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=Rm()?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:Om({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 Bm=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)}}},Vm=new Map,Hm=new Bm;function Um(e){Vm=new Map(Vm),Vm.delete(e)}function Wm(e,t){for(let[t]of Vm)if(t.id===e)return t}function Gm(e,t){for(let[t,n]of Vm)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Km(){return Vm}function qm(e,t){return Hm.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Jm(e,t){let n=Vm.get(e);Vm=new Map(Vm),Vm.set(e,t),Hm.emit(`groupChange`,{group:e,prev:n,next:t})}function Ym(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Fm(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 Xm(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Zm(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:rh(e),b:rh(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Am(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:nh(th(n.a)),b:nh(th(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 Qm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function $m(e){let t=getComputedStyle(ih(e)??e).display;return t===`flex`||t===`inline-flex`}function eh(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||$m(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`||Qm.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function th(e){let t=e.length;for(;t--;){let n=e[t];if(Am(n,`Missing node`),eh(n))return n}return null}function nh(e){return e&&Number(getComputedStyle(e).zIndex)||0}function rh(e){let t=[];for(;e;)t.push(e),e=ih(e);return t}function ih(e){let{parentNode:t}=e;return Xm(t)?t.host:t}function ah(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 oh({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Pm(n)||n.contains(e)||e.contains(n))return!0;if(Zm(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(ah(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function sh(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=zm(r),a=Ym(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&oh({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function ch(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 lh(e,t,n=0){return Math.abs(Dm(e)-Dm(t))<=n}function uh(e,t){return lh(e,t)?0:e>t?1:-1}function dh({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(uh(r,c)<0)if(a){let e=(i+c)/2;r=uh(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Dm(r),r}function fh({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(lh(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Am(u!=null,`Invalid first pivot index`),Am(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Am(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(Am(n!=null,`Previous layout not found for panel index ${t}`),lh(n,i)){let t=o-n;uh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Am(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(Am(n!=null,`Previous layout not found for panel index ${t}`),lh(n,o)){let t=n-i;uh(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Am(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&uh(i,c)<0)if(e>0){let t=c-o,n=t/2;uh(i+e,c)<0&&(e=uh(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;uh(i-e,c)<0&&(e=uh(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];Am(e!=null,`Previous layout not found for panel index ${r}`);let a=dh({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];Am(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=dh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!lh(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(ch(c,l))return i;{let t=e<0?d:u,r=s[t];Am(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=dh({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!lh(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Am(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=dh({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(lh(i,s)||(t-=s-i,l[r]=s),lh(t,0))break;e>0?r--:r++}}}if(!lh(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 ph(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||uh(e[n],t[n])!==0)return!1;return!0}function mh({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(!lh(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Am(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];Am(i!=null,`No layout data found for index ${e}`);let o=r[e];Am(o!=null,`No layout data found for index ${e}`);let s=dh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!lh(a,0))for(let e=0;e<t.length;e++){let n=r[e];Am(n!=null,`No layout data found for index ${e}`);let i=n+a,o=dh({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,lh(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function hh({groupId:e,panelId:t}){let n=()=>{let t=Km();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=mh({layout:fh({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});ph(l,p)||Jm(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&&lh(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Om({group:t});o(Dm(Em({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function gh(e){e.defaultPrevented||sh(e,Km()).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=hh({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function _h(e){let t=Km();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 vh({groupId:e}){let t=()=>{let t=Km();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=mh({layout:e,panelConstraints:r});return n?o:(ph(o,c)||Jm(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function yh(e,t){let n=_h(e),r=Gm(n.id,!0),i=n.separators.find(t=>t.element===e);Am(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Am(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=vh({groupId:n.id}).getLayout(),c=mh({layout:fh({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});ph(s,c)||Jm(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function bh(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=_h(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&yh(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&yh(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&yh(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&yh(t,-5);break;case`End`:e.preventDefault(),yh(t,100);break;case`Enter`:{e.preventDefault();let n=_h(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=Gm(n.id,!0),o=n.separators.find(e=>e.element===t);Am(o,`Matching separator not found`);let s=a.get(o);Am(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Am(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];yh(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=_h(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Am(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(),yh(t,-100);break}}var xh={cursorFlags:0,state:`inactive`},Sh=new Bm;function Ch(){return xh}function wh(e){return Sh.addListener(`change`,e)}function Th(e){let t=xh,n={...xh};n.cursorFlags=e,xh=n,Sh.emit(`change`,{prev:t,next:n})}function Eh(e){let t=xh;xh=e,Sh.emit(`change`,{prev:t,next:e})}function Dh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Km(),n=sh(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)}),Eh({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Oh=e=>e,kh=()=>{},Ah=1,jh=2,Mh=4,Nh=8,Ph=3,Fh=12,Ih;function Lh(){return Ih===void 0&&(Ih=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(Ih=!0)),Ih}function Rh({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&&Lh()){let t=(e&Ah)!==0,n=(e&jh)!==0,r=(e&Mh)!==0,i=(e&Nh)!==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 Lh()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var zh=new WeakMap;function Bh(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=zh.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Ch();switch(r.state){case`active`:case`hover`:{let e=Rh({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}zh.set(e,{prevStyle:t,styleSheet:n})}function Vh({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=fh({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(ph(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Ah:jh;break;case`vertical`:s|=d<0?Mh:Nh;break}}else Jm(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Ph:c|=s&Ph,t.movementY===0?c|=o&Fh:c|=s&Fh,Th(c),Bh(e)}function Hh(e){let t=Km(),n=Ch();switch(n.state){case`active`:Vh({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Uh(e){if(e.defaultPrevented)return;let t=Ch(),n=Km();switch(t.state){case`active`:if(e.buttons===0){Eh({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=Gm(e.group.id,!0);Jm(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)}Vh({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=sh(e,n);r.length===0?t.state!==`inactive`&&Eh({cursorFlags:0,state:`inactive`}):Eh({cursorFlags:0,hitRegions:r,state:`hover`}),Bh(e.currentTarget);break}}}function Wh(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Ch().state){case`hover`:Eh({cursorFlags:0,state:`inactive`})}}function Gh(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Ch();switch(t.state){case`active`:Eh({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(Bh(e.currentTarget),t.hitRegions.forEach(e=>{let t=Gm(e.group.id,!0);Jm(e.group,t)}),e.preventDefault())}}function Kh(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Dm(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Dm((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function qh(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Om({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Dm(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Jh(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 Yh({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=Dm(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]=Dm((r[e]??0)/a*l);else{let e=Dm(l/c.length);for(let t of c)u[t]=e}return u}function Xh(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 Zh=new Map;function Qh(e){let t=!0;Am(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=Om({group:e});if(t===0)return;let n=Gm(e.id);if(!n)return;let r=km(e),i=n.defaultLayoutDeferred?Kh(r):n.layout,a=mh({layout:Yh({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&ph(n.layout,a)&&Jh(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Jm(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else qh(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Am(!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=Om({group:e}),s=km(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Xh(e.panels,l)||(l=void 0));let u=mh({layout:e.mutableState.layouts[c]??l??Kh(s),panelConstraints:s}),d=e.element.ownerDocument;Zh.set(d,(Zh.get(d)??0)+1);let f=new Map;return zm(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Jm(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Am(!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`,bh)}),Zh.get(d)===1&&(d.addEventListener(`dblclick`,gh,!0),d.addEventListener(`pointerdown`,Dh,!0),d.addEventListener(`pointerleave`,Hh),d.addEventListener(`pointermove`,Uh),d.addEventListener(`pointerout`,Wh),d.addEventListener(`pointerup`,Gh,!0)),function(){t=!1,Zh.set(d,Math.max(0,(Zh.get(d)??0)-1)),Um(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,bh)}),Zh.get(d)||(d.removeEventListener(`dblclick`,gh,!0),d.removeEventListener(`pointerdown`,Dh,!0),d.removeEventListener(`pointerleave`,Hh),d.removeEventListener(`pointermove`,Uh),d.removeEventListener(`pointerout`,Wh),d.removeEventListener(`pointerup`,Gh,!0)),a.disconnect()}}function $h(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function eg(e){let t=(0,Z.useId)();return`${e??t}`}var tg=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function ng(e){let t=(0,Z.useRef)(e);return tg(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function rg(...e){return ng(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function ig(e){let t=(0,Z.useRef)({...e});return tg(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var ag=(0,Z.createContext)(null);function og(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:Oh});(0,Z.useImperativeHandle)(t,()=>n.current,[]),tg(()=>{Object.assign(n.current,vh({groupId:e}))})}function sg({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=ng(e=>{ph(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=ng(e=>{ph(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=eg(s),v=(0,Z.useRef)(null),[y,b]=$h(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=rg(v,a);og(_,o);let C=ng((e,t)=>{let r=Ch(),i=Wm(e),a=Gm(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=ig({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=jm(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=jm(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=Wm(_),i=Gm(_);r&&i&&Jm(r,{...i,derivedPanelConstraints:km(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 tg(()=>{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=Qh(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=Gm(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=qm(_,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=lh(t.collapsedSize,i[t.panelId]),a=lh(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Ch().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)(ag.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})})}sg.displayName=`Group`;function cg(){let e=(0,Z.useContext)(ag);return Am(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function lg(e,t){let{id:n}=cg(),r=(0,Z.useRef)({collapse:kh,expand:kh,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:kh});(0,Z.useImperativeHandle)(t,()=>r.current,[]),tg(()=>{Object.assign(r.current,hh({groupId:n,panelId:e}))})}function ug({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=eg(c),_=ig({disabled:a}),v=(0,Z.useRef)(null),y=rg(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=cg(),T=d!==null,E=ng((e,t,n)=>{d?.(e,c,n)});tg(()=>{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]),lg(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>qm(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:{...dg,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})})}ug.displayName=`Panel`;var dg={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function fg(){return(0,Z.useRef)(null)}function pg({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=mh({layout:fh({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=mh({layout:fh({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function mg({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=eg(a),l=ig({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),m=(0,Z.useRef)(null),h=rg(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=cg(),x=v===`horizontal`?`vertical`:`horizontal`;tg(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=wh(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=qm(_,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(pg({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})}mg.displayName=`Separator`;async function hg(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 gg(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=()=>hg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==s||t[5]!==o?(u=!s&&o.has(n),t[3]=n,t[4]=s,t[5]=o,t[6]=u):u=t[6];let d;t[7]!==c||t[8]!==l||t[9]!==u?(d={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=d):d=t[10];let{data:f,isLoading:p,error:m}=Je(d),h;t[11]===f?h=t[12]:(h=f===void 0?[]:f,t[11]=f,t[12]=h);let g=h,_;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Pe,{children:`Backlinks`}),t[13]=_):_=t[13];let v;t[14]!==g||t[15]!==p?(v=!p&&(0,$.jsx)(Me,{children:g.length}),t[14]=g,t[15]=p,t[16]=v):v=t[16];let y;t[17]===v?y=t[18]:(y=(0,$.jsxs)(Oe,{children:[_,v]}),t[17]=v,t[18]=y);let b;t[19]!==g||t[20]!==m||t[21]!==a||t[22]!==p||t[23]!==o?(b=m?(0,$.jsx)(te,{children:m instanceof Error?m.message:`Failed to load backlinks`}):g.length===0&&!p?(0,$.jsx)(ge,{children:`No pages link here yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`block w-full rounded-lg border border-border bg-background/80 px-3 py-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:()=>{let t=ft(e.source,{pages:o,folderPaths:a});window.location.assign(me(t.hashDocName,e.anchor))},children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source}),e.snippet?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.snippet}):null]},`${e.source}-${t}`))}),t[19]=g,t[20]=m,t[21]=a,t[22]=p,t[23]=o,t[24]=b):b=t[24];let x;t[25]!==p||t[26]!==b?(x=(0,$.jsx)(Ee,{"aria-busy":p,children:b}),t[25]=p,t[26]=b,t[27]=x):x=t[27];let S;return t[28]!==i||t[29]!==y||t[30]!==x?(S=(0,$.jsxs)(Ie,{className:i,children:[y,x]}),t[28]=i,t[29]=y,t[30]=x,t[31]=S):S=t[31],S}function _g(e){let t=e.split(`/`);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}async function vg(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 yg(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=()=>vg(n),t[0]=n,t[1]=c,t[2]=l);let u;t[3]!==n||t[4]!==o||t[5]!==s?(u=!s&&o.has(n),t[3]=n,t[4]=o,t[5]=s,t[6]=u):u=t[6];let d;t[7]!==c||t[8]!==l||t[9]!==u?(d={queryKey:c,queryFn:l,enabled:u},t[7]=c,t[8]=l,t[9]=u,t[10]=d):d=t[10];let{data:f,isLoading:p,error:m}=Je(d),h;t[11]===f?h=t[12]:(h=f===void 0?[]:f,t[11]=f,t[12]=h);let g=h,[_,v]=(0,Z.useState)(null),y;if(t[13]!==_||t[14]!==a||t[15]!==o){let e=_===null?null:en(_.docName,{pages:o,folderPaths:a});y=e===null?null:e.kind===`create`?{initialDir:e.initialDir,suggestedName:e.suggestedName}:Xt(e),t[13]=_,t[14]=a,t[15]=o,t[16]=y}else y=t[16];let b=y,x;t[17]!==a||t[18]!==o||t[19]!==s?(x=function(e){if(e.kind===`external`){window.open(e.url,`_blank`,`noopener,noreferrer`);return}let t=en(e.docName,{pages:o,folderPaths:a});if(!s&&t.kind===`create`){v(e);return}let n=t.kind===`navigate`?t.hashDocName:e.docName;window.location.assign(me(n,e.anchor))},t[17]=a,t[18]=o,t[19]=s,t[20]=x):x=t[20];let S=x,C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(Pe,{children:`Outgoing Links`}),t[21]=C):C=t[21];let w;t[22]!==p||t[23]!==g?(w=!p&&(0,$.jsx)(Me,{children:g.length}),t[22]=p,t[23]=g,t[24]=w):w=t[24];let T;t[25]===w?T=t[26]:(T=(0,$.jsxs)(Oe,{children:[C,w]}),t[25]=w,t[26]=T);let E;t[27]!==m||t[28]!==a||t[29]!==S||t[30]!==p||t[31]!==g||t[32]!==o||t[33]!==s?(E=m?(0,$.jsx)(te,{children:m instanceof Error?m.message:`Failed to load outgoing links`}):g.length===0&&!p?(0,$.jsx)(ge,{children:`This page doesn't link to anything yet.`}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>{let t=e.kind===`doc`?en(e.docName,{pages:o,folderPaths:a}):null,n=e.kind===`doc`&&!s&&t?.kind===`create`,r=e.kind===`doc`&&!s&&t?.kind===`navigate`&&t.displayState===`folder`,i=e.kind===`doc`?_g(e.docName):e.url,c=e.kind===`doc`&&e.title===e.docName?i:e.title,l=e.kind===`doc`?`doc:${e.docName}:${e.anchor??``}`:`ext:${e.url}`;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(q,{variant:`outline`,className:k(`h-auto w-full items-start justify-start whitespace-normal px-3 py-2 text-left`,n&&`border-amber-300 bg-amber-50/70 text-amber-950 hover:bg-amber-100 dark:border-amber-900 dark:bg-amber-950/20 dark:text-amber-200 dark:hover:bg-amber-950/35`,r&&`border-sky-300 bg-sky-50/70 text-sky-950 hover:bg-sky-100 dark:border-sky-900 dark:bg-sky-950/20 dark:text-sky-100 dark:hover:bg-sky-950/35`),onClick:()=>S(e),children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium`,title:e.kind===`doc`&&e.title===e.docName?e.docName:e.kind===`external`?e.url:void 0,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{children:c}),e.kind===`external`?(0,$.jsx)(_t,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}):null]})}),e.kind===`doc`&&e.title!==e.docName?(0,$.jsx)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,title:e.docName,children:i}):null,e.kind===`external`?(0,$.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-xs text-muted-foreground`,children:e.url}):null,n?(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(_n,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Missing page. Click to create.`})]}):null,r?(0,$.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-sky-700 dark:text-sky-300`,children:[(0,$.jsx)(Dn,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Folder target. Click to open the overview.`})]}):null,e.snippet?(0,$.jsx)(`p`,{className:`mt-1 break-words text-sm text-muted-foreground`,children:e.snippet}):null]})}),r?(0,$.jsxs)(q,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>v(e),children:[(0,$.jsx)(_n,{className:`size-3.5`}),`Create index note`]}):null]},l)})}),t[27]=m,t[28]=a,t[29]=S,t[30]=p,t[31]=g,t[32]=o,t[33]=s,t[34]=E):E=t[34];let D;t[35]!==p||t[36]!==E?(D=(0,$.jsx)(Ee,{"aria-busy":p,children:E}),t[35]=p,t[36]=E,t[37]=D):D=t[37];let O;t[38]!==i||t[39]!==T||t[40]!==D?(O=(0,$.jsxs)(Ie,{className:i,children:[T,D]}),t[38]=i,t[39]=T,t[40]=D,t[41]=O):O=t[41];let A=_!==null,j=b?.initialDir??``,M=b?.suggestedName,N;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{e||v(null)},t[42]=N):N=t[42];let P;t[43]!==A||t[44]!==j||t[45]!==M?(P=(0,$.jsx)(Ct,{open:A,kind:`file`,initialDir:j,suggestedName:M,onOpenChange:N}),t[43]=A,t[44]=j,t[45]=M,t[46]=P):P=t[46];let F;return t[47]!==O||t[48]!==P?(F=(0,$.jsxs)($.Fragment,{children:[O,P]}),t[47]=O,t[48]=P,t[49]=F):F=t[49],F}var bg=[{id:`outline`,label:`Outline`,icon:di},{id:`backlinks`,label:`Backlinks`,icon:Kr},{id:`forward-links`,label:`Outgoing Links`,icon:qr},{id:`graph`,label:`Graph`,icon:mi}];function xg(){return Sn(()=>import(`./GraphPanel-DW_Dc6tS.js`),__vite__mapDeps([0,1,2,3]))}var Sg=(0,Z.lazy)(async()=>({default:(await xg()).GraphPanel}));function Cg(e){let t=(0,Q.c)(27),{docName:n,isSourceMode:r}=e,[i,a]=(0,Z.useState)(bg[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=bg.map(wg),t[1]=s):s=t[1];let c;t[2]===i?c=t[3]:(c=(0,$.jsx)(mt,{type:`single`,variant:`outline`,value:i,onValueChange:o,className:`mx-auto p-2`,"aria-label":`Document panels`,children:s}),t[2]=i,t[3]=c);let l=`panel-${i}`,u=`tab-${i}`,d;t[4]!==i||t[5]!==n||t[6]!==r?(d=i===`outline`&&(0,$.jsx)(kn,{docName:n,isSourceMode:r}),t[4]=i,t[5]=n,t[6]=r,t[7]=d):d=t[7];let f;t[8]!==i||t[9]!==n?(f=i===`backlinks`&&(0,$.jsx)(gg,{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)(yg,{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)(Sg,{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 wg(e){let{id:t,label:n,icon:r}=e;return(0,$.jsxs)(ot,{children:[(0,$.jsx)(lt,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,$.jsx)(pt,{children:(0,$.jsx)(r,{})})}),(0,$.jsx)($e,{side:`bottom`,children:n})]},t)}function Tg(){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)(df,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,$.jsx)(df,{className:`h-4 w-full`}),(0,$.jsx)(df,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}function Eg(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function Dg(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=Eg(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function Og(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function kg(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:Dg(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:Og(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:Dg(e,t.pageTitles),children:a}}var Ag=lc,jg=uc,Mg=yc,Ng=hc;function Pg(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i&&`pl-8`,s;t[5]!==r||t[6]!==o?(s=k(`focus:bg-accent data-[state=open]:bg-accent flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,o,r),t[5]=r,t[6]=o,t[7]=s):s=t[7];let c;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Lr,{className:`ml-auto`}),t[8]=c):c=t[8];let l;return t[9]!==n||t[10]!==a||t[11]!==s?(l=(0,$.jsxs)(bc,{"data-slot":`dropdown-menu-sub-trigger`,className:s,...a,children:[n,c]}),t[9]=n,t[10]=a,t[11]=s,t[12]=l):l=t[12],l}function Fg(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(xc,{"data-slot":`dropdown-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ig(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,sideOffset:i,portal:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?4:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=k(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md`,n),t[5]=n,t[6]=c);let l;t[7]!==r||t[8]!==o||t[9]!==c?(l=(0,$.jsx)(fc,{"data-slot":`dropdown-menu-content`,sideOffset:o,className:c,...r}),t[7]=r,t[8]=o,t[9]=c,t[10]=l):l=t[10];let u=l;if(!s)return u;let d;return t[11]===u?d=t[12]:(d=(0,$.jsx)(dc,{children:u}),t[11]=u,t[12]=d),d}function Lg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=r&&`pl-8`,o;t[4]!==n||t[5]!==a?(o=k(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,$.jsx)(mc,{"data-slot":`dropdown-menu-item`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function Rg(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,inset:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,$.jsx)(_c,{children:(0,$.jsx)(Fr,{})})}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(gc,{"data-slot":`dropdown-menu-radio-item`,"data-inset":i,className:o,...a,children:[s,n]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function 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,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=r&&`pl-8`,o;t[4]!==n||t[5]!==a?(o=k(`px-2 py-1.5 text-sm font-semibold`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==o?(s=(0,$.jsx)(pc,{"data-slot":`dropdown-menu-label`,className:o,...i}),t[7]=i,t[8]=o,t[9]=s):s=t[9],s}function 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=k(`bg-muted -mx-1 my-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(vc,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Vg(e){let t=(0,Q.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=k(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=k(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,$.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,$.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function Hg(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ug(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`[&_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 Wg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=k(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,$.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Gg(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=k(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,$.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function 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=k(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qg(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 Jg(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 Yg(e){let t=(0,Q.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,$.jsx)(kr,{className:`ml-1 size-3`}):(0,$.jsx)(Tr,{className:`ml-1 size-3`}):(0,$.jsx)(Or,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function Xg(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)(df,{className:`size-5 rounded`}),(0,$.jsx)(df,{className:`h-7 w-48`})]}),(0,$.jsx)(df,{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)(df,{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)(df,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(e_)]})]})}),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=kg(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=Jg(e.children,h,_),l;t[21]===h?l=t[22]:(l=function(e){e===h?v($g):(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(Qg);if(!t.ok||!i?.ok){m(i?.error??`Server error (HTTP ${t.status})`),f(!1);return}let a=i.docName??`${n}/index`;r(a),ze([`files`,`backlinks`,`graph`]),window.location.hash=me(a)}catch(e){console.warn(`[FolderOverview] create index note failed:`,e),m(`Network error — please try again`)}f(!1)},t[23]=r,t[24]=n,t[25]=O):O=t[25];let k=O;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,w=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Dn,{className:`size-5 text-muted-foreground`}),t[26]=A):A=t[26];let j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,$.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(Si,{className:`size-4`}),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{children:[M,`New`,(0,$.jsx)(Ir,{className:`size-3`})]})}),t[28]=N):N=t[28];let P;t[29]===k?P=t[30]:(P=()=>void k(),t[29]=k,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-medium`,children:`Index note`}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Landing page for this folder`})]}),t[31]=F):F=t[31];let I;t[32]!==d||t[33]!==P?(I=(0,$.jsx)(Lg,{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)(Lg,{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)(Ag,{children:[N,(0,$.jsxs)(Ig,{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=Vg;let H=h===`name`?_===`asc`?`ascending`:`descending`:`none`,U;t[47]!==D||t[48]!==_||t[49]!==h?(U=(0,$.jsx)(Yg,{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)(Gg,{"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)(Yg,{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)(Gg,{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)(Hg,{children:(0,$.jsxs)(Wg,{children:[W,ee]})}),t[61]=W,t[62]=ee,t[63]=S):S=t[63],y=Ug,x=a.length?a.map(Zg):(0,$.jsx)(Wg,{children:(0,$.jsx)(Kg,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=r,t[4]=p,t[5]=d,t[6]=n,t[7]=i,t[8]=c,t[9]=s,t[10]=o,t[11]=_,t[12]=h,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E}else y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20];let D;t[64]!==y||t[65]!==x?(D=(0,$.jsx)(y,{children:x}),t[64]=y,t[65]=x,t[66]=D):D=t[66];let O;t[67]!==b||t[68]!==S||t[69]!==D?(O=(0,$.jsxs)(b,{children:[S,D]}),t[67]=b,t[68]=S,t[69]=D,t[70]=O):O=t[70];let k;t[71]!==C||t[72]!==O?(k=(0,$.jsx)(`div`,{className:C,children:O}),t[71]=C,t[72]=O,t[73]=k):k=t[73];let A;t[74]!==w||t[75]!==T||t[76]!==k?(A=(0,$.jsxs)(`div`,{className:w,children:[T,k]}),t[74]=w,t[75]=T,t[76]=k,t[77]=A):A=t[77];let j;t[78]!==A||t[79]!==E?(j=(0,$.jsx)(`div`,{className:E,children:A}),t[78]=A,t[79]=E,t[80]=j):j=t[80];let M;t[81]!==l||t[82]!==n?(M=(0,$.jsx)(Ct,{open:l,onOpenChange:u,kind:`file`,initialDir:n}),t[81]=l,t[82]=n,t[83]=M):M=t[83];let N;return t[84]!==j||t[85]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[84]=j,t[85]=M,t[86]=N):N=t[86],N}function Zg(e){return(0,$.jsxs)(Wg,{children:[(0,$.jsx)(Kg,{children:(0,$.jsxs)(`a`,{href:me(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0 text-muted-foreground`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,$.jsx)(Kg,{className:`text-muted-foreground`,children:e.kind===`file`?qg(e.modified):`—`})]},e.path)}function Qg(){return null}function $g(e){return e===`asc`?`desc`:`asc`}function e_(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,$.jsx)(df,{className:`size-4 rounded`}),(0,$.jsx)(df,{className:`h-4 w-40`}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(df,{className:`h-4 w-16`})})]},e)}var t_=1e3,n_=3;function r_(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??n_;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var i_={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:130,durationMin:620,durationMax:920}},a_=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function o_(e,t={}){let n=t.rng??Math.random,r=t.colors??a_,i=i_[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var s_=.8,c_=9.2736,l_=18.1799,u_=14.5244,d_={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function f_(e,t){let{halfWidth:n,apexLift:r}=d_[t];return`M${e-n} ${u_+.3} Q${e} ${u_-r}, ${e+n} ${u_+.3}`}var p_=15,m_=15;function h_(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 g_(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),b;t[1]===u?b=t[2]:(b=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=r_(u,t);d(n),p(v_),g(o_(n)),clearTimeout(y.current),y.current=setTimeout(()=>{d(0),g([])},t_)},t[1]=u,t[2]=b);let x=b,S,C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>()=>clearTimeout(y.current),C=[],t[3]=S,t[4]=C):(S=t[3],C=t[4]),(0,Z.useEffect)(S,C);let w,T;t[5]===o?(w=t[6],T=t[7]):(w=()=>{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)*s_;d=a/u*e,f=o/u*e}c.current?.setAttribute(`cx`,String(c_+d)),c.current?.setAttribute(`cy`,String(u_+f)),l.current?.setAttribute(`cx`,String(l_+d)),l.current?.setAttribute(`cy`,String(u_+f))})};return document.addEventListener(`mousemove`,e,{passive:!0}),()=>{document.removeEventListener(`mousemove`,e),v.current&&cancelAnimationFrame(v.current)}},T=[o],t[5]=o,t[6]=w,t[7]=T),(0,Z.useEffect)(w,T);let E=u>0,D=E?u:1,O=E?`ok-blob-clicked-${u}`:null,A;t[8]===r?A=t[9]:(A=k(`cursor-pointer`,r),t[8]=r,t[9]=A);let j=`body-${f}`,M;t[10]===O?M=t[11]:(M=k(`ok-blob-group`,O),t[10]=O,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=E&&`ok-blob-eye-hidden`,F;t[13]===P?F=t[14]:(F=k(`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:c_,cy:u_,rx:1.2722,ry:1.9083,className:F}),t[15]=F,t[16]=I);let L=E&&`ok-blob-eye-hidden`,R;t[17]===L?R=t[18]:(R=k(`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:l_,cy:u_,rx:1.2722,ry:1.9083,className:R}),t[19]=R,t[20]=z);let B;t[21]===D?B=t[22]:(B=f_(c_,D),t[21]=D,t[22]=B);let V=!E&&`ok-blob-eye-hidden`,H;t[23]===V?H=t[24]:(H=k(`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]===D?W=t[29]:(W=f_(l_,D),t[28]=D,t[29]=W);let G=!E&&`ok-blob-eye-hidden`,K;t[30]===G?K=t[31]:(K=k(`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 ne;t[42]!==f||t[43]!==h?(ne=h.length>0&&(0,$.jsx)(`g`,{children:h.map(__)},`firework-${f}`),t[42]=f,t[43]=h,t[44]=ne):ne=t[44];let re;return t[45]!==x||t[46]!==a||t[47]!==te||t[48]!==ne||t[49]!==A?(re=(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:x,children:[te,ne]}),t[45]=x,t[46]=a,t[47]=te,t[48]=ne,t[49]=A,t[50]=re):re=t[50],re}function __(e){return(0,$.jsx)(`circle`,{cx:p_+e.originDx,cy:m_+e.originDy,r:e.size,className:`ok-blob-firework`,style:h_(e)},e.id)}function v_(e){return e+1}function y_(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(sg,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function b_(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)(ug,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function x_(e){let t=(0,Q.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=k(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,$.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,$.jsx)(mg,{"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 S_=960,C_=1024;function w_(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(E_),[r,i]=(0,Z.useState)(T_),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${S_-1}px)`),t=window.matchMedia(`(max-width: ${C_-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 T_(){return window.innerWidth>=S_&&window.innerWidth<C_}function E_(){return window.innerWidth<S_?`sheet`:`panel`}var D_=Ye;function O_(){let[e]=(0,Z.useState)(s);return e}function k_(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 A_=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&qe(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(P(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(y(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(je(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Ze(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(U(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(o(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(z(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(m(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=l(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof T){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof i){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():k_(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&g(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},j_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new A_({view:t,...e})});Be.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[j_({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 M_=b(pe(),1),N_=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return ee(e,{textSerializers:He(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(P(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(y(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(je(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(Ze(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(U(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(o(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(z(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(m(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=l(this.view,e.from,e.to);g({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},P_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new N_({view:t,...e})});Be.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[P_({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 F_(e,t){return e??new r(t)}var I_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,L_=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),R_=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(`.`)),z_=new Set([`children`,`className`,`style`]),B_=new Set([`tabIndex`]),V_=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),H_={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function U_(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function W_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function G_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||V_.has(e)}function K_(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function q_(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:H_[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function J_(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 Y_(e){return B_.has(e)}function X_(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function Z_(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 Q_(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||R_.has(e)?String(t):`${t}px`}function $_(e,t){L_.has(t)||e.style.removeProperty(K_(t))}function ev(e,t,n){L_.has(t)||e.style.setProperty(K_(t),Q_(t,n))}function tv(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(z_.has(r)||!G_(r)||U_(r,t[r])||U_(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=W_(r);if(a==null||a===!1){Y_(r)&&Z_(e,r),e.removeAttribute(o);return}if(a===!0){Y_(r)&&X_(e,r,!0),e.setAttribute(o,``);return}if(Y_(r)){X_(e,r,a);return}e.setAttribute(o,String(a))})}function nv(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function rv(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){$_(e,t);return}ev(e,t,a)}})}function iv(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(!U_(t,n))return;let{eventName:i,options:a}=q_(t),o=t=>{n(J_(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function av(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);I_(()=>{let i=n.current;return nv(e,i.className,t.className),rv(e,i.style,t.style),tv(e,i,t),r.current=iv(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 ov=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)(F_(e,`bubbleMenu`)).current;av(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=Dt(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Z.useRef)(h);g.current=h;let[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=j_({...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,M_.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)(F_(e,`floatingMenu`)).current;av(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=Dt(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Z.useRef)(m);h.current=m;let[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=P_({...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,M_.createPortal)(s,u.current)});function sv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=k(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,$.jsx)(rl,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var cv=[{name:`paragraph`,label:`Text`,icon:yi,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Ln,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:mn,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:bt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:nn,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:Gt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:sn,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:jn,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:Ni,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function lv(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:uv},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Ut(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,$.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=cv.map(e=>{let t=e.icon,r=a[e.name];return(0,$.jsxs)(Lg,{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)(Ig,{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)(Ag,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function uv(e){let t=Object.fromEntries(cv.map(t=>[t.name,t.isActive(e.editor)]));return{current:cv.find(e=>t[e.name])??cv[0],activeStates:t}}var dv=[{name:`bold`,icon:jr,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:si,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Vi,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Ii,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:Vr,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:ii,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function fv(e){let t=(0,Q.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:pv},t[0]=n,t[1]=r);let i=Ut(r),a;t[2]!==i||t[3]!==n?(a=dv.map(e=>{let t=e.icon,r=i[e.name];return(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,$.jsx)(t,{className:`size-3.5`})})}),(0,$.jsxs)($e,{side:`bottom`,sideOffset:8,children:[(0,$.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,$.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function pv(e){return Object.fromEntries(dv.map(t=>[t.name,t.isActive(e.editor)]))}function mv(e){let t=(0,Q.c)(46),{editor:n}=e,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),s=(0,Z.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Z.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Z.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,$.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link...`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(Kr,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),window.open(d,`_blank`,`noopener,noreferrer`)},children:(0,$.jsx)(_t,{className:`size-3.5`})})}),(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,$.jsx)(It,{className:`size-3.5`})})}),(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,$.jsx)(li,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsxs)($e,{side:`bottom`,sideOffset:8,children:[`Link`,(0,$.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,$.jsxs)(ot,{children:[T,E]}),t[44]=T,t[45]=D),D}function hv({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 gv(e){let t=(0,Q.c)(25),{editor:n}=e,r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),o=(0,Z.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return l(n.view,e,t)}catch{return new DOMRect}},t[0]=n.state,t[1]=n.view,t[2]=s):s=t[2];let c;if(t[3]!==n.view.dom||t[4]!==s){let e={getBoundingClientRect:s,contextElement:n.view.dom};c=()=>{let t=r.current;t&&(o.current?.(),o.current=I(e,t,()=>{g(e,t,{placement:`top`,strategy:`fixed`,middleware:[je(8),P(),y({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch(yv)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let u=c,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{o.current?.(),o.current=null,a(vv)},t[6]=d):d=t[6];let f=d,p;t[7]===u?p=t[8]:(p={onShow:u,onHide:f,strategy:`fixed`},t[7]=u,t[8]=p);let m;t[9]===n?m=t[10]:(m=(0,$.jsx)(lv,{editor:n}),t[9]=n,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(sv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=h):h=t[11];let _;t[12]!==n||t[13]!==i?(_=(0,$.jsx)(fv,{editor:n},i),t[12]=n,t[13]=i,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(sv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=v):v=t[15];let b=`${i}-link`,x;t[16]!==n||t[17]!==b?(x=(0,$.jsx)(mv,{editor:n},b),t[16]=n,t[17]=b,t[18]=x):x=t[18];let S;return t[19]!==n||t[20]!==x||t[21]!==p||t[22]!==m||t[23]!==_?(S=(0,$.jsxs)(ov,{ref:r,editor:n,appendTo:_v,shouldShow:hv,updateDelay:250,options:p,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[m,h,_,v,x]}),t[19]=n,t[20]=x,t[21]=p,t[22]=m,t[23]=_,t[24]=S):S=t[24],S}function _v(){return document.body}function vv(e){return e+1}function yv(){}var bv=[{name:`addRowBefore`,icon:kr,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Tr,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:It,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],xv=[{name:`addColumnBefore`,icon:Er,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Dr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:It,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],Sv=[{name:`toggleHeaderRow`,icon:Ri,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:Ur,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:ri,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function Cv({editor:e}){return e.isActive(`table`)}function wv(e){let t=(0,Q.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,$.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,$.jsx)($e,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,$.jsxs)(ot,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Tv(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=bv.map(e=>(0,$.jsx)(wv,{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)(sv,{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=xv.map(e=>(0,$.jsx)(wv,{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)(sv,{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=Sv.map(e=>(0,$.jsx)(wv,{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)(ov,{editor:n,shouldShow:Cv,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 Ev=new WeakMap;function Dv(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=A(e.color),n.textContent=e.name,t.append(n),t}var Ov={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},kv=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)(Ov),s=O_(),[c]=(0,Z.useState)(Av),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);if(d)throw d;let p=(0,Z.useRef)(null),m=n.configuration.name??``,h;t[0]!==c||t[1]!==m||t[2]!==r||t[3]!==n?(h=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=yt({docName:m,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new we({element:e,onBeforeCreate:e=>{let{editor:n}=e;Ev.set(n,t)},onCreate:e=>{let{editor:t}=e,r=Ev.get(t);if(Ev.delete(t),r==null)return;let i=performance.now();bn(`ok/editor/create-tiptap`,{docName:n.configuration.name??`unknown`,ytextLength:n.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-10 pb-16 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=c.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>c.text(e,t),clipboardSerializer:c.html,handlePaste:(e,t)=>c.paste(e,t)},extensions:[...Rt.map(e=>e.name===`link`?e.configure({docName:n.configuration.name??``}):e),D_.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),rn.configure({document:n.document}),Be.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[on]}}),Be.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[hn(e,{cursorBuilder:Dv})]}})]}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),p.current=e,u(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),p.current=null,u(null),f(t instanceof Error?t:Error(String(t)))}return()=>{let e=p.current;e&&Rn(e),p.current=null,u(null)}},t[0]=c,t[1]=m,t[2]=r,t[3]=n,t[4]=h):h=t[4];let g;t[5]!==c||t[6]!==m||t[7]!==n?(g=[m,n,c],t[5]=c,t[6]=m,t[7]=n,t[8]=g):g=t[8],(0,Z.useEffect)(h,g);let _;t[9]===n.configuration.name?_=t[10]:(_=()=>{let e=n.configuration.name;return tn(e??null),jv},t[9]=n.configuration.name,t[10]=_);let v;t[11]===n?v=t[12]:(v=[n],t[11]=n,t[12]=v),(0,Z.useEffect)(_,v);let y;t[13]!==l||t[14]!==n.configuration.name?(y=()=>{},t[13]=l,t[14]=n.configuration.name,t[15]=y):y=t[15];let b;t[16]!==l||t[17]!==n?(b=[l,n],t[16]=l,t[17]=n,t[18]=b):b=t[18],(0,Z.useEffect)(y,b);let x,S;t[19]===l?(x=t[20],S=t[21]):(x=()=>{if(!l)return;let e=Mv,t=null,n=()=>{t||!l||l.isDestroyed||(t=l.view.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return l.editorView?n():l.on(`create`,n),()=>{l.off(`create`,n),r()}},S=[l],t[19]=l,t[20]=x,t[21]=S),(0,Z.useEffect)(x,S);let C,w;t[22]!==l||t[23]!==n.document?(w=()=>{if(!l)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,s=null,c=null,u=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},d=e=>{o.current=e;let t=a.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},f=()=>{let e=u(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(o.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};d(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),s&&clearTimeout(s),c&&clearTimeout(c),s=window.setTimeout(()=>{let e={...n,state:`settled`};d(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{d({...e,state:`idle`})},300)},H)};d(Ov);let p=()=>{if(B(e),!W(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),f()},e)}return}r=n,f()};e.observe(p);let m=()=>{document.visibilityState===`visible`?W(e,t)&&(t=Date.now(),r=Date.now(),f()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(p),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),s&&clearTimeout(s),c&&clearTimeout(c)}},C=[l,n.document],t[22]=l,t[23]=n.document,t[24]=C,t[25]=w):(C=t[24],w=t[25]),(0,Z.useEffect)(w,C);let T,E;t[26]===n?(T=t[27],E=t[28]):(T=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},E=[n],t[26]=n,t[27]=T,t[28]=E),(0,Z.useEffect)(T,E);let D,O;t[29]===l?(D=t[30],O=t[31]):(D=()=>{if(!l)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!l||l.isDestroyed)return;let n=l.editorView;if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(cn,e),()=>window.removeEventListener(cn,e)},O=[l],t[29]=l,t[30]=D,t[31]=O),(0,Z.useEffect)(D,O);let k,A;t[32]===n.document?(k=t[33],A=t[34]):(k=()=>{let e=n.document.getMap(`metadata`),t=e.get(`frontmatter`);typeof t==`string`&&t&&(i.current=t);let r=()=>{let t=e.get(`frontmatter`);typeof t==`string`&&(i.current=t)};return e.observe(r),()=>e.unobserve(r)},A=[n.document],t[32]=n.document,t[33]=k,t[34]=A),(0,Z.useEffect)(k,A);let j;t[35]!==s||t[36]!==n.awareness?(j=()=>{let e=n.awareness;e&&(e.setLocalStateField(`user`,{name:s.name,color:s.color,type:`human`,coeditor:s.coeditor,tabId:s.tabId}),e.setLocalStateField(`mode`,`wysiwyg`))},t[35]=s,t[36]=n.awareness,t[37]=j):j=t[37];let M;t[38]!==s||t[39]!==n?(M=[n,s],t[38]=s,t[39]=n,t[40]=M):M=t[40],(0,Z.useEffect)(j,M);let N;t[41]===l?N=t[42]:(N=l&&(0,$.jsx)(gv,{editor:l}),t[41]=l,t[42]=N);let P;t[43]===l?P=t[44]:(P=l&&(0,$.jsx)(Tv,{editor:l}),t[43]=l,t[44]=P);let F,I;t[45]===l?(F=t[46],I=t[47]):(F=(0,$.jsx)(kt,{editor:l,className:`h-full`}),I=l&&(0,$.jsx)(Wn,{store:Kt(l).store}),t[45]=l,t[46]=F,t[47]=I);let L;return t[48]!==N||t[49]!==P||t[50]!==F||t[51]!==I?(L=(0,$.jsxs)(`div`,{ref:a,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[N,P,F,I]}),t[48]=N,t[49]=P,t[50]=F,t[51]=I,t[52]=L):L=t[52],L};function Av(){let e=new ve({extensions:f});return{mdManager:e,text:Mn({mdManager:e}),html:En({mdManager:e}),paste:gn({mdManager:e})}}function jv(){return tn(null)}function Mv(){return xt()}function Nv(e){let t=(0,Q.c)(2),{docName:n,provider:r,children:i}=e;(0,Z.use)(Ht(n,r));let a;return t[0]===i?a=t[1]:(a=(0,$.jsx)($.Fragment,{children:i}),t[0]=i,t[1]=a),a}var Pv=(0,Z.createContext)(null),Fv={didCatch:!1,error:null},Iv=class extends Z.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Fv}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(Fv))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&Lv(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(Fv))}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)(Pv.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function Lv(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var Rv=`__back-nav__`;function zv(e){return e instanceof Ot||e instanceof Yt||e instanceof Vn||e instanceof Tt?e.docName:null}function Bv(e){return e instanceof Ot?{title:`Couldn't load document`,summary:`"${e.docName}" took too long to load. Check your connection and try again.`}:e instanceof Yt?{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 Vv(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=Bv(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)(q,{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)(q,{variant:`ghost`,onClick:()=>{!a||!o||(Et(zv(n)??i),o(a),r(Rv))},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 Hv(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)(Vv,{...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]===Rv){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}: ${Bv(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)(Iv,{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 Uv(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 Wv(){return Sn(()=>import(`./SourceEditor-BKyWQ7mW.js`),__vite__mapDeps([4,1,2,5,6,7,8]))}var Gv=(0,Z.lazy)(async()=>({default:(await Wv()).SourceEditor}));function Kv(e,t,n){if(n<=0)return[];let r=e.filter(e=>!yn(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function qv(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(St,{name:`activity-pool`,children:(0,$.jsx)(Jv,{...e})}),t[0]=e,t[1]=n),n}function Jv(e){let t=(0,Q.c)(11),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c}=Hn(),{pages:l,loading:u}=Se(),d=Kv(c,n,3),f=(0,Z.useRef)(``),p=d.map(Yv).join(`,`);(0,Z.useLayoutEffect)(()=>{if(f.current===p)return;let e=f.current?f.current.split(`,`):[],t=p?p.split(`,`):[];bn(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),f.current=p,On(t)},[p,n]);let m;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==u||t[4]!==o||t[5]!==s||t[6]!==l||t[7]!==a?(m=e=>(0,$.jsx)(Qv,{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 Yv(e){return e.docName}function Xv(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 Zv(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)(Tg,{}),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)(Gv,{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 Qv(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 _=Uv({ytextLength:u,isSourceMode:i,visitedSource:d,visitedVisual:p}),v=(0,Z.useRef)(``),y=`${_.isLarge}-${_.renderSource}-${_.renderVisual}`,b,x;t[5]!==n.docName||t[6]!==_.isLarge||t[7]!==_.renderSource||t[8]!==_.renderVisual||t[9]!==y||t[10]!==i||t[11]!==u?(b=()=>{v.current!==y&&(v.current=y,_.isLarge&&bn(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:u,isSourceMode:i,renderSource:_.renderSource,renderVisual:_.renderVisual}))},x=[y,_.isLarge,_.renderSource,_.renderVisual,n.docName,u,i],t[5]=n.docName,t[6]=_.isLarge,t[7]=_.renderSource,t[8]=_.renderVisual,t[9]=y,t[10]=i,t[11]=u,t[12]=b,t[13]=x):(b=t[12],x=t[13]),(0,Z.useEffect)(b,x);let S=r?`visible`:`hidden`,C=`editor:${n.docName}`,w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Tg,{}),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)(Zv,{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)(kv,{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)(Nv,{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)(Hv,{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)(Xv,{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 $v(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(St,{name:`editor-area`,children:(0,$.jsx)(ey,{...e})}),t[0]=e,t[1]=n),n}function ey(e){let t=(0,Q.c)(93),{editorMode:n,previewEntry:r,diffLayout:i,onNoDiff:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l}=Hn(),{openDocumentTransition:u}=Jt(),d=(0,Z.useDeferredValue)(o),f=c?.kind===`missing`?`Start writing to create this page…`:void 0,p=fg(),[m,h]=(0,Z.useState)(!1),{layout:g,autoCollapse:_}=w_(),v=g===`sheet`,[y,b]=(0,Z.useState)(!1),x=(0,Z.useRef)(!1),S,C;t[0]!==_||t[1]!==g||t[2]!==p?(S=()=>{g===`panel`&&(_?(x.current=!1,p.current?.collapse()):x.current||p.current?.expand())},C=[_,g,p],t[0]=_,t[1]=g,t[2]=p,t[3]=S,t[4]=C):(S=t[3],C=t[4]),(0,Z.useEffect)(S,C);let w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),D,O;t[5]===o?(D=t[6],O=t[7]):(D=()=>{if(o&&o!==w.current){let e=w.current;w.current=o,E(e)}},O=[o],t[5]=o,t[6]=D,t[7]=O),(0,Z.useEffect)(D,O);let[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),N;t[8]!==o||t[9]!==s||t[10]!==a||t[11]!==r?(N=()=>{if(!r?.sha||!o){A(null);return}let e=!1,t=r.sha,n=o;return M(!0),A(null),(async function(){try{let r=await fetch(`/api/history/${t}?docName=${encodeURIComponent(n)}`);if(e)return;if(!r.ok){A(null),M(!1);return}let i=await r.json();if(!e){let e=L(i.content??``).body,t=L(s?.document.getText(`source`).toString()??``).body,n=ny;if(n(e)===n(t)){M(!1),a?.();return}A({old:e,new:t}),M(!1)}}catch{e||(A(null),M(!1))}})(),()=>{e=!0}},t[8]=o,t[9]=s,t[10]=a,t[11]=r,t[12]=N):N=t[12];let P=r?.sha,F;if(t[13]!==o||t[14]!==s||t[15]!==a||t[16]!==P?(F=[P,o,s,a],t[13]=o,t[14]=s,t[15]=a,t[16]=P,t[17]=F):F=t[17],(0,Z.useEffect)(N,F),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,$.jsx)(Xg,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(!s||!o){if((typeof window<`u`?Te(window.location.hash):null)!==null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Tg,{}),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)(g_,{size:80}),(0,$.jsx)(`span`,{className:`select-none text-sm text-muted-foreground`,children:`Select a document to edit`})]}),t[21]=e):e=t[21],e}let I=n===`diff`,R=n===`source`,z=v?!y:m,B;t[22]!==m||t[23]!==v||t[24]!==p?(B=()=>{v?b(ty):m?(x.current=!1,p.current?.expand()):(x.current=!0,p.current?.collapse())},t[22]=m,t[23]=v,t[24]=p,t[25]=B):B=t[25];let V=z?`Show document panel`:`Hide document panel`,H;t[26]===z?H=t[27]:(H=z?(0,$.jsx)(vi,{className:`size-4`}):(0,$.jsx)(_i,{className:`size-4`}),t[26]=z,t[27]=H);let U;t[28]!==H||t[29]!==B||t[30]!==V?(U=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,onClick:B,"aria-label":V,className:`text-muted-foreground`,children:H})}),t[28]=H,t[29]=B,t[30]=V,t[31]=U):U=t[31];let W=z?`Show panel`:`Hide panel`,G;t[32]===W?G=t[33]:(G=(0,$.jsx)($e,{side:`left`,children:W}),t[32]=W,t[33]=G);let K;t[34]!==U||t[35]!==G?(K=(0,$.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,$.jsxs)(ot,{children:[U,G]})}),t[34]=U,t[35]=G,t[36]=K):K=t[36];let ee=K,te;t[37]!==I||t[38]!==j?(te=I&&j&&(0,$.jsx)(`div`,{className:`flex items-center justify-center py-16`,role:`status`,"aria-label":`Loading version`,children:(0,$.jsx)(`div`,{className:`size-5 animate-spin rounded-full border-2 border-muted border-t-foreground`})}),t[37]=I,t[38]=j,t[39]=te):te=t[39];let ne;t[40]!==k||t[41]!==i||t[42]!==I||t[43]!==j?(ne=I&&!j&&k!==null&&(0,$.jsx)(om,{oldContent:k.old,newContent:k.new,layout:i}),t[40]=k,t[41]=i,t[42]=I,t[43]=j,t[44]=ne):ne=t[44];let re=I?`none`:void 0,ie;t[45]===re?ie=t[46]:(ie={display:re},t[45]=re,t[46]=ie);let ae=d??o,oe=T??void 0,se;t[47]===u?se=t[48]:(se=e=>{let t=me(e);window.location.hash===t?u(e):window.location.hash=t},t[47]=u,t[48]=se);let ce;t[49]!==f||t[50]!==R||t[51]!==l||t[52]!==ae||t[53]!==oe||t[54]!==se?(ce=(0,$.jsx)(qv,{activeDocName:ae,isSourceMode:R,editorPlaceholder:f,previousDocName:oe,onNavigateBack:se,onRecycle:l}),t[49]=f,t[50]=R,t[51]=l,t[52]=ae,t[53]=oe,t[54]=se,t[55]=ce):ce=t[55];let le;t[56]!==o||t[57]!==d?(le=o&&o!==d?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Tg,{})}):null,t[56]=o,t[57]=d,t[58]=le):le=t[58];let ue;t[59]!==ie||t[60]!==ce||t[61]!==le?(ue=(0,$.jsxs)(`div`,{className:`relative h-full`,style:ie,children:[ce,le]}),t[59]=ie,t[60]=ce,t[61]=le,t[62]=ue):ue=t[62];let de;t[63]!==te||t[64]!==ne||t[65]!==ue||t[66]!==ee?(de=(0,$.jsxs)(`div`,{className:`relative h-full`,children:[te,ne,ue,ee]}),t[63]=te,t[64]=ne,t[65]=ue,t[66]=ee,t[67]=de):de=t[67];let fe=de;if(v){let e;t[68]===fe?e=t[69]:(e=(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:fe}),t[68]=fe,t[69]=e);let n;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(dm,{className:`sr-only`,children:(0,$.jsx)(fm,{children:`Document panel`})}),t[70]=n):n=t[70];let r;t[71]!==o||t[72]!==R?(r=(0,$.jsxs)(um,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,$.jsx)(Cg,{docName:o,isSourceMode:R})]}),t[71]=o,t[72]=R,t[73]=r):r=t[73];let i;t[74]!==y||t[75]!==r?(i=(0,$.jsx)(sm,{open:y,onOpenChange:b,children:r}),t[74]=y,t[75]=r,t[76]=i):i=t[76];let a;return t[77]!==e||t[78]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,i]}),t[77]=e,t[78]=i,t[79]=a):a=t[79],a}let pe;t[80]===fe?pe=t[81]:(pe=(0,$.jsx)(b_,{minSize:`30%`,defaultSize:`75%`,children:fe}),t[80]=fe,t[81]=pe);let he;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(x_,{withHandle:!0}),t[82]=he):he=t[82];let ge;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>h(e.asPercentage===0),t[83]=ge):ge=t[83];let _e;t[84]!==o||t[85]!==R?(_e=(0,$.jsx)(Cg,{docName:o,isSourceMode:R}),t[84]=o,t[85]=R,t[86]=_e):_e=t[86];let ve;t[87]!==p||t[88]!==_e?(ve=(0,$.jsx)(b_,{panelRef:p,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:ge,className:`flex flex-col bg-muted/20`,children:_e}),t[87]=p,t[88]=_e,t[89]=ve):ve=t[89];let ye;return t[90]!==pe||t[91]!==ve?(ye=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,$.jsxs)(y_,{orientation:`horizontal`,children:[pe,he,ve]})}),t[90]=pe,t[91]=ve,t[92]=ye):ye=t[92],ye}function ty(e){return!e}function ny(e){return e.replace(/\r\n/g,`
17
- `).replace(/[ \t]+$/gm,``).trimEnd()}function ry(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function iy(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function ay(e,t){let n=ry(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function oy(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 sy(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function cy(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var ly=1280;function uy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(dy),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ly-1}px)`),t=()=>{n(window.innerWidth<ly)};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 dy(){return window.innerWidth<ly}var fy=`sidebar_state`,py=3600*24*7,my=`18rem`,hy=`18rem`,gy=`3rem`,_y=`\\`,vy=Z.createContext(null);function yy(){let e=Z.use(vy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function by(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=uy(),[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=`${fy}=${t}; path=/; max-age=${py}`},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(Sy):_(xy)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,b,x;t[14]===y?(b=t[15],x=t[16]):(b=()=>{let e=e=>{e.key===_y&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},x=[y],t[14]=y,t[15]=b,t[16]=x),Z.useEffect(b,x);let S=h?`expanded`:`collapsed`,C;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==S||t[22]!==y?(C={state:S,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=S,t[22]=y,t[23]=C):C=t[23];let w;t[24]===s?w=t[25]:(w={"--sidebar-width":my,"--sidebar-width-icon":gy,...s},t[24]=s,t[25]=w);let T=w,E;t[26]===r?E=t[27]:(E=k(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=E);let D;t[28]!==n||t[29]!==a||t[30]!==T||t[31]!==E?(D=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:T,className:E,...a,children:n}),t[28]=n,t[29]=a,t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==D||t[34]!==C?(O=(0,$.jsx)(vy.Provider,{value:C,children:D}),t[33]=D,t[34]=C,t[35]=O):O=t[35],O}function xy(e){return!e}function Sy(e){return!e}function Cy(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}=yy();if(d===`none`){let e;t[8]===r?e=t[9]:(e=k(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e||t[13]!==u?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=u,t[14]=i):i=t[14],i}if(f){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":hy},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(dm,{className:`sr-only`,children:[(0,$.jsx)(fm,{children:`Sidebar`}),(0,$.jsx)(pm,{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)(um,{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)(sm,{open:m,onOpenChange:h,...a,children:s}),t[23]=m,t[24]=a,t[25]=h,t[26]=s,t[27]=c):c=t[27],c}let g=p===`collapsed`?d:``,_=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,v;t[28]===_?v=t[29]:(v=k(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,_),t[28]=_,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:v}),t[30]=v,t[31]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[32]!==r||t[33]!==b?(x=k(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,b,r),t[32]=r,t[33]=b,t[34]=x):x=t[34];let S;t[35]===n?S=t[36]:(S=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=S);let C;t[37]!==a||t[38]!==l||t[39]!==S||t[40]!==x?(C=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[37]=a,t[38]=l,t[39]=S,t[40]=x,t[41]=C):C=t[41];let w;return t[42]!==l||t[43]!==p||t[44]!==C||t[45]!==g||t[46]!==y||t[47]!==u?(w=(0,$.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":g,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[y,C]}),t[42]=l,t[43]=p,t[44]=C,t[45]=g,t[46]=y,t[47]=u,t[48]=w):w=t[48],w}function wy(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}=yy(),o;t[4]===n?o=t[5]:(o=k(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(gi,{}),l=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,$.jsxs)(q,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:o,onClick:s,...i,children:[c,l]}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function Ty(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ey(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Dy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function 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=k(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function 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=k(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ay(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var jy=Ae(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function My(e){let t=(0,Q.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?se:`button`,{isMobile:m,state:h}=yy(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=k(jy({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,$.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,$.jsx)(pt,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,$.jsx)($e,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,$.jsxs)(ot,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Ny(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?se:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=k(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,$.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Py(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`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 Fy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`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 Iy(e){let t=(0,Q.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?se:`a`,d;t[6]===n?d=t[7]:(d=k(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,$.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Ly(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 Ry(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 zy(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 By(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 Vy(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 Hy(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 Uy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Jc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Wy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Yc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Gy(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=k(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,$.jsx)(Xc,{children:(0,$.jsx)(Zc,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Ky(e){return typeof e==`object`&&!!e&&typeof e.getStates==`function`}function qy(e,t,n){let r=[],i=[];for(let a of e.getStates().values()){let e=a.agentPresence;if(e)for(let[a,o]of Object.entries(e))o.currentDoc&&(n-o.ts>=5e3||(o.currentDoc===t?r.push({agentId:a,entry:o}):i.push({agentId:a,entry:o})))}return{current:r,crossDoc:i}}function Jy(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentPresence;if(e)for(let r of Object.values(e))r.currentDoc&&(t-r.ts>=5e3||n.push(r))}return n.length===0?null:(n.sort((e,t)=>t.ts-e.ts),n[0].currentDoc)}var Yy=1e3,Xy=!1;function Zy(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function Qy(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:Ky(i)?a=i:(a=void 0,Xy||(Xy=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`})}let{current:t,crossDoc:i}=a?qy(a,n,Date.now()):{current:[],crossDoc:[]},s=$y,c=t.map(s),l=i.map(s),u=[...e,...c],d=l;o(e=>Zy(e.current,u)&&Zy(e.crossDoc,d)?e:{current:u,crossDoc:d})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,Yy);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function $y(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function eb(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`?tb: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 tb(e){return e===`synced`?`synced`:`connected`}var nb=`sync-status`;function rb(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:nb,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:nb,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}function ib(e){window.location.hash=me(e)}var ab=4,ob=3,sb={Bird:Ar,Cat:Pr,Dog:Yr,Fish:Qr,Mouse:wi,Rabbit:Ci,Shrimp:Ai,Snail:ji,Squirrel:Fi,Turtle:Bi},cb={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function lb(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)(Ly,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Vy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Hy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(zy,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(Ry,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(By,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(Mi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function ub(e){let t=(0,Q.c)(20),{user:n,mode:r}=e,i=n.name.split(` `)[1],a=i?sb[i]:void 0,o;t[0]===n.name?o=t[1]:(o=n.name.split(` `).map(db).join(``),t[0]=n.name,t[1]=o);let s=o,c;t[2]===n.color?c=t[3]:(c=A(n.color),t[2]=n.color,t[3]=c);let l=c,u;t[4]===n.color?u=t[5]:(u={backgroundColor:n.color},t[4]=n.color,t[5]=u);let d;t[6]!==a||t[7]!==l||t[8]!==s?(d=a?(0,$.jsx)(a,{size:18,color:l,strokeWidth:1.5}):(0,$.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:l},children:s}),t[6]=a,t[7]=l,t[8]=s,t[9]=d):d=t[9];let f;t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==n.name?(f=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":n.name,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:u,children:d})}),t[10]=r,t[11]=u,t[12]=d,t[13]=n.name,t[14]=f):f=t[14];let p;t[15]===n.name?p=t[16]:(p=(0,$.jsx)($e,{children:n.name}),t[15]=n.name,t[16]=p);let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(ot,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function db(e){return e[0]}function fb(e){let t=cb[e.icon];return e.displayName||t||`Agent`}function pb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function mb(e){let t=(0,Q.c)(30),{participant:n,crossDoc:r,onNavigate:i}=e,{presence:a}=n,o;t[0]===a?o=t[1]:(o=fb(a),t[0]=a,t[1]=o);let s=o,c=r&&a.currentDoc!==null,l=pb(a.mode),u=!c&&!r&&l,d=c?`cursor-pointer`:`cursor-default`,f=u?`ring-primary/40 animate-pulse`:``,p;t[2]!==d||t[3]!==f?(p=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 ring-background`,d,f].filter(Boolean),t[2]=d,t[3]=f,t[4]=p):p=t[4];let m=p.join(` `),h=r?`true`:void 0,g;t[5]!==a.mode||t[6]!==h?(g={"data-presence-badge":`agent`,"data-presence-mode":a.mode,"data-presence-crossdoc":h},t[5]=a.mode,t[6]=h,t[7]=g):g=t[7];let _=g,v;t[8]!==_||t[9]!==c||t[10]!==i||t[11]!==a.color||t[12]!==a.currentDoc||t[13]!==a.icon||t[14]!==m||t[15]!==s?(v=c?(0,$.jsx)(`button`,{type:`button`,..._,"aria-label":`${s}, editing ${a.currentDoc}`,className:m,style:{backgroundColor:a.color},onClick:()=>{a.currentDoc&&i(a.currentDoc)},children:(0,$.jsx)(lb,{icon:a.icon,width:16,height:16,className:`text-white`})}):(0,$.jsx)(`div`,{..._,role:`img`,"aria-label":s,className:m,style:{backgroundColor:a.color},children:(0,$.jsx)(lb,{icon:a.icon,width:16,height:16,className:`text-white`})}),t[8]=_,t[9]=c,t[10]=i,t[11]=a.color,t[12]=a.currentDoc,t[13]=a.icon,t[14]=m,t[15]=s,t[16]=v):v=t[16];let y=v,b;t[17]===y?b=t[18]:(b=(0,$.jsx)(pt,{asChild:!0,children:y}),t[17]=y,t[18]=b);let x;t[19]===s?x=t[20]:(x=(0,$.jsx)(`span`,{className:`font-medium`,children:s}),t[19]=s,t[20]=x);let S;t[21]!==r||t[22]!==a.currentDoc?(S=r&&a.currentDoc?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,a.currentDoc,`]]`]}):null,t[21]=r,t[22]=a.currentDoc,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==x?(C=(0,$.jsxs)($e,{className:`flex flex-col gap-0.5`,children:[x,S]}),t[24]=S,t[25]=x,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==b?(w=(0,$.jsxs)(ot,{children:[b,C]}),t[27]=C,t[28]=b,t[29]=w):w=t[29],w}function hb(e){let t=(0,Q.c)(16),{count:n,remainder:r,crossDoc:i,onNavigate:a}=e,o=i?`true`:void 0,s=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,c;t[0]!==n||t[1]!==o||t[2]!==s?(c=(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":o,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":s,children:[`+`,n]})}),t[0]=n,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l;if(t[4]!==i||t[5]!==a||t[6]!==r){let e;t[8]!==i||t[9]!==a?(e=e=>e.kind===`human`?(0,$.jsx)(ub,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(mb,{participant:e,crossDoc:i,onNavigate:a},e.agentId),t[8]=i,t[9]=a,t[10]=e):e=t[10],l=r.map(e),t[4]=i,t[5]=a,t[6]=r,t[7]=l}else l=t[7];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(Gy,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:l})}),t[11]=l,t[12]=u);let d;return t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(Uy,{children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],d}function gb(e,t,n){return e.kind===`human`?(0,$.jsx)(ub,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(mb,{participant:e,crossDoc:n,onNavigate:t},e.agentId)}function _b(){let e=(0,Q.c)(12),{activeProvider:t,activeDocName:n,systemProvider:r}=Hn(),{current:i,crossDoc:a}=Qy(t,r,n);rb(eb(t),n);let o;if(e[0]!==a||e[1]!==i){let t=i.slice(0,ab),n;e[3]===i?n=e[4]:(n=i.slice(ab),e[3]=i,e[4]=n);let r=n,s=a.slice(0,ob),c;e[5]===a?c=e[6]:(c=a.slice(ob),e[5]=a,e[6]=c);let l=c,u=t.map(yb),d;e[7]===r?d=e[8]:(d=r.length>0?(0,$.jsx)(hb,{count:r.length,remainder:r,crossDoc:!1,onNavigate:ib}):null,e[7]=r,e[8]=d);let f;e[9]!==u||e[10]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[u,d]}),e[9]=u,e[10]=d,e[11]=f):f=e[11],o=(0,$.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[f,a.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[s.map(vb),l.length>0?(0,$.jsx)(hb,{count:l.length,remainder:l,crossDoc:!0,onNavigate:ib}):null]})]}):null]}),e[0]=a,e[1]=i,e[2]=o}else o=e[2];return o}function vb(e){return gb(e,ib,!0)}function yb(e){return gb(e,ib,!1)}function bb(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 xb(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 Sb=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Mr},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:vt},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:xb},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:bb}],Cb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Rr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)($e,{children:`Help & resources`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:`Need help?`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(Uy,{children:[t,(0,$.jsxs)(Gy,{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:Sb.map(wb)})})]})]}),e[2]=r):r=e[2],r};function wb(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 Tb=`https://github.com/inkeep/open-knowledge/releases`;function Eb(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 Db(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:Tb}}};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 Ob(e){return od(e)}function kb(e){return`Opened ${e} in your browser.`}function Ab(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??pd,c=e.onWebFallbackSuccess??Mb,l=e.onWebFallbackError??jb,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Db({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=Eb({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(Ob(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)(Lg,{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)(Lg,{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)(Pg,{"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)(zg,{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)(Bg,{}),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)(Lg,{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)(Lg,{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)(Fg,{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)(Mg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function jb(){}function Mb(){}function Nb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Wd(),{dispatch:a}=Nd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=Fb,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?``:ad(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Xr,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in…`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})}),t[8]=p,t[9]=y);let b;t[10]!==_||t[11]!==h||t[12]!==r?(b=sd.map(e=>{let t=r[e.id];return(0,$.jsx)(Ab,{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)(Ig,{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)(Ag,{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){X.error(`Couldn't open ${e.displayName} in your browser.`)}function Fb(e){X.success(kb(e.displayName))}var Ib={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`},Lb=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`,...Ib,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},Rb=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)(Lb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},zb=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)(Lb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Bb=(e,t,n)=>qi(e,t,n,`ProjectSwitcher`);function Vb(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 Bb(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),Bb(()=>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),Bb(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=Ag,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),t[30]=a):a=t[30];let c;t[31]===n.config.projectName?c=t[32]:(c=(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:n.config.projectName}),t[31]=n.config.projectName,t[32]=c);let l;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1.5 px-2 text-muted-foreground hover:text-foreground`,"data-testid":`project-switcher-trigger`,title:`Switch project`,children:[a,c,l]})}),t[34]=c,t[35]=x),h=Ig,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(zg,{children:`Switch project`}),_=(0,$.jsx)(Bg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(zg,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(Lg,{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)(Bg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ei,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(Lg,{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 Hb(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=k(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(gl,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,$.jsx)(hl,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function Ub(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 Wb(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function Gb(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 Kb(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zi,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fi,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function qb(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 Jb(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 Yb(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 Xb(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`}`:Jb(e.state):`Sync off`}function Zb(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 Gb(e)}catch(t){console.error(`[sync] toggle failed`,t),X.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,$.jsx)(Kb,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=Jb(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)(Hb,{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:Yb(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: `,Ub(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,$.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,$.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,$.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,$.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,$.jsx)(Ui,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:$b,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:Qb,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function Qb(){Wb(`sync`)}function $b(){Wb(`sync`)}function ex(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}=tf();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(zr,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,$.jsxs)(ot,{children:[e,(0,$.jsx)($e,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=qb(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Jb(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)(Kb,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=Xb(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)($e,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(ot,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,$.jsx)(Gy,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(Zb,{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)(Uy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var tx=[{value:`light`,label:`Light`,icon:Li},{value:`dark`,label:`Dark`,icon:pi},{value:`system`,label:`System`,icon:Wr}],nx=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=Ve(),r=t===`system`?Wr:t===`dark`?pi:Li,i;e[0]===r?i=e[1]:(i=(0,$.jsx)(r,{}),e[0]=r,e[1]=i);let a=t??`system`,o;e[2]===a?o=e[3]:(o=(0,$.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,a,`)`]}),e[2]=a,e[3]=o);let s;e[4]!==i||e[5]!==o?(s=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[i,o]})}),e[4]=i,e[5]=o,e[6]=s):s=e[6];let c;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=tx.map(rx),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Ig,{align:`end`,children:(0,$.jsx)(Ng,{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)(Ag,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function rx(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Rg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function ix(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function ax(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(ix)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function ox(e){let t=(0,Q.c)(117),{editorMode:n,onModeChange:r,onTimelineToggle:i,onSaveVersion:a,saving:o,previewEntry:s,restoring:c,restoreError:l,onExitPreview:u,onRestore:d,diffLayout:f,onDiffLayoutChange:p,onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g,onOpenClone:_}=e,{activeDocName:v,activeProvider:y,activeTarget:b,closeDocument:x,pinnedDoc:S,pin:C,unpin:w}=Hn(),{state:T}=yy(),E=cd(),D=eb(y),O;t[0]!==v||t[1]!==E?(O=wd({docName:v,workspace:E}),t[0]=v,t[1]=E,t[2]=O):O=t[2];let k=O,A=!v||!(D===`connected`||D===`synced`),j=b?.kind===`folder`,M=b?.kind===`missing`,N=j?`${b.folderPath}/`:v?`${v}.md`:``,P;t[3]===v?P=t[4]:(P=v?.lastIndexOf(`/`)??-1,t[3]=v,t[4]=P);let F=P,I;t[5]!==v||t[6]!==F?(I=v&&F!==-1?`${v.substring(0,F+1)}`:``,t[5]=v,t[6]=F,t[7]=I):I=t[7];let L=I,R;t[8]!==v||t[9]!==F?(R=v?v.substring(F+1):``,t[8]=v,t[9]=F,t[10]=R):R=t[10];let z=R,B=S!==null,V;t[11]!==v||t[12]!==B||t[13]!==C||t[14]!==w?(V=function(){v&&(B?w():C(v))},t[11]=v,t[12]=B,t[13]=C,t[14]=w,t[15]=V):V=t[15];let H=V,U=n===`diff`,[W,G]=(0,Z.useState)(!1),[K,ee]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{le.current=!0,ue.current=null,de.current=null,ee(!1),ie(null)},t[16]=fe):fe=t[16];let pe;t[17]===v?pe=t[18]:(pe=[v],t[17]=v,t[18]=pe),(0,Z.useEffect)(fe,pe);let he,ge;t[19]===K?(he=t[20],ge=t[21]):(he=()=>{if(K){let e=setTimeout(()=>{let e=se.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},ge=[K],t[19]=K,t[20]=he,t[21]=ge),(0,Z.useEffect)(he,ge);let _e;t[22]!==v||t[23]!==j?(_e=function(){if(!v||j)return;let e=v.split(`/`);le.current=!1,ue.current=v,ne(e[e.length-1]),ie(null),de.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=_e):_e=t[24];let ve=_e,ye;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ye=function(){le.current=!0,ue.current=null,de.current=null,ee(!1),ne(``),ie(null)},t[25]=ye):ye=t[25];let be=ye,xe;t[26]!==x||t[27]!==te?(xe=async function(){if(le.current){le.current=!1;return}if(ce.current)return;let e=ue.current;if(!e){be();return}let t=ry(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){be();return}if(t===de.current)return;if(!iy(t)){ie(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=ay({kind:`file`,path:e,name:r},t);ce.current=!0,oe(!0),ie(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(le.current){oe(!1),ce.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),ie(`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!n.ok||!ax(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),ie(a?.error||`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!r.ok){ie(r.error||`Failed to rename path`),oe(!1),ce.current=!1,de.current=t;return}let a=r.renamed,o=cy(e,a);for(let e of a)x(e.fromDocName);ze([`files`,`backlinks`,`graph`]),ee(!1),ne(``),oe(!1),ce.current=!1,de.current=null,ue.current=null,o&&o!==e&&(window.location.hash=me(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),ie(`Network error — please try again`),oe(!1),ce.current=!1,de.current=t}},t[26]=x,t[27]=te,t[28]=xe):xe=t[28];let Se=xe,Ce;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{G(!1)},t[29]=Ce):Ce=t[29];let we;t[30]===s?we=t[31]:(we=[s],t[30]=s,t[31]=we),(0,Z.useEffect)(Ce,we);let Te;t[32]===d?Te=t[33]:(Te=function(){G(!1),d()},t[32]=d,t[33]=Te);let J=Te,Ee;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(wy,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Ee):Ee=t[34];let De=T===`expanded`?`Hide Files`:`Show Files`,Oe;t[35]===De?Oe=t[36]:(Oe=(0,$.jsxs)(ot,{children:[Ee,(0,$.jsx)($e,{children:De})]}),t[35]=De,t[36]=Oe);let ke,Ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ke=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(Vb,{bridge:window.okDesktop})]}):null,Ae=(0,$.jsx)(sv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=ke,t[38]=Ae):(ke=t[37],Ae=t[38]);let je;t[39]!==v||t[40]!==Se||t[41]!==N||t[42]!==ve||t[43]!==z||t[44]!==j||t[45]!==ae||t[46]!==K||t[47]!==L||t[48]!==re||t[49]!==te?(je=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:N})]}):v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[L&&(0,$.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:K?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,$.jsx)(`span`,{className:`truncate`,children:L.slice(0,-1)}),(0,$.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),K?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Mt,{ref:se,value:te,disabled:ae,"aria-label":`Rename ${v}`,"aria-invalid":re?!0:void 0,"aria-describedby":re?`editor-header-rename-error`:void 0,"aria-busy":ae||void 0,onChange:e=>{ne(e.target.value),ie(null),de.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Se()):e.key===`Escape`&&(e.preventDefault(),be())},onBlur:()=>void Se(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:`.md`})]}),re&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:re})]}):(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ve,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:[z,`.md`]})]}):(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:N}),t[39]=v,t[40]=Se,t[41]=N,t[42]=ve,t[43]=z,t[44]=j,t[45]=ae,t[46]=K,t[47]=L,t[48]=re,t[49]=te,t[50]=je):je=t[50];let Me;t[51]!==v||t[52]!==B||t[53]!==H?(Me=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:H,"aria-label":B?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":B,"data-pinned":B?`true`:`false`,children:B?(0,$.jsx)(xi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(bi,{className:`size-4`})})}),(0,$.jsx)($e,{children:B?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[51]=v,t[52]=B,t[53]=H,t[54]=Me):Me=t[54];let Y;t[55]===M?Y=t[56]:(Y=M&&(0,$.jsx)(vl,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=Y);let Ne;t[57]!==Oe||t[58]!==je||t[59]!==Me||t[60]!==Y?(Ne=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Oe,ke,Ae,je,Me,Y]}),t[57]=Oe,t[58]=je,t[59]=Me,t[60]=Y,t[61]=Ne):Ne=t[61];let Pe;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Pe=!U&&v&&(0,$.jsxs)(mt,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!v,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(zb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(lt,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(Rb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)($e,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)($e,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Pe):Pe=t[67];let Fe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Fe=U&&s&&!W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[l&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,$.jsxs)(mt,{type:`single`,value:f,onValueChange:e=>{e&&p(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Di,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Hr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ei,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(jt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Exit preview`})]})]}),t[68]=W,t[69]=f,t[70]=U,t[71]=p,t[72]=u,t[73]=s,t[74]=l,t[75]=Fe):Fe=t[75];let Ie;t[76]!==W||t[77]!==J||t[78]!==U||t[79]!==s||t[80]!==c?(Ie=U&&s&&W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Replace current content with this version?`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(q,{variant:`default`,size:`xs`,onClick:J,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=J,t[78]=U,t[79]=s,t[80]=c,t[81]=Ie):Ie=t[81];let Le;t[82]!==U||t[83]!==_?(Le=!U&&_&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(ni,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Le):Le=t[84];let Re;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Re=!U&&v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Oi,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Re):Re=t[89];let Be;t[90]!==v||t[91]!==i?(Be=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(ai,{className:`size-4`})})}),(0,$.jsx)($e,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Be):Be=t[92];let Ve;t[93]!==v||t[94]!==k||t[95]!==U?(Ve=!U&&v&&(0,$.jsx)(Nb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=Ve):Ve=t[96];let He;t[97]!==g||t[98]!==h||t[99]!==m?(He=(0,$.jsx)(ex,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=He):He=t[100];let Ue,We,Ge,Ke;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(_b,{}),We=(0,$.jsx)(sv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ge=(0,$.jsx)(Cb,{}),Ke=(0,$.jsx)(nx,{}),t[101]=Ue,t[102]=We,t[103]=Ge,t[104]=Ke):(Ue=t[101],We=t[102],Ge=t[103],Ke=t[104]);let qe;t[105]!==Le||t[106]!==Re||t[107]!==Be||t[108]!==Ve||t[109]!==He?(qe=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Le,Re,Be,Ve,He,Ue,We,Ge,Ke]}),t[105]=Le,t[106]=Re,t[107]=Be,t[108]=Ve,t[109]=He,t[110]=qe):qe=t[110];let Je;return t[111]!==Ne||t[112]!==Pe||t[113]!==Fe||t[114]!==Ie||t[115]!==qe?(Je=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Ne,Pe,Fe,Ie,qe]}),t[111]=Ne,t[112]=Pe,t[113]=Fe,t[114]=Ie,t[115]=qe,t[116]=Je):Je=t[116],Je}function sx(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 cx(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 lx(e){if(e.contributors.length>0){let t=e.contributors[0],n=t.colorSeed??t.name;return{hex:ie[Ue(n)]??Ge(n)}}return e.type===`upstream`?{className:`bg-muted-foreground/50`}:(e.authorEmail.includes(`openknowledge.local`)||e.type===`wip`)&&(e.authorEmail.includes(`agent`)||e.author.includes(`agent`)||e.authorEmail.includes(`cursor`)||e.authorEmail.includes(`claude`))?{className:`bg-[--color-agent]`}:{className:`bg-[--color-azure-blue]`}}function ux(e){let t=lx(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 dx(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(fx),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ir,{className:`size-3`}):(0,$.jsx)(Lr,{className:`size-3`}),t[1]=o,t[2]=l);let u=o?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,d;t[3]!==o||t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex items-center gap-1 px-4 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors text-left`,onClick:c,children:[l,u]}),t[3]=o,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==n||t[8]!==o||t[9]!==a||t[10]!==i?(f=o&&n.map(e=>(0,$.jsx)(gx,{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 fx(e){return!e}function px(e){return e.checkpoint?e.checkpoint.kind:`save`}function mx(e){let t=px(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${hx(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function hx(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function gx(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=sx(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=cx(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(_x);_=`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=px(n);return e===`bridge-merge-loss`?(0,$.jsx)(zi,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,$.jsx)(Zr,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(Jr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})})():(0,$.jsx)(`div`,{className:`mt-1.5 flex shrink-0 items-center`,children:ux(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:mx(n)}),ux(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 _x(e){return e.docs}function vx(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(bx),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)(fm,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),className:`text-xs text-muted-foreground`,children:`Now`}),t[12]=a,t[13]=o,t[14]=x):x=t[14];let S;t[15]===x?S=t[16]:(S=(0,$.jsx)(dm,{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(yx)}),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)(gx,{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)(gx,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(dx,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,selectedSha:o,onSelect:a},e.entries[0]?.sha??`wip-${t}`))}),t[33]=f,t[34]=_,t[35]=y,t[36]=u,t[37]=a,t[38]=o,t[39]=D):D=t[39];let O;t[40]!==T||t[41]!==E||t[42]!==D||t[43]!==C||t[44]!==w?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[C,w,T,E,D]}),t[40]=T,t[41]=E,t[42]=D,t[43]=C,t[44]=w,t[45]=O):O=t[45];let k;t[46]!==a||t[47]!==o?(k=o&&(0,$.jsxs)(`div`,{className:`border-t p-3 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground `,children:`Viewing historical version`}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ei,{className:`size-3`}),`Exit`]})]}),t[46]=a,t[47]=o,t[48]=k):k=t[48];let A;t[49]!==O||t[50]!==k||t[51]!==S?(A=(0,$.jsxs)(um,{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)(sm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function yx(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(df,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(df,{className:`h-3 w-24`}),(0,$.jsx)(df,{className:`h-3 w-40`})]}),(0,$.jsx)(df,{className:`h-3 w-14`})]},e)}function bx(e){return e.type===`checkpoint`}function xx(){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=ef(),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}=Hn(),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(),X.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&&Un(j,{kind:`raw-mdx`,detail:t}),n(`source`)};return window.addEventListener(Bt,e),()=>window.removeEventListener(Bt,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,X.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>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,ne;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(ne=async function(){w(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}w(!1)},e[21]=ne):ne=e[21];let re=ne,ie;e[22]!==j||e[23]!==h?(ie=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]=ie):ie=e[24];let ae=ie,oe;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(gf,{onOpenResolver:()=>o(!0)}),e[25]=oe):oe=e[25];let se;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>i(Sx),e[26]=se):se=e[26];let q,ce,le,ue;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>{u(`auth`),c(!0)},ce=()=>{u(`identity`),c(!0)},le=()=>o(!0),ue=()=>f(!0),e[27]=q,e[28]=ce,e[29]=le,e[30]=ue):(q=e[27],ce=e[28],le=e[29],ue=e[30]);let de;e[31]!==_||e[32]!==t||e[33]!==ae||e[34]!==h||e[35]!==x||e[36]!==y||e[37]!==C?(de=(0,$.jsx)(ox,{editorMode:t,onModeChange:te,onTimelineToggle:se,onSaveVersion:re,saving:C,previewEntry:h,restoring:y,restoreError:x,onExitPreview:I,onRestore:ae,diffLayout:_,onDiffLayoutChange:v,onSignIn:q,onSetIdentity:ce,onOpenConflictResolver:le,onOpenClone:ue}),e[31]=_,e[32]=t,e[33]=ae,e[34]=h,e[35]=x,e[36]=y,e[37]=C,e[38]=de):de=e[38];let fe;e[39]!==t||e[40]!==h?(fe=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: `,sx(h.timestamp),` — `,cx(h)]})}),e[39]=t,e[40]=h,e[41]=fe):fe=e[41];let pe;e[42]!==_||e[43]!==t||e[44]!==h?(pe=(0,$.jsx)($v,{editorMode:t,previewEntry:h,diffLayout:_,onNoDiff:R}),e[42]=_,e[43]=t,e[44]=h,e[45]=pe):pe=e[45];let me=j??``,he=h?.sha,ge;e[46]!==P||e[47]!==me||e[48]!==he||e[49]!==r?(ge=(0,$.jsx)(vx,{open:r,onOpenChange:i,docName:me,onEntrySelect:P,selectedSha:he}),e[46]=P,e[47]=me,e[48]=he,e[49]=r,e[50]=ge):ge=e[50];let _e;e[51]===a?_e=e[52]:(_e=(0,$.jsx)(ym,{open:a,onOpenChange:o}),e[51]=a,e[52]=_e);let ve;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>{c(e),e||m(!1)},e[53]=ve):ve=e[53];let ye=l===`identity`,be;e[54]===p?be=e[55]:(be=()=>{c(!1),p&&(m(!1),f(!0))},e[54]=p,e[55]=be);let xe;e[56]!==s||e[57]!==ye||e[58]!==be?(xe=(0,$.jsx)(lf,{open:s,onOpenChange:ve,identityPrompt:ye,onSuccess:be}),e[56]=s,e[57]=ye,e[58]=be,e[59]=xe):xe=e[59];let Se;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[60]=Se):Se=e[60];let Ce;e[61]===d?Ce=e[62]:(Ce=(0,$.jsx)(mf,{open:d,onOpenChange:f,onSignIn:Se}),e[61]=d,e[62]=Ce);let we;return e[63]!==de||e[64]!==fe||e[65]!==pe||e[66]!==ge||e[67]!==_e||e[68]!==xe||e[69]!==Ce?(we=(0,$.jsxs)($.Fragment,{children:[oe,de,fe,pe,ge,_e,xe,Ce]}),e[63]=de,e[64]=fe,e[65]=pe,e[66]=ge,e[67]=_e,e[68]=xe,e[69]=Ce,e[70]=we):we=e[70],we}function Sx(e){return!e}var Cx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function wx(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Tx(e){return`nodeType`in e}function Ex(e){return e?wx(e)?e:Tx(e)?e.ownerDocument?.defaultView??window:window:window}function Dx(e){let{Document:t}=Ex(e);return e instanceof t}function Ox(e){return wx(e)?!1:e instanceof Ex(e).HTMLElement}function kx(e){return e instanceof Ex(e).SVGElement}function Ax(e){return e?wx(e)?e.document:Tx(e)?Dx(e)?e:Ox(e)||kx(e)?e.ownerDocument:document:document:document}var jx=Cx?Z.useLayoutEffect:Z.useEffect;function Mx(e){let t=(0,Z.useRef)(e);return jx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Nx(){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 Px(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return jx(()=>{n.current!==e&&(n.current=e)},t),n}function Fx(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Ix(e){let t=Mx(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Lx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var Rx={};function zx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=Rx[e]==null?0:Rx[e]+1;return Rx[e]=n,e+`-`+n},[e,t])}function Bx(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 Vx=Bx(1),Hx=Bx(-1);function Ux(e){return`clientX`in e&&`clientY`in e}function Wx(e){if(!e)return!1;let{KeyboardEvent:t}=Ex(e.target);return t&&e instanceof t}function Gx(e){if(!e)return!1;let{TouchEvent:t}=Ex(e.target);return t&&e instanceof t}function Kx(e){if(Gx(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 Ux(e)?{x:e.clientX,y:e.clientY}:null}var qx=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[qx.Translate.toString(e),qx.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Jx=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Yx(e){return e.matches(Jx)?e:e.querySelector(Jx)}var Xx={display:`none`};function Zx(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:Xx},n)}function Qx(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 $x(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var eS=(0,Z.createContext)(null);function tS(e){let t=(0,Z.useContext)(eS);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function nS(){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 rS={draggable:`
17
+ `).replace(/[ \t]+$/gm,``).trimEnd()}function ry(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function iy(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function ay(e,t){let n=ry(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function oy(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 sy(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function cy(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var ly=1280;function uy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(dy),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ly-1}px)`),t=()=>{n(window.innerWidth<ly)};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 dy(){return window.innerWidth<ly}var fy=`sidebar_state`,py=3600*24*7,my=`18rem`,hy=`18rem`,gy=`3rem`,_y=`\\`,vy=Z.createContext(null);function yy(){let e=Z.use(vy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function by(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=uy(),[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=`${fy}=${t}; path=/; max-age=${py}`},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(Sy):_(xy)},t[11]=u,t[12]=_,t[13]=v):v=t[13];let y=v,b,x;t[14]===y?(b=t[15],x=t[16]):(b=()=>{let e=e=>{e.key===_y&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},x=[y],t[14]=y,t[15]=b,t[16]=x),Z.useEffect(b,x);let S=h?`expanded`:`collapsed`,C;t[17]!==u||t[18]!==h||t[19]!==d||t[20]!==_||t[21]!==S||t[22]!==y?(C={state:S,open:h,setOpen:_,isMobile:u,openMobile:d,setOpenMobile:f,toggleSidebar:y},t[17]=u,t[18]=h,t[19]=d,t[20]=_,t[21]=S,t[22]=y,t[23]=C):C=t[23];let w;t[24]===s?w=t[25]:(w={"--sidebar-width":my,"--sidebar-width-icon":gy,...s},t[24]=s,t[25]=w);let T=w,E;t[26]===r?E=t[27]:(E=k(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[26]=r,t[27]=E);let D;t[28]!==n||t[29]!==a||t[30]!==T||t[31]!==E?(D=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:T,className:E,...a,children:n}),t[28]=n,t[29]=a,t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;return t[33]!==D||t[34]!==C?(O=(0,$.jsx)(vy.Provider,{value:C,children:D}),t[33]=D,t[34]=C,t[35]=O):O=t[35],O}function xy(e){return!e}function Sy(e){return!e}function Cy(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}=yy();if(d===`none`){let e;t[8]===r?e=t[9]:(e=k(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e||t[13]!==u?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":u,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=u,t[14]=i):i=t[14],i}if(f){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":hy},t[15]=e):e=t[15];let r;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(dm,{className:`sr-only`,children:[(0,$.jsx)(fm,{children:`Sidebar`}),(0,$.jsx)(pm,{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)(um,{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)(sm,{open:m,onOpenChange:h,...a,children:s}),t[23]=m,t[24]=a,t[25]=h,t[26]=s,t[27]=c):c=t[27],c}let g=p===`collapsed`?d:``,_=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,v;t[28]===_?v=t[29]:(v=k(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,_),t[28]=_,t[29]=v);let y;t[30]===v?y=t[31]:(y=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:v}),t[30]=v,t[31]=y);let b=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,x;t[32]!==r||t[33]!==b?(x=k(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,b,r),t[32]=r,t[33]=b,t[34]=x):x=t[34];let S;t[35]===n?S=t[36]:(S=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=S);let C;t[37]!==a||t[38]!==l||t[39]!==S||t[40]!==x?(C=(0,$.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:x,...a,children:S}),t[37]=a,t[38]=l,t[39]=S,t[40]=x,t[41]=C):C=t[41];let w;return t[42]!==l||t[43]!==p||t[44]!==C||t[45]!==g||t[46]!==y||t[47]!==u?(w=(0,$.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":g,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[y,C]}),t[42]=l,t[43]=p,t[44]=C,t[45]=g,t[46]=y,t[47]=u,t[48]=w):w=t[48],w}function wy(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}=yy(),o;t[4]===n?o=t[5]:(o=k(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(gi,{}),l=(0,$.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,$.jsxs)(q,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,className:o,onClick:s,...i,children:[c,l]}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function Ty(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ey(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Dy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function 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=k(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function 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=k(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ay(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var jy=Ae(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function My(e){let t=(0,Q.c)(28),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?se:`button`,{isMobile:m,state:h}=yy(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=k(jy({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,$.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,$.jsx)(pt,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,$.jsx)($e,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,$.jsxs)(ot,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Ny(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?!1:i,s=a===void 0?!1:a,c=o?se:`button`,l=s&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,u;t[5]!==n||t[6]!==l?(u=k(`absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,l,n),t[5]=n,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==r||t[10]!==u?(d=(0,$.jsx)(c,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:u,...r}),t[8]=c,t[9]=r,t[10]=u,t[11]=d):d=t[11],d}function Py(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`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 Fy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`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 Iy(e){let t=(0,Q.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:i,size:a,isActive:o,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?!1:i,c=a===void 0?`md`:a,l=o===void 0?!1:o,u=s?se:`a`,d;t[6]===n?d=t[7]:(d=k(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,n),t[6]=n,t[7]=d);let f;return t[8]!==u||t[9]!==l||t[10]!==r||t[11]!==c||t[12]!==d?(f=(0,$.jsx)(u,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":c,"data-active":l,className:d,...r}),t[8]=u,t[9]=l,t[10]=r,t[11]=c,t[12]=d,t[13]=f):f=t[13],f}function Ly(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 Ry(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 zy(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 By(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 Vy(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 Hy(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 Uy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Jc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Wy(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(Yc,{"data-slot":`popover-trigger`,...n}),t[2]=n,t[3]=r),r}function Gy(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`center`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=k(`z-50 w-72 rounded-lg border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,$.jsx)(Xc,{children:(0,$.jsx)(Zc,{"data-slot":`popover-content`,align:o,sideOffset:s,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Ky(e){return typeof e==`object`&&!!e&&typeof e.getStates==`function`}function qy(e,t,n){let r=[],i=[];for(let a of e.getStates().values()){let e=a.agentPresence;if(e)for(let[a,o]of Object.entries(e))o.currentDoc&&(n-o.ts>=5e3||(o.currentDoc===t?r.push({agentId:a,entry:o}):i.push({agentId:a,entry:o})))}return{current:r,crossDoc:i}}function Jy(e,t){let n=[];for(let r of e.getStates().values()){let e=r.agentPresence;if(e)for(let r of Object.values(e))r.currentDoc&&(t-r.ts>=5e3||n.push(r))}return n.length===0?null:(n.sort((e,t)=>t.ts-e.ts),n[0].currentDoc)}var Yy=1e3,Xy=!1;function Zy(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function Qy(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:Ky(i)?a=i:(a=void 0,Xy||(Xy=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`})}let{current:t,crossDoc:i}=a?qy(a,n,Date.now()):{current:[],crossDoc:[]},s=$y,c=t.map(s),l=i.map(s),u=[...e,...c],d=l;o(e=>Zy(e.current,u)&&Zy(e.crossDoc,d)?e:{current:u,crossDoc:d})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,Yy);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function $y(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function eb(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`?tb: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 tb(e){return e===`synced`?`synced`:`connected`}var nb=`sync-status`;function rb(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,X.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:nb,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:nb,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}function ib(e){window.location.hash=me(e)}var ab=4,ob=3,sb={Bird:Ar,Cat:Pr,Dog:Yr,Fish:Qr,Mouse:wi,Rabbit:Ci,Shrimp:Ai,Snail:ji,Squirrel:Fi,Turtle:Bi},cb={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function lb(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)(Ly,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Vy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Hy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(zy,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(Ry,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(By,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,$.jsx)(Mi,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function ub(e){let t=(0,Q.c)(20),{user:n,mode:r}=e,i=n.name.split(` `)[1],a=i?sb[i]:void 0,o;t[0]===n.name?o=t[1]:(o=n.name.split(` `).map(db).join(``),t[0]=n.name,t[1]=o);let s=o,c;t[2]===n.color?c=t[3]:(c=A(n.color),t[2]=n.color,t[3]=c);let l=c,u;t[4]===n.color?u=t[5]:(u={backgroundColor:n.color},t[4]=n.color,t[5]=u);let d;t[6]!==a||t[7]!==l||t[8]!==s?(d=a?(0,$.jsx)(a,{size:18,color:l,strokeWidth:1.5}):(0,$.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:l},children:s}),t[6]=a,t[7]=l,t[8]=s,t[9]=d):d=t[9];let f;t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==n.name?(f=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":n.name,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:u,children:d})}),t[10]=r,t[11]=u,t[12]=d,t[13]=n.name,t[14]=f):f=t[14];let p;t[15]===n.name?p=t[16]:(p=(0,$.jsx)($e,{children:n.name}),t[15]=n.name,t[16]=p);let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(ot,{children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function db(e){return e[0]}function fb(e){let t=cb[e.icon];return e.displayName||t||`Agent`}function pb(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function mb(e){let t=(0,Q.c)(30),{participant:n,crossDoc:r,onNavigate:i}=e,{presence:a}=n,o;t[0]===a?o=t[1]:(o=fb(a),t[0]=a,t[1]=o);let s=o,c=r&&a.currentDoc!==null,l=pb(a.mode),u=!c&&!r&&l,d=c?`cursor-pointer`:`cursor-default`,f=u?`ring-primary/40 animate-pulse`:``,p;t[2]!==d||t[3]!==f?(p=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 ring-background`,d,f].filter(Boolean),t[2]=d,t[3]=f,t[4]=p):p=t[4];let m=p.join(` `),h=r?`true`:void 0,g;t[5]!==a.mode||t[6]!==h?(g={"data-presence-badge":`agent`,"data-presence-mode":a.mode,"data-presence-crossdoc":h},t[5]=a.mode,t[6]=h,t[7]=g):g=t[7];let _=g,v;t[8]!==_||t[9]!==c||t[10]!==i||t[11]!==a.color||t[12]!==a.currentDoc||t[13]!==a.icon||t[14]!==m||t[15]!==s?(v=c?(0,$.jsx)(`button`,{type:`button`,..._,"aria-label":`${s}, editing ${a.currentDoc}`,className:m,style:{backgroundColor:a.color},onClick:()=>{a.currentDoc&&i(a.currentDoc)},children:(0,$.jsx)(lb,{icon:a.icon,width:16,height:16,className:`text-white`})}):(0,$.jsx)(`div`,{..._,role:`img`,"aria-label":s,className:m,style:{backgroundColor:a.color},children:(0,$.jsx)(lb,{icon:a.icon,width:16,height:16,className:`text-white`})}),t[8]=_,t[9]=c,t[10]=i,t[11]=a.color,t[12]=a.currentDoc,t[13]=a.icon,t[14]=m,t[15]=s,t[16]=v):v=t[16];let y=v,b;t[17]===y?b=t[18]:(b=(0,$.jsx)(pt,{asChild:!0,children:y}),t[17]=y,t[18]=b);let x;t[19]===s?x=t[20]:(x=(0,$.jsx)(`span`,{className:`font-medium`,children:s}),t[19]=s,t[20]=x);let S;t[21]!==r||t[22]!==a.currentDoc?(S=r&&a.currentDoc?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,a.currentDoc,`]]`]}):null,t[21]=r,t[22]=a.currentDoc,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==x?(C=(0,$.jsxs)($e,{className:`flex flex-col gap-0.5`,children:[x,S]}),t[24]=S,t[25]=x,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==b?(w=(0,$.jsxs)(ot,{children:[b,C]}),t[27]=C,t[28]=b,t[29]=w):w=t[29],w}function hb(e){let t=(0,Q.c)(16),{count:n,remainder:r,crossDoc:i,onNavigate:a}=e,o=i?`true`:void 0,s=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,c;t[0]!==n||t[1]!==o||t[2]!==s?(c=(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":o,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":s,children:[`+`,n]})}),t[0]=n,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l;if(t[4]!==i||t[5]!==a||t[6]!==r){let e;t[8]!==i||t[9]!==a?(e=e=>e.kind===`human`?(0,$.jsx)(ub,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(mb,{participant:e,crossDoc:i,onNavigate:a},e.agentId),t[8]=i,t[9]=a,t[10]=e):e=t[10],l=r.map(e),t[4]=i,t[5]=a,t[6]=r,t[7]=l}else l=t[7];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(Gy,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:l})}),t[11]=l,t[12]=u);let d;return t[13]!==c||t[14]!==u?(d=(0,$.jsxs)(Uy,{children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],d}function gb(e,t,n){return e.kind===`human`?(0,$.jsx)(ub,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(mb,{participant:e,crossDoc:n,onNavigate:t},e.agentId)}function _b(){let e=(0,Q.c)(12),{activeProvider:t,activeDocName:n,systemProvider:r}=Hn(),{current:i,crossDoc:a}=Qy(t,r,n);rb(eb(t),n);let o;if(e[0]!==a||e[1]!==i){let t=i.slice(0,ab),n;e[3]===i?n=e[4]:(n=i.slice(ab),e[3]=i,e[4]=n);let r=n,s=a.slice(0,ob),c;e[5]===a?c=e[6]:(c=a.slice(ob),e[5]=a,e[6]=c);let l=c,u=t.map(yb),d;e[7]===r?d=e[8]:(d=r.length>0?(0,$.jsx)(hb,{count:r.length,remainder:r,crossDoc:!1,onNavigate:ib}):null,e[7]=r,e[8]=d);let f;e[9]!==u||e[10]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[u,d]}),e[9]=u,e[10]=d,e[11]=f):f=e[11],o=(0,$.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[f,a.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[s.map(vb),l.length>0?(0,$.jsx)(hb,{count:l.length,remainder:l,crossDoc:!0,onNavigate:ib}):null]})]}):null]}),e[0]=a,e[1]=i,e[2]=o}else o=e[2];return o}function vb(e){return gb(e,ib,!0)}function yb(e){return gb(e,ib,!1)}function bb(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 xb(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 Sb=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Mr},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:vt},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:xb},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:bb}],Cb=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,$.jsx)(Rr,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,$.jsx)($e,{children:`Help & resources`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`p`,{className:`text-sm font-medium mb-2`,children:`Need help?`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(Uy,{children:[t,(0,$.jsxs)(Gy,{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:Sb.map(wb)})})]})]}),e[2]=r):r=e[2],r};function wb(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 Tb=`https://github.com/inkeep/open-knowledge/releases`;function Eb(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 Db(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:Tb}}};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 Ob(e){return od(e)}function kb(e){return`Opened ${e} in your browser.`}function Ab(e){let t=(0,Q.c)(63),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??pd,c=e.onWebFallbackSuccess??Mb,l=e.onWebFallbackError??jb,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Db({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=Eb({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(Ob(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)(Lg,{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)(Lg,{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)(Pg,{"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)(zg,{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)(Bg,{}),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)(Lg,{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)(Lg,{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)(Fg,{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)(Mg,{children:[S,j]}),t[60]=j,t[61]=S,t[62]=M):M=t[62],M}function jb(){}function Mb(){}function Nb(e){let t=(0,Q.c)(21),{input:n}=e,{states:r,refresh:i}=Wd(),{dispatch:a}=Nd(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=Fb,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?``:ad(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Xr,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in…`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})}),t[8]=p,t[9]=y);let b;t[10]!==_||t[11]!==h||t[12]!==r?(b=sd.map(e=>{let t=r[e.id];return(0,$.jsx)(Ab,{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)(Ig,{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)(Ag,{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){X.error(`Couldn't open ${e.displayName} in your browser.`)}function Fb(e){X.success(kb(e.displayName))}var Ib={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`},Lb=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`,...Ib,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},Rb=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)(Lb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},zb=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)(Lb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Bb=(e,t,n)=>qi(e,t,n,`ProjectSwitcher`);function Vb(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 Bb(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),Bb(()=>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),Bb(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=Ag,y=o,b=s;let a;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),t[30]=a):a=t[30];let c;t[31]===n.config.projectName?c=t[32]:(c=(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:n.config.projectName}),t[31]=n.config.projectName,t[32]=c);let l;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ir,{className:`size-3 shrink-0 opacity-60`}),t[33]=l):l=t[33],t[34]===c?x=t[35]:(x=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:`gap-1.5 px-2 text-muted-foreground hover:text-foreground`,"data-testid":`project-switcher-trigger`,title:`Switch project`,children:[a,c,l]})}),t[34]=c,t[35]=x),h=Ig,S=`start`,C=`min-w-[260px]`,w=`project-switcher-menu`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(zg,{children:`Switch project`}),_=(0,$.jsx)(Bg,{}),t[36]=_,t[37]=T):(_=t[36],T=t[37]),v=r.length===0?(0,$.jsx)(zg,{className:`font-normal text-muted-foreground text-xs`,children:`No other recent projects.`}):r.slice(0,10).map(e=>(0,$.jsxs)(Lg,{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)(Bg,{}),t[38]=E):E=t[38];let D;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ei,{className:`mr-2 size-4`}),t[39]=D):D=t[39];let O;t[40]===p?O=t[41]:(O=(0,$.jsxs)(Lg,{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 Hb(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=k(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(gl,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`}),t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==a||t[9]!==o?(c=(0,$.jsx)(hl,{"data-slot":`switch`,"data-size":a,className:o,...r,children:s}),t[7]=r,t[8]=a,t[9]=o,t[10]=c):c=t[10],c}function Ub(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 Wb(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function Gb(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 Kb(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ti,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zi,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fi,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Br,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function qb(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 Jb(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 Yb(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 Xb(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`}`:Jb(e.state):`Sync off`}function Zb(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 Gb(e)}catch(t){console.error(`[sync] toggle failed`,t),X.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,$.jsx)(Kb,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=Jb(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)(Hb,{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:Yb(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: `,Ub(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,$.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,$.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,$.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,$.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,$.jsx)(Ui,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:$b,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:Qb,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,$.jsx)(q,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function Qb(){Wb(`sync`)}function $b(){Wb(`sync`)}function ex(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}=tf();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,$.jsx)(zr,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,$.jsxs)(ot,{children:[e,(0,$.jsx)($e,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=qb(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Jb(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)(Kb,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,$.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(Wy,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=Xb(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,$.jsx)($e,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,$.jsxs)(ot,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,$.jsx)(Gy,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(Zb,{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)(Uy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var tx=[{value:`light`,label:`Light`,icon:Li},{value:`dark`,label:`Dark`,icon:pi},{value:`system`,label:`System`,icon:Wr}],nx=()=>{let e=(0,Q.c)(14),{theme:t,setTheme:n}=Ve(),r=t===`system`?Wr:t===`dark`?pi:Li,i;e[0]===r?i=e[1]:(i=(0,$.jsx)(r,{}),e[0]=r,e[1]=i);let a=t??`system`,o;e[2]===a?o=e[3]:(o=(0,$.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,a,`)`]}),e[2]=a,e[3]=o);let s;e[4]!==i||e[5]!==o?(s=(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[i,o]})}),e[4]=i,e[5]=o,e[6]=s):s=e[6];let c;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=tx.map(rx),e[7]=c):c=e[7];let l;e[8]!==n||e[9]!==t?(l=(0,$.jsx)(Ig,{align:`end`,children:(0,$.jsx)(Ng,{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)(Ag,{children:[s,l]}),e[11]=s,e[12]=l,e[13]=u):u=e[13],u};function rx(e){let{value:t,label:n,icon:r}=e;return(0,$.jsxs)(Rg,{value:t,className:`capitalize`,children:[(0,$.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function ix(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function ax(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(ix)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function ox(e){let t=(0,Q.c)(117),{editorMode:n,onModeChange:r,onTimelineToggle:i,onSaveVersion:a,saving:o,previewEntry:s,restoring:c,restoreError:l,onExitPreview:u,onRestore:d,diffLayout:f,onDiffLayoutChange:p,onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g,onOpenClone:_}=e,{activeDocName:v,activeProvider:y,activeTarget:b,closeDocument:x,pinnedDoc:S,pin:C,unpin:w}=Hn(),{state:T}=yy(),E=cd(),D=eb(y),O;t[0]!==v||t[1]!==E?(O=wd({docName:v,workspace:E}),t[0]=v,t[1]=E,t[2]=O):O=t[2];let k=O,A=!v||!(D===`connected`||D===`synced`),j=b?.kind===`folder`,M=b?.kind===`missing`,N=j?`${b.folderPath}/`:v?`${v}.md`:``,P;t[3]===v?P=t[4]:(P=v?.lastIndexOf(`/`)??-1,t[3]=v,t[4]=P);let F=P,I;t[5]!==v||t[6]!==F?(I=v&&F!==-1?`${v.substring(0,F+1)}`:``,t[5]=v,t[6]=F,t[7]=I):I=t[7];let L=I,R;t[8]!==v||t[9]!==F?(R=v?v.substring(F+1):``,t[8]=v,t[9]=F,t[10]=R):R=t[10];let z=R,B=S!==null,V;t[11]!==v||t[12]!==B||t[13]!==C||t[14]!==w?(V=function(){v&&(B?w():C(v))},t[11]=v,t[12]=B,t[13]=C,t[14]=w,t[15]=V):V=t[15];let H=V,U=n===`diff`,[W,G]=(0,Z.useState)(!1),[K,ee]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(``),[re,ie]=(0,Z.useState)(null),[ae,oe]=(0,Z.useState)(!1),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(!1),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)(null),de=(0,Z.useRef)(null),fe;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{le.current=!0,ue.current=null,de.current=null,ee(!1),ie(null)},t[16]=fe):fe=t[16];let pe;t[17]===v?pe=t[18]:(pe=[v],t[17]=v,t[18]=pe),(0,Z.useEffect)(fe,pe);let he,ge;t[19]===K?(he=t[20],ge=t[21]):(he=()=>{if(K){let e=setTimeout(()=>{let e=se.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},ge=[K],t[19]=K,t[20]=he,t[21]=ge),(0,Z.useEffect)(he,ge);let _e;t[22]!==v||t[23]!==j?(_e=function(){if(!v||j)return;let e=v.split(`/`);le.current=!1,ue.current=v,ne(e[e.length-1]),ie(null),de.current=null,ee(!0)},t[22]=v,t[23]=j,t[24]=_e):_e=t[24];let ve=_e,ye;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ye=function(){le.current=!0,ue.current=null,de.current=null,ee(!1),ne(``),ie(null)},t[25]=ye):ye=t[25];let be=ye,xe;t[26]!==x||t[27]!==te?(xe=async function(){if(le.current){le.current=!1;return}if(ce.current)return;let e=ue.current;if(!e){be();return}let t=ry(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){be();return}if(t===de.current)return;if(!iy(t)){ie(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=ay({kind:`file`,path:e,name:r},t);ce.current=!0,oe(!0),ie(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(le.current){oe(!1),ce.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),ie(`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!n.ok||!ax(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),ie(a?.error||`Server error (HTTP ${n.status})`),oe(!1),ce.current=!1,de.current=t;return}if(!r.ok){ie(r.error||`Failed to rename path`),oe(!1),ce.current=!1,de.current=t;return}let a=r.renamed,o=cy(e,a);for(let e of a)x(e.fromDocName);ze([`files`,`backlinks`,`graph`]),ee(!1),ne(``),oe(!1),ce.current=!1,de.current=null,ue.current=null,o&&o!==e&&(window.location.hash=me(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),ie(`Network error — please try again`),oe(!1),ce.current=!1,de.current=t}},t[26]=x,t[27]=te,t[28]=xe):xe=t[28];let Se=xe,Ce;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{G(!1)},t[29]=Ce):Ce=t[29];let we;t[30]===s?we=t[31]:(we=[s],t[30]=s,t[31]=we),(0,Z.useEffect)(Ce,we);let Te;t[32]===d?Te=t[33]:(Te=function(){G(!1),d()},t[32]=d,t[33]=Te);let J=Te,Ee;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(wy,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[34]=Ee):Ee=t[34];let De=T===`expanded`?`Hide Files`:`Show Files`,Oe;t[35]===De?Oe=t[36]:(Oe=(0,$.jsxs)(ot,{children:[Ee,(0,$.jsx)($e,{children:De})]}),t[35]=De,t[36]=Oe);let ke,Ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ke=typeof window<`u`&&window.okDesktop?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(sv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(Vb,{bridge:window.okDesktop})]}):null,Ae=(0,$.jsx)(sv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[37]=ke,t[38]=Ae):(ke=t[37],Ae=t[38]);let je;t[39]!==v||t[40]!==Se||t[41]!==N||t[42]!==ve||t[43]!==z||t[44]!==j||t[45]!==ae||t[46]!==K||t[47]!==L||t[48]!==re||t[49]!==te?(je=j?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Dn,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:N})]}):v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[L&&(0,$.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:K?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,$.jsx)(`span`,{className:`truncate`,children:L.slice(0,-1)}),(0,$.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),K?(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Mt,{ref:se,value:te,disabled:ae,"aria-label":`Rename ${v}`,"aria-invalid":re?!0:void 0,"aria-describedby":re?`editor-header-rename-error`:void 0,"aria-busy":ae||void 0,onChange:e=>{ne(e.target.value),ie(null),de.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Se()):e.key===`Escape`&&(e.preventDefault(),be())},onBlur:()=>void Se(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:`.md`})]}),re&&(0,$.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:re})]}):(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ve,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:[z,`.md`]})]}):(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:N}),t[39]=v,t[40]=Se,t[41]=N,t[42]=ve,t[43]=z,t[44]=j,t[45]=ae,t[46]=K,t[47]=L,t[48]=re,t[49]=te,t[50]=je):je=t[50];let Me;t[51]!==v||t[52]!==B||t[53]!==H?(Me=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:H,"aria-label":B?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":B,"data-pinned":B?`true`:`false`,children:B?(0,$.jsx)(xi,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,$.jsx)(bi,{className:`size-4`})})}),(0,$.jsx)($e,{children:B?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[51]=v,t[52]=B,t[53]=H,t[54]=Me):Me=t[54];let Y;t[55]===M?Y=t[56]:(Y=M&&(0,$.jsx)(vl,{variant:`dashed`,children:`New file`}),t[55]=M,t[56]=Y);let Ne;t[57]!==Oe||t[58]!==je||t[59]!==Me||t[60]!==Y?(Ne=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[Oe,ke,Ae,je,Me,Y]}),t[57]=Oe,t[58]=je,t[59]=Me,t[60]=Y,t[61]=Ne):Ne=t[61];let Pe;t[62]!==v||t[63]!==n||t[64]!==U||t[65]!==r||t[66]!==A?(Pe=!U&&v&&(0,$.jsxs)(mt,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!v,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(zb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Visual`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{tabIndex:A?0:void 0,children:(0,$.jsxs)(lt,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:A,children:[(0,$.jsx)(Rb,{className:`size-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),A&&!v?null:A?(0,$.jsx)($e,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,$.jsx)($e,{className:`md:hidden`,children:`Markdown`})]})]}),t[62]=v,t[63]=n,t[64]=U,t[65]=r,t[66]=A,t[67]=Pe):Pe=t[67];let Fe;t[68]!==W||t[69]!==f||t[70]!==U||t[71]!==p||t[72]!==u||t[73]!==s||t[74]!==l?(Fe=U&&s&&!W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[l&&(0,$.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,$.jsxs)(mt,{type:`single`,value:f,onValueChange:e=>{e&&p(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,children:[(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`unified`,"aria-label":`Unified diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Di,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Unified`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Unified`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(`span`,{children:(0,$.jsxs)(lt,{value:`split`,"aria-label":`Split diff`,className:`gap-1 text-xs px-2`,children:[(0,$.jsx)(Hr,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Split`})]})})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Split`})]})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!0),children:[(0,$.jsx)(Ei,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Restore`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Restore`})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:u,children:[(0,$.jsx)(jt,{className:`size-3.5 md:hidden`}),(0,$.jsx)(`span`,{className:`hidden md:inline`,children:`Exit preview`})]})}),(0,$.jsx)($e,{className:`md:hidden`,children:`Exit preview`})]})]}),t[68]=W,t[69]=f,t[70]=U,t[71]=p,t[72]=u,t[73]=s,t[74]=l,t[75]=Fe):Fe=t[75];let Ie;t[76]!==W||t[77]!==J||t[78]!==U||t[79]!==s||t[80]!==c?(Ie=U&&s&&W&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Replace current content with this version?`}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>G(!1),disabled:c,children:`Cancel`}),(0,$.jsx)(q,{variant:`default`,size:`xs`,onClick:J,disabled:c,children:c?`Restoring…`:`Restore`})]}),t[76]=W,t[77]=J,t[78]=U,t[79]=s,t[80]=c,t[81]=Ie):Ie=t[81];let Le;t[82]!==U||t[83]!==_?(Le=!U&&_&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:_,className:`text-muted-foreground`,children:(0,$.jsx)(ni,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:`Clone from GitHub…`})]}),t[82]=U,t[83]=_,t[84]=Le):Le=t[84];let Re;t[85]!==v||t[86]!==U||t[87]!==a||t[88]!==o?(Re=!U&&v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:a,disabled:o,className:`text-muted-foreground`,children:(0,$.jsx)(Oi,{className:`size-3.5`})})}),(0,$.jsx)($e,{children:o?`Saving…`:`Checkpoint version`})]}),t[85]=v,t[86]=U,t[87]=a,t[88]=o,t[89]=Re):Re=t[89];let Be;t[90]!==v||t[91]!==i?(Be=v&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon-sm`,"aria-label":`Document timeline`,onClick:i,children:(0,$.jsx)(ai,{className:`size-4`})})}),(0,$.jsx)($e,{children:`Document timeline`})]}),t[90]=v,t[91]=i,t[92]=Be):Be=t[92];let Ve;t[93]!==v||t[94]!==k||t[95]!==U?(Ve=!U&&v&&(0,$.jsx)(Nb,{input:k}),t[93]=v,t[94]=k,t[95]=U,t[96]=Ve):Ve=t[96];let He;t[97]!==g||t[98]!==h||t[99]!==m?(He=(0,$.jsx)(ex,{onSignIn:m,onSetIdentity:h,onOpenConflictResolver:g}),t[97]=g,t[98]=h,t[99]=m,t[100]=He):He=t[100];let Ue,We,Ge,Ke;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(_b,{}),We=(0,$.jsx)(sv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ge=(0,$.jsx)(Cb,{}),Ke=(0,$.jsx)(nx,{}),t[101]=Ue,t[102]=We,t[103]=Ge,t[104]=Ke):(Ue=t[101],We=t[102],Ge=t[103],Ke=t[104]);let qe;t[105]!==Le||t[106]!==Re||t[107]!==Be||t[108]!==Ve||t[109]!==He?(qe=(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Le,Re,Be,Ve,He,Ue,We,Ge,Ke]}),t[105]=Le,t[106]=Re,t[107]=Be,t[108]=Ve,t[109]=He,t[110]=qe):qe=t[110];let Je;return t[111]!==Ne||t[112]!==Pe||t[113]!==Fe||t[114]!==Ie||t[115]!==qe?(Je=(0,$.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[Ne,Pe,Fe,Ie,qe]}),t[111]=Ne,t[112]=Pe,t[113]=Fe,t[114]=Ie,t[115]=qe,t[116]=Je):Je=t[116],Je}function sx(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 cx(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 lx(e){if(e.contributors.length>0){let t=e.contributors[0],n=t.colorSeed??t.name;return{hex:ie[Ue(n)]??Ge(n)}}return e.type===`upstream`?{className:`bg-muted-foreground/50`}:(e.authorEmail.includes(`openknowledge.local`)||e.type===`wip`)&&(e.authorEmail.includes(`agent`)||e.author.includes(`agent`)||e.authorEmail.includes(`cursor`)||e.authorEmail.includes(`claude`))?{className:`bg-[--color-agent]`}:{className:`bg-[--color-azure-blue]`}}function ux(e){let t=lx(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 dx(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(fx),t[0]=c):c=t[0];let l;t[1]===o?l=t[2]:(l=o?(0,$.jsx)(Ir,{className:`size-3`}):(0,$.jsx)(Lr,{className:`size-3`}),t[1]=o,t[2]=l);let u=o?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,d;t[3]!==o||t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":o,className:`flex items-center gap-1 px-4 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors text-left`,onClick:c,children:[l,u]}),t[3]=o,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]!==n||t[8]!==o||t[9]!==a||t[10]!==i?(f=o&&n.map(e=>(0,$.jsx)(gx,{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 fx(e){return!e}function px(e){return e.checkpoint?e.checkpoint.kind:`save`}function mx(e){let t=px(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${hx(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function hx(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function gx(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=sx(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=cx(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(_x);_=`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=px(n);return e===`bridge-merge-loss`?(0,$.jsx)(zi,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,$.jsx)(Zr,{className:`mt-0.5 size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,$.jsx)(Jr,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`})})():(0,$.jsx)(`div`,{className:`mt-1.5 flex shrink-0 items-center`,children:ux(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:mx(n)}),ux(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 _x(e){return e.docs}function vx(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(bx),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)(fm,{className:`text-sm`,children:`Timeline`}),t[11]=b):b=t[11];let x;t[12]!==a||t[13]!==o?(x=o&&(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),className:`text-xs text-muted-foreground`,children:`Now`}),t[12]=a,t[13]=o,t[14]=x):x=t[14];let S;t[15]===x?S=t[16]:(S=(0,$.jsx)(dm,{className:`border-b px-4 py-3 pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between pr-10`,children:[b,x]})}),t[15]=x,t[16]=S);let C;t[17]===u?C=t[18]:(C=u&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 p-4`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3,4].map(yx)}),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)(gx,{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)(gx,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(dx,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,selectedSha:o,onSelect:a},e.entries[0]?.sha??`wip-${t}`))}),t[33]=f,t[34]=_,t[35]=y,t[36]=u,t[37]=a,t[38]=o,t[39]=D):D=t[39];let O;t[40]!==T||t[41]!==E||t[42]!==D||t[43]!==C||t[44]!==w?(O=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[C,w,T,E,D]}),t[40]=T,t[41]=E,t[42]=D,t[43]=C,t[44]=w,t[45]=O):O=t[45];let k;t[46]!==a||t[47]!==o?(k=o&&(0,$.jsxs)(`div`,{className:`border-t p-3 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground `,children:`Viewing historical version`}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,onClick:()=>a?.({sha:``,timestamp:``,author:``,authorEmail:``,type:`wip`,message:``,contributors:[],checkpoint:null}),children:[(0,$.jsx)(Ei,{className:`size-3`}),`Exit`]})]}),t[46]=a,t[47]=o,t[48]=k):k=t[48];let A;t[49]!==O||t[50]!==k||t[51]!==S?(A=(0,$.jsxs)(um,{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)(sm,{open:n,onOpenChange:r,children:A}),t[53]=r,t[54]=n,t[55]=A,t[56]=j):j=t[56],j}function yx(e){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(df,{className:`size-3.5 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(df,{className:`h-3 w-24`}),(0,$.jsx)(df,{className:`h-3 w-40`})]}),(0,$.jsx)(df,{className:`h-3 w-14`})]},e)}function bx(e){return e.type===`checkpoint`}function xx(){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=ef(),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}=Hn(),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(),X.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&&Un(j,{kind:`raw-mdx`,detail:t}),n(`source`)};return window.addEventListener(Bt,e),()=>window.removeEventListener(Bt,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,X.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>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,ne;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(ne=async function(){w(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?X.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),X.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),X.error(`Checkpoint failed — try again`)}w(!1)},e[21]=ne):ne=e[21];let re=ne,ie;e[22]!==j||e[23]!==h?(ie=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]=ie):ie=e[24];let ae=ie,oe;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(gf,{onOpenResolver:()=>o(!0)}),e[25]=oe):oe=e[25];let se;e[26]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>i(Sx),e[26]=se):se=e[26];let q,ce,le,ue;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>{u(`auth`),c(!0)},ce=()=>{u(`identity`),c(!0)},le=()=>o(!0),ue=()=>f(!0),e[27]=q,e[28]=ce,e[29]=le,e[30]=ue):(q=e[27],ce=e[28],le=e[29],ue=e[30]);let de;e[31]!==_||e[32]!==t||e[33]!==ae||e[34]!==h||e[35]!==x||e[36]!==y||e[37]!==C?(de=(0,$.jsx)(ox,{editorMode:t,onModeChange:te,onTimelineToggle:se,onSaveVersion:re,saving:C,previewEntry:h,restoring:y,restoreError:x,onExitPreview:I,onRestore:ae,diffLayout:_,onDiffLayoutChange:v,onSignIn:q,onSetIdentity:ce,onOpenConflictResolver:le,onOpenClone:ue}),e[31]=_,e[32]=t,e[33]=ae,e[34]=h,e[35]=x,e[36]=y,e[37]=C,e[38]=de):de=e[38];let fe;e[39]!==t||e[40]!==h?(fe=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: `,sx(h.timestamp),` — `,cx(h)]})}),e[39]=t,e[40]=h,e[41]=fe):fe=e[41];let pe;e[42]!==_||e[43]!==t||e[44]!==h?(pe=(0,$.jsx)($v,{editorMode:t,previewEntry:h,diffLayout:_,onNoDiff:R}),e[42]=_,e[43]=t,e[44]=h,e[45]=pe):pe=e[45];let me=j??``,he=h?.sha,ge;e[46]!==P||e[47]!==me||e[48]!==he||e[49]!==r?(ge=(0,$.jsx)(vx,{open:r,onOpenChange:i,docName:me,onEntrySelect:P,selectedSha:he}),e[46]=P,e[47]=me,e[48]=he,e[49]=r,e[50]=ge):ge=e[50];let _e;e[51]===a?_e=e[52]:(_e=(0,$.jsx)(ym,{open:a,onOpenChange:o}),e[51]=a,e[52]=_e);let ve;e[53]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>{c(e),e||m(!1)},e[53]=ve):ve=e[53];let ye=l===`identity`,be;e[54]===p?be=e[55]:(be=()=>{c(!1),p&&(m(!1),f(!0))},e[54]=p,e[55]=be);let xe;e[56]!==s||e[57]!==ye||e[58]!==be?(xe=(0,$.jsx)(lf,{open:s,onOpenChange:ve,identityPrompt:ye,onSuccess:be}),e[56]=s,e[57]=ye,e[58]=be,e[59]=xe):xe=e[59];let Se;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[60]=Se):Se=e[60];let Ce;e[61]===d?Ce=e[62]:(Ce=(0,$.jsx)(mf,{open:d,onOpenChange:f,onSignIn:Se}),e[61]=d,e[62]=Ce);let we;return e[63]!==de||e[64]!==fe||e[65]!==pe||e[66]!==ge||e[67]!==_e||e[68]!==xe||e[69]!==Ce?(we=(0,$.jsxs)($.Fragment,{children:[oe,de,fe,pe,ge,_e,xe,Ce]}),e[63]=de,e[64]=fe,e[65]=pe,e[66]=ge,e[67]=_e,e[68]=xe,e[69]=Ce,e[70]=we):we=e[70],we}function Sx(e){return!e}var Cx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function wx(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Tx(e){return`nodeType`in e}function Ex(e){return e?wx(e)?e:Tx(e)?e.ownerDocument?.defaultView??window:window:window}function Dx(e){let{Document:t}=Ex(e);return e instanceof t}function Ox(e){return wx(e)?!1:e instanceof Ex(e).HTMLElement}function kx(e){return e instanceof Ex(e).SVGElement}function Ax(e){return e?wx(e)?e.document:Tx(e)?Dx(e)?e:Ox(e)||kx(e)?e.ownerDocument:document:document:document}var jx=Cx?Z.useLayoutEffect:Z.useEffect;function Mx(e){let t=(0,Z.useRef)(e);return jx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Nx(){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 Px(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return jx(()=>{n.current!==e&&(n.current=e)},t),n}function Fx(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Ix(e){let t=Mx(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Lx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var Rx={};function zx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=Rx[e]==null?0:Rx[e]+1;return Rx[e]=n,e+`-`+n},[e,t])}function Bx(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 Vx=Bx(1),Hx=Bx(-1);function Ux(e){return`clientX`in e&&`clientY`in e}function Wx(e){if(!e)return!1;let{KeyboardEvent:t}=Ex(e.target);return t&&e instanceof t}function Gx(e){if(!e)return!1;let{TouchEvent:t}=Ex(e.target);return t&&e instanceof t}function Kx(e){if(Gx(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 Ux(e)?{x:e.clientX,y:e.clientY}:null}var qx=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[qx.Translate.toString(e),qx.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Jx=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Yx(e){return e.matches(Jx)?e:e.querySelector(Jx)}var Xx={display:`none`};function Zx(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:Xx},n)}function Qx(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 $x(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var eS=(0,Z.createContext)(null);function tS(e){let t=(0,Z.useContext)(eS);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function nS(){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 rS={draggable:`
18
18
  To pick up a draggable item, press the space bar.
19
19
  While dragging, use the arrow keys to move the item.
20
20
  Press space again to drop the item in its new position, or press escape to cancel.