@inkeep/open-knowledge 0.0.0-dev-20260422232504 → 0.0.0-dev-20260423021439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +4 -4
- package/dist/constants-BZCjqpR_.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/init-BV6SLNHl.mjs +1 -0
- package/dist/{init-CAM_eIuh.mjs → init-BV7B4Mgk.mjs} +3 -3
- package/dist/init-Ci-hnTp7.mjs +1 -0
- package/dist/{init-CyIusiAw.mjs → init-JHuZsv_n.mjs} +2 -2
- package/dist/{loader-CyOUw8dB.mjs → loader-CO0vOmfa.mjs} +2 -2
- package/dist/loader-C_WrBIEx.mjs +1 -0
- package/dist/paths-BRk9TUIP.mjs +1 -0
- package/dist/{paths-B7nBwFyW.mjs → paths-C0PGZVIi.mjs} +2 -2
- package/dist/{preview-Cr-2Rh11.mjs → preview-BAML3CHB.mjs} +2 -2
- package/dist/preview-wRyVeF8p.mjs +1 -0
- package/dist/public/assets/{index-C80QVNFN.js → index-CcvrsPse.js} +3 -3
- package/dist/public/assets/index-lYAAGLdq.css +1 -0
- package/dist/public/index.html +2 -2
- package/dist/src-DPtUH4AE.mjs +1 -0
- package/dist/start-KwwdSJfw.mjs +1 -0
- package/dist/{start-By_-ez4R.mjs → start-iOkFA7_B.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-B-wIG6WQ.mjs +0 -2
- package/dist/init-CqQ2-jIJ.mjs +0 -1
- package/dist/init-D2KHqT1t.mjs +0 -1
- package/dist/loader-CRpUV2sW.mjs +0 -1
- package/dist/paths-KQXh_S14.mjs +0 -1
- package/dist/preview-BKyZuJqJ.mjs +0 -1
- package/dist/public/assets/index-CPyMCk-k.css +0 -1
- package/dist/src-D0qDs_nw.mjs +0 -1
- package/dist/start-BSG3um4-.mjs +0 -1
|
@@ -13,9 +13,9 @@ Error generating stack: `+e.message+`
|
|
|
13
13
|
`)+1)}}}catch(e){let r=e;r instanceof Error&&r.name===`AbortError`?n=!0:t=[]}n||e.aborted||(u(t),f(!1))},t[3]=w):w=t[3];let T=w,E,D;t[4]!==h||t[5]!==n?(E=()=>{if(!h||!n)return;let e=new AbortController;return T(e.signal),()=>e.abort()},D=[h,n],t[4]=h,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Z.useEffect)(E,D);let O;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e){o(e);let t=pf(e);t&&c(`~/Documents/${t}`)},t[8]=O):O=t[8];let k=O,A;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(e){o(e.clone_url);let t=e.full_name.split(`/`)[1];c(`~/Documents/${t}`)},t[9]=A):A=t[9];let j=A,M;t[10]!==s||t[11]!==r||t[12]!==a?(M=async function(){if(!a.trim()){X.error(`Enter a repository URL or owner/repo`);return}let e=new AbortController;b(e),v(!0);let t=X.loading(`Starting clone…`,{duration:1/0});x.current=t;try{let n=await fetch(`/api/local-op/clone`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:a.trim(),dir:s||void 0}),signal:e.signal});if(!n.ok||!n.body){X.error(`Clone failed — check the URL and try again`,{id:t}),v(!1),b(null);return}let i=n.body.getReader(),o=new TextDecoder,c=``;for(;;){let{done:e,value:n}=await i.read();if(e)break;c+=o.decode(n,{stream:!0});let a=c.split(`
|
|
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
|
-
`,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 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:`
|
|
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}`}function p_(e){let t=1.5,n=.3;return`M${e-t} ${u_-n} Q${e} ${u_+1.4}, ${e+t} ${u_-n}`}var m_=15,h_=15;function g_(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 __(e){let t=(0,Q.c)(61),{size:n,className:r,trackMouse:i,variant:a}=e,o=n===void 0?48:n,s=i===void 0?!0:i,c=a===void 0?`default`:a,l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),[f,p]=(0,Z.useState)(0),[m,h]=(0,Z.useState)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=[],t[0]=g):g=t[0];let[_,v]=(0,Z.useState)(g),y=(0,Z.useRef)(0),b=(0,Z.useRef)(0),x=(0,Z.useRef)(void 0),S=c===`sleeping`,C;t[1]!==f||t[2]!==S?(C=function(){if(S)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=y.current===0?1/0:e-y.current;y.current=e;let n=r_(f,t);p(n),h(y_),v(o_(n)),clearTimeout(x.current),x.current=setTimeout(()=>{p(0),v([])},t_)},t[1]=f,t[2]=S,t[3]=C):C=t[3];let w=C,T,E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>clearTimeout(x.current),E=[],t[4]=T,t[5]=E):(T=t[4],E=t[5]),(0,Z.useEffect)(T,E);let D,O;t[6]!==S||t[7]!==s?(D=()=>{if(!s||S||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=function(e){b.current&&cancelAnimationFrame(b.current),b.current=requestAnimationFrame(()=>{let t=l.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height*.48,a=e.clientX-r,o=e.clientY-i,s=Math.hypot(a,o),c=0,f=0;if(s>=1){let e=Math.min(s/150,1)*s_;c=a/s*e,f=o/s*e}u.current?.setAttribute(`cx`,String(c_+c)),u.current?.setAttribute(`cy`,String(u_+f)),d.current?.setAttribute(`cx`,String(l_+c)),d.current?.setAttribute(`cy`,String(u_+f))})};return document.addEventListener(`mousemove`,e,{passive:!0}),()=>{document.removeEventListener(`mousemove`,e),b.current&&cancelAnimationFrame(b.current)}},O=[s,S],t[6]=S,t[7]=s,t[8]=D,t[9]=O):(D=t[8],O=t[9]),(0,Z.useEffect)(D,O);let A=f>0,j=A?f:1,M=A?`ok-blob-clicked-${f}`:null,N=S?`cursor-default`:`cursor-pointer`,P;t[10]!==r||t[11]!==N?(P=k(N,r),t[10]=r,t[11]=N,t[12]=P):P=t[12];let F=`body-${m}`,I=S&&`ok-blob-sleeping`,L;t[13]!==M||t[14]!==I?(L=k(`ok-blob-group`,I,M),t[13]=M,t[14]=I,t[15]=L):L=t[15];let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[16]=R):R=t[16];let z=(A||S)&&`ok-blob-eye-hidden`,B;t[17]===z?B=t[18]:(B=k(`ok-blob-eye`,z),t[17]=z,t[18]=B);let V;t[19]===B?V=t[20]:(V=(0,$.jsx)(`ellipse`,{ref:u,cx:c_,cy:u_,rx:1.2722,ry:1.9083,className:B}),t[19]=B,t[20]=V);let H=(A||S)&&`ok-blob-eye-hidden`,U;t[21]===H?U=t[22]:(U=k(`ok-blob-eye ok-blob-eye-right`,H),t[21]=H,t[22]=U);let W;t[23]===U?W=t[24]:(W=(0,$.jsx)(`ellipse`,{ref:d,cx:l_,cy:u_,rx:1.2722,ry:1.9083,className:U}),t[23]=U,t[24]=W);let G;t[25]===j?G=t[26]:(G=f_(c_,j),t[25]=j,t[26]=G);let K=(!A||S)&&`ok-blob-eye-hidden`,ee;t[27]===K?ee=t[28]:(ee=k(`ok-blob-happy-eye`,K),t[27]=K,t[28]=ee);let te;t[29]!==G||t[30]!==ee?(te=(0,$.jsx)(`path`,{d:G,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ee}),t[29]=G,t[30]=ee,t[31]=te):te=t[31];let ne;t[32]===j?ne=t[33]:(ne=f_(l_,j),t[32]=j,t[33]=ne);let re=(!A||S)&&`ok-blob-eye-hidden`,ie;t[34]===re?ie=t[35]:(ie=k(`ok-blob-happy-eye`,re),t[34]=re,t[35]=ie);let ae;t[36]!==ne||t[37]!==ie?(ae=(0,$.jsx)(`path`,{d:ne,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ie}),t[36]=ne,t[37]=ie,t[38]=ae):ae=t[38];let oe;t[39]===S?oe=t[40]:(oe=S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`path`,{d:p_(c_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,$.jsx)(`path`,{d:p_(l_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[39]=S,t[40]=oe);let se;t[41]!==F||t[42]!==L||t[43]!==V||t[44]!==W||t[45]!==te||t[46]!==ae||t[47]!==oe?(se=(0,$.jsxs)(`g`,{className:L,children:[R,V,W,te,ae,oe]},F),t[41]=F,t[42]=L,t[43]=V,t[44]=W,t[45]=te,t[46]=ae,t[47]=oe,t[48]=se):se=t[48];let q;t[49]===S?q=t[50]:(q=S?(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,$.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[49]=S,t[50]=q);let ce;t[51]!==m||t[52]!==_?(ce=_.length>0&&(0,$.jsx)(`g`,{children:_.map(v_)},`firework-${m}`),t[51]=m,t[52]=_,t[53]=ce):ce=t[53];let le;return t[54]!==w||t[55]!==o||t[56]!==P||t[57]!==se||t[58]!==q||t[59]!==ce?(le=(0,$.jsxs)(`svg`,{ref:l,width:o,height:o,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:P,"aria-hidden":`true`,onClick:w,children:[se,q,ce]}),t[54]=w,t[55]=o,t[56]=P,t[57]=se,t[58]=q,t[59]=ce,t[60]=le):le=t[60],le}function v_(e){return(0,$.jsx)(`circle`,{cx:m_+e.originDx,cy:h_+e.originDy,r:e.size,className:`ok-blob-firework`,style:g_(e)},e.id)}function y_(e){return e+1}function b_(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 x_(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 S_(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 C_=960,w_=1024;function T_(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(D_),[r,i]=(0,Z.useState)(E_),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${C_-1}px)`),t=window.matchMedia(`(max-width: ${w_-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 E_(){return window.innerWidth>=C_&&window.innerWidth<w_}function D_(){return window.innerWidth<C_?`sheet`:`panel`}var O_=Ye;function k_(){let[e]=(0,Z.useState)(s);return e}function A_(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 j_=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():A_(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()}},M_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new j_({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?[M_({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 N_=b(pe(),1),P_=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()}},F_=e=>new xe({key:typeof e.pluginKey==`string`?new r(e.pluginKey):e.pluginKey,view:t=>new P_({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?[F_({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 I_(e,t){return e??new r(t)}var L_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,R_=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),z_=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(`.`)),B_=new Set([`children`,`className`,`style`]),V_=new Set([`tabIndex`]),H_=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),U_={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function W_(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function G_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function K_(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||H_.has(e)}function q_(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function J_(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:U_[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function Y_(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 X_(e){return V_.has(e)}function Z_(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function Q_(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 $_(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||z_.has(e)?String(t):`${t}px`}function ev(e,t){R_.has(t)||e.style.removeProperty(q_(t))}function tv(e,t,n){R_.has(t)||e.style.setProperty(q_(t),$_(t,n))}function nv(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(B_.has(r)||!K_(r)||W_(r,t[r])||W_(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=G_(r);if(a==null||a===!1){X_(r)&&Q_(e,r),e.removeAttribute(o);return}if(a===!0){X_(r)&&Z_(e,r,!0),e.setAttribute(o,``);return}if(X_(r)){Z_(e,r,a);return}e.setAttribute(o,String(a))})}function rv(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function iv(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){ev(e,t);return}tv(e,t,a)}})}function av(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(!W_(t,n))return;let{eventName:i,options:a}=J_(t),o=t=>{n(Y_(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function ov(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);L_(()=>{let i=n.current;return rv(e,i.className,t.className),iv(e,i.style,t.style),nv(e,i,t),r.current=av(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 sv=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)(I_(e,`bubbleMenu`)).current;ov(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=M_({...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,N_.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)(I_(e,`floatingMenu`)).current;ov(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=F_({...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,N_.createPortal)(s,u.current)});function cv(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 lv=[{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 uv(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:dv},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=lv.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 dv(e){let t=Object.fromEntries(lv.map(t=>[t.name,t.isActive(e.editor)]));return{current:lv.find(e=>t[e.name])??lv[0],activeStates:t}}var fv=[{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 pv(e){let t=(0,Q.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:mv},t[0]=n,t[1]=r);let i=Ut(r),a;t[2]!==i||t[3]!==n?(a=fv.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 mv(e){return Object.fromEntries(fv.map(t=>[t.name,t.isActive(e.editor)]))}function hv(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 gv({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 _v(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(bv)}))},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(yv)},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)(uv,{editor:n}),t[9]=n,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(cv,{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)(pv,{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)(cv,{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)(hv,{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)(sv,{ref:r,editor:n,appendTo:vv,shouldShow:gv,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 vv(){return document.body}function yv(e){return e+1}function bv(){}var xv=[{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()}],Sv=[{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()}],Cv=[{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 wv({editor:e}){return e.isActive(`table`)}function Tv(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 Ev(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=xv.map(e=>(0,$.jsx)(Tv,{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)(cv,{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=Sv.map(e=>(0,$.jsx)(Tv,{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)(cv,{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=Cv.map(e=>(0,$.jsx)(Tv,{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)(sv,{editor:n,shouldShow:wv,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 Dv=new WeakMap;function Ov(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 kv={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},Av=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)(kv),s=k_(),[c]=(0,Z.useState)(jv),[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;Dv.set(n,t)},onCreate:e=>{let{editor:t}=e,r=Dv.get(t);if(Dv.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),O_.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:Ov})]}})]}),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),Mv},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=Nv,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(kv);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)(_v,{editor:l}),t[41]=l,t[42]=N);let P;t[43]===l?P=t[44]:(P=l&&(0,$.jsx)(Ev,{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 jv(){let e=new ve({extensions:f});return{mdManager:e,text:Mn({mdManager:e}),html:En({mdManager:e}),paste:gn({mdManager:e})}}function Mv(){return tn(null)}function Nv(){return xt()}function Pv(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 Fv=(0,Z.createContext)(null),Iv={didCatch:!1,error:null},Lv=class extends Z.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Iv}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(Iv))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&Rv(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(Iv))}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)(Fv.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function Rv(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var zv=`__back-nav__`;function Bv(e){return e instanceof Ot||e instanceof Yt||e instanceof Vn||e instanceof Tt?e.docName:null}function Vv(e){return e instanceof Ot?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof Yt?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Vn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Tt?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function Hv(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=Vv(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(__,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,$.jsx)(`h2`,{id:`document-error-title`,className:`text-lg font-medium`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(q,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,$.jsx)(q,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(Et(Bv(n)??i),o(a),r(zv))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,$.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,$.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function Uv(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)(Hv,{...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]===zv){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}: ${Vv(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)(Lv,{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 Wv(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 Gv(){return Sn(()=>import(`./SourceEditor-BKyWQ7mW.js`),__vite__mapDeps([4,1,2,5,6,7,8]))}var Kv=(0,Z.lazy)(async()=>({default:(await Gv()).SourceEditor}));function qv(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 Jv(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)(Yv,{...e})}),t[0]=e,t[1]=n),n}function Yv(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=qv(c,n,3),f=(0,Z.useRef)(``),p=d.map(Xv).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)($v,{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 Xv(e){return e.docName}function Zv(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 Qv(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)(Kv,{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 $v(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 _=Wv({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)(Qv,{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)(Av,{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)(Pv,{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)(Uv,{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)(Zv,{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 ey(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)(ty,{...e})}),t[0]=e,t[1]=n),n}function ty(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:_}=T_(),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=ry;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)(__,{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(ny):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)(Jv,{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)(x_,{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)(S_,{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)(x_,{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)(b_,{orientation:`horizontal`,children:[pe,he,ve]})}),t[90]=pe,t[91]=ve,t[92]=ye):ye=t[92],ye}function ny(e){return!e}function ry(e){return e.replace(/\r\n/g,`
|
|
17
|
+
`).replace(/[ \t]+$/gm,``).trimEnd()}function iy(e,t){let n=t.trim();return e===`file`?n.replace(/\.md$/i,``):n}function ay(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function oy(e,t){let n=iy(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function sy(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 cy(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function ly(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var uy=1280;function dy(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(fy),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${uy-1}px)`),t=()=>{n(window.innerWidth<uy)};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 fy(){return window.innerWidth<uy}var py=`sidebar_state`,my=3600*24*7,hy=`18rem`,gy=`18rem`,_y=`3rem`,vy=`\\`,yy=Z.createContext(null);function by(){let e=Z.use(yy);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function xy(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=dy(),[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=`${py}=${t}; path=/; max-age=${my}`},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(Cy):_(Sy)},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===vy&&(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":hy,"--sidebar-width-icon":_y,...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)(yy.Provider,{value:C,children:D}),t[33]=D,t[34]=C,t[35]=O):O=t[35],O}function Sy(e){return!e}function Cy(e){return!e}function wy(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}=by();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":gy},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 Ty(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}=by(),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 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(`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 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-header`,"data-sidebar":`header`,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(`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 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(`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 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(`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 jy(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 My=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 Ny(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}=by(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=k(My({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 Py(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 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(`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 Iy(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`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 Ly(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 Ry(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 zy(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 By(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 Vy(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 Hy(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 Uy(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 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)(Jc,{"data-slot":`popover`,...n}),t[2]=n,t[3]=r),r}function Gy(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 Ky(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 qy(e){return typeof e==`object`&&!!e&&typeof e.getStates==`function`}function Jy(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 Yy(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 Xy=1e3,Zy=!1;function Qy(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 $y(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:qy(i)?a=i:(a=void 0,Zy||(Zy=!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?Jy(a,n,Date.now()):{current:[],crossDoc:[]},s=eb,c=t.map(s),l=i.map(s),u=[...e,...c],d=l;o(e=>Qy(e.current,u)&&Qy(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,Xy);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 eb(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function tb(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`?nb: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 nb(e){return e===`synced`?`synced`:`connected`}var rb=`sync-status`;function ib(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:rb,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:rb,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 ab(e){window.location.hash=me(e)}var ob=4,sb=3,cb={Bird:Ar,Cat:Pr,Dog:Yr,Fish:Qr,Mouse:wi,Rabbit:Ci,Shrimp:Ai,Snail:ji,Squirrel:Fi,Turtle:Bi},lb={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function ub(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)(Ry,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,$.jsx)(Hy,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,$.jsx)(Uy,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,$.jsx)(By,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,$.jsx)(zy,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,$.jsx)(Vy,{...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 db(e){let t=(0,Q.c)(20),{user:n,mode:r}=e,i=n.name.split(` `)[1],a=i?cb[i]:void 0,o;t[0]===n.name?o=t[1]:(o=n.name.split(` `).map(fb).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 fb(e){return e[0]}function pb(e){let t=lb[e.icon];return e.displayName||t||`Agent`}function mb(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 hb(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=pb(a),t[0]=a,t[1]=o);let s=o,c=r&&a.currentDoc!==null,l=mb(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)(ub,{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)(ub,{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 gb(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)(Gy,{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)(db,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(hb,{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)(Ky,{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)(Wy,{children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],d}function _b(e,t,n){return e.kind===`human`?(0,$.jsx)(db,{user:e.user,mode:e.mode},e.clientId):(0,$.jsx)(hb,{participant:e,crossDoc:n,onNavigate:t},e.agentId)}function vb(){let e=(0,Q.c)(12),{activeProvider:t,activeDocName:n,systemProvider:r}=Hn(),{current:i,crossDoc:a}=$y(t,r,n);ib(tb(t),n);let o;if(e[0]!==a||e[1]!==i){let t=i.slice(0,ob),n;e[3]===i?n=e[4]:(n=i.slice(ob),e[3]=i,e[4]=n);let r=n,s=a.slice(0,sb),c;e[5]===a?c=e[6]:(c=a.slice(sb),e[5]=a,e[6]=c);let l=c,u=t.map(bb),d;e[7]===r?d=e[8]:(d=r.length>0?(0,$.jsx)(gb,{count:r.length,remainder:r,crossDoc:!1,onNavigate:ab}):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(yb),l.length>0?(0,$.jsx)(gb,{count:l.length,remainder:l,crossDoc:!0,onNavigate:ab}):null]})]}):null]}),e[0]=a,e[1]=i,e[2]=o}else o=e[2];return o}function yb(e){return _b(e,ab,!0)}function bb(e){return _b(e,ab,!1)}function xb(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 Sb(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 Cb=[{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:Sb},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:xb}],wb=()=>{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)(Gy,{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)(Wy,{children:[t,(0,$.jsxs)(Ky,{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:Cb.map(Tb)})})]})]}),e[2]=r):r=e[2],r};function Tb(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 Eb=`https://github.com/inkeep/open-knowledge/releases`;function Db(e){let{target:t,installState:n,isElectronHost:r}=e;return t.id===`cursor`&&!r?`Desktop only`:n.installed===null?`Detecting…`:n.installed===!1?`Not installed`:null}function Ob(e){let{target:t,installState:n,isElectronHost:r}=e;if(t.id===`cursor`&&!r)return{enabled:!1,tooltip:{message:`Cursor handoff requires the desktop build.`,installAction:{label:`Install the Open Knowledge desktop app →`,url:Eb}}};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 kb(e){return od(e)}function Ab(e){return`Opened ${e} in your browser.`}function jb(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??Nb,l=e.onWebFallbackError??Mb,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=Ob({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=Db({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(kb(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 Mb(){}function Nb(){}function Pb(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=Ib,u=Fb,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)(jb,{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 Fb(e){X.error(`Couldn't open ${e.displayName} in your browser.`)}function Ib(e){X.success(Ab(e.displayName))}var Lb={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`},Rb=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`,...Lb,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},zb=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)(Rb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Bb=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)(Rb,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},Vb=(e,t,n)=>qi(e,t,n,`ProjectSwitcher`);function Hb(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 Vb(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),Vb(()=>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),Vb(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 Ub(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 Wb(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 Gb(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function Kb(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 qb(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 Jb(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 Yb(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 Xb(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 Zb(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`}`:Yb(e.state):`Sync off`}function Qb(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 Kb(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)(qb,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=Yb(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)(Ub,{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:Xb(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: `,Wb(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:ex,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:$b,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 $b(){Gb(`sync`)}function ex(){Gb(`sync`)}function tx(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=Jb(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=Yb(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)(qb,{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)(Gy,{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]:(_=Zb(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)(Ky,{align:`end`,className:`w-64 p-3`,children:(0,$.jsx)(Qb,{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)(Wy,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var nx=[{value:`light`,label:`Light`,icon:Li},{value:`dark`,label:`Dark`,icon:pi},{value:`system`,label:`System`,icon:Wr}],rx=()=>{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=nx.map(ix),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 ix(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 ax(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function ox(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(ax)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function sx(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}=by(),E=cd(),D=tb(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=iy(`file`,te),n=e.split(`/`),r=n[n.length-1];if(t===r){be();return}if(t===de.current)return;if(!ay(t)){ie(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=oy({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||!ox(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=ly(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)(Ty,{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)(cv,{orientation:`vertical`,className:`mx-1 h-4 shrink-0 data-vertical:self-center`}),(0,$.jsx)(Hb,{bridge:window.okDesktop})]}):null,Ae=(0,$.jsx)(cv,{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)(Bb,{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)(zb,{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)(Pb,{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)(tx,{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)(vb,{}),We=(0,$.jsx)(cv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ge=(0,$.jsx)(wb,{}),Ke=(0,$.jsx)(rx,{}),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 cx(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 lx(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 ux(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 dx(e){let t=ux(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 fx(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(px),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)(_x,{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 px(e){return!e}function mx(e){return e.checkpoint?e.checkpoint.kind:`save`}function hx(e){let t=mx(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${gx(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function gx(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function _x(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=cx(n.timestamp),t[0]=n.timestamp,t[1]=s);let c=s,l;t[2]===n?l=t[3]:(l=lx(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(vx);_=`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=mx(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:dx(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:hx(n)}),dx(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 vx(e){return e.docs}function yx(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(xx),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(bx)}),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)(_x,{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)(_x,{entry:e.entry,selected:e.entry.sha===o,onSelect:a,prominent:!0},e.entry.sha):(0,$.jsx)(fx,{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 bx(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 xx(e){return e.type===`checkpoint`}function Sx(){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(Cx),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)(sx,{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: `,cx(h.timestamp),` — `,lx(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)(ey,{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)(yx,{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 Cx(e){return!e}var wx=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Tx(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Ex(e){return`nodeType`in e}function Dx(e){return e?Tx(e)?e:Ex(e)?e.ownerDocument?.defaultView??window:window:window}function Ox(e){let{Document:t}=Dx(e);return e instanceof t}function kx(e){return Tx(e)?!1:e instanceof Dx(e).HTMLElement}function Ax(e){return e instanceof Dx(e).SVGElement}function jx(e){return e?Tx(e)?e.document:Ex(e)?Ox(e)?e:kx(e)||Ax(e)?e.ownerDocument:document:document:document}var Mx=wx?Z.useLayoutEffect:Z.useEffect;function Nx(e){let t=(0,Z.useRef)(e);return Mx(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Px(){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 Fx(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return Mx(()=>{n.current!==e&&(n.current=e)},t),n}function Ix(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Lx(e){let t=Nx(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Rx(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var zx={};function Bx(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=zx[e]==null?0:zx[e]+1;return zx[e]=n,e+`-`+n},[e,t])}function Vx(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 Hx=Vx(1),Ux=Vx(-1);function Wx(e){return`clientX`in e&&`clientY`in e}function Gx(e){if(!e)return!1;let{KeyboardEvent:t}=Dx(e.target);return t&&e instanceof t}function Kx(e){if(!e)return!1;let{TouchEvent:t}=Dx(e.target);return t&&e instanceof t}function qx(e){if(Kx(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Wx(e)?{x:e.clientX,y:e.clientY}:null}var Jx=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[Jx.Translate.toString(e),Jx.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Yx=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Xx(e){return e.matches(Yx)?e:e.querySelector(Yx)}var Zx={display:`none`};function Qx(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:Zx},n)}function $x(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 eS(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var tS=(0,Z.createContext)(null);function nS(e){let t=(0,Z.useContext)(tS);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function rS(){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 iS={draggable:`
|
|
18
18
|
To pick up a draggable item, press the space bar.
|
|
19
19
|
While dragging, use the arrow keys to move the item.
|
|
20
20
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
21
|
-
`},iS={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function aS(e){let{announcements:t=iS,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=rS}=e,{announce:a,announcement:o}=$x(),s=zx(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),tS((0,Z.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=Z.createElement(Z.Fragment,null,Z.createElement(Zx,{id:r,value:i.draggable}),Z.createElement(Qx,{id:s,announcement:o}));return n?(0,M_.createPortal)(u,n):u}var oS;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(oS||={});function sS(){}function cS(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function lS(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var uS=Object.freeze({x:0,y:0});function dS(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function fS(e,t){let n=Kx(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function pS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function mS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function hS(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function gS(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function _S(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var vS=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=_S(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(mS)};function yS(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var bS=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&yS(r,a)){let n=hS(a).reduce((e,t)=>e+dS(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(pS)};function xS(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function SS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:uS}function CS(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var wS=CS(1);function TS(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ES(e,t,n){let r=TS(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var DS={ignoreTransform:!1};function OS(e,t){t===void 0&&(t=DS);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Ex(e).getComputedStyle(e);t&&(n=ES(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function kS(e){return OS(e,{ignoreTransform:!0})}function AS(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function jS(e,t){return t===void 0&&(t=Ex(e).getComputedStyle(e)),t.position===`fixed`}function MS(e,t){t===void 0&&(t=Ex(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function NS(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Dx(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ox(i)||kx(i)||n.includes(i))return n;let a=Ex(e).getComputedStyle(i);return i!==e&&MS(i,a)&&n.push(i),jS(i,a)?n:r(i.parentNode)}return e?r(e):n}function PS(e){let[t]=NS(e,1);return t??null}function FS(e){return!Cx||!e?null:wx(e)?e:Tx(e)?Dx(e)||e===Ax(e).scrollingElement?window:Ox(e)?e:null:null}function IS(e){return wx(e)?e.scrollX:e.scrollLeft}function LS(e){return wx(e)?e.scrollY:e.scrollTop}function RS(e){return{x:IS(e),y:LS(e)}}var zS;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(zS||={});function BS(e){return!Cx||!e?!1:e===document.scrollingElement}function VS(e){let t={x:0,y:0},n=BS(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var HS={x:.2,y:.2};function US(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=HS);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=VS(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=zS.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=zS.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=zS.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=zS.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function WS(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function GS(e){return e.reduce((e,t)=>Vx(e,RS(t)),uS)}function KS(e){return e.reduce((e,t)=>e+IS(t),0)}function qS(e){return e.reduce((e,t)=>e+LS(t),0)}function JS(e,t){if(t===void 0&&(t=OS),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);PS(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var YS=[[`x`,[`left`,`right`],KS],[`y`,[`top`,`bottom`],qS]],XS=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=NS(t),r=GS(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of YS)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},ZS=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function QS(e){let{EventTarget:t}=Ex(e);return e instanceof t?e:Ax(e)}function $S(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var eC;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(eC||={});function tC(e){e.preventDefault()}function nC(e){e.stopPropagation()}var rC;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(rC||={});var iC={start:[rC.Space,rC.Enter],cancel:[rC.Esc],end:[rC.Space,rC.Enter,rC.Tab]},aC=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case rC.Right:return{...n,x:n.x+25};case rC.Left:return{...n,x:n.x-25};case rC.Down:return{...n,y:n.y+25};case rC.Up:return{...n,y:n.y-25}}},oC=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new ZS(Ax(t)),this.windowListeners=new ZS(Ex(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(eC.Resize,this.handleCancel),this.windowListeners.add(eC.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(eC.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&JS(n),t(uS)}handleKeyDown(e){if(Wx(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=iC,coordinateGetter:a=aC,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:uS;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Hx(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=VS(n),p=WS(n),m={x:Math.min(i===rC.Right?p.right-p.width/2:p.right,Math.max(i===rC.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===rC.Down?p.bottom-p.height/2:p.bottom,Math.max(i===rC.Down?p.top:p.top+p.height/2,u.y))},h=i===rC.Right&&!s||i===rC.Left&&!c,g=i===rC.Down&&!l||i===rC.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===rC.Right&&e<=d.x||i===rC.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===rC.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===rC.Down&&e<=d.y||i===rC.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===rC.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Vx(Hx(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};oC.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=iC,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function sC(e){return!!(e&&`distance`in e)}function cC(e){return!!(e&&`delay`in e)}var lC=class{constructor(e,t,n){n===void 0&&(n=QS(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Ax(i),this.documentListeners=new ZS(this.document),this.listeners=new ZS(n),this.windowListeners=new ZS(Ex(i)),this.initialCoordinates=Kx(r)??uS,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(eC.Resize,this.handleCancel),this.windowListeners.add(eC.DragStart,tC),this.windowListeners.add(eC.VisibilityChange,this.handleCancel),this.windowListeners.add(eC.ContextMenu,tC),this.documentListeners.add(eC.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cC(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(sC(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(eC.Click,nC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(eC.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Kx(e)??uS,s=Hx(n,o);if(!t&&a){if(sC(a)){if(a.tolerance!=null&&$S(s,a.tolerance))return this.handleCancel();if($S(s,a.distance))return this.handleStart()}if(cC(a)&&$S(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===rC.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},uC={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},dC=class extends lC{constructor(e){let{event:t}=e,n=Ax(t.target);super(e,uC,n)}};dC.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var fC={move:{name:`mousemove`},end:{name:`mouseup`}},pC;(function(e){e[e.RightClick=2]=`RightClick`})(pC||={});var mC=class extends lC{constructor(e){super(e,fC,Ax(e.event.target))}};mC.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===pC.RightClick?!1:(r?.({event:n}),!0)}}];var hC={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},gC=class extends lC{constructor(e){super(e,hC)}static setup(){return window.addEventListener(hC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(hC.move.name,e)};function e(){}}};gC.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var _C;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(_C||={});var vC;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(vC||={});function yC(e){let{acceleration:t,activator:n=_C.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=vC.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=xC({delta:d,disabled:!a}),[m,h]=Nx(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case _C.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _C.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,Z.useMemo)(()=>s===vC.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=US(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var bC={x:{[zS.Backward]:!1,[zS.Forward]:!1},y:{[zS.Backward]:!1,[zS.Forward]:!1}};function xC(e){let{delta:t,disabled:n}=e,r=Lx(t);return Fx(e=>{if(n||!r||!e)return bC;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[zS.Backward]:e.x[zS.Backward]||i.x===-1,[zS.Forward]:e.x[zS.Forward]||i.x===1},y:{[zS.Backward]:e.y[zS.Backward]||i.y===-1,[zS.Forward]:e.y[zS.Forward]||i.y===1}}},[n,t,r])}function SC(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Fx(e=>t==null?null:r??e??null,[r,t])}function CC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var wC;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(wC||={});var TC;(function(e){e.Optimized=`optimized`})(TC||={});var EC=new Map;function DC(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=Px(d),p=(0,Z.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,Z.useRef)(null),h=Fx(t=>{if(d&&!n)return EC;if(!t||t===EC||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new XS(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case wC.Always:return!1;case wC.BeforeDragging:return n;default:return!n}}}function OC(e,t){return Fx(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function kC(e,t){return OC(e,t)}function AC(e){let{callback:t,disabled:n}=e,r=Mx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function jC(e){let{callback:t,disabled:n}=e,r=Mx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function MC(e){return new XS(OS(e),e)}function NC(e,t,n){t===void 0&&(t=MC);let[r,i]=(0,Z.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=AC({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=jC({callback:a});return jx(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function PC(e){return SS(e,OC(e))}var FC=[];function IC(e){let t=(0,Z.useRef)(e),n=Fx(n=>e?n&&n!==FC&&e&&t.current&&e.parentNode===t.current.parentNode?n:NS(e):FC,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function LC(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=FS(e.target);t&&n(e=>e?(e.set(t,RS(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=FS(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,RS(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{FS(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Vx(e,t),uS):GS(e):uS,[e,t])}function RC(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==uS;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Hx(e,n.current):uS}function zC(e){(0,Z.useEffect)(()=>{if(!Cx)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function BC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function VC(e){return(0,Z.useMemo)(()=>e?AS(e):null,[e])}var HC=[];function UC(e,t){t===void 0&&(t=OS);let[n]=e,r=VC(n?Ex(n):null),[i,a]=(0,Z.useState)(HC);function o(){a(()=>e.length?e.map(e=>BS(e)?r:new XS(t(e),e)):HC)}let s=jC({callback:o});return jx(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function WC(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Ox(t)?t:e}function GC(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=jC({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(Ox(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Ix((0,Z.useCallback)(e=>{let n=WC(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var KC=[{sensor:dC,options:{}},{sensor:oC,options:{}}],qC={current:{}},JC={draggable:{measure:kS},droppable:{measure:kS,strategy:wC.WhileDragging,frequency:TC.Optimized},dragOverlay:{measure:OS}},YC=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},XC={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new YC,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:sS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:JC,measureDroppableContainers:sS,windowRect:null,measuringScheduled:!1},ZC={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:sS,draggableNodes:new Map,over:null,measureDroppableContainers:sS},QC=(0,Z.createContext)(ZC),$C=(0,Z.createContext)(XC);function ew(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new YC}}}function tw(e,t){switch(t.type){case oS.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case oS.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case oS.DragEnd:case oS.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case oS.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new YC(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case oS.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new YC(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case oS.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new YC(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function nw(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(QC),a=Lx(r),o=Lx(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Wx(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Yx(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function rw(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function iw(e){return(0,Z.useMemo)(()=>({draggable:{...JC.draggable,...e?.draggable},droppable:{...JC.droppable,...e?.droppable},dragOverlay:{...JC.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function aw(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;jx(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=SS(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=PS(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var ow=(0,Z.createContext)({...uS,scaleX:1,scaleY:1}),sw;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(sw||={});var cw=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=KC,collisionDetection:o=vS,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(tw,void 0,ew),[f,p]=nS(),[m,h]=(0,Z.useState)(sw.Uninitialized),g=m===sw.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??qC,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=Px(l,Object.values(l)),A=zx(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=iw(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=DC(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=SC(v,_),L=(0,Z.useMemo)(()=>D?Kx(D):null,[D]),R=xe(),z=kC(I,M.draggable.measure);aw({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=NC(I,M.draggable.measure,z),V=NC(I?I.parentElement:null),H=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),U=b.getNodeFor(H.current.over?.id),W=GC({measure:M.dragOverlay.measure}),G=W.nodeRef.current??I,K=g?W.rect??B:null,ee=!!(W.nodeRef.current&&W.rect),te=PC(ee?null:B),ne=VC(G?Ex(G):null),re=IC(g?U??I:null),ie=UC(re),ae=rw(c,{transform:{x:y.x-te.x,y:y.y-te.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:K,over:H.current.over,overlayNodeRect:W.rect,scrollableAncestors:re,scrollableAncestorRects:ie,windowRect:ne}),oe=L?Vx(L,y):null,se=LC(re),q=RC(se),ce=RC(se,[B]),le=Vx(ae,q),ue=K?wS(K,ae):null,de=C&&ue?o({active:C,collisionRect:ue,droppableRects:N,droppableContainers:j,pointerCoordinates:oe}):null,fe=gS(de,`id`),[pe,me]=(0,Z.useState)(null),he=xS(ee?ae:Vx(ae,ce),pe?.rect??null,B),ge=(0,Z.useRef)(null),_e=(0,Z.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;ge.current=new n({active:w.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,M_.unstable_batchedUpdates)(()=>{r?.(i),h(sw.Initializing),d({type:oS.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(ge.current),O(a)})},onMove(e){d({type:oS.DragMove,coordinates:e})},onEnd:o(oS.DragEnd),onCancel:o(oS.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===oS.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=oS.DragCancel)}w.current=null,(0,M_.unstable_batchedUpdates)(()=>{d({type:e}),h(sw.Uninitialized),me(null),E(null),O(null),ge.current=null;let t=e===oS.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ve=CC(a,(0,Z.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,_e(n,t))},[v,_e]));zC(a),jx(()=>{B&&m===sw.Initializing&&h(sw.Initialized)},[B,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:le.x,y:le.y},over:i};(0,M_.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[le.x,le.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(fe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,M_.unstable_batchedUpdates)(()=>{me(s),a?.(c),f({type:`onDragOver`,event:c})})},[fe]),jx(()=>{H.current={activatorEvent:D,active:C,activeNode:I,collisionRect:ue,collisions:de,droppableRects:N,draggableNodes:v,draggingNode:G,draggingNodeRect:K,droppableContainers:b,over:pe,scrollableAncestors:re,scrollAdjustedTranslate:le},S.current={initial:K,translated:ue}},[C,I,de,ue,v,G,K,N,b,pe,re,le]),yC({...R,delta:y,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:re,scrollableAncestorRects:ie});let ye=(0,Z.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:de,containerNodeRect:V,dragOverlay:W,draggableNodes:v,droppableContainers:b,droppableRects:N,over:pe,measureDroppableContainers:P,scrollableAncestors:re,scrollableAncestorRects:ie,measuringConfiguration:M,measuringScheduled:F,windowRect:ne}),[C,I,B,D,de,V,W,v,b,N,pe,P,re,ie,M,F,ne]),be=(0,Z.useMemo)(()=>({activatorEvent:D,activators:ve,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:pe,measureDroppableContainers:P}),[D,ve,C,B,d,A,v,pe,P]);return Z.createElement(eS.Provider,{value:p},Z.createElement(QC.Provider,{value:be},Z.createElement($C.Provider,{value:ye},Z.createElement(ow.Provider,{value:he},i)),Z.createElement(nw,{disabled:n?.restoreFocus===!1})),Z.createElement(aS,{...n,hiddenTextDescribedById:A}));function xe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),lw=(0,Z.createContext)(null),uw=`button`,dw=`Draggable`;function fw(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=zx(dw),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(QC),{role:p=uw,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?ow:lw),[v,y]=Ix(),[b,x]=Ix(),S=BC(o,t),C=Px(n);return jx(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===uw?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function pw(){return(0,Z.useContext)($C)}var mw=`Droppable`,hw={timeout:25};function gw(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=zx(mw),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(QC),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...hw,...i},_=Px(h??r),v=jC({callback:(0,Z.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Ix((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Px(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:oS.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:oS.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:oS.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function _w(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=Lx(n);return!n&&!r&&s&&i(s),jx(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var vw={x:0,y:0,scaleX:1,scaleY:1};function yw(e){let{children:t}=e;return Z.createElement(QC.Provider,{value:ZC},Z.createElement(ow.Provider,{value:vw},t))}var bw={position:`fixed`,touchAction:`none`},xw=e=>Wx(e)?`transform 250ms ease`:void 0,Sw=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=xw}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...bw,width:s.width,height:s.height,top:s.top,left:s.left,transform:qx.Transform.toString(d),transformOrigin:i&&r?fS(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Cw={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:qx.Transform.toString(t)},{transform:qx.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function ww(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Mx((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=WC(a);if(!c)return;let{transform:l}=Ex(a).getComputedStyle(a),u=TS(l);if(!u)return;let d=typeof t==`function`?t:Tw(t);return JS(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Tw(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Cw,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Ew=0;function Dw(e){return(0,Z.useMemo)(()=>{if(e!=null)return Ew++,Ew},[e])}var Ow=Z.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=pw(),S=(0,Z.useContext)(ow),C=Dw(d?.id),w=rw(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=OC(f),E=ww({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(yw,null,Z.createElement(_w,{animation:E},d&&C?Z.createElement(Sw,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function kw(e){let t=(0,Q.c)(20),{itemName:n,isSubmitting:r,onDelete:i,customTitle:a,customDescription:o,children:s}=e,c=n===void 0?`this item`:n,l=a??`Delete ${c}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(pn,{children:l}),t[0]=l,t[1]=u);let d=o??`Are you sure you want to delete ${c}? This action cannot be undone.`,f;t[2]===d?f=t[3]:(f=(0,$.jsx)(dn,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,disabled:r,children:`Cancel`})}),t[4]=r,t[5]=p);let m;t[6]===r?m=t[7]:(m=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(an,{className:`size-4 animate-spin`}),` Deleting...`]}):`Delete`,t[6]=r,t[7]=m);let h;t[8]!==r||t[9]!==i||t[10]!==m?(h=(0,$.jsx)(q,{variant:`destructive`,onClick:i,disabled:r,children:m}),t[8]=r,t[9]=i,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==h?(g=(0,$.jsxs)(wn,{children:[p,h]}),t[12]=p,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==s||t[16]!==u||t[17]!==f||t[18]!==g?(_=(0,$.jsxs)(In,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function Aw(e){let t=e.lastIndexOf(`/`);return t<=0?``:e.slice(0,t)}function jw(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Mw(e,t){return e?`${e}/${t}`:t}function Nw(e,t){return Mw(t,jw(e.path))}function Pw(e,t){if(e.kind===`folder`){if(t===e.path)return{ok:!1,reason:`self`};if(t.length>e.path.length&&t.startsWith(`${e.path}/`))return{ok:!1,reason:`descendant`}}let n=Nw(e,t);return n===e.path?{ok:!1,reason:`no_op`}:{ok:!0,destinationPath:n}}function Fw(e,t){if(!e)return{selectedFilePath:t,selectedFolderPath:null,navigationPath:t};switch(e.kind){case`doc`:return{selectedFilePath:e.docName,selectedFolderPath:null,navigationPath:e.docName};case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function Iw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(vs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function Lw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(ys,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Rw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(ws,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function zw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(bs,{children:(0,$.jsx)(xs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Bw(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=k(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,$.jsx)(Ss,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Vw(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Lr,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(Ts,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Hw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Es,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Uw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Cs,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ww(e,t,n,r){return e.id===`cursor`&&!n?`Desktop only`:t.installed===null?`Detecting…`:t.installed===!1?`Not installed`:r?`No workspace`:null}function Gw(e){let t=(0,Q.c)(8),{input:n,installStates:r,isElectronHost:i,dispatch:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Vw,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=sd.map(e=>{let t=r[e.id],o=Db({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=Ww(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)(Bw,{disabled:!c,onSelect:()=>{!c||!n||a(e.id,n)},"data-testid":`file-tree-open-in-${e.id}`,"aria-label":u,children:[(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,e.displayName]}),l?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)}),t[1]=a,t[2]=n,t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsxs)(Rw,{children:[o,(0,$.jsx)(Hw,{children:s})]}),t[6]=s,t[7]=c),c}var Kw=80,qw=3,Jw=20,Yw=new Map,Xw=new Set,Zw=[],Qw=new Map;function $w(e){for(Qw.delete(e),Qw.set(e,!0);Qw.size>Jw;){let e=Qw.keys().next().value;if(e===void 0)break;Qw.delete(e)}}function eT(e){Xw.delete(e),tT()}function tT(){for(;Xw.size<qw&&Zw.length>0;){let e=Zw.shift();if(!e)break;if(!Qw.has(e.docName)){Xw.add(e.docName),$w(e.docName);try{e.prewarm(e.docName)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{eT(e.docName)}}}}function nT(e,t){if(yn(e)||Qw.has(e))return;let n=Yw.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(Yw.delete(e),Xw.size>=qw){Zw.push({docName:e,prewarm:t});return}$w(e),Xw.add(e);try{t(e)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{eT(e)}},Kw);Yw.set(e,{timer:r,prewarm:t})}function rT(e){let t=Yw.get(e);t&&(clearTimeout(t.timer),Yw.delete(e))}var iT=(0,Z.createContext)(null);function aT(){return(0,Z.use)(iT)}function oT(e){window.location.hash=me(e)}function sT(e){return e.kind===`file`?`${e.path}.md`:e.path}async function cT(e,t){try{await navigator.clipboard.writeText(e),X.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),X.error(`Could not copy ${t}`)}}var lT=new Set([`agents`,`agent`,`claude`,`skill`]);function uT(e){return e.kind===`file`&&lT.has(e.name.toLowerCase())}function dT(e){let t=(0,Q.c)(38),{kind:n,value:r,busy:i,error:a,onChange:o,onCommit:s,onCancel:c}=e,l=(0,Z.useRef)(null),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=setTimeout(()=>l.current?.focus(),0);return()=>clearTimeout(e)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,Z.useEffect)(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=k(`flex h-8 items-center gap-2 rounded-md px-2`),t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=n===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[3]=n,t[4]=p);let m=`Create new ${n}`,h=!!a,g=a?`inline-create-error`:void 0,_=n===`folder`?`folder-name`:`file-name`,v=a&&`border-destructive`,y;t[5]===v?y=t[6]:(y=k(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let b;t[7]!==i||t[8]!==a||t[9]!==c?(b=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=b):b=t[10];let x;t[11]===o?x=t[12]:(x=e=>o(e.target.value),t[11]=o,t[12]=x);let S;t[13]!==c||t[14]!==s?(S=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=S):S=t[15];let C;t[16]!==i||t[17]!==y||t[18]!==b||t[19]!==x||t[20]!==S||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(C=(0,$.jsx)(Mt,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:b,onChange:x,onKeyDown:S}),t[16]=i,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=C):C=t[26];let w;t[27]===n?w=t[28]:(w=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=w);let T;t[29]!==C||t[30]!==w||t[31]!==p?(T=(0,$.jsxs)(`div`,{className:f,children:[p,C,w]}),t[29]=C,t[30]=w,t[31]=p,t[32]=T):T=t[32];let E;t[33]===a?E=t[34]:(E=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=E);let D;return t[35]!==T||t[36]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37],D}function fT(e,t){if(!e)return``;let n=Pw(e,t);return!n.ok&&(n.reason===`self`||n.reason===`descendant`)?`bg-destructive/20 ring-2 ring-destructive/50`:n.ok?`bg-primary/10 ring-2 ring-primary/40`:``}function pT(e){let t=(0,Q.c)(11),{treeActionsLocked:n}=e,r=aT(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={destinationFolderPath:``},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a={id:`drop-root`,disabled:n,data:i},t[1]=n,t[2]=a);let{setNodeRef:o,isOver:s}=gw(a);if(!r)return null;let c;t[3]!==r||t[4]!==s?(c=s&&fT(r,``),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=k(`flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-xs text-muted-foreground transition-colors`,c),t[6]=c,t[7]=l);let u;return t[8]!==o||t[9]!==l?(u=(0,$.jsx)(Ay,{children:(0,$.jsx)(`div`,{ref:o,className:l,children:`Drop here to move to library root`})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}var mT=e=>{let t=(0,Q.c)(171),{node:n,nested:r,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:T,getInlineCreate:E}=e,D=r===void 0?!1:r,O=(0,Z.useRef)(!1),A=(0,Z.useRef)(null),j=n.kind===`file`,M=!j&&o.has(n.path),N=j?n.path===i:n.path===a,P=l===n.path,F,I;t[0]===P?(F=t[1],I=t[2]):(F=()=>{P&&requestAnimationFrame(()=>{let e=A.current;e&&(e.focus(),e.select())})},I=[P],t[0]=P,t[1]=F,t[2]=I),(0,Z.useEffect)(F,I);let L=d===n.path,R=d!==null,z=j?Nn:M?Dn:ti,B=D?Fy:Ay,V=D?Iy:My,H;t[3]!==n.kind||t[4]!==n.name||t[5]!==n.path?(H={kind:n.kind,path:n.path,name:n.name},t[3]=n.kind,t[4]=n.name,t[5]=n.path,t[6]=H):H=t[6];let U=H,W;t[7]!==j||t[8]!==n.path?(W=j?Aw(n.path):n.path,t[7]=j,t[8]=n.path,t[9]=W):W=t[9];let G=W,K=aT(),ee=`drag-${n.kind}-${n.path}`,te=f||P,ne;t[10]===U?ne=t[11]:(ne={source:U},t[10]=U,t[11]=ne);let re;t[12]!==ee||t[13]!==te||t[14]!==ne?(re={id:ee,disabled:te,data:ne},t[12]=ee,t[13]=te,t[14]=ne,t[15]=re):re=t[15];let{attributes:ie,listeners:ae,setNodeRef:oe,isDragging:se}=fw(re),q=`drop-${n.kind}-${n.path}`,ce;t[16]===G?ce=t[17]:(ce={destinationFolderPath:G},t[16]=G,t[17]=ce);let le;t[18]!==q||t[19]!==ce||t[20]!==f?(le={id:q,disabled:f,data:ce},t[18]=q,t[19]=ce,t[20]=f,t[21]=le):le=t[21];let{setNodeRef:ue,isOver:de}=gw(le),fe;t[22]!==c||t[23]!==N||t[24]!==oe||t[25]!==ue?(fe=e=>{oe(e),ue(e),N&&c(e)},t[22]=c,t[23]=N,t[24]=oe,t[25]=ue,t[26]=fe):fe=t[26];let pe=fe,me=de&&K?fT(K,G):``,he=j&&n.isSymlink,ge;t[27]===n?ge=t[28]:(ge=uT(n),t[27]=n,t[28]=ge);let _e=ge,ve;t[29]!==j||t[30]!==n.path||t[31]!==g?(ve=j?()=>{nT(n.path,e=>{g(e)})}:void 0,t[29]=j,t[30]=n.path,t[31]=g,t[32]=ve):ve=t[32];let ye=ve,be;t[33]!==j||t[34]!==n.path?(be=j?()=>{rT(n.path)}:void 0,t[33]=j,t[34]=n.path,t[35]=be):be=t[35];let xe=be,Se=N?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,Ce;t[36]!==z||t[37]!==Se?(Ce=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:Se}),t[36]=z,t[37]=Se,t[38]=Ce):Ce=t[38];let we=N?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,Te;t[39]===we?Te=t[40]:(Te=k(`min-w-0 flex-1 truncate text-sm`,we),t[39]=we,t[40]=Te);let J=n.name+(j?`.md`:``),Ee;t[41]!==Te||t[42]!==J?(Ee=(0,$.jsx)(`span`,{className:Te,children:J}),t[41]=Te,t[42]=J,t[43]=Ee):Ee=t[43];let De;t[44]!==n.canonicalDocName||t[45]!==n.targetPath||t[46]!==he?(De=he&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(ci,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)($e,{side:`right`,className:`text-center leading-relaxed`,children:[`Symlink → `,n.targetPath,(0,$.jsx)(`br`,{}),`Opens the same document as `,n.canonicalDocName]})]}),t[44]=n.canonicalDocName,t[45]=n.targetPath,t[46]=he,t[47]=De):De=t[47];let Oe;t[48]===_e?Oe=t[49]:(Oe=_e&&(0,$.jsx)(Nr,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[48]=_e,t[49]=Oe);let ke;t[50]!==Ce||t[51]!==Ee||t[52]!==De||t[53]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[Ce,Ee,De,Oe]}),t[50]=Ce,t[51]=Ee,t[52]=De,t[53]=Oe,t[54]=ke):ke=t[54];let Ae=ke,je=!D&&`ml-2`,Me=N&&`bg-sidebar-accent text-sidebar-accent-foreground`,Y;t[55]!==je||t[56]!==Me?(Y=k(`flex h-8 items-center gap-2 rounded-md px-2`,je,Me),t[55]=je,t[56]=Me,t[57]=Y):Y=t[57];let Ne;t[58]===z?Ne=t[59]:(Ne=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[58]=z,t[59]=Ne);let Pe=`Rename ${n.kind}`,Fe;t[60]===v?Fe=t[61]:(Fe=e=>v(e.target.value),t[60]=v,t[61]=Fe);let Ie;t[62]!==b||t[63]!==y||t[64]!==U?(Ie=e=>{e.key===`Enter`?(e.preventDefault(),y(U)):e.key===`Escape`&&(e.preventDefault(),b())},t[62]=b,t[63]=y,t[64]=U,t[65]=Ie):Ie=t[65];let Le;t[66]!==u||t[67]!==L||t[68]!==b||t[69]!==Pe||t[70]!==Fe||t[71]!==Ie?(Le=(0,$.jsx)(Mt,{ref:A,value:u,disabled:L,"aria-label":Pe,onBlur:b,onChange:Fe,onKeyDown:Ie,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[66]=u,t[67]=L,t[68]=b,t[69]=Pe,t[70]=Fe,t[71]=Ie,t[72]=Le):Le=t[72];let Re;t[73]===j?Re=t[74]:(Re=j&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[73]=j,t[74]=Re);let ze;t[75]!==Y||t[76]!==Ne||t[77]!==Le||t[78]!==Re?(ze=(0,$.jsxs)(`div`,{className:Y,children:[Ne,Le,Re]}),t[75]=Y,t[76]=Ne,t[77]=Le,t[78]=Re,t[79]=ze):ze=t[79];let Be=P?ze:j?(0,$.jsx)(V,{isActive:N,onClick:()=>h(n.path),className:`cursor-pointer`,"aria-current":N?`page`:void 0,children:Ae}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(V,{isActive:N,className:`w-full cursor-pointer pr-8`,"aria-current":N?`page`:void 0,onClick:()=>h(n.path),children:Ae}),(0,$.jsx)(Ny,{type:`button`,className:k(`top-1`,M&&`rotate-90`),"aria-label":`${M?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":M,onPointerDown:ST,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Lr,{className:`size-4 text-muted-foreground/50`})})]}),Ve=Iw,He=Lw,Ue=k(`rounded-md transition-[opacity,box-shadow] duration-150 ease-out`,se&&`opacity-40`,me),We=!P&&ae,Ge=!P&&ie,Ke;t[80]!==ye||t[81]!==xe||t[82]!==pe||t[83]!==Ue||t[84]!==We||t[85]!==Ge||t[86]!==Be?(Ke=(0,$.jsx)(`div`,{ref:pe,className:Ue,onMouseEnter:ye,onMouseLeave:xe,...We,...Ge,role:`presentation`,tabIndex:void 0,children:Be}),t[80]=ye,t[81]=xe,t[82]=pe,t[83]=Ue,t[84]=We,t[85]=Ge,t[86]=Be,t[87]=Ke):Ke=t[87];let qe;t[88]!==He||t[89]!==Ke?(qe=(0,$.jsx)(He,{asChild:!0,children:Ke}),t[88]=He,t[89]=Ke,t[90]=qe):qe=t[90];let Je;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>{O.current&&(O.current=!1,e.preventDefault())},t[91]=Je):Je=t[91];let Ye;t[92]!==R||t[93]!==j||t[94]!==n||t[95]!==w||t[96]!==C||t[97]!==S?(Ye=!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Bw,{disabled:R,onSelect:()=>{O.current=!0,S(`file`,n.path)},children:[(0,$.jsx)(Pi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)(Bw,{disabled:R,onSelect:()=>{O.current=!0,S(`folder`,n.path)},children:[(0,$.jsx)(ei,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(Uw,{}),(0,$.jsxs)(Bw,{onSelect:()=>C(n),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)(Bw,{onSelect:()=>w(n),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(Uw,{})]}),t[92]=R,t[93]=j,t[94]=n,t[95]=w,t[96]=C,t[97]=S,t[98]=Ye):Ye=t[98];let Xe;t[99]!==_||t[100]!==U?(Xe=()=>{O.current=!0,_(U)},t[99]=_,t[100]=U,t[101]=Xe):Xe=t[101];let Ze;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,$.jsx)(Ft,{"aria-hidden":`true`}),t[102]=Ze):Ze=t[102];let Qe;t[103]!==R||t[104]!==Xe?(Qe=(0,$.jsxs)(Bw,{disabled:R,onSelect:Xe,children:[Ze,`Rename`]}),t[103]=R,t[104]=Xe,t[105]=Qe):Qe=t[105];let et;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsxs)(Vw,{children:[(0,$.jsx)(Gr,{"aria-hidden":`true`}),`Copy Path`]}),t[106]=et):et=t[106];let tt=!p,nt;t[107]!==n||t[108]!==p?(nt=()=>{p&&cT(Sd(p.contentDir,sT(n),p.pathSeparator),`full path`)},t[107]=n,t[108]=p,t[109]=nt):nt=t[109];let rt;t[110]!==tt||t[111]!==nt?(rt=(0,$.jsx)(Bw,{disabled:tt,onSelect:nt,children:`Full Path`}),t[110]=tt,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]===n?it=t[114]:(it=(0,$.jsx)(Bw,{onSelect:()=>{cT(sT(n),`relative path`)},children:`Relative Path`}),t[113]=n,t[114]=it);let at;t[115]!==rt||t[116]!==it?(at=(0,$.jsxs)(Rw,{children:[et,(0,$.jsxs)(Hw,{children:[rt,it]})]}),t[115]=rt,t[116]=it,t[117]=at):at=t[117];let st;t[118]!==m||t[119]!==j||t[120]!==n.path||t[121]!==p?(st=j&&(0,$.jsx)(Gw,{input:wd({docName:n.path,workspace:p}),installStates:m.installStates,isElectronHost:m.isElectronHost,dispatch:m.dispatch}),t[118]=m,t[119]=j,t[120]=n.path,t[121]=p,t[122]=st):st=t[122];let ct;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(Uw,{}),t[123]=ct):ct=t[123];let lt;t[124]!==x||t[125]!==U?(lt=()=>{x(U)},t[124]=x,t[125]=U,t[126]=lt):lt=t[126];let ut;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(It,{"aria-hidden":`true`}),t[127]=ut):ut=t[127];let dt;t[128]!==R||t[129]!==lt?(dt=(0,$.jsxs)(Bw,{variant:`destructive`,disabled:R,onSelect:lt,children:[ut,`Delete`]}),t[128]=R,t[129]=lt,t[130]=dt):dt=t[130];let ft;t[131]!==Ye||t[132]!==Qe||t[133]!==at||t[134]!==st||t[135]!==dt?(ft=(0,$.jsxs)(zw,{onCloseAutoFocus:Je,children:[Ye,Qe,at,st,ct,dt]}),t[131]=Ye,t[132]=Qe,t[133]=at,t[134]=st,t[135]=dt,t[136]=ft):ft=t[136];let mt;t[137]!==Ve||t[138]!==qe||t[139]!==ft?(mt=(0,$.jsxs)(Ve,{children:[qe,ft]}),t[137]=Ve,t[138]=qe,t[139]=ft,t[140]=mt):mt=t[140];let ht;t[141]!==c||t[142]!==d||t[143]!==l||t[144]!==u||t[145]!==M||t[146]!==o||t[147]!==E||t[148]!==m||t[149]!==T||t[150]!==n.children||t[151]!==b||t[152]!==w||t[153]!==y||t[154]!==x||t[155]!==v||t[156]!==C||t[157]!==h||t[158]!==S||t[159]!==_||t[160]!==s||t[161]!==g||t[162]!==i||t[163]!==a||t[164]!==f||t[165]!==p?(ht=M&&(n.children.length>0||!!T)&&(0,$.jsxs)(Py,{className:`mr-0 pr-0`,children:[T&&(0,$.jsx)(Fy,{children:(0,$.jsx)(dT,{...T})}),n.children.map(e=>(0,$.jsx)(mT,{node:e,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:E(e.path),getInlineCreate:E,nested:!0},e.path))]}),t[141]=c,t[142]=d,t[143]=l,t[144]=u,t[145]=M,t[146]=o,t[147]=E,t[148]=m,t[149]=T,t[150]=n.children,t[151]=b,t[152]=w,t[153]=y,t[154]=x,t[155]=v,t[156]=C,t[157]=h,t[158]=S,t[159]=_,t[160]=s,t[161]=g,t[162]=i,t[163]=a,t[164]=f,t[165]=p,t[166]=ht):ht=t[166];let gt;return t[167]!==B||t[168]!==mt||t[169]!==ht?(gt=(0,$.jsxs)(B,{children:[mt,ht]}),t[167]=B,t[168]=mt,t[169]=ht,t[170]=gt):gt=t[170],gt};function hT(e){let t=(0,Q.c)(91),{ref:n}=e,{activeDocName:r,activeTarget:i,closeDocument:a,prewarm:o}=Hn(),{addPage:s}=Se(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(xT),[C,w]=(0,Z.useState)(bT),{selectedFilePath:T,selectedFolderPath:E,navigationPath:D}=Fw(i,r),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(null),B;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(B={activationConstraint:{distance:12}},t[1]=B):B=t[1];let V=lS(cS(dC,B)),[H,U]=(0,Z.useState)(null),{states:W}=Wd(),{dispatch:G}=Nd(),K=typeof window<`u`&&window.okDesktop!=null,ee;t[2]!==G||t[3]!==W?(ee={installStates:W,isElectronHost:K,dispatch:G},t[2]=G,t[3]=W,t[4]=ee):ee=t[4];let te=ee,ne=yT,re,ie;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(vT);e&&(t.ok&&n?.ok?(u(n.documents),m(null)):m(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&m(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&f(!1)});t();let n=()=>{document.visibilityState===`visible`&&t()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=ce(e=>{e.includes(`files`)&&t()});return()=>{e=!1,window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},ie=[],t[5]=re,t[6]=ie):(re=t[5],ie=t[6]),(0,Z.useEffect)(re,ie);let ae,oe;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(_T);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&U({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(gT),()=>{e=!1}},oe=[],t[7]=ae,t[8]=oe):(ae=t[7],oe=t[8]),(0,Z.useEffect)(ae,oe);let se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){j({kind:e,parentDir:t}),N(``),L(null),t&&(S(e=>new Set(e).add(t)),w(e=>{let n=new Set(e);return n.delete(t),n}))},t[9]=se):se=t[9];let le=se,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{S(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),w(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[10]=ue):ue=t[10];let fe=ue,pe;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{w(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),S(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[11]=pe):pe=t[11];let me=pe,he;t[12]===l?he=t[13]:(he=()=>({startCreating:le,expandAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{S(e),w(new Set)})},collapseAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{w(e),S(new Set)})}}),t[12]=l,t[13]=he),(0,Z.useImperativeHandle)(n,he);let ge;t[14]===P?ge=t[15]:(ge=function(){P||(j(null),N(``),L(null))},t[14]=P,t[15]=ge);let ve=ge,ye;t[16]!==s||t[17]!==A||t[18]!==M?(ye=async function(){if(!A)return;let e=M.trim();if(!e){L(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){L(`Invalid name`);return}let t=A.kind===`file`?De(A.parentDir,e):Ne(A.parentDir,e);F(!0),L(null);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})}),n=null;try{n=await e.json()}catch(t){console.warn(`[FileTree] create response JSON parse failed:`,t,`status:`,e.status)}if(!e.ok||!n?.ok){let e=n?.error??`Failed to create ${A.kind}`;X.error(e),L(e),F(!1);return}let r=n.docName??t.replace(/\.md$/,``);j(null),N(``),L(null),F(!1),r&&oT(r),s(r),ze([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),X.error(`Network error — please try again`),L(`Network error — please try again`),F(!1)}},t[16]=s,t[17]=A,t[18]=M,t[19]=ye):ye=t[19];let be=ye,xe;t[20]!==r||t[21]!==a||t[22]!==_?(xe=async function(e){let t=ry(e.kind,_);if(!iy(t)){m(`Name must be a single path segment`);return}let n=ay(e,t);if(n===e.path){g(null),v(``),m(null);return}b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,i=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),s=await o.json();if(!o.ok||!s.ok){m(s.error??`Failed to rename path`),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=cy(r,c);for(let e of c)a(e.fromDocName);u(e=>oy(e,c)),ze([`files`,`backlinks`,`graph`]),g(null),v(``),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),m(`Network error — please try again`),b(null)}},t[20]=r,t[21]=a,t[22]=_,t[23]=xe):xe=t[23];let Ce=xe,we;t[24]!==r||t[25]!==a||t[26]!==h||t[27]!==k?(we=async function(e){b(e.path),k(null);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),n=await t.json();if(!t.ok||!n.ok){X.error(n.error??`Failed to delete path`),b(null);return}let i=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],o=new Set(i);for(let e of o)a(e);u(e=>sy(e,i)),ze([`files`,`backlinks`,`graph`]),r&&o.has(r)&&(window.location.hash=``),h&&(o.has(h)||e.path===h)&&(g(null),v(``)),b(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),X.error(`Network error — please try again`),b(null)}},t[24]=r,t[25]=a,t[26]=h,t[27]=k,t[28]=we):we=t[28];let Te=we,J;t[29]!==r||t[30]!==a?(J=async function(e,t){let n=Pw(e,t);if(!n.ok){if(n.reason===`no_op`)return;X.error(n.reason===`self`?`Cannot move a folder into itself`:`Cannot move a folder into one of its subfolders`);return}let i=n.destinationPath;b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,n=e.kind===`file`?{docName:e.path,newDocName:i}:{kind:`folder`,fromPath:e.path,toPath:i},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),s=await o.json();if(!o.ok||!s.ok){let e=s.error??`Failed to move`;X.error(e),m(e),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=cy(r,c);for(let e of c)a(e.fromDocName);u(e=>oy(e,c)),ze([`files`,`backlinks`,`graph`]);let d=i.split(`/`).filter(Boolean);d.length>1&&S(e=>{let t=new Set(e);for(let e=0;e<d.length-1;e++)t.add(d.slice(0,e+1).join(`/`));return t}),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),b(null)}},t[29]=r,t[30]=a,t[31]=J):J=t[31];let Ee=J;if(d){let e;return t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`Loading...`})}),t[32]=e):e=t[32],e}if(p&&l.length===0){let e;return t[33]===p?e=t[34]:(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/50`,children:p})}),t[33]=p,t[34]=e),e}if(l.length===0&&!A){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),t[35]=e):e=t[35];let n;return t[36]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>le(`file`,``),children:`Create your first file`})]}),t[36]=n):n=t[36],n}let Oe=l.length>0?de(l):[],ke=Re(Oe),Ae=_e(D),je=new Set(Ae),Me=new Set;for(let e of je)ke.has(e)&&Me.add(e);for(let e of x)ke.has(e)&&Me.add(e);for(let e of C)ke.has(e)&&!je.has(e)&&Me.delete(e);let Y=function(e){if(je.has(e))return;let[t,n]=Me.has(e)?[w,S]:[S,w];t(t=>new Set(t).add(e)),n(t=>{let n=new Set(t);return n.delete(e),n})},Pe;t[37]!==P||t[38]!==I||t[39]!==A||t[40]!==M||t[41]!==ve||t[42]!==be?(Pe=function(e){return!A||A.parentDir!==e?null:{kind:A.kind,value:M,busy:P,error:I,onChange:N,onCommit:()=>void be(),onCancel:ve}},t[37]=P,t[38]=I,t[39]=A,t[40]=M,t[41]=ve,t[42]=be,t[43]=Pe):Pe=t[43];let Fe=Pe,Ie;t[44]===Fe?Ie=t[45]:(Ie=Fe(``),t[44]=Fe,t[45]=Ie);let Le=Ie,Be=y!==null||h!==null||A!==null,Ve=cw,He=bS,Ue;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=e=>{let{active:t}=e;z(t.data.current?.source??null)},t[46]=Ue):Ue=t[46];let We;t[47]===Ee?We=t[48]:(We=e=>{let{active:t,over:n}=e;if(z(null),!n)return;let r=t.data.current?.source,i=n.data.current?.destinationFolderPath;!r||typeof i!=`string`||Ee(r,i)},t[47]=Ee,t[48]=We);let Ge;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>z(null),t[49]=Ge):Ge=t[49];let Ke=iT,qe;t[50]===p?qe=t[51]:(qe=p&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:p}),t[50]=p,t[51]=qe);let Je=ky,Ye;t[52]===Le?Ye=t[53]:(Ye=Le&&(0,$.jsx)(Ay,{children:(0,$.jsx)(dT,{...Le})}),t[52]=Le,t[53]=Ye);let Xe;t[54]===Be?Xe=t[55]:(Xe=(0,$.jsx)(pT,{treeActionsLocked:Be}),t[54]=Be,t[55]=Xe);let Ze=Oe.map(e=>(0,$.jsx)(mT,{node:e,selectedFilePath:T,selectedFolderPath:E,expandedPaths:Me,onToggle:Y,activeRowRef:ne,editingPath:h,editingValue:_,busyPath:y,treeActionsLocked:Be,workspace:H,handoff:te,onNavigate:oT,prewarm:o,onStartRename:e=>{g(e.path),v(e.name),m(null)},onEditingValueChange:v,onCommitRename:e=>void Ce(e),onCancelRename:()=>{y||(g(null),v(``))},onDelete:e=>k(e),onStartCreating:le,onExpandSubtree:fe,onCollapseSubtree:me,inlineCreate:Fe(e.path),getInlineCreate:Fe},e.path)),Qe;t[56]!==Je||t[57]!==Ye||t[58]!==Xe||t[59]!==Ze?(Qe=(0,$.jsxs)(Je,{children:[Ye,Xe,Ze]}),t[56]=Je,t[57]=Ye,t[58]=Xe,t[59]=Ze,t[60]=Qe):Qe=t[60];let $e=!!O,et;t[61]!==y||t[62]!==k?(et=e=>{!e&&!y&&k(null)},t[61]=y,t[62]=k,t[63]=et):et=t[63];let tt;t[64]!==y||t[65]!==O||t[66]!==Te?(tt=O&&(0,$.jsx)(kw,{itemName:`${O.name}${O.kind===`file`?`.md`:`/`}`,isSubmitting:y===O.path,onDelete:()=>Te(O),customDescription:O.kind===`folder`?`Are you sure you want to delete ${O.name}/ and all files inside? This action cannot be undone.`:void 0}),t[64]=y,t[65]=O,t[66]=Te,t[67]=tt):tt=t[67];let nt;t[68]!==$e||t[69]!==et||t[70]!==tt?(nt=(0,$.jsx)(ln,{open:$e,onOpenChange:et,children:tt}),t[68]=$e,t[69]=et,t[70]=tt,t[71]=nt):nt=t[71];let rt;t[72]===R?rt=t[73]:(rt=R?(0,$.jsxs)(`div`,{className:`pointer-events-none flex max-w-[min(100vw-2rem,280px)] items-center gap-2 rounded-md border border-sidebar-border bg-sidebar px-3 py-1.5 text-sm shadow-lg`,children:[R.kind===`file`?(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sidebar-foreground`,children:[R.name,R.kind===`file`?`.md`:``]})]}):null,t[72]=R,t[73]=rt);let it;t[74]===rt?it=t[75]:(it=(0,$.jsx)(Ow,{dropAnimation:null,children:rt}),t[74]=rt,t[75]=it);let at;t[76]!==R||t[77]!==Ke.Provider||t[78]!==qe||t[79]!==Qe||t[80]!==nt||t[81]!==it?(at=(0,$.jsxs)(Ke.Provider,{value:R,children:[qe,Qe,nt,it]}),t[76]=R,t[77]=Ke.Provider,t[78]=qe,t[79]=Qe,t[80]=nt,t[81]=it,t[82]=at):at=t[82];let ot;return t[83]!==Ve||t[84]!==V||t[85]!==He||t[86]!==Ue||t[87]!==We||t[88]!==Ge||t[89]!==at?(ot=(0,$.jsx)(Ve,{sensors:V,collisionDetection:He,onDragStart:Ue,onDragEnd:We,onDragCancel:Ge,children:at}),t[83]=Ve,t[84]=V,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=at,t[90]=ot):ot=t[90],ot}function gT(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function _T(){return null}function vT(){return null}function yT(e){e&&e.scrollIntoView({block:`nearest`})}function bT(){return new Set}function xT(){return new Set}function ST(e){e.stopPropagation()}function CT(e){let t=(0,Q.c)(13),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a=`update-notice-${n.id}`,o=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,s;t[0]===n.body?s=t[1]:(s=(0,$.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[0]=n.body,t[1]=s);let c;t[2]===n.action?c=t[3]:(c=n.action?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[2]=n.action,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(jt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":a,className:o,children:[s,c,u]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12],d}function wT(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function TT(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Yl,Jl,Jl),n;e[0]===t?n=e[1]:(n=wT(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{ql(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,$.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,$.jsx)(CT,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function ET(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(St,{name:`file-sidebar`,children:(0,$.jsx)(DT,{})}),e[0]=t):t=e[0],t}function DT(){let e=(0,Q.c)(8),t=(0,Z.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}),e[0]=n):n=e[0];let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(ui,{"aria-hidden":`true`})})})}),(0,$.jsx)($e,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(Lg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(Ag,{children:[r,(0,$.jsxs)(Ig,{align:`end`,children:[i,(0,$.jsxs)(Lg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Pi,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Ey,{children:(0,$.jsx)(ky,{children:(0,$.jsx)(Ay,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,o,(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(ei,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Oy,{children:(0,$.jsx)(hT,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(Cy,{variant:`inset`,children:[s,c,(0,$.jsx)(Dy,{children:(0,$.jsx)(TT,{})})]}),e[7]=l):l=e[7],l}function OT(){let e=(0,Q.c)(11),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i,setSystemProvider:a}=Hn(),o=(0,Z.useRef)(n),s=(0,Z.useRef)(r),c,l;e[0]===n?(c=e[1],l=e[2]):(c=()=>{o.current=n},l=[n],e[0]=n,e[1]=c,e[2]=l),(0,Z.useEffect)(c,l);let u=(0,Z.useRef)(null),d,f;e[3]===r?(d=e[4],f=e[5]):(d=()=>{let e=s.current!==null;if(s.current=r,!(e&&r===null)||Date.now()-xn()<3e3)return;let t=u.current?.awareness;if(!t)return;let n=Jy(t,Date.now());n&&n!==o.current&&(window.location.hash=me(n))},f=[r],e[3]=r,e[4]=d,e[5]=f),(0,Z.useEffect)(d,f);let p,m;return e[6]!==i||e[7]!==t||e[8]!==a?(p=()=>{if(i===null)return;let e=new Tn,n=new Pn({url:i,name:v,document:e,onStateless:MT,onClose:jT,onDisconnect:AT}),r=ce(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))});n.on(`synced`,kT);let c=null,l=new Set,d=()=>{if(c=null,s.current!==null||Date.now()-xn()<3e3)return;let e=n.awareness;if(!e)return;let t=Jy(e,Date.now());t&&t!==o.current&&(window.location.hash=me(t))},f=()=>{if(n.awareness)for(let[e,t]of n.awareness.getStates().entries())l.has(e)||t.user?.type===`agent`&&(l.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`));c!==null&&clearTimeout(c),c=setTimeout(d,300)};return n.awareness?.on(`change`,f),u.current=n,a(n),()=>{r(),c!==null&&clearTimeout(c),n.awareness?.off(`change`,f),a(null),n.destroy(),e.destroy(),u.current=null}},m=[t,i,a],e[6]=i,e[7]=t,e[8]=a,e[9]=p,e[10]=m):(p=e[9],m=e[10]),(0,Z.useEffect)(p,m),null}function kT(){ze([`files`,`backlinks`,`graph`])}function AT(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function jT(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function MT(e){let{payload:t}=e,n=vn(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}ze([n.ch])}function NT(){let t=(0,Q.c)(7),{clearTarget:n}=Hn(),{openTargetTransition:r}=Jt(),{folderPaths:i,loading:a,pages:o}=Se(),s,c;return t[0]!==n||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==o?(s=()=>{t();function t(){let t=Te(window.location.hash);if(!t){bn(`ok/nav/hash-change`,{docName:null,kind:`clear`}),n();return}if(a){bn(`ok/nav/hash-change`,{docName:t,kind:`deferred-loading`});return}let s=e(t,{pages:o,folderPaths:i});bn(`ok/nav/hash-change`,{docName:t,kind:s.kind}),r(s)}return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},c=[n,i,a,r,o],t[0]=n,t[1]=i,t[2]=a,t[3]=r,t[4]=o,t[5]=s,t[6]=c):(s=t[5],c=t[6]),(0,Z.useEffect)(s,c),null}function PT(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=Hn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:re(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Qt({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,$.jsx)(Ct,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function FT(){let e=(0,Q.c)(7),t=typeof window<`u`?window.okDesktop??null:null,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Qd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(OT,{}),i=(0,$.jsx)(NT,{}),a=(0,$.jsx)(PT,{}),o=t?(0,$.jsx)(qd,{bridge:t}):null,e[1]=r,e[2]=i,e[3]=a,e[4]=o):(r=e[1],i=e[2],a=e[3],o=e[4]);let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(ET,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(St,{name:`app`,children:(0,$.jsxs)(un,{children:[n,(0,$.jsxs)(oe,{children:[r,i,a,o,(0,$.jsxs)(by,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(Ty,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(xx,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Tl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&kl({bridge:window.okDesktop}),Xl(),typeof window<`u`&&Ol({bridge:window.okDesktop});var IT=new br({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),LT=document.getElementById(`root`);if(!LT)throw Error(`Root element not found`);var RT=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Wi.createRoot)(LT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(ae,{client:IT,children:(0,$.jsxs)(K,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(ut,{children:RT&&window.okDesktop?(0,$.jsx)(bl,{bridge:window.okDesktop}):(0,$.jsx)(FT,{})}),(0,$.jsx)(wl,{richColors:!0})]})})}));
|
|
21
|
+
`},aS={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function oS(e){let{announcements:t=aS,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=iS}=e,{announce:a,announcement:o}=eS(),s=Bx(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),nS((0,Z.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=Z.createElement(Z.Fragment,null,Z.createElement(Qx,{id:r,value:i.draggable}),Z.createElement($x,{id:s,announcement:o}));return n?(0,N_.createPortal)(u,n):u}var sS;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(sS||={});function cS(){}function lS(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function uS(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var dS=Object.freeze({x:0,y:0});function fS(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function pS(e,t){let n=qx(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function mS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function hS(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function gS(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function _S(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function vS(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var yS=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=vS(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(hS)};function bS(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var xS=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&bS(r,a)){let n=gS(a).reduce((e,t)=>e+fS(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(mS)};function SS(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function CS(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:dS}function wS(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var TS=wS(1);function ES(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function DS(e,t,n){let r=ES(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var OS={ignoreTransform:!1};function kS(e,t){t===void 0&&(t=OS);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Dx(e).getComputedStyle(e);t&&(n=DS(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function AS(e){return kS(e,{ignoreTransform:!0})}function jS(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function MS(e,t){return t===void 0&&(t=Dx(e).getComputedStyle(e)),t.position===`fixed`}function NS(e,t){t===void 0&&(t=Dx(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function PS(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Ox(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!kx(i)||Ax(i)||n.includes(i))return n;let a=Dx(e).getComputedStyle(i);return i!==e&&NS(i,a)&&n.push(i),MS(i,a)?n:r(i.parentNode)}return e?r(e):n}function FS(e){let[t]=PS(e,1);return t??null}function IS(e){return!wx||!e?null:Tx(e)?e:Ex(e)?Ox(e)||e===jx(e).scrollingElement?window:kx(e)?e:null:null}function LS(e){return Tx(e)?e.scrollX:e.scrollLeft}function RS(e){return Tx(e)?e.scrollY:e.scrollTop}function zS(e){return{x:LS(e),y:RS(e)}}var BS;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(BS||={});function VS(e){return!wx||!e?!1:e===document.scrollingElement}function HS(e){let t={x:0,y:0},n=VS(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var US={x:.2,y:.2};function WS(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=US);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=HS(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=BS.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=BS.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=BS.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=BS.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function GS(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function KS(e){return e.reduce((e,t)=>Hx(e,zS(t)),dS)}function qS(e){return e.reduce((e,t)=>e+LS(t),0)}function JS(e){return e.reduce((e,t)=>e+RS(t),0)}function YS(e,t){if(t===void 0&&(t=kS),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);FS(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var XS=[[`x`,[`left`,`right`],qS],[`y`,[`top`,`bottom`],JS]],ZS=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=PS(t),r=KS(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of XS)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},QS=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function $S(e){let{EventTarget:t}=Dx(e);return e instanceof t?e:jx(e)}function eC(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var tC;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(tC||={});function nC(e){e.preventDefault()}function rC(e){e.stopPropagation()}var iC;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(iC||={});var aC={start:[iC.Space,iC.Enter],cancel:[iC.Esc],end:[iC.Space,iC.Enter,iC.Tab]},oC=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case iC.Right:return{...n,x:n.x+25};case iC.Left:return{...n,x:n.x-25};case iC.Down:return{...n,y:n.y+25};case iC.Up:return{...n,y:n.y-25}}},sC=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new QS(jx(t)),this.windowListeners=new QS(Dx(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(tC.Resize,this.handleCancel),this.windowListeners.add(tC.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(tC.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&YS(n),t(dS)}handleKeyDown(e){if(Gx(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=aC,coordinateGetter:a=oC,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:dS;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Ux(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=HS(n),p=GS(n),m={x:Math.min(i===iC.Right?p.right-p.width/2:p.right,Math.max(i===iC.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===iC.Down?p.bottom-p.height/2:p.bottom,Math.max(i===iC.Down?p.top:p.top+p.height/2,u.y))},h=i===iC.Right&&!s||i===iC.Left&&!c,g=i===iC.Down&&!l||i===iC.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===iC.Right&&e<=d.x||i===iC.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===iC.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===iC.Down&&e<=d.y||i===iC.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===iC.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Hx(Ux(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};sC.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=aC,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function cC(e){return!!(e&&`distance`in e)}function lC(e){return!!(e&&`delay`in e)}var uC=class{constructor(e,t,n){n===void 0&&(n=$S(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=jx(i),this.documentListeners=new QS(this.document),this.listeners=new QS(n),this.windowListeners=new QS(Dx(i)),this.initialCoordinates=qx(r)??dS,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(tC.Resize,this.handleCancel),this.windowListeners.add(tC.DragStart,nC),this.windowListeners.add(tC.VisibilityChange,this.handleCancel),this.windowListeners.add(tC.ContextMenu,nC),this.documentListeners.add(tC.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(lC(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(cC(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(tC.Click,rC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(tC.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=qx(e)??dS,s=Ux(n,o);if(!t&&a){if(cC(a)){if(a.tolerance!=null&&eC(s,a.tolerance))return this.handleCancel();if(eC(s,a.distance))return this.handleStart()}if(lC(a)&&eC(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===iC.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},dC={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},fC=class extends uC{constructor(e){let{event:t}=e,n=jx(t.target);super(e,dC,n)}};fC.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var pC={move:{name:`mousemove`},end:{name:`mouseup`}},mC;(function(e){e[e.RightClick=2]=`RightClick`})(mC||={});var hC=class extends uC{constructor(e){super(e,pC,jx(e.event.target))}};hC.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===mC.RightClick?!1:(r?.({event:n}),!0)}}];var gC={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},_C=class extends uC{constructor(e){super(e,gC)}static setup(){return window.addEventListener(gC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(gC.move.name,e)};function e(){}}};_C.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var vC;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(vC||={});var yC;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(yC||={});function bC(e){let{acceleration:t,activator:n=vC.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=yC.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=SC({delta:d,disabled:!a}),[m,h]=Px(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case vC.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case vC.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,Z.useMemo)(()=>s===yC.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=WS(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var xC={x:{[BS.Backward]:!1,[BS.Forward]:!1},y:{[BS.Backward]:!1,[BS.Forward]:!1}};function SC(e){let{delta:t,disabled:n}=e,r=Rx(t);return Ix(e=>{if(n||!r||!e)return xC;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[BS.Backward]:e.x[BS.Backward]||i.x===-1,[BS.Forward]:e.x[BS.Forward]||i.x===1},y:{[BS.Backward]:e.y[BS.Backward]||i.y===-1,[BS.Forward]:e.y[BS.Forward]||i.y===1}}},[n,t,r])}function CC(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Ix(e=>t==null?null:r??e??null,[r,t])}function wC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var TC;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(TC||={});var EC;(function(e){e.Optimized=`optimized`})(EC||={});var DC=new Map;function OC(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=Fx(d),p=(0,Z.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,Z.useRef)(null),h=Ix(t=>{if(d&&!n)return DC;if(!t||t===DC||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new ZS(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case TC.Always:return!1;case TC.BeforeDragging:return n;default:return!n}}}function kC(e,t){return Ix(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function AC(e,t){return kC(e,t)}function jC(e){let{callback:t,disabled:n}=e,r=Nx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function MC(e){let{callback:t,disabled:n}=e,r=Nx(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function NC(e){return new ZS(kS(e),e)}function PC(e,t,n){t===void 0&&(t=NC);let[r,i]=(0,Z.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=jC({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=MC({callback:a});return Mx(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function FC(e){return CS(e,kC(e))}var IC=[];function LC(e){let t=(0,Z.useRef)(e),n=Ix(n=>e?n&&n!==IC&&e&&t.current&&e.parentNode===t.current.parentNode?n:PS(e):IC,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function RC(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=IS(e.target);t&&n(e=>e?(e.set(t,zS(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=IS(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,zS(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{IS(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Hx(e,t),dS):KS(e):dS,[e,t])}function zC(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==dS;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Ux(e,n.current):dS}function BC(e){(0,Z.useEffect)(()=>{if(!wx)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function VC(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function HC(e){return(0,Z.useMemo)(()=>e?jS(e):null,[e])}var UC=[];function WC(e,t){t===void 0&&(t=kS);let[n]=e,r=HC(n?Dx(n):null),[i,a]=(0,Z.useState)(UC);function o(){a(()=>e.length?e.map(e=>VS(e)?r:new ZS(t(e),e)):UC)}let s=MC({callback:o});return Mx(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function GC(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return kx(t)?t:e}function KC(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=MC({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(kx(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Lx((0,Z.useCallback)(e=>{let n=GC(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var qC=[{sensor:fC,options:{}},{sensor:sC,options:{}}],JC={current:{}},YC={draggable:{measure:AS},droppable:{measure:AS,strategy:TC.WhileDragging,frequency:EC.Optimized},dragOverlay:{measure:kS}},XC=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},ZC={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new XC,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:cS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:YC,measureDroppableContainers:cS,windowRect:null,measuringScheduled:!1},QC={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:cS,draggableNodes:new Map,over:null,measureDroppableContainers:cS},$C=(0,Z.createContext)(QC),ew=(0,Z.createContext)(ZC);function tw(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new XC}}}function nw(e,t){switch(t.type){case sS.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case sS.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case sS.DragEnd:case sS.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case sS.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new XC(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case sS.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new XC(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case sS.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new XC(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function rw(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)($C),a=Rx(r),o=Rx(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Gx(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Xx(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function iw(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function aw(e){return(0,Z.useMemo)(()=>({draggable:{...YC.draggable,...e?.draggable},droppable:{...YC.droppable,...e?.droppable},dragOverlay:{...YC.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function ow(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Mx(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=CS(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=FS(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var sw=(0,Z.createContext)({...dS,scaleX:1,scaleY:1}),cw;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(cw||={});var lw=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=qC,collisionDetection:o=yS,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(nw,void 0,tw),[f,p]=rS(),[m,h]=(0,Z.useState)(cw.Uninitialized),g=m===cw.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??JC,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=Fx(l,Object.values(l)),A=Bx(`DndDescribedBy`,t),j=(0,Z.useMemo)(()=>b.getEnabled(),[b]),M=aw(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=OC(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=CC(v,_),L=(0,Z.useMemo)(()=>D?qx(D):null,[D]),R=xe(),z=AC(I,M.draggable.measure);ow({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:M.draggable.measure});let B=PC(I,M.draggable.measure,z),V=PC(I?I.parentElement:null),H=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),U=b.getNodeFor(H.current.over?.id),W=KC({measure:M.dragOverlay.measure}),G=W.nodeRef.current??I,K=g?W.rect??B:null,ee=!!(W.nodeRef.current&&W.rect),te=FC(ee?null:B),ne=HC(G?Dx(G):null),re=LC(g?U??I:null),ie=WC(re),ae=iw(c,{transform:{x:y.x-te.x,y:y.y-te.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:K,over:H.current.over,overlayNodeRect:W.rect,scrollableAncestors:re,scrollableAncestorRects:ie,windowRect:ne}),oe=L?Hx(L,y):null,se=RC(re),q=zC(se),ce=zC(se,[B]),le=Hx(ae,q),ue=K?TS(K,ae):null,de=C&&ue?o({active:C,collisionRect:ue,droppableRects:N,droppableContainers:j,pointerCoordinates:oe}):null,fe=_S(de,`id`),[pe,me]=(0,Z.useState)(null),he=SS(ee?ae:Hx(ae,ce),pe?.rect??null,B),ge=(0,Z.useRef)(null),_e=(0,Z.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;ge.current=new n({active:w.current,activeNode:i,event:a,options:r,context:H,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,N_.unstable_batchedUpdates)(()=>{r?.(i),h(cw.Initializing),d({type:sS.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(ge.current),O(a)})},onMove(e){d({type:sS.DragMove,coordinates:e})},onEnd:o(sS.DragEnd),onCancel:o(sS.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=H.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===sS.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=sS.DragCancel)}w.current=null,(0,N_.unstable_batchedUpdates)(()=>{d({type:e}),h(cw.Uninitialized),me(null),E(null),O(null),ge.current=null;let t=e===sS.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ve=wC(a,(0,Z.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,_e(n,t))},[v,_e]));BC(a),Mx(()=>{B&&m===cw.Initializing&&h(cw.Initialized)},[B,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=H.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:le.x,y:le.y},over:i};(0,N_.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[le.x,le.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=H.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(fe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,N_.unstable_batchedUpdates)(()=>{me(s),a?.(c),f({type:`onDragOver`,event:c})})},[fe]),Mx(()=>{H.current={activatorEvent:D,active:C,activeNode:I,collisionRect:ue,collisions:de,droppableRects:N,draggableNodes:v,draggingNode:G,draggingNodeRect:K,droppableContainers:b,over:pe,scrollableAncestors:re,scrollAdjustedTranslate:le},S.current={initial:K,translated:ue}},[C,I,de,ue,v,G,K,N,b,pe,re,le]),bC({...R,delta:y,draggingRect:ue,pointerCoordinates:oe,scrollableAncestors:re,scrollableAncestorRects:ie});let ye=(0,Z.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:B,activatorEvent:D,collisions:de,containerNodeRect:V,dragOverlay:W,draggableNodes:v,droppableContainers:b,droppableRects:N,over:pe,measureDroppableContainers:P,scrollableAncestors:re,scrollableAncestorRects:ie,measuringConfiguration:M,measuringScheduled:F,windowRect:ne}),[C,I,B,D,de,V,W,v,b,N,pe,P,re,ie,M,F,ne]),be=(0,Z.useMemo)(()=>({activatorEvent:D,activators:ve,active:C,activeNodeRect:B,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:pe,measureDroppableContainers:P}),[D,ve,C,B,d,A,v,pe,P]);return Z.createElement(tS.Provider,{value:p},Z.createElement($C.Provider,{value:be},Z.createElement(ew.Provider,{value:ye},Z.createElement(sw.Provider,{value:he},i)),Z.createElement(rw,{disabled:n?.restoreFocus===!1})),Z.createElement(oS,{...n,hiddenTextDescribedById:A}));function xe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),uw=(0,Z.createContext)(null),dw=`button`,fw=`Draggable`;function pw(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Bx(fw),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)($C),{role:p=dw,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?sw:uw),[v,y]=Lx(),[b,x]=Lx(),S=VC(o,t),C=Fx(n);return Mx(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===dw?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function mw(){return(0,Z.useContext)(ew)}var hw=`Droppable`,gw={timeout:25};function _w(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Bx(hw),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)($C),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...gw,...i},_=Fx(h??r),v=MC({callback:(0,Z.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Lx((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Fx(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:sS.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:sS.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:sS.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function vw(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=Rx(n);return!n&&!r&&s&&i(s),Mx(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var yw={x:0,y:0,scaleX:1,scaleY:1};function bw(e){let{children:t}=e;return Z.createElement($C.Provider,{value:QC},Z.createElement(sw.Provider,{value:yw},t))}var xw={position:`fixed`,touchAction:`none`},Sw=e=>Gx(e)?`transform 250ms ease`:void 0,Cw=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Sw}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...xw,width:s.width,height:s.height,top:s.top,left:s.left,transform:Jx.Transform.toString(d),transformOrigin:i&&r?pS(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),ww={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Jx.Transform.toString(t)},{transform:Jx.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Tw(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Nx((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=GC(a);if(!c)return;let{transform:l}=Dx(a).getComputedStyle(a),u=ES(l);if(!u)return;let d=typeof t==`function`?t:Ew(t);return YS(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Ew(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...ww,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Dw=0;function Ow(e){return(0,Z.useMemo)(()=>{if(e!=null)return Dw++,Dw},[e])}var kw=Z.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=mw(),S=(0,Z.useContext)(sw),C=Ow(d?.id),w=iw(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=kC(f),E=Tw({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(bw,null,Z.createElement(vw,{animation:E},d&&C?Z.createElement(Cw,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Aw(e){let t=(0,Q.c)(20),{itemName:n,isSubmitting:r,onDelete:i,customTitle:a,customDescription:o,children:s}=e,c=n===void 0?`this item`:n,l=a??`Delete ${c}`,u;t[0]===l?u=t[1]:(u=(0,$.jsx)(pn,{children:l}),t[0]=l,t[1]=u);let d=o??`Are you sure you want to delete ${c}? This action cannot be undone.`,f;t[2]===d?f=t[3]:(f=(0,$.jsx)(dn,{className:`whitespace-pre-wrap`,children:d}),t[2]=d,t[3]=f);let p;t[4]===r?p=t[5]:(p=(0,$.jsx)(An,{asChild:!0,children:(0,$.jsx)(q,{variant:`outline`,disabled:r,children:`Cancel`})}),t[4]=r,t[5]=p);let m;t[6]===r?m=t[7]:(m=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(an,{className:`size-4 animate-spin`}),` Deleting...`]}):`Delete`,t[6]=r,t[7]=m);let h;t[8]!==r||t[9]!==i||t[10]!==m?(h=(0,$.jsx)(q,{variant:`destructive`,onClick:i,disabled:r,children:m}),t[8]=r,t[9]=i,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==p||t[13]!==h?(g=(0,$.jsxs)(wn,{children:[p,h]}),t[12]=p,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==s||t[16]!==u||t[17]!==f||t[18]!==g?(_=(0,$.jsxs)(In,{children:[u,f,s,g]}),t[15]=s,t[16]=u,t[17]=f,t[18]=g,t[19]=_):_=t[19],_}function jw(e){let t=e.lastIndexOf(`/`);return t<=0?``:e.slice(0,t)}function Mw(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Nw(e,t){return e?`${e}/${t}`:t}function Pw(e,t){return Nw(t,Mw(e.path))}function Fw(e,t){if(e.kind===`folder`){if(t===e.path)return{ok:!1,reason:`self`};if(t.length>e.path.length&&t.startsWith(`${e.path}/`))return{ok:!1,reason:`descendant`}}let n=Pw(e,t);return n===e.path?{ok:!1,reason:`no_op`}:{ok:!0,destinationPath:n}}function Iw(e,t){if(!e)return{selectedFilePath:t,selectedFolderPath:null,navigationPath:t};switch(e.kind){case`doc`:return{selectedFilePath:e.docName,selectedFolderPath:null,navigationPath:e.docName};case`folder`:case`folder-index`:return{selectedFilePath:null,selectedFolderPath:e.folderPath,navigationPath:e.folderPath};case`missing`:return{selectedFilePath:null,selectedFolderPath:null,navigationPath:null}}}function Lw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(vs,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function Rw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(ys,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function zw(e){let t=(0,Q.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,$.jsx)(ws,{"data-slot":`context-menu-sub`,...n}),t[2]=n,t[3]=r),r}function Bw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(bs,{children:(0,$.jsx)(xs,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Vw(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=k(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,$.jsx)(Ss,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Hw(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=k(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Lr,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,$.jsxs)(Ts,{"data-slot":`context-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Uw(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`z-50 min-w-32 origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Es,{"data-slot":`context-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ww(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=k(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(Cs,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Gw(e,t,n,r){return e.id===`cursor`&&!n?`Desktop only`:t.installed===null?`Detecting…`:t.installed===!1?`Not installed`:r?`No workspace`:null}function Kw(e){let t=(0,Q.c)(8),{input:n,installStates:r,isElectronHost:i,dispatch:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Hw,{children:`Open in…`}),t[0]=o):o=t[0];let s;t[1]!==a||t[2]!==n||t[3]!==r||t[4]!==i?(s=sd.map(e=>{let t=r[e.id],o=Ob({target:e,installState:t,isElectronHost:i}),s=n===null,c=o.enabled&&!s,l=Gw(e,t,i,s),u=l?`Open in ${e.displayName}, ${l}`:`Open in ${e.displayName}`;return(0,$.jsxs)(Vw,{disabled:!c,onSelect:()=>{!c||!n||a(e.id,n)},"data-testid":`file-tree-open-in-${e.id}`,"aria-label":u,children:[(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Open in `,e.displayName]}),l?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:l}):null]},e.id)}),t[1]=a,t[2]=n,t[3]=r,t[4]=i,t[5]=s):s=t[5];let c;return t[6]===s?c=t[7]:(c=(0,$.jsxs)(zw,{children:[o,(0,$.jsx)(Uw,{children:s})]}),t[6]=s,t[7]=c),c}var qw=80,Jw=3,Yw=20,Xw=new Map,Zw=new Set,Qw=[],$w=new Map;function eT(e){for($w.delete(e),$w.set(e,!0);$w.size>Yw;){let e=$w.keys().next().value;if(e===void 0)break;$w.delete(e)}}function tT(e){Zw.delete(e),nT()}function nT(){for(;Zw.size<Jw&&Qw.length>0;){let e=Qw.shift();if(!e)break;if(!$w.has(e.docName)){Zw.add(e.docName),eT(e.docName);try{e.prewarm(e.docName)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e.docName,message:t instanceof Error?t.message:String(t)})}finally{tT(e.docName)}}}}function rT(e,t){if(yn(e)||$w.has(e))return;let n=Xw.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>{if(Xw.delete(e),Zw.size>=Jw){Qw.push({docName:e,prewarm:t});return}eT(e),Zw.add(e);try{t(e)}catch(t){bn(`ok/sidebar/prewarm-failed`,{docName:e,message:t instanceof Error?t.message:String(t)})}finally{tT(e)}},qw);Xw.set(e,{timer:r,prewarm:t})}function iT(e){let t=Xw.get(e);t&&(clearTimeout(t.timer),Xw.delete(e))}var aT=(0,Z.createContext)(null);function oT(){return(0,Z.use)(aT)}function sT(e){window.location.hash=me(e)}function cT(e){return e.kind===`file`?`${e.path}.md`:e.path}async function lT(e,t){try{await navigator.clipboard.writeText(e),X.success(`Copied ${t}`,{description:e})}catch(e){console.warn(`[FileTree] clipboard write failed:`,e),X.error(`Could not copy ${t}`)}}var uT=new Set([`agents`,`agent`,`claude`,`skill`]);function dT(e){return e.kind===`file`&&uT.has(e.name.toLowerCase())}function fT(e){let t=(0,Q.c)(38),{kind:n,value:r,busy:i,error:a,onChange:o,onCommit:s,onCancel:c}=e,l=(0,Z.useRef)(null),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=setTimeout(()=>l.current?.focus(),0);return()=>clearTimeout(e)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),(0,Z.useEffect)(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=k(`flex h-8 items-center gap-2 rounded-md px-2`),t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=n===`folder`?(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[3]=n,t[4]=p);let m=`Create new ${n}`,h=!!a,g=a?`inline-create-error`:void 0,_=n===`folder`?`folder-name`:`file-name`,v=a&&`border-destructive`,y;t[5]===v?y=t[6]:(y=k(`h-7 min-w-0 flex-1 bg-background text-sm`,v),t[5]=v,t[6]=y);let b;t[7]!==i||t[8]!==a||t[9]!==c?(b=()=>{!i&&!a&&c()},t[7]=i,t[8]=a,t[9]=c,t[10]=b):b=t[10];let x;t[11]===o?x=t[12]:(x=e=>o(e.target.value),t[11]=o,t[12]=x);let S;t[13]!==c||t[14]!==s?(S=e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(e.preventDefault(),c())},t[13]=c,t[14]=s,t[15]=S):S=t[15];let C;t[16]!==i||t[17]!==y||t[18]!==b||t[19]!==x||t[20]!==S||t[21]!==m||t[22]!==h||t[23]!==g||t[24]!==_||t[25]!==r?(C=(0,$.jsx)(Mt,{ref:l,value:r,disabled:i,"aria-label":m,"aria-invalid":h,"aria-describedby":g,placeholder:_,className:y,onBlur:b,onChange:x,onKeyDown:S}),t[16]=i,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=m,t[22]=h,t[23]=g,t[24]=_,t[25]=r,t[26]=C):C=t[26];let w;t[27]===n?w=t[28]:(w=n===`file`&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[27]=n,t[28]=w);let T;t[29]!==C||t[30]!==w||t[31]!==p?(T=(0,$.jsxs)(`div`,{className:f,children:[p,C,w]}),t[29]=C,t[30]=w,t[31]=p,t[32]=T):T=t[32];let E;t[33]===a?E=t[34]:(E=a&&(0,$.jsx)(`span`,{id:`inline-create-error`,role:`alert`,className:`px-2 text-xs text-destructive`,children:a}),t[33]=a,t[34]=E);let D;return t[35]!==T||t[36]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[T,E]}),t[35]=T,t[36]=E,t[37]=D):D=t[37],D}function pT(e,t){if(!e)return``;let n=Fw(e,t);return!n.ok&&(n.reason===`self`||n.reason===`descendant`)?`bg-destructive/20 ring-2 ring-destructive/50`:n.ok?`bg-primary/10 ring-2 ring-primary/40`:``}function mT(e){let t=(0,Q.c)(11),{treeActionsLocked:n}=e,r=oT(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={destinationFolderPath:``},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a={id:`drop-root`,disabled:n,data:i},t[1]=n,t[2]=a);let{setNodeRef:o,isOver:s}=_w(a);if(!r)return null;let c;t[3]!==r||t[4]!==s?(c=s&&pT(r,``),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=k(`flex h-8 items-center rounded-md border border-dashed border-sidebar-border px-2 text-xs text-muted-foreground transition-colors`,c),t[6]=c,t[7]=l);let u;return t[8]!==o||t[9]!==l?(u=(0,$.jsx)(jy,{children:(0,$.jsx)(`div`,{ref:o,className:l,children:`Drop here to move to library root`})}),t[8]=o,t[9]=l,t[10]=u):u=t[10],u}var hT=e=>{let t=(0,Q.c)(171),{node:n,nested:r,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:T,getInlineCreate:E}=e,D=r===void 0?!1:r,O=(0,Z.useRef)(!1),A=(0,Z.useRef)(null),j=n.kind===`file`,M=!j&&o.has(n.path),N=j?n.path===i:n.path===a,P=l===n.path,F,I;t[0]===P?(F=t[1],I=t[2]):(F=()=>{P&&requestAnimationFrame(()=>{let e=A.current;e&&(e.focus(),e.select())})},I=[P],t[0]=P,t[1]=F,t[2]=I),(0,Z.useEffect)(F,I);let L=d===n.path,R=d!==null,z=j?Nn:M?Dn:ti,B=D?Iy:jy,V=D?Ly:Ny,H;t[3]!==n.kind||t[4]!==n.name||t[5]!==n.path?(H={kind:n.kind,path:n.path,name:n.name},t[3]=n.kind,t[4]=n.name,t[5]=n.path,t[6]=H):H=t[6];let U=H,W;t[7]!==j||t[8]!==n.path?(W=j?jw(n.path):n.path,t[7]=j,t[8]=n.path,t[9]=W):W=t[9];let G=W,K=oT(),ee=`drag-${n.kind}-${n.path}`,te=f||P,ne;t[10]===U?ne=t[11]:(ne={source:U},t[10]=U,t[11]=ne);let re;t[12]!==ee||t[13]!==te||t[14]!==ne?(re={id:ee,disabled:te,data:ne},t[12]=ee,t[13]=te,t[14]=ne,t[15]=re):re=t[15];let{attributes:ie,listeners:ae,setNodeRef:oe,isDragging:se}=pw(re),q=`drop-${n.kind}-${n.path}`,ce;t[16]===G?ce=t[17]:(ce={destinationFolderPath:G},t[16]=G,t[17]=ce);let le;t[18]!==q||t[19]!==ce||t[20]!==f?(le={id:q,disabled:f,data:ce},t[18]=q,t[19]=ce,t[20]=f,t[21]=le):le=t[21];let{setNodeRef:ue,isOver:de}=_w(le),fe;t[22]!==c||t[23]!==N||t[24]!==oe||t[25]!==ue?(fe=e=>{oe(e),ue(e),N&&c(e)},t[22]=c,t[23]=N,t[24]=oe,t[25]=ue,t[26]=fe):fe=t[26];let pe=fe,me=de&&K?pT(K,G):``,he=j&&n.isSymlink,ge;t[27]===n?ge=t[28]:(ge=dT(n),t[27]=n,t[28]=ge);let _e=ge,ve;t[29]!==j||t[30]!==n.path||t[31]!==g?(ve=j?()=>{rT(n.path,e=>{g(e)})}:void 0,t[29]=j,t[30]=n.path,t[31]=g,t[32]=ve):ve=t[32];let ye=ve,be;t[33]!==j||t[34]!==n.path?(be=j?()=>{iT(n.path)}:void 0,t[33]=j,t[34]=n.path,t[35]=be):be=t[35];let xe=be,Se=N?`var(--color-sidebar-accent-foreground)`:`var(--color-muted-foreground)`,Ce;t[36]!==z||t[37]!==Se?(Ce=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:Se}),t[36]=z,t[37]=Se,t[38]=Ce):Ce=t[38];let we=N?`text-sidebar-accent-foreground`:`text-sidebar-foreground/70`,Te;t[39]===we?Te=t[40]:(Te=k(`min-w-0 flex-1 truncate text-sm`,we),t[39]=we,t[40]=Te);let J=n.name+(j?`.md`:``),Ee;t[41]!==Te||t[42]!==J?(Ee=(0,$.jsx)(`span`,{className:Te,children:J}),t[41]=Te,t[42]=J,t[43]=Ee):Ee=t[43];let De;t[44]!==n.canonicalDocName||t[45]!==n.targetPath||t[46]!==he?(De=he&&(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(ci,{className:`size-3.5 shrink-0 text-muted-foreground/50!`})}),(0,$.jsxs)($e,{side:`right`,className:`text-center leading-relaxed`,children:[`Symlink → `,n.targetPath,(0,$.jsx)(`br`,{}),`Opens the same document as `,n.canonicalDocName]})]}),t[44]=n.canonicalDocName,t[45]=n.targetPath,t[46]=he,t[47]=De):De=t[47];let Oe;t[48]===_e?Oe=t[49]:(Oe=_e&&(0,$.jsx)(Nr,{className:`size-3.5 shrink-0 text-muted-foreground/50!`}),t[48]=_e,t[49]=Oe);let ke;t[50]!==Ce||t[51]!==Ee||t[52]!==De||t[53]!==Oe?(ke=(0,$.jsxs)($.Fragment,{children:[Ce,Ee,De,Oe]}),t[50]=Ce,t[51]=Ee,t[52]=De,t[53]=Oe,t[54]=ke):ke=t[54];let Ae=ke,je=!D&&`ml-2`,Me=N&&`bg-sidebar-accent text-sidebar-accent-foreground`,Y;t[55]!==je||t[56]!==Me?(Y=k(`flex h-8 items-center gap-2 rounded-md px-2`,je,Me),t[55]=je,t[56]=Me,t[57]=Y):Y=t[57];let Ne;t[58]===z?Ne=t[59]:(Ne=(0,$.jsx)(z,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),t[58]=z,t[59]=Ne);let Pe=`Rename ${n.kind}`,Fe;t[60]===v?Fe=t[61]:(Fe=e=>v(e.target.value),t[60]=v,t[61]=Fe);let Ie;t[62]!==b||t[63]!==y||t[64]!==U?(Ie=e=>{e.key===`Enter`?(e.preventDefault(),y(U)):e.key===`Escape`&&(e.preventDefault(),b())},t[62]=b,t[63]=y,t[64]=U,t[65]=Ie):Ie=t[65];let Le;t[66]!==u||t[67]!==L||t[68]!==b||t[69]!==Pe||t[70]!==Fe||t[71]!==Ie?(Le=(0,$.jsx)(Mt,{ref:A,value:u,disabled:L,"aria-label":Pe,onBlur:b,onChange:Fe,onKeyDown:Ie,className:`h-7 min-w-0 flex-1 bg-background text-sm text-foreground`}),t[66]=u,t[67]=L,t[68]=b,t[69]=Pe,t[70]=Fe,t[71]=Ie,t[72]=Le):Le=t[72];let Re;t[73]===j?Re=t[74]:(Re=j&&(0,$.jsx)(`span`,{className:`text-xs text-sidebar-foreground/40`,children:`.md`}),t[73]=j,t[74]=Re);let ze;t[75]!==Y||t[76]!==Ne||t[77]!==Le||t[78]!==Re?(ze=(0,$.jsxs)(`div`,{className:Y,children:[Ne,Le,Re]}),t[75]=Y,t[76]=Ne,t[77]=Le,t[78]=Re,t[79]=ze):ze=t[79];let Be=P?ze:j?(0,$.jsx)(V,{isActive:N,onClick:()=>h(n.path),className:`cursor-pointer`,"aria-current":N?`page`:void 0,children:Ae}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(V,{isActive:N,className:`w-full cursor-pointer pr-8`,"aria-current":N?`page`:void 0,onClick:()=>h(n.path),children:Ae}),(0,$.jsx)(Py,{type:`button`,className:k(`top-1`,M&&`rotate-90`),"aria-label":`${M?`Collapse`:`Expand`} ${n.name}`,"aria-expanded":M,onPointerDown:CT,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(n.path)},children:(0,$.jsx)(Lr,{className:`size-4 text-muted-foreground/50`})})]}),Ve=Lw,He=Rw,Ue=k(`rounded-md transition-[opacity,box-shadow] duration-150 ease-out`,se&&`opacity-40`,me),We=!P&&ae,Ge=!P&&ie,Ke;t[80]!==ye||t[81]!==xe||t[82]!==pe||t[83]!==Ue||t[84]!==We||t[85]!==Ge||t[86]!==Be?(Ke=(0,$.jsx)(`div`,{ref:pe,className:Ue,onMouseEnter:ye,onMouseLeave:xe,...We,...Ge,role:`presentation`,tabIndex:void 0,children:Be}),t[80]=ye,t[81]=xe,t[82]=pe,t[83]=Ue,t[84]=We,t[85]=Ge,t[86]=Be,t[87]=Ke):Ke=t[87];let qe;t[88]!==He||t[89]!==Ke?(qe=(0,$.jsx)(He,{asChild:!0,children:Ke}),t[88]=He,t[89]=Ke,t[90]=qe):qe=t[90];let Je;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(Je=e=>{O.current&&(O.current=!1,e.preventDefault())},t[91]=Je):Je=t[91];let Ye;t[92]!==R||t[93]!==j||t[94]!==n||t[95]!==w||t[96]!==C||t[97]!==S?(Ye=!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Vw,{disabled:R,onSelect:()=>{O.current=!0,S(`file`,n.path)},children:[(0,$.jsx)(Pi,{"aria-hidden":`true`}),`New File`]}),(0,$.jsxs)(Vw,{disabled:R,onSelect:()=>{O.current=!0,S(`folder`,n.path)},children:[(0,$.jsx)(ei,{"aria-hidden":`true`}),`New Folder`]}),(0,$.jsx)(Ww,{}),(0,$.jsxs)(Vw,{onSelect:()=>C(n),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),(0,$.jsxs)(Vw,{onSelect:()=>w(n),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]}),(0,$.jsx)(Ww,{})]}),t[92]=R,t[93]=j,t[94]=n,t[95]=w,t[96]=C,t[97]=S,t[98]=Ye):Ye=t[98];let Xe;t[99]!==_||t[100]!==U?(Xe=()=>{O.current=!0,_(U)},t[99]=_,t[100]=U,t[101]=Xe):Xe=t[101];let Ze;t[102]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,$.jsx)(Ft,{"aria-hidden":`true`}),t[102]=Ze):Ze=t[102];let Qe;t[103]!==R||t[104]!==Xe?(Qe=(0,$.jsxs)(Vw,{disabled:R,onSelect:Xe,children:[Ze,`Rename`]}),t[103]=R,t[104]=Xe,t[105]=Qe):Qe=t[105];let et;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsxs)(Hw,{children:[(0,$.jsx)(Gr,{"aria-hidden":`true`}),`Copy Path`]}),t[106]=et):et=t[106];let tt=!p,nt;t[107]!==n||t[108]!==p?(nt=()=>{p&&lT(Sd(p.contentDir,cT(n),p.pathSeparator),`full path`)},t[107]=n,t[108]=p,t[109]=nt):nt=t[109];let rt;t[110]!==tt||t[111]!==nt?(rt=(0,$.jsx)(Vw,{disabled:tt,onSelect:nt,children:`Full Path`}),t[110]=tt,t[111]=nt,t[112]=rt):rt=t[112];let it;t[113]===n?it=t[114]:(it=(0,$.jsx)(Vw,{onSelect:()=>{lT(cT(n),`relative path`)},children:`Relative Path`}),t[113]=n,t[114]=it);let at;t[115]!==rt||t[116]!==it?(at=(0,$.jsxs)(zw,{children:[et,(0,$.jsxs)(Uw,{children:[rt,it]})]}),t[115]=rt,t[116]=it,t[117]=at):at=t[117];let st;t[118]!==m||t[119]!==j||t[120]!==n.path||t[121]!==p?(st=j&&(0,$.jsx)(Kw,{input:wd({docName:n.path,workspace:p}),installStates:m.installStates,isElectronHost:m.isElectronHost,dispatch:m.dispatch}),t[118]=m,t[119]=j,t[120]=n.path,t[121]=p,t[122]=st):st=t[122];let ct;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(ct=(0,$.jsx)(Ww,{}),t[123]=ct):ct=t[123];let lt;t[124]!==x||t[125]!==U?(lt=()=>{x(U)},t[124]=x,t[125]=U,t[126]=lt):lt=t[126];let ut;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(ut=(0,$.jsx)(It,{"aria-hidden":`true`}),t[127]=ut):ut=t[127];let dt;t[128]!==R||t[129]!==lt?(dt=(0,$.jsxs)(Vw,{variant:`destructive`,disabled:R,onSelect:lt,children:[ut,`Delete`]}),t[128]=R,t[129]=lt,t[130]=dt):dt=t[130];let ft;t[131]!==Ye||t[132]!==Qe||t[133]!==at||t[134]!==st||t[135]!==dt?(ft=(0,$.jsxs)(Bw,{onCloseAutoFocus:Je,children:[Ye,Qe,at,st,ct,dt]}),t[131]=Ye,t[132]=Qe,t[133]=at,t[134]=st,t[135]=dt,t[136]=ft):ft=t[136];let mt;t[137]!==Ve||t[138]!==qe||t[139]!==ft?(mt=(0,$.jsxs)(Ve,{children:[qe,ft]}),t[137]=Ve,t[138]=qe,t[139]=ft,t[140]=mt):mt=t[140];let ht;t[141]!==c||t[142]!==d||t[143]!==l||t[144]!==u||t[145]!==M||t[146]!==o||t[147]!==E||t[148]!==m||t[149]!==T||t[150]!==n.children||t[151]!==b||t[152]!==w||t[153]!==y||t[154]!==x||t[155]!==v||t[156]!==C||t[157]!==h||t[158]!==S||t[159]!==_||t[160]!==s||t[161]!==g||t[162]!==i||t[163]!==a||t[164]!==f||t[165]!==p?(ht=M&&(n.children.length>0||!!T)&&(0,$.jsxs)(Fy,{className:`mr-0 pr-0`,children:[T&&(0,$.jsx)(Iy,{children:(0,$.jsx)(fT,{...T})}),n.children.map(e=>(0,$.jsx)(hT,{node:e,selectedFilePath:i,selectedFolderPath:a,expandedPaths:o,onToggle:s,activeRowRef:c,editingPath:l,editingValue:u,busyPath:d,treeActionsLocked:f,workspace:p,handoff:m,onNavigate:h,prewarm:g,onStartRename:_,onEditingValueChange:v,onCommitRename:y,onCancelRename:b,onDelete:x,onStartCreating:S,onExpandSubtree:C,onCollapseSubtree:w,inlineCreate:E(e.path),getInlineCreate:E,nested:!0},e.path))]}),t[141]=c,t[142]=d,t[143]=l,t[144]=u,t[145]=M,t[146]=o,t[147]=E,t[148]=m,t[149]=T,t[150]=n.children,t[151]=b,t[152]=w,t[153]=y,t[154]=x,t[155]=v,t[156]=C,t[157]=h,t[158]=S,t[159]=_,t[160]=s,t[161]=g,t[162]=i,t[163]=a,t[164]=f,t[165]=p,t[166]=ht):ht=t[166];let gt;return t[167]!==B||t[168]!==mt||t[169]!==ht?(gt=(0,$.jsxs)(B,{children:[mt,ht]}),t[167]=B,t[168]=mt,t[169]=ht,t[170]=gt):gt=t[170],gt};function gT(e){let t=(0,Q.c)(91),{ref:n}=e,{activeDocName:r,activeTarget:i,closeDocument:a,prewarm:o}=Hn(),{addPage:s}=Se(),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=(0,Z.useState)(c),[d,f]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(ST),[C,w]=(0,Z.useState)(xT),{selectedFilePath:T,selectedFolderPath:E,navigationPath:D}=Iw(i,r),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(null),B;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(B={activationConstraint:{distance:12}},t[1]=B):B=t[1];let V=uS(lS(fC,B)),[H,U]=(0,Z.useState)(null),{states:W}=Wd(),{dispatch:G}=Nd(),K=typeof window<`u`&&window.okDesktop!=null,ee;t[2]!==G||t[3]!==W?(ee={installStates:W,isElectronHost:K,dispatch:G},t[2]=G,t[3]=W,t[4]=ee):ee=t[4];let te=ee,ne=bT,re,ie;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>{let e=!0,t=()=>fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(yT);e&&(t.ok&&n?.ok?(u(n.documents),m(null)):m(n?.error??`Server error (HTTP ${t.status})`))}).catch(t=>{e&&m(`Could not reach server`),console.warn(`[FileTree] fetch failed:`,t)}).finally(()=>{e&&f(!1)});t();let n=()=>{document.visibilityState===`visible`&&t()};window.addEventListener(`focus`,n),window.addEventListener(`visibilitychange`,n);let r=ce(e=>{e.includes(`files`)&&t()});return()=>{e=!1,window.removeEventListener(`focus`,n),window.removeEventListener(`visibilitychange`,n),r()}},ie=[],t[5]=re,t[6]=ie):(re=t[5],ie=t[6]),(0,Z.useEffect)(re,ie);let ae,oe;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{let e=!0;return fetch(`/api/workspace`).then(async t=>{let n=await t.json().catch(vT);e&&t.ok&&n?.ok&&typeof n.contentDir==`string`&&(n.pathSeparator===`/`||n.pathSeparator===`\\`)&&U({contentDir:n.contentDir,pathSeparator:n.pathSeparator})}).catch(_T),()=>{e=!1}},oe=[],t[7]=ae,t[8]=oe):(ae=t[7],oe=t[8]),(0,Z.useEffect)(ae,oe);let se;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(se=function(e,t){j({kind:e,parentDir:t}),N(``),L(null),t&&(S(e=>new Set(e).add(t)),w(e=>{let n=new Set(e);return n.delete(t),n}))},t[9]=se):se=t[9];let le=se,ue;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{S(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),w(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[10]=ue):ue=t[10];let fe=ue,pe;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=function(e){let t=Re([e]);(0,Z.startTransition)(()=>{w(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),S(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n})})},t[11]=pe):pe=t[11];let me=pe,he;t[12]===l?he=t[13]:(he=()=>({startCreating:le,expandAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{S(e),w(new Set)})},collapseAll(){let e=Re(de(l));(0,Z.startTransition)(()=>{w(e),S(new Set)})}}),t[12]=l,t[13]=he),(0,Z.useImperativeHandle)(n,he);let ge;t[14]===P?ge=t[15]:(ge=function(){P||(j(null),N(``),L(null))},t[14]=P,t[15]=ge);let ve=ge,ye;t[16]!==s||t[17]!==A||t[18]!==M?(ye=async function(){if(!A)return;let e=M.trim();if(!e){L(`Name is required`);return}if(e.includes(`..`)||e.startsWith(`/`)||e.includes(`\\`)||e.includes(`\0`)){L(`Invalid name`);return}let t=A.kind===`file`?De(A.parentDir,e):Ne(A.parentDir,e);F(!0),L(null);try{let e=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})}),n=null;try{n=await e.json()}catch(t){console.warn(`[FileTree] create response JSON parse failed:`,t,`status:`,e.status)}if(!e.ok||!n?.ok){let e=n?.error??`Failed to create ${A.kind}`;X.error(e),L(e),F(!1);return}let r=n.docName??t.replace(/\.md$/,``);j(null),N(``),L(null),F(!1),r&&sT(r),s(r),ze([`files`,`backlinks`,`graph`])}catch(e){console.warn(`[FileTree] create failed:`,e),X.error(`Network error — please try again`),L(`Network error — please try again`),F(!1)}},t[16]=s,t[17]=A,t[18]=M,t[19]=ye):ye=t[19];let be=ye,xe;t[20]!==r||t[21]!==a||t[22]!==_?(xe=async function(e){let t=iy(e.kind,_);if(!ay(t)){m(`Name must be a single path segment`);return}let n=oy(e,t);if(n===e.path){g(null),v(``),m(null);return}b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,i=e.kind===`file`?{docName:e.path,newDocName:n}:{kind:e.kind,fromPath:e.path,toPath:n},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),s=await o.json();if(!o.ok||!s.ok){m(s.error??`Failed to rename path`),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=ly(r,c);for(let e of c)a(e.fromDocName);u(e=>sy(e,c)),ze([`files`,`backlinks`,`graph`]),g(null),v(``),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] rename failed:`,e),m(`Network error — please try again`),b(null)}},t[20]=r,t[21]=a,t[22]=_,t[23]=xe):xe=t[23];let Ce=xe,we;t[24]!==r||t[25]!==a||t[26]!==h||t[27]!==k?(we=async function(e){b(e.path),k(null);try{let t=await fetch(`/api/delete-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e.kind,path:e.path})}),n=await t.json();if(!t.ok||!n.ok){X.error(n.error??`Failed to delete path`),b(null);return}let i=Array.isArray(n.deletedDocNames)?n.deletedDocNames:[],o=new Set(i);for(let e of o)a(e);u(e=>cy(e,i)),ze([`files`,`backlinks`,`graph`]),r&&o.has(r)&&(window.location.hash=``),h&&(o.has(h)||e.path===h)&&(g(null),v(``)),b(null)}catch(e){console.warn(`[FileTree] delete failed:`,e),X.error(`Network error — please try again`),b(null)}},t[24]=r,t[25]=a,t[26]=h,t[27]=k,t[28]=we):we=t[28];let Te=we,J;t[29]!==r||t[30]!==a?(J=async function(e,t){let n=Fw(e,t);if(!n.ok){if(n.reason===`no_op`)return;X.error(n.reason===`self`?`Cannot move a folder into itself`:`Cannot move a folder into one of its subfolders`);return}let i=n.destinationPath;b(e.path),m(null);try{let t=e.kind===`file`?`/api/rename`:`/api/rename-path`,n=e.kind===`file`?{docName:e.path,newDocName:i}:{kind:`folder`,fromPath:e.path,toPath:i},o=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),s=await o.json();if(!o.ok||!s.ok){let e=s.error??`Failed to move`;X.error(e),m(e),b(null);return}let c=Array.isArray(s.renamed)?s.renamed:[],l=ly(r,c);for(let e of c)a(e.fromDocName);u(e=>sy(e,c)),ze([`files`,`backlinks`,`graph`]);let d=i.split(`/`).filter(Boolean);d.length>1&&S(e=>{let t=new Set(e);for(let e=0;e<d.length-1;e++)t.add(d.slice(0,e+1).join(`/`));return t}),r&&l!==r&&(window.location.hash=`#/${l}`),b(null)}catch(e){console.warn(`[FileTree] move failed:`,e),X.error(`Network error — please try again`),b(null)}},t[29]=r,t[30]=a,t[31]=J):J=t[31];let Ee=J;if(d){let e;return t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`Loading...`})}),t[32]=e):e=t[32],e}if(p&&l.length===0){let e;return t[33]===p?e=t[34]:(e=(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/50`,children:p})}),t[33]=p,t[34]=e),e}if(l.length===0&&!A){let e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`select-none text-sm text-sidebar-foreground/30`,children:`No files yet.`}),t[35]=e):e=t[35];let n;return t[36]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-8`,children:[e,(0,$.jsx)(q,{variant:`link`,size:`sm`,className:`font-mono uppercase`,onClick:()=>le(`file`,``),children:`Create your first file`})]}),t[36]=n):n=t[36],n}let Oe=l.length>0?de(l):[],ke=Re(Oe),Ae=_e(D),je=new Set(Ae),Me=new Set;for(let e of je)ke.has(e)&&Me.add(e);for(let e of x)ke.has(e)&&Me.add(e);for(let e of C)ke.has(e)&&!je.has(e)&&Me.delete(e);let Y=function(e){if(je.has(e))return;let[t,n]=Me.has(e)?[w,S]:[S,w];t(t=>new Set(t).add(e)),n(t=>{let n=new Set(t);return n.delete(e),n})},Pe;t[37]!==P||t[38]!==I||t[39]!==A||t[40]!==M||t[41]!==ve||t[42]!==be?(Pe=function(e){return!A||A.parentDir!==e?null:{kind:A.kind,value:M,busy:P,error:I,onChange:N,onCommit:()=>void be(),onCancel:ve}},t[37]=P,t[38]=I,t[39]=A,t[40]=M,t[41]=ve,t[42]=be,t[43]=Pe):Pe=t[43];let Fe=Pe,Ie;t[44]===Fe?Ie=t[45]:(Ie=Fe(``),t[44]=Fe,t[45]=Ie);let Le=Ie,Be=y!==null||h!==null||A!==null,Ve=lw,He=xS,Ue;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=e=>{let{active:t}=e;z(t.data.current?.source??null)},t[46]=Ue):Ue=t[46];let We;t[47]===Ee?We=t[48]:(We=e=>{let{active:t,over:n}=e;if(z(null),!n)return;let r=t.data.current?.source,i=n.data.current?.destinationFolderPath;!r||typeof i!=`string`||Ee(r,i)},t[47]=Ee,t[48]=We);let Ge;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=()=>z(null),t[49]=Ge):Ge=t[49];let Ke=aT,qe;t[50]===p?qe=t[51]:(qe=p&&(0,$.jsx)(`span`,{role:`alert`,className:`px-3 pb-1 text-xs text-destructive`,children:p}),t[50]=p,t[51]=qe);let Je=Ay,Ye;t[52]===Le?Ye=t[53]:(Ye=Le&&(0,$.jsx)(jy,{children:(0,$.jsx)(fT,{...Le})}),t[52]=Le,t[53]=Ye);let Xe;t[54]===Be?Xe=t[55]:(Xe=(0,$.jsx)(mT,{treeActionsLocked:Be}),t[54]=Be,t[55]=Xe);let Ze=Oe.map(e=>(0,$.jsx)(hT,{node:e,selectedFilePath:T,selectedFolderPath:E,expandedPaths:Me,onToggle:Y,activeRowRef:ne,editingPath:h,editingValue:_,busyPath:y,treeActionsLocked:Be,workspace:H,handoff:te,onNavigate:sT,prewarm:o,onStartRename:e=>{g(e.path),v(e.name),m(null)},onEditingValueChange:v,onCommitRename:e=>void Ce(e),onCancelRename:()=>{y||(g(null),v(``))},onDelete:e=>k(e),onStartCreating:le,onExpandSubtree:fe,onCollapseSubtree:me,inlineCreate:Fe(e.path),getInlineCreate:Fe},e.path)),Qe;t[56]!==Je||t[57]!==Ye||t[58]!==Xe||t[59]!==Ze?(Qe=(0,$.jsxs)(Je,{children:[Ye,Xe,Ze]}),t[56]=Je,t[57]=Ye,t[58]=Xe,t[59]=Ze,t[60]=Qe):Qe=t[60];let $e=!!O,et;t[61]!==y||t[62]!==k?(et=e=>{!e&&!y&&k(null)},t[61]=y,t[62]=k,t[63]=et):et=t[63];let tt;t[64]!==y||t[65]!==O||t[66]!==Te?(tt=O&&(0,$.jsx)(Aw,{itemName:`${O.name}${O.kind===`file`?`.md`:`/`}`,isSubmitting:y===O.path,onDelete:()=>Te(O),customDescription:O.kind===`folder`?`Are you sure you want to delete ${O.name}/ and all files inside? This action cannot be undone.`:void 0}),t[64]=y,t[65]=O,t[66]=Te,t[67]=tt):tt=t[67];let nt;t[68]!==$e||t[69]!==et||t[70]!==tt?(nt=(0,$.jsx)(ln,{open:$e,onOpenChange:et,children:tt}),t[68]=$e,t[69]=et,t[70]=tt,t[71]=nt):nt=t[71];let rt;t[72]===R?rt=t[73]:(rt=R?(0,$.jsxs)(`div`,{className:`pointer-events-none flex max-w-[min(100vw-2rem,280px)] items-center gap-2 rounded-md border border-sidebar-border bg-sidebar px-3 py-1.5 text-sm shadow-lg`,children:[R.kind===`file`?(0,$.jsx)(Nn,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}):(0,$.jsx)(ti,{className:`size-4 shrink-0`,stroke:`var(--color-muted-foreground)`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sidebar-foreground`,children:[R.name,R.kind===`file`?`.md`:``]})]}):null,t[72]=R,t[73]=rt);let it;t[74]===rt?it=t[75]:(it=(0,$.jsx)(kw,{dropAnimation:null,children:rt}),t[74]=rt,t[75]=it);let at;t[76]!==R||t[77]!==Ke.Provider||t[78]!==qe||t[79]!==Qe||t[80]!==nt||t[81]!==it?(at=(0,$.jsxs)(Ke.Provider,{value:R,children:[qe,Qe,nt,it]}),t[76]=R,t[77]=Ke.Provider,t[78]=qe,t[79]=Qe,t[80]=nt,t[81]=it,t[82]=at):at=t[82];let ot;return t[83]!==Ve||t[84]!==V||t[85]!==He||t[86]!==Ue||t[87]!==We||t[88]!==Ge||t[89]!==at?(ot=(0,$.jsx)(Ve,{sensors:V,collisionDetection:He,onDragStart:Ue,onDragEnd:We,onDragCancel:Ge,children:at}),t[83]=Ve,t[84]=V,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=at,t[90]=ot):ot=t[90],ot}function _T(e){console.warn(`[FileTree] /api/workspace fetch failed:`,e)}function vT(){return null}function yT(){return null}function bT(e){e&&e.scrollIntoView({block:`nearest`})}function xT(){return new Set}function ST(){return new Set}function CT(e){e.stopPropagation()}function wT(e){let t=(0,Q.c)(13),{notice:n,onDismiss:r}=e,i=n.variant===`error`?`border-destructive/60`:`border-sidebar-border`,a=`update-notice-${n.id}`,o=`flex items-center gap-2 rounded-md border bg-sidebar-accent/30 px-2 py-1.5 text-xs text-muted-foreground ${i}`,s;t[0]===n.body?s=t[1]:(s=(0,$.jsx)(`span`,{className:`flex-1 leading-snug`,children:n.body}),t[0]=n.body,t[1]=s);let c;t[2]===n.action?c=t[3]:(c=n.action?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium underline underline-offset-2 decoration-muted-foreground/40 hover:text-sidebar-foreground hover:decoration-sidebar-foreground`,onClick:()=>{n.action?.onClick()},children:n.action.label}):null,t[2]=n.action,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(jt,{"aria-hidden":`true`,className:`size-3`}),t[4]=l):l=t[4];let u;t[5]===r?u=t[6]:(u=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-sidebar-foreground`,"aria-label":`Dismiss notice`,onClick:r,children:l}),t[5]=r,t[6]=u);let d;return t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"data-testid":a,className:o,children:[s,c,u]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12],d}function TT(e){if(e.length===0)return null;let t=e[0];if(!t)return null;for(let n=1;n<e.length;n++){let r=e[n];r&&r.priority<t.priority&&(t=r)}return t}function ET(){let e=(0,Q.c)(7),t=(0,Z.useSyncExternalStore)(Yl,Jl,Jl),n;e[0]===t?n=e[1]:(n=TT(t),e[0]=t,e[1]=n);let r=n;if(!r)return null;let i;e[2]===r.id?i=e[3]:(i=()=>{ql(r.id)},e[2]=r.id,e[3]=i);let a;return e[4]!==r||e[5]!==i?(a=(0,$.jsx)(`div`,{"data-testid":`update-notices-list`,children:(0,$.jsx)(wT,{notice:r,onDismiss:i})}),e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function DT(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(St,{name:`file-sidebar`,children:(0,$.jsx)(OT,{})}),e[0]=t):t=e[0],t}function OT(){let e=(0,Q.c)(8),t=(0,Z.useRef)(null),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`font-mono text-sm uppercase tracking-wider text-sidebar-foreground/50`,children:`Files`}),e[0]=n):n=e[0];let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(jg,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`Tree view options`,children:(0,$.jsx)(ui,{"aria-hidden":`true`})})})}),(0,$.jsx)($e,{children:`Tree view options`})]}),e[1]=r):r=e[1];let i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(Lg,{onSelect:()=>t.current?.expandAll(),children:[(0,$.jsx)(Hi,{"aria-hidden":`true`}),`Expand All`]}),e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(Ag,{children:[r,(0,$.jsxs)(Ig,{align:`end`,children:[i,(0,$.jsxs)(Lg,{onSelect:()=>t.current?.collapseAll(),children:[(0,$.jsx)($r,{"aria-hidden":`true`}),`Collapse All`]})]})]}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New file`,onClick:()=>t.current?.startCreating(`file`,``),children:(0,$.jsx)(Pi,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New File`})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Dy,{children:(0,$.jsx)(Ay,{children:(0,$.jsx)(jy,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[n,(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,o,(0,$.jsxs)(ot,{children:[(0,$.jsx)(pt,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`New folder`,onClick:()=>t.current?.startCreating(`folder`,``),children:(0,$.jsx)(ei,{"aria-hidden":`true`})})}),(0,$.jsx)($e,{children:`New Folder`})]})]})]})})})}),e[5]=s):s=e[5];let c;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(ky,{children:(0,$.jsx)(gT,{ref:t})}),e[6]=c):c=e[6];let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(wy,{variant:`inset`,children:[s,c,(0,$.jsx)(Oy,{children:(0,$.jsx)(ET,{})})]}),e[7]=l):l=e[7],l}function kT(){let e=(0,Q.c)(11),t=Ke(),{activeDocName:n,pinnedDoc:r,collabUrl:i,setSystemProvider:a}=Hn(),o=(0,Z.useRef)(n),s=(0,Z.useRef)(r),c,l;e[0]===n?(c=e[1],l=e[2]):(c=()=>{o.current=n},l=[n],e[0]=n,e[1]=c,e[2]=l),(0,Z.useEffect)(c,l);let u=(0,Z.useRef)(null),d,f;e[3]===r?(d=e[4],f=e[5]):(d=()=>{let e=s.current!==null;if(s.current=r,!(e&&r===null)||Date.now()-xn()<3e3)return;let t=u.current?.awareness;if(!t)return;let n=Yy(t,Date.now());n&&n!==o.current&&(window.location.hash=me(n))},f=[r],e[3]=r,e[4]=d,e[5]=f),(0,Z.useEffect)(d,f);let p,m;return e[6]!==i||e[7]!==t||e[8]!==a?(p=()=>{if(i===null)return;let e=new Tn,n=new Pn({url:i,name:v,document:e,onStateless:NT,onClose:MT,onDisconnect:jT}),r=ce(e=>{(e.includes(`files`)||e.includes(`backlinks`))&&(t.invalidateQueries({queryKey:[`backlinks`]}),t.invalidateQueries({queryKey:[`forward-links`]})),(e.includes(`files`)||e.includes(`graph`))&&(t.invalidateQueries({queryKey:[`orphans`]}),t.invalidateQueries({queryKey:[`hubs`]}))});n.on(`synced`,AT);let c=null,l=new Set,d=()=>{if(c=null,s.current!==null||Date.now()-xn()<3e3)return;let e=n.awareness;if(!e)return;let t=Yy(e,Date.now());t&&t!==o.current&&(window.location.hash=me(t))},f=()=>{if(n.awareness)for(let[e,t]of n.awareness.getStates().entries())l.has(e)||t.user?.type===`agent`&&(l.add(e),console.warn(`[agent-presence] observed stale AwarenessUser.type === 'agent' from clientID ${e} — probably a stale bundled client`));c!==null&&clearTimeout(c),c=setTimeout(d,300)};return n.awareness?.on(`change`,f),u.current=n,a(n),()=>{r(),c!==null&&clearTimeout(c),n.awareness?.off(`change`,f),a(null),n.destroy(),e.destroy(),u.current=null}},m=[t,i,a],e[6]=i,e[7]=t,e[8]=a,e[9]=p,e[10]=m):(p=e[9],m=e[10]),(0,Z.useEffect)(p,m),null}function AT(){ze([`files`,`backlinks`,`graph`])}function jT(){console.warn(`[CC1] __system__ disconnected - derived views may be stale`)}function MT(e){let{event:t}=e;console.warn(`[CC1] __system__ connection closed:`,t.code,t.reason)}function NT(e){let{payload:t}=e,n=vn(t);if(!n){console.warn(`[CC1] Unparseable stateless payload, skipping:`,t.slice(0,100));return}ze([n.ch])}function PT(){let t=(0,Q.c)(7),{clearTarget:n}=Hn(),{openTargetTransition:r}=Jt(),{folderPaths:i,loading:a,pages:o}=Se(),s,c;return t[0]!==n||t[1]!==i||t[2]!==a||t[3]!==r||t[4]!==o?(s=()=>{t();function t(){let t=Te(window.location.hash);if(!t){bn(`ok/nav/hash-change`,{docName:null,kind:`clear`}),n();return}if(a){bn(`ok/nav/hash-change`,{docName:t,kind:`deferred-loading`});return}let s=e(t,{pages:o,folderPaths:i});bn(`ok/nav/hash-change`,{docName:t,kind:s.kind}),r(s)}return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},c=[n,i,a,r,o],t[0]=n,t[1]=i,t[2]=a,t[3]=r,t[4]=o,t[5]=s,t[6]=c):(s=t[5],c=t[6]),(0,Z.useEffect)(s,c),null}function FT(){let e=(0,Q.c)(8),{activeDocName:t,activeTarget:n}=Hn(),[r,i]=(0,Z.useState)(!1),a;e[0]!==t||e[1]!==n?(a=n?.kind===`folder`?n.folderPath:re(t),e[0]=t,e[1]=n,e[2]=a):a=e[2];let o=a,s,c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=function(e){let t=e.target;Qt({target:t,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,key:e.key})&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},c=[],e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l;return e[5]!==r||e[6]!==o?(l=(0,$.jsx)(Ct,{open:r,onOpenChange:i,kind:`file`,initialDir:o}),e[5]=r,e[6]=o,e[7]=l):l=e[7],l}function IT(){let e=(0,Q.c)(7),t=typeof window<`u`?window.okDesktop??null:null,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Qd,{}),e[0]=n):n=e[0];let r,i,a,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(kT,{}),i=(0,$.jsx)(PT,{}),a=(0,$.jsx)(FT,{}),o=t?(0,$.jsx)(qd,{bridge:t}):null,e[1]=r,e[2]=i,e[3]=a,e[4]=o):(r=e[1],i=e[2],a=e[3],o=e[4]);let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(DT,{}),e[5]=s):s=e[5];let c;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(St,{name:`app`,children:(0,$.jsxs)(un,{children:[n,(0,$.jsxs)(oe,{children:[r,i,a,o,(0,$.jsxs)(xy,{className:`h-screen overflow-hidden`,children:[s,(0,$.jsx)(Ey,{className:`overflow-hidden h-[calc(100vh-var(--layout-inset-offset))]`,children:(0,$.jsx)(Sx,{})})]})]})]})}),e[6]=c):c=e[6],c}typeof window<`u`&&window.okDesktop?.config.apiOrigin&&Tl({apiOrigin:window.okDesktop.config.apiOrigin}),typeof window<`u`&&kl({bridge:window.okDesktop}),Xl(),typeof window<`u`&&Ol({bridge:window.okDesktop});var LT=new br({defaultOptions:{queries:{retry:1,staleTime:1e4}}}),RT=document.getElementById(`root`);if(!RT)throw Error(`Root element not found`);var zT=typeof window<`u`&&window.okDesktop?.config.mode===`navigator`;(0,Wi.createRoot)(RT).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(ae,{client:LT,children:(0,$.jsxs)(K,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,storageKey:`ok-theme-v1`,children:[(0,$.jsx)(ut,{children:zT&&window.okDesktop?(0,$.jsx)(bl,{bridge:window.okDesktop}):(0,$.jsx)(IT,{})}),(0,$.jsx)(wl,{richColors:!0})]})})}));
|