@inkeep/open-knowledge 0.5.0-beta.15 → 0.5.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/open-knowledge/SKILL.md +12 -3
- package/dist/cli.mjs +4 -4
- package/dist/constants-XCszYh-u.mjs +2 -0
- package/dist/{dist-JvyJrwkx.mjs → dist-D5J2z1mI.mjs} +1 -1
- package/dist/{dist-BFaejI07.mjs → dist-V31CRf7D.mjs} +326 -9
- package/dist/index.mjs +1 -1
- package/dist/{init-JeGcMd-V.mjs → init-Db-MJvF_.mjs} +5 -5
- package/dist/init-De5O5Atd.mjs +1 -0
- package/dist/{loader-ZLKIXjJM.mjs → loader-BF1HVIAE.mjs} +2 -2
- package/dist/loader-C1hxiMbK.mjs +1 -0
- package/dist/preview-N6-E_vFx.mjs +1 -0
- package/dist/{preview-BIVzSnXG.mjs → preview-qR7FFUro.mjs} +2 -2
- package/dist/public/assets/{index--ExYK6aw.js → index-BXFJIE7O.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/{repair-mcp-configs-Cpbs7DO6.mjs → repair-mcp-configs-DUU6zN1U.mjs} +2 -2
- package/dist/{src-DK12uoo0.mjs → src-DzWkP5Kf.mjs} +2 -2
- package/dist/start-D6YbKWO-.mjs +1 -0
- package/dist/{start-Ci3v8Z67.mjs → start-DivgyWbO.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BKcZ-SZr.mjs +0 -2
- package/dist/init-BROwb5FR.mjs +0 -1
- package/dist/loader-B01x_zMV.mjs +0 -1
- package/dist/preview-f1ZGdsVb.mjs +0 -1
- package/dist/start-BQOVij1z.mjs +0 -1
|
@@ -31,7 +31,7 @@ This template lives at an ancestor folder — deleting affects every folder unde
|
|
|
31
31
|
This template lives in your user home (~/.ok/templates/) — deleting affects every OK project you open with this user account.`:``}`}),t[37]=c,t[38]=f,t[39]=_,t[40]=k):k=t[40],t[41]!==D||t[42]!==O||t[43]!==k?(w=(0,Z.jsx)(Ja,{open:D,onOpenChange:O,children:k}),t[41]=D,t[42]=O,t[43]=k,t[44]=w):w=t[44],y=Hi,b=n,x=new Set(e.map($D)),t[7]=c,t[8]=f,t[9]=o,t[10]=n,t[11]=_,t[12]=i,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C,t[19]=w}else y=t[14],b=t[15],x=t[16],S=t[17],C=t[18],w=t[19];let T;t[45]!==y||t[46]!==m||t[47]!==i||t[48]!==b||t[49]!==x?(T=(0,Z.jsx)(y,{folderPath:b,existingNames:x,open:m,onOpenChange:h,onCreated:i}),t[45]=y,t[46]=m,t[47]=i,t[48]=b,t[49]=x,t[50]=T):T=t[50];let E=u!==null,D;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{e||d(null)},t[51]=D):D=t[51];let O=u??void 0,k;t[52]!==a||t[53]!==n||t[54]!==O||t[55]!==E?(k=(0,Z.jsx)(Pf,{open:E,onOpenChange:D,kind:`file`,initialDir:n,initialTemplate:O,folderConfig:a}),t[52]=a,t[53]=n,t[54]=O,t[55]=E,t[56]=k):k=t[56];let A;return t[57]!==k||t[58]!==S||t[59]!==C||t[60]!==w||t[61]!==T?(A=(0,Z.jsxs)(Z.Fragment,{children:[S,C,w,T,k]}),t[57]=k,t[58]=S,t[59]=C,t[60]=w,t[61]=T,t[62]=A):A=t[62],A}function $D(e){return e.name}function eO(e){return e.scope!==`user`}function tO(e){let t=(0,$.c)(43),{template:n,onCreate:r,onEdit:i,onDelete:a}=e,o=n.title&&n.title!==n.name,s=n.title??n.name,c;t[0]===s?c=t[1]:(c=(0,Z.jsx)(`span`,{className:`font-medium truncate`,children:s}),t[0]=s,t[1]=c);let l;t[2]!==o||t[3]!==n.name?(l=o?(0,Z.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground shrink-0`,children:n.name}):null,t[2]=o,t[3]=n.name,t[4]=l):l=t[4];let u;t[5]===n.scope?u=t[6]:(u=n.scope===`inherited`?(0,Z.jsx)(Ne,{variant:`gray`,className:`ml-auto shrink-0 text-2xs`,children:`inherited`}):null,t[5]=n.scope,t[6]=u);let d;t[7]===n.scope?d=t[8]:(d=n.scope===`user`?(0,Z.jsx)(Ne,{variant:`primary`,className:`ml-auto shrink-0 text-2xs`,children:`user`}):null,t[7]=n.scope,t[8]=d);let f;t[9]!==c||t[10]!==l||t[11]!==u||t[12]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[c,l,u,d]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.description?p=t[15]:(p=n.description?(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate mt-0.5`,children:n.description}):null,t[14]=n.description,t[15]=p);let m;t[16]!==i||t[17]!==f||t[18]!==p?(m=(0,Z.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,children:[f,p]}),t[16]=i,t[17]=f,t[18]=p,t[19]=m):m=t[19];let h=`Create note from ${s}`,g;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(Cs,{className:`size-3.5`,"aria-hidden":!0}),t[20]=g):g=t[20];let _;t[21]!==r||t[22]!==h?(_=(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,className:`font-mono uppercase shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100`,onClick:r,"aria-label":h,children:[g,`Create`]}),t[21]=r,t[22]=h,t[23]=_):_=t[23];let v=`Actions for ${s}`,y;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(hi,{className:`size-4`,"aria-hidden":!0}),t[24]=y):y=t[24];let b;t[25]===v?b=t[26]:(b=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{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":v,children:y})}),t[25]=v,t[26]=b);let x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(be,{"aria-hidden":!0}),t[27]=x):x=t[27];let S;t[28]===i?S=t[29]:(S=(0,Z.jsxs)(di,{onSelect:i,children:[x,`Edit`]}),t[28]=i,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Z.jsx)(fe,{"aria-hidden":!0}),t[30]=C):C=t[30];let w;t[31]===a?w=t[32]:(w=(0,Z.jsxs)(di,{variant:`destructive`,onSelect:a,children:[C,`Delete`]}),t[31]=a,t[32]=w);let T;t[33]!==S||t[34]!==w?(T=(0,Z.jsxs)(Aa,{align:`end`,children:[S,w]}),t[33]=S,t[34]=w,t[35]=T):T=t[35];let E;t[36]!==b||t[37]!==T?(E=(0,Z.jsxs)(ji,{children:[b,T]}),t[36]=b,t[37]=T,t[38]=E):E=t[38];let D;return t[39]!==_||t[40]!==E||t[41]!==m?(D=(0,Z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-md px-2 py-2 hover:bg-muted/50 text-sm`,children:[m,_,E]}),t[39]=_,t[40]=E,t[41]=m,t[42]=D):D=t[42],D}function nO(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=Y(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=Y(`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 rO(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=Y(`[&_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 iO(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=Y(`[&_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 aO(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=Y(`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 oO(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=Y(`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 sO(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=Y(`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 cO(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 lO(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 uO(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)(P,{className:`ml-1 size-3`}):(0,Z.jsx)(z,{className:`ml-1 size-3`}):(0,Z.jsx)(ts,{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)(X,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function dO(e){let t=(0,$.c)(81),{folderPath:n}=e,{folderPaths:r,loading:i,pages:a,pageTitles:o,pageMeta:s}=wr(),c=ra(n),{state:l,refresh:u}=c,[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`name`),[h,g]=(0,Q.useState)(`asc`);if(i){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)(Gi,{className:`size-5 rounded`}),(0,Z.jsx)(Gi,{className:`h-7 w-48`})]}),(0,Z.jsx)(Gi,{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)(Gi,{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)(Gi,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(mO)]})]})}),t[2]=r):r=t[2],r}let _,v,y,b,x,S,C,w,T,E;if(t[3]!==l||t[4]!==c||t[5]!==n||t[6]!==r||t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==u||t[11]!==h||t[12]!==p){let e=ZD(n,{pages:a,pageTitles:o,pageMeta:s,folderPaths:r}),i=lO(e.children,p,h),d;t[23]===p?d=t[24]:(d=function(e){e===p?g(pO):(m(e),g(`asc`))},t[23]=p,t[24]=d);let D=d;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,S=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let O;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(G,{className:`size-5 text-muted-foreground`}),t[25]=O):O=t[25];let k=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,(0,Z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsxs)(X,{onClick:()=>f(!0),children:[(0,Z.jsx)(Fi,{className:`size-4`}),`New`]}),t[26]=A):A=t[26],t[27]===k?C=t[28]:(C=(0,Z.jsx)(`div`,{className:`flex flex-col gap-6`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,A]})}),t[27]=k,t[28]=C),t[29]!==l||t[30]!==n||t[31]!==u?(w=(0,Z.jsx)(GD,{folderPath:n,state:l,onChange:u}),t[29]=l,t[30]=n,t[31]=u,t[32]=w):w=t[32],t[33]!==l||t[34]!==c||t[35]!==n||t[36]!==u?(T=(0,Z.jsx)(QD,{folderPath:n,state:l,onChange:u,folderConfigHandle:c}),t[33]=l,t[34]=c,t[35]=n,t[36]=u,t[37]=T):T=t[37],x=`rounded-lg border`,v=nO;let j=p===`name`?h===`asc`?`ascending`:`descending`:`none`,M;t[38]!==D||t[39]!==h||t[40]!==p?(M=(0,Z.jsx)(uO,{label:`Name`,sortKey:`name`,activeKey:p,activeDir:h,onSort:D}),t[38]=D,t[39]=h,t[40]=p,t[41]=M):M=t[41];let N;t[42]!==j||t[43]!==M?(N=(0,Z.jsx)(oO,{"aria-sort":j,children:M}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P=p===`modified`?h===`asc`?`ascending`:`descending`:`none`,F;t[45]!==D||t[46]!==h||t[47]!==p?(F=(0,Z.jsx)(uO,{label:`Modified`,sortKey:`modified`,activeKey:p,activeDir:h,onSort:D}),t[45]=D,t[46]=h,t[47]=p,t[48]=F):F=t[48];let I;t[49]!==P||t[50]!==F?(I=(0,Z.jsx)(oO,{className:`w-32`,"aria-sort":P,children:F}),t[49]=P,t[50]=F,t[51]=I):I=t[51],t[52]!==N||t[53]!==I?(b=(0,Z.jsx)(rO,{children:(0,Z.jsxs)(aO,{children:[N,I]})}),t[52]=N,t[53]=I,t[54]=b):b=t[54],_=iO,y=i.length?i.map(fO):(0,Z.jsx)(aO,{children:(0,Z.jsx)(sO,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=l,t[4]=c,t[5]=n,t[6]=r,t[7]=s,t[8]=o,t[9]=a,t[10]=u,t[11]=h,t[12]=p,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E}else _=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22];let D;t[55]!==_||t[56]!==y?(D=(0,Z.jsx)(_,{children:y}),t[55]=_,t[56]=y,t[57]=D):D=t[57];let O;t[58]!==v||t[59]!==b||t[60]!==D?(O=(0,Z.jsxs)(v,{children:[b,D]}),t[58]=v,t[59]=b,t[60]=D,t[61]=O):O=t[61];let k;t[62]!==O||t[63]!==x?(k=(0,Z.jsx)(`div`,{className:x,children:O}),t[62]=O,t[63]=x,t[64]=k):k=t[64];let A;t[65]!==k||t[66]!==S||t[67]!==C||t[68]!==w||t[69]!==T?(A=(0,Z.jsxs)(`div`,{className:S,children:[C,w,T,k]}),t[65]=k,t[66]=S,t[67]=C,t[68]=w,t[69]=T,t[70]=A):A=t[70];let j;t[71]!==A||t[72]!==E?(j=(0,Z.jsx)(`div`,{className:E,children:A}),t[71]=A,t[72]=E,t[73]=j):j=t[73];let M;t[74]!==d||t[75]!==c||t[76]!==n?(M=(0,Z.jsx)(Pf,{open:d,onOpenChange:f,kind:`file`,initialDir:n,folderConfig:c,suggestedName:`index`}),t[74]=d,t[75]=c,t[76]=n,t[77]=M):M=t[77];let N;return t[78]!==j||t[79]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[j,M]}),t[78]=j,t[79]=M,t[80]=N):N=t[80],N}function fO(e){return(0,Z.jsxs)(aO,{children:[(0,Z.jsx)(sO,{children:(0,Z.jsxs)(`a`,{href:er(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)(ks,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,Z.jsx)(sO,{className:`text-muted-foreground`,children:e.kind===`file`?cO(e.modified):`—`})]},e.path)}function pO(e){return e===`asc`?`desc`:`asc`}function mO(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)(Gi,{className:`size-4 rounded`}),(0,Z.jsx)(Gi,{className:`h-4 w-40`}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(Gi,{className:`h-4 w-16`})})]},e)}function hO(e){let t=(0,$.c)(7),{docName:n}=e,[r,i]=(0,Q.useState)(gO),a,o;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>ue(e=>{i(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})}),o=[],t[0]=a,t[1]=o):(a=t[0],o=t[1]),(0,Q.useEffect)(a,o),!r.has(n))return null;let s;t[2]===n?s=t[3]:(s=function(){Ue(n)?.abort(),i(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})},t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`span`,{children:`Still loading`}),t[4]=l):l=t[4];let u;return t[5]===c?u=t[6]:(u=(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-8 z-20 flex justify-center text-xs text-muted-foreground`,children:[l,(0,Z.jsx)(X,{variant:`link`,size:`sm`,className:`h-auto px-2 py-0 text-xs`,onClick:c,children:`Cancel`})]}),t[5]=c,t[6]=u),u}function gO(){return new Set}var _O=(0,Q.createContext)(null);function vO(e){let t=(0,$.c)(7),{children:n}=e,[r,i]=(0,Q.useState)(yO),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)(_O,{value:u,children:n}),t[4]=n,t[5]=u,t[6]=d):d=t[6],d}function yO(){return new Map}function bO(){let e=(0,Q.use)(_O);if(e===null)throw Error(`useProperties must be used within <PropertyProvider />`);return e}function xO(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=Y(`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)(Ly,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SO(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)(By,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function CO(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=Y(`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)(Wy,{"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 wO=960,TO=1024;function EO(){let e=(0,$.c)(5),[t,n]=(0,Q.useState)(OO),[r,i]=(0,Q.useState)(DO),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${wO-1}px)`),t=window.matchMedia(`(max-width: ${TO-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 DO(){return window.innerWidth>=wO&&window.innerWidth<TO}function OO(){return window.innerWidth<wO?`sheet`:`panel`}var kO={words:0,chars:0,tokens:0},AO=/[ -〿-ゟ゠-ヿ㐀-䶿一-鿿豈---ក-]/,jO=/[\p{L}\p{N}]/u,MO=new Set([`text`,`inlineCode`,`code`,`tag`]),NO=new Set([`html`,`definition`,`footnoteDefinition`,`yaml`,`toml`,`image`,`imageReference`,`mdxFlowExpression`,`mdxTextExpression`,`mdxjsEsm`,`rawMdxFallback`,`rawMdxFallbackMdast`]),PO=new Set([`paragraph`,`heading`,`blockquote`,`list`,`listItem`,`thematicBreak`,`table`,`tableRow`,`tableCell`,`mdxJsxFlowElement`,`commentBlock`]);function FO(e,t){if(!e)return;let n=e.type;if(!NO.has(n)){if(MO.has(n)){e.value&&(t.push(e.value),n===`code`&&t.push(`
|
|
32
32
|
`));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)FO(n,t);if(PO.has(n)&&t.length>0){let e=t[t.length-1];e&&!e.endsWith(`
|
|
33
33
|
`)&&t.push(`
|
|
34
|
-
`)}}}}function IO(e){try{let t=f().parseToMdast(e),n=[];return FO(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function LO(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))jO.test(n)&&t++;return t}function RO(e){let t=globalThis.Intl.Segmenter;if(!t)return LO(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function zO(e){let t=AO.test(e)?1.5:4;return Math.ceil(e.length/t)}function BO(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Sn(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=IO(t);return n?{words:AO.test(n)?RO(n):LO(n),chars:n.length,tokens:zO(n)}:{words:0,chars:0,tokens:0}}var VO=300;function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(kO),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(kO);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(BO(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,VO)};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 UO(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`?WO: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 WO(e){return e===`synced`?`synced`:`connected`}var GO=nr;function KO(e,t={}){let n=oe(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var qO=200,JO=`Outside any block`;function YO(e){let t=(0,$.c)(5),{editor:n}=e,r=ce(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?XO(n,r):o.current?JO:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},qO),()=>{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 XO(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=KO(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=KO(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 ZO(){let[e]=(0,Q.useState)(jr);return e}function QO({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Yn(e.display_name),color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function $O(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 ek=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&&Fr(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(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof nn){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 zn){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():$O(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&ar(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()}},tk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new ek({view:t,...e})});Tr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[tk({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 nk=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 Qn(e,{textSerializers:Xn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to);ar({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()}},rk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new nk({view:t,...e})});Tr.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?[rk({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 ik(e,t){return e??new or(t)}var ak=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ok=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),sk=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(`.`)),ck=new Set([`children`,`className`,`style`]),lk=new Set([`tabIndex`]),uk=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),dk={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function fk(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function pk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function mk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||uk.has(e)}function hk(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function gk(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:dk[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function _k(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 vk(e){return lk.has(e)}function yk(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function bk(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 xk(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||sk.has(e)?String(t):`${t}px`}function Sk(e,t){ok.has(t)||e.style.removeProperty(hk(t))}function Ck(e,t,n){ok.has(t)||e.style.setProperty(hk(t),xk(t,n))}function wk(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(ck.has(r)||!mk(r)||fk(r,t[r])||fk(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=pk(r);if(a==null||a===!1){vk(r)&&bk(e,r),e.removeAttribute(o);return}if(a===!0){vk(r)&&yk(e,r,!0),e.setAttribute(o,``);return}if(vk(r)){yk(e,r,a);return}e.setAttribute(o,String(a))})}function Tk(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Ek(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){Sk(e,t);return}Ck(e,t,a)}})}function Dk(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(!fk(t,n))return;let{eventName:i,options:a}=gk(t),o=t=>{n(_k(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Ok(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);ak(()=>{let i=n.current;return Tk(e,i.className,t.className),Ek(e,i.style,t.style),wk(e,i,t),r.current=Dk(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 kk=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},d)=>{let f=(0,Q.useRef)(document.createElement(`div`)),p=(0,Q.useRef)(ik(e,`bubbleMenu`)).current;Ok(f.current,u),typeof d==`function`?d(f.current):d&&(d.current=f.current);let{editor:m}=c(),h=t||m,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:p,shouldShow:a,getReferencedVirtualElement:o,options:s},_=(0,Q.useRef)(g);_.current=g;let[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(h?.isDestroyed)return;if(!h){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=f.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=tk({..._.current,editor:h,element:e});h.registerPlugin(t);let n=_.current.pluginKey;return b.current=!0,y(!0),()=>{y(!1),h.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[h]),(0,Q.useEffect)(()=>{if(!(!v||!h||h.isDestroyed)){if(b.current){b.current=!1;return}h.view.dispatch(h.state.tr.setMeta(p,{type:`updateOptions`,options:_.current}))}},[v,h,n,r,a,s,i,o,p]),(0,is.createPortal)(l,f.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(ik(e,`floatingMenu`)).current;Ok(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=c(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,options:o},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(`FloatingMenu 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=rk({...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,o,i,f]),(0,is.createPortal)(s,d.current)});var Ak=[{name:`paragraph`,label:`Text`,icon:Xs,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:me,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:dt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:He,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:De,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:Ae,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:ut,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:sc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function jk(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Mk},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Se(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)(Ie,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=Ak.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(di,{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)(Aa,{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)(ji,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function Mk(e){let t=Object.fromEntries(Ak.map(t=>[t.name,t.isActive(e.editor)]));return{current:Ak.find(e=>t[e.name])??Ak[0],activeStates:t}}function Nk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`File`&&n!==`WikiEmbedFile`)return null;let r=(t.attrs.props??{}).src;return typeof r!=`string`||r.length===0?null:r}function Pk(e){let t=e.state.selection.node;if(!t)return``;let n=t.attrs.props??{},r=typeof n.alias==`string`?n.alias:``;if(r.length>0)return r;let i=typeof n.name==`string`?n.name:``;return i.length>0?i:V(typeof n.src==`string`?n.src:``)}function Fk(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function Ik(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:Lk},t[0]=n,t[1]=r),Se(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=Nk(n);t&&Fk(t,Pk(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Oi,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(uo,{children:[o,s]})}),t[8]=o,t[9]=c),c}function Lk(e){return Nk(e.editor)}function Rk(e){return Nk(e)!==null}var zk=[{value:`left`,label:`Align left`,icon:Je},{value:`center`,label:`Align center`,icon:_e},{value:`right`,label:`Align right`,icon:it}];function Bk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function Vk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Hk},t[0]=n,t[1]=r);let i=Se(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=zk.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(nn.create(u.doc,s)),Ee(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:r})]},t)}),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 Hk(e){return Bk(e.editor)}function Uk(e){return Bk(e)!==null}var Wk=[{name:`bold`,icon:rs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:Ps,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:gc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:dc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:ms,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ns,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Gk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Kk},t[0]=n,t[1]=r);let i=Se(r),a;t[2]!==i||t[3]!==n?(a=Wk.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(co,{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 Kk(e){return Object.fromEntries(Wk.map(t=>[t.name,t.isActive(e.editor)]))}function qk(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)(ys,{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)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,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)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),ne(d)},children:(0,Z.jsx)(Ma,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(fe,{className:`size-3.5`})})}),(0,Z.jsx)(co,{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)(zs,{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)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(co,{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)(uo,{children:[T,E]}),t[44]=T,t[45]=D),D}function Jk({editor:e}){if(e.isActive(`codeBlock`))return!1;if(Uk(e)||Rk(e))return!0;if(e.state.selection.empty)return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function Yk(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:eA},t[0]=n,t[1]=s);let c=Se(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:$k},t[2]=n,t[3]=l);let u=Se(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return Nr(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=yn(e,t,()=>{ar(e,t,{placement:`top`,strategy:`fixed`,middleware:[_n(8),Qt(),xn({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(Qk)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(Zk)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(Vk,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(Ik,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jk,{editor:n}),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(Gk,{editor:n},i),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(qk,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(kk,{ref:r,editor:n,appendTo:Xk,shouldShow:Jk,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xk(){return document.body}function Zk(e){return e+1}function Qk(){}function $k(e){return Rk(e.editor)}function eA(e){return Uk(e.editor)}var tA=[{name:`addRowBefore`,icon:P,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:z,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fe,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],nA=[{name:`addColumnBefore`,icon:ti,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:oa,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fe,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],rA=[{name:`toggleHeaderRow`,icon:pc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:gs,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:js,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function iA({editor:e}){return e.isActive(`table`)}function aA(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)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(co,{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)(uo,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function oA(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=tA.map(e=>(0,Z.jsx)(aA,{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)(Bi,{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=nA.map(e=>(0,Z.jsx)(aA,{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)(Bi,{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=rA.map(e=>(0,Z.jsx)(aA,{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)(kk,{editor:n,shouldShow:iA,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 sA=new WeakMap;function cA(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=Or(e.color),n.textContent=e.name,t.append(n),t}var lA={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function uA(){let e=new Mr({extensions:Nn});return{mdManager:e,text:S({mdManager:e}),html:re({mdManager:e}),paste:$e({mdManager:e}),drop:D({mdManager:e})}}function dA(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...Xe.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e),GO.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),C.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),Tr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[s]}}),Tr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[k(e,{cursorBuilder:cA})]}})]}function fA(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{sA.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=sA.get(e);if(sA.delete(e),r==null)return;let i=performance.now();Ge(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:(e,t)=>n.drop(e,t)},extensions:ld(dA(e))}}function pA(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=ur(dA({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=T(t.document.getXmlFragment(`default`),a);return{...fA({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var mA=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(lA),c=ZO(),{principal:l,activeDocName:u}=We(),d=n.configuration.name??``,[f]=(0,Q.useState)(uA),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new hr(pA({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=bt(d)??crypto.randomUUID();h=Q.use,g=Oe({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{xe(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(hA,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},hA=e=>{let t=(0,$.c)(71),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:d}=e,f=(0,Q.useRef)(null),p,m;t[0]===d?(p=t[1],m=t[2]):(p=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},m=[d],t[0]=d,t[1]=p,t[2]=m),(0,Q.useLayoutEffect)(p,m);let h;t[3]!==c||t[4]!==n.configuration.name?(h=()=>(ct(c,n.configuration.name??null),()=>{ct(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=h):h=t[5];let g;t[6]!==c||t[7]!==n?(g=[c,n],t[6]=c,t[7]=n,t[8]=g):g=t[8],(0,Q.useEffect)(h,g);let _;t[9]!==c||t[10]!==n.configuration.name?(_=()=>{},t[9]=c,t[10]=n.configuration.name,t[11]=_):_=t[11];let v;t[12]!==c||t[13]!==n?(v=[c,n],t[12]=c,t[13]=n,t[14]=v):v=t[14],(0,Q.useEffect)(_,v);let y;t[15]!==c||t[16]!==n.configuration.name?(y=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=y):y=t[17];let b;t[18]!==c||t[19]!==n?(b=[c,n],t[18]=c,t[19]=n,t[20]=b):b=t[20],(0,Q.useEffect)(y,b);let x,S;t[21]===c?(x=t[22],S=t[23]):(S=()=>{let e=gA,t=null,n=()=>{if(t||c.isDestroyed)return;let n=pt(c);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 pt(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},x=[c],t[21]=c,t[22]=x,t[23]=S),(0,Q.useEffect)(S,x);let C,T;t[24]!==u||t[25]!==n.document||t[26]!==l?(C=()=>{let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,o=null,s=()=>{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},c=e=>{u.current=e;let t=l.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=s(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(u.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};c(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),o&&clearTimeout(o),a=window.setTimeout(()=>{let e={...n,state:`settled`};c(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),o=window.setTimeout(()=>{c({...e,state:`idle`})},300)},dr)};c(lA);let f=()=>{if(Wn(e),!Vn(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(f);let p=()=>{document.visibilityState===`visible`?Vn(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,p),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,p),i&&clearTimeout(i),a&&clearTimeout(a),o&&clearTimeout(o)}},T=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=C,t[28]=T):(C=t[27],T=t[28]),(0,Q.useEffect)(C,T);let E,D;t[29]===n?(E=t[30],D=t[31]):(E=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},D=[n],t[29]=n,t[30]=E,t[31]=D),(0,Q.useEffect)(E,D);let k,A;t[32]===c?(k=t[33],A=t[34]):(k=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=pt(c);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(zo,e),()=>window.removeEventListener(zo,e)},A=[c],t[32]=c,t[33]=k,t[34]=A),(0,Q.useEffect)(k,A);let j;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:QO({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=j):j=t[41];let M;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(M=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=M):M=t[48],(0,Q.useEffect)(j,M);let N,P;t[49]===c?(N=t[50],P=t[51]):(N=(0,Z.jsx)(Yk,{editor:c}),P=(0,Z.jsx)(oA,{editor:c}),t[49]=c,t[50]=N,t[51]=P);let F;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[52]=F):F=t[52];let I;t[53]===c?I=t[54]:(I=(0,Z.jsx)(se,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[53]=c,t[54]=I);let L;t[55]!==d||t[56]!==I?(L=(0,is.createPortal)(I,d),t[55]=d,t[56]=I,t[57]=L):L=t[57];let R;t[58]===c?R=t[59]:(R=(0,Z.jsx)(YO,{editor:c}),t[58]=c,t[59]=R);let z;t[60]===c?z=t[61]:(z=w(c),t[60]=c,t[61]=z);let B;t[62]===z.store?B=t[63]:(B=(0,Z.jsx)(O,{store:z.store}),t[62]=z.store,t[63]=B);let V;return t[64]!==N||t[65]!==P||t[66]!==L||t[67]!==R||t[68]!==B||t[69]!==l?(V=(0,Z.jsxs)(`div`,{ref:l,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,L,R,B]}),t[64]=N,t[65]=P,t[66]=L,t[67]=R,t[68]=B,t[69]=l,t[70]=V):V=t[70],V};function gA(){return q()}function _A(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(lt(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 vA=`__back-nav__`;function yA(e){return e instanceof ge||e instanceof qe||e instanceof de||e instanceof Me||e instanceof rt||e instanceof Qe?e.docName:null}function bA(e){return e instanceof ge?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof qe?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof de?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Me?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof rt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Qe?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function xA(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=bA(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)(jb,{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-2xl font-light tracking-tighter text-balance`,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)(X,{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)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(ze(yA(n)??i),o(a),r(vA))},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 SA(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)(xA,{...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]===vA){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.error(`[DocumentErrorBoundary] rendered fallback for ${n}: ${bA(e).title}`,e)},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)(b,{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 CA={text:``,number:0,boolean:!1,date:``,list:[]};function wA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=vr(t);return{map:n,keys:pn(t),parseError:r}}function TA(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>wA(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,u;t[2]===n?(c=t[3],u=t[4]):(c=()=>{let e=br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},u=[n],t[2]=n,t[3]=c,t[4]=u),(0,Q.useEffect)(c,u);let d=o.map,f=o.keys,p=o.parseError,[m,h]=(0,Q.useState)(!1),g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[5]=g):g=t[5];let[_,v]=(0,Q.useState)(g),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C={},t[6]=C):C=t[6];let[w,T]=(0,Q.useState)(C),E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E={},t[7]=E):E=t[7];let[D,O]=(0,Q.useState)(E),k=n.configuration.name??``,j;t[8]===k?j=t[9]:(j=DA(k),t[8]=k,t[9]=j);let M=ra(j),P;t[10]!==M.state.data||t[11]!==M.state.status?(P=M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[10]=M.state.data,t[11]=M.state.status,t[12]=P):P=t[12];let F=P,I;t[13]!==M.state.data||t[14]!==M.state.status?(I=M.state.status===`ready`?M.state.data.frontmatterSources:{},t[13]=M.state.data,t[14]=M.state.status,t[15]=I):I=t[15];let L=I,z;t[16]===r?z=t[17]:(z=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=lr(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]=z);let B=z,V;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){T(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=V):V=t[18];let H=V,U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};T(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),O(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=U):U=t[19];let W=U,G;t[20]===B?G=t[21]:(G=function(e,t){H(e),W(B({[e]:t}),[e])},t[20]=B,t[21]=G);let K=G,q;t[22]===B?q=t[23]:(q=function(e){H(e),W(B({[e]:null}),[e])},t[22]=B,t[23]=q);let ee=q,te;t[24]===r?te=t[25]:(te=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=lr(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]=te);let ne=te,re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e,t){return`${e} ${t}`},t[26]=re):re=t[26];let ie=re,ae;t[27]!==r||t[28]!==f?(ae=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=f.map((e,t)=>ie(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=f.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]=f,t[29]=ae):ae=t[29];let oe=ae,se;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(se={activationConstraint:{distance:4}},t[30]=se):se=t[30];let ce;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(ce={coordinateGetter:fi},t[31]=ce):ce=t[31];let le=ia(ui(Di,se),ui(mi,ce)),ue;t[32]!==F||t[33]!==K||t[34]!==d?(ue=function(e,t){let n=d[e]??OA(F[e]);if(n===void 0)return;v(n=>({...n,[e]:t}));let r=MD(n,t);(!Object.hasOwn(d,e)||!EA(n,r))&&K(e,r)},t[32]=F,t[33]=K,t[34]=d,t[35]=ue):ue=t[35];let de=ue,fe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(){b({name:``,type:`text`,value:``,error:null}),h(!1)},t[36]=fe):fe=t[36];let pe=fe,{addPropertySignal:me,clearAddProperty:he}=bO(),ge;t[37]!==me||t[38]!==k?(ge=me.get(k)??0,t[37]=me,t[38]=k,t[39]=ge):ge=t[39];let _e=ge,ve,ye;t[40]===_e?(ve=t[41],ye=t[42]):(ve=()=>{_e>0&&(b({name:``,type:`text`,value:``,error:null}),h(!1))},ye=[_e],t[40]=_e,t[41]=ve,t[42]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[43]!==he||t[44]!==k?(be=()=>()=>he(k),xe=[k,he],t[43]=he,t[44]=k,t[45]=be,t[46]=xe):(be=t[45],xe=t[46]),(0,Q.useEffect)(be,xe);let Se;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){b(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):CA[e];return{...t,type:e,value:n,error:null}})},t[47]=Se):Se=t[47];let Ce=Se,we;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){b(t=>t&&{...t,value:e})},t[48]=we):we=t[48];let J=we,Te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Te=function(e){b(t=>t&&{...t,name:e,error:null})},t[49]=Te):Te=t[49];let Ee=Te,De;t[50]!==y||t[51]!==B||t[52]!==d?(De=function(){if(!y)return;let e=y.name.trim();if(!e){b({...y,error:`Name is required`});return}if(e===`frontmatter`){b({...y,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){b({...y,error:`Property "${e}" already exists`});return}let t=B({[e]:y.value});if(t.ok){b(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;b({...y,error:n??r})},t[50]=y,t[51]=B,t[52]=d,t[53]=De):De=t[53];let Oe=De,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){b(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){S({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){S(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(){S(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==d||t[59]!==ne||t[60]!==x?(Le=function(){if(!x)return;let e=x.draft.trim();if(!e){S(null);return}if(e===x.key){S(null);return}if(e===`frontmatter`){S({...x,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){S({...x,error:`Property "${e}" already exists`});return}let t=ne(x.key,e);if(t.ok){v(t=>{if(!Object.hasOwn(t,x.key))return t;let n={...t};return n[e]=n[x.key],delete n[x.key],n}),H(x.key),S(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[x.key]??t.error??`Failed to rename property`;S({...x,error:n})},t[58]=d,t[59]=ne,t[60]=x,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==d||t[63]!==f?(ze=f.length>0?f:Object.keys(d),t[62]=d,t[63]=f,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,qe,Je,Ye,Xe,Ze,Qe,$e;if(t[67]!==y||t[68]!==F||t[69]!==L||t[70]!==m||t[71]!==K||t[72]!==Re||t[73]!==Ve||t[74]!==w||t[75]!==oe||t[76]!==d||t[77]!==_||t[78]!==p||t[79]!==ee||t[80]!==x||t[81]!==Be||t[82]!==D||t[83]!==le||t[84]!==de){$e=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(F).filter(e=>!Object.hasOwn(d,e)).sort();if(Be.length===0&&e.length===0&&!y&&!p){$e=null;break bb0}Ze=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Qe=`property-panel`,Ue=A,Je=!m,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>h(!e),t[97]=Ye):Ye=t[97];let n=!m,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(l,{"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?Xe=t[102]:(Xe=(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(X,{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]=Xe),He=N,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===p?Ge=t[104]:(Ge=p?(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)(Dn,{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:p})]})]}):null,t[103]=p,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ie(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]!==F||t[109]!==L||t[110]!==K||t[111]!==Re||t[112]!==Ve||t[113]!==w||t[114]!==d||t[115]!==_||t[116]!==ee||t[117]!==x||t[118]!==Be||t[119]!==D||t[120]!==de){let e;t[122]!==F||t[123]!==L||t[124]!==K||t[125]!==Re||t[126]!==Ve||t[127]!==w||t[128]!==d||t[129]!==_||t[130]!==ee||t[131]!==x||t[132]!==D||t[133]!==de?(e=(e,t)=>{let n=d[e];if(n===void 0)return null;let r=_[e]??on(n),i=x?.key===e?x:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(F,e)?(0,Z.jsx)(kA,{source:L[e]??``}):void 0;return(0,Z.jsx)(PD,{sortableId:ie(e,t),keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>K(e,t),onChangeType:t=>de(e,t),onRemove:()=>ee(e)},`${e}-${t}`)},t[122]=F,t[123]=L,t[124]=K,t[125]=Re,t[126]=Ve,t[127]=w,t[128]=d,t[129]=_,t[130]=ee,t[131]=x,t[132]=D,t[133]=de,t[134]=e):e=t[134],o=Be.map(e),t[108]=F,t[109]=L,t[110]=K,t[111]=Re,t[112]=Ve,t[113]=w,t[114]=d,t[115]=_,t[116]=ee,t[117]=x,t[118]=Be,t[119]=D,t[120]=de,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(Mi,{items:a,strategy:Pi,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==oe||t[139]!==le||t[140]!==s?(Ke=(0,Z.jsx)(gi,{sensors:le,collisionDetection:aa,onDragEnd:oe,children:s}),t[138]=oe,t[139]=le,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==F||t[143]!==L||t[144]!==K||t[145]!==w||t[146]!==D||t[147]!==de?(c=e=>{let t=F[e],n=OA(t),r=on(n),i=L[e]??``;return(0,Z.jsx)(PD,{keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isInherited:!0,badge:(0,Z.jsx)(VD,{source:i}),onCommit:t=>K(e,t),onChangeType:t=>de(e,t)},`inherited-${e}`)},t[142]=F,t[143]=L,t[144]=K,t[145]=w,t[146]=D,t[147]=de,t[148]=c):c=t[148],qe=e.map(c)}t[67]=y,t[68]=F,t[69]=L,t[70]=m,t[71]=K,t[72]=Re,t[73]=Ve,t[74]=w,t[75]=oe,t[76]=d,t[77]=_,t[78]=p,t[79]=ee,t[80]=x,t[81]=Be,t[82]=D,t[83]=le,t[84]=de,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe,t[94]=Ze,t[95]=Qe,t[96]=$e}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],qe=t[90],Je=t[91],Ye=t[92],Xe=t[93],Ze=t[94],Qe=t[95],$e=t[96];if($e!==Symbol.for(`react.early_return_sentinel`))return $e;let et;t[149]!==y||t[150]!==Oe?(et=y?(0,Z.jsx)(zD,{draft:y,onChangeName:Ee,onChangeType:Ce,onChangeValue:J,onCommit:Oe,onCancel:Ae}):(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:pe,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)(Fi,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=y,t[150]=Oe,t[151]=et):et=t[151];let tt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==qe||t[157]!==et?(tt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,qe,et]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=qe,t[157]=et,t[158]=tt):tt=t[158];let nt;t[159]!==Ue||t[160]!==Je||t[161]!==Ye||t[162]!==Xe||t[163]!==tt?(nt=(0,Z.jsxs)(Ue,{open:Je,onOpenChange:Ye,children:[Xe,tt]}),t[159]=Ue,t[160]=Je,t[161]=Ye,t[162]=Xe,t[163]=tt,t[164]=nt):nt=t[164];let rt;return t[165]!==Ze||t[166]!==Qe||t[167]!==nt?(rt=(0,Z.jsx)(`div`,{className:Ze,"data-testid":Qe,children:nt}),t[165]=Ze,t[166]=Qe,t[167]=nt,t[168]=rt):rt=t[168],rt}function EA(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function DA(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function OA(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 kA(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)(Ne,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var AA=tt(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function jA(e){let t=e.threshold??AA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function MA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var NA=tt(`ACTIVITY_MOUNT_LIMIT`,3);function PA(){return r(()=>import(`./SourceEditor-CSsFAy0n.js`),__vite__mapDeps([43,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,44,24]),import.meta.url)}var FA=(0,Q.lazy)(async()=>({default:(await PA()).SourceEditor}));function IA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!we(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 LA(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 RA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(st,{name:`activity-pool`,children:(0,Z.jsx)(zA,{...e})}),t[0]=e,t[1]=n),n}function zA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=We(),{pages:u,loading:d}=wr(),f=IA(c,n,NA),p=(0,Q.useRef)(``),m=f.map(BA).join(`,`),h=(0,Q.useRef)(c),g,_;t[0]===c?(g=t[1],_=t[2]):(g=()=>{h.current=c},_=[c],t[0]=c,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_),(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)ft(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;he(e,t&&t.length>0?t:crypto.randomUUID())}Ge(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,Te(t)},[m,n]);let v;t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==d||t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==a||t[11]!==l?(v=e=>(0,Z.jsx)(GA,{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[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function BA(e){return e.docName}function VA(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 pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function HA(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)(qy,{}),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)(FA,{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 UA(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)(ec,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Ze,{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)(X,{type:`button`,onClick:WA,children:[(0,Z.jsx)(ec,{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 WA(){return window.location.reload()}function GA(e){let t=(0,$.c)(48),{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=LA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=jA({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&Ge(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{MA({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(Ge(`ok/cold/first-toggle`,{docName:n.docName,mountId:bt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(UA,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(SA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(qy,{}),children:(0,Z.jsx)(_A,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(TA,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(HA,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(mA,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(VA,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function KA(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}var qA={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`},JA=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`,...qA,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},YA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},XA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function ZA(e){let t=(0,$.c)(39),{isSourceMode:n,sourceDisabled:r,onModeChange:i,showAddPropertyButton:a,onAddProperty:o,showPanelOpen:s,onTogglePanel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{}),t[0]=l):l=t[0];let u=n?`source`:`wysiwyg`,d;t[1]===i?d=t[2]:(d=e=>{e&&i(e)},t[1]=i,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(ro,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(XA,{className:`size-4`})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Visual`})]}),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(YA,{className:`size-4`}),t[4]=p):p=t[4];let m;t[5]===r?m=t[6]:(m=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ro,{value:`source`,"aria-label":`Markdown source`,disabled:r,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:p})})}),t[5]=r,t[6]=m);let h=r?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,g;t[7]===h?g=t[8]:(g=(0,Z.jsx)(co,{side:`bottom`,children:h}),t[7]=h,t[8]=g);let _;t[9]!==m||t[10]!==g?(_=(0,Z.jsxs)(uo,{children:[m,g]}),t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==u||t[13]!==d||t[14]!==_?(v=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(ao,{type:`single`,value:u,onValueChange:d,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[f,_]})}),t[12]=u,t[13]=d,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o||t[17]!==a?(y=a&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:o,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(Vs,{})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Add properties`})]}),t[16]=o,t[17]=a,t[18]=y):y=t[18];let b=s?`Show document panel`:`Hide document panel`,x;t[19]===s?x=t[20]:(x=(0,Z.jsx)(so,{children:s?(0,Z.jsx)(Js,{}):(0,Z.jsx)(qs,{})}),t[19]=s,t[20]=x);let S;t[21]!==c||t[22]!==b||t[23]!==x?(S=(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":b,asChild:!0,children:x}),t[21]=c,t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=s?`Show panel`:`Hide panel`,w;t[25]===C?w=t[26]:(w=(0,Z.jsx)(co,{side:`bottom`,children:C}),t[25]=C,t[26]=w);let T;t[27]!==S||t[28]!==w?(T=(0,Z.jsxs)(uo,{children:[S,w]}),t[27]=S,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==y||t[31]!==T?(E=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[y,T]}),t[30]=y,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==v||t[34]!==E?(D=(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center px-2 py-2 bg-background`,children:[l,v,E]}),t[33]=v,t[34]=E,t[35]=D):D=t[35];let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[36]=O):O=t[36];let k;return t[37]===D?k=t[38]:(k=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[D,O]}),t[37]=D,t[38]=k),k}function QA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var $A=(0,Q.lazy)(()=>r(()=>import(`./SettingsDialog-x6fsBA_3.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([45,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,46,16,22,10,23]),import.meta.url));function ej(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(nj,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(tj,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(st,{name:`editor-area`,children:(0,Z.jsxs)(vO,{children:[n,r]})}),t[3]=n,t[4]=i),i}function tj(){let e=(0,$.c)(8),t=Wf(),[n,r]=(0,Q.useState)(!1),i,a;if(e[0]===t.open?(i=e[1],a=e[2]):(i=()=>{t.open&&r(!0)},a=[t.open],e[0]=t.open,e[1]=i,e[2]=a),(0,Q.useEffect)(i,a),!n)return null;let o;e[3]===t?o=e[4]:(o=e=>{e||t.close()},e[3]=t,e[4]=o);let s;return e[5]!==t.open||e[6]!==o?(s=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)($A,{open:t.open,onOpenChange:o})}),e[5]=t.open,e[6]=o,e[7]=s):s=e[7],s}function nj(e){let t=(0,$.c)(95),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=We(),{openDocumentTransition:f}=et(),{requestAddProperty:p}=bO(),m=HO(s,o),h=UO(s),g=h===`connected`||h===`synced`,_=(0,Q.useDeferredValue)(o),v=c?.kind===`missing`,y=!!o&&c?.kind!==`folder`,b=v?`Start writing to create this page`:void 0,x=Hy(),[S,C]=(0,Q.useState)(!1),{layout:w,autoCollapse:T}=EO(),E=w===`sheet`,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(!1),A,j;t[0]!==T||t[1]!==w||t[2]!==x?(A=()=>{w===`panel`&&(T?(k.current=!1,x.current?.collapse()):k.current||x.current?.expand())},j=[T,w,x],t[0]=T,t[1]=w,t[2]=x,t[3]=A,t[4]=j):(A=t[3],j=t[4]),(0,Q.useEffect)(A,j);let M,N;t[5]!==E||t[6]!==a||t[7]!==x?(M=()=>{let e=e=>{a(e),E?O(!0):(k.current=!1,x.current?.expand())},t=yf();return t&&e(t),xf(t=>{yf(),e(t)})},N=[E,a,x],t[5]=E,t[6]=a,t[7]=x,t[8]=M,t[9]=N):(M=t[8],N=t[9]),(0,Q.useEffect)(M,N);let P,F;t[10]!==d||t[11]!==E||t[12]!==x?(P=()=>{d!==0&&(E?O(!0):(k.current=!1,x.current?.expand()))},F=[d,E,x],t[10]=d,t[11]=E,t[12]=x,t[13]=P,t[14]=F):(P=t[13],F=t[14]),(0,Q.useEffect)(P,F);let I=(0,Q.useRef)(null),[L,R]=(0,Q.useState)(null),z,B;if(t[15]===o?(z=t[16],B=t[17]):(z=()=>{if(o&&o!==I.current){let e=I.current;I.current=o,R(e)}},B=[o],t[15]=o,t[16]=z,t[17]=B),(0,Q.useEffect)(z,B),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(dO,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(c?.kind===`asset`){let e;return t[20]!==c.assetPath||t[21]!==c.mediaKind?(e=(0,Z.jsx)(Ky,{assetPath:c.assetPath,mediaKind:c.mediaKind}),t[20]=c.assetPath,t[21]=c.mediaKind,t[22]=e):e=t[22],e}if(!s||!o){if((typeof window<`u`?fr(window.location.hash):null)!==null){let e;return t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(qy,{}),t[23]=e):e=t[23],e}let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(px,{}),t[24]=e):e=t[24],e}let V=n===`source`,H=!g,U=E?!D:S,W;t[25]!==o||t[26]!==p?(W=function(){o&&p(o)},t[25]=o,t[26]=p,t[27]=W):W=t[27];let G=W,K;t[28]!==S||t[29]!==E||t[30]!==x?(K=function(){E?O(rj):S?(k.current=!1,x.current?.expand()):(k.current=!0,x.current?.collapse())},t[28]=S,t[29]=E,t[30]=x,t[31]=K):K=t[31];let q=K,ee=_??o,te=L??void 0,ne;t[32]===f?ne=t[33]:(ne=e=>{let t=er(e);window.location.hash===t?f(e):window.location.hash=t},t[32]=f,t[33]=ne);let re;t[34]!==b||t[35]!==V||t[36]!==l||t[37]!==ee||t[38]!==te||t[39]!==ne?(re=(0,Z.jsx)(RA,{activeDocName:ee,isSourceMode:V,editorPlaceholder:b,previousDocName:te,onNavigateBack:ne,onRecycle:l}),t[34]=b,t[35]=V,t[36]=l,t[37]=ee,t[38]=te,t[39]=ne,t[40]=re):re=t[40];let ie;t[41]!==o||t[42]!==_?(ie=QA({activeDocName:o,deferredActiveDocName:_,mountResolved:o!==null&&je(o),syncResolved:o!==null&&ye(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(qy,{}),o===null?null:(0,Z.jsx)(hO,{docName:o})]}):null,t[41]=o,t[42]=_,t[43]=ie):ie=t[43];let ae;t[44]!==re||t[45]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[re,ie]}),t[44]=re,t[45]=ie,t[46]=ae):ae=t[46];let oe=!V,se;t[47]!==V||t[48]!==r||t[49]!==G||t[50]!==U||t[51]!==H||t[52]!==oe||t[53]!==q?(se=(0,Z.jsx)(ZA,{isSourceMode:V,sourceDisabled:H,onModeChange:r,showAddPropertyButton:oe,onAddProperty:G,showPanelOpen:U,onTogglePanel:q}),t[47]=V,t[48]=r,t[49]=G,t[50]=U,t[51]=H,t[52]=oe,t[53]=q,t[54]=se):se=t[54];let ce;t[55]!==ae||t[56]!==se?(ce=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ae,se]}),t[55]=ae,t[56]=se,t[57]=ce):ce=t[57];let le;t[58]!==y||t[59]!==m?(le=y&&(0,Z.jsx)(KA,{stats:m}),t[58]=y,t[59]=m,t[60]=le):le=t[60];let ue;t[61]!==ce||t[62]!==le?(ue=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ce,le]}),t[61]=ce,t[62]=le,t[63]=ue):ue=t[63];let de=ue;if(E){let e;t[64]===de?e=t[65]:(e=(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:de}),t[64]=de,t[65]=e);let n;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(vg,{className:`sr-only`,children:(0,Z.jsx)(yg,{children:`Document panel`})}),t[66]=n):n=t[66];let r;t[67]!==o||t[68]!==i||t[69]!==u||t[70]!==V||t[71]!==a?(r=(0,Z.jsxs)(_g,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})]}),t[67]=o,t[68]=i,t[69]=u,t[70]=V,t[71]=a,t[72]=r):r=t[72];let s;t[73]!==D||t[74]!==r?(s=(0,Z.jsx)(mg,{open:D,onOpenChange:O,children:r}),t[73]=D,t[74]=r,t[75]=s):s=t[75];let c;return t[76]!==e||t[77]!==s?(c=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,s]}),t[76]=e,t[77]=s,t[78]=c):c=t[78],c}let fe;t[79]===de?fe=t[80]:(fe=(0,Z.jsx)(SO,{minSize:`30%`,defaultSize:`75%`,children:de}),t[79]=de,t[80]=fe);let pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Z.jsx)(CO,{withHandle:!0}),t[81]=pe):pe=t[81];let me;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>C(e.asPercentage===0),t[82]=me):me=t[82];let he;t[83]!==o||t[84]!==i||t[85]!==u||t[86]!==V||t[87]!==a?(he=(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u}),t[83]=o,t[84]=i,t[85]=u,t[86]=V,t[87]=a,t[88]=he):he=t[88];let ge;t[89]!==x||t[90]!==he?(ge=(0,Z.jsx)(SO,{panelRef:x,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:me,className:`flex flex-col bg-muted/20`,children:he}),t[89]=x,t[90]=he,t[91]=ge):ge=t[91];let _e;return t[92]!==fe||t[93]!==ge?(_e=(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,Z.jsxs)(xO,{orientation:`horizontal`,children:[fe,pe,ge]})}),t[92]=fe,t[93]=ge,t[94]=_e):_e=t[94],_e}function rj(e){return!e}var ij=1280;function aj(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(oj),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ij-1}px)`),t=()=>{n(window.innerWidth<ij)};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 oj(){return window.innerWidth<ij}function sj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function cj(e){let{value:t,unit:n}=sj(e);return n===`rem`?t*16:t}function lj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var uj=3600*24*7;function dj(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?fj:m,O=g===void 0?uj: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,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=cj(b),ee;t[6]===x?ee=t[7]:(ee=cj(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:cj(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]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{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}=sj(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<=q*w;else if(e<=q){let n=q*(w-1);t=q-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>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(te,t)),u=lj(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(q,Math.min(te,u)),f=lj(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)}},ae=[i,a,D,q,te,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]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function fj(){}var pj=`sidebar_state`,mj=3600*24*7,hj=`18rem`,gj=`3rem`,_j=`\\`,vj=`app-file-sidebar`,yj=`14.625rem`,bj=`22rem`,xj=`sidebar_width`,Sj=/^\d+(?:\.\d+)?(?:rem|px)$/,Cj=Q.createContext(null);function wj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${xj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Sj.test(n)?n:e}function Tj(){let e=Q.use(Cj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Ej(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?hj:l,f=aj(),p;t[9]===d?p=t[10]:(p=()=>wj(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=`${pj}=${t}; path=/; max-age=${mj}`},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?_(Oj):D(Dj)},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===_j&&(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":gj,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=Y(`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 K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(Cj.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function Dj(e){return!e}function Oj(e){return!e}function kj(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}=Tj();if(u===`none`){let e;t[7]===r?e=t[8]:(e=Y(`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=Y(`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:vj,"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]:(_=Y(`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=Y(`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 Aj(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}=Tj(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=Y(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)(J,{}),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)(X,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":vj,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 jj(e){let t=(0,$.c)(24),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=Tj(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:yj,maxResizeWidth:bj,setIsDraggingRail:p,widthCookieName:xj,widthCookieMaxAge:mj},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=dj(h),v;t[14]!==_||t[15]!==r?(v=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=v):v=t[16];let y;t[17]===n?y=t[18]:(y=Y(`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`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[17]=n,t[18]=y);let b;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y?(b=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:v,title:`Toggle Sidebar`,className:y,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b):b=t[23],b}function Mj(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}=Tj(),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=Y(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm 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 Nj(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=Y(`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 Pj(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=Y(`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 Fj(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=Y(`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 Ij(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=Y(`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 Lj(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=Y(`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 Rj=Lr(`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 zj(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?Rr:`button`,{isMobile:m,state:h}=Tj(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=Y(Rj({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)(so,{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)(co,{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)(uo,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Bj(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 Vj(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 Hj=1e3,Uj=!1;function Wj(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function Gj(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:si(i)?a=i:(a=void 0,Uj||(Uj=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=(r?.getLocalState())?.user?.principalId??null,t=r?.clientID??null,i=[];if(r)for(let[n,a]of r.getStates().entries()){let r=a;if(!r.user||typeof r.user!=`object`)continue;let o=r.user;o.type===`human`&&(Wj({entryPrincipalId:o.principalId,entryClientId:n,localPrincipalId:e,localClientId:t})||i.push({kind:`human`,clientId:n,user:o,mode:r.mode??`wysiwyg`,tabCount:1}))}let s=Vj(i),{current:c,crossDoc:l}=a?ni(a,n,Date.now()):{current:[],crossDoc:[]},u=Kj,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>Bj(e.current,p)&&Bj(e.crossDoc,m)?e:{current:p,crossDoc:m})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,Hj);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 Kj(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var qj=`sync-status`;function Jj(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,Xa.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:qj,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Xa.success(`Reconnected`,{id:qj,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 Yj=4,Xj=3,Zj={Bird:ns,Cat:cs,Dog:xs,Fish:Ts,Mouse:$s,Rabbit:Qs,Shrimp:ic,Snail:ac,Squirrel:lc,Turtle:mc};Object.freeze([...Object.keys(Zj)]);function Qj(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(Zj,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var $j={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function eM(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=Qj(n),o=a.kind===`animal`?Zj[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Rn(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Or(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)(so,{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)(co,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(uo,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tM(e){let t=$j[e.icon];return e.displayName||t||`Agent`}function nM(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 rM(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=tM(o),t[0]=o,t[1]=c);let l=c,u=nM(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=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(ai,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(so,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(co,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(uo,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function iM(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)(ie,{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)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{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)(ae,{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)(E,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function aM(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function oM(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=We(),{current:s,crossDoc:c}=Gj(t,r,n);Jj(UO(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,Yj),n;e[6]===s?n=e[7]:(n=s.slice(Yj),e[6]=s,e[7]=n);let r=n,u=c.slice(0,Xj),d;e[8]===c?d=e[9]:(d=c.slice(Xj),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=>aM(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)(iM,{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)(`div`,{className:`ml-1.5 flex items-center gap-1.5`,"data-presence-section":`crossdoc`,children:[u.map(e=>aM(e,p,!0,m)),f.length>0?(0,Z.jsx)(iM,{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 sM(e,t){return t.trim()}function cM(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function lM(e,t){let n=sM(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function uM(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>Ar(e)?{...e,docName:r.get(e.docName)??e.docName}:Pr(e)||Fn(e)?{...e,path:pM(e.path,n)}:e)}function dM(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>Ar(e)?!r.has(e.docName)&&!mM(e.docName,n):Pr(e)||Fn(e)?!mM(e.path,n):!0)}function fM(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function pM(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function mM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function hM(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)(bl,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function gM(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=Y(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xl,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _M(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=Y(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Sl,{children:(0,Z.jsx)(Cl,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vM(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=Y(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Z.jsx)(wl,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function yM(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=Y(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Tl,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bM(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=Y(`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 xM=Lr(`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 SM(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=Y(xM({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:CM,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function CM(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Lr(`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 wM(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=Y(`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 TM(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=Y(`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)(fo,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var EM=[`.md`,`.mdx`],DM=`group relative -mb-px flex h-10 min-w-28 max-w-64 shrink-0 cursor-pointer items-center overflow-hidden border border-transparent font-medium transition-colors`,OM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,kM=Y(OM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),AM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,jM=`mr-2 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:opacity-100`;function MM(e){return Y(jM,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function NM(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 PM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function FM(e){let t=er(e);window.location.hash!==t&&(window.location.hash=t)}function IM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function LM(e,t){let n=[t,...EM].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 RM(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=Pe(s.filter(e),l),t[4]=s,t[5]=l,t[6]=u,t[7]=h}else h=t[7];let g=h,_;t[10]!==s||t[11]!==l?(_=Pe(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(gM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(vM,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(vM,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(vM,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yM,{}),(0,Z.jsx)(vM,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(_M,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(hM,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function zM(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Zs,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-2 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Fa,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-2`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function BM(){let e=(0,$.c)(68),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,isNewTabActive:d,newTabIds:f,openNewTab:p,openTabs:m,pinTab:h,pinnedTabIds:g,remapTabsForRename:_,unpinTab:v,visibleTabIds:y}=We(),{pageMeta:b}=wr(),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(!1),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(null),F=(0,Q.useRef)(t),I;e[0]!==n||e[1]!==t||e[2]!==i?(I=n??(i?ve(i):t?nt(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=I):I=e[3];let L=I,R;e[4]!==r||e[5]!==L||e[6]!==d||e[7]!==f||e[8]!==m?(R=d?`${r??`__new-tab__`}\u0000${m.join(`\0`)}\u0000${f.join(`\0`)}`:L?`${L}\u0000${m.join(`\0`)}`:``,e[4]=r,e[5]=L,e[6]=d,e[7]=f,e[8]=m,e[9]=R):R=e[9];let z=R,B,V;e[10]===t?(B=e[11],V=e[12]):(B=()=>{F.current=t},V=[t],e[10]=t,e[11]=B,e[12]=V),(0,Q.useEffect)(B,V);let H,U;e[13]===z?(H=e[14],U=e[15]):(H=()=>{z&&(x.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},U=[z],e[13]=z,e[14]=H,e[15]=U),(0,Q.useEffect)(H,U);let W,G;e[16]===S?(W=e[17],G=e[18]):(W=()=>{S&&(A.current?.focus(),A.current?.select())},G=[S],e[16]=S,e[17]=W,e[18]=G),(0,Q.useEffect)(W,G);let K,q;e[19]!==m||e[20]!==S?(K=()=>{!S||m.includes(S.tabId)||(N.current=!0,P.current=null,C(null),T(``),D(null),k(!1))},q=[m,S],e[19]=m,e[20]=S,e[21]=K,e[22]=q):(K=e[21],q=e[22]),(0,Q.useEffect)(K,q);let ee,te,ne,re,ie;if(e[23]!==o||e[24]!==a||e[25]!==r||e[26]!==L||e[27]!==s||e[28]!==c||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==f||e[33]!==b||e[34]!==h||e[35]!==g||e[36]!==_||e[37]!==E||e[38]!==w||e[39]!==S?.docName||e[40]!==S?.tabId||e[41]!==v||e[42]!==y){let t=function(e,t){let n=t.split(`/`);N.current=!1,P.current=null,C({docName:t,tabId:e}),T(n[n.length-1]),D(null)},n=function(){N.current=!0,P.current=null,C(null),T(``),D(null),k(!1)},i=async function(){if(N.current){N.current=!1;return}if(j.current)return;let e=S?.docName;if(!e){n();return}let t=sM(`file`,LM(w,b.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){n();return}if(t===P.current){A.current?.focus();return}if(!cM(t)){D(`Name can’t be empty, ".", "..", or contain / or \\`),A.current?.focus();return}let a=lM({kind:`file`,path:e,name:i},t);j.current=!0,k(!0),D(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:a})});if(N.current){k(!1),j.current=!1;return}let r=await Le(n,`Server error (HTTP ${n.status})`);if(!r.ok){D(r.title),k(!1),j.current=!1,P.current=t,A.current?.focus();return}let i=M(vn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=F.current,c=fM(o,i);await Promise.all(i.flatMap(e=>[s(e.fromDocName),s(e.toDocName)])),_(i),Kn([`files`,`backlinks`,`graph`]),N.current=!0,C(null),T(``),D(null),k(!1),j.current=!1,P.current=null,c&&c!==o&&FM(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:a,normalized:t}),D(`Network error — please try again`),k(!1),j.current=!1,P.current=t,A.current?.focus()}};ee=typeof window<`u`&&window.okDesktop!=null;let d;e[48]===f?d=e[49]:(d=new Set(f),e[48]=f,e[49]=d);let p=d,m;e[50]!==c||e[51]!==u||e[52]!==p?(m=function(e){let t=[],n=[];for(let r of e)p.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[50]=c,e[51]=u,e[52]=p,e[53]=m):m=e[53];let I=m;te=x,e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ee&&`[-webkit-app-region:drag]`),e[54]=ne):ne=e[54],re=IM,ie=y.map(e=>{if(p.has(e)){let t=e===r;return(0,Z.jsx)(RM,{tabId:e,canPin:!1,openTabs:y,closeTab:c,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":t?`true`:void 0,className:Y(DM,t?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:AM,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:MM(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Fa,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=Ye(e),u=e===L,d=g.includes(e);if(s.kind===`folder`){let{baseName:t,label:n,prefix:r}=NM(s.folderPath,`/`),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:r}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,r?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}if(s.kind===`asset`){let{baseName:t,label:n,prefix:r}=NM(s.assetPath,``),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:r}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,r?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}let f=s.docName,m=b.get(f)?.docExt??`.md`,{baseName:_,extension:x,label:C,prefix:k}=NM(f,m),j=`${k}${C}`,M=S?.tabId===e,N=`editor-tab-rename-error-${PM(f)}`;return(0,Z.jsx)(RM,{disabled:M,tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,M&&E&&`border-destructive`,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:M?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(bM,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(TM,{ref:A,value:w,disabled:O,"aria-label":`Rename ${C}`,"aria-invalid":E?!0:void 0,"aria-describedby":E?N:void 0,"aria-busy":O||void 0,title:E??f,className:`h-full min-w-0 px-2 py-0 font-medium text-foreground text-xs selection:bg-primary selection:text-primary-foreground`,onChange:e=>{T(LM(e.target.value,m)),D(null),P.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:i}),(0,Z.jsx)(SM,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(wM,{className:`text-muted-foreground/60 text-xs`,children:m})})]}),E?(0,Z.jsx)(`span`,{id:N,role:`alert`,className:`sr-only`,children:E}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":j,className:AM,onClick:()=>{a(e)},onDoubleClick:n=>{n.preventDefault(),n.stopPropagation(),t(e,f)},children:[k&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:k}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,k?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:x})]})]}),(0,Z.jsx)(zM,{accessibleLabel:j,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})})},e)}),e[23]=o,e[24]=a,e[25]=r,e[26]=L,e[27]=s,e[28]=c,e[29]=l,e[30]=u,e[31]=O,e[32]=f,e[33]=b,e[34]=h,e[35]=g,e[36]=_,e[37]=E,e[38]=w,e[39]=S?.docName,e[40]=S?.tabId,e[41]=v,e[42]=y,e[43]=ee,e[44]=te,e[45]=ne,e[46]=re,e[47]=ie}else ee=e[43],te=e[44],ne=e[45],re=e[46],ie=e[47];let ae;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(ae=Y(`first:mb-3 mb-1.5`,ee&&`[-webkit-app-region:no-drag]`),e[55]=ae):ae=e[55];let oe;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Fi,{"aria-hidden":`true`}),e[56]=oe):oe=e[56];let se;e[57]===p?se=e[58]:(se=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:ae,onClick:p,children:oe})}),e[57]=p,e[58]=se);let ce;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(co,{children:`New tab`}),e[59]=ce):ce=e[59];let le;e[60]===se?le=e[61]:(le=(0,Z.jsxs)(uo,{children:[se,ce]}),e[60]=se,e[61]=le);let ue;return e[62]!==te||e[63]!==ne||e[64]!==re||e[65]!==ie||e[66]!==le?(ue=(0,Z.jsxs)(`div`,{ref:te,className:ne,onWheel:re,children:[ie,le]}),e[62]=te,e[63]=ne,e[64]=re,e[65]=ie,e[66]=le,e[67]=ue):ue=e[67],ue}function VM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Discord`}),r=(0,Z.jsx)(`path`,{d:`M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9554 2.4189-2.1568 2.4189Z`}),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 HM(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 UM=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:j},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Du},{label:`Website`,href:`https://openknowledge.ai/`,icon:ja},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:VM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:HM}],WM=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(co,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(ae,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:UM.map(GM)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(E,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function GM(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=>pi(e,n),onAuxClick:e=>pi(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)}function KM(e){let t=(0,$.c)(70),{input:n}=e,{states:r,refresh:i}=Wp(),{dispatch:a}=Np(),{skillInstalled:o,refresh:s}=la(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=typeof window<`u`&&window.okDesktop!=null,p;t[0]===i?p=t[1]:(p=e=>{l(e),e&&i()},t[0]=i,t[1]=p);let m=p,h=n===null,g;t[2]===n?g=t[3]:(g=n!==null&&n.docContext!==null?tr(n.docContext):``,t[2]=n,t[3]=g);let _=g,y;t[4]!==a||t[5]!==n?(y=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=y):y=t[6];let b=y,x,S,C,w,T,E,D,O,k,A,j,M;if(t[7]!==m||t[8]!==b||t[9]!==n||t[10]!==c||t[11]!==_||t[12]!==o||t[13]!==r||t[14]!==h){let e;t[27]===r?e=t[28]:(e=e=>r[e.id]?.installed===!0,t[27]=r,t[28]=e);let i=zf.filter(e);C=r[`claude-cowork`]?.installed===!0;let a;t[29]!==n||t[30]!==_?(a=()=>{n!==null&&tb(_)},t[29]=n,t[30]=_,t[31]=a):a=t[31],w=a,S=ji,M=c,T=m;let s;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ii,{className:`size-4`}),t[32]=s):s=t[32];let l;t[33]===h?l=t[34]:(l=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:h,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[33]=h,t[34]=l);let u;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(co,{children:`Edit with AI`}),t[35]=u):u=t[35],t[36]===l?E=t[37]:(E=(0,Z.jsxs)(uo,{children:[l,u]}),t[36]=l,t[37]=E),x=Aa,D=`end`,O=`min-w-[220px]`,k=`open-in-agent-menu`,t[38]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Li,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in`}),t[38]=A):A=t[38];let p;t[39]!==b||t[40]!==_||t[41]!==o||t[42]!==r?(p=e=>{let t=r[e.id];return(0,Z.jsx)(rb,{target:e,installState:t,isElectronHost:f,prompt:_,onSelect:()=>b(e),onInstallSkillRequest:e.id===`claude-cowork`&&!o?()=>d(!0):void 0},e.id)},t[39]=b,t[40]=_,t[41]=o,t[42]=r,t[43]=p):p=t[43],j=i.map(p),t[7]=m,t[8]=b,t[9]=n,t[10]=c,t[11]=_,t[12]=o,t[13]=r,t[14]=h,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,t[25]=j,t[26]=M}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],j=t[25],M=t[26];let N;t[44]!==C||t[45]!==w||t[46]!==n?(N=C?null:(0,Z.jsxs)(di,{onSelect:w,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)(v,{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[44]=C,t[45]=w,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==x||t[49]!==N||t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==j?(P=(0,Z.jsxs)(x,{align:D,className:O,"data-testid":k,children:[A,j,N]}),t[48]=x,t[49]=N,t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j,t[55]=P):P=t[55];let F;t[56]!==S||t[57]!==T||t[58]!==E||t[59]!==P||t[60]!==M?(F=(0,Z.jsxs)(S,{open:M,onOpenChange:T,children:[E,P]}),t[56]=S,t[57]=T,t[58]=E,t[59]=P,t[60]=M,t[61]=F):F=t[61];let I;t[62]===s?I=t[63]:(I=e=>{d(e),e||s()},t[62]=s,t[63]=I);let L;t[64]!==u||t[65]!==I?(L=(0,Z.jsx)(ta,{open:u,onOpenChange:I}),t[64]=u,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(Z.Fragment,{children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69],R}var qM=()=>{let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onClick:JM,children:[(0,Z.jsx)(rc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(co,{children:`Settings`})]}),e[0]=t):t=e[0],t};function JM(){window.location.hash!==`#settings`&&(window.location.hash=Bf)}function YM(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 XM(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function ZM(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)(ps,{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)(ec,{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)(ps,{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)(ec,{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)(Dn,{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)(fs,{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)(Us,{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)(Dn,{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)(ps,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QM(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 $M(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 eN(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 tN(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`}`:$M(e.state):`Sync off`}function nN(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:s}=ba(),c=o?.autoSync?.enabled??!1,{confirmOpen:l,setConfirmOpen:u,onToggleRequest:d,onConfirm:f}=zi(Vi()),p;t[0]===n?p=t[1]:(p=(0,Z.jsx)(ZM,{status:n}),t[0]=n,t[1]=p);let m;t[2]===n.state?m=t[3]:(m=$M(n.state),t[2]=n.state,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:m}),t[4]=m,t[5]=h);let g;t[6]!==p||t[7]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8];let _=!s,v=c?`Disable sync`:`Enable sync`,y;t[9]!==c||t[10]!==d||t[11]!==_||t[12]!==v?(y=(0,Z.jsx)(Fe,{checked:c,disabled:_,onCheckedChange:d,"aria-label":v}),t[9]=c,t[10]=d,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==g||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==l||t[18]!==f||t[19]!==u?(x=(0,Z.jsx)(pa,{open:l,onOpenChange:u,onConfirm:f}),t[17]=l,t[18]=f,t[19]=u,t[20]=x):x=t[20];let S;t[21]===n.error?S=t[22]:(S=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=S);let C;t[23]===n.pausedReason?C=t[24]:(C=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eN(n.pausedReason)}),t[23]=n.pausedReason,t[24]=C);let w;t[25]===n.state?w=t[26]:(w=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[25]=n.state,t[26]=w);let T;t[27]!==c||t[28]!==n.lastSyncUtc||t[29]!==n.state?(T=c&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,YM(n.lastSyncUtc)]}),t[27]=c,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=T):T=t[30];let E;t[31]===n.ahead?E=t[32]:(E=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=E);let D;t[33]===n.behind?D=t[34]:(D=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=D);let O;t[35]===n.conflictCount?O=t[36]:(O=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=O);let k;t[37]===c?k=t[38]:(k=!c&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=c,t[38]=k);let A;t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O||t[43]!==k?(A=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[T,E,D,O,k]}),t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k,t[44]=A):A=t[44];let j;t[45]!==a||t[46]!==n.identityUnresolved?(j=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(vc,{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)(X,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=j):j=t[47];let M;t[48]!==c||t[49]!==n.state?(M=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:iN,children:`Sync now`}),t[48]=c,t[49]=n.state,t[50]=M):M=t[50];let N;t[51]!==c||t[52]!==r||t[53]!==n.state?(N=c&&n.state===`auth-error`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=c,t[52]=r,t[53]=n.state,t[54]=N):N=t[54];let P;t[55]!==c||t[56]!==n.state?(P=c&&n.state===`offline`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:rN,children:`Retry`}),t[55]=c,t[56]=n.state,t[57]=P):P=t[57];let F;t[58]!==c||t[59]!==i||t[60]!==n.state?(F=c&&n.state===`conflict`&&i&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=c,t[59]=i,t[60]=n.state,t[61]=F):F=t[61];let I;t[62]!==M||t[63]!==N||t[64]!==P||t[65]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[M,N,P,F]}),t[62]=M,t[63]=N,t[64]=P,t[65]=F,t[66]=I):I=t[66];let L;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==A||t[71]!==j||t[72]!==I||t[73]!==b||t[74]!==x?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[b,x,S,C,w,A,j,I]}),t[67]=S,t[68]=C,t[69]=w,t[70]=A,t[71]=j,t[72]=I,t[73]=b,t[74]=x,t[75]=L):L=t[75],L}function rN(){XM(`sync`)}function iN(){XM(`sync`)}function aN(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}=_a();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(fs,{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)(uo,{children:[e,(0,Z.jsx)(co,{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=QM(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$M(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)(ZM,{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)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tN(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(co,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(uo,{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)(ae,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(nN,{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)(E,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oN=[{value:`light`,label:`Light`,icon:fc},{value:`dark`,label:`Dark`,icon:Ws},{value:`system`,label:`System`,icon:vs}],sN=()=>{let e=(0,$.c)(16),{theme:t}=yr(),{merged:n,userBinding:r}=ba(),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||Xa.error(wn(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?vs:i===`dark`?Ws:fc,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)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{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=oN.map(cN),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(Aa,{align:`end`,children:(0,Z.jsx)(bi,{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)(ji,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function cN(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(Ii,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function lN(e){let t=(0,$.c)(38),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s}=We(),{state:c}=Tj(),l=qf(),u;t[0]!==s||t[1]!==l?(u=Sp({docName:s,workspace:l}),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d=u,f=typeof window<`u`&&window.okDesktop!=null,p=f&&c===`collapsed`&&`pl-[78px]`,m;t[3]===p?m=t[4]:(m=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,f&&`[-webkit-app-region:drag]`,p,f&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[3]=p,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Aj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,f&&`[-webkit-app-region:no-drag]`)})}),t[5]=h):h=t[5];let g=c===`expanded`?`Hide Files`:`Show Files`,_;t[6]===g?_=t[7]:(_=(0,Z.jsxs)(uo,{children:[h,(0,Z.jsx)(co,{children:g})]}),t[6]=g,t[7]=_);let v,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),y=(0,Z.jsx)(BM,{}),t[8]=v,t[9]=y):(v=t[8],y=t[9]);let b;t[10]===_?b=t[11]:(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[_,v,y]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,f&&`[&>*]:[-webkit-app-region:no-drag]`),t[12]=x):x=t[12];let S;t[13]!==s||t[14]!==n||t[15]!==r?(S=s&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(nc,{className:`size-3.5`})})}),(0,Z.jsx)(co,{children:r?`Saving`:`Checkpoint version`})]}),t[13]=s,t[14]=n,t[15]=r,t[16]=S):S=t[16];let C;t[17]!==s||t[18]!==d?(C=s&&(0,Z.jsx)(KM,{input:d}),t[17]=s,t[18]=d,t[19]=C):C=t[19];let w;t[20]!==o||t[21]!==a||t[22]!==i?(w=(0,Z.jsx)(aN,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[20]=o,t[21]=a,t[22]=i,t[23]=w):w=t[23];let T,E,D,O,k,A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(oM,{}),E=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),D=(0,Z.jsx)(cu,{}),O=(0,Z.jsx)(qM,{}),k=(0,Z.jsx)(WM,{}),A=(0,Z.jsx)(sN,{}),t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A):(T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29]);let j;t[30]!==S||t[31]!==C||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:x,children:[S,C,w,T,E,D,O,k,A]}),t[30]=S,t[31]=C,t[32]=w,t[33]=j):j=t[33];let M;return t[34]!==j||t[35]!==m||t[36]!==b?(M=(0,Z.jsxs)(`header`,{className:m,children:[b,j]}),t[34]=j,t[35]=m,t[36]=b,t[37]=M):M=t[37],M}function uN(){let e=(0,$.c)(32),[t,n]=bm(),[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)(G_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=da(),{projectLocalConfig:v,projectLocalSynced:y}=ba(),{activeDocName:b}=We(),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&&Lo(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(fm,e),()=>window.removeEventListener(fm,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?Xa.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Xa.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Xa.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)(Cm,{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)(lN,{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)(ej,{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)(Tg,{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)(ou,{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)(xm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(lm,{}),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 dN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
34
|
+
`)}}}}function IO(e){try{let t=f().parseToMdast(e),n=[];return FO(t,n),n.join(``).trim()}catch(t){return console.warn(`[document-stats] mdast parse failed, falling back to raw text`,t),e.trim()}}function LO(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))jO.test(n)&&t++;return t}function RO(e){let t=globalThis.Intl.Segmenter;if(!t)return LO(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function zO(e){let t=AO.test(e)?1.5:4;return Math.ceil(e.length/t)}function BO(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=Sn(e);if(!t.trim())return{words:0,chars:0,tokens:0};let n=IO(t);return n?{words:AO.test(n)?RO(n):LO(n),chars:n.length,tokens:zO(n)}:{words:0,chars:0,tokens:0}}var VO=300;function HO(e,t){let n=(0,$.c)(4),[r,i]=(0,Q.useState)(kO),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(kO);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(BO(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,VO)};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 UO(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`?WO: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 WO(e){return e===`synced`?`synced`:`connected`}var GO=nr;function KO(e,t={}){let n=oe(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var qO=200,JO=`Outside any block`;function YO(e){let t=(0,$.c)(5),{editor:n}=e,r=ce(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?XO(n,r):o.current?JO:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},qO),()=>{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 XO(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=KO(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=KO(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 ZO(){let[e]=(0,Q.useState)(jr);return e}function QO({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Yn(e.display_name),color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:Sr(e.id,In),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function $O(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 ek=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&&Fr(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(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof nn){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 zn){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():$O(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&ar(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()}},tk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new ek({view:t,...e})});Tr.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[tk({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 nk=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 Qn(e,{textSerializers:Xn(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Qt(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(xn(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(_n(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(rn(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(an(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(tn(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(rr(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(hn(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=Nr(this.view,e.from,e.to);ar({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()}},rk=e=>new bn({key:typeof e.pluginKey==`string`?new or(e.pluginKey):e.pluginKey,view:t=>new nk({view:t,...e})});Tr.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?[rk({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 ik(e,t){return e??new or(t)}var ak=typeof window<`u`?Q.useLayoutEffect:Q.useEffect,ok=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),sk=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(`.`)),ck=new Set([`children`,`className`,`style`]),lk=new Set([`tabIndex`]),uk=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),dk={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function fk(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function pk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function mk(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||uk.has(e)}function hk(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function gk(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:dk[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function _k(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 vk(e){return lk.has(e)}function yk(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function bk(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 xk(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||sk.has(e)?String(t):`${t}px`}function Sk(e,t){ok.has(t)||e.style.removeProperty(hk(t))}function Ck(e,t,n){ok.has(t)||e.style.setProperty(hk(t),xk(t,n))}function wk(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(ck.has(r)||!mk(r)||fk(r,t[r])||fk(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=pk(r);if(a==null||a===!1){vk(r)&&bk(e,r),e.removeAttribute(o);return}if(a===!0){vk(r)&&yk(e,r,!0),e.setAttribute(o,``);return}if(vk(r)){yk(e,r,a);return}e.setAttribute(o,String(a))})}function Tk(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function Ek(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){Sk(e,t);return}Ck(e,t,a)}})}function Dk(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(!fk(t,n))return;let{eventName:i,options:a}=gk(t),o=t=>{n(_k(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function Ok(e,t){let n=(0,Q.useRef)({}),r=(0,Q.useRef)([]);ak(()=>{let i=n.current;return Tk(e,i.className,t.className),Ek(e,i.style,t.style),wk(e,i,t),r.current=Dk(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 kk=Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:l,...u},d)=>{let f=(0,Q.useRef)(document.createElement(`div`)),p=(0,Q.useRef)(ik(e,`bubbleMenu`)).current;Ok(f.current,u),typeof d==`function`?d(f.current):d&&(d.current=f.current);let{editor:m}=c(),h=t||m,g={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:p,shouldShow:a,getReferencedVirtualElement:o,options:s},_=(0,Q.useRef)(g);_.current=g;let[v,y]=(0,Q.useState)(!1),b=(0,Q.useRef)(!0);return(0,Q.useEffect)(()=>{if(h?.isDestroyed)return;if(!h){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=f.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=tk({..._.current,editor:h,element:e});h.registerPlugin(t);let n=_.current.pluginKey;return b.current=!0,y(!0),()=>{y(!1),h.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[h]),(0,Q.useEffect)(()=>{if(!(!v||!h||h.isDestroyed)){if(b.current){b.current=!1;return}h.view.dispatch(h.state.tr.setMeta(p,{type:`updateOptions`,options:_.current}))}},[v,h,n,r,a,s,i,o,p]),(0,is.createPortal)(l,f.current)});Q.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...l},u)=>{let d=(0,Q.useRef)(document.createElement(`div`)),f=(0,Q.useRef)(ik(e,`floatingMenu`)).current;Ok(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=c(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,options:o},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(`FloatingMenu 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=rk({...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,o,i,f]),(0,is.createPortal)(s,d.current)});var Ak=[{name:`paragraph`,label:`Text`,icon:Xs,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:me,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:dt,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:He,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:De,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:Ae,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:ut,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:sc,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function jk(e){let t=(0,$.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Mk},t[0]=n,t[1]=r);let{current:i,activeStates:a}=Se(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)(Ie,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=Ak.map(e=>{let t=e.icon,r=a[e.name];return(0,Z.jsxs)(di,{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)(Aa,{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)(ji,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function Mk(e){let t=Object.fromEntries(Ak.map(t=>[t.name,t.isActive(e.editor)]));return{current:Ak.find(e=>t[e.name])??Ak[0],activeStates:t}}function Nk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`File`&&n!==`WikiEmbedFile`)return null;let r=(t.attrs.props??{}).src;return typeof r!=`string`||r.length===0?null:r}function Pk(e){let t=e.state.selection.node;if(!t)return``;let n=t.attrs.props??{},r=typeof n.alias==`string`?n.alias:``;if(r.length>0)return r;let i=typeof n.name==`string`?n.name:``;return i.length>0?i:V(typeof n.src==`string`?n.src:``)}function Fk(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener noreferrer`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function Ik(e){let t=(0,$.c)(10),{editor:n}=e,r;if(t[0]===n?r=t[1]:(r={editor:n,selector:Lk},t[0]=n,t[1]=r),Se(r)===null)return null;let i;t[2]===n?i=t[3]:(i=e=>{e.preventDefault();let t=Nk(n);t&&Fk(t,Pk(n))},t[2]=n,t[3]=i);let a;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(Oi,{className:`size-3.5`}),t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Download file`,className:`text-accent-foreground`,onMouseDown:i,children:a})}),t[5]=i,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Download file`}),t[7]=s):s=t[7];let c;return t[8]===o?c=t[9]:(c=(0,Z.jsx)(`div`,{className:`flex items-center gap-0.5`,children:(0,Z.jsxs)(uo,{children:[o,s]})}),t[8]=o,t[9]=c),c}function Lk(e){return Nk(e.editor)}function Rk(e){return Nk(e)!==null}var zk=[{value:`left`,label:`Align left`,icon:Je},{value:`center`,label:`Align center`,icon:_e},{value:`right`,label:`Align right`,icon:it}];function Bk(e){let t=e.state.selection.node;if(!t||t.type.name!==`jsxComponent`)return null;let n=t.attrs.componentName;if(n!==`img`&&n!==`CommonMarkImage`&&n!==`Embed`)return null;let r=(t.attrs.props??{}).align;return r===`left`||r===`right`||r===`center`?r:`center`}function Vk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Hk},t[0]=n,t[1]=r);let i=Se(r);if(i===null)return null;let a;t[2]!==i||t[3]!==n?(a=zk.map(e=>{let{value:t,label:r,icon:a}=e,o=i===t;return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":r,"aria-pressed":o,className:o?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:e=>{e.preventDefault();let r=n.state.selection,i=r.node;if(!i||i.type.name!==`jsxComponent`)return;let a=String(i.attrs.componentName??``);if(a!==`img`&&a!==`CommonMarkImage`&&a!==`Embed`||i.attrs.kind!==`element`)return;let o=a===`CommonMarkImage`,s=r.from,c={...i.attrs.props??{},align:t},l=o?{...i.attrs,componentName:`img`,props:c,sourceDirty:!0}:{...i.attrs,props:c,sourceDirty:!0},u=n.state.tr.setNodeMarkup(s,null,l);u.setSelection(nn.create(u.doc,s)),Ee(n.view.nodeDOM(s),()=>{n.view.dispatch(u)})},children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:r})]},t)}),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 Hk(e){return Bk(e.editor)}function Uk(e){return Bk(e)!==null}var Wk=[{name:`bold`,icon:rs,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:Ps,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:gc,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:dc,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:ms,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:Ns,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Gk(e){let t=(0,$.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Kk},t[0]=n,t[1]=r);let i=Se(r),a;t[2]!==i||t[3]!==n?(a=Wk.map(e=>{let t=e.icon,r=i[e.name];return(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,Z.jsx)(t,{className:`size-3.5`})})}),(0,Z.jsxs)(co,{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 Kk(e){return Object.fromEntries(Wk.map(t=>[t.name,t.isActive(e.editor)]))}function qk(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)(ys,{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)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,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)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),ne(d)},children:(0,Z.jsx)(Ma,{className:`size-3.5`})})}),(0,Z.jsx)(co,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,Z.jsx)(fe,{className:`size-3.5`})})}),(0,Z.jsx)(co,{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)(zs,{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)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsxs)(co,{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)(uo,{children:[T,E]}),t[44]=T,t[45]=D),D}function Jk({editor:e}){if(e.isActive(`codeBlock`))return!1;if(Uk(e)||Rk(e))return!0;if(e.state.selection.empty)return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function Yk(e){let t=(0,$.c)(22),{editor:n}=e,r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(0),o=(0,Q.useRef)(null),s;t[0]===n?s=t[1]:(s={editor:n,selector:eA},t[0]=n,t[1]=s);let c=Se(s),l;t[2]===n?l=t[3]:(l={editor:n,selector:$k},t[2]=n,t[3]=l);let u=Se(l),d;t[4]!==n.state||t[5]!==n.view?(d=()=>{try{let{from:e,to:t}=n.state.selection;return Nr(n.view,e,t)}catch{return new DOMRect}},t[4]=n.state,t[5]=n.view,t[6]=d):d=t[6];let f;if(t[7]!==n.view.dom||t[8]!==d){let e={getBoundingClientRect:d,contextElement:n.view.dom};f=()=>{let t=r.current;t&&(o.current?.(),o.current=yn(e,t,()=>{ar(e,t,{placement:`top`,strategy:`fixed`,middleware:[_n(8),Qt(),xn({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(Qk)}))},t[7]=n.view.dom,t[8]=d,t[9]=f}else f=t[9];let p=f,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{o.current?.(),o.current=null,a(Zk)},t[10]=m):m=t[10];let h=m,g;t[11]===p?g=t[12]:(g={onShow:p,onHide:h,strategy:`fixed`},t[11]=p,t[12]=g);let _;t[13]!==n||t[14]!==u||t[15]!==c||t[16]!==i?(_=c?(0,Z.jsx)(Vk,{editor:n},`${i}-img-align`):u?(0,Z.jsx)(Ik,{editor:n},`${i}-file`):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jk,{editor:n}),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(Gk,{editor:n},i),(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),(0,Z.jsx)(qk,{editor:n},`${i}-link`)]}),t[13]=n,t[14]=u,t[15]=c,t[16]=i,t[17]=_):_=t[17];let v;return t[18]!==n||t[19]!==g||t[20]!==_?(v=(0,Z.jsx)(kk,{ref:r,editor:n,appendTo:Xk,shouldShow:Jk,updateDelay:250,options:g,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:_}),t[18]=n,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xk(){return document.body}function Zk(e){return e+1}function Qk(){}function $k(e){return Rk(e.editor)}function eA(e){return Uk(e.editor)}var tA=[{name:`addRowBefore`,icon:P,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:z,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fe,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],nA=[{name:`addColumnBefore`,icon:ti,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:oa,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fe,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],rA=[{name:`toggleHeaderRow`,icon:pc,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:gs,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:js,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function iA({editor:e}){return e.isActive(`table`)}function aA(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)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,Z.jsx)(co,{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)(uo,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function oA(e){let t=(0,$.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=tA.map(e=>(0,Z.jsx)(aA,{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)(Bi,{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=nA.map(e=>(0,Z.jsx)(aA,{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)(Bi,{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=rA.map(e=>(0,Z.jsx)(aA,{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)(kk,{editor:n,shouldShow:iA,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 sA=new WeakMap;function cA(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=Or(e.color),n.textContent=e.name,t.append(n),t}var lA={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null};function uA(){let e=new Mr({extensions:Nn});return{mdManager:e,text:S({mdManager:e}),html:re({mdManager:e}),paste:$e({mdManager:e}),drop:D({mdManager:e})}}function dA(e){let{provider:t,placeholder:n,prebuiltMapping:r}=e;return[...Xe.map(e=>e.name===`link`||e.name===`wikiLink`?e.configure({docName:t.configuration.name??``}):e),GO.configure({placeholder:n??`Type '/' for commands`,showOnlyCurrent:!0}),C.configure({document:t.document,...r?{ySyncOptions:{mapping:r}}:{}}),Tr.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[s]}}),Tr.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=t.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[k(e,{cursorBuilder:cA})]}})]}function fA(e){let{provider:t,clipboard:n,ctorStart:r}=e;return{onBeforeCreate:({editor:e})=>{sA.set(e,r)},onCreate:({editor:e})=>{n.html.setView(e.view);let r=sA.get(e);if(sA.delete(e),r==null)return;let i=performance.now();Ge(`ok/editor/create-tiptap`,{docName:t.configuration.name??`unknown`,ytextLength:t.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-4 pb-4 h-full`},clipboardTextParser:(e,t,r,i)=>{let a=n.mdManager.parse(e);return i.state.schema.nodeFromJSON(a).content},clipboardTextSerializer:(e,t)=>n.text(e,t),clipboardSerializer:n.html.serializer,handlePaste:(e,t)=>n.paste(e,t),handleDrop:(e,t)=>n.drop(e,t)},extensions:ld(dA(e))}}function pA(e){let{provider:t,placeholder:n,clipboard:r,ctorStart:i}=e,a=ur(dA({provider:t,placeholder:n,clipboard:r,ctorStart:i})),{doc:o,mapping:s}=T(t.document.getXmlFragment(`default`),a);return{...fA({provider:t,placeholder:n,clipboard:r,ctorStart:i,prebuiltMapping:s}),content:o.toJSON(),element:null}}var mA=e=>{let t=(0,$.c)(21),{provider:n,placeholder:r,isSourceMode:i,portalTarget:a}=e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(lA),c=ZO(),{principal:l,activeDocName:u}=We(),d=n.configuration.name??``,[f]=(0,Q.useState)(uA),p;t[0]!==f||t[1]!==r||t[2]!==n?(p=()=>()=>({editor:new hr(pA({provider:n,placeholder:r,clipboard:f,ctorStart:performance.now()})),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}),t[0]=f,t[1]=r,t[2]=n,t[3]=p):p=t[3];let[m]=(0,Q.useState)(p),h,g;if(t[4]!==m||t[5]!==d||t[6]!==n.document){let e={viewCount:0,bytes:n.document.getText(`source`).length},r=bt(d)??crypto.randomUUID();h=Q.use,g=Oe({docName:d,mountId:r,construct:m,sizeStats:e}),t[4]=m,t[5]=d,t[6]=n.document,t[7]=h,t[8]=g}else h=t[7],g=t[8];let _=h(g),v=_.editor,y,b;t[9]===_?(y=t[10],b=t[11]):(y=()=>()=>{xe(_)},b=[_],t[9]=_,t[10]=y,t[11]=b),(0,Q.useEffect)(y,b);let x;return t[12]!==u||t[13]!==d||t[14]!==v||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==l||t[19]!==n?(x=(0,Z.jsx)(hA,{provider:n,isSourceMode:i,docName:d,activeDocName:u,identity:c,principal:l,editor:v,wrapperRef:o,flashStateRef:s,portalTarget:a}),t[12]=u,t[13]=d,t[14]=v,t[15]=c,t[16]=i,t[17]=a,t[18]=l,t[19]=n,t[20]=x):x=t[20],x},hA=e=>{let t=(0,$.c)(71),{provider:n,isSourceMode:r,docName:i,activeDocName:a,identity:o,principal:s,editor:c,wrapperRef:l,flashStateRef:u,portalTarget:d}=e,f=(0,Q.useRef)(null),p,m;t[0]===d?(p=t[1],m=t[2]):(p=()=>{let e=f.current;if(e)return e.appendChild(d),()=>{d.parentNode===e&&e.removeChild(d)}},m=[d],t[0]=d,t[1]=p,t[2]=m),(0,Q.useLayoutEffect)(p,m);let h;t[3]!==c||t[4]!==n.configuration.name?(h=()=>(ct(c,n.configuration.name??null),()=>{ct(c,null)}),t[3]=c,t[4]=n.configuration.name,t[5]=h):h=t[5];let g;t[6]!==c||t[7]!==n?(g=[c,n],t[6]=c,t[7]=n,t[8]=g):g=t[8],(0,Q.useEffect)(h,g);let _;t[9]!==c||t[10]!==n.configuration.name?(_=()=>{},t[9]=c,t[10]=n.configuration.name,t[11]=_):_=t[11];let v;t[12]!==c||t[13]!==n?(v=[c,n],t[12]=c,t[13]=n,t[14]=v):v=t[14],(0,Q.useEffect)(_,v);let y;t[15]!==c||t[16]!==n.configuration.name?(y=()=>{},t[15]=c,t[16]=n.configuration.name,t[17]=y):y=t[17];let b;t[18]!==c||t[19]!==n?(b=[c,n],t[18]=c,t[19]=n,t[20]=b):b=t[20],(0,Q.useEffect)(y,b);let x,S;t[21]===c?(x=t[22],S=t[23]):(S=()=>{let e=gA,t=null,n=()=>{if(t||c.isDestroyed)return;let n=pt(c);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 pt(c)?n():c.on(`create`,n),()=>{c.off(`create`,n),r()}},x=[c],t[21]=c,t[22]=x,t[23]=S),(0,Q.useEffect)(S,x);let C,T;t[24]!==u||t[25]!==n.document||t[26]!==l?(C=()=>{let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,o=null,s=()=>{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},c=e=>{u.current=e;let t=l.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=s(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(u.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};c(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),o&&clearTimeout(o),a=window.setTimeout(()=>{let e={...n,state:`settled`};c(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),o=window.setTimeout(()=>{c({...e,state:`idle`})},300)},dr)};c(lA);let f=()=>{if(Wn(e),!Vn(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(f);let p=()=>{document.visibilityState===`visible`?Vn(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,p),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,p),i&&clearTimeout(i),a&&clearTimeout(a),o&&clearTimeout(o)}},T=[n.document,u,l],t[24]=u,t[25]=n.document,t[26]=l,t[27]=C,t[28]=T):(C=t[27],T=t[28]),(0,Q.useEffect)(C,T);let E,D;t[29]===n?(E=t[30],D=t[31]):(E=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},D=[n],t[29]=n,t[30]=E,t[31]=D),(0,Q.useEffect)(E,D);let k,A;t[32]===c?(k=t[33],A=t[34]):(k=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||c.isDestroyed)return;let n=pt(c);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(zo,e),()=>window.removeEventListener(zo,e)},A=[c],t[32]=c,t[33]=k,t[34]=A),(0,Q.useEffect)(k,A);let j;t[35]!==a||t[36]!==i||t[37]!==o||t[38]!==r||t[39]!==s||t[40]!==n.awareness?(j=()=>{let e=n.awareness;if(e){if(i!==a){e.setLocalState(null);return}e.setLocalState({user:QO({principal:s,identity:o}),mode:r?`source`:`wysiwyg`})}},t[35]=a,t[36]=i,t[37]=o,t[38]=r,t[39]=s,t[40]=n.awareness,t[41]=j):j=t[41];let M;t[42]!==a||t[43]!==i||t[44]!==o||t[45]!==r||t[46]!==s||t[47]!==n?(M=[n,i,a,o,s,r],t[42]=a,t[43]=i,t[44]=o,t[45]=r,t[46]=s,t[47]=n,t[48]=M):M=t[48],(0,Q.useEffect)(j,M);let N,P;t[49]===c?(N=t[50],P=t[51]):(N=(0,Z.jsx)(Yk,{editor:c}),P=(0,Z.jsx)(oA,{editor:c}),t[49]=c,t[50]=N,t[51]=P);let F;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(`div`,{ref:f,style:{display:`contents`}}),t[52]=F):F=t[52];let I;t[53]===c?I=t[54]:(I=(0,Z.jsx)(se,{editor:c,className:`tiptap-editor-portal-content h-full`}),t[53]=c,t[54]=I);let L;t[55]!==d||t[56]!==I?(L=(0,is.createPortal)(I,d),t[55]=d,t[56]=I,t[57]=L):L=t[57];let R;t[58]===c?R=t[59]:(R=(0,Z.jsx)(YO,{editor:c}),t[58]=c,t[59]=R);let z;t[60]===c?z=t[61]:(z=w(c),t[60]=c,t[61]=z);let B;t[62]===z.store?B=t[63]:(B=(0,Z.jsx)(O,{store:z.store}),t[62]=z.store,t[63]=B);let V;return t[64]!==N||t[65]!==P||t[66]!==L||t[67]!==R||t[68]!==B||t[69]!==l?(V=(0,Z.jsxs)(`div`,{ref:l,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,L,R,B]}),t[64]=N,t[65]=P,t[66]=L,t[67]=R,t[68]=B,t[69]=l,t[70]=V):V=t[70],V};function gA(){return q()}function _A(e){let t=(0,$.c)(2),{docName:n,provider:r,children:i}=e;(0,Q.use)(lt(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 vA=`__back-nav__`;function yA(e){return e instanceof ge||e instanceof qe||e instanceof de||e instanceof Me||e instanceof rt||e instanceof Qe?e.docName:null}function bA(e){return e instanceof ge?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof qe?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof de?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof Me?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof rt?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:e instanceof Qe?{title:`Cancelled`,summary:`You cancelled loading "${e.docName}".`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function xA(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=bA(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)(jb,{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-2xl font-light tracking-tighter text-balance`,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)(X,{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)(X,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(ze(yA(n)??i),o(a),r(vA))},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 SA(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)(xA,{...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]===vA){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.error(`[DocumentErrorBoundary] rendered fallback for ${n}: ${bA(e).title}`,e)},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)(b,{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 CA={text:``,number:0,boolean:!1,date:``,list:[]};function wA(e){let t=e.document.getText(`source`).toString(),{map:n,parseError:r}=vr(t);return{map:n,keys:pn(t),parseError:r}}function TA(e){let t=(0,$.c)(169),{provider:n}=e,[r,i]=(0,Q.useState)(null),a;t[0]===n?a=t[1]:(a=()=>wA(n),t[0]=n,t[1]=a);let[o,s]=(0,Q.useState)(a),c,u;t[2]===n?(c=t[3],u=t[4]):(c=()=>{let e=br(n);i(e),s(e.current());let t=e.subscribe(e=>{s(e)});return()=>{t(),e.dispose(),i(t=>t===e?null:t)}},u=[n],t[2]=n,t[3]=c,t[4]=u),(0,Q.useEffect)(c,u);let d=o.map,f=o.keys,p=o.parseError,[m,h]=(0,Q.useState)(!1),g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[5]=g):g=t[5];let[_,v]=(0,Q.useState)(g),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C={},t[6]=C):C=t[6];let[w,T]=(0,Q.useState)(C),E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E={},t[7]=E):E=t[7];let[D,O]=(0,Q.useState)(E),k=n.configuration.name??``,j;t[8]===k?j=t[9]:(j=DA(k),t[8]=k,t[9]=j);let M=ra(j),P;t[10]!==M.state.data||t[11]!==M.state.status?(P=M.state.status===`ready`?M.state.data.folder.frontmatter_defaults??{}:{},t[10]=M.state.data,t[11]=M.state.status,t[12]=P):P=t[12];let F=P,I;t[13]!==M.state.data||t[14]!==M.state.status?(I=M.state.status===`ready`?M.state.data.frontmatterSources:{},t[13]=M.state.data,t[14]=M.state.status,t[15]=I):I=t[15];let L=I,z;t[16]===r?z=t[17]:(z=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=lr(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]=z);let B=z,V;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){T(t=>{if(!Object.hasOwn(t,e))return t;let n={...t};return delete n[e],n})},t[18]=V):V=t[18];let H=V,U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=function(e,t){if(e.ok)return;let n=e.error??`Failed to update property`,r=e.fieldErrors??{};T(e=>{let i={...e};for(let e of t)i[e]=r[e]??n;return i}),O(e=>{let n={...e};for(let e of t)n[e]=(n[e]??0)+1;return n})},t[19]=U):U=t[19];let W=U,G;t[20]===B?G=t[21]:(G=function(e,t){H(e),W(B({[e]:t}),[e])},t[20]=B,t[21]=G);let K=G,q;t[22]===B?q=t[23]:(q=function(e){H(e),W(B({[e]:null}),[e])},t[22]=B,t[23]=q);let ee=q,te;t[24]===r?te=t[25]:(te=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=lr(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]=te);let ne=te,re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(re=function(e,t){return`${e} ${t}`},t[26]=re):re=t[26];let ie=re,ae;t[27]!==r||t[28]!==f?(ae=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=f.map((e,t)=>ie(e,t)),a=i.indexOf(t),o=i.indexOf(n);if(a<0||o<0)return;let s=f.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]=f,t[29]=ae):ae=t[29];let oe=ae,se;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(se={activationConstraint:{distance:4}},t[30]=se):se=t[30];let ce;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(ce={coordinateGetter:fi},t[31]=ce):ce=t[31];let le=ia(ui(Di,se),ui(mi,ce)),ue;t[32]!==F||t[33]!==K||t[34]!==d?(ue=function(e,t){let n=d[e]??OA(F[e]);if(n===void 0)return;v(n=>({...n,[e]:t}));let r=MD(n,t);(!Object.hasOwn(d,e)||!EA(n,r))&&K(e,r)},t[32]=F,t[33]=K,t[34]=d,t[35]=ue):ue=t[35];let de=ue,fe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(fe=function(){b({name:``,type:`text`,value:``,error:null}),h(!1)},t[36]=fe):fe=t[36];let pe=fe,{addPropertySignal:me,clearAddProperty:he}=bO(),ge;t[37]!==me||t[38]!==k?(ge=me.get(k)??0,t[37]=me,t[38]=k,t[39]=ge):ge=t[39];let _e=ge,ve,ye;t[40]===_e?(ve=t[41],ye=t[42]):(ve=()=>{_e>0&&(b({name:``,type:`text`,value:``,error:null}),h(!1))},ye=[_e],t[40]=_e,t[41]=ve,t[42]=ye),(0,Q.useEffect)(ve,ye);let be,xe;t[43]!==he||t[44]!==k?(be=()=>()=>he(k),xe=[k,he],t[43]=he,t[44]=k,t[45]=be,t[46]=xe):(be=t[45],xe=t[46]),(0,Q.useEffect)(be,xe);let Se;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(Se=function(e){b(t=>{if(!t)return t;let n=e===`date`?new Date().toISOString().slice(0,10):CA[e];return{...t,type:e,value:n,error:null}})},t[47]=Se):Se=t[47];let Ce=Se,we;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(we=function(e){b(t=>t&&{...t,value:e})},t[48]=we):we=t[48];let J=we,Te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Te=function(e){b(t=>t&&{...t,name:e,error:null})},t[49]=Te):Te=t[49];let Ee=Te,De;t[50]!==y||t[51]!==B||t[52]!==d?(De=function(){if(!y)return;let e=y.name.trim();if(!e){b({...y,error:`Name is required`});return}if(e===`frontmatter`){b({...y,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){b({...y,error:`Property "${e}" already exists`});return}let t=B({[e]:y.value});if(t.ok){b(null);return}let n=t.fieldErrors?.[e],r=t.error??`Failed to add property`;b({...y,error:n??r})},t[50]=y,t[51]=B,t[52]=d,t[53]=De):De=t[53];let Oe=De,ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=function(){b(null)},t[54]=ke):ke=t[54];let Ae=ke,je;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(je=function(e){S({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){S(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(){S(null)},t[57]=Fe):Fe=t[57];let Ie=Fe,Le;t[58]!==d||t[59]!==ne||t[60]!==x?(Le=function(){if(!x)return;let e=x.draft.trim();if(!e){S(null);return}if(e===x.key){S(null);return}if(e===`frontmatter`){S({...x,error:`"frontmatter" is a reserved property name`});return}if(Object.hasOwn(d,e)){S({...x,error:`Property "${e}" already exists`});return}let t=ne(x.key,e);if(t.ok){v(t=>{if(!Object.hasOwn(t,x.key))return t;let n={...t};return n[e]=n[x.key],delete n[x.key],n}),H(x.key),S(null);return}let n=t.fieldErrors?.[e]??t.fieldErrors?.[x.key]??t.error??`Failed to rename property`;S({...x,error:n})},t[58]=d,t[59]=ne,t[60]=x,t[61]=Le):Le=t[61];let Re=Le,ze;t[62]!==d||t[63]!==f?(ze=f.length>0?f:Object.keys(d),t[62]=d,t[63]=f,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,qe,Je,Ye,Xe,Ze,Qe,$e;if(t[67]!==y||t[68]!==F||t[69]!==L||t[70]!==m||t[71]!==K||t[72]!==Re||t[73]!==Ve||t[74]!==w||t[75]!==oe||t[76]!==d||t[77]!==_||t[78]!==p||t[79]!==ee||t[80]!==x||t[81]!==Be||t[82]!==D||t[83]!==le||t[84]!==de){$e=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Object.keys(F).filter(e=>!Object.hasOwn(d,e)).sort();if(Be.length===0&&e.length===0&&!y&&!p){$e=null;break bb0}Ze=`property-panel editor-content-aligned pt-4 pb-4 text-sm`,Qe=`property-panel`,Ue=A,Je=!m,t[97]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=e=>h(!e),t[97]=Ye):Ye=t[97];let n=!m,r;t[98]===n?r=t[99]:(r=(0,Z.jsx)(l,{"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?Xe=t[102]:(Xe=(0,Z.jsx)(R,{asChild:!0,children:(0,Z.jsxs)(X,{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]=Xe),He=N,We=`overflow-hidden data-[state=open]:animate-[collapsible-down_150ms_ease-out] data-[state=closed]:animate-[collapsible-up_150ms_ease-in]`,t[103]===p?Ge=t[104]:(Ge=p?(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)(Dn,{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:p})]})]}):null,t[103]=p,t[104]=Ge);let a;if(t[105]!==Be){let e;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(e=(e,t)=>ie(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]!==F||t[109]!==L||t[110]!==K||t[111]!==Re||t[112]!==Ve||t[113]!==w||t[114]!==d||t[115]!==_||t[116]!==ee||t[117]!==x||t[118]!==Be||t[119]!==D||t[120]!==de){let e;t[122]!==F||t[123]!==L||t[124]!==K||t[125]!==Re||t[126]!==Ve||t[127]!==w||t[128]!==d||t[129]!==_||t[130]!==ee||t[131]!==x||t[132]!==D||t[133]!==de?(e=(e,t)=>{let n=d[e];if(n===void 0)return null;let r=_[e]??on(n),i=x?.key===e?x:null,a=(Ve.get(e)??0)>1,o=Object.hasOwn(F,e)?(0,Z.jsx)(kA,{source:L[e]??``}):void 0;return(0,Z.jsx)(PD,{sortableId:ie(e,t),keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isDuplicate:a,badge:o,rename:{state:i,onBegin:()=>Me(e),onChangeDraft:Pe,onCommit:Re,onCancel:Ie},onCommit:t=>K(e,t),onChangeType:t=>de(e,t),onRemove:()=>ee(e)},`${e}-${t}`)},t[122]=F,t[123]=L,t[124]=K,t[125]=Re,t[126]=Ve,t[127]=w,t[128]=d,t[129]=_,t[130]=ee,t[131]=x,t[132]=D,t[133]=de,t[134]=e):e=t[134],o=Be.map(e),t[108]=F,t[109]=L,t[110]=K,t[111]=Re,t[112]=Ve,t[113]=w,t[114]=d,t[115]=_,t[116]=ee,t[117]=x,t[118]=Be,t[119]=D,t[120]=de,t[121]=o}else o=t[121];let s;t[135]!==a||t[136]!==o?(s=(0,Z.jsx)(Mi,{items:a,strategy:Pi,children:o}),t[135]=a,t[136]=o,t[137]=s):s=t[137],t[138]!==oe||t[139]!==le||t[140]!==s?(Ke=(0,Z.jsx)(gi,{sensors:le,collisionDetection:aa,onDragEnd:oe,children:s}),t[138]=oe,t[139]=le,t[140]=s,t[141]=Ke):Ke=t[141];let c;t[142]!==F||t[143]!==L||t[144]!==K||t[145]!==w||t[146]!==D||t[147]!==de?(c=e=>{let t=F[e],n=OA(t),r=on(n),i=L[e]??``;return(0,Z.jsx)(PD,{keyName:e,value:n,declared:r,error:w[e]??null,resetCounter:D[e]??0,isInherited:!0,badge:(0,Z.jsx)(VD,{source:i}),onCommit:t=>K(e,t),onChangeType:t=>de(e,t)},`inherited-${e}`)},t[142]=F,t[143]=L,t[144]=K,t[145]=w,t[146]=D,t[147]=de,t[148]=c):c=t[148],qe=e.map(c)}t[67]=y,t[68]=F,t[69]=L,t[70]=m,t[71]=K,t[72]=Re,t[73]=Ve,t[74]=w,t[75]=oe,t[76]=d,t[77]=_,t[78]=p,t[79]=ee,t[80]=x,t[81]=Be,t[82]=D,t[83]=le,t[84]=de,t[85]=He,t[86]=Ue,t[87]=We,t[88]=Ge,t[89]=Ke,t[90]=qe,t[91]=Je,t[92]=Ye,t[93]=Xe,t[94]=Ze,t[95]=Qe,t[96]=$e}else He=t[85],Ue=t[86],We=t[87],Ge=t[88],Ke=t[89],qe=t[90],Je=t[91],Ye=t[92],Xe=t[93],Ze=t[94],Qe=t[95],$e=t[96];if($e!==Symbol.for(`react.early_return_sentinel`))return $e;let et;t[149]!==y||t[150]!==Oe?(et=y?(0,Z.jsx)(zD,{draft:y,onChangeName:Ee,onChangeType:Ce,onChangeValue:J,onCommit:Oe,onCancel:Ae}):(0,Z.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`add-property-trigger`,onClick:pe,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)(Fi,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Add property`})]}),t[149]=y,t[150]=Oe,t[151]=et):et=t[151];let tt;t[152]!==He||t[153]!==We||t[154]!==Ge||t[155]!==Ke||t[156]!==qe||t[157]!==et?(tt=(0,Z.jsxs)(He,{className:We,children:[Ge,Ke,qe,et]}),t[152]=He,t[153]=We,t[154]=Ge,t[155]=Ke,t[156]=qe,t[157]=et,t[158]=tt):tt=t[158];let nt;t[159]!==Ue||t[160]!==Je||t[161]!==Ye||t[162]!==Xe||t[163]!==tt?(nt=(0,Z.jsxs)(Ue,{open:Je,onOpenChange:Ye,children:[Xe,tt]}),t[159]=Ue,t[160]=Je,t[161]=Ye,t[162]=Xe,t[163]=tt,t[164]=nt):nt=t[164];let rt;return t[165]!==Ze||t[166]!==Qe||t[167]!==nt?(rt=(0,Z.jsx)(`div`,{className:Ze,"data-testid":Qe,children:nt}),t[165]=Ze,t[166]=Qe,t[167]=nt,t[168]=rt):rt=t[168],rt}function EA(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length?e.every((e,n)=>e===t[n]):!1:e===t}function DA(e){if(!e)return``;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function OA(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 kA(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)(Ne,{variant:`primary`,"data-testid":`property-override-badge`,title:r,className:`text-2xs`,children:`overrides`}),t[0]=r,t[1]=i),i}var AA=tt(`LARGE_DOC_CHAR_THRESHOLD`,5e5);function jA(e){let t=e.threshold??AA;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function MA(e){return e.hasEmittedFirstToggle||!e.isLarge?!1:e.renderSource&&e.renderVisual}var NA=tt(`ACTIVITY_MOUNT_LIMIT`,3);function PA(){return r(()=>import(`./SourceEditor-CSsFAy0n.js`),__vite__mapDeps([43,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,44,24]),import.meta.url)}var FA=(0,Q.lazy)(async()=>({default:(await PA()).SourceEditor}));function IA(e,t,n){if(n<=0)return[];let r=e.filter(e=>!we(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 LA(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 RA(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Z.jsx)(st,{name:`activity-pool`,children:(0,Z.jsx)(zA,{...e})}),t[0]=e,t[1]=n),n}function zA(e){let t=(0,$.c)(15),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=We(),{pages:u,loading:d}=wr(),f=IA(c,n,NA),p=(0,Q.useRef)(``),m=f.map(BA).join(`,`),h=(0,Q.useRef)(c),g,_;t[0]===c?(g=t[1],_=t[2]):(g=()=>{h.current=c},_=[c],t[0]=c,t[1]=g,t[2]=_),(0,Q.useLayoutEffect)(g,_),(0,Q.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[],r=e.filter(e=>!t.includes(e)),i=t.filter(t=>!e.includes(t));for(let e of r)ft(e);for(let e of i){let t=h.current.find(t=>t.docName===e)?.poolEventId;he(e,t&&t.length>0?t:crypto.randomUUID())}Ge(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:r}),p.current=m,Te(t)},[m,n]);let v;t[3]!==n||t[4]!==i||t[5]!==r||t[6]!==d||t[7]!==o||t[8]!==s||t[9]!==u||t[10]!==a||t[11]!==l?(v=e=>(0,Z.jsx)(GA,{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[3]=n,t[4]=i,t[5]=r,t[6]=d,t[7]=o,t[8]=s,t[9]=u,t[10]=a,t[11]=l,t[12]=v):v=t[12];let y=f.map(v),b;return t[13]===y?b=t[14]:(b=(0,Z.jsx)(Z.Fragment,{children:y}),t[13]=y,t[14]=b),b}function BA(e){return e.docName}function VA(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 pt-14 scroll-pt-14`,style:u,children:r}),t[6]=r,t[7]=d),d}function HA(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)(qy,{}),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)(FA,{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 UA(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)(ec,{className:`size-5`,"aria-hidden":`true`}):(0,Z.jsx)(Ze,{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)(X,{type:`button`,onClick:WA,children:[(0,Z.jsx)(ec,{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 WA(){return window.location.reload()}function GA(e){let t=(0,$.c)(48),{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=LA(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p;t[3]===n.docName?p=t[4]:(p=()=>{let e=document.createElement(`div`);return e.setAttribute(`data-ok-editor-portal`,n.docName),e.style.display=`contents`,e},t[3]=n.docName,t[4]=p);let[m]=(0,Q.useState)(p),h=n.provider.document.getText(`source`).length,[g,_]=(0,Q.useState)(i),[v,y]=(0,Q.useState)(!i),b,x;t[5]!==i||t[6]!==g||t[7]!==v?(b=()=>{i&&!g?_(!0):!i&&!v&&y(!0)},x=[i,g,v],t[5]=i,t[6]=g,t[7]=v,t[8]=b,t[9]=x):(b=t[8],x=t[9]),(0,Q.useEffect)(b,x);let S=jA({ytextLength:h,isSourceMode:i,visitedSource:g,visitedVisual:v}),C=(0,Q.useRef)(``),w=`${S.isLarge}-${S.renderSource}-${S.renderVisual}`,T,E;t[10]!==n.docName||t[11]!==S.isLarge||t[12]!==S.renderSource||t[13]!==S.renderVisual||t[14]!==w||t[15]!==i||t[16]!==h?(T=()=>{C.current!==w&&(C.current=w,S.isLarge&&Ge(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:h,isSourceMode:i,renderSource:S.renderSource,renderVisual:S.renderVisual}))},E=[w,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[10]=n.docName,t[11]=S.isLarge,t[12]=S.renderSource,t[13]=S.renderVisual,t[14]=w,t[15]=i,t[16]=h,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,Q.useEffect)(T,E);let[D,O]=(0,Q.useState)(!1),k,A;t[19]!==n.docName||t[20]!==S.isLarge||t[21]!==S.renderSource||t[22]!==S.renderVisual||t[23]!==D||t[24]!==i||t[25]!==h?(k=()=>{MA({isLarge:S.isLarge,renderSource:S.renderSource,renderVisual:S.renderVisual,hasEmittedFirstToggle:D})&&(Ge(`ok/cold/first-toggle`,{docName:n.docName,mountId:bt(n.docName),ytextLength:h,modeEnteredFirst:i?`source`:`visual`}),O(!0))},A=[D,S.isLarge,S.renderSource,S.renderVisual,n.docName,h,i],t[19]=n.docName,t[20]=S.isLarge,t[21]=S.renderSource,t[22]=S.renderVisual,t[23]=D,t[24]=i,t[25]=h,t[26]=k,t[27]=A):(k=t[26],A=t[27]),(0,Q.useEffect)(k,A);let j=r?`visible`:`hidden`,M=`editor:${n.docName}`,N;t[28]!==a||t[29]!==n||t[30]!==S.renderSource||t[31]!==S.renderVisual||t[32]!==r||t[33]!==o||t[34]!==i||t[35]!==c||t[36]!==l||t[37]!==m||t[38]!==s||t[39]!==f?(N=f?(0,Z.jsx)(UA,{view:f}):(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(SA,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(qy,{}),children:(0,Z.jsx)(_A,{docName:n.docName,provider:n.provider,children:(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!i&&(0,Z.jsx)(TA,{provider:n.provider}),(0,Z.jsxs)(`div`,{className:`relative flex-1`,children:[S.renderSource?(0,Z.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,Z.jsx)(HA,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,S.renderVisual?(0,Z.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,Z.jsx)(mA,{provider:n.provider,placeholder:a,isSourceMode:i,portalTarget:m},`${n.docName}-${String(o)}`)}):null]})]})})})})}),t[28]=a,t[29]=n,t[30]=S.renderSource,t[31]=S.renderVisual,t[32]=r,t[33]=o,t[34]=i,t[35]=c,t[36]=l,t[37]=m,t[38]=s,t[39]=f,t[40]=N):N=t[40];let P;t[41]!==r||t[42]!==N?(P=(0,Z.jsx)(VA,{isActive:r,children:N}),t[41]=r,t[42]=N,t[43]=P):P=t[43];let F;return t[44]!==M||t[45]!==P||t[46]!==j?(F=(0,Z.jsx)(Q.Activity,{mode:j,name:M,children:P}),t[44]=M,t[45]=P,t[46]=j,t[47]=F):F=t[47],F}function KA(e){let t=(0,$.c)(27),{stats:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-full h-2 bg-linear-to-t from-background to-transparent`}),t[0]=r):r=t[0];let i;t[1]===n.words?i=t[2]:(i=n.words.toLocaleString(),t[1]=n.words,t[2]=i);let a;t[3]===i?a=t[4]:(a=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:i}),t[3]=i,t[4]=a);let o=n.words===1?`word`:`words`,s;t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`span`,{children:[a,` `,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7];let c;t[8]===n.chars?c=t[9]:(c=n.chars.toLocaleString(),t[8]=n.chars,t[9]=c);let l;t[10]===c?l=t[11]:(l=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:c}),t[10]=c,t[11]=l);let u=n.chars===1?`char`:`chars`,d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`span`,{children:[l,` `,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f=n.tokens>0?`~`:``,p;t[15]===n.tokens?p=t[16]:(p=n.tokens.toLocaleString(),t[15]=n.tokens,t[16]=p);let m;t[17]===p?m=t[18]:(m=(0,Z.jsx)(`span`,{className:`tabular-nums`,children:p}),t[17]=p,t[18]=m);let h=n.tokens===1?`token`:`tokens`,g;t[19]!==f||t[20]!==m||t[21]!==h?(g=(0,Z.jsxs)(`span`,{children:[f,m,` `,h]}),t[19]=f,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;return t[23]!==g||t[24]!==s||t[25]!==d?(_=(0,Z.jsxs)(`section`,{"aria-label":`Document statistics`,className:`relative flex h-6 shrink-0 items-center justify-end gap-3 bg-background px-3 text-2xs text-muted-foreground`,children:[r,s,d,g]}),t[23]=g,t[24]=s,t[25]=d,t[26]=_):_=t[26],_}var qA={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`},JA=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`,...qA,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},YA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},XA=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)(JA,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function ZA(e){let t=(0,$.c)(39),{isSourceMode:n,sourceDisabled:r,onModeChange:i,showAddPropertyButton:a,onAddProperty:o,showPanelOpen:s,onTogglePanel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(`div`,{}),t[0]=l):l=t[0];let u=n?`source`:`wysiwyg`,d;t[1]===i?d=t[2]:(d=e=>{e&&i(e)},t[1]=i,t[2]=d);let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(ro,{value:`wysiwyg`,"aria-label":`Visual editor`,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(XA,{className:`size-4`})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Visual`})]}),t[3]=f):f=t[3];let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(YA,{className:`size-4`}),t[4]=p):p=t[4];let m;t[5]===r?m=t[6]:(m=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(`div`,{children:(0,Z.jsx)(ro,{value:`source`,"aria-label":`Markdown source`,disabled:r,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:p})})}),t[5]=r,t[6]=m);let h=r?`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`:`Markdown`,g;t[7]===h?g=t[8]:(g=(0,Z.jsx)(co,{side:`bottom`,children:h}),t[7]=h,t[8]=g);let _;t[9]!==m||t[10]!==g?(_=(0,Z.jsxs)(uo,{children:[m,g]}),t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==u||t[13]!==d||t[14]!==_?(v=(0,Z.jsx)(`div`,{className:`pointer-events-auto flex justify-center`,children:(0,Z.jsxs)(ao,{type:`single`,value:u,onValueChange:d,"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 data-[size=sm]:rounded-[10px] bg-muted p-0.5`,children:[f,_]})}),t[12]=u,t[13]=d,t[14]=_,t[15]=v):v=t[15];let y;t[16]!==o||t[17]!==a?(y=a&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`Add properties`,onClick:o,"data-testid":`add-properties-button`,asChild:!0,children:(0,Z.jsx)(so,{children:(0,Z.jsx)(Vs,{})})}),(0,Z.jsx)(co,{side:`bottom`,children:`Add properties`})]}),t[16]=o,t[17]=a,t[18]=y):y=t[18];let b=s?`Show document panel`:`Hide document panel`,x;t[19]===s?x=t[20]:(x=(0,Z.jsx)(so,{children:s?(0,Z.jsx)(Js,{}):(0,Z.jsx)(qs,{})}),t[19]=s,t[20]=x);let S;t[21]!==c||t[22]!==b||t[23]!==x?(S=(0,Z.jsx)(X,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":b,asChild:!0,children:x}),t[21]=c,t[22]=b,t[23]=x,t[24]=S):S=t[24];let C=s?`Show panel`:`Hide panel`,w;t[25]===C?w=t[26]:(w=(0,Z.jsx)(co,{side:`bottom`,children:C}),t[25]=C,t[26]=w);let T;t[27]!==S||t[28]!==w?(T=(0,Z.jsxs)(uo,{children:[S,w]}),t[27]=S,t[28]=w,t[29]=T):T=t[29];let E;t[30]!==y||t[31]!==T?(E=(0,Z.jsxs)(`div`,{className:`pointer-events-auto flex items-center justify-end gap-1`,children:[y,T]}),t[30]=y,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==v||t[34]!==E?(D=(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 items-center px-2 py-2 bg-background`,children:[l,v,E]}),t[33]=v,t[34]=E,t[35]=D):D=t[35];let O;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none h-2 bg-linear-to-b from-background to-transparent`}),t[36]=O):O=t[36];let k;return t[37]===D?k=t[38]:(k=(0,Z.jsxs)(`div`,{"data-testid":`editor-toolbar`,className:`pointer-events-none absolute inset-x-0 top-0 z-10`,children:[D,O]}),t[37]=D,t[38]=k),k}function QA(e){let{activeDocName:t,deferredActiveDocName:n,mountResolved:r,syncResolved:i}=e;return t===null||t===n?!1:!(r&&i)}var $A=(0,Q.lazy)(()=>r(()=>import(`./SettingsDialog-x6fsBA_3.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([45,1,35,2,36,37,21,38,39,40,41,20,3,6,7,15,4,8,14,9,46,16,22,10,23]),import.meta.url));function ej(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=(0,Z.jsx)(nj,{...e}),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(tj,{}),t[2]=r):r=t[2];let i;return t[3]===n?i=t[4]:(i=(0,Z.jsx)(st,{name:`editor-area`,children:(0,Z.jsxs)(vO,{children:[n,r]})}),t[3]=n,t[4]=i),i}function tj(){let e=(0,$.c)(8),t=Wf(),[n,r]=(0,Q.useState)(!1),i,a;if(e[0]===t.open?(i=e[1],a=e[2]):(i=()=>{t.open&&r(!0)},a=[t.open],e[0]=t.open,e[1]=i,e[2]=a),(0,Q.useEffect)(i,a),!n)return null;let o;e[3]===t?o=e[4]:(o=e=>{e||t.close()},e[3]=t,e[4]=o);let s;return e[5]!==t.open||e[6]!==o?(s=(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)($A,{open:t.open,onOpenChange:o})}),e[5]=t.open,e[6]=o,e[7]=s):s=e[7],s}function nj(e){let t=(0,$.c)(93),{editorMode:n,onModeChange:r,activeTab:i,onActiveTabChange:a}=e,{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=We(),{openDocumentTransition:f}=et(),{requestAddProperty:p}=bO(),m=HO(s,o),h=UO(s),g=h===`connected`||h===`synced`,_=(0,Q.useDeferredValue)(o),v=c?.kind===`missing`,y=!!o&&c?.kind!==`folder`,b=v?`Start writing to create this page`:void 0,x=Hy(),[S,C]=(0,Q.useState)(!1),{layout:w,autoCollapse:T}=EO(),E=w===`sheet`,[D,O]=(0,Q.useState)(!1),k=(0,Q.useRef)(!1),A,j;t[0]!==T||t[1]!==w||t[2]!==x?(A=()=>{if(w!==`panel`)return;let e=requestAnimationFrame(()=>{T?(k.current=!1,x.current?.collapse()):k.current||x.current?.expand()});return()=>cancelAnimationFrame(e)},j=[T,w,x],t[0]=T,t[1]=w,t[2]=x,t[3]=A,t[4]=j):(A=t[3],j=t[4]),(0,Q.useEffect)(A,j);let M,N;t[5]!==E||t[6]!==a||t[7]!==x?(M=()=>{let e=e=>{a(e),E?O(!0):(k.current=!1,x.current?.expand())},t=yf();return t&&e(t),xf(t=>{yf(),e(t)})},N=[E,a,x],t[5]=E,t[6]=a,t[7]=x,t[8]=M,t[9]=N):(M=t[8],N=t[9]),(0,Q.useEffect)(M,N);let P,F;t[10]!==d||t[11]!==E||t[12]!==x?(P=()=>{d!==0&&(E?O(!0):(k.current=!1,x.current?.expand()))},F=[d,E,x],t[10]=d,t[11]=E,t[12]=x,t[13]=P,t[14]=F):(P=t[13],F=t[14]),(0,Q.useEffect)(P,F);let I=(0,Q.useRef)(null),[L,R]=(0,Q.useState)(null),z,B;if(t[15]===o?(z=t[16],B=t[17]):(z=()=>{if(o&&o!==I.current){let e=I.current;I.current=o,R(e)}},B=[o],t[15]=o,t[16]=z,t[17]=B),(0,Q.useEffect)(z,B),c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,Z.jsx)(dO,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(c?.kind===`asset`){let e;return t[20]!==c.assetPath||t[21]!==c.mediaKind?(e=(0,Z.jsx)(Ky,{assetPath:c.assetPath,mediaKind:c.mediaKind}),t[20]=c.assetPath,t[21]=c.mediaKind,t[22]=e):e=t[22],e}if(!s||!o){if((typeof window<`u`?fr(window.location.hash):null)!==null){let e;return t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(qy,{}),t[23]=e):e=t[23],e}let e;return t[24]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(px,{}),t[24]=e):e=t[24],e}let V=n===`source`,H=!g,U=E?!D:S,W;t[25]!==o||t[26]!==p?(W=function(){o&&p(o)},t[25]=o,t[26]=p,t[27]=W):W=t[27];let G=W,K;t[28]!==S||t[29]!==E||t[30]!==x?(K=function(){E?O(rj):S?(k.current=!1,x.current?.expand()):(k.current=!0,x.current?.collapse())},t[28]=S,t[29]=E,t[30]=x,t[31]=K):K=t[31];let q=K,ee=_??o,te=L??void 0,ne;t[32]===f?ne=t[33]:(ne=e=>{let t=er(e);window.location.hash===t?f(e):window.location.hash=t},t[32]=f,t[33]=ne);let re;t[34]!==b||t[35]!==V||t[36]!==l||t[37]!==ee||t[38]!==te||t[39]!==ne?(re=(0,Z.jsx)(RA,{activeDocName:ee,isSourceMode:V,editorPlaceholder:b,previousDocName:te,onNavigateBack:ne,onRecycle:l}),t[34]=b,t[35]=V,t[36]=l,t[37]=ee,t[38]=te,t[39]=ne,t[40]=re):re=t[40];let ie;t[41]!==o||t[42]!==_?(ie=QA({activeDocName:o,deferredActiveDocName:_,mountResolved:o!==null&&je(o),syncResolved:o!==null&&ye(o)})?(0,Z.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:[(0,Z.jsx)(qy,{}),o===null?null:(0,Z.jsx)(hO,{docName:o})]}):null,t[41]=o,t[42]=_,t[43]=ie):ie=t[43];let ae;t[44]!==re||t[45]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`relative h-full`,children:[re,ie]}),t[44]=re,t[45]=ie,t[46]=ae):ae=t[46];let oe=!V,se;t[47]!==V||t[48]!==r||t[49]!==G||t[50]!==U||t[51]!==H||t[52]!==oe||t[53]!==q?(se=(0,Z.jsx)(ZA,{isSourceMode:V,sourceDisabled:H,onModeChange:r,showAddPropertyButton:oe,onAddProperty:G,showPanelOpen:U,onTogglePanel:q}),t[47]=V,t[48]=r,t[49]=G,t[50]=U,t[51]=H,t[52]=oe,t[53]=q,t[54]=se):se=t[54];let ce;t[55]!==ae||t[56]!==se?(ce=(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ae,se]}),t[55]=ae,t[56]=se,t[57]=ce):ce=t[57];let le;t[58]!==y||t[59]!==m?(le=y&&(0,Z.jsx)(KA,{stats:m}),t[58]=y,t[59]=m,t[60]=le):le=t[60];let ue;t[61]!==ce||t[62]!==le?(ue=(0,Z.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ce,le]}),t[61]=ce,t[62]=le,t[63]=ue):ue=t[63];let de=ue,fe=E?`100%`:`30%`,pe=E?`100%`:`75%`,me;t[64]!==de||t[65]!==fe||t[66]!==pe?(me=(0,Z.jsx)(SO,{minSize:fe,defaultSize:pe,children:de}),t[64]=de,t[65]=fe,t[66]=pe,t[67]=me):me=t[67];let he;t[68]===E?he=t[69]:(he=E?null:(0,Z.jsx)(CO,{withHandle:!0}),t[68]=E,t[69]=he);let ge;t[70]!==o||t[71]!==i||t[72]!==u||t[73]!==E||t[74]!==V||t[75]!==a||t[76]!==x?(ge=E?null:(0,Z.jsx)(SO,{panelRef:x,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:e=>C(e.asPercentage===0),className:`flex flex-col bg-muted/20`,children:(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})}),t[70]=o,t[71]=i,t[72]=u,t[73]=E,t[74]=V,t[75]=a,t[76]=x,t[77]=ge):ge=t[77];let _e;t[78]!==me||t[79]!==he||t[80]!==ge?(_e=(0,Z.jsxs)(xO,{orientation:`horizontal`,children:[me,he,ge]}),t[78]=me,t[79]=he,t[80]=ge,t[81]=_e):_e=t[81];let ve;t[82]!==o||t[83]!==i||t[84]!==u||t[85]!==E||t[86]!==V||t[87]!==a||t[88]!==D?(ve=E?(0,Z.jsx)(mg,{open:D,onOpenChange:O,children:(0,Z.jsxs)(_g,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[(0,Z.jsx)(vg,{className:`sr-only`,children:(0,Z.jsx)(yg,{children:`Document panel`})}),(0,Z.jsx)(Y_,{docName:o,isSourceMode:V,activeTab:i,onActiveTabChange:a,mode:u})]})}):null,t[82]=o,t[83]=i,t[84]=u,t[85]=E,t[86]=V,t[87]=a,t[88]=D,t[89]=ve):ve=t[89];let be;return t[90]!==_e||t[91]!==ve?(be=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[_e,ve]}),t[90]=_e,t[91]=ve,t[92]=be):be=t[92],be}function rj(e){return!e}var ij=1280;function aj(){let e=(0,$.c)(2),[t,n]=(0,Q.useState)(oj),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ij-1}px)`),t=()=>{n(window.innerWidth<ij)};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 oj(){return window.innerWidth<ij}function sj(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function cj(e){let{value:t,unit:n}=sj(e);return n===`rem`?t*16:t}function lj(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var uj=3600*24*7;function dj(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?fj:m,O=g===void 0?uj: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,K;t[3]===y?(G=t[4],K=t[5]):(G=()=>{H.current=y},K=[y],t[3]=y,t[4]=G,t[5]=K),(0,Q.useEffect)(G,K);let q=cj(b),ee;t[6]===x?ee=t[7]:(ee=cj(x),t[6]=x,t[7]=ee);let te=ee,ne;t[8]!==E||t[9]!==k?(ne=function(e){P.current=!0,E&&(j.current=H.current?0:cj(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]=ne):ne=t[10];let re=ne,ie,ae;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==te||t[18]!==q||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ie=()=>{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}=sj(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<=q*w;else if(e<=q){let n=q*(w-1);t=q-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>q*T){a();let t=n(r,M.current,j.current,s),c=Math.max(q,Math.min(te,t)),u=lj(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(q,Math.min(te,u)),f=lj(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)}},ae=[i,a,D,q,te,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]=te,t[18]=q,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ie,t[25]=ae):(ie=t[24],ae=t[25]),(0,Q.useEffect)(ie,ae);let oe;return t[26]===re?oe=t[27]:(oe={dragRef:A,isDragging:N,handleMouseDown:re},t[26]=re,t[27]=oe),oe}function fj(){}var pj=`sidebar_state`,mj=3600*24*7,hj=`18rem`,gj=`3rem`,_j=`\\`,vj=`app-file-sidebar`,yj=`14.625rem`,bj=`22rem`,xj=`sidebar_width`,Sj=/^\d+(?:\.\d+)?(?:rem|px)$/,Cj=Q.createContext(null);function wj(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${xj}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return Sj.test(n)?n:e}function Tj(){let e=Q.use(Cj);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Ej(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?hj:l,f=aj(),p;t[9]===d?p=t[10]:(p=()=>wj(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=`${pj}=${t}; path=/; max-age=${mj}`},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?_(Oj):D(Dj)},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===_j&&(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":gj,...s},t[40]=s,t[41]=m,t[42]=H):H=t[42];let U=H,W;t[43]===r?W=t[44]:(W=Y(`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 K;return t[50]!==V||t[51]!==G?(K=(0,Z.jsx)(Cj.Provider,{value:V,children:G}),t[50]=V,t[51]=G,t[52]=K):K=t[52],K}function Dj(e){return!e}function Oj(e){return!e}function kj(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}=Tj();if(u===`none`){let e;t[7]===r?e=t[8]:(e=Y(`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=Y(`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:vj,"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]:(_=Y(`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=Y(`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 Aj(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}=Tj(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=Y(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)(J,{}),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)(X,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":vj,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 jj(e){let t=(0,$.c)(24),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,enableDrag:a,enableToggle:o,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?!0:a,c=o===void 0?!0:o,{toggleSidebar:l,setWidth:u,state:d,width:f,setIsDraggingRail:p}=Tj(),m=d===`collapsed`,h;t[6]!==s||t[7]!==c||t[8]!==p||t[9]!==u||t[10]!==m||t[11]!==l||t[12]!==f?(h={direction:`right`,enableDrag:s,enableToggle:c,onResize:u,onToggle:l,currentWidth:f,isCollapsed:m,minResizeWidth:yj,maxResizeWidth:bj,setIsDraggingRail:p,widthCookieName:xj,widthCookieMaxAge:mj},t[6]=s,t[7]=c,t[8]=p,t[9]=u,t[10]=m,t[11]=l,t[12]=f,t[13]=h):h=t[13];let{dragRef:g,handleMouseDown:_}=dj(h),v;t[14]!==_||t[15]!==r?(v=e=>{r?.(e),e.defaultPrevented||_(e)},t[14]=_,t[15]=r,t[16]=v):v=t[16];let y;t[17]===n?y=t[18]:(y=Y(`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`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[17]=n,t[18]=y);let b;return t[19]!==g||t[20]!==i||t[21]!==v||t[22]!==y?(b=(0,Z.jsx)(`button`,{ref:g,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:v,title:`Toggle Sidebar`,className:y,...i}),t[19]=g,t[20]=i,t[21]=v,t[22]=y,t[23]=b):b=t[23],b}function Mj(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}=Tj(),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=Y(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm 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 Nj(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=Y(`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 Pj(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=Y(`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 Fj(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=Y(`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 Ij(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=Y(`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 Lj(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=Y(`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 Rj=Lr(`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 zj(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?Rr:`button`,{isMobile:m,state:h}=Tj(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=Y(Rj({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)(so,{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)(co,{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)(uo,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function Bj(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 Vj(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 Hj=1e3,Uj=!1;function Wj(e){return!!(e.localPrincipalId&&e.entryPrincipalId===e.localPrincipalId||!e.localPrincipalId&&e.entryClientId===e.localClientId)}function Gj(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:si(i)?a=i:(a=void 0,Uj||(Uj=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=(r?.getLocalState())?.user?.principalId??null,t=r?.clientID??null,i=[];if(r)for(let[n,a]of r.getStates().entries()){let r=a;if(!r.user||typeof r.user!=`object`)continue;let o=r.user;o.type===`human`&&(Wj({entryPrincipalId:o.principalId,entryClientId:n,localPrincipalId:e,localClientId:t})||i.push({kind:`human`,clientId:n,user:o,mode:r.mode??`wysiwyg`,tabCount:1}))}let s=Vj(i),{current:c,crossDoc:l}=a?ni(a,n,Date.now()):{current:[],crossDoc:[]},u=Kj,d=c.map(u),f=l.map(u),p=[...s,...d],m=f;o(e=>Bj(e.current,p)&&Bj(e.crossDoc,m)?e:{current:p,crossDoc:m})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,Hj);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 Kj(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}var qj=`sync-status`;function Jj(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,Xa.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:qj,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Xa.success(`Reconnected`,{id:qj,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 Yj=4,Xj=3,Zj={Bird:ns,Cat:cs,Dog:xs,Fish:Ts,Mouse:$s,Rabbit:Qs,Shrimp:ic,Snail:ac,Squirrel:lc,Turtle:mc};Object.freeze([...Object.keys(Zj)]);function Qj(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(Zj,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var $j={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function eM(e){let t=(0,$.c)(20),{user:n,mode:r,tabCount:i}=e,a=Qj(n),o=a.kind===`animal`?Zj[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Rn(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Or(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)(so,{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)(co,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(uo,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function tM(e){let t=$j[e.icon];return e.displayName||t||`Agent`}function nM(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 rM(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=tM(o),t[0]=o,t[1]=c);let l=c,u=nM(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=o.currentDoc&&o.currentDoc!==`(connected)`?o.currentDoc:null,x=r&&b?`Open activity panel for ${l}, editing ${b}`:`Open activity panel for ${l}`,S;t[9]===o.color?S=t[10]:(S={backgroundColor:o.color},t[9]=o.color,t[10]=S);let C;t[11]!==s||t[12]!==a?(C=()=>a(s),t[11]=s,t[12]=a,t[13]=C):C=t[13];let w;t[14]===o.icon?w=t[15]:(w=(0,Z.jsx)(ai,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=w);let T;t[16]!==x||t[17]!==y||t[18]!==h||t[19]!==w||t[20]!==S||t[21]!==C?(T=(0,Z.jsx)(`button`,{type:`button`,...y,"aria-label":x,className:h,style:S,onClick:C,children:w}),t[16]=x,t[17]=y,t[18]=h,t[19]=w,t[20]=S,t[21]=C,t[22]=T):T=t[22];let E=T,D;t[23]===E?D=t[24]:(D=(0,Z.jsx)(so,{asChild:!0,children:E}),t[23]=E,t[24]=D);let O;t[25]===l?O=t[26]:(O=(0,Z.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=O);let k;t[27]!==r||t[28]!==b?(k=r&&b?(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,b,`]]`]}):null,t[27]=r,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==O||t[31]!==k?(A=(0,Z.jsxs)(co,{className:`flex flex-col gap-0.5`,children:[O,k]}),t[30]=O,t[31]=k,t[32]=A):A=t[32];let j;return t[33]!==D||t[34]!==A?(j=(0,Z.jsxs)(uo,{children:[D,A]}),t[33]=D,t[34]=A,t[35]=j):j=t[35],j}function iM(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)(ie,{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)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{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)(ae,{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)(E,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function aM(e,t,n,r){return e.kind===`human`?(0,Z.jsx)(eM,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,Z.jsx)(rM,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function oM(){let e=(0,$.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=We(),{current:s,crossDoc:c}=Gj(t,r,n);Jj(UO(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,Yj),n;e[6]===s?n=e[7]:(n=s.slice(Yj),e[6]=s,e[7]=n);let r=n,u=c.slice(0,Xj),d;e[8]===c?d=e[9]:(d=c.slice(Xj),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=>aM(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)(iM,{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)(`div`,{className:`ml-1.5 flex items-center gap-1.5`,"data-presence-section":`crossdoc`,children:[u.map(e=>aM(e,p,!0,m)),f.length>0?(0,Z.jsx)(iM,{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 sM(e,t){return t.trim()}function cM(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function lM(e,t){let n=sM(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function uM(e,t,n=[]){if(t.length===0&&n.length===0)return e;let r=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>Ar(e)?{...e,docName:r.get(e.docName)??e.docName}:Pr(e)||Fn(e)?{...e,path:pM(e.path,n)}:e)}function dM(e,t,n){if(t.length===0&&!n)return e;let r=new Set(t);return e.filter(e=>Ar(e)?!r.has(e.docName)&&!mM(e.docName,n):Pr(e)||Fn(e)?!mM(e.path,n):!0)}function fM(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}function pM(e,t){for(let{fromPath:n,toPath:r}of t){if(e===n)return r;if(e.startsWith(`${n}/`))return`${r}${e.slice(n.length)}`}return e}function mM(e,t){return!!t&&(e===t||e.startsWith(`${t}/`))}function hM(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)(bl,{"data-slot":`context-menu`,...n}),t[2]=n,t[3]=r),r}function gM(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=Y(`select-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(xl,{"data-slot":`context-menu-trigger`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _M(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=Y(`z-50 max-h-(--radix-context-menu-content-available-height) min-w-36 origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Sl,{children:(0,Z.jsx)(Cl,{"data-slot":`context-menu-content`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vM(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=Y(`group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Z.jsx)(wl,{"data-slot":`context-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function yM(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=Y(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(Tl,{"data-slot":`context-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bM(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=Y(`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 xM=Lr(`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 SM(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=Y(xM({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:CM,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function CM(e){e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.parentElement?.querySelector(`input`)?.focus())}Lr(`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 wM(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=Y(`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 TM(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=Y(`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)(fo,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var EM=[`.md`,`.mdx`],DM=`group relative -mb-px flex h-10 min-w-28 max-w-64 shrink-0 cursor-pointer items-center overflow-hidden border border-transparent font-medium transition-colors`,OM=`z-10 rounded-t-lg rounded-b-none border-border border-b-0 bg-background text-foreground`,kM=Y(OM,`bg-transparent hover:bg-muted focus-visible:bg-muted border-transparent hover:border-border focus-visible:border-border`),AM=`flex h-full min-w-0 flex-1 cursor-pointer items-center overflow-hidden px-3 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,jM=`mr-2 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none transition hover:bg-foreground/10 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:opacity-100`;function MM(e){return Y(jM,e?`opacity-100`:`pointer-events-none opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`)}function NM(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 PM(e){return e.replace(/[^A-Za-z0-9_-]/g,`-`)}function FM(e){let t=er(e);window.location.hash!==t&&(window.location.hash=t)}function IM(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}function LM(e,t){let n=[t,...EM].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 RM(e){let t=(0,$.c)(48),{children:n,closeTab:r,closeTabs:i,canPin:a,disabled:o,openTabs:s,pinTab:c,pinnedTabIds:l,tabId:u,unpinTab:d}=e,f=a===void 0?!0:a;if(o!==void 0&&o)return n;let p;t[0]!==f||t[1]!==l||t[2]!==u?(p=f&&l.includes(u),t[0]=f,t[1]=l,t[2]=u,t[3]=p):p=t[3];let m=p,h;if(t[4]!==s||t[5]!==l||t[6]!==u){let e;t[8]===u?e=t[9]:(e=e=>e!==u,t[8]=u,t[9]=e),h=Pe(s.filter(e),l),t[4]=s,t[5]=l,t[6]=u,t[7]=h}else h=t[7];let g=h,_;t[10]!==s||t[11]!==l?(_=Pe(s,l),t[10]=s,t[11]=l,t[12]=_):_=t[12];let v=_,y=l.length?`Close all unpinned`:`Close all`,b;t[13]===n?b=t[14]:(b=(0,Z.jsx)(gM,{asChild:!0,children:n}),t[13]=n,t[14]=b);let x;t[15]!==r||t[16]!==u?(x=()=>r(u),t[15]=r,t[16]=u,t[17]=x):x=t[17];let S;t[18]!==m||t[19]!==x?(S=(0,Z.jsx)(vM,{disabled:m,onSelect:x,children:`Close`}),t[18]=m,t[19]=x,t[20]=S):S=t[20];let C=g.length===0,w;t[21]!==i||t[22]!==g?(w=()=>{i(g)},t[21]=i,t[22]=g,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==C?(T=(0,Z.jsx)(vM,{disabled:C,onSelect:w,children:`Close others`}),t[24]=w,t[25]=C,t[26]=T):T=t[26];let E=v.length===0,D;t[27]!==v||t[28]!==i?(D=()=>{i(v)},t[27]=v,t[28]=i,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==E||t[32]!==D?(O=(0,Z.jsx)(vM,{disabled:E,onSelect:D,children:y}),t[30]=y,t[31]=E,t[32]=D,t[33]=O):O=t[33];let k;t[34]!==f||t[35]!==m||t[36]!==c||t[37]!==u||t[38]!==d?(k=f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yM,{}),(0,Z.jsx)(vM,{onSelect:()=>m?d(u):c(u),children:m?`Unpin tab`:`Pin tab`})]}),t[34]=f,t[35]=m,t[36]=c,t[37]=u,t[38]=d,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==O||t[42]!==k||t[43]!==S?(A=(0,Z.jsxs)(_M,{className:`min-w-40`,children:[S,T,O,k]}),t[40]=T,t[41]=O,t[42]=k,t[43]=S,t[44]=A):A=t[44];let j;return t[45]!==A||t[46]!==b?(j=(0,Z.jsxs)(hM,{children:[b,A]}),t[45]=A,t[46]=b,t[47]=j):j=t[47],j}function zM(e){let t=(0,$.c)(14),{accessibleLabel:n,closeTab:r,isPinned:i,tabId:a,unpinTab:o}=e;if(i){let e=`Unpin ${n}`,r;t[0]!==a||t[1]!==o?(r=e=>{e.stopPropagation(),o(a)},t[0]=a,t[1]=o,t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(Zs,{"aria-hidden":`true`}),t[3]=i):i=t[3];let s;return t[4]!==e||t[5]!==r?(s=(0,Z.jsx)(X,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":e,className:`mr-2 text-primary! hover:bg-primary/10!`,onClick:r,children:i}),t[4]=e,t[5]=r,t[6]=s):s=t[6],s}let s=`Close ${n}`,c;t[7]!==r||t[8]!==a?(c=e=>{e.stopPropagation(),r(a)},t[7]=r,t[8]=a,t[9]=c):c=t[9];let l;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(Fa,{"aria-hidden":`true`}),t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==c?(u=(0,Z.jsx)(X,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":s,className:`mr-2`,onClick:c,children:l}),t[11]=s,t[12]=c,t[13]=u):u=t[13],u}function BM(){let e=(0,$.c)(68),{activeDocName:t,activeTabId:n,activeNewTabId:r,activeTarget:i,activateTab:a,activateNewTab:o,closeAndClearForRename:s,closeNewTab:c,closeTab:l,closeTabs:u,isNewTabActive:d,newTabIds:f,openNewTab:p,openTabs:m,pinTab:h,pinnedTabIds:g,remapTabsForRename:_,unpinTab:v,visibleTabIds:y}=We(),{pageMeta:b}=wr(),x=(0,Q.useRef)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),A=(0,Q.useRef)(null),j=(0,Q.useRef)(!1),N=(0,Q.useRef)(!1),P=(0,Q.useRef)(null),F=(0,Q.useRef)(t),I;e[0]!==n||e[1]!==t||e[2]!==i?(I=n??(i?ve(i):t?nt(t):null),e[0]=n,e[1]=t,e[2]=i,e[3]=I):I=e[3];let L=I,R;e[4]!==r||e[5]!==L||e[6]!==d||e[7]!==f||e[8]!==m?(R=d?`${r??`__new-tab__`}\u0000${m.join(`\0`)}\u0000${f.join(`\0`)}`:L?`${L}\u0000${m.join(`\0`)}`:``,e[4]=r,e[5]=L,e[6]=d,e[7]=f,e[8]=m,e[9]=R):R=e[9];let z=R,B,V;e[10]===t?(B=e[11],V=e[12]):(B=()=>{F.current=t},V=[t],e[10]=t,e[11]=B,e[12]=V),(0,Q.useEffect)(B,V);let H,U;e[13]===z?(H=e[14],U=e[15]):(H=()=>{z&&(x.current?.querySelector(`[data-active-tab="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},U=[z],e[13]=z,e[14]=H,e[15]=U),(0,Q.useEffect)(H,U);let W,G;e[16]===S?(W=e[17],G=e[18]):(W=()=>{S&&(A.current?.focus(),A.current?.select())},G=[S],e[16]=S,e[17]=W,e[18]=G),(0,Q.useEffect)(W,G);let K,q;e[19]!==m||e[20]!==S?(K=()=>{!S||m.includes(S.tabId)||(N.current=!0,P.current=null,C(null),T(``),D(null),k(!1))},q=[m,S],e[19]=m,e[20]=S,e[21]=K,e[22]=q):(K=e[21],q=e[22]),(0,Q.useEffect)(K,q);let ee,te,ne,re,ie;if(e[23]!==o||e[24]!==a||e[25]!==r||e[26]!==L||e[27]!==s||e[28]!==c||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==f||e[33]!==b||e[34]!==h||e[35]!==g||e[36]!==_||e[37]!==E||e[38]!==w||e[39]!==S?.docName||e[40]!==S?.tabId||e[41]!==v||e[42]!==y){let t=function(e,t){let n=t.split(`/`);N.current=!1,P.current=null,C({docName:t,tabId:e}),T(n[n.length-1]),D(null)},n=function(){N.current=!0,P.current=null,C(null),T(``),D(null),k(!1)},i=async function(){if(N.current){N.current=!1;return}if(j.current)return;let e=S?.docName;if(!e){n();return}let t=sM(`file`,LM(w,b.get(e)?.docExt??`.md`)),r=e.split(`/`),i=r[r.length-1];if(t===i){n();return}if(t===P.current){A.current?.focus();return}if(!cM(t)){D(`Name can’t be empty, ".", "..", or contain / or \\`),A.current?.focus();return}let a=lM({kind:`file`,path:e,name:i},t);j.current=!0,k(!0),D(null);try{let n=await fetch(`/api/rename-path`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:`file`,fromPath:e,toPath:a})});if(N.current){k(!1),j.current=!1;return}let r=await Le(n,`Server error (HTTP ${n.status})`);if(!r.ok){D(r.title),k(!1),j.current=!1,P.current=t,A.current?.focus();return}let i=M(vn,r.body,`rename-path:tab`,{renamed:[]}).renamed,o=F.current,c=fM(o,i);await Promise.all(i.flatMap(e=>[s(e.fromDocName),s(e.toDocName)])),_(i),Kn([`files`,`backlinks`,`graph`]),N.current=!0,C(null),T(``),D(null),k(!1),j.current=!1,P.current=null,c&&c!==o&&FM(c)}catch(n){console.warn(`[EditorTabs] rename failed`,{err:n,docName:e,newDocName:a,normalized:t}),D(`Network error — please try again`),k(!1),j.current=!1,P.current=t,A.current?.focus()}};ee=typeof window<`u`&&window.okDesktop!=null;let d;e[48]===f?d=e[49]:(d=new Set(f),e[48]=f,e[49]=d);let p=d,m;e[50]!==c||e[51]!==u||e[52]!==p?(m=function(e){let t=[],n=[];for(let r of e)p.has(r)?n.push(r):t.push(r);t.length>0&&u(t);for(let e of n)c(e)},e[50]=c,e[51]=u,e[52]=p,e[53]=m):m=e[53];let I=m;te=x,e[54]===Symbol.for(`react.memo_cache_sentinel`)?(ne=Y(`pl-2 flex h-12 min-w-0 touch-manipulation flex-1 items-end gap-1 overflow-x-auto overflow-y-hidden overscroll-x-contain scroll-fade-mask-x [scrollbar-width:none]`,ee&&`[-webkit-app-region:drag]`),e[54]=ne):ne=e[54],re=IM,ie=y.map(e=>{if(p.has(e)){let t=e===r;return(0,Z.jsx)(RM,{tabId:e,canPin:!1,openTabs:y,closeTab:c,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":t?`true`:void 0,className:Y(DM,t?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),c(e))},onClick:t=>{t.target===t.currentTarget&&o(e)},children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Activate new tab`,className:AM,onClick:()=>o(e),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:`New tab`})}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close new tab`,className:MM(t),onClick:t=>{t.stopPropagation(),c(e)},children:(0,Z.jsx)(Fa,{"aria-hidden":`true`,className:`size-3.5`})})]})},e)}let s=Ye(e),u=e===L,d=g.includes(e);if(s.kind===`folder`){let{baseName:t,label:n,prefix:r}=NM(s.folderPath,`/`),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate`,u&&`text-muted-foreground`),children:r}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,r?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`/`})]})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}if(s.kind===`asset`){let{baseName:t,label:n,prefix:r}=NM(s.assetPath,``),i=`${r}${n}`;return(0,Z.jsx)(RM,{tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsxs)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i,className:AM,onClick:()=>{a(e)},children:[r?(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:r}):null,(0,Z.jsx)(`span`,{className:Y(`min-w-0 truncate`,r?`max-w-[70%] shrink-0`:`flex-1`),children:t})]}),(0,Z.jsx)(zM,{accessibleLabel:i,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})},e)}let f=s.docName,m=b.get(f)?.docExt??`.md`,{baseName:_,extension:x,label:C,prefix:k}=NM(f,m),j=`${k}${C}`,M=S?.tabId===e,N=`editor-tab-rename-error-${PM(f)}`;return(0,Z.jsx)(RM,{disabled:M,tabId:e,openTabs:y,closeTab:l,closeTabs:I,pinTab:h,pinnedTabIds:g,unpinTab:v,children:(0,Z.jsx)(`div`,{role:`presentation`,"data-active-tab":u?`true`:void 0,className:Y(DM,u?OM:kM,M&&E&&`border-destructive`,ee&&`[-webkit-app-region:no-drag]`),onAuxClick:t=>{t.button===1&&(t.preventDefault(),!d&&l(e))},onClick:t=>{t.target===t.currentTarget&&a(e)},children:M?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(bM,{className:`h-full min-w-0 flex-1 rounded-none border-0 bg-transparent dark:bg-transparent`,children:[(0,Z.jsx)(TM,{ref:A,value:w,disabled:O,"aria-label":`Rename ${C}`,"aria-invalid":E?!0:void 0,"aria-describedby":E?N:void 0,"aria-busy":O||void 0,title:E??f,className:`h-full min-w-0 px-2 py-0 font-medium text-foreground text-xs selection:bg-primary selection:text-primary-foreground`,onChange:e=>{T(LM(e.target.value,m)),D(null),P.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i()):e.key===`Escape`&&(e.preventDefault(),n())},onBlur:i}),(0,Z.jsx)(SM,{align:`inline-end`,"aria-hidden":`true`,className:`pr-2 text-xs`,children:(0,Z.jsx)(wM,{className:`text-muted-foreground/60 text-xs`,children:m})})]}),E?(0,Z.jsx)(`span`,{id:N,role:`alert`,className:`sr-only`,children:E}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-label":j,className:AM,onClick:()=>{a(e)},onDoubleClick:n=>{n.preventDefault(),n.stopPropagation(),t(e,f)},children:[k&&(0,Z.jsx)(`span`,{className:Y(`min-w-0 flex-1 truncate text-muted-foreground/60`,u&&`text-muted-foreground`),children:k}),(0,Z.jsxs)(`span`,{className:Y(`flex min-w-0 items-center`,k?`max-w-[70%] shrink-0`:`flex-1`),children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:x})]})]}),(0,Z.jsx)(zM,{accessibleLabel:j,closeTab:l,isPinned:d,tabId:e,unpinTab:v})]})})},e)}),e[23]=o,e[24]=a,e[25]=r,e[26]=L,e[27]=s,e[28]=c,e[29]=l,e[30]=u,e[31]=O,e[32]=f,e[33]=b,e[34]=h,e[35]=g,e[36]=_,e[37]=E,e[38]=w,e[39]=S?.docName,e[40]=S?.tabId,e[41]=v,e[42]=y,e[43]=ee,e[44]=te,e[45]=ne,e[46]=re,e[47]=ie}else ee=e[43],te=e[44],ne=e[45],re=e[46],ie=e[47];let ae;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(ae=Y(`first:mb-3 mb-1.5`,ee&&`[-webkit-app-region:no-drag]`),e[55]=ae):ae=e[55];let oe;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(Fi,{"aria-hidden":`true`}),e[56]=oe):oe=e[56];let se;e[57]===p?se=e[58]:(se=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{type:`button`,size:`icon-xs`,variant:`ghost`,"aria-label":`New tab`,className:ae,onClick:p,children:oe})}),e[57]=p,e[58]=se);let ce;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(co,{children:`New tab`}),e[59]=ce):ce=e[59];let le;e[60]===se?le=e[61]:(le=(0,Z.jsxs)(uo,{children:[se,ce]}),e[60]=se,e[61]=le);let ue;return e[62]!==te||e[63]!==ne||e[64]!==re||e[65]!==ie||e[66]!==le?(ue=(0,Z.jsxs)(`div`,{ref:te,className:ne,onWheel:re,children:[ie,le]}),e[62]=te,e[63]=ne,e[64]=re,e[65]=ie,e[66]=le,e[67]=ue):ue=e[67],ue}function VM(e){let t=(0,$.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`title`,{children:`Discord`}),r=(0,Z.jsx)(`path`,{d:`M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9554 2.4189-2.1568 2.4189Z`}),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 HM(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 UM=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:j},{label:`GitHub`,href:`https://github.com/inkeep/open-knowledge`,icon:Du},{label:`Website`,href:`https://openknowledge.ai/`,icon:ja},{label:`Discord`,href:`https://go.inkeep.com/ok-discord`,icon:VM},{label:`Twitter`,href:`https://x.com/inkeep`,icon:HM}],WM=()=>{let e=(0,$.c)(5),[t,n]=(0,Q.useState)(!1),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Resources`})]})})}),(0,Z.jsx)(co,{children:`Resources`})]}),e[0]=r):r=e[0];let i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[1]=i):i=e[1];let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsxs)(ae,{align:`end`,className:`w-64 p-3`,children:[i,(0,Z.jsx)(`nav`,{"aria-label":`Resources`,children:(0,Z.jsx)(`ul`,{className:`space-y-0.5`,children:UM.map(GM)})})]}),e[2]=a):a=e[2];let o;return e[3]===t?o=e[4]:(o=(0,Z.jsxs)(E,{open:t,onOpenChange:n,children:[r,a]}),e[3]=t,e[4]=o),o};function GM(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=>pi(e,n),onAuxClick:e=>pi(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)}function KM(e){let t=(0,$.c)(70),{input:n}=e,{states:r,refresh:i}=Wp(),{dispatch:a}=Np(),{skillInstalled:o,refresh:s}=la(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),f=typeof window<`u`&&window.okDesktop!=null,p;t[0]===i?p=t[1]:(p=e=>{l(e),e&&i()},t[0]=i,t[1]=p);let m=p,h=n===null,g;t[2]===n?g=t[3]:(g=n!==null&&n.docContext!==null?tr(n.docContext):``,t[2]=n,t[3]=g);let _=g,y;t[4]!==a||t[5]!==n?(y=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=y):y=t[6];let b=y,x,S,C,w,T,E,D,O,k,A,j,M;if(t[7]!==m||t[8]!==b||t[9]!==n||t[10]!==c||t[11]!==_||t[12]!==o||t[13]!==r||t[14]!==h){let e;t[27]===r?e=t[28]:(e=e=>r[e.id]?.installed===!0,t[27]=r,t[28]=e);let i=zf.filter(e);C=r[`claude-cowork`]?.installed===!0;let a;t[29]!==n||t[30]!==_?(a=()=>{n!==null&&tb(_)},t[29]=n,t[30]=_,t[31]=a):a=t[31],w=a,S=ji,M=c,T=m;let s;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(ii,{className:`size-4`}),t[32]=s):s=t[32];let l;t[33]===h?l=t[34]:(l=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Si,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:h,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:s})})}),t[33]=h,t[34]=l);let u;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)(co,{children:`Edit with AI`}),t[35]=u):u=t[35],t[36]===l?E=t[37]:(E=(0,Z.jsxs)(uo,{children:[l,u]}),t[36]=l,t[37]=E),x=Aa,D=`end`,O=`min-w-[220px]`,k=`open-in-agent-menu`,t[38]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Z.jsx)(Li,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in`}),t[38]=A):A=t[38];let p;t[39]!==b||t[40]!==_||t[41]!==o||t[42]!==r?(p=e=>{let t=r[e.id];return(0,Z.jsx)(rb,{target:e,installState:t,isElectronHost:f,prompt:_,onSelect:()=>b(e),onInstallSkillRequest:e.id===`claude-cowork`&&!o?()=>d(!0):void 0},e.id)},t[39]=b,t[40]=_,t[41]=o,t[42]=r,t[43]=p):p=t[43],j=i.map(p),t[7]=m,t[8]=b,t[9]=n,t[10]=c,t[11]=_,t[12]=o,t[13]=r,t[14]=h,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,t[25]=j,t[26]=M}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],j=t[25],M=t[26];let N;t[44]!==C||t[45]!==w||t[46]!==n?(N=C?null:(0,Z.jsxs)(di,{onSelect:w,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)(v,{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[44]=C,t[45]=w,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==x||t[49]!==N||t[50]!==D||t[51]!==O||t[52]!==k||t[53]!==A||t[54]!==j?(P=(0,Z.jsxs)(x,{align:D,className:O,"data-testid":k,children:[A,j,N]}),t[48]=x,t[49]=N,t[50]=D,t[51]=O,t[52]=k,t[53]=A,t[54]=j,t[55]=P):P=t[55];let F;t[56]!==S||t[57]!==T||t[58]!==E||t[59]!==P||t[60]!==M?(F=(0,Z.jsxs)(S,{open:M,onOpenChange:T,children:[E,P]}),t[56]=S,t[57]=T,t[58]=E,t[59]=P,t[60]=M,t[61]=F):F=t[61];let I;t[62]===s?I=t[63]:(I=e=>{d(e),e||s()},t[62]=s,t[63]=I);let L;t[64]!==u||t[65]!==I?(L=(0,Z.jsx)(ta,{open:u,onOpenChange:I}),t[64]=u,t[65]=I,t[66]=L):L=t[66];let R;return t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(Z.Fragment,{children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69],R}var qM=()=>{let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,"data-testid":`header-settings-button`,onClick:JM,children:[(0,Z.jsx)(rc,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Z.jsx)(co,{children:`Settings`})]}),e[0]=t):t=e[0],t};function JM(){window.location.hash!==`#settings`&&(window.location.hash=Bf)}function YM(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 XM(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}function ZM(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)(ps,{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)(ec,{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)(ps,{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)(ec,{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)(Dn,{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)(fs,{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)(Us,{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)(Dn,{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)(ps,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QM(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 $M(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 eN(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 tN(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`}`:$M(e.state):`Sync off`}function nN(e){let t=(0,$.c)(76),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,{projectLocalConfig:o,projectLocalSynced:s}=ba(),c=o?.autoSync?.enabled??!1,{confirmOpen:l,setConfirmOpen:u,onToggleRequest:d,onConfirm:f}=zi(Vi()),p;t[0]===n?p=t[1]:(p=(0,Z.jsx)(ZM,{status:n}),t[0]=n,t[1]=p);let m;t[2]===n.state?m=t[3]:(m=$M(n.state),t[2]=n.state,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:m}),t[4]=m,t[5]=h);let g;t[6]!==p||t[7]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8];let _=!s,v=c?`Disable sync`:`Enable sync`,y;t[9]!==c||t[10]!==d||t[11]!==_||t[12]!==v?(y=(0,Z.jsx)(Fe,{checked:c,disabled:_,onCheckedChange:d,"aria-label":v}),t[9]=c,t[10]=d,t[11]=_,t[12]=v,t[13]=y):y=t[13];let b;t[14]!==g||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16];let x;t[17]!==l||t[18]!==f||t[19]!==u?(x=(0,Z.jsx)(pa,{open:l,onOpenChange:u,onConfirm:f}),t[17]=l,t[18]=f,t[19]=u,t[20]=x):x=t[20];let S;t[21]===n.error?S=t[22]:(S=n.error&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[21]=n.error,t[22]=S);let C;t[23]===n.pausedReason?C=t[24]:(C=n.pausedReason&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eN(n.pausedReason)}),t[23]=n.pausedReason,t[24]=C);let w;t[25]===n.state?w=t[26]:(w=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[25]=n.state,t[26]=w);let T;t[27]!==c||t[28]!==n.lastSyncUtc||t[29]!==n.state?(T=c&&n.state!==`dormant`&&(0,Z.jsxs)(`div`,{children:[`Last synced: `,YM(n.lastSyncUtc)]}),t[27]=c,t[28]=n.lastSyncUtc,t[29]=n.state,t[30]=T):T=t[30];let E;t[31]===n.ahead?E=t[32]:(E=n.ahead>0&&(0,Z.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[31]=n.ahead,t[32]=E);let D;t[33]===n.behind?D=t[34]:(D=n.behind>0&&(0,Z.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[33]=n.behind,t[34]=D);let O;t[35]===n.conflictCount?O=t[36]:(O=n.conflictCount>0&&(0,Z.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[35]=n.conflictCount,t[36]=O);let k;t[37]===c?k=t[38]:(k=!c&&(0,Z.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[37]=c,t[38]=k);let A;t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O||t[43]!==k?(A=(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[T,E,D,O,k]}),t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=k,t[44]=A):A=t[44];let j;t[45]!==a||t[46]!==n.identityUnresolved?(j=n.identityUnresolved&&a&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,Z.jsx)(vc,{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)(X,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[45]=a,t[46]=n.identityUnresolved,t[47]=j):j=t[47];let M;t[48]!==c||t[49]!==n.state?(M=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:iN,children:`Sync now`}),t[48]=c,t[49]=n.state,t[50]=M):M=t[50];let N;t[51]!==c||t[52]!==r||t[53]!==n.state?(N=c&&n.state===`auth-error`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[51]=c,t[52]=r,t[53]=n.state,t[54]=N):N=t[54];let P;t[55]!==c||t[56]!==n.state?(P=c&&n.state===`offline`&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:rN,children:`Retry`}),t[55]=c,t[56]=n.state,t[57]=P):P=t[57];let F;t[58]!==c||t[59]!==i||t[60]!==n.state?(F=c&&n.state===`conflict`&&i&&(0,Z.jsx)(X,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[58]=c,t[59]=i,t[60]=n.state,t[61]=F):F=t[61];let I;t[62]!==M||t[63]!==N||t[64]!==P||t[65]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[M,N,P,F]}),t[62]=M,t[63]=N,t[64]=P,t[65]=F,t[66]=I):I=t[66];let L;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==A||t[71]!==j||t[72]!==I||t[73]!==b||t[74]!==x?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[b,x,S,C,w,A,j,I]}),t[67]=S,t[68]=C,t[69]=w,t[70]=A,t[71]=j,t[72]=I,t[73]=b,t[74]=x,t[75]=L):L=t[75],L}function rN(){XM(`sync`)}function iN(){XM(`sync`)}function aN(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}=_a();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,Z.jsx)(fs,{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)(uo,{children:[e,(0,Z.jsx)(co,{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=QM(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$M(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)(ZM,{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)(so,{asChild:!0,children:(0,Z.jsx)(ie,{asChild:!0,children:(0,Z.jsxs)(X,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tN(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,Z.jsx)(co,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,Z.jsxs)(uo,{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)(ae,{align:`end`,className:`w-64 p-3`,children:(0,Z.jsx)(nN,{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)(E,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oN=[{value:`light`,label:`Light`,icon:fc},{value:`dark`,label:`Dark`,icon:Ws},{value:`system`,label:`System`,icon:vs}],sN=()=>{let e=(0,$.c)(16),{theme:t}=yr(),{merged:n,userBinding:r}=ba(),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||Xa.error(wn(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?vs:i===`dark`?Ws:fc,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)(Si,{asChild:!0,children:(0,Z.jsxs)(X,{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=oN.map(cN),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,Z.jsx)(Aa,{align:`end`,children:(0,Z.jsx)(bi,{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)(ji,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function cN(e){let{value:t,label:n,icon:r}=e;return(0,Z.jsxs)(Ii,{value:t,className:`capitalize`,children:[(0,Z.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function lN(e){let t=(0,$.c)(38),{onSaveVersion:n,saving:r,onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}=e,{activeDocName:s}=We(),{state:c}=Tj(),l=qf(),u;t[0]!==s||t[1]!==l?(u=Sp({docName:s,workspace:l}),t[0]=s,t[1]=l,t[2]=u):u=t[2];let d=u,f=typeof window<`u`&&window.okDesktop!=null,p=f&&c===`collapsed`&&`pl-[78px]`,m;t[3]===p?m=t[4]:(m=Y(`flex h-12 shrink-0 items-center bg-muted/35 shadow-[inset_0_-1px_0_var(--border)]`,f&&`[-webkit-app-region:drag]`,p,f&&`motion-safe:transition-[padding] motion-safe:duration-200 motion-safe:ease-linear`),t[3]=p,t[4]=m);let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(Aj,{className:Y(`-ml-1 shrink-0 text-muted-foreground`,f&&`[-webkit-app-region:no-drag]`)})}),t[5]=h):h=t[5];let g=c===`expanded`?`Hide Files`:`Show Files`,_;t[6]===g?_=t[7]:(_=(0,Z.jsxs)(uo,{children:[h,(0,Z.jsx)(co,{children:g})]}),t[6]=g,t[7]=_);let v,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),y=(0,Z.jsx)(BM,{}),t[8]=v,t[9]=y):(v=t[8],y=t[9]);let b;t[10]===_?b=t[11]:(b=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 px-3`,children:[_,v,y]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`flex shrink-0 items-center justify-end gap-2 px-3`,f&&`[&>*]:[-webkit-app-region:no-drag]`),t[12]=x):x=t[12];let S;t[13]!==s||t[14]!==n||t[15]!==r?(S=s&&(0,Z.jsxs)(uo,{children:[(0,Z.jsx)(so,{asChild:!0,children:(0,Z.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:n,disabled:r,className:`text-muted-foreground`,children:(0,Z.jsx)(nc,{className:`size-3.5`})})}),(0,Z.jsx)(co,{children:r?`Saving`:`Checkpoint version`})]}),t[13]=s,t[14]=n,t[15]=r,t[16]=S):S=t[16];let C;t[17]!==s||t[18]!==d?(C=s&&(0,Z.jsx)(KM,{input:d}),t[17]=s,t[18]=d,t[19]=C):C=t[19];let w;t[20]!==o||t[21]!==a||t[22]!==i?(w=(0,Z.jsx)(aN,{onSignIn:i,onSetIdentity:a,onOpenConflictResolver:o}),t[20]=o,t[21]=a,t[22]=i,t[23]=w):w=t[23];let T,E,D,O,k,A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(oM,{}),E=(0,Z.jsx)(Bi,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),D=(0,Z.jsx)(cu,{}),O=(0,Z.jsx)(qM,{}),k=(0,Z.jsx)(WM,{}),A=(0,Z.jsx)(sN,{}),t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A):(T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29]);let j;t[30]!==S||t[31]!==C||t[32]!==w?(j=(0,Z.jsxs)(`div`,{className:x,children:[S,C,w,T,E,D,O,k,A]}),t[30]=S,t[31]=C,t[32]=w,t[33]=j):j=t[33];let M;return t[34]!==j||t[35]!==m||t[36]!==b?(M=(0,Z.jsxs)(`header`,{className:m,children:[b,j]}),t[34]=j,t[35]=m,t[36]=b,t[37]=M):M=t[37],M}function uN(){let e=(0,$.c)(32),[t,n]=bm(),[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)(G_[0].id),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=da(),{projectLocalConfig:v,projectLocalSynced:y}=ba(),{activeDocName:b}=We(),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&&Lo(b,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(fm,e),()=>window.removeEventListener(fm,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?Xa.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Xa.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Xa.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)(Cm,{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)(lN,{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)(ej,{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)(Tg,{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)(ou,{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)(xm,{open:x,onResolved:R}),e[23]=x,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(lm,{}),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 dN=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
35
35
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
36
36
|
<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"/>
|
|
37
37
|
</symbol>
|