@inkeep/open-knowledge 0.4.0-beta.11 → 0.4.0-beta.13

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.
@@ -36,7 +36,7 @@ Error generating stack: `+e.message+`
36
36
  This template lives at an ancestor folder — deleting affects every folder under that ancestor that does not shadow it locally.`:``}`}),t[25]=s,t[26]=l,t[27]=m,t[28]=D):D=t[28];let O;t[29]!==T||t[30]!==E||t[31]!==D?(O=(0,Z.jsx)(yi,{open:T,onOpenChange:E,children:D}),t[29]=T,t[30]=E,t[31]=D,t[32]=O):O=t[32];let k;t[33]===g?k=t[34]:(k=new Set(g.map(Gj)),t[33]=g,t[34]=k);let A;t[35]!==n||t[36]!==d||t[37]!==i||t[38]!==k?(A=(0,Z.jsx)(jj,{folderPath:n,existingNames:k,open:d,onOpenChange:f,onCreated:i}),t[35]=n,t[36]=d,t[37]=i,t[38]=k,t[39]=A):A=t[39];let j;return t[40]!==w||t[41]!==O||t[42]!==A||t[43]!==S?(j=(0,Z.jsxs)(Z.Fragment,{children:[S,w,O,A]}),t[40]=w,t[41]=O,t[42]=A,t[43]=S,t[44]=j):j=t[44],j}function Gj(e){return e.name}function Kj(e){let t=(0,$.c)(35),{template:n,onEdit:r,onDelete:i}=e,a=n.title&&n.title!==n.name,o=n.title??n.name,s;t[0]===o?s=t[1]:(s=(0,Z.jsx)(`span`,{className:`font-medium truncate`,children:o}),t[0]=o,t[1]=s);let c;t[2]!==a||t[3]!==n.name?(c=a?(0,Z.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=a,t[3]=n.name,t[4]=c):c=t[4];let l;t[5]===n.scope?l=t[6]:(l=n.scope===`inherited`?(0,Z.jsx)(pn,{variant:`gray`,className:`ml-auto shrink-0 text-2xs`,children:`inherited`}):null,t[5]=n.scope,t[6]=l);let u;t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[s,c,l]}),t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.description?d=t[12]:(d=n.description?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[11]=n.description,t[12]=d);let f;t[13]!==r||t[14]!==u||t[15]!==d?(f=(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,children:[u,d]}),t[13]=r,t[14]=u,t[15]=d,t[16]=f):f=t[16];let p=`Actions for ${n.title??n.name}`,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Pa,{className:`size-4`,"aria-hidden":!0}),t[17]=m):m=t[17];let h;t[18]===p?h=t[19]:(h=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100`,"aria-label":p,children:m})}),t[18]=p,t[19]=h);let g;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(dn,{"aria-hidden":!0}),t[20]=g):g=t[20];let _;t[21]===r?_=t[22]:(_=(0,Z.jsxs)(EA,{onSelect:r,children:[g,`Edit`]}),t[21]=r,t[22]=_);let v;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Kn,{"aria-hidden":!0}),t[23]=v):v=t[23];let y;t[24]===i?y=t[25]:(y=(0,Z.jsxs)(EA,{variant:`destructive`,onSelect:i,children:[v,`Delete`]}),t[24]=i,t[25]=y);let b;t[26]!==_||t[27]!==y?(b=(0,Z.jsxs)(TA,{align:`end`,children:[_,y]}),t[26]=_,t[27]=y,t[28]=b):b=t[28];let x;t[29]!==h||t[30]!==b?(x=(0,Z.jsxs)(CA,{children:[h,b]}),t[29]=h,t[30]=b,t[31]=x):x=t[31];let S;return t[32]!==x||t[33]!==f?(S=(0,Z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,children:[f,x]}),t[32]=x,t[33]=f,t[34]=S):S=t[34],S}function qj(e){let t=(0,$.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=J(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=J(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,Z.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,Z.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function Jj(e){let t=(0,$.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=J(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yj(e){let t=(0,$.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=J(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xj(e){let t=(0,$.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=J(`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,Z.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function Zj(e){let t=(0,$.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=J(`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,Z.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 Qj(e){let t=(0,$.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=J(`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,Z.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $j(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 eM(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 tM(e){let t=(0,$.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,Z.jsx)(Bn,{className:`ml-1 size-3`}):(0,Z.jsx)(ur,{className:`ml-1 size-3`}):(0,Z.jsx)(ma,{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,Z.jsxs)(Y,{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 nM(e){let t=(0,$.c)(98),{folderPath:n}=e,{addPage:r,folderPaths:i,loading:a,pages:o,pageTitles:s,pageMeta:c}=Ee(),{state:l,refresh:u}=Nj(n),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(`name`),[y,b]=(0,Q.useState)(`asc`);if(a){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Br,{className:`size-5 rounded`}),(0,Z.jsx)(Br,{className:`h-7 w-48`})]}),(0,Z.jsx)(Br,{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,Z.jsx)(Br,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.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,Z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,Z.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Br,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(oM)]})]})}),t[2]=r):r=t[2],r}let x,S,C,w,T,E,D,O,k,A;if(t[3]!==r||t[4]!==h||t[5]!==p||t[6]!==l||t[7]!==n||t[8]!==i||t[9]!==c||t[10]!==s||t[11]!==o||t[12]!==u||t[13]!==y||t[14]!==_){let e=yj(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=eM(e.children,_,y),d;t[25]===_?d=t[26]:(d=function(e){e===_?b(aM):(v(e),b(`asc`))},t[25]=_,t[26]=d);let j=d,M;t[27]!==r||t[28]!==n?(M=async function(){m(!0),g(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(iM);if(!t.ok||!i?.ok){g(i?.error??`Server error (HTTP ${t.status})`),m(!1);return}let a=i.docName??`${n}/index`;r(a),Ze([`files`,`backlinks`,`graph`]),window.location.hash=Ie(a)}catch(e){console.warn(`[FolderOverview] create index note failed:`,e),g(`Network error — please try again`)}m(!1)},t[27]=r,t[28]=n,t[29]=M):M=t[29];let N=M;A=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,E=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let P;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(On,{className:`size-5 text-muted-foreground`}),t[30]=P):P=t[30];let F=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,(0,Z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(co,{className:`size-4`}),t[31]=I):I=t[31];let L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsxs)(Y,{children:[I,`New`,(0,Z.jsx)(Mn,{className:`size-3`})]})}),t[32]=L):L=t[32];let R;t[33]===N?R=t[34]:(R=()=>void N(),t[33]=N,t[34]=R);let z;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:`Index note`}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Landing page for this folder`})]}),t[35]=z):z=t[35];let B;t[36]!==p||t[37]!==R?(B=(0,Z.jsx)(EA,{disabled:p,onSelect:R,children:z}),t[36]=p,t[37]=R,t[38]=B):B=t[38];let V;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(EA,{onSelect:()=>f(!0),children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:`Note`}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`New note inside this folder`})]})}),t[39]=V):V=t[39];let H;t[40]===B?H=t[41]:(H=(0,Z.jsxs)(CA,{children:[L,(0,Z.jsxs)(TA,{align:`end`,children:[B,V]})]}),t[40]=B,t[41]=H);let U;t[42]!==F||t[43]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[F,H]}),t[42]=F,t[43]=H,t[44]=U):U=t[44];let W;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,Z.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[45]=W):W=t[45];let G;t[46]===h?G=t[47]:(G=h?(0,Z.jsx)(`span`,{role:`alert`,className:`text-sm text-destructive`,children:h}):null,t[46]=h,t[47]=G),t[48]!==U||t[49]!==G?(D=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[U,W,G]}),t[48]=U,t[49]=G,t[50]=D):D=t[50],t[51]!==l||t[52]!==n||t[53]!==u?(O=(0,Z.jsx)(pj,{folderPath:n,state:l,onChange:u}),k=(0,Z.jsx)(Wj,{folderPath:n,state:l,onChange:u}),t[51]=l,t[52]=n,t[53]=u,t[54]=O,t[55]=k):(O=t[54],k=t[55]),T=`rounded-lg border`,S=qj;let ee=_===`name`?y===`asc`?`ascending`:`descending`:`none`,te;t[56]!==j||t[57]!==y||t[58]!==_?(te=(0,Z.jsx)(tM,{label:`Name`,sortKey:`name`,activeKey:_,activeDir:y,onSort:j}),t[56]=j,t[57]=y,t[58]=_,t[59]=te):te=t[59];let ne;t[60]!==ee||t[61]!==te?(ne=(0,Z.jsx)(Zj,{"aria-sort":ee,children:te}),t[60]=ee,t[61]=te,t[62]=ne):ne=t[62];let re=_===`modified`?y===`asc`?`ascending`:`descending`:`none`,ie;t[63]!==j||t[64]!==y||t[65]!==_?(ie=(0,Z.jsx)(tM,{label:`Modified`,sortKey:`modified`,activeKey:_,activeDir:y,onSort:j}),t[63]=j,t[64]=y,t[65]=_,t[66]=ie):ie=t[66];let ae;t[67]!==re||t[68]!==ie?(ae=(0,Z.jsx)(Zj,{className:`w-32`,"aria-sort":re,children:ie}),t[67]=re,t[68]=ie,t[69]=ae):ae=t[69],t[70]!==ne||t[71]!==ae?(w=(0,Z.jsx)(Jj,{children:(0,Z.jsxs)(Xj,{children:[ne,ae]})}),t[70]=ne,t[71]=ae,t[72]=w):w=t[72],x=Yj,C=a.length?a.map(rM):(0,Z.jsx)(Xj,{children:(0,Z.jsx)(Qj,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=r,t[4]=h,t[5]=p,t[6]=l,t[7]=n,t[8]=i,t[9]=c,t[10]=s,t[11]=o,t[12]=u,t[13]=y,t[14]=_,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E,t[21]=D,t[22]=O,t[23]=k,t[24]=A}else x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20],D=t[21],O=t[22],k=t[23],A=t[24];let j;t[73]!==x||t[74]!==C?(j=(0,Z.jsx)(x,{children:C}),t[73]=x,t[74]=C,t[75]=j):j=t[75];let M;t[76]!==S||t[77]!==w||t[78]!==j?(M=(0,Z.jsxs)(S,{children:[w,j]}),t[76]=S,t[77]=w,t[78]=j,t[79]=M):M=t[79];let N;t[80]!==M||t[81]!==T?(N=(0,Z.jsx)(`div`,{className:T,children:M}),t[80]=M,t[81]=T,t[82]=N):N=t[82];let P;t[83]!==N||t[84]!==E||t[85]!==D||t[86]!==O||t[87]!==k?(P=(0,Z.jsxs)(`div`,{className:E,children:[D,O,k,N]}),t[83]=N,t[84]=E,t[85]=D,t[86]=O,t[87]=k,t[88]=P):P=t[88];let F;t[89]!==P||t[90]!==A?(F=(0,Z.jsx)(`div`,{className:A,children:P}),t[89]=P,t[90]=A,t[91]=F):F=t[91];let I;t[92]!==d||t[93]!==n?(I=(0,Z.jsx)(Pn,{open:d,onOpenChange:f,kind:`file`,initialDir:n}),t[92]=d,t[93]=n,t[94]=I):I=t[94];let L;return t[95]!==F||t[96]!==I?(L=(0,Z.jsxs)(Z.Fragment,{children:[F,I]}),t[95]=F,t[96]=I,t[97]=L):L=t[97],L}function rM(e){return(0,Z.jsxs)(Xj,{children:[(0,Z.jsx)(Qj,{children:(0,Z.jsxs)(`a`,{href:Ie(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,Z.jsx)(Va,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(Xt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(Qj,{className:`text-muted-foreground`,children:e.kind===`file`?$j(e.modified):`—`})]},e.path)}function iM(){return null}function aM(e){return e===`asc`?`desc`:`asc`}function oM(e){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,Z.jsx)(Br,{className:`size-4 rounded`}),(0,Z.jsx)(Br,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Br,{className:`h-4 w-16`})})]},e)}var sM=(0,Q.createContext)(null);function cM(e){let t=(0,$.c)(7),{children:n}=e,[r,i]=(0,Q.useState)(lM),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>{i(t=>{let n=new Map(t);return n.set(e,(t.get(e)??0)+1),n})},t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>{i(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},t[1]=s):s=t[1];let c=s,l;t[2]===r?l=t[3]:(l={addPropertySignal:r,requestAddProperty:o,clearAddProperty:c},t[2]=r,t[3]=l);let u=l,d;return t[4]!==n||t[5]!==u?(d=(0,Z.jsx)(sM,{value:u,children:n}),t[4]=n,t[5]=u,t[6]=d):d=t[6],d}function lM(){return new Map}function uM(){let e=(0,Q.use)(sM);if(e===null)throw Error(`useProperties must be used within <PropertyProvider />`);return e}var dM=yt(`group/button-group flex w-fit items-stretch *:focus-visible:relative *:focus-visible:z-10 has-[>[data-slot=button-group]]:gap-2 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-lg [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-r-lg!`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot]:not(:has(~[data-slot]))]:rounded-b-lg!`}},defaultVariants:{orientation:`horizontal`}});function fM(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]!==n||t[5]!==r?(a=J(dM({orientation:r}),n),t[4]=n,t[5]=r,t[6]=a):a=t[6];let o;return t[7]!==r||t[8]!==i||t[9]!==a?(o=(0,Z.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":r,className:a,...i}),t[7]=r,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}function pM(e){let t=(0,$.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=J(`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,Z.jsx)(Uy,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mM(e){let t=(0,$.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,Z.jsx)(Ky,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function hM(e){let t=(0,$.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=J(`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,Z.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,Z.jsx)(Xy,{"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 gM=960,_M=1024;function vM(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(bM),[r,i]=(0,Q.useState)(yM),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${gM-1}px)`),t=window.matchMedia(`(max-width: ${_M-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Q.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 yM(){return window.innerWidth>=gM&&window.innerWidth<_M}function bM(){return window.innerWidth<gM?`sheet`:`panel`}var xM={words:0,chars:0,tokens:0},SM=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,CM=/[\p{L}\p{N}]/u,wM=new Set([`text`,`inlineCode`,`code`,`tag`]),TM=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),EM=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function DM(e,t){if(!e)return;let n=e.type;if(!TM.has(n)){if(wM.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
37
37
  `));return}if(n===`wikiLink`||n===`wikiLinkEmbed`){let n=e.data?.alias??e.value??``;n&&t.push(n);return}if(Array.isArray(e.children)){for(let n of e.children)DM(n,t);if(EM.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
38
38
  `)&&t.push(`
39
- `)}}}}function OM(e){try{let t=bn().parseToMdast(e),n=[];return DM(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function kM(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))CM.test(n)&&t++;return t}function AM(e){let t=globalThis.Intl.Segmenter;if(!t)return kM(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function jM(e){let t=SM.test(e)?1.5:4;return Math.ceil(e.length/t)}function MM(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Ae(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=OM(t);return n?{words:SM.test(n)?AM(n):kM(n),chars:n.length,tokens:jM(n)}:{words:0,chars:0,tokens:0}}var NM=300;function PM(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(xM),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(xM);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(MM(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,NM)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function FM(e){let t=(0,$.c)(3),[n,r]=(0,Q.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`?IM: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,Q.useEffect)(i,a),n}function IM(e){return e===`synced`?`synced`:`connected`}var LM=Le;function RM(e,t={}){let n=rr(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var zM=4;function BM(e){let t=(0,$.c)(8),{editor:n}=e,r=mr(n),i=!!(n&&r&&r.ancestorChain.length>0),a=i?void 0:`true`,o=`jsx-component-breadcrumb flex items-center gap-1 min-h-[28px] px-3 py-1.5 text-xs font-mono text-muted-foreground overflow-hidden ${i?`border-t border-border`:``}`,s;t[0]!==r||t[1]!==n||t[2]!==i?(s=i&&r?(0,Z.jsx)(HM,{editor:n,blockSelection:r}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsx)(`nav`,{"aria-label":`Block ancestor navigation`,"aria-hidden":a,className:o,children:s}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function VM(e,t){let n=rn.getState(e.state)?.posToId;if(!n)return t.pos;for(let[e,r]of n)if(r===t.bridgeId)return e;return null}function HM(e){let t=(0,$.c)(9),{editor:n,blockSelection:r}=e,{ancestorChain:i,selectedBlockId:a}=r,o;if(t[0]!==i||t[1]!==n||t[2]!==a){let e=GM(i),r;t[4]===n?r=t[5]:(r=(0,Z.jsx)(`button`,{type:`button`,className:`opacity-60 hover:opacity-100 hover:text-foreground transition-opacity outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,onClick:()=>{n.chain().focus().setTextSelection(0).command(WM).run()},children:Gt}),t[4]=n,t[5]=r);let s;t[6]!==n||t[7]!==a?(s=e=>{if(e.kind===`ellipsis`)return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(An,{size:12,className:`opacity-50`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{role:`img`,"aria-label":`${e.hiddenCount} hidden ancestors`,title:`${e.hiddenCount} hidden ancestors`,className:`opacity-60`,children:`…`})]},`ellipsis`);let t=RM(e.entry),r=e.entry.bridgeId===a;return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(An,{size:12,className:`opacity-50 shrink-0`,"aria-hidden":`true`}),r?(0,Z.jsx)(`span`,{"aria-current":`location`,className:`text-foreground truncate`,children:t}):(0,Z.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm truncate`,onClick:()=>{let t=VM(n,e.entry);t!==null&&n.chain().focus().setNodeSelection(t).command(UM).run()},children:t})]},e.entry.bridgeId)},t[6]=n,t[7]=a,t[8]=s):s=t[8],o=(0,Z.jsxs)(Z.Fragment,{children:[r,e.map(s)]}),t[0]=i,t[1]=n,t[2]=a,t[3]=o}else o=t[3];return o}function UM(e){let{tr:t}=e;return t.setMeta(xn,`programmatic`),!0}function WM(e){let{tr:t}=e;return t.setMeta(xn,`programmatic`),!0}function GM(e){if(e.length<=zM)return e.map(e=>({kind:`entry`,entry:e}));let t=e[0],n=e.slice(-2),r=e.length-1-n.length;return[{kind:`entry`,entry:t},{kind:`ellipsis`,hiddenCount:r},...n.map(e=>({kind:`entry`,entry:e}))]}var KM=200,qM=`Outside any block`;function JM(e){let t=(0,$.c)(5),{editor:n}=e,r=mr(n),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?YM(n,r):o.current?qM:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},KM),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function YM(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=RM(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=RM(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function XM(){let[e]=(0,Q.useState)(K);return e}function ZM({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:z(e.display_name),color:ke(e.id,ee),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:ke(e.id,ee),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function QM(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 $M=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&&pt(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(je(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Re(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(pe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Se(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(_e(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(lt(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ke(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=V(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Be){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 xe){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():QM(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&I(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()}},eN=e=>new ie({key:typeof e.pluginKey==`string`?new ae(e.pluginKey):e.pluginKey,view:t=>new $M({view:t,...e})});Qe.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[eN({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 tN=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 Te(e,{textSerializers:ht(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(je(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Re(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(pe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Se(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(_e(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(lt(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ke(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=V(this.view,e.from,e.to);I({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()}},nN=e=>new ie({key:typeof e.pluginKey==`string`?new ae(e.pluginKey):e.pluginKey,view:t=>new tN({view:t,...e})});Qe.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?[nN({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 rN(e,t){return e??new ae(t)}var iN=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,aN=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),oN=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(`.`)),sN=new Set([`children`,`className`,`style`]),cN=new Set([`tabIndex`]),lN=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),uN={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function dN(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function fN(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function pN(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||lN.has(e)}function mN(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function hN(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:uN[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function gN(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 _N(e){return cN.has(e)}function vN(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function yN(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 bN(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||oN.has(e)?String(t):`${t}px`}function xN(e,t){aN.has(t)||e.style.removeProperty(mN(t))}function SN(e,t,n){aN.has(t)||e.style.setProperty(mN(t),bN(t,n))}function CN(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(sN.has(r)||!pN(r)||dN(r,t[r])||dN(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=fN(r);if(a==null||a===!1){_N(r)&&yN(e,r),e.removeAttribute(o);return}if(a===!0){_N(r)&&vN(e,r,!0),e.setAttribute(o,``);return}if(_N(r)){vN(e,r,a);return}e.setAttribute(o,String(a))})}function wN(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function TN(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){xN(e,t);return}SN(e,t,a)}})}function EN(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(!dN(t,n))return;let{eventName:i,options:a}=hN(t),o=t=>{n(gN(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function DN(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);iN(()=>{let i=n.current;return wN(e,i.className,t.className),TN(e,i.style,t.style),CN(e,i,t),r.current=EN(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 ON=Q.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,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(rN(e,`bubbleMenu`)).current;DN(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=hr(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.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=eN({...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,Q.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,_a.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(rN(e,`floatingMenu`)).current;DN(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=hr(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.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=nN({...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,Q.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,_a.createPortal)(s,u.current)});var kN=[{name:`paragraph`,label:`Text`,icon:so,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Qt,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:En,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:en,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:yn,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:ln,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:bo,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function AN(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:jN},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Sn(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,Z.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Mn,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsxs)(Y,{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=kN.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(EA,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.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,Z.jsx)(TA,{align:`start`,sideOffset:8,className:`w-44 max-h-(--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,Z.jsxs)(CA,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function jN(e){let t=Object.fromEntries(kN.map(t=>[t.name,t.isActive(e.editor)]));return{current:kN.find(e=>t[e.name])??kN[0],activeStates:t}}var MN=[{name:`bold`,icon:ga,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:qa,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Oo,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Co,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:Da,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ka,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function NN(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:PN},t[0]=n,t[1]=r);let i=Sn(r),a;t[2]!==i||t[3]!==n?(a=MN.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(wi,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.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,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function PN(e){return Object.fromEntries(MN.map(t=>[t.name,t.isActive(e.editor)]))}function FN(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.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,Q.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,Q.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,Z.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,Z.jsx)(ja,{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,Z.jsx)(Y,{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,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),vr(d)},children:(0,Z.jsx)(ti,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(Kn,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{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,Z.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,Z.jsx)(Za,{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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsxs)(wi,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.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,Z.jsxs)(Ei,{children:[T,E]}),t[44]=T,t[45]=D),D}function IN({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 LN(e){let t=(0,$.c)(25),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return V(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=se(e,t,()=>{I(e,t,{placement:`top`,strategy:`fixed`,middleware:[it(8),je(),Re({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(BN)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let l=c,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{o.current?.(),o.current=null,a(zN)},t[6]=u):u=t[6];let d=u,f;t[7]===l?f=t[8]:(f={onShow:l,onHide:d,strategy:`fixed`},t[7]=l,t[8]=f);let p;t[9]===n?p=t[10]:(p=(0,Z.jsx)(AN,{editor:n}),t[9]=n,t[10]=p);let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=m):m=t[11];let h;t[12]!==n||t[13]!==i?(h=(0,Z.jsx)(NN,{editor:n},i),t[12]=n,t[13]=i,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=g):g=t[15];let _=`${i}-link`,v;t[16]!==n||t[17]!==_?(v=(0,Z.jsx)(FN,{editor:n},_),t[16]=n,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==n||t[20]!==v||t[21]!==f||t[22]!==p||t[23]!==h?(y=(0,Z.jsxs)(ON,{ref:r,editor:n,appendTo:RN,shouldShow:IN,updateDelay:250,options:f,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[p,m,h,g,v]}),t[19]=n,t[20]=v,t[21]=f,t[22]=p,t[23]=h,t[24]=y):y=t[24],y}function RN(){return document.body}function zN(e){return e+1}function BN(){}var VN=[{name:`addRowBefore`,icon:Bn,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:ur,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:Kn,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],HN=[{name:`addColumnBefore`,icon:Er,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Qr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:Kn,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],UN=[{name:`toggleHeaderRow`,icon:To,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:ka,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:Ua,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function WN({editor:e}){return e.isActive(`table`)}function GN(e){let t=(0,$.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,Z.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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsx)(wi,{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,Z.jsxs)(Ei,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function KN(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=VN.map(e=>(0,Z.jsx)(GN,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ng,{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=HN.map(e=>(0,Z.jsx)(GN,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Ng,{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=UN.map(e=>(0,Z.jsx)(GN,{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,Z.jsxs)(ON,{editor:n,shouldShow:WN,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 qN=new WeakMap;function JN(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=ft(e.color),n.textContent=e.name,t.append(n),t}var YN={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},XN=e=>{let t=(0,$.c)(66),{provider:n,placeholder:r,isSourceMode:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(YN),s=XM(),{principal:c,activeDocName:l}=Qn(),u=n.configuration.name??``,[d]=(0,Q.useState)(ZN),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null);if(m)throw m;let g=(0,Q.useRef)(null),_;t[0]!==d||t[1]!==u||t[2]!==r||t[3]!==n?(_=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=gn({docName:u,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new Me({element:e,onBeforeCreate:e=>{let{editor:n}=e;qN.set(n,t)},onCreate:e=>{let{editor:t}=e;d.html.setView(t.view);let r=qN.get(t);if(qN.delete(t),r==null)return;let i=performance.now();Wt(`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-4 pb-4 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=d.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>d.text(e,t),clipboardSerializer:d.html.serializer,handlePaste:(e,t)=>d.paste(e,t),handleDrop:(e,t)=>d.drop(e,t)},extensions:xu([...Hn.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:n.configuration.name??``}):e),LM.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),Yt.configure({document:n.document}),Qe.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[tn]}}),Qe.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[Xn(e,{cursorBuilder:JN})]}})])}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),g.current=e,p(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),g.current=null,p(null),h(t instanceof Error?t:Error(String(t)))}return()=>{let e=g.current;e&&Vn(e),g.current=null,p(null)}},t[0]=d,t[1]=u,t[2]=r,t[3]=n,t[4]=_):_=t[4];let v;t[5]!==d||t[6]!==u||t[7]!==n?(v=[u,n,d],t[5]=d,t[6]=u,t[7]=n,t[8]=v):v=t[8],(0,Q.useEffect)(_,v);let y;t[9]!==f||t[10]!==n.configuration.name?(y=()=>{if(f)return jn(f,n.configuration.name??null),()=>{jn(f,null)}},t[9]=f,t[10]=n.configuration.name,t[11]=y):y=t[11];let b;t[12]!==f||t[13]!==n?(b=[f,n],t[12]=f,t[13]=n,t[14]=b):b=t[14],(0,Q.useEffect)(y,b);let x;t[15]!==f||t[16]!==n.configuration.name?(x=()=>{},t[15]=f,t[16]=n.configuration.name,t[17]=x):x=t[17];let S;t[18]!==f||t[19]!==n?(S=[f,n],t[18]=f,t[19]=n,t[20]=S):S=t[20],(0,Q.useEffect)(x,S);let C,w;t[21]===f?(C=t[22],w=t[23]):(C=()=>{if(!f)return;let e=QN,t=null,n=()=>{if(t||!f||f.isDestroyed)return;let n=gr(f);n&&(t=n.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 gr(f)?n():f.on(`create`,n),()=>{f.off(`create`,n),r()}},w=[f],t[21]=f,t[22]=C,t[23]=w),(0,Q.useEffect)(C,w);let T,E;t[24]!==f||t[25]!==n.document?(E=()=>{if(!f)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,s=null,c=null,l=()=>{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},u=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??``))},d=()=>{let e=l(),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};u(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),s&&clearTimeout(s),c&&clearTimeout(c),s=window.setTimeout(()=>{let e={...n,state:`settled`};u(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{u({...e,state:`idle`})},300)},oe)};u(YN);let p=()=>{if(_t(e),!B(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(),d()},e)}return}r=n,d()};e.observe(p);let m=()=>{document.visibilityState===`visible`?B(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(p),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),s&&clearTimeout(s),c&&clearTimeout(c)}},T=[f,n.document],t[24]=f,t[25]=n.document,t[26]=T,t[27]=E):(T=t[26],E=t[27]),(0,Q.useEffect)(E,T);let D,O;t[28]===n?(D=t[29],O=t[30]):(D=()=>{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)}},O=[n],t[28]=n,t[29]=D,t[30]=O),(0,Q.useEffect)(D,O);let k,A;t[31]===f?(k=t[32],A=t[33]):(k=()=>{if(!f)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!f||f.isDestroyed)return;let n=gr(f);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(Qi,e),()=>window.removeEventListener(Qi,e)},A=[f],t[31]=f,t[32]=k,t[33]=A),(0,Q.useEffect)(k,A);let j;t[34]!==l||t[35]!==u||t[36]!==s||t[37]!==i||t[38]!==c||t[39]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(u!==l){e.setLocalState(null);return}e.setLocalState({user:ZM({principal:c,identity:s}),mode:i?`source`:`wysiwyg`})}},t[34]=l,t[35]=u,t[36]=s,t[37]=i,t[38]=c,t[39]=n.awareness,t[40]=j):j=t[40];let M;t[41]!==l||t[42]!==u||t[43]!==s||t[44]!==i||t[45]!==c||t[46]!==n?(M=[n,u,l,s,c,i],t[41]=l,t[42]=u,t[43]=s,t[44]=i,t[45]=c,t[46]=n,t[47]=M):M=t[47],(0,Q.useEffect)(j,M);let N;t[48]===f?N=t[49]:(N=f&&(0,Z.jsx)(LN,{editor:f}),t[48]=f,t[49]=N);let P;t[50]===f?P=t[51]:(P=f&&(0,Z.jsx)(KN,{editor:f}),t[50]=f,t[51]=P);let F,I;t[52]===f?(F=t[53],I=t[54]):(F=(0,Z.jsx)(Ht,{editor:f,className:`h-full`}),I=f&&(0,Z.jsx)(BM,{editor:f}),t[52]=f,t[53]=F,t[54]=I);let L;t[55]===f?L=t[56]:(L=f&&(0,Z.jsx)(JM,{editor:f}),t[55]=f,t[56]=L);let R;t[57]===f?R=t[58]:(R=f&&(0,Z.jsx)($t,{store:qt(f).store}),t[57]=f,t[58]=R);let z;return t[59]!==N||t[60]!==P||t[61]!==F||t[62]!==I||t[63]!==L||t[64]!==R?(z=(0,Z.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,L,R]}),t[59]=N,t[60]=P,t[61]=F,t[62]=I,t[63]=L,t[64]=R,t[65]=z):z=t[65],z};function ZN(){let e=new de({extensions:L});return{mdManager:e,text:Zt({mdManager:e}),html:Tn({mdManager:e}),paste:Dn({mdManager:e}),drop:Cn({mdManager:e})}}function QN(){return Vt()}function $N(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(fr(n,r));let a;return t[0]===i?a=t[1]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[0]=i,t[1]=a),a}var eP=`__back-nav__`;function tP(e){return e instanceof In||e instanceof er||e instanceof Nn||e instanceof Un||e instanceof sr?e.docName:null}function nP(e){return e instanceof In?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof er?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Nn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Un?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof sr?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function rP(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=nP(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.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,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Cb,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.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,Z.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,Z.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,Z.jsx)(Y,{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,Z.jsx)(Y,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(Yn(tP(n)??i),o(a),r(eP))},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,Z.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,Z.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 iP(e){let t=(0,$.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,Z.jsx)(rP,{...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]===eP){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}: ${nP(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,Z.jsx)(mn,{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}var aP={text:``,number:0,boolean:!1,date:``,list:[]};function oP(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=me(t);return{map:n,keys:ge(t),parseError:r}}function sP(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>oP(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{let e=qe(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useEffect)(c,l);let u=o.map,d=o.keys,f=o.parseError,[p,m]=(0,Q.useState)(!1),h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[5]=h):h=t[5];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S={},t[6]=S):S=t[6];let[C,w]=(0,Q.useState)(S),T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[7]=T):T=t[7];let[E,D]=(0,Q.useState)(T),O=n.configuration.name??``,k;t[8]===O?k=t[9]:(k=lP(O),t[8]=O,t[9]=k);let A=Nj(k),j;t[10]!==A.state.data||t[11]!==A.state.status?(j=A.state.status===`ready`?A.state.data.folder.frontmatter_defaults??{}:{},t[10]=A.state.data,t[11]=A.state.status,t[12]=j):j=t[12];let M=j,N;t[13]!==A.state.data||t[14]!==A.state.status?(N=A.state.status===`ready`?A.state.data.frontmatterSources:{},t[13]=A.state.data,t[14]=A.state.status,t[15]=N):N=t[15];let P=N,F;t[16]===r?F=t[17]:(F=function(e){if(!r)return{ok:!1,error:`Connecting…`};let t=r.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=ue(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[16]=r,t[17]=F);let I=F,L;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){w(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};w(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),D(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=z):z=t[19];let B=z,V;t[20]===I?V=t[21]:(V=function(e,t){R(e),B(I({[e]:t}),[e])},t[20]=I,t[21]=V);let H=V,U;t[22]===I?U=t[23]:(U=function(e){R(e),B(I({[e]:null}),[e])},t[22]=I,t[23]=U);let W=U,G;t[24]===r?G=t[25]:(G=function(e,t){if(!r)return{ok:!1,error:`Connecting…`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=ue(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[24]=r,t[25]=G);let ee=G,te;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e,t){return`${e} ${t}`},t[26]=te):te=t[26];let ne=te,re;t[27]!==r||t[28]!==d?(re=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=d.map((e,t)=>ne(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=d.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[27]=r,t[28]=d,t[29]=re):re=t[29];let ie=re,ae;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ae={activationConstraint:{distance:4}},t[30]=ae):ae=t[30];let oe;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(oe={coordinateGetter:Sw},t[31]=oe):oe=t[31];let se=Gx(Wx(qS,ae),Wx(HS,oe)),ce;t[32]!==M||t[33]!==H||t[34]!==u?(ce=function(e,t){let n=u[e]??uP(M[e]);if(n===void 0)return;_(n=>({...n,[e]:t}));let r=JA(n,t);(!Object.hasOwn(u,e)||!cP(n,r))&&H(e,r)},t[32]=M,t[33]=H,t[34]=u,t[35]=ce):ce=t[35];let K=ce,q;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(){y({name:``,type:`text`,value:``,error:null}),m(!1)},t[36]=q):q=t[36];let de=q,{addPropertySignal:fe,clearAddProperty:pe}=uM(),me;t[37]!==fe||t[38]!==O?(me=fe.get(O)??0,t[37]=fe,t[38]=O,t[39]=me):me=t[39];let he=me,ge,_e;t[40]===he?(ge=t[41],_e=t[42]):(ge=()=>{he>0&&(y({name:``,type:`text`,value:``,error:null}),m(!1))},_e=[he],t[40]=he,t[41]=ge,t[42]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[43]!==pe||t[44]!==O?(ve=()=>()=>pe(O),ye=[O,pe],t[43]=pe,t[44]=O,t[45]=ve,t[46]=ye):(ve=t[45],ye=t[46]),(0,Q.useEffect)(ve,ye);let be;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){y(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):aP[e];return{...t,type:e,value:n,error:null}})},t[47]=be):be=t[47];let xe=be,Se;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){y(t=>t&&{...t,value:e})},t[48]=Se):Se=t[48];let Ce=Se,we;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){y(t=>t&&{...t,name:e,error:null})},t[49]=we):we=t[49];let Te=we,Ee;t[50]!==v||t[51]!==I||t[52]!==u?(Ee=function(){if(!v)return;let e=v.name.trim();if(!e){y({...v,error:`Name is required`});return}if(e===`frontmatter`){y({...v,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){y({...v,error:`Property "${e}" already exists`});return}let t=I({[e]:v.value});if(t.ok){y(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;y({...v,error:n??r})},t[50]=v,t[51]=I,t[52]=u,t[53]=Ee):Ee=t[53];let De=Ee,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){y(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){x({key:e,draft:e,error:null})},t[55]=je):je=t[55];let Me=je,Ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=function(e){x(t=>t&&{...t,draft:e,error:null})},t[56]=Ne):Ne=t[56];let Pe=Ne,Fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=function(){x(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==u||t[59]!==ee||t[60]!==b?(Le=function(){if(!b)return;let e=b.draft.trim();if(!e){x(null);return}if(e===b.key){x(null);return}if(e===`frontmatter`){x({...b,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){x({...b,error:`Property "${e}" already exists`});return}let t=ee(b.key,e);if(t.ok){_(t=>{if(!Object.hasOwn(t,b.key))return t;let n={...t};return n[e]=n[b.key],delete n[b.key],n}),R(b.key),x(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[b.key]??t.error??`Failed to rename property`;x({...b,error:n})},t[58]=u,t[59]=ee,t[60]=b,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==u||t[63]!==d?(ze=d.length>0?d:Object.keys(u),t[62]=u,t[63]=d,t[64]=ze):ze=t[64];let Be=ze,Ve;if(t[65]!==Be){Ve=new Map;for(let e of Be)Ve.set(e,(Ve.get(e)??0)+1);t[65]=Be,t[66]=Ve}else Ve=t[66];let He,Ue,We,Ge,Ke,Je,Ye,Xe,Ze,Qe,$e,et;if(t[67]!==v||t[68]!==M||t[69]!==P||t[70]!==p||t[71]!==H||t[72]!==Re||t[73]!==Ve||t[74]!==C||t[75]!==ie||t[76]!==u||t[77]!==g||t[78]!==f||t[79]!==W||t[80]!==b||t[81]!==Be||t[82]!==E||t[83]!==se||t[84]!==K){et=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(M).filter(e=>!Object.hasOwn(u,e)).sort();if(Be.length===0&&e.length===0&&!v&&!f){et=null;break bb0}Qe=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,$e=`property-panel`,Ue=fn,Ye=!p,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>m(!e),t[97]=Xe):Xe=t[97];let n=!p,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(An,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[98]=n,t[99]=r);let i;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[100]=i):i=t[100],t[101]===r?Ze=t[102]:(Ze=(0,Z.jsx)(Rt,{asChild:!0,children:(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[r,i]})}),t[101]=r,t[102]=Ze),He=qn,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===f?Ge=t[104]:(Ge=f?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:f})]})]}):null,t[103]=f,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ne(e,t),t[107]=e):e=t[107],a=Be.map(e),t[105]=Be,t[106]=a}else a=t[106];let o;if(t[108]!==M||t[109]!==P||t[110]!==H||t[111]!==Re||t[112]!==Ve||t[113]!==C||t[114]!==u||t[115]!==g||t[116]!==W||t[117]!==b||t[118]!==Be||t[119]!==E||t[120]!==K){let e;t[122]!==M||t[123]!==P||t[124]!==H||t[125]!==Re||t[126]!==Ve||t[127]!==C||t[128]!==u||t[129]!==g||t[130]!==W||t[131]!==b||t[132]!==E||t[133]!==K?(e=(e,t)=>{let n=u[e];if(n===void 0)return null;let r=g[e]??le(n),i=b?.key===e?b:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(M,e)?(0,Z.jsx)(dP,{source:P[e]??``}):void 0;return(0,Z.jsx)(XA,{sortableId:ne(e,t),keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>H(e,t),onChangeType:t=>K(e,t),onRemove:()=>W(e)},`${e}-${t}`)},t[122]=M,t[123]=P,t[124]=H,t[125]=Re,t[126]=Ve,t[127]=C,t[128]=u,t[129]=g,t[130]=W,t[131]=b,t[132]=E,t[133]=K,t[134]=e):e=t[134],o=Be.map(e),t[108]=M,t[109]=P,t[110]=H,t[111]=Re,t[112]=Ve,t[113]=C,t[114]=u,t[115]=g,t[116]=W,t[117]=b,t[118]=Be,t[119]=E,t[120]=K,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(uw,{items:a,strategy:ow,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==ie||t[139]!==se||t[140]!==s?(Ke=(0,Z.jsx)(WC,{sensors:se,collisionDetection:$x,onDragEnd:ie,children:s}),t[138]=ie,t[139]=se,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==M||t[143]!==P||t[144]!==H||t[145]!==C||t[146]!==E||t[147]!==K?(c=e=>{let t=M[e],n=uP(t),r=le(n),i=P[e]??``;return(0,Z.jsx)(XA,{keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isInherited:!0,badge:(0,Z.jsx)(rj,{source:i}),onCommit:t=>H(e,t),onChangeType:t=>K(e,t)},`inherited-${e}`)},t[142]=M,t[143]=P,t[144]=H,t[145]=C,t[146]=E,t[147]=K,t[148]=c):c=t[148],Je=e.map(c)}t[67]=v,t[68]=M,t[69]=P,t[70]=p,t[71]=H,t[72]=Re,t[73]=Ve,t[74]=C,t[75]=ie,t[76]=u,t[77]=g,t[78]=f,t[79]=W,t[80]=b,t[81]=Be,t[82]=E,t[83]=se,t[84]=K,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=Je,t[91]=Ye,t[92]=Xe,t[93]=Ze,t[94]=Qe,t[95]=$e,t[96]=et}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],Je=t[90],Ye=t[91],Xe=t[92],Ze=t[93],Qe=t[94],$e=t[95],et=t[96];if(et!==Symbol.for(`react.early_return_sentinel`))return et;let tt;t[149]!==v||t[150]!==De?(tt=v?(0,Z.jsx)(tj,{draft:v,onChangeName:Te,onChangeType:xe,onChangeValue:Ce,onCommit:De,onCancel:Ae}):(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:de,className:`mt-1 flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(co,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=v,t[150]=De,t[151]=tt):tt=t[151];let nt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==Je||t[157]!==tt?(nt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,Je,tt]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=Je,t[157]=tt,t[158]=nt):nt=t[158];let rt;t[159]!==Ue||t[160]!==Ye||t[161]!==Xe||t[162]!==Ze||t[163]!==nt?(rt=(0,Z.jsxs)(Ue,{open:Ye,onOpenChange:Xe,children:[Ze,nt]}),t[159]=Ue,t[160]=Ye,t[161]=Xe,t[162]=Ze,t[163]=nt,t[164]=rt):rt=t[164];let it;return t[165]!==Qe||t[166]!==$e||t[167]!==rt?(it=(0,Z.jsx)(`div`,{className:Qe,"data-testid":$e,children:rt}),t[165]=Qe,t[166]=$e,t[167]=rt,t[168]=it):it=t[168],it}function cP(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function lP(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function uP(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}function dP(e){let t=(0,$.c)(2),{source:n}=e,r=`Overrides default from ${n===``?`.ok/frontmatter.yml`:`${n}/.ok/frontmatter.yml`}. Remove to revert.`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(pn,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var fP=$n(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function pP(e){let t=e.threshold??fP;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function mP(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var hP=$n(`ACTIVITY_MOUNT_LIMIT`,3);function gP(){return r(()=>import(`./SourceEditor-CTgjCTMk.js`),__vite__mapDeps([32,1,27,2,28,29,14,13,3,6,7,30,4,8,33,16]),import.meta.url)}var _P=(0,Q.lazy)(async()=>({default:(await gP()).SourceEditor}));function vP(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Rn(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 yP(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function bP(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Kt,{name:`activity-pool`,children:(0,Z.jsx)(xP,{...e})}),t[0]=e,t[1]=n),n}function xP(e){let t=(0,$.c)(12),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=Qn(),{pages:u,loading:d}=Ee(),f=vP(c,n,hP),p=(0,Q.useRef)(``),m=f.map(SP).join(`,`);(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[];Wt(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),p.current=m,dr(t)},[m,n]);let h;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==d||t[4]!==o||t[5]!==s||t[6]!==u||t[7]!==a||t[8]!==l?(h=e=>(0,Z.jsx)(DP,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[0]=n,t[1]=i,t[2]=r,t[3]=d,t[4]=o,t[5]=s,t[6]=u,t[7]=a,t[8]=l,t[9]=h):h=t[9];let g=f.map(h),_;return t[10]===g?_=t[11]:(_=(0,Z.jsx)(Z.Fragment,{children:g}),t[10]=g,t[11]=_),_}function SP(e){return e.docName}function CP(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.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,Q.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,Q.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,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto`,style:u,children:r}),t[6]=r,t[7]=d),d}function wP(e){let t=(0,$.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Q.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,Q.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)($y,{}),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,Z.jsx)(Q.Suspense,{fallback:d,children:(0,Z.jsx)(_P,{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 TP(e){let t=(0,$.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,Z.jsx)(fo,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Jt,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,Z.jsxs)(Y,{type:`button`,onClick:EP,children:[(0,Z.jsx)(fo,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,Z.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function EP(){return window.location.reload()}function DP(e){let t=(0,$.c)(45),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=yP(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=n.provider.document.getText(`source`).length,[m,h]=(0,Q.useState)(i),[g,_]=(0,Q.useState)(!i),v,y;t[3]!==i||t[4]!==m||t[5]!==g?(v=()=>{i&&!m?h(!0):!i&&!g&&_(!0)},y=[i,m,g],t[3]=i,t[4]=m,t[5]=g,t[6]=v,t[7]=y):(v=t[6],y=t[7]),(0,Q.useEffect)(v,y);let b=pP({ytextLength:p,isSourceMode:i,visitedSource:m,visitedVisual:g}),x=(0,Q.useRef)(``),S=`${b.isLarge}-${b.renderSource}-${b.renderVisual}`,C,w;t[8]!==n.docName||t[9]!==b.isLarge||t[10]!==b.renderSource||t[11]!==b.renderVisual||t[12]!==S||t[13]!==i||t[14]!==p?(C=()=>{x.current!==S&&(x.current=S,b.isLarge&&Wt(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:p,isSourceMode:i,renderSource:b.renderSource,renderVisual:b.renderVisual}))},w=[S,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[8]=n.docName,t[9]=b.isLarge,t[10]=b.renderSource,t[11]=b.renderVisual,t[12]=S,t[13]=i,t[14]=p,t[15]=C,t[16]=w):(C=t[15],w=t[16]),(0,Q.useEffect)(C,w);let[T,E]=(0,Q.useState)(!1),D,O;t[17]!==n.docName||t[18]!==b.isLarge||t[19]!==b.renderSource||t[20]!==b.renderVisual||t[21]!==T||t[22]!==i||t[23]!==p?(D=()=>{mP({isLarge:b.isLarge,renderSource:b.renderSource,renderVisual:b.renderVisual,hasEmittedFirstToggle:T})&&(Wt(`ok/cold/first-toggle`,{docName:n.docName,ytextLength:p,modeEnteredFirst:i?`source`:`visual`}),E(!0))},O=[T,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[17]=n.docName,t[18]=b.isLarge,t[19]=b.renderSource,t[20]=b.renderVisual,t[21]=T,t[22]=i,t[23]=p,t[24]=D,t[25]=O):(D=t[24],O=t[25]),(0,Q.useEffect)(D,O);let k=r?`visible`:`hidden`,A=`editor:${n.docName}`,j;t[26]!==a||t[27]!==n||t[28]!==b.renderSource||t[29]!==b.renderVisual||t[30]!==r||t[31]!==o||t[32]!==i||t[33]!==c||t[34]!==l||t[35]!==s||t[36]!==f?(j=f?(0,Z.jsx)(TP,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(iP,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)($y,{}),children:(0,Z.jsx)($N,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col ${i?``:`pt-6`}`,children:[!i&&(0,Z.jsx)(sP,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[b.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(wP,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,b.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(XN,{provider:n.provider,placeholder:a,isSourceMode:i},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[26]=a,t[27]=n,t[28]=b.renderSource,t[29]=b.renderVisual,t[30]=r,t[31]=o,t[32]=i,t[33]=c,t[34]=l,t[35]=s,t[36]=f,t[37]=j):j=t[37];let M;t[38]!==r||t[39]!==j?(M=(0,Z.jsx)(CP,{isActive:r,children:j}),t[38]=r,t[39]=j,t[40]=M):M=t[40];let N;return t[41]!==M||t[42]!==k||t[43]!==A?(N=(0,Z.jsx)(Q.Activity,{mode:k,name:A,children:M}),t[41]=M,t[42]=k,t[43]=A,t[44]=N):N=t[44],N}function OP(e){let t=(0,$.c)(26),{stats:n}=e,r;t[0]===n.words?r=t[1]:(r=n.words.toLocaleString(),t[0]=n.words,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:r}),t[2]=r,t[3]=i);let a=n.words===1?`word`:`words`,o;t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`span`,{children:[i,` `,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===n.chars?s=t[8]:(s=n.chars.toLocaleString(),t[7]=n.chars,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:s}),t[9]=s,t[10]=c);let l=n.chars===1?`char`:`chars`,u;t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(`span`,{children:[c,` `,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13];let d=n.tokens>0?`~`:``,f;t[14]===n.tokens?f=t[15]:(f=n.tokens.toLocaleString(),t[14]=n.tokens,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:f}),t[16]=f,t[17]=p);let m=n.tokens===1?`token`:`tokens`,h;t[18]!==p||t[19]!==m||t[20]!==d?(h=(0,Z.jsxs)(`span`,{children:[d,p,` `,m]}),t[18]=p,t[19]=m,t[20]=d,t[21]=h):h=t[21];let g;return t[22]!==h||t[23]!==o||t[24]!==u?(g=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`flex h-6 shrink-0 items-center justify-end gap-3 px-3 text-2xs text-muted-foreground`,children:[o,u,h]}),t[22]=h,t[23]=o,t[24]=u,t[25]=g):g=t[25],g}var kP={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`},AP=e=>{let t=(0,$.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,Z.jsx)(`svg`,{"aria-hidden":`true`,...kP,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},jP=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Markdown`}),r=(0,Z.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,Z.jsxs)(AP,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},MP=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Textbox`}),r=(0,Z.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,Z.jsxs)(AP,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},NP=(0,Q.lazy)(()=>r(()=>import(`./SettingsPane-CyMjmU3t.js`).then(e=>({default:e.SettingsPane})),__vite__mapDeps([34,1,27,2,28,29,14,13,3,6,7,30,4,8,35,15]),import.meta.url));function PP(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Kt,{name:`editor-area`,children:(0,Z.jsx)(cM,{children:(0,Z.jsx)(FP,{...e})})}),t[0]=e,t[1]=n),n}function FP(e){let t=(0,$.c)(127),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,o=Yf(),{activeDocName:s,activeProvider:c,activeTarget:l,recycleDocument:u,docPanelMode:d,docPanelExpandSignal:f}=Qn(),{openDocumentTransition:p}=ar(),{requestAddProperty:m}=uM(),h=PM(c,s),g=FM(c),_=g===`connected`||g===`synced`,v=(0,Q.useDeferredValue)(s),y=l?.kind===`missing`,b=!!s&&l?.kind!==`folder`,x=y?`Start writing to create this page…`:void 0,S=Jy(),[C,w]=(0,Q.useState)(!1),{layout:T,autoCollapse:E}=vM(),D=T===`sheet`,[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(!1),j,M;t[0]!==E||t[1]!==T||t[2]!==S?(j=()=>{T===`panel`&&(E?(A.current=!1,S.current?.collapse()):A.current||S.current?.expand())},M=[E,T,S],t[0]=E,t[1]=T,t[2]=S,t[3]=j,t[4]=M):(j=t[3],M=t[4]),(0,Q.useEffect)(j,M);let N,P;t[5]!==D||t[6]!==a||t[7]!==S?(N=()=>{let e=e=>{a(e),D?k(!0):(A.current=!1,S.current?.expand())},t=Fd();return t&&e(t),Ld(t=>{Fd(),e(t)})},P=[D,a,S],t[5]=D,t[6]=a,t[7]=S,t[8]=N,t[9]=P):(N=t[8],P=t[9]),(0,Q.useEffect)(N,P);let F,I;t[10]!==f||t[11]!==D||t[12]!==S?(F=()=>{f!==0&&(D?k(!0):(A.current=!1,S.current?.expand()))},I=[f,D,S],t[10]=f,t[11]=D,t[12]=S,t[13]=F,t[14]=I):(F=t[13],I=t[14]),(0,Q.useEffect)(F,I);let L=(0,Q.useRef)(null),[R,z]=(0,Q.useState)(null),B,V;if(t[15]===s?(B=t[16],V=t[17]):(B=()=>{if(s&&s!==L.current){let e=L.current;L.current=s,z(e)}},V=[s],t[15]=s,t[16]=B,t[17]=V),(0,Q.useEffect)(B,V),o.scope!==null){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($y,{}),t[18]=e):e=t[18];let n;return t[19]!==o.close||t[20]!==o.scope||t[21]!==o.setScope?(n=(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(NP,{scope:o.scope,onClose:o.close,onScopeChange:o.setScope})}),t[19]=o.close,t[20]=o.scope,t[21]=o.setScope,t[22]=n):n=t[22],n}if(l?.kind===`folder`){let e;return t[23]===l.folderPath?e=t[24]:(e=(0,Z.jsx)(nM,{folderPath:l.folderPath}),t[23]=l.folderPath,t[24]=e),e}if(l?.kind===`asset`){let e;return t[25]!==l.assetPath||t[26]!==l.mediaKind?(e=(0,Z.jsx)(Qy,{assetPath:l.assetPath,mediaKind:l.mediaKind}),t[25]=l.assetPath,t[26]=l.mediaKind,t[27]=e):e=t[27],e}if(!c||!s){if((typeof window<`u`?Ge(window.location.hash):null)!==null){let e;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($y,{}),t[28]=e):e=t[28],e}let e;return t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xb,{}),t[29]=e):e=t[29],e}let H=n===`source`,U=!_,W=D?!O:C,G;t[30]!==s||t[31]!==m?(G=function(){s&&m(s)},t[30]=s,t[31]=m,t[32]=G):G=t[32];let ee=G,te=H?`source`:`wysiwyg`,ne;t[33]===r?ne=t[34]:(ne=e=>{e&&r(e)},t[33]=r,t[34]=ne);let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Je,{value:`wysiwyg`,"aria-label":`Visual editor`,asChild:!0,children:(0,Z.jsx)(Ci,{children:(0,Z.jsx)(MP,{})})}),(0,Z.jsx)(wi,{side:`bottom`,children:`Visual`})]}),t[35]=re):re=t[35];let ie;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(jP,{}),t[36]=ie):ie=t[36];let ae;t[37]===U?ae=t[38]:(ae=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Je,{value:`source`,"aria-label":`Markdown source`,disabled:U,className:`rounded-s-none! border-s-0!`,children:ie})})}),t[37]=U,t[38]=ae);let oe=U?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,se;t[39]===oe?se=t[40]:(se=(0,Z.jsx)(wi,{side:`bottom`,children:oe}),t[39]=oe,t[40]=se);let ce;t[41]!==ae||t[42]!==se?(ce=(0,Z.jsxs)(Ei,{children:[ae,se]}),t[41]=ae,t[42]=se,t[43]=ce):ce=t[43];let le;t[44]!==te||t[45]!==ne||t[46]!==ce?(le=(0,Z.jsxs)(be,{type:`single`,value:te,onValueChange:ne,"aria-label":`Editor mode`,variant:`outline`,className:`shrink-0 rounded-lg bg-background/90 p-0.5 shadow-sm backdrop-blur`,children:[re,ce]}),t[44]=te,t[45]=ne,t[46]=ce,t[47]=le):le=t[47];let ue;t[48]!==H||t[49]!==ee?(ue=!H&&(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,"aria-label":`Add properties`,onClick:ee,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ci,{children:(0,Z.jsx)($a,{})})}),(0,Z.jsx)(wi,{side:`bottom`,children:`Add properties`})]}),t[48]=H,t[49]=ee,t[50]=ue):ue=t[50];let K;t[51]!==C||t[52]!==D||t[53]!==S?(K=()=>{D?k(IP):C?(A.current=!1,S.current?.expand()):(A.current=!0,S.current?.collapse())},t[51]=C,t[52]=D,t[53]=S,t[54]=K):K=t[54];let q=W?`Show document panel`:`Hide document panel`,de;t[55]===W?de=t[56]:(de=(0,Z.jsx)(Ci,{children:W?(0,Z.jsx)(oo,{}):(0,Z.jsx)(ao,{})}),t[55]=W,t[56]=de);let fe;t[57]!==K||t[58]!==q||t[59]!==de?(fe=(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,onClick:K,"aria-label":q,asChild:!0,children:de}),t[57]=K,t[58]=q,t[59]=de,t[60]=fe):fe=t[60];let pe=W?`Show panel`:`Hide panel`,me;t[61]===pe?me=t[62]:(me=(0,Z.jsx)(wi,{side:`bottom`,children:pe}),t[61]=pe,t[62]=me);let he;t[63]!==fe||t[64]!==me?(he=(0,Z.jsxs)(Ei,{children:[fe,me]}),t[63]=fe,t[64]=me,t[65]=he):he=t[65];let ge;t[66]!==ue||t[67]!==he?(ge=(0,Z.jsxs)(fM,{className:`shrink-0 rounded-lg bg-background/90 p-0.5 shadow-sm backdrop-blur`,children:[ue,he]}),t[66]=ue,t[67]=he,t[68]=ge):ge=t[68];let _e;t[69]!==le||t[70]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1`,children:[le,ge]}),t[69]=le,t[70]=ge,t[71]=_e):_e=t[71];let ve=_e,ye=v??s,xe=R??void 0,Se;t[72]===p?Se=t[73]:(Se=e=>{let t=Ie(e);window.location.hash===t?p(e):window.location.hash=t},t[72]=p,t[73]=Se);let Ce;t[74]!==x||t[75]!==H||t[76]!==u||t[77]!==ye||t[78]!==xe||t[79]!==Se?(Ce=(0,Z.jsx)(bP,{activeDocName:ye,isSourceMode:H,editorPlaceholder:x,previousDocName:xe,onNavigateBack:Se,onRecycle:u}),t[74]=x,t[75]=H,t[76]=u,t[77]=ye,t[78]=xe,t[79]=Se,t[80]=Ce):Ce=t[80];let we;t[81]!==s||t[82]!==v?(we=s&&s!==v?(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,Z.jsx)($y,{})}):null,t[81]=s,t[82]=v,t[83]=we):we=t[83];let Te;t[84]!==Ce||t[85]!==we?(Te=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[Ce,we]}),t[84]=Ce,t[85]=we,t[86]=Te):Te=t[86];let Ee;t[87]!==Te||t[88]!==ve?(Ee=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[Te,ve]}),t[87]=Te,t[88]=ve,t[89]=Ee):Ee=t[89];let De;t[90]!==b||t[91]!==h?(De=b&&(0,Z.jsx)(OP,{stats:h}),t[90]=b,t[91]=h,t[92]=De):De=t[92];let Oe;t[93]!==Ee||t[94]!==De?(Oe=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[Ee,De]}),t[93]=Ee,t[94]=De,t[95]=Oe):Oe=t[95];let ke=Oe;if(D){let e;t[96]===ke?e=t[97]:(e=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:ke}),t[96]=ke,t[97]=e);let n;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(wg,{className:`sr-only`,children:(0,Z.jsx)(Tg,{children:`Document panel`})}),t[98]=n):n=t[98];let r;t[99]!==s||t[100]!==i||t[101]!==d||t[102]!==H||t[103]!==a?(r=(0,Z.jsxs)(Cg,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,Z.jsx)(tv,{docName:s,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:d})]}),t[99]=s,t[100]=i,t[101]=d,t[102]=H,t[103]=a,t[104]=r):r=t[104];let o;t[105]!==O||t[106]!==r?(o=(0,Z.jsx)(bg,{open:O,onOpenChange:k,children:r}),t[105]=O,t[106]=r,t[107]=o):o=t[107];let c;return t[108]!==e||t[109]!==o?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,o]}),t[108]=e,t[109]=o,t[110]=c):c=t[110],c}let Ae;t[111]===ke?Ae=t[112]:(Ae=(0,Z.jsx)(mM,{minSize:`30%`,defaultSize:`75%`,children:ke}),t[111]=ke,t[112]=Ae);let je;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Z.jsx)(hM,{withHandle:!0}),t[113]=je):je=t[113];let Me;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>w(e.asPercentage===0),t[114]=Me):Me=t[114];let Ne;t[115]!==s||t[116]!==i||t[117]!==d||t[118]!==H||t[119]!==a?(Ne=(0,Z.jsx)(tv,{docName:s,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:d}),t[115]=s,t[116]=i,t[117]=d,t[118]=H,t[119]=a,t[120]=Ne):Ne=t[120];let Pe;t[121]!==S||t[122]!==Ne?(Pe=(0,Z.jsx)(mM,{panelRef:S,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:Me,className:`flex flex-col bg-muted/20`,children:Ne}),t[121]=S,t[122]=Ne,t[123]=Pe):Pe=t[123];let Fe;return t[124]!==Ae||t[125]!==Pe?(Fe=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(pM,{orientation:`horizontal`,children:[Ae,je,Pe]})}),t[124]=Ae,t[125]=Pe,t[126]=Fe):Fe=t[126],Fe}function IP(e){return!e}var LP=1280;function RP(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(zP),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${LP-1}px)`),t=()=>{n(window.innerWidth<LP)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function zP(){return window.innerWidth<LP}function BP(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function VP(e){let{value:t,unit:n}=BP(e);return n===`rem`?t*16:t}function HP(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var UP=3600*24*7;function WP(e){let t=(0,$.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?GP:m,O=g===void 0?UP:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,ee;t[3]===y?(G=t[4],ee=t[5]):(G=()=>{H.current=y},ee=[y],t[3]=y,t[4]=G,t[5]=ee),(0,Q.useEffect)(G,ee);let te=VP(b),ne;t[6]===x?ne=t[7]:(ne=VP(x),t[6]=x,t[7]=ne);let re=ne,ie;t[8]!==E||t[9]!==k?(ie=function(e){P.current=!0,E&&(j.current=H.current?0:VP(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ie):ie=t[10];let ae=ie,oe,se;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==re||t[18]!==te||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(oe=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=BP(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=te*w;else if(e<=te){let n=te*(w-1);t=te-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>te*T){a();let t=n(r,M.current,j.current,s),c=Math.max(te,Math.min(re,t)),u=HP(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(te,Math.min(re,u)),f=HP(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},se=[i,a,D,te,re,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=re,t[18]=te,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=oe,t[25]=se):(oe=t[24],se=t[25]),(0,Q.useEffect)(oe,se);let ce;return t[26]===ae?ce=t[27]:(ce={dragRef:A,isDragging:N,handleMouseDown:ae},t[26]=ae,t[27]=ce),ce}function GP(){}var KP=`sidebar_state`,qP=3600*24*7,JP=`18rem`,YP=`3rem`,XP=`\\`,ZP=`app-file-sidebar`,QP=`14rem`,$P=`22rem`,eF=`sidebar_width`,tF=/^\d+(?:\.\d+)?(?:rem|px)$/,nF=Q.createContext(null);function rF(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${eF}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return tF.test(n)?n:e}function iF(){let e=Q.use(nF);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function aF(e){let t=(0,$.c)(55),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?JP:l,f=RP(),p;t[9]===d?p=t[10]:(p=()=>rF(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState(u),w=i??S,T;t[11]!==w||t[12]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),document.cookie=`${KP}=${t}; path=/; max-age=${qP}`},t[11]=w,t[12]=o,t[13]=T):T=t[13];let E=T,D;t[14]!==f||t[15]!==E?(D=function(){return f?_(sF):E(oF)},t[14]=f,t[15]=E,t[16]=D):D=t[16];let O=D,k;t[17]!==f||t[18]!==g?(k=function(){!f||!g||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||x(!0)},t[17]=f,t[18]=g,t[19]=k):k=t[19];let A=k,j,M;t[20]===O?(j=t[21],M=t[22]):(j=()=>{let e=e=>{e.key===XP&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},M=[O],t[20]=O,t[21]=j,t[22]=M),Q.useEffect(j,M);let N,P;t[23]!==f||t[24]!==g?(P=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},N=[f,g],t[23]=f,t[24]=g,t[25]=N,t[26]=P):(N=t[25],P=t[26]),Q.useEffect(P,N);let F=Q.useRef(f),I,L;t[27]!==f||t[28]!==w?(I=()=>{!F.current&&f&&_(w),F.current=f},L=[f,w],t[27]=f,t[28]=w,t[29]=I,t[30]=L):(I=t[29],L=t[30]),Q.useEffect(I,L);let R=f?g?`expanded`:`collapsed`:w?`expanded`:`collapsed`,z;t[31]!==v||t[32]!==f||t[33]!==A||t[34]!==w||t[35]!==g||t[36]!==E||t[37]!==b||t[38]!==R||t[39]!==O||t[40]!==m?(z={state:R,open:w,setOpen:E,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:O,width:m,setWidth:h,isDraggingRail:v,setIsDraggingRail:y,showPushPulse:b,setShowPushPulse:x,notifySidebarFileSelected:A},t[31]=v,t[32]=f,t[33]=A,t[34]=w,t[35]=g,t[36]=E,t[37]=b,t[38]=R,t[39]=O,t[40]=m,t[41]=z):z=t[41];let B;t[42]!==s||t[43]!==m?(B={"--sidebar-width":m,"--sidebar-width-icon":YP,...s},t[42]=s,t[43]=m,t[44]=B):B=t[44];let V=B,H;t[45]===r?H=t[46]:(H=J(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[45]=r,t[46]=H);let U;t[47]!==n||t[48]!==a||t[49]!==V||t[50]!==H?(U=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:V,className:H,...a,children:n}),t[47]=n,t[48]=a,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;return t[52]!==z||t[53]!==U?(W=(0,Z.jsx)(nF.Provider,{value:z,children:U}),t[52]=z,t[53]=U,t[54]=W):W=t[54],W}function oF(e){return!e}function sF(e){return!e}function cF(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=iF();if(u===`none`){let e;t[7]===r?e=t[8]:(e=J(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=J(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,Z.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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:ZP,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=J(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`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`,b;t[33]!==r||t[34]!==y?(b=J(`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`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,Z.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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function lF(e){let t=(0,$.c)(16),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,state:o}=iF(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=J(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(hn,{}),d=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,Z.jsxs)(Y,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":ZP,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function uF(e){let t=(0,$.c)(22),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,enableDrag:a,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,{toggleSidebar:s,setWidth:c,state:l,width:u,setIsDraggingRail:d}=iF(),f=l===`collapsed`,p;t[5]!==o||t[6]!==d||t[7]!==c||t[8]!==f||t[9]!==s||t[10]!==u?(p={direction:`right`,enableDrag:o,onResize:c,onToggle:s,currentWidth:u,isCollapsed:f,minResizeWidth:QP,maxResizeWidth:$P,setIsDraggingRail:d,widthCookieName:eF,widthCookieMaxAge:qP},t[5]=o,t[6]=d,t[7]=c,t[8]=f,t[9]=s,t[10]=u,t[11]=p):p=t[11];let{dragRef:m,handleMouseDown:h}=WP(p),g;t[12]!==h||t[13]!==r?(g=e=>{r?.(e),e.defaultPrevented||h(e)},t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=J(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==i||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(`button`,{ref:m,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:g,title:`Toggle Sidebar`,className:_,...i}),t[17]=m,t[18]=i,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function dF(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=iF(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=J(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function fF(e){let t=(0,$.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=J(`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,Z.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 pF(e){let t=(0,$.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=J(`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,Z.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 mF(e){let t=(0,$.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=J(`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,Z.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 hF(e){let t=(0,$.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=J(`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,Z.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 gF(e){let t=(0,$.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=J(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.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 _F=yt(`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 vF(e){let t=(0,$.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?bt:`button`,{isMobile:m,state:h}=iF(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=J(_F({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,Z.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,Z.jsx)(Ci,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(wi,{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,Z.jsxs)(Ei,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function yF(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||r.tabCount!==i.tabCount)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 bF(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var xF=1e3,SF=!1;function CF(e,t,n){let r=(0,$.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Q.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:Mr(i)?a=i:(a=void 0,SF||(SF=!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`,tabCount:1})}let t=bF(e),{current:i,crossDoc:s}=a?Dr(a,n,Date.now()):{current:[],crossDoc:[]},c=wF,l=i.map(c),u=s.map(c),d=[...t,...l],f=u;o(e=>yF(e.current,d)&&yF(e.crossDoc,f)?e:{current:d,crossDoc:f})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,xF);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,Q.useEffect)(s,c),a}function wF(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var TF=`sync-status`;function EF(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.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:TF,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:TF,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var DF=4,OF=3,kF={Bird:ha,Cat:xa,Dog:Na,Fish:La,Mouse:uo,Rabbit:lo,Shrimp:_o,Snail:vo,Squirrel:So,Turtle:Eo};Object.freeze([...Object.keys(kF)]);function AF(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(kF,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var jF={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function MF(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=AF(n),o=a.kind===`animal`?kF[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=et(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=ft(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(wi,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(Ei,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function NF(e){let t=jF[e.icon];return e.displayName||t||`Agent`}function PF(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(e===`writing`),i=(0,Q.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,Q.useEffect)(a,o),n}function FF(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=NF(o),t[0]=o,t[1]=c);let l=c,u=PF(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=r&&o.currentDoc?`Open activity panel for ${l}, editing ${o.currentDoc}`:`Open activity panel for ${l}`,x;t[9]===o.color?x=t[10]:(x={backgroundColor:o.color},t[9]=o.color,t[10]=x);let S;t[11]!==s||t[12]!==a?(S=()=>a(s),t[11]=s,t[12]=a,t[13]=S):S=t[13];let C;t[14]===o.icon?C=t[15]:(C=(0,Z.jsx)(Ar,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=C);let w;t[16]!==b||t[17]!==y||t[18]!==h||t[19]!==C||t[20]!==x||t[21]!==S?(w=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":b,className:h,style:x,onClick:S,children:C}),t[16]=b,t[17]=y,t[18]=h,t[19]=C,t[20]=x,t[21]=S,t[22]=w):w=t[22];let T=w,E;t[23]===T?E=t[24]:(E=(0,Z.jsx)(Ci,{asChild:!0,children:T}),t[23]=T,t[24]=E);let D;t[25]===l?D=t[26]:(D=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=D);let O;t[27]!==r||t[28]!==o.currentDoc?(O=r&&o.currentDoc?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,o.currentDoc,`]]`]}):null,t[27]=r,t[28]=o.currentDoc,t[29]=O):O=t[29];let k;t[30]!==D||t[31]!==O?(k=(0,Z.jsxs)(wi,{className:`flex flex-col gap-0.5`,children:[D,O]}),t[30]=D,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==E||t[34]!==k?(A=(0,Z.jsxs)(Ei,{children:[E,k]}),t[33]=E,t[34]=k,t[35]=A):A=t[35],A}function IF(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,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":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(MF,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(FF,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(cn,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(Gn,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function LF(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(MF,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(FF,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function RF(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=Qn(),{current:s,crossDoc:c}=CF(t,r,n);EF(FM(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,DF),n;e[6]===s?n=e[7]:(n=s.slice(DF),e[6]=s,e[7]=n);let r=n,u=c.slice(0,OF),d;e[8]===c?d=e[9]:(d=c.slice(OF),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>LF(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,Z.jsx)(IF,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,Z.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[u.map(e=>LF(e,p,!0,m)),f.length>0?(0,Z.jsx)(IF,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]})]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function zF(e,t){return t.trim()}function BF(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function VF(e,t){let n=zF(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function HF(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function UF(e){return typeof e==`object`&&!!e&&typeof e.docName==`string`&&typeof e.rewrites==`number`}function WF(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(HF)&&Array.isArray(t.rewrittenDocs)&&t.rewrittenDocs.every(UF):t.ok===!1?typeof t.error==`string`:!1}function GF(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>dt(e)?e:{...e,docName:n.get(e.docName)??e.docName})}function KF(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>dt(e)||!n.has(e.docName))}function qF(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function JF(e){let t=(0,$.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=J(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var YF=yt(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function XF(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=J(YF({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:ZF,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function ZF(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}yt(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function QF(e){let t=(0,$.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=J(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $F(e){let t=(0,$.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=J(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Jn,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var eI=[`.md`,`.mdx`];function tI(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function nI(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function rI(e){let t=Ie(e);window.location.hash!==t&&(window.location.hash=t)}function iI(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function aI(e,t){let n=[t,...eI].filter((e,t,n)=>e&&n.indexOf(e)===t),r=e.toLowerCase(),i=n.find(t=>e.length>t.length&&r.endsWith(t.toLowerCase()));return i?e.slice(0,-i.length):e}function oI(){let e=(0,$.c)(36),{activeDocName:t,closeAndClearForRename:n,closeTab:r,openTabs:i,remapTabsForRename:a}=Qn(),{pageMeta:o}=Ee(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(null),b=(0,Q.useRef)(t),x;e[0]!==t||e[1]!==i?(x=t?`${t}\u0000${i.join(`\0`)}`:``,e[0]=t,e[1]=i,e[2]=x):x=e[2];let S=x,C,w;e[3]===t?(C=e[4],w=e[5]):(C=()=>{b.current=t},w=[t],e[3]=t,e[4]=C,e[5]=w),(0,Q.useEffect)(C,w);let T,E;e[6]===S?(T=e[7],E=e[8]):(T=()=>{S&&(s.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},E=[S],e[6]=S,e[7]=T,e[8]=E),(0,Q.useEffect)(T,E);let D,O;e[9]===c?(D=e[10],O=e[11]):(D=()=>{c&&(g.current?.focus(),g.current?.select())},O=[c],e[9]=c,e[10]=D,e[11]=O),(0,Q.useEffect)(D,O);let k,A;e[12]!==i||e[13]!==c?(k=()=>{!c||i.includes(c)||(v.current=!0,y.current=null,l(null),d(``),p(null),h(!1))},A=[i,c],e[12]=i,e[13]=c,e[14]=k,e[15]=A):(k=e[14],A=e[15]),(0,Q.useEffect)(k,A);let j,M,N,P,F;if(e[16]!==t||e[17]!==n||e[18]!==r||e[19]!==m||e[20]!==i||e[21]!==o||e[22]!==a||e[23]!==f||e[24]!==u||e[25]!==c){P=Symbol.for(`react.early_return_sentinel`);bb0:{let e=function(e){let t=e.split(`/`);v.current=!1,y.current=null,l(e),d(t[t.length-1]),p(null)},x=function(){v.current=!0,y.current=null,l(null),d(``),p(null),h(!1)},S=async function(){if(v.current){v.current=!1;return}if(_.current)return;let e=c;if(!e){x();return}let t=zF(`file`,aI(u,o.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){x();return}if(t===y.current){g.current?.focus();return}if(!BF(t)){p(`Name can’t be empty, ".", "..", or contain / or \\`),g.current?.focus();return}let s=VF({kind:`file`,path:e,name:i},t);_.current=!0,h(!0),p(null);try{let r=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:s})});if(v.current){h(!1),_.current=!1;return}let i;try{i=await r.json()}catch(n){console.warn(`[EditorTabs] rename response JSON parse failed`,{parseErr:n,status:r.status,docName:e,newDocName:s}),p(`Server error (HTTP ${r.status})`),h(!1),_.current=!1,y.current=t,g.current?.focus();return}if(!WF(i)){console.warn(`[EditorTabs] rename failed`,{status:r.status,docName:e,newDocName:s}),p(`Server error (HTTP ${r.status})`),h(!1),_.current=!1,y.current=t,g.current?.focus();return}if(!r.ok||!i.ok){p(i.ok?`Server error (HTTP ${r.status})`:i.error),h(!1),_.current=!1,y.current=t,g.current?.focus();return}let o=i.renamed,c=b.current,u=qF(c,o);await Promise.all(o.flatMap(e=>[n(e.fromDocName),n(e.toDocName)])),a(o),Ze([`files`,`backlinks`,`graph`]),v.current=!0,l(null),d(``),p(null),h(!1),_.current=!1,y.current=null,u&&u!==c&&rI(u)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:s,normalized:t}),p(`Network error — please try again`),h(!1),_.current=!1,y.current=t,g.current?.focus()}};if(i.length===0){P=null;break bb0}F=s,j=`ml-2 flex h-8 min-w-0 touch-manipulation flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain subtle-scrollbar`,M=iI,N=i.map(n=>{let i=n===t,a=o.get(n)?.docExt??`.md`,{baseName:s,extension:l,label:h,prefix:_}=tI(n,a),v=`${_}${h}`,b=c===n,C=`editor-tab-rename-error-${nI(n)}`;return(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":i?`true`:void 0,className:J(`group flex h-7 min-w-28 max-w-64 shrink-0 items-center overflow-hidden rounded-md border`,i?`border-border bg-background text-foreground`:`border-transparent text-muted-foreground hover:bg-muted/70 hover:text-foreground`,b&&f&&`border-destructive`),onAuxClick:e=>{e.button===1&&(e.preventDefault(),r(n))},children:b?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(JF,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent`,children:[(0,Z.jsx)($F,{ref:g,value:u,disabled:m,"aria-label":`Rename ${h}`,"aria-invalid":f?!0:void 0,"aria-describedby":f?C:void 0,"aria-busy":m||void 0,title:f??n,className:`h-full min-w-0 px-2 py-0 text-xs`,onChange:e=>{d(aI(e.target.value,a)),p(null),y.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),S()):e.key===`Escape`&&(e.preventDefault(),x())},onBlur:S}),(0,Z.jsx)(XF,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(QF,{className:`text-xs text-muted-foreground/60`,children:a})})]}),f?(0,Z.jsx)(`span`,{id:C,role:`alert`,className:`sr-only`,children:f}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":v,title:v,className:`flex h-full min-w-0 flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{rI(n)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),e(n)},children:[_?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/60`,children:_}):null,(0,Z.jsxs)(`span`,{className:J(`flex min-w-0 items-center font-medium`,_?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:l})]})]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close ${h}`,className:`mr-1 flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground opacity-70 outline-none transition hover:bg-muted hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50 group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),r(n)},children:(0,Z.jsx)(ri,{"aria-hidden":`true`,className:`size-3.5`})})]})},n)})}e[16]=t,e[17]=n,e[18]=r,e[19]=m,e[20]=i,e[21]=o,e[22]=a,e[23]=f,e[24]=u,e[25]=c,e[26]=j,e[27]=M,e[28]=N,e[29]=P,e[30]=F}else j=e[26],M=e[27],N=e[28],P=e[29],F=e[30];if(P!==Symbol.for(`react.early_return_sentinel`))return P;let I;return e[31]!==j||e[32]!==M||e[33]!==N||e[34]!==F?(I=(0,Z.jsx)(`div`,{ref:F,className:j,onWheel:M,children:N}),e[31]=j,e[32]=M,e[33]=N,e[34]=F,e[35]=I):I=e[35],I}function sI(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`LinkedIn`}),r=(0,Z.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,Z.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 cI(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`X (Twitter)`}),r=(0,Z.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,Z.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 lI=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Lt},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:ei},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:cI},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:sI}],uI=()=>{let e=(0,$.c)(15),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(nn,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,Z.jsx)(wi,{children:`Help & resources`})]}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Setup`}),e[1]=o):o=e[1];let s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Wf)},e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`help-popover-settings`,onClick:s,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(go,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{children:`Settings…`})]})}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{i(!1),n(!0)},e[4]=l):l=e[4];let u,d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsxs)(`ul`,{className:`mb-3 space-y-0.5`,children:[c,(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:l,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)($r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{children:`Install for Claude Chat & Cowork…`})]})})]}),d=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[5]=u,e[6]=d):(u=e[5],d=e[6]);let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(cn,{align:`end`,className:`w-64 p-3`,children:[o,u,d,(0,Z.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:lI.map(dI)})})]}),e[7]=f):f=e[7];let p;e[8]===r?p=e[9]:(p=(0,Z.jsxs)(Gn,{open:r,onOpenChange:i,children:[a,f]}),e[8]=r,e[9]=p);let m;e[10]===t?m=e[11]:(m=(0,Z.jsx)(Hr,{open:t,onOpenChange:n}),e[10]=t,e[11]=m);let h;return e[12]!==p||e[13]!==m?(h=(0,Z.jsxs)(Z.Fragment,{children:[p,m]}),e[12]=p,e[13]=m,e[14]=h):h=e[14],h};function dI(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Pr(e,n),onAuxClick:e=>Pr(e,n),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,Z.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var fI={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function pI(e){let t=(0,$.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=We(),s=fI[r],c=s?(o===`dark`?mt[s]:void 0)??we[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=J(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,Z.jsx)(Sr,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,Z.jsx)(xr,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,Z.jsx)(Or,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}var mI=`https://github.com/inkeep/open-knowledge/releases`;function hI(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 gI(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:mI}}};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 _I(e){return at(e)}function vI(e){return`Opened ${e} in your browser.`}var yI=`claude.ai`;async function bI(e,t=bp){(await t(at(e))).ok?X.success(vI(yI)):X.error(`Couldn't open ${yI} in your browser.`)}function xI(e){let t=(0,$.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??bp,c=e.onWebFallbackSuccess??CI,l=e.onWebFallbackError??SI,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=gI({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=hI({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(_I(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=`Open in ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,Z.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,Z.jsxs)(EA,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,Z.jsxs)(EA,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,Z.jsxs)(MA,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,Z.jsx)(kA,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(AA,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,Z.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,Z.jsx)(EA,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,Z.jsxs)(EA,{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,Z.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,Z.jsxs)(NA,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,Z.jsxs)(jA,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function SI(){}function CI(){}function wI(e){let t=(0,$.c)(60),{input:n}=e,{states:r,refresh:i}=Zp(),{dispatch:a}=Bp(),[o,s]=(0,Q.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l;t[0]===i?l=t[1]:(l=e=>{s(e),e&&i()},t[0]=i,t[1]=l);let u=l,d=n===null,f;t[2]===n?f=t[3]:(f=n===null?``:Pe(n.docContext),t[2]=n,t[3]=f);let p=f,m;t[4]!==a||t[5]!==n?(m=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=m):m=t[6];let h=m,g,_,v,y,b,x,S,C,w,T,E,D;if(t[7]!==u||t[8]!==h||t[9]!==n||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==d){let e;t[26]===r?e=t[27]:(e=e=>r[e.id]?.installed===!0,t[26]=r,t[27]=e);let i=Uf.filter(e);v=r[`claude-cowork`]?.installed===!0;let a;t[28]!==n||t[29]!==p?(a=()=>{n!==null&&bI(p)},t[28]=n,t[29]=p,t[30]=a):a=t[30],y=a,_=CA,D=o,b=u;let s;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(kr,{className:`size-4`}),t[31]=s):s=t[31];let l;t[32]===d?l=t[33]:(l=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:d,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[32]=d,t[33]=l);let f;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(wi,{children:`Edit with AI`}),t[34]=f):f=t[34],t[35]===l?x=t[36]:(x=(0,Z.jsxs)(Ei,{children:[l,f]}),t[35]=l,t[36]=x),g=TA,S=`end`,C=`min-w-[220px]`,w=`open-in-agent-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(kA,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in…`}),t[37]=T):T=t[37];let m;t[38]!==h||t[39]!==p||t[40]!==r?(m=e=>{let t=r[e.id];return(0,Z.jsx)(xI,{target:e,installState:t,isElectronHost:c,prompt:p,onSelect:()=>h(e)},e.id)},t[38]=h,t[39]=p,t[40]=r,t[41]=m):m=t[41],E=i.map(m),t[7]=u,t[8]=h,t[9]=n,t[10]=o,t[11]=p,t[12]=r,t[13]=d,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=D}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23],E=t[24],D=t[25];let O;t[42]!==v||t[43]!==y||t[44]!==n?(O=v?null:(0,Z.jsxs)(EA,{onSelect:y,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(ir,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[42]=v,t[43]=y,t[44]=n,t[45]=O):O=t[45];let k;t[46]!==g||t[47]!==O||t[48]!==S||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E?(k=(0,Z.jsxs)(g,{align:S,className:C,"data-testid":w,children:[T,E,O]}),t[46]=g,t[47]=O,t[48]=S,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=k):k=t[53];let A;return t[54]!==_||t[55]!==b||t[56]!==x||t[57]!==k||t[58]!==D?(A=(0,Z.jsxs)(_,{open:D,onOpenChange:b,children:[x,k]}),t[54]=_,t[55]=b,t[56]=x,t[57]=k,t[58]=D,t[59]=A):A=t[59],A}function TI(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 EI(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function DI(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ea,{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,Z.jsx)(fo,{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,Z.jsx)(Ea,{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,Z.jsx)(fo,{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,Z.jsx)(Oe,{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,Z.jsx)(Ta,{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,Z.jsx)(to,{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,Z.jsx)(Oe,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ea,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function OI(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``;default:return``}}function kI(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 AI(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 jI(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`}`:kI(e.state):`Sync off`}function MI(e){let t=(0,$.c)(75),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,o=n.syncEnabled,{confirmOpen:s,setConfirmOpen:c,onToggleRequest:l,onConfirm:u}=Lr(Ur()),d;t[0]===n?d=t[1]:(d=(0,Z.jsx)(DI,{status:n}),t[0]=n,t[1]=d);let f;t[2]===n.state?f=t[3]:(f=kI(n.state),t[2]=n.state,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[4]=f,t[5]=p);let m;t[6]!==d||t[7]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h=o?`Disable sync`:`Enable sync`,g;t[9]!==o||t[10]!==l||t[11]!==h?(g=(0,Z.jsx)(Ut,{checked:o,onCheckedChange:l,"aria-label":h}),t[9]=o,t[10]=l,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==m||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,g]}),t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==s||t[17]!==u||t[18]!==c?(v=(0,Z.jsx)(qr,{open:s,onOpenChange:c,onConfirm:u}),t[16]=s,t[17]=u,t[18]=c,t[19]=v):v=t[19];let y;t[20]===n.error?y=t[21]:(y=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[20]=n.error,t[21]=y);let b;t[22]===n.pausedReason?b=t[23]:(b=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:AI(n.pausedReason)}),t[22]=n.pausedReason,t[23]=b);let x;t[24]===n.state?x=t[25]:(x=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[24]=n.state,t[25]=x);let S;t[26]!==o||t[27]!==n.lastSyncUtc||t[28]!==n.state?(S=o&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,TI(n.lastSyncUtc)]}),t[26]=o,t[27]=n.lastSyncUtc,t[28]=n.state,t[29]=S):S=t[29];let C;t[30]===n.ahead?C=t[31]:(C=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[30]=n.ahead,t[31]=C);let w;t[32]===n.behind?w=t[33]:(w=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[32]=n.behind,t[33]=w);let T;t[34]===n.conflictCount?T=t[35]:(T=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[34]=n.conflictCount,t[35]=T);let E;t[36]===o?E=t[37]:(E=!o&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[36]=o,t[37]=E);let D;t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==T||t[42]!==E?(D=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[38]=S,t[39]=C,t[40]=w,t[41]=T,t[42]=E,t[43]=D):D=t[43];let O;t[44]!==a||t[45]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(Ao,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.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,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[44]=a,t[45]=n.identityUnresolved,t[46]=O):O=t[46];let k;t[47]!==o||t[48]!==n.state?(k=o&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:PI,children:`Sync now`}),t[47]=o,t[48]=n.state,t[49]=k):k=t[49];let A;t[50]!==o||t[51]!==r||t[52]!==n.state?(A=o&&n.state===`auth-error`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[50]=o,t[51]=r,t[52]=n.state,t[53]=A):A=t[53];let j;t[54]!==o||t[55]!==n.state?(j=o&&n.state===`offline`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:NI,children:`Retry`}),t[54]=o,t[55]=n.state,t[56]=j):j=t[56];let M;t[57]!==o||t[58]!==i||t[59]!==n.state?(M=o&&n.state===`conflict`&&i&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[57]=o,t[58]=i,t[59]=n.state,t[60]=M):M=t[60];let N;t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=N):N=t[65];let P;return t[66]!==b||t[67]!==x||t[68]!==D||t[69]!==O||t[70]!==N||t[71]!==_||t[72]!==v||t[73]!==y?(P=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v,y,b,x,D,O,N]}),t[66]=b,t[67]=x,t[68]=D,t[69]=O,t[70]=N,t[71]=_,t[72]=v,t[73]=y,t[74]=P):P=t[74],P}function NI(){EI(`sync`)}function PI(){EI(`sync`)}function FI(e){let t=(0,$.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}=Vr();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(Ta,{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,Z.jsxs)(Ei,{children:[e,(0,Z.jsx)(wi,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=OI(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=kI(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,Z.jsx)(DI,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.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,Z.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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(Y,{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]:(_=jI(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(wi,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(Ei,{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,Z.jsx)(cn,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(MI,{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,Z.jsxs)(Gn,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var II=[{value:`light`,label:`Light`,icon:wo},{value:`dark`,label:`Dark`,icon:no},{value:`system`,label:`System`,icon:Aa}],LI=()=>{let e=(0,$.c)(16),{theme:t}=We(),{merged:n,userBinding:r}=Kr(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||X.error(Ve(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?Aa:i===`dark`?no:wo,c;e[2]===s?c=e[3]:(c=(0,Z.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=II.map(RI),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(TA,{align:`end`,children:(0,Z.jsx)(DA,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,Z.jsxs)(CA,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function RI(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(OA,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function zI(e){let t=(0,$.c)(47),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s,activeTarget:c}=Qn(),{state:l}=iF(),u=Qf(),d;t[0]!==s||t[1]!==u?(d=jp({docName:s,workspace:u}),t[0]=s,t[1]=u,t[2]=d):d=t[2];let f=d,p=c?.kind===`folder`,m=c?.kind===`asset`,h=p?`${c.folderPath}/`:``,g=m?c.assetPath:``,_,v;t[3]===g?(_=t[4],v=t[5]):(_=g.lastIndexOf(`/`),v=_===-1?``:g.slice(0,_),t[3]=g,t[4]=_,t[5]=v);let y=v,b;t[6]!==g||t[7]!==_?(b=_===-1?g:g.slice(_+1),t[6]=g,t[7]=_,t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(lF,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[9]=S):S=t[9];let C=l===`expanded`?`Hide Files`:`Show Files`,w;t[10]===C?w=t[11]:(w=(0,Z.jsxs)(Ei,{children:[S,(0,Z.jsx)(wi,{children:C})]}),t[10]=C,t[11]=w);let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[12]=T):T=t[12];let E;t[13]!==s||t[14]!==x||t[15]!==y||t[16]!==h||t[17]!==m||t[18]!==p?(E=p?(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(On,{className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:h})]}):m?(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden text-sm`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center overflow-hidden`,children:[y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground/60`,children:y}),(0,Z.jsx)(`span`,{className:`shrink-0 px-2 text-muted-foreground/60`,children:`/`})]}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium text-foreground`,children:x})]})}):s?null:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:h}),t[13]=s,t[14]=x,t[15]=y,t[16]=h,t[17]=m,t[18]=p,t[19]=E):E=t[19];let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(oI,{}),t[20]=D):D=t[20];let O;t[21]!==w||t[22]!==E?(O=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[w,T,E,D]}),t[21]=w,t[22]=E,t[23]=O):O=t[23];let k;t[24]!==s||t[25]!==n||t[26]!==r?(k=s&&(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(mo,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{children:r?`Saving…`:`Checkpoint version`})]}),t[24]=s,t[25]=n,t[26]=r,t[27]=k):k=t[27];let A;t[28]!==s||t[29]!==f?(A=s&&(0,Z.jsx)(wI,{input:f}),t[28]=s,t[29]=f,t[30]=A):A=t[30];let j;t[31]!==o||t[32]!==a||t[33]!==i?(j=(0,Z.jsx)(FI,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[31]=o,t[32]=a,t[33]=i,t[34]=j):j=t[34];let M,N,P,F,I;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(RF,{}),N=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),P=(0,Z.jsx)($l,{}),F=(0,Z.jsx)(uI,{}),I=(0,Z.jsx)(LI,{}),t[35]=M,t[36]=N,t[37]=P,t[38]=F,t[39]=I):(M=t[35],N=t[36],P=t[37],F=t[38],I=t[39]);let L;t[40]!==k||t[41]!==A||t[42]!==j?(L=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 px-3`,children:[k,A,j,M,N,P,F,I]}),t[40]=k,t[41]=A,t[42]=j,t[43]=L):L=t[43];let R;return t[44]!==O||t[45]!==L?(R=(0,Z.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[O,L]}),t[44]=O,t[45]=L,t[46]=R):R=t[46],R}function BI(){let e=(0,$.c)(32),[t,n]=Em(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(Z_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=Wr(),{projectLocalConfig:v,projectLocalSynced:y}=Kr(),{activeDocName:b}=Qn(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&Zi(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(vm,e),()=>window.removeEventListener(vm,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!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`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(km,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(zI,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(PP,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(jg,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(Zl,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(Dm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(hm,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var VI=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
39
+ `)}}}}function OM(e){try{let t=bn().parseToMdast(e),n=[];return DM(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function kM(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))CM.test(n)&&t++;return t}function AM(e){let t=globalThis.Intl.Segmenter;if(!t)return kM(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function jM(e){let t=SM.test(e)?1.5:4;return Math.ceil(e.length/t)}function MM(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Ae(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=OM(t);return n?{words:SM.test(n)?AM(n):kM(n),chars:n.length,tokens:jM(n)}:{words:0,chars:0,tokens:0}}var NM=300;function PM(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(xM),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(xM);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(MM(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,NM)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Q.useEffect)(a,o),r}function FM(e){let t=(0,$.c)(3),[n,r]=(0,Q.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`?IM: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,Q.useEffect)(i,a),n}function IM(e){return e===`synced`?`synced`:`connected`}var LM=Le;function RM(e,t={}){let n=rr(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var zM=4;function BM(e){let t=(0,$.c)(8),{editor:n}=e,r=mr(n),i=!!(n&&r&&r.ancestorChain.length>0),a=i?void 0:`true`,o=`jsx-component-breadcrumb flex items-center gap-1 min-h-[28px] px-3 py-1.5 text-xs font-mono text-muted-foreground overflow-hidden ${i?`border-t border-border`:``}`,s;t[0]!==r||t[1]!==n||t[2]!==i?(s=i&&r?(0,Z.jsx)(HM,{editor:n,blockSelection:r}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,Z.jsx)(`nav`,{"aria-label":`Block ancestor navigation`,"aria-hidden":a,className:o,children:s}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function VM(e,t){let n=rn.getState(e.state)?.posToId;if(!n)return t.pos;for(let[e,r]of n)if(r===t.bridgeId)return e;return null}function HM(e){let t=(0,$.c)(9),{editor:n,blockSelection:r}=e,{ancestorChain:i,selectedBlockId:a}=r,o;if(t[0]!==i||t[1]!==n||t[2]!==a){let e=GM(i),r;t[4]===n?r=t[5]:(r=(0,Z.jsx)(`button`,{type:`button`,className:`opacity-60 hover:opacity-100 hover:text-foreground transition-opacity outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,onClick:()=>{n.chain().focus().setTextSelection(0).command(WM).run()},children:Gt}),t[4]=n,t[5]=r);let s;t[6]!==n||t[7]!==a?(s=e=>{if(e.kind===`ellipsis`)return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(An,{size:12,className:`opacity-50`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{role:`img`,"aria-label":`${e.hiddenCount} hidden ancestors`,title:`${e.hiddenCount} hidden ancestors`,className:`opacity-60`,children:`…`})]},`ellipsis`);let t=RM(e.entry),r=e.entry.bridgeId===a;return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(An,{size:12,className:`opacity-50 shrink-0`,"aria-hidden":`true`}),r?(0,Z.jsx)(`span`,{"aria-current":`location`,className:`text-foreground truncate`,children:t}):(0,Z.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm truncate`,onClick:()=>{let t=VM(n,e.entry);t!==null&&n.chain().focus().setNodeSelection(t).command(UM).run()},children:t})]},e.entry.bridgeId)},t[6]=n,t[7]=a,t[8]=s):s=t[8],o=(0,Z.jsxs)(Z.Fragment,{children:[r,e.map(s)]}),t[0]=i,t[1]=n,t[2]=a,t[3]=o}else o=t[3];return o}function UM(e){let{tr:t}=e;return t.setMeta(xn,`programmatic`),!0}function WM(e){let{tr:t}=e;return t.setMeta(xn,`programmatic`),!0}function GM(e){if(e.length<=zM)return e.map(e=>({kind:`entry`,entry:e}));let t=e[0],n=e.slice(-2),r=e.length-1-n.length;return[{kind:`entry`,entry:t},{kind:`ellipsis`,hiddenCount:r},...n.map(e=>({kind:`entry`,entry:e}))]}var KM=200,qM=`Outside any block`;function JM(e){let t=(0,$.c)(5),{editor:n}=e,r=mr(n),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?YM(n,r):o.current?qM:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},KM),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Q.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function YM(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=RM(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=RM(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function XM(){let[e]=(0,Q.useState)(K);return e}function ZM({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:z(e.display_name),color:ke(e.id,ee),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:ke(e.id,ee),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function QM(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 $M=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&&pt(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(je(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Re(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(pe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Se(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(_e(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(lt(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ke(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=V(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof Be){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 xe){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():QM(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&I(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()}},eN=e=>new ie({key:typeof e.pluginKey==`string`?new ae(e.pluginKey):e.pluginKey,view:t=>new $M({view:t,...e})});Qe.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[eN({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 tN=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 Te(e,{textSerializers:ht(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(je(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(Re(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(it(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(pe(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Se(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(_e(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(lt(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(Ke(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=V(this.view,e.from,e.to);I({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()}},nN=e=>new ie({key:typeof e.pluginKey==`string`?new ae(e.pluginKey):e.pluginKey,view:t=>new tN({view:t,...e})});Qe.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?[nN({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 rN(e,t){return e??new ae(t)}var iN=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,aN=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),oN=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(`.`)),sN=new Set([`children`,`className`,`style`]),cN=new Set([`tabIndex`]),lN=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),uN={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function dN(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function fN(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function pN(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||lN.has(e)}function mN(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function hN(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:uN[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function gN(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 _N(e){return cN.has(e)}function vN(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function yN(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 bN(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||oN.has(e)?String(t):`${t}px`}function xN(e,t){aN.has(t)||e.style.removeProperty(mN(t))}function SN(e,t,n){aN.has(t)||e.style.setProperty(mN(t),bN(t,n))}function CN(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(sN.has(r)||!pN(r)||dN(r,t[r])||dN(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=fN(r);if(a==null||a===!1){_N(r)&&yN(e,r),e.removeAttribute(o);return}if(a===!0){_N(r)&&vN(e,r,!0),e.setAttribute(o,``);return}if(_N(r)){vN(e,r,a);return}e.setAttribute(o,String(a))})}function wN(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function TN(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){xN(e,t);return}SN(e,t,a)}})}function EN(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(!dN(t,n))return;let{eventName:i,options:a}=hN(t),o=t=>{n(gN(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function DN(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);iN(()=>{let i=n.current;return wN(e,i.className,t.className),TN(e,i.style,t.style),CN(e,i,t),r.current=EN(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 ON=Q.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,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(rN(e,`bubbleMenu`)).current;DN(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=hr(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Q.useRef)(h);g.current=h;let[_,v]=(0,Q.useState)(!1),y=(0,Q.useRef)(!0);return(0,Q.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=eN({...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,Q.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,_a.createPortal)(c,d.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Q.useRef)(document.createElement(`div`)),d=(0,Q.useRef)(rN(e,`floatingMenu`)).current;DN(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=hr(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Q.useRef)(m);h.current=m;let[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(!0);return(0,Q.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=nN({...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,Q.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,_a.createPortal)(s,u.current)});var kN=[{name:`paragraph`,label:`Text`,icon:so,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:Qt,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:En,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:en,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:yn,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:ln,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:bo,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function AN(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:jN},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Sn(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,Z.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,Z.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Mn,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsxs)(Y,{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=kN.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(EA,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,Z.jsx)(t,{className:`size-4`}),(0,Z.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,Z.jsx)(TA,{align:`start`,sideOffset:8,className:`w-44 max-h-(--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,Z.jsxs)(CA,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function jN(e){let t=Object.fromEntries(kN.map(t=>[t.name,t.isActive(e.editor)]));return{current:kN.find(e=>t[e.name])??kN[0],activeStates:t}}var MN=[{name:`bold`,icon:ga,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:qa,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Oo,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Co,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:Da,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ka,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function NN(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:PN},t[0]=n,t[1]=r);let i=Sn(r),a;t[2]!==i||t[3]!==n?(a=MN.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(wi,{side:`bottom`,sideOffset:8,children:[(0,Z.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,Z.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,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function PN(e){return Object.fromEntries(MN.map(t=>[t.name,t.isActive(e.editor)]))}function FN(e){let t=(0,$.c)(46),{editor:n}=e,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.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,Q.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,Q.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,Z.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,Z.jsx)(ja,{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,Z.jsx)(Y,{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,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),vr(d)},children:(0,Z.jsx)(ti,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(Kn,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{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,Z.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,Z.jsx)(Za,{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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsxs)(wi,{side:`bottom`,sideOffset:8,children:[`Link`,(0,Z.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,Z.jsxs)(Ei,{children:[T,E]}),t[44]=T,t[45]=D),D}function IN({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 LN(e){let t=(0,$.c)(25),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return V(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=se(e,t,()=>{I(e,t,{placement:`top`,strategy:`fixed`,middleware:[it(8),je(),Re({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(BN)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let l=c,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{o.current?.(),o.current=null,a(zN)},t[6]=u):u=t[6];let d=u,f;t[7]===l?f=t[8]:(f={onShow:l,onHide:d,strategy:`fixed`},t[7]=l,t[8]=f);let p;t[9]===n?p=t[10]:(p=(0,Z.jsx)(AN,{editor:n}),t[9]=n,t[10]=p);let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=m):m=t[11];let h;t[12]!==n||t[13]!==i?(h=(0,Z.jsx)(NN,{editor:n},i),t[12]=n,t[13]=i,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=g):g=t[15];let _=`${i}-link`,v;t[16]!==n||t[17]!==_?(v=(0,Z.jsx)(FN,{editor:n},_),t[16]=n,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==n||t[20]!==v||t[21]!==f||t[22]!==p||t[23]!==h?(y=(0,Z.jsxs)(ON,{ref:r,editor:n,appendTo:RN,shouldShow:IN,updateDelay:250,options:f,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[p,m,h,g,v]}),t[19]=n,t[20]=v,t[21]=f,t[22]=p,t[23]=h,t[24]=y):y=t[24],y}function RN(){return document.body}function zN(e){return e+1}function BN(){}var VN=[{name:`addRowBefore`,icon:Bn,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:ur,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:Kn,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],HN=[{name:`addColumnBefore`,icon:Er,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:Qr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:Kn,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],UN=[{name:`toggleHeaderRow`,icon:To,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:ka,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:Ua,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function WN({editor:e}){return e.isActive(`table`)}function GN(e){let t=(0,$.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,Z.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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{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,Z.jsx)(wi,{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,Z.jsxs)(Ei,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function KN(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=VN.map(e=>(0,Z.jsx)(GN,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Ng,{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=HN.map(e=>(0,Z.jsx)(GN,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(Ng,{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=UN.map(e=>(0,Z.jsx)(GN,{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,Z.jsxs)(ON,{editor:n,shouldShow:WN,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 qN=new WeakMap;function JN(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=ft(e.color),n.textContent=e.name,t.append(n),t}var YN={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},XN=e=>{let t=(0,$.c)(66),{provider:n,placeholder:r,isSourceMode:i}=e,a=(0,Q.useRef)(null),o=(0,Q.useRef)(YN),s=XM(),{principal:c,activeDocName:l}=Qn(),u=n.configuration.name??``,[d]=(0,Q.useState)(ZN),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null);if(m)throw m;let g=(0,Q.useRef)(null),_;t[0]!==d||t[1]!==u||t[2]!==r||t[3]!==n?(_=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=gn({docName:u,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new Me({element:e,onBeforeCreate:e=>{let{editor:n}=e;qN.set(n,t)},onCreate:e=>{let{editor:t}=e;d.html.setView(t.view);let r=qN.get(t);if(qN.delete(t),r==null)return;let i=performance.now();Wt(`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-4 pb-4 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=d.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>d.text(e,t),clipboardSerializer:d.html.serializer,handlePaste:(e,t)=>d.paste(e,t),handleDrop:(e,t)=>d.drop(e,t)},extensions:xu([...Hn.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:n.configuration.name??``}):e),LM.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),Yt.configure({document:n.document}),Qe.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[tn]}}),Qe.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[Xn(e,{cursorBuilder:JN})]}})])}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),g.current=e,p(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),g.current=null,p(null),h(t instanceof Error?t:Error(String(t)))}return()=>{let e=g.current;e&&Vn(e),g.current=null,p(null)}},t[0]=d,t[1]=u,t[2]=r,t[3]=n,t[4]=_):_=t[4];let v;t[5]!==d||t[6]!==u||t[7]!==n?(v=[u,n,d],t[5]=d,t[6]=u,t[7]=n,t[8]=v):v=t[8],(0,Q.useEffect)(_,v);let y;t[9]!==f||t[10]!==n.configuration.name?(y=()=>{if(f)return jn(f,n.configuration.name??null),()=>{jn(f,null)}},t[9]=f,t[10]=n.configuration.name,t[11]=y):y=t[11];let b;t[12]!==f||t[13]!==n?(b=[f,n],t[12]=f,t[13]=n,t[14]=b):b=t[14],(0,Q.useEffect)(y,b);let x;t[15]!==f||t[16]!==n.configuration.name?(x=()=>{},t[15]=f,t[16]=n.configuration.name,t[17]=x):x=t[17];let S;t[18]!==f||t[19]!==n?(S=[f,n],t[18]=f,t[19]=n,t[20]=S):S=t[20],(0,Q.useEffect)(x,S);let C,w;t[21]===f?(C=t[22],w=t[23]):(C=()=>{if(!f)return;let e=QN,t=null,n=()=>{if(t||!f||f.isDestroyed)return;let n=gr(f);n&&(t=n.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 gr(f)?n():f.on(`create`,n),()=>{f.off(`create`,n),r()}},w=[f],t[21]=f,t[22]=C,t[23]=w),(0,Q.useEffect)(C,w);let T,E;t[24]!==f||t[25]!==n.document?(E=()=>{if(!f)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,s=null,c=null,l=()=>{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},u=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??``))},d=()=>{let e=l(),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};u(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),s&&clearTimeout(s),c&&clearTimeout(c),s=window.setTimeout(()=>{let e={...n,state:`settled`};u(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{u({...e,state:`idle`})},300)},oe)};u(YN);let p=()=>{if(_t(e),!B(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(),d()},e)}return}r=n,d()};e.observe(p);let m=()=>{document.visibilityState===`visible`?B(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(p),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),s&&clearTimeout(s),c&&clearTimeout(c)}},T=[f,n.document],t[24]=f,t[25]=n.document,t[26]=T,t[27]=E):(T=t[26],E=t[27]),(0,Q.useEffect)(E,T);let D,O;t[28]===n?(D=t[29],O=t[30]):(D=()=>{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)}},O=[n],t[28]=n,t[29]=D,t[30]=O),(0,Q.useEffect)(D,O);let k,A;t[31]===f?(k=t[32],A=t[33]):(k=()=>{if(!f)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!f||f.isDestroyed)return;let n=gr(f);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(Qi,e),()=>window.removeEventListener(Qi,e)},A=[f],t[31]=f,t[32]=k,t[33]=A),(0,Q.useEffect)(k,A);let j;t[34]!==l||t[35]!==u||t[36]!==s||t[37]!==i||t[38]!==c||t[39]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(u!==l){e.setLocalState(null);return}e.setLocalState({user:ZM({principal:c,identity:s}),mode:i?`source`:`wysiwyg`})}},t[34]=l,t[35]=u,t[36]=s,t[37]=i,t[38]=c,t[39]=n.awareness,t[40]=j):j=t[40];let M;t[41]!==l||t[42]!==u||t[43]!==s||t[44]!==i||t[45]!==c||t[46]!==n?(M=[n,u,l,s,c,i],t[41]=l,t[42]=u,t[43]=s,t[44]=i,t[45]=c,t[46]=n,t[47]=M):M=t[47],(0,Q.useEffect)(j,M);let N;t[48]===f?N=t[49]:(N=f&&(0,Z.jsx)(LN,{editor:f}),t[48]=f,t[49]=N);let P;t[50]===f?P=t[51]:(P=f&&(0,Z.jsx)(KN,{editor:f}),t[50]=f,t[51]=P);let F,I;t[52]===f?(F=t[53],I=t[54]):(F=(0,Z.jsx)(Ht,{editor:f,className:`h-full`}),I=f&&(0,Z.jsx)(BM,{editor:f}),t[52]=f,t[53]=F,t[54]=I);let L;t[55]===f?L=t[56]:(L=f&&(0,Z.jsx)(JM,{editor:f}),t[55]=f,t[56]=L);let R;t[57]===f?R=t[58]:(R=f&&(0,Z.jsx)($t,{store:qt(f).store}),t[57]=f,t[58]=R);let z;return t[59]!==N||t[60]!==P||t[61]!==F||t[62]!==I||t[63]!==L||t[64]!==R?(z=(0,Z.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,L,R]}),t[59]=N,t[60]=P,t[61]=F,t[62]=I,t[63]=L,t[64]=R,t[65]=z):z=t[65],z};function ZN(){let e=new de({extensions:L});return{mdManager:e,text:Zt({mdManager:e}),html:Tn({mdManager:e}),paste:Dn({mdManager:e}),drop:Cn({mdManager:e})}}function QN(){return Vt()}function $N(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(fr(n,r));let a;return t[0]===i?a=t[1]:(a=(0,Z.jsx)(Z.Fragment,{children:i}),t[0]=i,t[1]=a),a}var eP=`__back-nav__`;function tP(e){return e instanceof In||e instanceof er||e instanceof Nn||e instanceof Un||e instanceof sr?e.docName:null}function nP(e){return e instanceof In?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof er?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof Nn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Un?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof sr?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function rP(e){let t=(0,$.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=nP(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Q.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,Q.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Z.jsx)(Cb,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,Z.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,Z.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,Z.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,Z.jsx)(Y,{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,Z.jsx)(Y,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(Yn(tP(n)??i),o(a),r(eP))},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,Z.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,Z.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 iP(e){let t=(0,$.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,Z.jsx)(rP,{...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]===eP){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}: ${nP(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,Z.jsx)(mn,{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}var aP={text:``,number:0,boolean:!1,date:``,list:[]};function oP(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=me(t);return{map:n,keys:ge(t),parseError:r}}function sP(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>oP(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{let e=qe(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Q.useEffect)(c,l);let u=o.map,d=o.keys,f=o.parseError,[p,m]=(0,Q.useState)(!1),h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h={},t[5]=h):h=t[5];let[g,_]=(0,Q.useState)(h),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S={},t[6]=S):S=t[6];let[C,w]=(0,Q.useState)(S),T;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(T={},t[7]=T):T=t[7];let[E,D]=(0,Q.useState)(T),O=n.configuration.name??``,k;t[8]===O?k=t[9]:(k=lP(O),t[8]=O,t[9]=k);let A=Nj(k),j;t[10]!==A.state.data||t[11]!==A.state.status?(j=A.state.status===`ready`?A.state.data.folder.frontmatter_defaults??{}:{},t[10]=A.state.data,t[11]=A.state.status,t[12]=j):j=t[12];let M=j,N;t[13]!==A.state.data||t[14]!==A.state.status?(N=A.state.status===`ready`?A.state.data.frontmatterSources:{},t[13]=A.state.data,t[14]=A.state.status,t[15]=N):N=t[15];let P=N,F;t[16]===r?F=t[17]:(F=function(e){if(!r)return{ok:!1,error:`Connecting…`};let t=r.patch(e);if(t.ok)return{ok:!0};if(t.error.code===`WRITE_ERROR`)return console.warn(`[PropertyPanel] binding write error:`,t.error.detail),{ok:!1,error:t.error.detail};let n=ue(t.error);return{ok:!1,error:t.error.issues[0]?.message??`Invalid patch payload`,fieldErrors:Object.keys(n).length>0?n:void 0}},t[16]=r,t[17]=F);let I=F,L;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(L=function(e){w(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=L):L=t[18];let R=L,z;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(z=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};w(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),D(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=z):z=t[19];let B=z,V;t[20]===I?V=t[21]:(V=function(e,t){R(e),B(I({[e]:t}),[e])},t[20]=I,t[21]=V);let H=V,U;t[22]===I?U=t[23]:(U=function(e){R(e),B(I({[e]:null}),[e])},t[22]=I,t[23]=U);let W=U,G;t[24]===r?G=t[25]:(G=function(e,t){if(!r)return{ok:!1,error:`Connecting…`};if(e===t)return{ok:!0};let n=r.rename(e,t);if(n.ok)return{ok:!0};if(n.error.code===`WRITE_ERROR`)return{ok:!1,error:n.error.detail};let i=ue(n.error);return{ok:!1,error:n.error.issues[0]?.message??`Failed to rename`,fieldErrors:Object.keys(i).length>0?i:void 0}},t[24]=r,t[25]=G);let ee=G,te;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(te=function(e,t){return`${e} ${t}`},t[26]=te):te=t[26];let ne=te,re;t[27]!==r||t[28]!==d?(re=function(e){if(!r)return;let t=String(e.active.id),n=e.over?String(e.over.id):null;if(!n||t===n)return;let i=d.map((e,t)=>ne(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=d.slice(),[c]=s.splice(a,1);if(!c)return;s.splice(o,0,c);let l=r.reorder(s);l.ok||console.warn(`[PropertyPanel] reorder failed:`,l.error)},t[27]=r,t[28]=d,t[29]=re):re=t[29];let ie=re,ae;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ae={activationConstraint:{distance:4}},t[30]=ae):ae=t[30];let oe;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(oe={coordinateGetter:Sw},t[31]=oe):oe=t[31];let se=Gx(Wx(qS,ae),Wx(HS,oe)),ce;t[32]!==M||t[33]!==H||t[34]!==u?(ce=function(e,t){let n=u[e]??uP(M[e]);if(n===void 0)return;_(n=>({...n,[e]:t}));let r=JA(n,t);(!Object.hasOwn(u,e)||!cP(n,r))&&H(e,r)},t[32]=M,t[33]=H,t[34]=u,t[35]=ce):ce=t[35];let K=ce,q;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(q=function(){y({name:``,type:`text`,value:``,error:null}),m(!1)},t[36]=q):q=t[36];let de=q,{addPropertySignal:fe,clearAddProperty:pe}=uM(),me;t[37]!==fe||t[38]!==O?(me=fe.get(O)??0,t[37]=fe,t[38]=O,t[39]=me):me=t[39];let he=me,ge,_e;t[40]===he?(ge=t[41],_e=t[42]):(ge=()=>{he>0&&(y({name:``,type:`text`,value:``,error:null}),m(!1))},_e=[he],t[40]=he,t[41]=ge,t[42]=_e),(0,Q.useEffect)(ge,_e);let ve,ye;t[43]!==pe||t[44]!==O?(ve=()=>()=>pe(O),ye=[O,pe],t[43]=pe,t[44]=O,t[45]=ve,t[46]=ye):(ve=t[45],ye=t[46]),(0,Q.useEffect)(ve,ye);let be;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(be=function(e){y(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):aP[e];return{...t,type:e,value:n,error:null}})},t[47]=be):be=t[47];let xe=be,Se;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){y(t=>t&&{...t,value:e})},t[48]=Se):Se=t[48];let Ce=Se,we;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){y(t=>t&&{...t,name:e,error:null})},t[49]=we):we=t[49];let Te=we,Ee;t[50]!==v||t[51]!==I||t[52]!==u?(Ee=function(){if(!v)return;let e=v.name.trim();if(!e){y({...v,error:`Name is required`});return}if(e===`frontmatter`){y({...v,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){y({...v,error:`Property "${e}" already exists`});return}let t=I({[e]:v.value});if(t.ok){y(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;y({...v,error:n??r})},t[50]=v,t[51]=I,t[52]=u,t[53]=Ee):Ee=t[53];let De=Ee,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){y(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){x({key:e,draft:e,error:null})},t[55]=je):je=t[55];let Me=je,Ne;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=function(e){x(t=>t&&{...t,draft:e,error:null})},t[56]=Ne):Ne=t[56];let Pe=Ne,Fe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=function(){x(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==u||t[59]!==ee||t[60]!==b?(Le=function(){if(!b)return;let e=b.draft.trim();if(!e){x(null);return}if(e===b.key){x(null);return}if(e===`frontmatter`){x({...b,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(u,e)){x({...b,error:`Property "${e}" already exists`});return}let t=ee(b.key,e);if(t.ok){_(t=>{if(!Object.hasOwn(t,b.key))return t;let n={...t};return n[e]=n[b.key],delete n[b.key],n}),R(b.key),x(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[b.key]??t.error??`Failed to rename property`;x({...b,error:n})},t[58]=u,t[59]=ee,t[60]=b,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==u||t[63]!==d?(ze=d.length>0?d:Object.keys(u),t[62]=u,t[63]=d,t[64]=ze):ze=t[64];let Be=ze,Ve;if(t[65]!==Be){Ve=new Map;for(let e of Be)Ve.set(e,(Ve.get(e)??0)+1);t[65]=Be,t[66]=Ve}else Ve=t[66];let He,Ue,We,Ge,Ke,Je,Ye,Xe,Ze,Qe,$e,et;if(t[67]!==v||t[68]!==M||t[69]!==P||t[70]!==p||t[71]!==H||t[72]!==Re||t[73]!==Ve||t[74]!==C||t[75]!==ie||t[76]!==u||t[77]!==g||t[78]!==f||t[79]!==W||t[80]!==b||t[81]!==Be||t[82]!==E||t[83]!==se||t[84]!==K){et=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(M).filter(e=>!Object.hasOwn(u,e)).sort();if(Be.length===0&&e.length===0&&!v&&!f){et=null;break bb0}Qe=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,$e=`property-panel`,Ue=fn,Ye=!p,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=e=>m(!e),t[97]=Xe):Xe=t[97];let n=!p,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(An,{"data-expanded":n,className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150 ease-out data-[expanded=true]:rotate-90`}),t[98]=n,t[99]=r);let i;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`span`,{children:`Properties`}),t[100]=i):i=t[100],t[101]===r?Ze=t[102]:(Ze=(0,Z.jsx)(Rt,{asChild:!0,children:(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,className:`mb-1.5 flex h-auto w-fit bg-transparent! items-center gap-1 px-1 py-0.5 text-base font-medium text-foreground hover:bg-transparent hover:text-foreground`,children:[r,i]})}),t[101]=r,t[102]=Ze),He=qn,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===f?Ge=t[104]:(Ge=f?(0,Z.jsxs)(`div`,{role:`alert`,"data-testid":`property-panel-yaml-error`,className:`mb-1 flex items-start gap-1.5 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[11px] text-destructive`,children:[(0,Z.jsx)(Oe,{className:`size-3.5 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{children:[`Frontmatter YAML is malformed; fix in source mode to recover.`,(0,Z.jsx)(`span`,{className:`block text-[10px] opacity-80`,children:f})]})]}):null,t[103]=f,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ne(e,t),t[107]=e):e=t[107],a=Be.map(e),t[105]=Be,t[106]=a}else a=t[106];let o;if(t[108]!==M||t[109]!==P||t[110]!==H||t[111]!==Re||t[112]!==Ve||t[113]!==C||t[114]!==u||t[115]!==g||t[116]!==W||t[117]!==b||t[118]!==Be||t[119]!==E||t[120]!==K){let e;t[122]!==M||t[123]!==P||t[124]!==H||t[125]!==Re||t[126]!==Ve||t[127]!==C||t[128]!==u||t[129]!==g||t[130]!==W||t[131]!==b||t[132]!==E||t[133]!==K?(e=(e,t)=>{let n=u[e];if(n===void 0)return null;let r=g[e]??le(n),i=b?.key===e?b:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(M,e)?(0,Z.jsx)(dP,{source:P[e]??``}):void 0;return(0,Z.jsx)(XA,{sortableId:ne(e,t),keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>H(e,t),onChangeType:t=>K(e,t),onRemove:()=>W(e)},`${e}-${t}`)},t[122]=M,t[123]=P,t[124]=H,t[125]=Re,t[126]=Ve,t[127]=C,t[128]=u,t[129]=g,t[130]=W,t[131]=b,t[132]=E,t[133]=K,t[134]=e):e=t[134],o=Be.map(e),t[108]=M,t[109]=P,t[110]=H,t[111]=Re,t[112]=Ve,t[113]=C,t[114]=u,t[115]=g,t[116]=W,t[117]=b,t[118]=Be,t[119]=E,t[120]=K,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(uw,{items:a,strategy:ow,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==ie||t[139]!==se||t[140]!==s?(Ke=(0,Z.jsx)(WC,{sensors:se,collisionDetection:$x,onDragEnd:ie,children:s}),t[138]=ie,t[139]=se,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==M||t[143]!==P||t[144]!==H||t[145]!==C||t[146]!==E||t[147]!==K?(c=e=>{let t=M[e],n=uP(t),r=le(n),i=P[e]??``;return(0,Z.jsx)(XA,{keyName:e,value:n,declared:r,error:C[e]??null,resetCounter:E[e]??0,isInherited:!0,badge:(0,Z.jsx)(rj,{source:i}),onCommit:t=>H(e,t),onChangeType:t=>K(e,t)},`inherited-${e}`)},t[142]=M,t[143]=P,t[144]=H,t[145]=C,t[146]=E,t[147]=K,t[148]=c):c=t[148],Je=e.map(c)}t[67]=v,t[68]=M,t[69]=P,t[70]=p,t[71]=H,t[72]=Re,t[73]=Ve,t[74]=C,t[75]=ie,t[76]=u,t[77]=g,t[78]=f,t[79]=W,t[80]=b,t[81]=Be,t[82]=E,t[83]=se,t[84]=K,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=Je,t[91]=Ye,t[92]=Xe,t[93]=Ze,t[94]=Qe,t[95]=$e,t[96]=et}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],Je=t[90],Ye=t[91],Xe=t[92],Ze=t[93],Qe=t[94],$e=t[95],et=t[96];if(et!==Symbol.for(`react.early_return_sentinel`))return et;let tt;t[149]!==v||t[150]!==De?(tt=v?(0,Z.jsx)(tj,{draft:v,onChangeName:Te,onChangeType:xe,onChangeValue:Ce,onCommit:De,onCancel:Ae}):(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:de,className:`mt-1 flex items-center gap-1.5 rounded px-2 py-1 font-medium text-sm hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(co,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=v,t[150]=De,t[151]=tt):tt=t[151];let nt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==Je||t[157]!==tt?(nt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,Je,tt]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=Je,t[157]=tt,t[158]=nt):nt=t[158];let rt;t[159]!==Ue||t[160]!==Ye||t[161]!==Xe||t[162]!==Ze||t[163]!==nt?(rt=(0,Z.jsxs)(Ue,{open:Ye,onOpenChange:Xe,children:[Ze,nt]}),t[159]=Ue,t[160]=Ye,t[161]=Xe,t[162]=Ze,t[163]=nt,t[164]=rt):rt=t[164];let it;return t[165]!==Qe||t[166]!==$e||t[167]!==rt?(it=(0,Z.jsx)(`div`,{className:Qe,"data-testid":$e,children:rt}),t[165]=Qe,t[166]=$e,t[167]=rt,t[168]=it):it=t[168],it}function cP(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function lP(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function uP(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:Array.isArray(e)?e.map(e=>typeof e==`string`?e:JSON.stringify(e)):e==null?``:JSON.stringify(e)}function dP(e){let t=(0,$.c)(2),{source:n}=e,r=`Overrides default from ${n===``?`.ok/frontmatter.yml`:`${n}/.ok/frontmatter.yml`}. Remove to revert.`,i;return t[0]===r?i=t[1]:(i=(0,Z.jsx)(pn,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var fP=$n(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function pP(e){let t=e.threshold??fP;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function mP(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var hP=$n(`ACTIVITY_MOUNT_LIMIT`,3);function gP(){return r(()=>import(`./SourceEditor-CTgjCTMk.js`),__vite__mapDeps([32,1,27,2,28,29,14,13,3,6,7,30,4,8,33,16]),import.meta.url)}var _P=(0,Q.lazy)(async()=>({default:(await gP()).SourceEditor}));function vP(e,t,n){if(n<=0)return[];let r=e.filter(e=>!Rn(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 yP(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function bP(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Kt,{name:`activity-pool`,children:(0,Z.jsx)(xP,{...e})}),t[0]=e,t[1]=n),n}function xP(e){let t=(0,$.c)(12),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=Qn(),{pages:u,loading:d}=Ee(),f=vP(c,n,hP),p=(0,Q.useRef)(``),m=f.map(SP).join(`,`);(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[];Wt(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),p.current=m,dr(t)},[m,n]);let h;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==d||t[4]!==o||t[5]!==s||t[6]!==u||t[7]!==a||t[8]!==l?(h=e=>(0,Z.jsx)(DP,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[0]=n,t[1]=i,t[2]=r,t[3]=d,t[4]=o,t[5]=s,t[6]=u,t[7]=a,t[8]=l,t[9]=h):h=t[9];let g=f.map(h),_;return t[10]===g?_=t[11]:(_=(0,Z.jsx)(Z.Fragment,{children:g}),t[10]=g,t[11]=_),_}function SP(e){return e.docName}function CP(e){let t=(0,$.c)(8),{isActive:n,children:r}=e,i=(0,Q.useRef)(null),a=(0,Q.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,Q.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,Q.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,Z.jsx)(`div`,{ref:i,"data-testid":`editor-scroll-container`,className:`subtle-scrollbar h-full overflow-y-auto`,style:u,children:r}),t[6]=r,t[7]=d),d}function wP(e){let t=(0,$.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Q.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,Q.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Z.jsx)($y,{}),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,Z.jsx)(Q.Suspense,{fallback:d,children:(0,Z.jsx)(_P,{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 TP(e){let t=(0,$.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,Z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,Z.jsx)(fo,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Jt,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,Z.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,Z.jsxs)(Y,{type:`button`,onClick:EP,children:[(0,Z.jsx)(fo,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,Z.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function EP(){return window.location.reload()}function DP(e){let t=(0,$.c)(45),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=yP(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=n.provider.document.getText(`source`).length,[m,h]=(0,Q.useState)(i),[g,_]=(0,Q.useState)(!i),v,y;t[3]!==i||t[4]!==m||t[5]!==g?(v=()=>{i&&!m?h(!0):!i&&!g&&_(!0)},y=[i,m,g],t[3]=i,t[4]=m,t[5]=g,t[6]=v,t[7]=y):(v=t[6],y=t[7]),(0,Q.useEffect)(v,y);let b=pP({ytextLength:p,isSourceMode:i,visitedSource:m,visitedVisual:g}),x=(0,Q.useRef)(``),S=`${b.isLarge}-${b.renderSource}-${b.renderVisual}`,C,w;t[8]!==n.docName||t[9]!==b.isLarge||t[10]!==b.renderSource||t[11]!==b.renderVisual||t[12]!==S||t[13]!==i||t[14]!==p?(C=()=>{x.current!==S&&(x.current=S,b.isLarge&&Wt(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:p,isSourceMode:i,renderSource:b.renderSource,renderVisual:b.renderVisual}))},w=[S,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[8]=n.docName,t[9]=b.isLarge,t[10]=b.renderSource,t[11]=b.renderVisual,t[12]=S,t[13]=i,t[14]=p,t[15]=C,t[16]=w):(C=t[15],w=t[16]),(0,Q.useEffect)(C,w);let[T,E]=(0,Q.useState)(!1),D,O;t[17]!==n.docName||t[18]!==b.isLarge||t[19]!==b.renderSource||t[20]!==b.renderVisual||t[21]!==T||t[22]!==i||t[23]!==p?(D=()=>{mP({isLarge:b.isLarge,renderSource:b.renderSource,renderVisual:b.renderVisual,hasEmittedFirstToggle:T})&&(Wt(`ok/cold/first-toggle`,{docName:n.docName,ytextLength:p,modeEnteredFirst:i?`source`:`visual`}),E(!0))},O=[T,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[17]=n.docName,t[18]=b.isLarge,t[19]=b.renderSource,t[20]=b.renderVisual,t[21]=T,t[22]=i,t[23]=p,t[24]=D,t[25]=O):(D=t[24],O=t[25]),(0,Q.useEffect)(D,O);let k=r?`visible`:`hidden`,A=`editor:${n.docName}`,j;t[26]!==a||t[27]!==n||t[28]!==b.renderSource||t[29]!==b.renderVisual||t[30]!==r||t[31]!==o||t[32]!==i||t[33]!==c||t[34]!==l||t[35]!==s||t[36]!==f?(j=f?(0,Z.jsx)(TP,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(iP,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)($y,{}),children:(0,Z.jsx)($N,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col ${i?``:`pt-6`}`,children:[!i&&(0,Z.jsx)(sP,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[b.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(wP,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,b.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(XN,{provider:n.provider,placeholder:a,isSourceMode:i},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[26]=a,t[27]=n,t[28]=b.renderSource,t[29]=b.renderVisual,t[30]=r,t[31]=o,t[32]=i,t[33]=c,t[34]=l,t[35]=s,t[36]=f,t[37]=j):j=t[37];let M;t[38]!==r||t[39]!==j?(M=(0,Z.jsx)(CP,{isActive:r,children:j}),t[38]=r,t[39]=j,t[40]=M):M=t[40];let N;return t[41]!==M||t[42]!==k||t[43]!==A?(N=(0,Z.jsx)(Q.Activity,{mode:k,name:A,children:M}),t[41]=M,t[42]=k,t[43]=A,t[44]=N):N=t[44],N}function OP(e){let t=(0,$.c)(26),{stats:n}=e,r;t[0]===n.words?r=t[1]:(r=n.words.toLocaleString(),t[0]=n.words,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:r}),t[2]=r,t[3]=i);let a=n.words===1?`word`:`words`,o;t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`span`,{children:[i,` `,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===n.chars?s=t[8]:(s=n.chars.toLocaleString(),t[7]=n.chars,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:s}),t[9]=s,t[10]=c);let l=n.chars===1?`char`:`chars`,u;t[11]!==c||t[12]!==l?(u=(0,Z.jsxs)(`span`,{children:[c,` `,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13];let d=n.tokens>0?`~`:``,f;t[14]===n.tokens?f=t[15]:(f=n.tokens.toLocaleString(),t[14]=n.tokens,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:f}),t[16]=f,t[17]=p);let m=n.tokens===1?`token`:`tokens`,h;t[18]!==p||t[19]!==m||t[20]!==d?(h=(0,Z.jsxs)(`span`,{children:[d,p,` `,m]}),t[18]=p,t[19]=m,t[20]=d,t[21]=h):h=t[21];let g;return t[22]!==h||t[23]!==o||t[24]!==u?(g=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`flex h-6 shrink-0 items-center justify-end gap-3 px-3 text-2xs text-muted-foreground`,children:[o,u,h]}),t[22]=h,t[23]=o,t[24]=u,t[25]=g):g=t[25],g}var kP={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`},AP=e=>{let t=(0,$.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,Z.jsx)(`svg`,{"aria-hidden":`true`,...kP,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},jP=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Markdown`}),r=(0,Z.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,Z.jsxs)(AP,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},MP=e=>{let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Textbox`}),r=(0,Z.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,Z.jsxs)(AP,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},NP=(0,Q.lazy)(()=>r(()=>import(`./SettingsPane-CyMjmU3t.js`).then(e=>({default:e.SettingsPane})),__vite__mapDeps([34,1,27,2,28,29,14,13,3,6,7,30,4,8,35,15]),import.meta.url));function PP(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(Kt,{name:`editor-area`,children:(0,Z.jsx)(cM,{children:(0,Z.jsx)(FP,{...e})})}),t[0]=e,t[1]=n),n}function FP(e){let t=(0,$.c)(127),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,o=Yf(),{activeDocName:s,activeProvider:c,activeTarget:l,recycleDocument:u,docPanelMode:d,docPanelExpandSignal:f}=Qn(),{openDocumentTransition:p}=ar(),{requestAddProperty:m}=uM(),h=PM(c,s),g=FM(c),_=g===`connected`||g===`synced`,v=(0,Q.useDeferredValue)(s),y=l?.kind===`missing`,b=!!s&&l?.kind!==`folder`,x=y?`Start writing to create this page…`:void 0,S=Jy(),[C,w]=(0,Q.useState)(!1),{layout:T,autoCollapse:E}=vM(),D=T===`sheet`,[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(!1),j,M;t[0]!==E||t[1]!==T||t[2]!==S?(j=()=>{T===`panel`&&(E?(A.current=!1,S.current?.collapse()):A.current||S.current?.expand())},M=[E,T,S],t[0]=E,t[1]=T,t[2]=S,t[3]=j,t[4]=M):(j=t[3],M=t[4]),(0,Q.useEffect)(j,M);let N,P;t[5]!==D||t[6]!==a||t[7]!==S?(N=()=>{let e=e=>{a(e),D?k(!0):(A.current=!1,S.current?.expand())},t=Fd();return t&&e(t),Ld(t=>{Fd(),e(t)})},P=[D,a,S],t[5]=D,t[6]=a,t[7]=S,t[8]=N,t[9]=P):(N=t[8],P=t[9]),(0,Q.useEffect)(N,P);let F,I;t[10]!==f||t[11]!==D||t[12]!==S?(F=()=>{f!==0&&(D?k(!0):(A.current=!1,S.current?.expand()))},I=[f,D,S],t[10]=f,t[11]=D,t[12]=S,t[13]=F,t[14]=I):(F=t[13],I=t[14]),(0,Q.useEffect)(F,I);let L=(0,Q.useRef)(null),[R,z]=(0,Q.useState)(null),B,V;if(t[15]===s?(B=t[16],V=t[17]):(B=()=>{if(s&&s!==L.current){let e=L.current;L.current=s,z(e)}},V=[s],t[15]=s,t[16]=B,t[17]=V),(0,Q.useEffect)(B,V),o.scope!==null){let e;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($y,{}),t[18]=e):e=t[18];let n;return t[19]!==o.close||t[20]!==o.scope||t[21]!==o.setScope?(n=(0,Z.jsx)(Q.Suspense,{fallback:e,children:(0,Z.jsx)(NP,{scope:o.scope,onClose:o.close,onScopeChange:o.setScope})}),t[19]=o.close,t[20]=o.scope,t[21]=o.setScope,t[22]=n):n=t[22],n}if(l?.kind===`folder`){let e;return t[23]===l.folderPath?e=t[24]:(e=(0,Z.jsx)(nM,{folderPath:l.folderPath}),t[23]=l.folderPath,t[24]=e),e}if(l?.kind===`asset`){let e;return t[25]!==l.assetPath||t[26]!==l.mediaKind?(e=(0,Z.jsx)(Qy,{assetPath:l.assetPath,mediaKind:l.mediaKind}),t[25]=l.assetPath,t[26]=l.mediaKind,t[27]=e):e=t[27],e}if(!c||!s){if((typeof window<`u`?Ge(window.location.hash):null)!==null){let e;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($y,{}),t[28]=e):e=t[28],e}let e;return t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Xb,{}),t[29]=e):e=t[29],e}let H=n===`source`,U=!_,W=D?!O:C,G;t[30]!==s||t[31]!==m?(G=function(){s&&m(s)},t[30]=s,t[31]=m,t[32]=G):G=t[32];let ee=G,te=H?`source`:`wysiwyg`,ne;t[33]===r?ne=t[34]:(ne=e=>{e&&r(e)},t[33]=r,t[34]=ne);let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Je,{value:`wysiwyg`,"aria-label":`Visual editor`,asChild:!0,children:(0,Z.jsx)(Ci,{children:(0,Z.jsx)(MP,{})})}),(0,Z.jsx)(wi,{side:`bottom`,children:`Visual`})]}),t[35]=re):re=t[35];let ie;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Z.jsx)(jP,{}),t[36]=ie):ie=t[36];let ae;t[37]===U?ae=t[38]:(ae=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Je,{value:`source`,"aria-label":`Markdown source`,disabled:U,className:`rounded-s-none! border-s-0!`,children:ie})})}),t[37]=U,t[38]=ae);let oe=U?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,se;t[39]===oe?se=t[40]:(se=(0,Z.jsx)(wi,{side:`bottom`,children:oe}),t[39]=oe,t[40]=se);let ce;t[41]!==ae||t[42]!==se?(ce=(0,Z.jsxs)(Ei,{children:[ae,se]}),t[41]=ae,t[42]=se,t[43]=ce):ce=t[43];let le;t[44]!==te||t[45]!==ne||t[46]!==ce?(le=(0,Z.jsxs)(be,{type:`single`,value:te,onValueChange:ne,"aria-label":`Editor mode`,variant:`outline`,className:`shrink-0 rounded-lg bg-background/90 p-0.5 shadow-sm backdrop-blur`,children:[re,ce]}),t[44]=te,t[45]=ne,t[46]=ce,t[47]=le):le=t[47];let ue;t[48]!==H||t[49]!==ee?(ue=!H&&(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,"aria-label":`Add properties`,onClick:ee,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(Ci,{children:(0,Z.jsx)($a,{})})}),(0,Z.jsx)(wi,{side:`bottom`,children:`Add properties`})]}),t[48]=H,t[49]=ee,t[50]=ue):ue=t[50];let K;t[51]!==C||t[52]!==D||t[53]!==S?(K=()=>{D?k(IP):C?(A.current=!1,S.current?.expand()):(A.current=!0,S.current?.collapse())},t[51]=C,t[52]=D,t[53]=S,t[54]=K):K=t[54];let q=W?`Show document panel`:`Hide document panel`,de;t[55]===W?de=t[56]:(de=(0,Z.jsx)(Ci,{children:W?(0,Z.jsx)(oo,{}):(0,Z.jsx)(ao,{})}),t[55]=W,t[56]=de);let fe;t[57]!==K||t[58]!==q||t[59]!==de?(fe=(0,Z.jsx)(Y,{variant:`outline`,size:`icon`,onClick:K,"aria-label":q,asChild:!0,children:de}),t[57]=K,t[58]=q,t[59]=de,t[60]=fe):fe=t[60];let pe=W?`Show panel`:`Hide panel`,me;t[61]===pe?me=t[62]:(me=(0,Z.jsx)(wi,{side:`bottom`,children:pe}),t[61]=pe,t[62]=me);let he;t[63]!==fe||t[64]!==me?(he=(0,Z.jsxs)(Ei,{children:[fe,me]}),t[63]=fe,t[64]=me,t[65]=he):he=t[65];let ge;t[66]!==ue||t[67]!==he?(ge=(0,Z.jsxs)(fM,{className:`shrink-0 rounded-lg bg-background/90 p-0.5 shadow-sm backdrop-blur`,children:[ue,he]}),t[66]=ue,t[67]=he,t[68]=ge):ge=t[68];let _e;t[69]!==le||t[70]!==ge?(_e=(0,Z.jsxs)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1`,children:[le,ge]}),t[69]=le,t[70]=ge,t[71]=_e):_e=t[71];let ve=_e,ye=v??s,xe=R??void 0,Se;t[72]===p?Se=t[73]:(Se=e=>{let t=Ie(e);window.location.hash===t?p(e):window.location.hash=t},t[72]=p,t[73]=Se);let Ce;t[74]!==x||t[75]!==H||t[76]!==u||t[77]!==ye||t[78]!==xe||t[79]!==Se?(Ce=(0,Z.jsx)(bP,{activeDocName:ye,isSourceMode:H,editorPlaceholder:x,previousDocName:xe,onNavigateBack:Se,onRecycle:u}),t[74]=x,t[75]=H,t[76]=u,t[77]=ye,t[78]=xe,t[79]=Se,t[80]=Ce):Ce=t[80];let we;t[81]!==s||t[82]!==v?(we=s&&s!==v?(0,Z.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,Z.jsx)($y,{})}):null,t[81]=s,t[82]=v,t[83]=we):we=t[83];let Te;t[84]!==Ce||t[85]!==we?(Te=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[Ce,we]}),t[84]=Ce,t[85]=we,t[86]=Te):Te=t[86];let Ee;t[87]!==Te||t[88]!==ve?(Ee=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[Te,ve]}),t[87]=Te,t[88]=ve,t[89]=Ee):Ee=t[89];let De;t[90]!==b||t[91]!==h?(De=b&&(0,Z.jsx)(OP,{stats:h}),t[90]=b,t[91]=h,t[92]=De):De=t[92];let Oe;t[93]!==Ee||t[94]!==De?(Oe=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[Ee,De]}),t[93]=Ee,t[94]=De,t[95]=Oe):Oe=t[95];let ke=Oe;if(D){let e;t[96]===ke?e=t[97]:(e=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:ke}),t[96]=ke,t[97]=e);let n;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(wg,{className:`sr-only`,children:(0,Z.jsx)(Tg,{children:`Document panel`})}),t[98]=n):n=t[98];let r;t[99]!==s||t[100]!==i||t[101]!==d||t[102]!==H||t[103]!==a?(r=(0,Z.jsxs)(Cg,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,Z.jsx)(tv,{docName:s,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:d})]}),t[99]=s,t[100]=i,t[101]=d,t[102]=H,t[103]=a,t[104]=r):r=t[104];let o;t[105]!==O||t[106]!==r?(o=(0,Z.jsx)(bg,{open:O,onOpenChange:k,children:r}),t[105]=O,t[106]=r,t[107]=o):o=t[107];let c;return t[108]!==e||t[109]!==o?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,o]}),t[108]=e,t[109]=o,t[110]=c):c=t[110],c}let Ae;t[111]===ke?Ae=t[112]:(Ae=(0,Z.jsx)(mM,{minSize:`30%`,defaultSize:`75%`,children:ke}),t[111]=ke,t[112]=Ae);let je;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Z.jsx)(hM,{withHandle:!0}),t[113]=je):je=t[113];let Me;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Me=e=>w(e.asPercentage===0),t[114]=Me):Me=t[114];let Ne;t[115]!==s||t[116]!==i||t[117]!==d||t[118]!==H||t[119]!==a?(Ne=(0,Z.jsx)(tv,{docName:s,isSourceMode:H,activeTab:i,onActiveTabChange:a,mode:d}),t[115]=s,t[116]=i,t[117]=d,t[118]=H,t[119]=a,t[120]=Ne):Ne=t[120];let Pe;t[121]!==S||t[122]!==Ne?(Pe=(0,Z.jsx)(mM,{panelRef:S,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:Me,className:`flex flex-col bg-muted/20`,children:Ne}),t[121]=S,t[122]=Ne,t[123]=Pe):Pe=t[123];let Fe;return t[124]!==Ae||t[125]!==Pe?(Fe=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(pM,{orientation:`horizontal`,children:[Ae,je,Pe]})}),t[124]=Ae,t[125]=Pe,t[126]=Fe):Fe=t[126],Fe}function IP(e){return!e}var LP=1280;function RP(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(zP),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${LP-1}px)`),t=()=>{n(window.innerWidth<LP)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i),t}function zP(){return window.innerWidth<LP}function BP(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function VP(e){let{value:t,unit:n}=BP(e);return n===`rem`?t*16:t}function HP(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var UP=3600*24*7;function WP(e){let t=(0,$.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?GP:m,O=g===void 0?UP:g,k=_===void 0?!1:_,A=(0,Q.useRef)(null),j=(0,Q.useRef)(0),M=(0,Q.useRef)(0),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null),I=(0,Q.useRef)(0),L=(0,Q.useRef)(!1),R=(0,Q.useRef)(0),z=(0,Q.useRef)(0),B=(0,Q.useRef)(null),V=(0,Q.useRef)(r),H=(0,Q.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Q.useEffect)(U,W);let G,ee;t[3]===y?(G=t[4],ee=t[5]):(G=()=>{H.current=y},ee=[y],t[3]=y,t[4]=G,t[5]=ee),(0,Q.useEffect)(G,ee);let te=VP(b),ne;t[6]===x?ne=t[7]:(ne=VP(x),t[6]=x,t[7]=ne);let re=ne,ie;t[8]!==E||t[9]!==k?(ie=function(e){P.current=!0,E&&(j.current=H.current?0:VP(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=ie):ie=t[10];let ae=ie,oe,se;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==re||t[18]!==te||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(oe=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=BP(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=te*w;else if(e<=te){let n=te*(w-1);t=te-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>te*T){a();let t=n(r,M.current,j.current,s),c=Math.max(te,Math.min(re,t)),u=HP(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(te,Math.min(re,u)),f=HP(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},se=[i,a,D,te,re,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=re,t[18]=te,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=oe,t[25]=se):(oe=t[24],se=t[25]),(0,Q.useEffect)(oe,se);let ce;return t[26]===ae?ce=t[27]:(ce={dragRef:A,isDragging:N,handleMouseDown:ae},t[26]=ae,t[27]=ce),ce}function GP(){}var KP=`sidebar_state`,qP=3600*24*7,JP=`18rem`,YP=`3rem`,XP=`\\`,ZP=`app-file-sidebar`,QP=`14rem`,$P=`22rem`,eF=`sidebar_width`,tF=/^\d+(?:\.\d+)?(?:rem|px)$/,nF=Q.createContext(null);function rF(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${eF}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return tF.test(n)?n:e}function iF(){let e=Q.use(nF);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function aF(e){let t=(0,$.c)(53),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?JP:l,f=RP(),p;t[9]===d?p=t[10]:(p=()=>rF(d),t[9]=d,t[10]=p);let[m,h]=Q.useState(p),[g,_]=Q.useState(!1),v=Q.useRef(g),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),[C,w]=Q.useState(u),T=i??C,E;t[11]!==T||t[12]!==o?(E=e=>{let t=typeof e==`function`?e(T):e;o?o(t):w(t),document.cookie=`${KP}=${t}; path=/; max-age=${qP}`},t[11]=T,t[12]=o,t[13]=E):E=t[13];let D=E,O;t[14]===D?O=t[15]:(O=function(){return window.innerWidth<1280?_(sF):D(oF)},t[14]=D,t[15]=O);let k=O,A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=function(){window.innerWidth>=1280||v.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||S(!0))},t[16]=A):A=t[16];let j=A,M;t[17]===g?M=t[18]:(M=()=>{v.current=g},t[17]=g,t[18]=M),Q.useLayoutEffect(M);let N,P;t[19]===k?(N=t[20],P=t[21]):(N=()=>{let e=e=>{e.key===XP&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},P=[k],t[19]=k,t[20]=N,t[21]=P),Q.useEffect(N,P);let F,I;t[22]!==f||t[23]!==g?(F=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},I=[f,g],t[22]=f,t[23]=g,t[24]=F,t[25]=I):(F=t[24],I=t[25]),Q.useEffect(F,I);let L=Q.useRef(f),R,z;t[26]!==f||t[27]!==T?(R=()=>{!L.current&&f&&_(T),L.current=f},z=[f,T],t[26]=f,t[27]=T,t[28]=R,t[29]=z):(R=t[28],z=t[29]),Q.useEffect(R,z);let B=f?g?`expanded`:`collapsed`:T?`expanded`:`collapsed`,V;t[30]!==y||t[31]!==f||t[32]!==T||t[33]!==g||t[34]!==D||t[35]!==x||t[36]!==B||t[37]!==k||t[38]!==m?(V={state:B,open:T,setOpen:D,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:k,width:m,setWidth:h,isDraggingRail:y,setIsDraggingRail:b,showPushPulse:x,setShowPushPulse:S,notifySidebarFileSelected:j},t[30]=y,t[31]=f,t[32]=T,t[33]=g,t[34]=D,t[35]=x,t[36]=B,t[37]=k,t[38]=m,t[39]=V):V=t[39];let H;t[40]!==s||t[41]!==m?(H={"--sidebar-width":m,"--sidebar-width-icon":YP,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=J(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[43]=r,t[44]=W);let G;t[45]!==n||t[46]!==a||t[47]!==U||t[48]!==W?(G=(0,Z.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:U,className:W,...a,children:n}),t[45]=n,t[46]=a,t[47]=U,t[48]=W,t[49]=G):G=t[49];let ee;return t[50]!==V||t[51]!==G?(ee=(0,Z.jsx)(nF.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=ee):ee=t[52],ee}function oF(e){return!e}function sF(e){return!e}function cF(e){let t=(0,$.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=iF();if(u===`none`){let e;t[7]===r?e=t[8]:(e=J(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,Z.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=J(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,Z.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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,Z.jsx)(`nav`,{id:ZP,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,Z.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=J(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,Z.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`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`,b;t[33]!==r||t[34]!==y?(b=J(`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`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,Z.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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,Z.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,Z.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function lF(e){let t=(0,$.c)(16),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,state:o}=iF(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=J(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(hn,{}),d=(0,Z.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,Z.jsxs)(Y,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":ZP,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function uF(e){let t=(0,$.c)(22),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,enableDrag:a,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,{toggleSidebar:s,setWidth:c,state:l,width:u,setIsDraggingRail:d}=iF(),f=l===`collapsed`,p;t[5]!==o||t[6]!==d||t[7]!==c||t[8]!==f||t[9]!==s||t[10]!==u?(p={direction:`right`,enableDrag:o,onResize:c,onToggle:s,currentWidth:u,isCollapsed:f,minResizeWidth:QP,maxResizeWidth:$P,setIsDraggingRail:d,widthCookieName:eF,widthCookieMaxAge:qP},t[5]=o,t[6]=d,t[7]=c,t[8]=f,t[9]=s,t[10]=u,t[11]=p):p=t[11];let{dragRef:m,handleMouseDown:h}=WP(p),g;t[12]!==h||t[13]!==r?(g=e=>{r?.(e),e.defaultPrevented||h(e)},t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=J(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==i||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(`button`,{ref:m,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:g,title:`Toggle Sidebar`,className:_,...i}),t[17]=m,t[18]=i,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function dF(e){let t=(0,$.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=iF(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=J(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,Z.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function fF(e){let t=(0,$.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=J(`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,Z.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 pF(e){let t=(0,$.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=J(`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,Z.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 mF(e){let t=(0,$.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=J(`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,Z.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 hF(e){let t=(0,$.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=J(`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,Z.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 gF(e){let t=(0,$.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=J(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.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 _F=yt(`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 vF(e){let t=(0,$.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?bt:`button`,{isMobile:m,state:h}=iF(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=J(_F({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,Z.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,Z.jsx)(Ci,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,Z.jsx)(wi,{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,Z.jsxs)(Ei,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function yF(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||r.tabCount!==i.tabCount)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 bF(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var xF=1e3,SF=!1;function CF(e,t,n){let r=(0,$.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Q.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:Mr(i)?a=i:(a=void 0,SF||(SF=!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`,tabCount:1})}let t=bF(e),{current:i,crossDoc:s}=a?Dr(a,n,Date.now()):{current:[],crossDoc:[]},c=wF,l=i.map(c),u=s.map(c),d=[...t,...l],f=u;o(e=>yF(e.current,d)&&yF(e.crossDoc,f)?e:{current:d,crossDoc:f})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,xF);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,Q.useEffect)(s,c),a}function wF(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var TF=`sync-status`;function EF(e,t){let n=(0,$.c)(4),r=(0,Q.useRef)(!1),i=(0,Q.useRef)(!1),a=(0,Q.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:TF,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,X.success(`Reconnected`,{id:TF,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Q.useEffect)(o,s)}var DF=4,OF=3,kF={Bird:ha,Cat:xa,Dog:Na,Fish:La,Mouse:uo,Rabbit:lo,Shrimp:_o,Snail:vo,Squirrel:So,Turtle:Eo};Object.freeze([...Object.keys(kF)]);function AF(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(kF,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var jF={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function MF(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=AF(n),o=a.kind===`animal`?kF[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=et(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=ft(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,Z.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,Z.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,Z.jsx)(wi,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(Ei,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function NF(e){let t=jF[e.icon];return e.displayName||t||`Agent`}function PF(e){let t=(0,$.c)(3),[n,r]=(0,Q.useState)(e===`writing`),i=(0,Q.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,Q.useEffect)(a,o),n}function FF(e){let t=(0,$.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=NF(o),t[0]=o,t[1]=c);let l=c,u=PF(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=r&&o.currentDoc?`Open activity panel for ${l}, editing ${o.currentDoc}`:`Open activity panel for ${l}`,x;t[9]===o.color?x=t[10]:(x={backgroundColor:o.color},t[9]=o.color,t[10]=x);let S;t[11]!==s||t[12]!==a?(S=()=>a(s),t[11]=s,t[12]=a,t[13]=S):S=t[13];let C;t[14]===o.icon?C=t[15]:(C=(0,Z.jsx)(Ar,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=C);let w;t[16]!==b||t[17]!==y||t[18]!==h||t[19]!==C||t[20]!==x||t[21]!==S?(w=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":b,className:h,style:x,onClick:S,children:C}),t[16]=b,t[17]=y,t[18]=h,t[19]=C,t[20]=x,t[21]=S,t[22]=w):w=t[22];let T=w,E;t[23]===T?E=t[24]:(E=(0,Z.jsx)(Ci,{asChild:!0,children:T}),t[23]=T,t[24]=E);let D;t[25]===l?D=t[26]:(D=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=D);let O;t[27]!==r||t[28]!==o.currentDoc?(O=r&&o.currentDoc?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,o.currentDoc,`]]`]}):null,t[27]=r,t[28]=o.currentDoc,t[29]=O):O=t[29];let k;t[30]!==D||t[31]!==O?(k=(0,Z.jsxs)(wi,{className:`flex flex-col gap-0.5`,children:[D,O]}),t[30]=D,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==E||t[34]!==k?(A=(0,Z.jsxs)(Ei,{children:[E,k]}),t[33]=E,t[34]=k,t[35]=A):A=t[35],A}function IF(e){let t=(0,$.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,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":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,Z.jsx)(MF,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(FF,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,Z.jsx)(cn,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(Gn,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function LF(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(MF,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(FF,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function RF(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=Qn(),{current:s,crossDoc:c}=CF(t,r,n);EF(FM(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,DF),n;e[6]===s?n=e[7]:(n=s.slice(DF),e[6]=s,e[7]=n);let r=n,u=c.slice(0,OF),d;e[8]===c?d=e[9]:(d=c.slice(OF),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>LF(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,Z.jsx)(IF,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,Z.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[u.map(e=>LF(e,p,!0,m)),f.length>0?(0,Z.jsx)(IF,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]})]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function zF(e,t){return t.trim()}function BF(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function VF(e,t){let n=zF(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function HF(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function UF(e){return typeof e==`object`&&!!e&&typeof e.docName==`string`&&typeof e.rewrites==`number`}function WF(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(HF)&&Array.isArray(t.rewrittenDocs)&&t.rewrittenDocs.every(UF):t.ok===!1?typeof t.error==`string`:!1}function GF(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>dt(e)?e:{...e,docName:n.get(e.docName)??e.docName})}function KF(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>dt(e)||!n.has(e.docName))}function qF(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function JF(e){let t=(0,$.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=J(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`input-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var YF=yt(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function XF(e){let t=(0,$.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=J(YF({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Z.jsx)(`div`,{"data-slot":`input-group-addon`,"data-align":a,className:o,onMouseDown:ZF,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function ZF(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}yt(`flex items-center gap-2 text-sm shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:``,"icon-xs":`size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0`,"icon-sm":`size-8 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function QF(e){let t=(0,$.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=J(`flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $F(e){let t=(0,$.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=J(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Jn,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var eI=[`.md`,`.mdx`];function tI(e,t){let n=e.lastIndexOf(`/`),r=n<0?e:e.slice(n+1),i=`${r}${t}`;return n<0?{baseName:r,extension:t,label:i,prefix:``}:{baseName:r,extension:t,label:i,prefix:`${e.slice(0,n)}/`}}function nI(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function rI(e){let t=Ie(e);window.location.hash!==t&&(window.location.hash=t)}function iI(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function aI(e,t){let n=[t,...eI].filter((e,t,n)=>e&&n.indexOf(e)===t),r=e.toLowerCase(),i=n.find(t=>e.length>t.length&&r.endsWith(t.toLowerCase()));return i?e.slice(0,-i.length):e}function oI(){let e=(0,$.c)(36),{activeDocName:t,closeAndClearForRename:n,closeTab:r,openTabs:i,remapTabsForRename:a}=Qn(),{pageMeta:o}=Ee(),s=(0,Q.useRef)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(null),b=(0,Q.useRef)(t),x;e[0]!==t||e[1]!==i?(x=t?`${t}\u0000${i.join(`\0`)}`:``,e[0]=t,e[1]=i,e[2]=x):x=e[2];let S=x,C,w;e[3]===t?(C=e[4],w=e[5]):(C=()=>{b.current=t},w=[t],e[3]=t,e[4]=C,e[5]=w),(0,Q.useEffect)(C,w);let T,E;e[6]===S?(T=e[7],E=e[8]):(T=()=>{S&&(s.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},E=[S],e[6]=S,e[7]=T,e[8]=E),(0,Q.useEffect)(T,E);let D,O;e[9]===c?(D=e[10],O=e[11]):(D=()=>{c&&(g.current?.focus(),g.current?.select())},O=[c],e[9]=c,e[10]=D,e[11]=O),(0,Q.useEffect)(D,O);let k,A;e[12]!==i||e[13]!==c?(k=()=>{!c||i.includes(c)||(v.current=!0,y.current=null,l(null),d(``),p(null),h(!1))},A=[i,c],e[12]=i,e[13]=c,e[14]=k,e[15]=A):(k=e[14],A=e[15]),(0,Q.useEffect)(k,A);let j,M,N,P,F;if(e[16]!==t||e[17]!==n||e[18]!==r||e[19]!==m||e[20]!==i||e[21]!==o||e[22]!==a||e[23]!==f||e[24]!==u||e[25]!==c){P=Symbol.for(`react.early_return_sentinel`);bb0:{let e=function(e){let t=e.split(`/`);v.current=!1,y.current=null,l(e),d(t[t.length-1]),p(null)},x=function(){v.current=!0,y.current=null,l(null),d(``),p(null),h(!1)},S=async function(){if(v.current){v.current=!1;return}if(_.current)return;let e=c;if(!e){x();return}let t=zF(`file`,aI(u,o.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){x();return}if(t===y.current){g.current?.focus();return}if(!BF(t)){p(`Name can’t be empty, ".", "..", or contain / or \\`),g.current?.focus();return}let s=VF({kind:`file`,path:e,name:i},t);_.current=!0,h(!0),p(null);try{let r=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:s})});if(v.current){h(!1),_.current=!1;return}let i;try{i=await r.json()}catch(n){console.warn(`[EditorTabs] rename response JSON parse failed`,{parseErr:n,status:r.status,docName:e,newDocName:s}),p(`Server error (HTTP ${r.status})`),h(!1),_.current=!1,y.current=t,g.current?.focus();return}if(!WF(i)){console.warn(`[EditorTabs] rename failed`,{status:r.status,docName:e,newDocName:s}),p(`Server error (HTTP ${r.status})`),h(!1),_.current=!1,y.current=t,g.current?.focus();return}if(!r.ok||!i.ok){p(i.ok?`Server error (HTTP ${r.status})`:i.error),h(!1),_.current=!1,y.current=t,g.current?.focus();return}let o=i.renamed,c=b.current,u=qF(c,o);await Promise.all(o.flatMap(e=>[n(e.fromDocName),n(e.toDocName)])),a(o),Ze([`files`,`backlinks`,`graph`]),v.current=!0,l(null),d(``),p(null),h(!1),_.current=!1,y.current=null,u&&u!==c&&rI(u)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:s,normalized:t}),p(`Network error — please try again`),h(!1),_.current=!1,y.current=t,g.current?.focus()}};if(i.length===0){P=null;break bb0}F=s,j=`ml-2 flex h-8 min-w-0 touch-manipulation flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain subtle-scrollbar`,M=iI,N=i.map(n=>{let i=n===t,a=o.get(n)?.docExt??`.md`,{baseName:s,extension:l,label:h,prefix:_}=tI(n,a),v=`${_}${h}`,b=c===n,C=`editor-tab-rename-error-${nI(n)}`;return(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":i?`true`:void 0,className:J(`group flex h-7 min-w-28 max-w-64 shrink-0 items-center overflow-hidden rounded-md border`,i?`border-border bg-background text-foreground`:`border-transparent text-muted-foreground hover:bg-muted/70 hover:text-foreground`,b&&f&&`border-destructive`),onAuxClick:e=>{e.button===1&&(e.preventDefault(),r(n))},children:b?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(JF,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent`,children:[(0,Z.jsx)($F,{ref:g,value:u,disabled:m,"aria-label":`Rename ${h}`,"aria-invalid":f?!0:void 0,"aria-describedby":f?C:void 0,"aria-busy":m||void 0,title:f??n,className:`h-full min-w-0 px-2 py-0 text-xs`,onChange:e=>{d(aI(e.target.value,a)),p(null),y.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),S()):e.key===`Escape`&&(e.preventDefault(),x())},onBlur:S}),(0,Z.jsx)(XF,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(QF,{className:`text-xs text-muted-foreground/60`,children:a})})]}),f?(0,Z.jsx)(`span`,{id:C,role:`alert`,className:`sr-only`,children:f}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":v,title:v,className:`flex h-full min-w-0 flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,onClick:()=>{rI(n)},onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),e(n)},children:[_?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/60`,children:_}):null,(0,Z.jsxs)(`span`,{className:J(`flex min-w-0 items-center font-medium`,_?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:l})]})]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close ${h}`,className:`mr-1 flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground opacity-70 outline-none transition hover:bg-muted hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50 group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),r(n)},children:(0,Z.jsx)(ri,{"aria-hidden":`true`,className:`size-3.5`})})]})},n)})}e[16]=t,e[17]=n,e[18]=r,e[19]=m,e[20]=i,e[21]=o,e[22]=a,e[23]=f,e[24]=u,e[25]=c,e[26]=j,e[27]=M,e[28]=N,e[29]=P,e[30]=F}else j=e[26],M=e[27],N=e[28],P=e[29],F=e[30];if(P!==Symbol.for(`react.early_return_sentinel`))return P;let I;return e[31]!==j||e[32]!==M||e[33]!==N||e[34]!==F?(I=(0,Z.jsx)(`div`,{ref:F,className:j,onWheel:M,children:N}),e[31]=j,e[32]=M,e[33]=N,e[34]=F,e[35]=I):I=e[35],I}function sI(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`LinkedIn`}),r=(0,Z.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,Z.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 cI(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`X (Twitter)`}),r=(0,Z.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,Z.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 lI=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:Lt},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:ei},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:cI},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:sI}],uI=()=>{let e=(0,$.c)(15),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(nn,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,Z.jsx)(wi,{children:`Help & resources`})]}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Setup`}),e[1]=o):o=e[1];let s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Wf)},e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`help-popover-settings`,onClick:s,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)(go,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{children:`Settings…`})]})}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{i(!1),n(!0)},e[4]=l):l=e[4];let u,d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsxs)(`ul`,{className:`mb-3 space-y-0.5`,children:[c,(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:l,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,Z.jsx)($r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{children:`Install for Claude Chat & Cowork…`})]})})]}),d=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[5]=u,e[6]=d):(u=e[5],d=e[6]);let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(cn,{align:`end`,className:`w-64 p-3`,children:[o,u,d,(0,Z.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:lI.map(dI)})})]}),e[7]=f):f=e[7];let p;e[8]===r?p=e[9]:(p=(0,Z.jsxs)(Gn,{open:r,onOpenChange:i,children:[a,f]}),e[8]=r,e[9]=p);let m;e[10]===t?m=e[11]:(m=(0,Z.jsx)(Hr,{open:t,onOpenChange:n}),e[10]=t,e[11]=m);let h;return e[12]!==p||e[13]!==m?(h=(0,Z.jsxs)(Z.Fragment,{children:[p,m]}),e[12]=p,e[13]=m,e[14]=h):h=e[14],h};function dI(e){let{label:t,href:n,icon:r}=e;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>Pr(e,n),onAuxClick:e=>Pr(e,n),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,Z.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var fI={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function pI(e){let t=(0,$.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=We(),s=fI[r],c=s?(o===`dark`?mt[s]:void 0)??we[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=J(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,Z.jsx)(Sr,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,Z.jsx)(xr,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,Z.jsx)(Or,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}var mI=`https://github.com/inkeep/open-knowledge/releases`;function hI(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 gI(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:mI}}};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 _I(e){return at(e)}function vI(e){return`Opened ${e} in your browser.`}var yI=`claude.ai`;async function bI(e,t=bp){(await t(at(e))).ok?X.success(vI(yI)):X.error(`Couldn't open ${yI} in your browser.`)}function xI(e){let t=(0,$.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??bp,c=e.onWebFallbackSuccess??CI,l=e.onWebFallbackError??SI,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=gI({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=hI({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(_I(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=`Open in ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,Z.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,Z.jsxs)(EA,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,Z.jsxs)(EA,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,Z.jsx)(pI,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,Z.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,Z.jsxs)(MA,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,Z.jsx)(kA,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(AA,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,Z.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,Z.jsx)(EA,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,Z.jsxs)(EA,{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,Z.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,Z.jsxs)(NA,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,Z.jsxs)(jA,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function SI(){}function CI(){}function wI(e){let t=(0,$.c)(60),{input:n}=e,{states:r,refresh:i}=Zp(),{dispatch:a}=Bp(),[o,s]=(0,Q.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l;t[0]===i?l=t[1]:(l=e=>{s(e),e&&i()},t[0]=i,t[1]=l);let u=l,d=n===null,f;t[2]===n?f=t[3]:(f=n===null?``:Pe(n.docContext),t[2]=n,t[3]=f);let p=f,m;t[4]!==a||t[5]!==n?(m=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=m):m=t[6];let h=m,g,_,v,y,b,x,S,C,w,T,E,D;if(t[7]!==u||t[8]!==h||t[9]!==n||t[10]!==o||t[11]!==p||t[12]!==r||t[13]!==d){let e;t[26]===r?e=t[27]:(e=e=>r[e.id]?.installed===!0,t[26]=r,t[27]=e);let i=Uf.filter(e);v=r[`claude-cowork`]?.installed===!0;let a;t[28]!==n||t[29]!==p?(a=()=>{n!==null&&bI(p)},t[28]=n,t[29]=p,t[30]=a):a=t[30],y=a,_=CA,D=o,b=u;let s;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(kr,{className:`size-4`}),t[31]=s):s=t[31];let l;t[32]===d?l=t[33]:(l=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:d,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[32]=d,t[33]=l);let f;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsx)(wi,{children:`Edit with AI`}),t[34]=f):f=t[34],t[35]===l?x=t[36]:(x=(0,Z.jsxs)(Ei,{children:[l,f]}),t[35]=l,t[36]=x),g=TA,S=`end`,C=`min-w-[220px]`,w=`open-in-agent-menu`,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(kA,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in…`}),t[37]=T):T=t[37];let m;t[38]!==h||t[39]!==p||t[40]!==r?(m=e=>{let t=r[e.id];return(0,Z.jsx)(xI,{target:e,installState:t,isElectronHost:c,prompt:p,onSelect:()=>h(e)},e.id)},t[38]=h,t[39]=p,t[40]=r,t[41]=m):m=t[41],E=i.map(m),t[7]=u,t[8]=h,t[9]=n,t[10]=o,t[11]=p,t[12]=r,t[13]=d,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=D}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20],C=t[21],w=t[22],T=t[23],E=t[24],D=t[25];let O;t[42]!==v||t[43]!==y||t[44]!==n?(O=v?null:(0,Z.jsxs)(EA,{onSelect:y,disabled:n===null,"data-testid":`open-in-agent-claude-web-fallback`,"aria-label":`Open in claude.ai, opens in browser with prompt pre-filled`,children:[(0,Z.jsx)(ir,{className:`size-4`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:`Open in claude.ai →`}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser`})]}),t[42]=v,t[43]=y,t[44]=n,t[45]=O):O=t[45];let k;t[46]!==g||t[47]!==O||t[48]!==S||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E?(k=(0,Z.jsxs)(g,{align:S,className:C,"data-testid":w,children:[T,E,O]}),t[46]=g,t[47]=O,t[48]=S,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=k):k=t[53];let A;return t[54]!==_||t[55]!==b||t[56]!==x||t[57]!==k||t[58]!==D?(A=(0,Z.jsxs)(_,{open:D,onOpenChange:b,children:[x,k]}),t[54]=_,t[55]=b,t[56]=x,t[57]=k,t[58]=D,t[59]=A):A=t[59],A}function TI(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 EI(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function DI(e){let t=(0,$.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ea,{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,Z.jsx)(fo,{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,Z.jsx)(Ea,{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,Z.jsx)(fo,{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,Z.jsx)(Oe,{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,Z.jsx)(Ta,{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,Z.jsx)(to,{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,Z.jsx)(Oe,{className:`size-3.5 text-amber-500`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ea,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function OI(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``;default:return``}}function kI(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 AI(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 jI(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`}`:kI(e.state):`Sync off`}function MI(e){let t=(0,$.c)(75),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,o=n.syncEnabled,{confirmOpen:s,setConfirmOpen:c,onToggleRequest:l,onConfirm:u}=Lr(Ur()),d;t[0]===n?d=t[1]:(d=(0,Z.jsx)(DI,{status:n}),t[0]=n,t[1]=d);let f;t[2]===n.state?f=t[3]:(f=kI(n.state),t[2]=n.state,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[4]=f,t[5]=p);let m;t[6]!==d||t[7]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h=o?`Disable sync`:`Enable sync`,g;t[9]!==o||t[10]!==l||t[11]!==h?(g=(0,Z.jsx)(Ut,{checked:o,onCheckedChange:l,"aria-label":h}),t[9]=o,t[10]=l,t[11]=h,t[12]=g):g=t[12];let _;t[13]!==m||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,g]}),t[13]=m,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==s||t[17]!==u||t[18]!==c?(v=(0,Z.jsx)(qr,{open:s,onOpenChange:c,onConfirm:u}),t[16]=s,t[17]=u,t[18]=c,t[19]=v):v=t[19];let y;t[20]===n.error?y=t[21]:(y=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[20]=n.error,t[21]=y);let b;t[22]===n.pausedReason?b=t[23]:(b=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:AI(n.pausedReason)}),t[22]=n.pausedReason,t[23]=b);let x;t[24]===n.state?x=t[25]:(x=n.state===`conflict`&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[24]=n.state,t[25]=x);let S;t[26]!==o||t[27]!==n.lastSyncUtc||t[28]!==n.state?(S=o&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,TI(n.lastSyncUtc)]}),t[26]=o,t[27]=n.lastSyncUtc,t[28]=n.state,t[29]=S):S=t[29];let C;t[30]===n.ahead?C=t[31]:(C=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[30]=n.ahead,t[31]=C);let w;t[32]===n.behind?w=t[33]:(w=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[32]=n.behind,t[33]=w);let T;t[34]===n.conflictCount?T=t[35]:(T=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[34]=n.conflictCount,t[35]=T);let E;t[36]===o?E=t[37]:(E=!o&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[36]=o,t[37]=E);let D;t[38]!==S||t[39]!==C||t[40]!==w||t[41]!==T||t[42]!==E?(D=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[38]=S,t[39]=C,t[40]=w,t[41]=T,t[42]=E,t[43]=D):D=t[43];let O;t[44]!==a||t[45]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(Ao,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,Z.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,Z.jsx)(Y,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[44]=a,t[45]=n.identityUnresolved,t[46]=O):O=t[46];let k;t[47]!==o||t[48]!==n.state?(k=o&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:PI,children:`Sync now`}),t[47]=o,t[48]=n.state,t[49]=k):k=t[49];let A;t[50]!==o||t[51]!==r||t[52]!==n.state?(A=o&&n.state===`auth-error`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[50]=o,t[51]=r,t[52]=n.state,t[53]=A):A=t[53];let j;t[54]!==o||t[55]!==n.state?(j=o&&n.state===`offline`&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:NI,children:`Retry`}),t[54]=o,t[55]=n.state,t[56]=j):j=t[56];let M;t[57]!==o||t[58]!==i||t[59]!==n.state?(M=o&&n.state===`conflict`&&i&&(0,Z.jsx)(Y,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[57]=o,t[58]=i,t[59]=n.state,t[60]=M):M=t[60];let N;t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=N):N=t[65];let P;return t[66]!==b||t[67]!==x||t[68]!==D||t[69]!==O||t[70]!==N||t[71]!==_||t[72]!==v||t[73]!==y?(P=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v,y,b,x,D,O,N]}),t[66]=b,t[67]=x,t[68]=D,t[69]=O,t[70]=N,t[71]=_,t[72]=v,t[73]=y,t[74]=P):P=t[74],P}function NI(){EI(`sync`)}function PI(){EI(`sync`)}function FI(e){let t=(0,$.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}=Vr();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(Ta,{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,Z.jsxs)(Ei,{children:[e,(0,Z.jsx)(wi,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote||o.state===`disabled`&&!o.pausedReason)return null;let c;t[5]===o?c=t[6]:(c=OI(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=kI(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,Z.jsx)(DI,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,Z.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,Z.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,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(un,{asChild:!0,children:(0,Z.jsxs)(Y,{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]:(_=jI(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(wi,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(Ei,{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,Z.jsx)(cn,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(MI,{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,Z.jsxs)(Gn,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var II=[{value:`light`,label:`Light`,icon:wo},{value:`dark`,label:`Dark`,icon:no},{value:`system`,label:`System`,icon:Aa}],LI=()=>{let e=(0,$.c)(16),{theme:t}=We(),{merged:n,userBinding:r}=Kr(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||X.error(Ve(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?Aa:i===`dark`?no:wo,c;e[2]===s?c=e[3]:(c=(0,Z.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,Z.jsx)(wA,{asChild:!0,children:(0,Z.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=II.map(RI),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(TA,{align:`end`,children:(0,Z.jsx)(DA,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,Z.jsxs)(CA,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function RI(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(OA,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function zI(e){let t=(0,$.c)(47),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s,activeTarget:c}=Qn(),{state:l}=iF(),u=Qf(),d;t[0]!==s||t[1]!==u?(d=jp({docName:s,workspace:u}),t[0]=s,t[1]=u,t[2]=d):d=t[2];let f=d,p=c?.kind===`folder`,m=c?.kind===`asset`,h=p?`${c.folderPath}/`:``,g=m?c.assetPath:``,_,v;t[3]===g?(_=t[4],v=t[5]):(_=g.lastIndexOf(`/`),v=_===-1?``:g.slice(0,_),t[3]=g,t[4]=_,t[5]=v);let y=v,b;t[6]!==g||t[7]!==_?(b=_===-1?g:g.slice(_+1),t[6]=g,t[7]=_,t[8]=b):b=t[8];let x=b,S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(lF,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[9]=S):S=t[9];let C=l===`expanded`?`Hide Files`:`Show Files`,w;t[10]===C?w=t[11]:(w=(0,Z.jsxs)(Ei,{children:[S,(0,Z.jsx)(wi,{children:C})]}),t[10]=C,t[11]=w);let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[12]=T):T=t[12];let E;t[13]!==s||t[14]!==x||t[15]!==y||t[16]!==h||t[17]!==m||t[18]!==p?(E=p?(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(On,{className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:h})]}):m?(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden text-sm`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center overflow-hidden`,children:[y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`truncate text-muted-foreground/60`,children:y}),(0,Z.jsx)(`span`,{className:`shrink-0 px-2 text-muted-foreground/60`,children:`/`})]}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium text-foreground`,children:x})]})}):s?null:(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:h}),t[13]=s,t[14]=x,t[15]=y,t[16]=h,t[17]=m,t[18]=p,t[19]=E):E=t[19];let D;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(oI,{}),t[20]=D):D=t[20];let O;t[21]!==w||t[22]!==E?(O=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[w,T,E,D]}),t[21]=w,t[22]=E,t[23]=O):O=t[23];let k;t[24]!==s||t[25]!==n||t[26]!==r?(k=s&&(0,Z.jsxs)(Ei,{children:[(0,Z.jsx)(Ci,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(mo,{className:`size-3.5`})})}),(0,Z.jsx)(wi,{children:r?`Saving…`:`Checkpoint version`})]}),t[24]=s,t[25]=n,t[26]=r,t[27]=k):k=t[27];let A;t[28]!==s||t[29]!==f?(A=s&&(0,Z.jsx)(wI,{input:f}),t[28]=s,t[29]=f,t[30]=A):A=t[30];let j;t[31]!==o||t[32]!==a||t[33]!==i?(j=(0,Z.jsx)(FI,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[31]=o,t[32]=a,t[33]=i,t[34]=j):j=t[34];let M,N,P,F,I;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(RF,{}),N=(0,Z.jsx)(Ng,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),P=(0,Z.jsx)($l,{}),F=(0,Z.jsx)(uI,{}),I=(0,Z.jsx)(LI,{}),t[35]=M,t[36]=N,t[37]=P,t[38]=F,t[39]=I):(M=t[35],N=t[36],P=t[37],F=t[38],I=t[39]);let L;t[40]!==k||t[41]!==A||t[42]!==j?(L=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 px-3`,children:[k,A,j,M,N,P,F,I]}),t[40]=k,t[41]=A,t[42]=j,t[43]=L):L=t[43];let R;return t[44]!==O||t[45]!==L?(R=(0,Z.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[O,L]}),t[44]=O,t[45]=L,t[46]=R):R=t[46],R}function BI(){let e=(0,$.c)(32),[t,n]=Em(),[r,i]=(0,Q.useState)(t),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(`auth`),[d,f]=(0,Q.useState)(Z_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=Wr(),{projectLocalConfig:v,projectLocalSynced:y}=Kr(),{activeDocName:b}=Qn(),x=!h&&_?.hasRemote===!0&&y===!0&&v!==null&&v.autoSync?.enabled===null,S,C;e[0]===b?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&b&&Zi(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(vm,e),()=>window.removeEventListener(vm,e)},C=[b],e[0]=b,e[1]=S,e[2]=C),(0,Q.useEffect)(S,C);let w;e[3]===n?w=e[4]:(w=function(e){i(e),n(e)},e[3]=n,e[4]=w);let T=w,E;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(E=async function(){m(!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`)}m(!1)},e[5]=E):E=e[5];let D=E,O;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(km,{onOpenResolver:()=>o(!0)}),e[6]=O):O=e[6];let k,A,j;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{u(`auth`),c(!0)},A=()=>{u(`identity`),c(!0)},j=()=>o(!0),e[7]=k,e[8]=A,e[9]=j):(k=e[7],A=e[8],j=e[9]);let M;e[10]===p?M=e[11]:(M=(0,Z.jsx)(zI,{onSaveVersion:D,saving:p,onSignIn:k,onSetIdentity:A,onOpenConflictResolver:j}),e[10]=p,e[11]=M);let N;e[12]!==d||e[13]!==r||e[14]!==T?(N=(0,Z.jsx)(PP,{editorMode:r,onModeChange:T,activeTab:d,onActiveTabChange:f}),e[12]=d,e[13]=r,e[14]=T,e[15]=N):N=e[15];let P;e[16]===a?P=e[17]:(P=(0,Z.jsx)(jg,{open:a,onOpenChange:o}),e[16]=a,e[17]=P);let F=l===`identity`,I;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{c(!1)},e[18]=I):I=e[18];let L;e[19]!==s||e[20]!==F?(L=(0,Z.jsx)(Zl,{open:s,onOpenChange:c,identityPrompt:F,onSuccess:I}),e[19]=s,e[20]=F,e[21]=L):L=e[21];let R;e[22]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>g(!0),e[22]=R):R=e[22];let z;e[23]===x?z=e[24]:(z=(0,Z.jsx)(Dm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(hm,{}),e[25]=B):B=e[25];let V;return e[26]!==P||e[27]!==L||e[28]!==z||e[29]!==M||e[30]!==N?(V=(0,Z.jsxs)(Z.Fragment,{children:[O,M,N,P,L,z,B]}),e[26]=P,e[27]=L,e[28]=z,e[29]=M,e[30]=N,e[31]=V):V=e[31],V}var VI=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
40
40
  <symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
41
41
  <path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06" fill="currentcolor"/>
42
42
  </symbol>