@inkeep/open-knowledge 0.5.0-beta.5 → 0.5.0-beta.7

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.
Files changed (38) hide show
  1. package/dist/assets/skills/open-knowledge/SKILL.md +1 -1
  2. package/dist/cli.mjs +7 -7
  3. package/dist/constants-BN9aqQSl.mjs +2 -0
  4. package/dist/{dist-Buq7uUK7.mjs → dist-B74wAiOa.mjs} +2 -2
  5. package/dist/{dist-C2XvqbzG.mjs → dist-BYmxMXZg.mjs} +3 -3
  6. package/dist/{dist-B-QGEbwX.mjs → dist-CvGFxT_a.mjs} +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/{init-i-jBgnJ2.mjs → init-CYYdmMOG.mjs} +3 -3
  9. package/dist/init-DjClxIN7.mjs +1 -0
  10. package/dist/loader-BhrK8nSo.mjs +1 -0
  11. package/dist/{loader-CnH9VoDJ.mjs → loader-CH-v-Qtm.mjs} +2 -2
  12. package/dist/preview-BdRvsNWW.mjs +1 -0
  13. package/dist/{preview-CCbpDues.mjs → preview-SlVh3iib.mjs} +2 -2
  14. package/dist/public/assets/{ActivityModeContent-baqsrxsY.js → ActivityModeContent-Ang-xhpW.js} +1 -1
  15. package/dist/public/assets/DocumentContext-CsF17uix.js +52 -0
  16. package/dist/public/assets/{GraphPanel-Bqt87S0c.js → GraphPanel-CoFwUyvg.js} +1 -1
  17. package/dist/public/assets/{SettingsDialog-D6nNBqeV.js → SettingsDialog-EgEf-NyI.js} +1 -1
  18. package/dist/public/assets/{SourceEditor-CJiFlEvK.js → SourceEditor-Bkzb4TXw.js} +1 -1
  19. package/dist/public/assets/{config-validation-events-CuJstsYS.js → config-validation-events-CKCKFSHM.js} +1 -1
  20. package/dist/public/assets/{doc-hash-D-COaeDG.js → doc-hash-BKGDaKGf.js} +1 -1
  21. package/dist/public/assets/{index-Bzh2wENQ.js → index-BZq8zfYI.js} +72 -72
  22. package/dist/public/assets/index-CJAlddOb.css +1 -0
  23. package/dist/public/assets/{target-navigation-intent-BebfMyQT.js → target-navigation-intent-C0xmUmXJ.js} +1 -1
  24. package/dist/public/assets/{toggle-group-B6Y5d2LH.js → toggle-group-BR-jgxRp.js} +1 -1
  25. package/dist/public/assets/{tooltip-Cn5mq_qc.js → tooltip-ByfPsJhp.js} +1 -1
  26. package/dist/public/assets/{typing-burst-detector-BizuT3zF.js → typing-burst-detector-BYx4IpkY.js} +1 -1
  27. package/dist/public/index.html +9 -9
  28. package/dist/{src-D_lB64Ap.mjs → src-_ZBGqS72.mjs} +2 -2
  29. package/dist/{start-CbyceAIT.mjs → start-CU6SWyyi.mjs} +2 -2
  30. package/dist/start-j7CIZwfc.mjs +1 -0
  31. package/package.json +1 -1
  32. package/dist/constants-B2q9_EXF.mjs +0 -2
  33. package/dist/init-Dpxl7-0c.mjs +0 -1
  34. package/dist/loader-mM5jGq2A.mjs +0 -1
  35. package/dist/preview-UJpuXEs3.mjs +0 -1
  36. package/dist/public/assets/DocumentContext-D4lHVgL4.js +0 -52
  37. package/dist/public/assets/index-BHqEYdAv.css +0 -1
  38. package/dist/start-Bo61NrI5.mjs +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ActivityPanelDiffView-EaCFURAu.js","./chunk-CFjPhJqf.js","./compiler-runtime-CVnuRdak.js","./ActivityPanelDiffView-legcy4jI.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{$ as a,Dn as o,On as s,dn as c,kn as l,n as u,r as d}from"./DocumentContext-D4lHVgL4.js";import{G as f,W as p,jt as m,p as h}from"./doc-hash-D-COaeDG.js";import{C as g,t as _}from"./button-C1nwPVFQ.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-BrTlNKmt.js";import{a as C,c as w,i as T,o as E,s as D,t as O,x as k}from"./dialog-CY2eQd6O.js";import{i as A,n as ee,t as te}from"./tooltip-Cn5mq_qc.js";var ne=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),j=i(),M=e(n(),1),re=500,ie=64;async function ae(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new a(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=m.safeParse(r);throw e.success?Error(e.data.title):new a(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=p.safeParse(r);if(!i.success)throw new a(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function oe(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),o;try{o=await i.json()}catch(e){throw new a(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=m.safeParse(o);throw e.success?Error(e.data.title):new a(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let s=f.safeParse(o);if(!s.success)throw new a(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:s.error,status:i.status});return s.data.diff}function se(e){let t=(0,j.c)(23),{systemProvider:n}=u(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(`idle`),[s,c]=(0,M.useState)(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new y(ie),t[0]=l):l=t[0];let d=(0,M.useRef)(l),f=(0,M.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),ae(e).then(r=>{if(f.current!==t)return;let a=le(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(c(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let m=p,g;t[3]!==e||t[4]!==m?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=h(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},re))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,M.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=le(n,e);i(e=>!e||ce(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,M.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await oe(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==m?(C=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==s||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:s,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=s,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function ce(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function le(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var N=r(),ue=(0,M.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-EaCFURAu.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function de(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function fe(e){let t=(0,j.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[a,o]=(0,M.useState)(!1),[c,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(P),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,M.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==a||t[6]!==i||t[7]!==p?(y=()=>{let e=!a;o(e),e&&c===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{u(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=a,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${a?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===a?S=t[10]:(S=a?(0,N.jsx)(l,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,N.jsx)(s,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=a,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=de(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,N.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,N.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==a||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,N.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":a,"aria-label":x,children:[S,w,D]}),t[23]=a,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==c||t[31]!==a||t[32]!==d||t[33]!==p?(k=a?(0,N.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}):d?(0,N.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):c===null?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}),children:(0,N.jsx)(ue,{diff:c})})}):null,t[30]=c,t[31]=a,t[32]=d,t[33]=p,t[34]=k):k=t[34];let A;return t[35]!==O||t[36]!==k?(A=(0,N.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37],A}function P(){return Date.now()}function pe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function F(e){let t=(0,j.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:a,onUndoLast:o,onUndoAll:c,fetchBurstDiff:u}=e,[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[y,b]=(0,M.useState)(he),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,M.useEffect)(x,S),n.bursts.length===0)return null;let k=!r||n.bursts.length===0||h,re=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ie;t[2]!==k||t[3]!==n.docName||t[4]!==o?(ie=e=>{e.stopPropagation(),!k&&(g(!0),Promise.resolve(o(n.docName)).finally(()=>g(!1)))},t[2]=k,t[3]=n.docName,t[4]=o,t[5]=ie):ie=t[5];let ae=ie,oe;t[6]===k?oe=t[7]:(oe=e=>{e.stopPropagation(),!k&&m(!0)},t[6]=k,t[7]=oe);let se=oe,ce;t[8]!==k||t[9]!==n.docName||t[10]!==c?(ce=()=>{m(!1),!k&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[8]=k,t[9]=n.docName,t[10]=c,t[11]=ce):ce=t[11];let le=ce,ue;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>f(me),t[12]=ue):ue=t[12];let de=d?`Collapse ${n.docName}`:`Expand ${n.docName}`,P;t[13]===d?P=t[14]:(P=d?(0,N.jsx)(l,{className:`size-4`,"aria-hidden":`true`}):(0,N.jsx)(s,{className:`size-4`,"aria-hidden":`true`}),t[13]=d,t[14]=P);let F;t[15]!==d||t[16]!==de||t[17]!==P?(F=(0,N.jsx)(`button`,{type:`button`,onClick:ue,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":d,"aria-label":de,"data-testid":`activity-panel-file-row-carrot`,children:P}),t[15]=d,t[16]=de,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==n.docName||t[20]!==a?(I=()=>a(n.docName),t[19]=n.docName,t[20]=a,t[21]=I):I=t[21];let ge=`Navigate to ${n.docName}`,L;t[22]!==n.docName||t[23]!==I||t[24]!==ge?(L=(0,N.jsx)(`button`,{type:`button`,onClick:I,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":ge,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=I,t[24]=ge,t[25]=L):L=t[25];let _e=`Undo last edit on ${n.docName}`,ve;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ve):ve=t[26];let R;t[27]!==k||t[28]!==ae||t[29]!==_e?(R=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ae,disabled:k,"aria-label":_e,"data-testid":`activity-panel-undo-last`,children:ve})}),t[27]=k,t[28]=ae,t[29]=_e,t[30]=R):R=t[30];let ye=re??`Undo last edit`,z;t[31]===ye?z=t[32]:(z=(0,N.jsx)(ee,{side:`bottom`,children:ye}),t[31]=ye,t[32]=z);let B;t[33]!==R||t[34]!==z?(B=(0,N.jsxs)(te,{children:[R,z]}),t[33]=R,t[34]=z,t[35]=B):B=t[35];let be=`Undo all edits on ${n.docName}`,xe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(ne,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=xe):xe=t[36];let V;t[37]!==k||t[38]!==se||t[39]!==be?(V=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:se,disabled:k,"aria-label":be,"data-testid":`activity-panel-undo-all`,children:xe})}),t[37]=k,t[38]=se,t[39]=be,t[40]=V):V=t[40];let Se=re??`Undo all edits`,H;t[41]===Se?H=t[42]:(H=(0,N.jsx)(ee,{side:`bottom`,children:Se}),t[41]=Se,t[42]=H);let U;t[43]!==V||t[44]!==H?(U=(0,N.jsxs)(te,{children:[V,H]}),t[43]=V,t[44]=H,t[45]=U):U=t[45];let W;t[46]===n.additionsTotal?W=t[47]:(W=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=W);let G;t[48]===n.deletionsTotal?G=t[49]:(G=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=G);let K;t[50]!==W||t[51]!==G?(K=(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[W,` `,G]}),t[50]=W,t[51]=G,t[52]=K):K=t[52];let q;t[53]!==n.lastTs||t[54]!==y?(q=pe(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=q):q=t[55];let J;t[56]===q?J=t[57]:(J=(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:q}),t[56]=q,t[57]=J);let Y;t[58]===i?Y=t[59]:(Y=i?(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing`}):null,t[58]=i,t[59]=Y);let X;t[60]!==L||t[61]!==B||t[62]!==U||t[63]!==K||t[64]!==J||t[65]!==Y||t[66]!==F?(X=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[F,L,B,U,K,J,Y]}),t[60]=L,t[61]=B,t[62]=U,t[63]=K,t[64]=J,t[65]=Y,t[66]=F,t[67]=X):X=t[67];let Z;t[68]!==d||t[69]!==u||t[70]!==n.bursts||t[71]!==n.docName?(Z=d?(0,N.jsx)(`div`,{children:n.bursts.map(e=>(0,N.jsx)(fe,{burst:e,docName:n.docName,fetchBurstDiff:u},`${n.docName}:${e.stackIndex}`))}):null,t[68]=d,t[69]=u,t[70]=n.bursts,t[71]=n.docName,t[72]=Z):Z=t[72];let Ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,N.jsx)(w,{children:`Undo all edits on this file?`}),t[73]=Ce):Ce=t[73];let Q;t[74]===n.docName?Q=t[75]:(Q=(0,N.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Q);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Q||t[78]!==we?(Te=(0,N.jsxs)(D,{children:[Ce,(0,N.jsxs)(C,{children:[`This will revert every change this agent has made to`,` `,Q,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Q,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,N.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===le?De=t[82]:(De=(0,N.jsxs)(E,{children:[Ee,(0,N.jsx)(_,{type:`button`,variant:`destructive`,onClick:le,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=le,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,N.jsxs)(T,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==p||t[87]!==Oe?($=(0,N.jsx)(O,{open:p,onOpenChange:m,children:Oe}),t[86]=p,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==X||t[90]!==Z||t[91]!==$?(ke=(0,N.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[X,Z,$]}),t[89]=X,t[90]=Z,t[91]=$,t[92]=ke):ke=t[92],ke}function me(e){return!e}function he(){return Date.now()}async function I(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function ge(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function L(e){typeof window>`u`||(window.location.hash=ge(e))}function _e(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,N.jsx)(c,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity`})]}),e[0]=t):t=e[0],t}function ve(e){let t=(0,j.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(o,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let s;t[2]===n?s=t[3]:(s=(0,N.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,N.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function R(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,N.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function ye(e){let t=(0,j.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,N.jsx)(z,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function z(e){let t=(0,j.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(ee,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,N.jsxs)(te,{children:[i,a]}),t[4]=i,t[5]=o),o}function B(e){let t=(0,j.c)(9),{lastTs:n}=e,[r]=(0,M.useState)(be),i;t[0]!==n||t[1]!==r?(i=n?xe(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,N.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,N.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=l),l}function be(){return Date.now()}function xe(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function V(e){let t=(0,j.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,N.jsx)(x,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,N.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Se(e){let t=(0,j.c)(20),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,N.jsx)(z,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]===n?p=t[3]:(p=n?.agent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{agent:n.agent}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,N.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,N.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,N.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]!==n||t[8]!==i||t[9]!==o||t[10]!==d||t[11]!==c||t[12]!==u||t[13]!==l||t[14]!==a||t[15]!==r?(h=(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,N.jsx)(_e,{}):r===`error`&&i?(0,N.jsx)(ve,{error:i,onRetry:a}):n===null?(0,N.jsx)(R,{}):(0,N.jsxs)(N.Fragment,{children:[n.sessionAlive?null:(0,N.jsx)(B,{lastTs:d}),n.files.length===0?(0,N.jsx)(R,{}):n.files.map(e=>(0,N.jsx)(F,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[7]=n,t[8]=i,t[9]=o,t[10]=d,t[11]=c,t[12]=u,t[13]=l,t[14]=a,t[15]=r,t[16]=h):h=t[16];let g;return t[17]!==m||t[18]!==h?(g=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function H(){let e=(0,j.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=u(),{openDocumentTransition:r}=d(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=se(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,N.jsx)(ye,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),L(e)},e[2]=r,e[3]=l);let f=l,p;e[4]!==i||e[5]!==t||e[6]!==s?(p=async e=>{try{await I({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await I({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),k.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==s||e[20]!==a?(_=(0,N.jsx)(Se,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=f,e[17]=g,e[18]=m,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{H as ActivityModeContent};
2
+ import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./preload-helper-2ej06EnG.js";import{n,r,t as i}from"./compiler-runtime-CVnuRdak.js";import{$ as a,Dn as o,On as s,dn as c,kn as l,n as u,r as d}from"./DocumentContext-CsF17uix.js";import{G as f,W as p,jt as m,p as h}from"./doc-hash-BKGDaKGf.js";import{C as g,t as _}from"./button-C1nwPVFQ.js";import{f as v,i as y,m as b,r as x,t as S}from"./agent-presence-BrTlNKmt.js";import{a as C,c as w,i as T,o as E,s as D,t as O,x as k}from"./dialog-CY2eQd6O.js";import{i as A,n as ee,t as te}from"./tooltip-ByfPsJhp.js";var ne=g(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),j=i(),M=e(n(),1),re=500,ie=64;async function ae(e){let t=`/api/agent-activity?agentId=${encodeURIComponent(e)}`,n=await fetch(t),r;try{r=await n.json()}catch(e){throw new a(`Could not parse /api/agent-activity response.`,{cause:e,status:n.status})}if(!n.ok){let e=m.safeParse(r);throw e.success?Error(e.data.title):new a(`/api/agent-activity returned a non-RFC-9457 error response.`,{cause:e.error,status:n.status})}let i=p.safeParse(r);if(!i.success)throw new a(`/api/agent-activity returned a body that did not match AgentActivitySuccessSchema.`,{cause:i.error,status:n.status});return i.data}async function oe(e,t,n){let r=`/api/agent-burst-diff?agentId=${encodeURIComponent(e)}&docName=${encodeURIComponent(t)}&stackIndex=${n}`,i=await fetch(r),o;try{o=await i.json()}catch(e){throw new a(`Could not parse /api/agent-burst-diff response.`,{cause:e,status:i.status})}if(!i.ok){let e=m.safeParse(o);throw e.success?Error(e.data.title):new a(`/api/agent-burst-diff returned a non-RFC-9457 error response.`,{cause:e.error,status:i.status})}let s=f.safeParse(o);if(!s.success)throw new a(`/api/agent-burst-diff returned a body that did not match AgentBurstDiffSuccessSchema.`,{cause:s.error,status:i.status});return s.data.diff}function se(e){let t=(0,j.c)(23),{systemProvider:n}=u(),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(`idle`),[s,c]=(0,M.useState)(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new y(ie),t[0]=l):l=t[0];let d=(0,M.useRef)(l),f=(0,M.useRef)(0),p;t[1]===n?p=t[2]:(p=e=>{let t=f.current+=1;o(`loading`),c(null),ae(e).then(r=>{if(f.current!==t)return;let a=le(n,e);i({...r,writingDocs:a}),o(`ready`)}).catch(e=>{f.current===t&&(c(e instanceof Error?e.message:String(e)),o(`error`))})},t[1]=n,t[2]=p);let m=p,g;t[3]!==e||t[4]!==m?(g=()=>{if(!e){f.current+=1,i(null),o(`idle`),c(null),d.current.clear();return}d.current.clear(),m(e);let t=null,n=h(n=>{n.includes(`session-activity`)&&(t&&clearTimeout(t),t=setTimeout(()=>{t=null,m(e)},re))});return()=>{t&&clearTimeout(t),n()}},t[3]=e,t[4]=m,t[5]=g):g=t[5];let _;t[6]===e?_=t[7]:(_=[e],t[6]=e,t[7]=_),(0,M.useEffect)(g,_);let v,b;t[8]!==e||t[9]!==n?(v=()=>{if(!e||!n)return;let t=()=>{if(!n.awareness)return;let t=le(n,e);i(e=>!e||ce(e.writingDocs,t)?e:{...e,writingDocs:t})},r=n.awareness;if(!r||typeof r.on!=`function`){t();return}r.on(`update`,t),t();let a=setInterval(t,1e3);return()=>{clearInterval(a),typeof r.off==`function`&&r.off(`update`,t)}},b=[e,n],t[8]=e,t[9]=n,t[10]=v,t[11]=b):(v=t[10],b=t[11]),(0,M.useEffect)(v,b);let x;t[12]===e?x=t[13]:(x=async(t,n)=>{if(!e)return``;let r=`${t}\0${n}`,i=d.current.get(r);if(i!==void 0)return i;let a=await oe(e,t,n);return d.current.set(r,a),a},t[12]=e,t[13]=x);let S=x,C;t[14]!==e||t[15]!==m?(C=()=>{e&&m(e)},t[14]=e,t[15]=m,t[16]=C):C=t[16];let w=C,T;return t[17]!==r||t[18]!==s||t[19]!==S||t[20]!==w||t[21]!==a?(T={data:r,status:a,error:s,reload:w,fetchBurstDiff:S},t[17]=r,t[18]=s,t[19]=S,t[20]=w,t[21]=a,t[22]=T):T=t[22],T}function ce(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function le(e,t){let n=new Set;if(!e)return n;let r=e.awareness;if(!S(r))return n;let i=[t,t.startsWith(`agent-`)?t.slice(6):`agent-${t}`];for(let e of r.getStates().values()){let t=e.agentPresence;if(t)for(let e of i){let r=t[e];r&&r.mode===`writing`&&r.currentDoc&&n.add(r.currentDoc)}}return n}var N=r(),ue=(0,M.lazy)(async()=>({default:(await t(()=>import(`./ActivityPanelDiffView-EaCFURAu.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).ActivityPanelDiffView}));function de(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function fe(e){let t=(0,j.c)(38),{burst:n,docName:r,fetchBurstDiff:i}=e,[a,o]=(0,M.useState)(!1),[c,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(P),_,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval(e)},v=[],t[0]=_,t[1]=v):(_=t[0],v=t[1]),(0,M.useEffect)(_,v);let y;t[2]!==n.stackIndex||t[3]!==c||t[4]!==r||t[5]!==a||t[6]!==i||t[7]!==p?(y=()=>{let e=!a;o(e),e&&c===null&&!p&&(m(!0),f(null),i(r,n.stackIndex).then(e=>{u(e),m(!1)}).catch(e=>{f(e instanceof Error?e.message:String(e)),m(!1)}))},t[2]=n.stackIndex,t[3]=c,t[4]=r,t[5]=a,t[6]=i,t[7]=p,t[8]=y):y=t[8];let b=y,x=`${a?`Collapse`:`Expand`} burst ${n.stackIndex+1} diff`,S;t[9]===a?S=t[10]:(S=a?(0,N.jsx)(l,{className:`size-3 shrink-0`,"aria-hidden":`true`}):(0,N.jsx)(s,{className:`size-3 shrink-0`,"aria-hidden":`true`}),t[9]=a,t[10]=S);let C;t[11]!==n.ts||t[12]!==h?(C=de(n.ts,h),t[11]=n.ts,t[12]=h,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,N.jsx)(`span`,{className:`font-mono`,children:C}),t[14]=C,t[15]=w);let T;t[16]===n.additions?T=t[17]:(T=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additions]}),t[16]=n.additions,t[17]=T);let E;t[18]===n.deletions?E=t[19]:(E=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletions]}),t[18]=n.deletions,t[19]=E);let D;t[20]!==T||t[21]!==E?(D=(0,N.jsxs)(`span`,{className:`ml-auto font-mono`,children:[T,` `,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;t[23]!==a||t[24]!==D||t[25]!==x||t[26]!==S||t[27]!==w||t[28]!==b?(O=(0,N.jsxs)(`button`,{type:`button`,onClick:b,className:`flex w-full items-center gap-2 px-4 py-1.5 text-xs text-muted-foreground hover:bg-muted/40`,"aria-expanded":a,"aria-label":x,children:[S,w,D]}),t[23]=a,t[24]=D,t[25]=x,t[26]=S,t[27]=w,t[28]=b,t[29]=O):O=t[29];let k;t[30]!==c||t[31]!==a||t[32]!==d||t[33]!==p?(k=a?(0,N.jsx)(`div`,{className:`bg-muted/20`,children:p?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}):d?(0,N.jsxs)(`div`,{className:`px-4 py-2 text-xs text-destructive`,children:[`Failed: `,d]}):c===null?(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`No diff.`}):(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`px-4 py-2 text-xs text-muted-foreground italic`,children:`Loading diff`}),children:(0,N.jsx)(ue,{diff:c})})}):null,t[30]=c,t[31]=a,t[32]=d,t[33]=p,t[34]=k):k=t[34];let A;return t[35]!==O||t[36]!==k?(A=(0,N.jsxs)(`div`,{className:`border-t border-border/50`,children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37],A}function P(){return Date.now()}function pe(e,t){let n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function F(e){let t=(0,j.c)(93),{file:n,sessionAlive:r,isWriting:i,onNavigate:a,onUndoLast:o,onUndoAll:c,fetchBurstDiff:u}=e,[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[y,b]=(0,M.useState)(he),x,S;if(t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(e)},S=[],t[0]=x,t[1]=S):(x=t[0],S=t[1]),(0,M.useEffect)(x,S),n.bursts.length===0)return null;let k=!r||n.bursts.length===0||h,re=r?n.bursts.length===0?`Nothing to undo on this file`:null:`Session ended — undo unavailable`,ie;t[2]!==k||t[3]!==n.docName||t[4]!==o?(ie=e=>{e.stopPropagation(),!k&&(g(!0),Promise.resolve(o(n.docName)).finally(()=>g(!1)))},t[2]=k,t[3]=n.docName,t[4]=o,t[5]=ie):ie=t[5];let ae=ie,oe;t[6]===k?oe=t[7]:(oe=e=>{e.stopPropagation(),!k&&m(!0)},t[6]=k,t[7]=oe);let se=oe,ce;t[8]!==k||t[9]!==n.docName||t[10]!==c?(ce=()=>{m(!1),!k&&(g(!0),Promise.resolve(c(n.docName)).finally(()=>g(!1)))},t[8]=k,t[9]=n.docName,t[10]=c,t[11]=ce):ce=t[11];let le=ce,ue;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>f(me),t[12]=ue):ue=t[12];let de=d?`Collapse ${n.docName}`:`Expand ${n.docName}`,P;t[13]===d?P=t[14]:(P=d?(0,N.jsx)(l,{className:`size-4`,"aria-hidden":`true`}):(0,N.jsx)(s,{className:`size-4`,"aria-hidden":`true`}),t[13]=d,t[14]=P);let F;t[15]!==d||t[16]!==de||t[17]!==P?(F=(0,N.jsx)(`button`,{type:`button`,onClick:ue,className:`flex size-5 shrink-0 items-center justify-center rounded hover:bg-muted`,"aria-expanded":d,"aria-label":de,"data-testid":`activity-panel-file-row-carrot`,children:P}),t[15]=d,t[16]=de,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==n.docName||t[20]!==a?(I=()=>a(n.docName),t[19]=n.docName,t[20]=a,t[21]=I):I=t[21];let ge=`Navigate to ${n.docName}`,L;t[22]!==n.docName||t[23]!==I||t[24]!==ge?(L=(0,N.jsx)(`button`,{type:`button`,onClick:I,className:`min-w-0 flex-1 truncate text-left text-foreground hover:underline focus-visible:outline-ring`,"aria-label":ge,"data-testid":`activity-panel-file-row-filename`,title:n.docName,children:n.docName}),t[22]=n.docName,t[23]=I,t[24]=ge,t[25]=L):L=t[25];let _e=`Undo last edit on ${n.docName}`,ve;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,N.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),t[26]=ve):ve=t[26];let R;t[27]!==k||t[28]!==ae||t[29]!==_e?(R=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:ae,disabled:k,"aria-label":_e,"data-testid":`activity-panel-undo-last`,children:ve})}),t[27]=k,t[28]=ae,t[29]=_e,t[30]=R):R=t[30];let ye=re??`Undo last edit`,z;t[31]===ye?z=t[32]:(z=(0,N.jsx)(ee,{side:`bottom`,children:ye}),t[31]=ye,t[32]=z);let B;t[33]!==R||t[34]!==z?(B=(0,N.jsxs)(te,{children:[R,z]}),t[33]=R,t[34]=z,t[35]=B):B=t[35];let be=`Undo all edits on ${n.docName}`,xe;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,N.jsx)(ne,{className:`size-3.5`,"aria-hidden":`true`}),t[36]=xe):xe=t[36];let V;t[37]!==k||t[38]!==se||t[39]!==be?(V=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6 shrink-0`,onClick:se,disabled:k,"aria-label":be,"data-testid":`activity-panel-undo-all`,children:xe})}),t[37]=k,t[38]=se,t[39]=be,t[40]=V):V=t[40];let Se=re??`Undo all edits`,H;t[41]===Se?H=t[42]:(H=(0,N.jsx)(ee,{side:`bottom`,children:Se}),t[41]=Se,t[42]=H);let U;t[43]!==V||t[44]!==H?(U=(0,N.jsxs)(te,{children:[V,H]}),t[43]=V,t[44]=H,t[45]=U):U=t[45];let W;t[46]===n.additionsTotal?W=t[47]:(W=(0,N.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,n.additionsTotal]}),t[46]=n.additionsTotal,t[47]=W);let G;t[48]===n.deletionsTotal?G=t[49]:(G=(0,N.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,n.deletionsTotal]}),t[48]=n.deletionsTotal,t[49]=G);let K;t[50]!==W||t[51]!==G?(K=(0,N.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[W,` `,G]}),t[50]=W,t[51]=G,t[52]=K):K=t[52];let q;t[53]!==n.lastTs||t[54]!==y?(q=pe(n.lastTs,y),t[53]=n.lastTs,t[54]=y,t[55]=q):q=t[55];let J;t[56]===q?J=t[57]:(J=(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:q}),t[56]=q,t[57]=J);let Y;t[58]===i?Y=t[59]:(Y=i?(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] text-primary animate-pulse`,role:`status`,children:`writing`}):null,t[58]=i,t[59]=Y);let X;t[60]!==L||t[61]!==B||t[62]!==U||t[63]!==K||t[64]!==J||t[65]!==Y||t[66]!==F?(X=(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,children:[F,L,B,U,K,J,Y]}),t[60]=L,t[61]=B,t[62]=U,t[63]=K,t[64]=J,t[65]=Y,t[66]=F,t[67]=X):X=t[67];let Z;t[68]!==d||t[69]!==u||t[70]!==n.bursts||t[71]!==n.docName?(Z=d?(0,N.jsx)(`div`,{children:n.bursts.map(e=>(0,N.jsx)(fe,{burst:e,docName:n.docName,fetchBurstDiff:u},`${n.docName}:${e.stackIndex}`))}):null,t[68]=d,t[69]=u,t[70]=n.bursts,t[71]=n.docName,t[72]=Z):Z=t[72];let Ce;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,N.jsx)(w,{children:`Undo all edits on this file?`}),t[73]=Ce):Ce=t[73];let Q;t[74]===n.docName?Q=t[75]:(Q=(0,N.jsx)(`span`,{className:`font-mono text-foreground`,children:n.docName}),t[74]=n.docName,t[75]=Q);let we=n.bursts.length===1?``:`s`,Te;t[76]!==n.bursts.length||t[77]!==Q||t[78]!==we?(Te=(0,N.jsxs)(D,{children:[Ce,(0,N.jsxs)(C,{children:[`This will revert every change this agent has made to`,` `,Q,` in their current session (`,n.bursts.length,` burst`,we,`). Other files and other writers are not affected.`]})]}),t[76]=n.bursts.length,t[77]=Q,t[78]=we,t[79]=Te):Te=t[79];let Ee;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,N.jsx)(_,{type:`button`,variant:`outline`,onClick:()=>m(!1),"data-testid":`activity-panel-undo-all-cancel`,children:`Cancel`}),t[80]=Ee):Ee=t[80];let De;t[81]===le?De=t[82]:(De=(0,N.jsxs)(E,{children:[Ee,(0,N.jsx)(_,{type:`button`,variant:`destructive`,onClick:le,"data-testid":`activity-panel-undo-all-confirm`,children:`Undo all`})]}),t[81]=le,t[82]=De);let Oe;t[83]!==Te||t[84]!==De?(Oe=(0,N.jsxs)(T,{className:`sm:max-w-md`,children:[Te,De]}),t[83]=Te,t[84]=De,t[85]=Oe):Oe=t[85];let $;t[86]!==p||t[87]!==Oe?($=(0,N.jsx)(O,{open:p,onOpenChange:m,children:Oe}),t[86]=p,t[87]=Oe,t[88]=$):$=t[88];let ke;return t[89]!==X||t[90]!==Z||t[91]!==$?(ke=(0,N.jsxs)(`div`,{className:`border-b border-border`,"data-testid":`activity-panel-file-row`,children:[X,Z,$]}),t[89]=X,t[90]=Z,t[91]=$,t[92]=ke):ke=t[92],ke}function me(e){return!e}function he(){return Date.now()}async function I(e){let t=await fetch(`/api/agent-undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,agentId:e.connectionId})});if(!t.ok)throw Error(`agent-undo failed: HTTP ${t.status}`)}function ge(e){return`#/${e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function L(e){typeof window>`u`||(window.location.hash=ge(e))}function _e(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsxs)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,role:`status`,"aria-busy":`true`,children:[(0,N.jsx)(c,{className:`mr-2 size-4 animate-spin`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`text-sm`,children:`Loading agent activity`})]}),e[0]=t):t=e[0],t}function ve(e){let t=(0,j.c)(9),{error:n,onRetry:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(o,{className:`size-6 text-destructive`,"aria-hidden":`true`}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(`p`,{className:`text-sm font-medium`,children:`Failed to load activity`}),t[1]=a):a=t[1];let s;t[2]===n?s=t[3]:(s=(0,N.jsxs)(`div`,{className:`space-y-1`,children:[a,(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=(0,N.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`}),t[4]=r,t[5]=c);let l;return t[6]!==s||t[7]!==c?(l=(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-6 text-center`,role:`alert`,"data-testid":`activity-panel-error`,children:[i,s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l}function R(){let e=(0,j.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-muted-foreground`,"data-testid":`activity-panel-empty`,children:(0,N.jsx)(`p`,{className:`text-sm italic`,children:`No edits yet.`})}),e[0]=t):t=e[0],t}function ye(e){let t=(0,j.c)(8),{onExit:n}=e,r;t[0]===n?r=t[1]:(r=(0,N.jsx)(z,{onClick:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`}),t[2]=i):i=t[2];let a;t[3]===r?a=t[4]:(a=(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-row items-center gap-2 border-b border-border px-3 py-2`,children:[r,i]}),t[3]=r,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-center text-sm italic`,children:`Click an agent's avatar in the presence bar to view their session.`})}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel-no-agent`,"aria-label":`Agent activity`,children:[a,o]}),t[6]=a,t[7]=s),s}function z(e){let t=(0,j.c)(6),{onClick:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,N.jsx)(b,{}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,N.jsx)(A,{asChild:!0,children:(0,N.jsx)(_,{type:`button`,variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,onClick:n,"aria-label":`Back to document view`,"data-testid":`docpanel-exit-agent-mode`,children:r})}),t[1]=n,t[2]=i);let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(ee,{side:`bottom`,children:`Back to document view`}),t[3]=a):a=t[3];let o;return t[4]===i?o=t[5]:(o=(0,N.jsxs)(te,{children:[i,a]}),t[4]=i,t[5]=o),o}function B(e){let t=(0,j.c)(9),{lastTs:n}=e,[r]=(0,M.useState)(be),i;t[0]!==n||t[1]!==r?(i=n?xe(r-n):null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsx)(`span`,{className:`font-medium`,children:`Session ended`}),t[3]=o):o=t[3];let s;t[4]===a?s=t[5]:(s=a?(0,N.jsxs)(`span`,{children:[` · `,a]}):null,t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,N.jsx)(`div`,{className:`mt-1 opacity-80`,children:`Undo buttons are disabled — per-session state has been garbage-collected.`}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,N.jsxs)(`div`,{className:`border-b border-border bg-muted/40 px-4 py-3 text-xs text-muted-foreground`,"data-testid":`activity-panel-session-ended`,children:[o,s,c]}),t[7]=s,t[8]=l),l}function be(){return Date.now()}function xe(e){let t=Math.max(0,e);return t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function V(e){let t=(0,j.c)(10),{agent:n,size:r}=e,i=r===void 0?28:r,a;t[0]!==n.color||t[1]!==i?(a={backgroundColor:n.color,width:i,height:i},t[0]=n.color,t[1]=i,t[2]=a):a=t[2];let o=i*.57,s=i*.57,c;t[3]!==n.icon||t[4]!==o||t[5]!==s?(c=(0,N.jsx)(x,{icon:n.icon,width:o,height:s}),t[3]=n.icon,t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==c?(l=(0,N.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-full text-white ring-2 ring-background`,style:a,"aria-hidden":`true`,children:c}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function Se(e){let t=(0,j.c)(21),{data:n,status:r,error:i,reload:a,fetchBurstDiff:o,onExit:s,onNavigate:c,onUndoLast:l,onUndoAll:u}=e,d=n?.files?.[0]?.lastTs??null,f;t[0]===s?f=t[1]:(f=(0,N.jsx)(z,{onClick:s}),t[0]=s,t[1]=f);let p;t[2]!==n||t[3]!==d?(p=n?.agent?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{agent:n.agent}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:n.agent.displayName}),(0,N.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[n.sessionAlive?`Active`:d===null?`No edit session yet`:`Ended`,n.files.length>0?` · ${n.files.length} file${n.files.length===1?``:`s`}`:``]})]})]}):(0,N.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,N.jsx)(`h2`,{className:`truncate text-sm font-medium`,children:`Agent activity`})}),t[2]=n,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==p?(m=(0,N.jsxs)(`div`,{className:`flex flex-row items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[f,p]}),t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==i||t[10]!==o||t[11]!==d||t[12]!==c||t[13]!==u||t[14]!==l||t[15]!==a||t[16]!==r?(h=(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`activity-panel-body`,children:r===`loading`&&n===null?(0,N.jsx)(_e,{}):r===`error`&&i?(0,N.jsx)(ve,{error:i,onRetry:a}):n===null?(0,N.jsx)(R,{}):(0,N.jsxs)(N.Fragment,{children:[!n.sessionAlive&&d!==null?(0,N.jsx)(B,{lastTs:d}):null,n.files.length===0?(0,N.jsx)(R,{}):n.files.map(e=>(0,N.jsx)(F,{file:e,sessionAlive:n.sessionAlive,isWriting:n.writingDocs.has(e.docName),onNavigate:c,onUndoLast:l,onUndoAll:u,fetchBurstDiff:o},e.docName))]})}),t[8]=n,t[9]=i,t[10]=o,t[11]=d,t[12]=c,t[13]=u,t[14]=l,t[15]=a,t[16]=r,t[17]=h):h=t[17];let g;return t[18]!==m||t[19]!==h?(g=(0,N.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`activity-panel`,"aria-label":`Agent activity`,children:[m,h]}),t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function H(){let e=(0,j.c)(22),{docPanelAgentId:t,closeActivityPanel:n}=u(),{openDocumentTransition:r}=d(),{data:i,status:a,error:o,reload:s,fetchBurstDiff:c}=se(t);if(t===null){let t;return e[0]===n?t=e[1]:(t=(0,N.jsx)(ye,{onExit:n}),e[0]=n,e[1]=t),t}let l;e[2]===r?l=e[3]:(l=e=>{r(e),L(e)},e[2]=r,e[3]=l);let f=l,p;e[4]!==i||e[5]!==t||e[6]!==s?(p=async e=>{try{await I({connectionId:t,docName:e,scope:`last`,agentName:i?.agent?.displayName}),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo failed: ${n}`),s()}},e[4]=i,e[5]=t,e[6]=s,e[7]=p):p=e[7];let m=p,h;e[8]!==i||e[9]!==t||e[10]!==s?(h=async e=>{try{await I({connectionId:t,docName:e,scope:`file`,agentName:i?.agent?.displayName}),k.success(`Undone all edits on ${e}`),s()}catch(e){let t=e,n=t instanceof Error?t.message:String(t);k.error(`Undo all failed: ${n}`),s()}},e[8]=i,e[9]=t,e[10]=s,e[11]=h):h=e[11];let g=h,_;return e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==c||e[16]!==f||e[17]!==g||e[18]!==m||e[19]!==s||e[20]!==a?(_=(0,N.jsx)(Se,{data:i,status:a,error:o,reload:s,fetchBurstDiff:c,onExit:n,onNavigate:f,onUndoLast:m,onUndoAll:g}),e[12]=n,e[13]=i,e[14]=o,e[15]=c,e[16]=f,e[17]=g,e[18]=m,e[19]=s,e[20]=a,e[21]=_):_=e[21],_}export{H as ActivityModeContent};