cogpit 3.5.1 → 3.5.3

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 (90) hide show
  1. package/dist/cli-runtime.js +39279 -35071
  2. package/dist/instance-worker.js +1206 -154
  3. package/dist/web/assets/AutomationsPanel-D7XmgTgZ.js +1 -0
  4. package/dist/web/assets/{CogpitBlock-ZgOubpsS.js → CogpitBlock-CiS2M1Q_.js} +16 -16
  5. package/dist/web/assets/CommandPaletteHost-Dj06VjlP.js +1 -0
  6. package/dist/web/assets/ConfigBrowser-DqQo1F4o.js +1 -0
  7. package/dist/web/assets/CrewPanel-DzLPmS6o.js +1 -0
  8. package/dist/web/assets/HighlightedEditor-DPrSCx1c.js +2 -0
  9. package/dist/web/assets/KeyboardShortcutsDialog-BdXPWBJw.js +1 -0
  10. package/dist/web/assets/MissionHome-CTcx5vR7.js +2 -0
  11. package/dist/web/assets/MobileFileChanges-Ngv9AlhR.js +1 -0
  12. package/dist/web/assets/PluginsDialog-CWRSNNll.js +1 -0
  13. package/dist/web/assets/PreviewPanel-CQcJIdef.js +1 -0
  14. package/dist/web/assets/ProjectFilesPanel-D5EKIBD7.js +4 -0
  15. package/dist/web/assets/ProjectSwitcherModal-BoSCOiv9.js +1 -0
  16. package/dist/web/assets/{TerminalOutput-DOX29EmA.js → TerminalOutput-DYZJD2WR.js} +3 -3
  17. package/dist/web/assets/ThemeSelectorModal-8sO11Ob-.js +1 -0
  18. package/dist/web/assets/WorkflowsPanel-qv6TkN7g.js +1 -0
  19. package/dist/web/assets/WorktreePanel-Dr82TWOP.js +1 -0
  20. package/dist/web/assets/{bash-Yzrsuije.js → bash-DgJyDXW6.js} +1 -1
  21. package/dist/web/assets/{c-BIGW1oBm.js → c-BG-tZi7o.js} +1 -1
  22. package/dist/web/assets/cpp-BzPMphJ4.js +1 -0
  23. package/dist/web/assets/{css-DPfMkruS.js → css-PZBBrkI0.js} +1 -1
  24. package/dist/web/assets/edition-ui-DQHX5fm4.js +2 -0
  25. package/dist/web/assets/github-dark-BQV5ugrc.js +1 -0
  26. package/dist/web/assets/github-light-Rcb2q3L5.js +1 -0
  27. package/dist/web/assets/{go-CxLEBnE3.js → go-BBr2UQCn.js} +1 -1
  28. package/dist/web/assets/{html-GMplVEZG.js → html-DOf0XnR2.js} +1 -1
  29. package/dist/web/assets/index-BGSPI7dK.js +1 -0
  30. package/dist/web/assets/index-BVmNox_3.js +504 -0
  31. package/dist/web/assets/index-CHtH7TlZ.js +2 -0
  32. package/dist/web/assets/index-DKDki7Rz.css +1 -0
  33. package/dist/web/assets/index-DU4gWgPu.js +3 -0
  34. package/dist/web/assets/{index-By5-_P50.js → index-zhwBlO_8.js} +4 -4
  35. package/dist/web/assets/{java-CylS5w8V.js → java-BTDmaRNO.js} +1 -1
  36. package/dist/web/assets/{javascript-wDzz0qaB.js → javascript-WyGyM1wV.js} +1 -1
  37. package/dist/web/assets/{json-Cp-IABpG.js → json-B8JryHcM.js} +1 -1
  38. package/dist/web/assets/{jsx-g9-lgVsj.js → jsx-8cLv2Six.js} +1 -1
  39. package/dist/web/assets/{kotlin-BdnUsdx6.js → kotlin-BQy537ds.js} +1 -1
  40. package/dist/web/assets/{markdown-Cvjx9yec.js → markdown-DX-TNHnc.js} +1 -1
  41. package/dist/web/assets/{php-aq0itWAE.js → php-47JHu45N.js} +1 -1
  42. package/dist/web/assets/{python-B6aJPvgy.js → python-B6Ihcp-E.js} +1 -1
  43. package/dist/web/assets/render.worker-DW0Lo4fc.js +154 -0
  44. package/dist/web/assets/ruby-BrGyNOch.js +1 -0
  45. package/dist/web/assets/{rust-B1yitclQ.js → rust-CxuBE0J8.js} +1 -1
  46. package/dist/web/assets/{scss-OYdSNvt2.js → scss-DxBkwadj.js} +1 -1
  47. package/dist/web/assets/session-parser.worker-DCsmYUeX.js +41 -0
  48. package/dist/web/assets/{sql-BLtJtn59.js → sql-BbONfI8K.js} +1 -1
  49. package/dist/web/assets/svelte-H3swLp47.js +1 -0
  50. package/dist/web/assets/{swift-D82vCrfD.js → swift-tEesUtni.js} +1 -1
  51. package/dist/web/assets/switch-gTnbAJaZ.js +1 -0
  52. package/dist/web/assets/{toml-vGWfd6FD.js → toml-Ms459DBw.js} +1 -1
  53. package/dist/web/assets/{tsx-COt5Ahok.js → tsx-D6116Ycy.js} +1 -1
  54. package/dist/web/assets/{typescript-BPQ3VLAy.js → typescript-BqvgUolh.js} +1 -1
  55. package/dist/web/assets/vendor-markdown-BEJ8yVzA.js +29 -0
  56. package/dist/web/assets/{vendor-ui-DQeMoSiV.js → vendor-ui-CKjyvB3_.js} +226 -191
  57. package/dist/web/assets/vue-CWSgrUPf.js +1 -0
  58. package/dist/web/assets/{xml-D2mA2LmW.js → xml-CdYS3kUe.js} +1 -1
  59. package/dist/web/assets/{yaml-Buea-lGh.js → yaml-Bopit2L3.js} +1 -1
  60. package/dist/web/index.html +4 -5
  61. package/package.json +1 -1
  62. package/dist/web/assets/CommandPaletteHost-Djn2jqYR.js +0 -1
  63. package/dist/web/assets/ConfigBrowser-CRwh8BXq.js +0 -1
  64. package/dist/web/assets/CrewPanel-BxPl5D7h.js +0 -1
  65. package/dist/web/assets/HighlightedEditor-D9A-dW2Z.js +0 -2
  66. package/dist/web/assets/KeyboardShortcutsDialog-L7rRhApI.js +0 -1
  67. package/dist/web/assets/MissionHome-zp7VebSO.js +0 -2
  68. package/dist/web/assets/MobileFileChanges-O-SvMq9F.js +0 -1
  69. package/dist/web/assets/PluginsDialog-CBOyfoUX.js +0 -1
  70. package/dist/web/assets/PreviewPanel-_pKuUaps.js +0 -1
  71. package/dist/web/assets/ProjectFilesPanel-BsbpTgWK.js +0 -4
  72. package/dist/web/assets/ProjectSwitcherModal-D4MzdPVH.js +0 -1
  73. package/dist/web/assets/ThemeSelectorModal-7CWXZB-z.js +0 -1
  74. package/dist/web/assets/WorkflowsPanel-aOz1o3kA.js +0 -1
  75. package/dist/web/assets/WorktreePanel-BFve9bpC.js +0 -1
  76. package/dist/web/assets/cpp-BRuaLJcg.js +0 -1
  77. package/dist/web/assets/edition-ui-CFxEM3WF.js +0 -2
  78. package/dist/web/assets/github-dark-DHJKELXO.js +0 -1
  79. package/dist/web/assets/github-light-DAi9KRSo.js +0 -1
  80. package/dist/web/assets/index-CPTFl4Qh.js +0 -498
  81. package/dist/web/assets/index-DjpYbGVZ.js +0 -2
  82. package/dist/web/assets/index-DmMg-zf3.js +0 -1
  83. package/dist/web/assets/index-hGMtuUNI.css +0 -1
  84. package/dist/web/assets/ruby-B0Tyh1qT.js +0 -1
  85. package/dist/web/assets/session-parser.worker-3tFlB6dy.js +0 -31
  86. package/dist/web/assets/svelte-DZMnMd3x.js +0 -1
  87. package/dist/web/assets/switch-DS7UyNS2.js +0 -1
  88. package/dist/web/assets/vendor-markdown-BE1gYnO9.js +0 -37
  89. package/dist/web/assets/vendor-shiki-DOn6sF-i.js +0 -144
  90. package/dist/web/assets/vue-DVfSmUF7.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as C,c as ue,j as n}from"./vendor-react-gGw_S5I_.js";import{F as ze,d4 as it,a0 as je,d5 as jt,d6 as yt,d7 as Nt,B as te,E as rt,f as ct,U as It,h as dt,i as ut,ae as Je,d8 as Ct,ac as Qe,aC as et,d9 as kt,da as St,m as ft,ad as Mt,db as $t,av as Rt,cv as Tt,dc as At,cU as Ot,aZ as Et,o as Lt,n as _t,D as zt,j as Dt,c as oe,dd as Ft,bP as Pt,bQ as Yt,bO as qt,de as qe,V as We,df as Wt,ct as Ht,c9 as Ut,ca as Bt,cb as Ae,cc as Oe,al as Gt,k as Vt,dg as Kt,dh as Xt,di as Zt,b8 as Jt}from"./index-BVmNox_3.js";import{S as Qt}from"./switch-gTnbAJaZ.js";import{bS as es,dx as ts,aP as ss,bq as ns,N as ht,bo as pt,bg as os,bx as as,bp as ls,A as De,dy as is,aO as rs,X as cs}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";async function ke(t){if(t.ok)return t;const e=await t.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Ee(t,e){return[...new Map([...t,...e].map(s=>[s.sequence,s])).values()].sort((s,r)=>s.sequence-r.sequence)}function ds(t){const[e,s]=C.useState(null),[r,i]=C.useState([]),[a,c]=C.useState(null),[o,f]=C.useState(!1),[g,h]=C.useState(!1),[l,w]=C.useState(!1),[u,x]=C.useState(new Set),p=C.useRef(0),m=C.useRef(null),y=C.useRef(!1),k=C.useRef(!1),b=C.useRef(new Set),M=C.useRef(!1),N=C.useRef(null),$=C.useCallback(async j=>{const L=++p.current;try{const I=N.current,S=await(await ke(await ze(`/api/crew-chat/${encodeURIComponent(t)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!j()||L!==p.current)return;s(R=>R&&JSON.stringify(R.members)===JSON.stringify(S.members)?{...S,members:R.members}:S),i(R=>Ee(R,S.messages)),N.current=S.nextCursor,M.current||(M.current=!0,w(S.hasMore)),c(null)}catch(I){j()&&L===p.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[t]);it($,2e3);const _=C.useCallback(async j=>{var L;if(y.current)return!1;y.current=!0,f(!0),((L=m.current)==null?void 0:L.text)!==j&&(m.current={text:j,id:crypto.randomUUID()});try{const A=await(await ke(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{text:j,commandId:m.current.id}))).json();return p.current++,i(S=>Ee(S,[A.message])),m.current=null,c(A.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(I){return c(I instanceof Error?I.message:"Couldn't send the message."),!1}finally{y.current=!1,f(!1)}},[t]),O=C.useCallback(async(j,L)=>{if(!b.current.has(j)){b.current.add(j),x(I=>new Set(I).add(j));try{await ke(await je(`/api/crew-chat/${encodeURIComponent(t)}`,{sessionId:j,listening:L},{method:"PATCH"})),p.current++,s(I=>I&&{...I,members:I.members.map(A=>A.sessionId===j?{...A,listening:L}:A)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(j),x(I=>{const A=new Set(I);return A.delete(j),A})}}},[t]),E=C.useCallback(async()=>{if(!(!r.length||k.current)){k.current=!0,h(!0);try{const L=await(await ke(await ze(`/api/crew-chat/${encodeURIComponent(t)}?before=${r[0].sequence}`))).json();i(I=>Ee(I,L.messages)),w(L.hasMore)}catch(j){c(j instanceof Error?j.message:"Couldn't load older messages.")}finally{k.current=!1,h(!1)}}},[r,t]);return{page:e,messages:r,error:a,posting:o,busyMembers:u,hasOlder:l,loadingOlder:g,post:_,setListening:O,older:E}}const us=[],fs=new Map;function hs(t){var He,Ue,Be,Ge,Ve,Ke,Xe;const e=ue.c(111),{rootId:s,kinds:r,active:i}=t,a=r===void 0?fs:r,c=i===void 0?!0:i,o=ds(s),[f,g]=C.useState(""),h=C.useRef(null),l=C.useRef(!0);let w;e[0]!==o.messages?(w=(He=o.messages.at(-1))==null?void 0:He.sequence,e[0]=o.messages,e[1]=w):w=e[1];const u=w,x=((Ue=o.page)==null?void 0:Ue.members)??us;let p;e[2]!==x?(p=jt(x),e[2]=x,e[3]=p):p=e[3];const m=p;let y;e[4]!==x||e[5]!==s?(y=yt(x,s),e[4]=x,e[5]=s,e[6]=y):y=e[6];const k=y;let b;e[7]!==x?(b=new Map(x.map(ms)),e[7]=x,e[8]=b):b=e[8];const M=b;let N;e[9]!==o.messages||e[10]!==s?(N=Nt(o.messages,s),e[9]=o.messages,e[10]=s,e[11]=N):N=e[11];const $=N;let _;e[12]!==c?(_=()=>{var V,B;c&&l.current&&((B=(V=h.current)==null?void 0:V.scrollIntoView)==null||B.call(V,{block:"end"}))},e[12]=c,e[13]=_):_=e[13];let O;e[14]!==c||e[15]!==u?(O=[c,u],e[14]=c,e[15]=u,e[16]=O):O=e[16],C.useEffect(_,O);let E;e[17]!==o||e[18]!==f?(E=async()=>{const V=f.trim();!V||o.posting||await o.post(V)&&(g(B=>B.trim()===V?"":B),l.current=!0)},e[17]=o,e[18]=f,e[19]=E):E=e[19];const j=E;let L;e[20]!==o.page||e[21]!==x?(L=o.page?`${x.filter(ps).length} listening · Members & mentions`:"Loading chat…",e[20]=o.page,e[21]=x,e[22]=L):L=e[22];let I;e[23]!==L?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:L}),e[23]=L,e[24]=I):I=e[24];let A;if(e[25]!==o||e[26]!==a||e[27]!==x||e[28]!==s||e[29]!==k){let V;e[31]!==o||e[32]!==a||e[33]!==s||e[34]!==k?(V=B=>{var Ze;return n.jsxs(Je,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(Ct,{role:B.sessionId===s?"lead":"agent",sessionId:B.sessionId,kinds:a,tints:k,className:"size-5"}),n.jsxs(Qe,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${B.sessionId}`,"aria-label":`Listen for ${B.name}`,children:[n.jsx("span",{className:"truncate",children:B.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",B.handle]})]}),n.jsx(te,{variant:"ghost",size:"icon-xs",disabled:!((Ze=o.page)!=null&&Ze.canPost)||!B.canInteract,onClick:()=>g(ye=>`${ye}${ye&&!/\s$/.test(ye)?" ":""}@${B.handle} `),"aria-label":`Mention ${B.name}`,title:`Mention @${B.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${B.sessionId}`,size:"sm",checked:B.listening,disabled:!B.canInteract||o.busyMembers.has(B.sessionId),onCheckedChange:ye=>void o.setListening(B.sessionId,ye)})]},B.sessionId)},e[31]=o,e[32]=a,e[33]=s,e[34]=k,e[35]=V):V=e[35],A=x.map(V),e[25]=o,e[26]=a,e[27]=x,e[28]=s,e[29]=k,e[30]=A}else A=e[30];let S;e[36]!==A?(S=n.jsx(et,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:A}),e[36]=A,e[37]=S):S=e[37];let R;e[38]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=R):R=e[38];let F;e[39]!==I||e[40]!==S?(F=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,S,R]}),e[39]=I,e[40]=S,e[41]=F):F=e[41];let P;e[42]===Symbol.for("react.memo_cache_sentinel")?(P=V=>{const B=V.target;l.current=B.scrollHeight-B.scrollTop-B.clientHeight<80},e[42]=P):P=e[42];let H;e[43]!==o?(H=o.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(te,{variant:"ghost",size:"xs",disabled:o.loadingOlder,onClick:()=>void o.older(),children:o.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=o,e[44]=H):H=e[44];let D;e[45]!==o.messages.length||e[46]!==o.page?(D=o.page&&o.messages.length===0&&n.jsx(rt,{children:n.jsxs(ct,{children:[n.jsx(It,{variant:"icon",children:n.jsx(es,{})}),n.jsx(dt,{children:"Talk to the crew"}),n.jsx(ut,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=o.messages.length,e[46]=o.page,e[47]=D):D=e[47];let Y;if(e[48]!==M||e[49]!==m||e[50]!==a||e[51]!==s||e[52]!==$||e[53]!==k){let V;e[55]!==M||e[56]!==m||e[57]!==a||e[58]!==s||e[59]!==k?(V=B=>n.jsxs(C.Fragment,{children:[B.day!==void 0&&n.jsx(kt,{day:B.day}),n.jsx(St,{run:B,members:M,handles:m,kinds:a,tints:k,rootId:s})]},B.messages[0].sequence),e[55]=M,e[56]=m,e[57]=a,e[58]=s,e[59]=k,e[60]=V):V=e[60],Y=$.map(V),e[48]=M,e[49]=m,e[50]=a,e[51]=s,e[52]=$,e[53]=k,e[54]=Y}else Y=e[54];let G;e[61]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("div",{ref:h}),e[61]=G):G=e[61];let U;e[62]!==Y?(U=n.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[Y,G]}),e[62]=Y,e[63]=U):U=e[63];let z;e[64]!==H||e[65]!==D||e[66]!==U?(z=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:P,children:[H,D,U]}),e[64]=H,e[65]=D,e[66]=U,e[67]=z):z=e[67];let q;e[68]!==j?(q=V=>{V.preventDefault(),j()},e[68]=j,e[69]=q):q=e[69];const W=!!o.error,K=`crew-chat-${s}`;let d;e[70]!==K?(d=n.jsx(Qe,{htmlFor:K,className:"sr-only",children:"Message the crew"}),e[70]=K,e[71]=d):d=e[71];const v=`crew-chat-${s}`,T=!((Be=o.page)!=null&&Be.canPost),X=!!o.error;let ae;e[72]===Symbol.for("react.memo_cache_sentinel")?(ae=V=>g(V.target.value),e[72]=ae):ae=e[72];let J;e[73]!==j?(J=V=>{V.key==="Enter"&&(V.metaKey||V.ctrlKey)&&!V.nativeEvent.isComposing&&(V.preventDefault(),j())},e[73]=j,e[74]=J):J=e[74];let Q;e[75]!==f||e[76]!==v||e[77]!==T||e[78]!==X||e[79]!==J?(Q=n.jsx(Mt,{id:v,value:f,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:T,"aria-invalid":X,onChange:ae,onKeyDown:J}),e[75]=f,e[76]=v,e[77]=T,e[78]=X,e[79]=J,e[80]=Q):Q=e[80];let ee;e[81]!==o.error?(ee=o.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o.error}),e[81]=o.error,e[82]=ee):ee=e[82];let se;e[83]!==W||e[84]!==d||e[85]!==Q||e[86]!==ee?(se=n.jsxs(Je,{"data-invalid":W,children:[d,Q,ee]}),e[83]=W,e[84]=d,e[85]=Q,e[86]=ee,e[87]=se):se=e[87];const re=((Ge=o.page)==null?void 0:Ge.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let Z;e[88]!==re?(Z=n.jsx(Rt,{className:"flex-1",children:re}),e[88]=re,e[89]=Z):Z=e[89];let ce;e[90]!==((Ve=o.page)==null?void 0:Ve.canPost)||e[91]!==o.posting||e[92]!==f?(ce=!((Ke=o.page)!=null&&Ke.canPost)||!f.trim()||o.posting,e[90]=(Xe=o.page)==null?void 0:Xe.canPost,e[91]=o.posting,e[92]=f,e[93]=ce):ce=e[93];let pe;e[94]===Symbol.for("react.memo_cache_sentinel")?(pe=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=pe):pe=e[94];const Te=o.posting?"Sending…":"Send";let ge;e[95]!==ce||e[96]!==Te?(ge=n.jsxs(te,{type:"submit",size:"sm",disabled:ce,children:[pe,Te]}),e[95]=ce,e[96]=Te,e[97]=ge):ge=e[97];let xe;e[98]!==Z||e[99]!==ge?(xe=n.jsxs("div",{className:"flex items-center gap-2",children:[Z,ge]}),e[98]=Z,e[99]=ge,e[100]=xe):xe=e[100];let we;e[101]!==se||e[102]!==xe?(we=n.jsxs(et,{className:"gap-2",children:[se,xe]}),e[101]=se,e[102]=xe,e[103]=we):we=e[103];let be;e[104]!==q||e[105]!==we?(be=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:q,children:we}),e[104]=q,e[105]=we,e[106]=be):be=e[106];let Ce;return e[107]!==F||e[108]!==z||e[109]!==be?(Ce=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[F,z,be]}),e[107]=F,e[108]=z,e[109]=be,e[110]=Ce):Ce=e[110],Ce}function ps(t){return t.listening}function ms(t){return[t.sessionId,t]}const fe={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function mt(t){const e=new Date(t),s=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?s:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${s}`}function he(t){if(t.status==="deferred")return"needs-you";switch(t.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function tt(t,e){var s,r;return{sessionId:t.sessionId,dirName:((s=t.address)==null?void 0:s.dirName)??"",fileName:((r=t.address)==null?void 0:r.fileName)??"",projectShortName:"",lastModified:t.lastActivityAt??"",lastActivityAt:t.lastActivityAt,size:0,cwd:t.cwd,customTitle:t.customTitle,aiTitle:t.aiTitle,firstUserMessage:t.firstUserMessage,...t.parentId&&{crew:{rootId:e,parentId:t.parentId,startedAt:t.startedAt??0,...t.name&&{name:t.name}}}}}function gs(t,e,s){var o;const r=((o=[...e.values()].find(f=>f.parentId===null))==null?void 0:o.sessionId)??t.sessionId,i=s[t.sessionId],a=tt(t,r);if(!t.parentId)return Tt(a,i);const c=e.get(t.parentId);return At(a,{customName:i,parent:c&&tt(c,r)})}function xs(t){const e=new Map;for(const a of t.members){if(!a.parentId)continue;const c=e.get(a.parentId);c?c.push(a):e.set(a.parentId,[a])}const s=[],r=new Set,i=(a,c)=>{var f;const o=[...e.get(a)??[]].sort((g,h)=>(g.startedAt??0)-(h.startedAt??0));for(const g of o)r.has(g.sessionId)||(r.add(g.sessionId),s.push({member:g,depth:c,children:((f=e.get(g.sessionId))==null?void 0:f.length)??0}),i(g.sessionId,c+1))};i(t.rootId,0);for(const a of t.members)a.parentId&&!r.has(a.sessionId)&&(r.add(a.sessionId),s.push({member:a,depth:0,children:0}));return s}function ws(t){const e=({member:s,pending:r})=>r.askedAt??(Date.parse(s.lastActivityAt??"")||0);return t.members.flatMap(s=>s.waiting.map(r=>({member:s,pending:r}))).sort((s,r)=>e(s)-e(r))}function bs(t){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const s of t.members){if(!s.parentId)continue;e.size++;const r=he(s);r==="working"?e.working++:r==="needs-you"?e.needsYou++:r==="failed"?e.failed++:r==="unreachable"?e.unreachable++:e.done++,Re(s)&&e.unreadResults++}return e}function Re(t){return!!(t.result&&t.result.state!=="running"&&!t.result.acknowledged)}function Ie(t){const[e]=t.waiting;switch(he(t)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":!e&&t.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return t.status==="tool_use"&&t.toolName?t.toolName:t.status==="thinking"?"Thinking":t.status==="compacting"?"Compacting":t.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return t.error?`Failed · ${t.error}`:"Failed";case"unreachable":return t.device?`${t.device.name} is not answering`:"Not found";default:return Re(t)?"Finished · result unread":"Finished"}}const le=196,ne=86,de=40,ve=12,vs=28,Me=6,st=8,me=10,js=6,$e=28,Fe=36;function gt(t){const e=he(t);return e==="working"||e==="needs-you"}function ys(t){const e={all:t.members.length,active:0,working:0,needsYou:0};for(const s of t.members){const r=he(s);r==="working"?e.working++:r==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(t,e)=>(t.startedAt??0)-(e.startedAt??0)||t.sessionId.localeCompare(e.sessionId);function xt(t){const e=new Map(t.members.map(i=>[i.sessionId,i])),s=new Map,r=[];for(const i of t.members){const a=i.parentId&&i.sessionId!==t.rootId?e.get(i.parentId):void 0;if(!a){r.push(i);continue}const c=s.get(a.sessionId);c?c.push(i):s.set(a.sessionId,[i])}for(const i of s.values())i.sort(nt);return r.sort((i,a)=>+(a.sessionId===t.rootId)-+(i.sessionId===t.rootId)||nt(i,a)),{roots:r,childrenOf:s}}function Ns(t,e){if(e==="all")return new Set(t.members.map(i=>i.sessionId));const s=new Map(t.members.map(i=>[i.sessionId,i])),r=new Set;for(const i of t.members){if(!gt(i))continue;let a=i;for(;a&&!r.has(a.sessionId);)r.add(a.sessionId),a=a.sessionId===t.rootId||!a.parentId?void 0:s.get(a.parentId)}return r}function Is(t){const{roots:e,childrenOf:s}=xt(t),r=new Set;let i=0;const a=e.map(c=>({member:c,depth:0}));for(;a.length>0;){const{member:c,depth:o}=a.pop();if(!r.has(c.sessionId)){r.add(c.sessionId),i=Math.max(i,o);for(const f of s.get(c.sessionId)??[])a.push({member:f,depth:o+1})}}return i}function Cs(t){return(t+1)*le+t*de}function ks(t,e,s,{group:r=!1,stacked:i}={}){const{roots:a,childrenOf:c}=xt(t),o=Ns(t,e),f=N=>(c.get(N)??[]).filter($=>o.has($.sessionId)),g=(i==null?void 0:i.cardWidth)??le,h=[],l=[],w=[],u=new Set;let x=0,p=0;const m=N=>{const $={count:0,working:0,needsYou:0},_=new Set(u),O=[...f(N)];for(;O.length>0;){const E=O.pop();if(_.has(E.sessionId))continue;_.add(E.sessionId),$.count++;const j=he(E);j==="working"?$.working++:j==="needs-you"&&$.needsYou++,O.push(...f(E.sessionId))}return $},y=N=>f(N).filter($=>!u.has($.sessionId)),k=N=>y(N.sessionId).length===0||s.has(N.sessionId),b=(N,$,_)=>{u.add(N.sessionId);const O=y(N.sessionId),E=O.length>0&&s.has(N.sessionId),j=E?[]:O,L=r&&!i&&j.length>=st?j.filter(k):[],I=L.length>=st?L:[],A=new Set(I),S=j.filter(P=>!A.has(P)),R={member:N,depth:$,x:(_==null?void 0:_.x)??$*(i?$e:le+de),y:(_==null?void 0:_.y)??x+(S.length===0&&I.length>0?me:0),childCount:O.length,collapsed:E,hidden:E?m(N.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!gt(N),grouped:!!_};if(h.push(R),p=Math.max(p,R.x+g+(i&&O.length>0?Fe:0)),i){x+=ne+ve;const P=j.map(H=>b(H,$+1));return P.length>0&&l.push({parentId:N.sessionId,path:Ms(R.x,R.y,P)}),R.y}if(E){const P=R.y+ne/2;l.push({parentId:N.sessionId,path:`M${R.x+le} ${P}H${R.x+le+de/2}`})}if(_)return R.y;if(j.length===0)return x+=ne+ve,R.y;const F=S.map(P=>b(P,$+1));return I.length>0&&F.push(M(N.sessionId,I,$+1)+me),l.push({parentId:N.sessionId,path:Ss(R.x+le,R.y,F)}),R.y},M=(N,$,_)=>{const O=Math.min(js,Math.max(2,Math.ceil(Math.sqrt($.length/1.5)))),E=Math.ceil($.length/O),j={parentId:N,x:_*(le+de),y:x,width:O*le+(O-1)*de+2*me,height:E*ne+(E-1)*ve+2*me};return w.push(j),$.forEach((L,I)=>b(L,_,{x:j.x+me+I%O*(le+de),y:j.y+me+Math.floor(I/O)*(ne+ve)})),p=Math.max(p,j.x+j.width),x+=j.height+ve,j.y};for(const N of a)!o.has(N.sessionId)||u.has(N.sessionId)||(h.length>0&&(x+=vs),b(N,0));return{orientation:i?"stacked":"across",cardWidth:g,nodes:h,edges:l,groups:w,width:p,height:Math.max(0,x-ve)}}function Ss(t,e,s){const r=e+ne/2,i=[`M${t} ${r}H${t+de}`];for(const a of s)a!==e&&i.push(wt(t,r,a+ne/2));return i.join("")}function wt(t,e,s){const r=t+de/2;return`M${r} ${e}V${s-Me}Q${r} ${s} ${r+Me} ${s}H${t+de}`}function Ms(t,e,s){return s.map(r=>bt(t,e,r)).join("")}function bt(t,e,s){const r=t+$e/2,i=s+ne/2;return`M${r} ${e+ne}V${i-Me}Q${r} ${i} ${r+Me} ${i}H${t+$e}`}function $s(t,e){const s=new Map(t.nodes.map(c=>[c.member.sessionId,c])),r=new Map(t.groups.map(c=>[c.parentId,c]));let i=e?s.get(e):void 0;const a=[];for(;i!=null&&i.member.parentId;){const c=i.member.parentId,o=s.get(c);if(!o||o.depth!==i.depth-1)break;if(t.orientation==="stacked"){a.unshift(bt(o.x,o.y,i.y)),i=o;continue}const f=o.x+le,g=o.y+ne/2,h=i.grouped?r.get(c):void 0,l=(h?h.y+me:i.y)+ne/2;a.unshift(l===g?`M${f} ${g}H${f+de}`:`M${f} ${g}H${f+de/2}${wt(f,g,l)}`),i=o}return a.length>0?a.join(""):null}const ie=14,Pe=.25,ot=1.5,Rs=.7,Se=1.2,Ts=56,As=900,Os=.85,Es=320,Le={all:new Set,active:new Set};function Ls(t){const[e,s]=Ot(Et("crew-map-filter"),"all"),r=e==="active"?"active":"all",[i,a]=C.useState({rootId:t,folds:Le}),c=C.useRef(new Map),o=i.rootId===t?i.folds:Le,f=C.useCallback(h=>a(l=>{const w=l.rootId===t?l.folds:Le,u=new Set(w[r]);return u.delete(h)||u.add(h),{rootId:t,folds:{...w,[r]:u}}}),[r,t]),g=C.useMemo(()=>({get current(){return c.current.get(t)??null},set current(h){c.current.set(t,h)}}),[t]);return{filter:r,setFilter:s,collapsed:o[r],toggle:f,viewport:g}}function _s(t){const e=ue.c(86),{crew:s,hereId:r,controls:i,kinds:a,nameOf:c,onOpen:o}=t,[f,g]=C.useState(!1),{filter:h,collapsed:l,toggle:w}=i;let u,x,p,m,y,k,b,M,N,$,_,O,E,j,L,I;if(e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==f||e[4]!==h||e[5]!==r||e[6]!==a||e[7]!==c||e[8]!==o||e[9]!==w){let U;e[26]!==s.rootId?(U=v=>v.sessionId===s.rootId,e[26]=s.rootId,e[27]=U):U=e[27];const z=s.members.find(U);let q;e[28]!==l||e[29]!==i||e[30]!==s||e[31]!==h||e[32]!==r||e[33]!==a||e[34]!==c||e[35]!==w?(q=(v,T)=>n.jsx(Ps,{crew:s,collapsed:l,groups:!v,filter:h,hereId:r,kinds:a,nameOf:c,memory:v,onOpen:T,onToggle:w,onShowAll:()=>i.setFilter("all")}),e[28]=l,e[29]=i,e[30]=s,e[31]=h,e[32]=r,e[33]=a,e[34]=c,e[35]=w,e[36]=q):q=e[36],p=q,k="flex h-full min-h-0 flex-col";let W;e[37]!==i||e[38]!==s?(W=n.jsx(at,{crew:s,controls:i}),e[37]=i,e[38]=s,e[39]=W):W=e[39];let K;e[40]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("span",{className:"flex-1"}),e[40]=K):K=e[40];let d;e[41]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>g(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=d):d=e[41],e[42]!==W?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[W,K,d]}),e[42]=W,e[43]=b):b=e[43],e[44]!==p||e[45]!==i.viewport||e[46]!==o?(M=p(i.viewport,o),e[44]=p,e[45]=i.viewport,e[46]=o,e[47]=M):M=e[47],x=Lt,I=f,y=g,u=_t,O=!0,E="flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden p-0 sm:h-[calc(100dvh-4rem)] sm:w-[calc(100vw-4rem)] sm:max-w-none",e[48]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(zt,{className:"sr-only",children:"Crew map"}),L=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=j,e[49]=L):(j=e[48],L=e[49]),$="flex h-12 shrink-0 items-center gap-3 pl-4 pr-14",e[50]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),e[50]=_):_=e[50],m="min-w-0 truncate text-sm font-medium",N=z?c(z):"Crew",e[0]=l,e[1]=i,e[2]=s,e[3]=f,e[4]=h,e[5]=r,e[6]=a,e[7]=c,e[8]=o,e[9]=w,e[10]=u,e[11]=x,e[12]=p,e[13]=m,e[14]=y,e[15]=k,e[16]=b,e[17]=M,e[18]=N,e[19]=$,e[20]=_,e[21]=O,e[22]=E,e[23]=j,e[24]=L,e[25]=I}else u=e[10],x=e[11],p=e[12],m=e[13],y=e[14],k=e[15],b=e[16],M=e[17],N=e[18],$=e[19],_=e[20],O=e[21],E=e[22],j=e[23],L=e[24],I=e[25];let A;e[51]!==m||e[52]!==N?(A=n.jsx("span",{className:m,children:N}),e[51]=m,e[52]=N,e[53]=A):A=e[53];let S;e[54]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx("span",{className:"flex-1"}),e[54]=S):S=e[54];let R;e[55]!==i||e[56]!==s?(R=n.jsx(at,{crew:s,controls:i}),e[55]=i,e[56]=s,e[57]=R):R=e[57];let F;e[58]!==A||e[59]!==R||e[60]!==$||e[61]!==_?(F=n.jsxs("header",{className:$,children:[_,A,S,R]}),e[58]=A,e[59]=R,e[60]=$,e[61]=_,e[62]=F):F=e[62];let P;e[63]!==o?(P=U=>{g(!1),o(U)},e[63]=o,e[64]=P):P=e[64];let H;e[65]!==p||e[66]!==P?(H=p(null,P),e[65]=p,e[66]=P,e[67]=H):H=e[67];let D;e[68]!==u||e[69]!==F||e[70]!==H||e[71]!==O||e[72]!==E||e[73]!==j||e[74]!==L?(D=n.jsxs(u,{showCloseButton:O,className:E,children:[j,L,F,H]}),e[68]=u,e[69]=F,e[70]=H,e[71]=O,e[72]=E,e[73]=j,e[74]=L,e[75]=D):D=e[75];let Y;e[76]!==x||e[77]!==y||e[78]!==D||e[79]!==I?(Y=n.jsx(x,{open:I,onOpenChange:y,children:D}),e[76]=x,e[77]=y,e[78]=D,e[79]=I,e[80]=Y):Y=e[80];let G;return e[81]!==k||e[82]!==b||e[83]!==M||e[84]!==Y?(G=n.jsxs("div",{className:k,children:[b,M,Y]}),e[81]=k,e[82]=b,e[83]=M,e[84]=Y,e[85]=G):G=e[85],G}function at(t){const e=ue.c(3),{crew:s,controls:r}=t;let i;if(e[0]!==r||e[1]!==s){const a=ys(s),c=[{id:"all",label:"All",count:a.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:a.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];i=n.jsx("div",{role:"radiogroup","aria-label":"Show on the map",className:"flex shrink-0 gap-0.5 rounded-full border bg-background p-0.5",children:c.map(o=>{const{id:f,label:g,count:h,hint:l}=o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":r.filter===f,"aria-label":`${g}, ${vt(h)}`,title:l,onClick:()=>r.setFilter(f),className:oe("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",r.filter===f&&"bg-accent text-foreground"),children:[g,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:h})]},f)})}),e[0]=r,e[1]=s,e[2]=i}else i=e[2];return i}function vt(t){return`${t} ${t===1?"session":"sessions"}`}function _e(t,e,s){return t.orientation==="stacked"?{scale:e,left:ie,top:ie}:{scale:e,left:Math.max(ie,(s.width-t.width*e)/2),top:Math.max(ie,Math.min((s.height-t.height*e)/2,s.height*.12))}}function zs(t,e,s){return{width:Math.max(s.width,e.left+t.width*e.scale+ie),height:Math.max(s.height,e.top+t.height*e.scale+Ts)}}function lt(t,e,{widthOnly:s=!1}={}){if(t.width===0||e.width===0)return 1;const r=(e.width-2*ie)/t.width,i=s?r:Math.min(r,(e.height-2*ie)/t.height);return Ye(i,Pe,1)}const Ye=(t,e,s)=>Math.min(s,Math.max(e,t));function Ds(t,e,s,r,i){var w;const a=new Map(e.layout.nodes.map(u=>[u.member.sessionId,u])),c=new Map(s.nodes.map(u=>[u.member.sessionId,u]));if(e.frame===r&&a.size===c.size&&s.nodes.every(u=>{const x=a.get(u.member.sessionId);return x!==void 0&&x.x===u.x&&x.y===u.y}))return null;const f=u=>({x:e.frame.left+u.x*e.frame.scale-t.left,y:e.frame.top+u.y*e.frame.scale-t.top}),g=i&&a.has(i)&&c.has(i)?i:(w=e.layout.nodes.filter(u=>c.has(u.member.sessionId)).map(u=>({node:u,screen:f(u)})).filter(({screen:u})=>u.y+ne*e.frame.scale>0&&u.x+e.layout.cardWidth*e.frame.scale>0).sort((u,x)=>u.screen.y-x.screen.y||u.screen.x-x.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!g)return null;const h=f(a.get(g)),l=c.get(g);return{left:r.left+l.x*r.scale-h.x,top:r.top+l.y*r.scale-h.y}}function Fs(t,e,s,r){const i=new Map(t.nodes.map(x=>[x.member.sessionId,x])),a=e?i.get(e):void 0;if(!a)return{left:0,top:0};const{scale:c}=s,o=s.left+a.x*c,f=s.top+a.y*c,g=o+t.cardWidth*c,h=f+ne*c;if(g<=r.clientWidth&&h<=r.clientHeight)return{left:0,top:0};const l=a.member.parentId&&i.get(a.member.parentId)||a;let w=s.left+Math.min(l.x,a.x)*c-ie,u=s.top+Math.min(l.y,a.y)*c-ie;return g-w>r.clientWidth&&(w=o-ie),h-u>r.clientHeight&&(u=f-r.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,u)}}function Ps({crew:t,collapsed:e,groups:s,filter:r,hereId:i,kinds:a,nameOf:c,memory:o,onOpen:f,onToggle:g,onShowAll:h}){const l=C.useRef(null),[w,u]=C.useState({width:0,height:0}),x=s&&w.width>=As,p=C.useMemo(()=>Is(t),[t]),m=w.width-2*ie,y=!s&&w.width>0&&Cs(p)*Os>m,k=y?Ye(m-p*$e-Fe,le,Es):le,b=C.useMemo(()=>ks(t,r,e,{group:x,...y&&{stacked:{cardWidth:k}}}),[t,r,e,x,y,k]),[M,N]=C.useState(()=>{var d;return((d=o==null?void 0:o.current)==null?void 0:d.frame)??{scale:1,left:ie,top:ie}}),[$,_]=C.useState(!1),O=C.useRef(null),E=C.useRef(null),j=C.useRef({left:0,top:0}),L=C.useRef(null),I=C.useRef(null),A=zs(b,M,w),{scale:S}=M;C.useLayoutEffect(()=>{const d=l.current;if(!d)return;const v=()=>u(X=>X.width===d.clientWidth&&X.height===d.clientHeight?X:{width:d.clientWidth,height:d.clientHeight});v();const T=new ResizeObserver(v);return T.observe(d),()=>T.disconnect()},[]);const R=C.useCallback(d=>{const v=l.current;o&&v&&(o.current={frame:d,left:v.scrollLeft,top:v.scrollTop})},[o]),F=C.useCallback((d,v)=>{O.current={frame:d,scroll:v},N(d)},[]),P=C.useCallback(d=>{const v=_e(d,Math.max(lt(d,w,{widthOnly:!0}),Rs),w);F(v,()=>{const T=l.current;return T?Fs(d,i,v,T):{left:0,top:0}})},[F,i,w]);C.useLayoutEffect(()=>{const d=l.current;if(w.width===0||!d)return;const v=L.current;if(v){if(v.filter!==r||v.layout.orientation!==b.orientation)P(b);else if(v.layout!==b){const T=Ds(j.current,v,b,M,E.current);T&&(d.scrollLeft=T.left,d.scrollTop=T.top,j.current={left:d.scrollLeft,top:d.scrollTop})}}else{const T=o==null?void 0:o.current;T?F(T.frame,()=>({left:T.left,top:T.top})):P(b)}E.current=null,L.current={layout:b,filter:r,frame:M}}),C.useLayoutEffect(()=>{const d=O.current,v=l.current;if(!d||!v||d.frame!==M)return;O.current=null;const{left:T,top:X}=d.scroll();v.scrollLeft=T,v.scrollTop=X,j.current={left:v.scrollLeft,top:v.scrollTop},R(M)});const H=C.useRef(i);C.useEffect(()=>{var d,v;H.current!==i&&(H.current=i,i&&((v=(d=l.current)==null?void 0:d.querySelector(`[data-crew-map-card="${CSS.escape(i)}"]`))==null||v.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[i]);const D=C.useCallback((d,v)=>{var ce;const T=l.current,X=((ce=O.current)==null?void 0:ce.frame.scale)??S,ae=Ye(X*d,Pe,ot);if(!T||ae===X)return;const J=T.getBoundingClientRect(),Q=v?v.clientX-J.left:T.clientWidth/2,ee=v?v.clientY-J.top:T.clientHeight/2,se=(T.scrollLeft+Q-M.left)/S,re=(T.scrollTop+ee-M.top)/S,Z=_e(b,ae,w);F(Z,()=>({left:Z.left+se*Z.scale-Q,top:Z.top+re*Z.scale-ee}))},[F,M.left,M.top,b,S,w]),Y=C.useRef(D);C.useLayoutEffect(()=>{Y.current=D}),C.useEffect(()=>{const d=l.current;if(!d)return;const v=T=>{!T.ctrlKey&&!T.metaKey||(T.preventDefault(),Y.current(Math.exp(-T.deltaY*.01),T))};return d.addEventListener("wheel",v,{passive:!1}),()=>d.removeEventListener("wheel",v)},[]);const G=d=>{const v=l.current;!v||d.pointerType!=="mouse"||d.button!==0||d.target.closest("button")||(I.current={pointerId:d.pointerId,x:d.clientX,y:d.clientY,left:v.scrollLeft,top:v.scrollTop},v.setPointerCapture(d.pointerId),_(!0))},U=d=>{const v=I.current,T=l.current;!v||!T||v.pointerId!==d.pointerId||(T.scrollLeft=v.left-(d.clientX-v.x),T.scrollTop=v.top-(d.clientY-v.y))},z=d=>{var v,T;((v=I.current)==null?void 0:v.pointerId)===d.pointerId&&(I.current=null,(T=l.current)==null||T.releasePointerCapture(d.pointerId),_(!1))},q=C.useMemo(()=>$s(b,i),[b,i]),W=b.nodes.length===0,K=b.orientation==="stacked"?b.cardWidth+Fe/2:le+de/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:l,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:d=>{j.current={left:d.currentTarget.scrollLeft,top:d.currentTarget.scrollTop},O.current||R(M)},onPointerDown:G,onPointerMove:U,onPointerUp:z,onPointerCancel:z,onKeyDown:d=>{d.target===d.currentTarget&&(d.key==="+"||d.key==="="?D(Se):d.key==="-"&&D(1/Se))},tabIndex:-1,className:oe("absolute inset-0 overflow-auto overscroll-contain outline-none [touch-action:pan-x_pan-y]","bg-muted/30 bg-local bg-[radial-gradient(circle,var(--border)_1px,transparent_1px)] bg-size-[18px_18px]",$?"cursor-grabbing select-none":"cursor-grab"),children:W?n.jsxs(rt,{className:"h-full",children:[n.jsxs(ct,{children:[n.jsx(dt,{children:"Nothing is active"}),n.jsx(ut,{className:"text-xs",children:"No session in this crew is working or waiting on you."})]}),n.jsx(te,{variant:"outline",size:"xs",onClick:h,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:A.width,height:A.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:M.left,top:M.top,width:b.width,height:b.height,transform:`scale(${S})`},children:[b.groups.map(d=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:d.x,top:d.y,width:d.width,height:d.height}},d.parentId)),n.jsxs("svg",{"aria-hidden":"true",width:b.width,height:b.height,className:"pointer-events-none absolute inset-0 overflow-visible",fill:"none",children:[b.edges.map(d=>n.jsx("path",{d:d.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},d.parentId)),q&&n.jsx("path",{d:q,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(d=>n.jsx(Hs,{node:d,width:b.cardWidth,toggleLeft:K,here:d.member.sessionId===i,kind:a.get(d.member.sessionId),name:c(d.member),onOpen:f,onToggle:v=>{E.current=v,g(v)}},d.member.sessionId))})]})})}),!W&&n.jsxs("div",{className:"absolute bottom-2.5 right-2.5 flex items-center gap-0.5 rounded-lg border bg-popover p-0.5 shadow-sm",children:[n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:S<=Pe,onClick:()=>D(1/Se),children:n.jsx(pt,{"data-icon":"inline-start"})}),n.jsxs(te,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>D(1/S),children:[Math.round(S*100),"%"]}),n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:S>=ot,onClick:()=>D(Se),children:n.jsx(os,{"data-icon":"inline-start"})}),n.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":"true"}),n.jsx(te,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>F(_e(b,lt(b,w),w),()=>({left:0,top:0})),children:"Fit"})]})]})}const Ys={"needs-you":"border-warning/60 bg-[color-mix(in_oklch,var(--warning)_7%,var(--card))]",failed:"border-destructive/45",unreachable:"border-dashed"},qs={"needs-you":"text-warning",failed:"text-destructive"};function Ws(t){var s,r;const e=(s=t.pullRequests)==null?void 0:s.at(-1);return[t.model&&qe(t.model),(r=t.device)==null?void 0:r.name,e&&`#${e.number}`,t.lastActivityAt&&We(t.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(t){const e=ue.c(75),{node:s,width:r,toggleLeft:i,here:a,kind:c,name:o,onOpen:f,onToggle:g}=t,{member:h}=s;let l;e[0]!==h?(l=he(h),e[0]=h,e[1]=l):l=e[1];const w=l;let u;e[2]!==h?(u=Ie(h),e[2]=h,e[3]=u):u=e[3];const x=u;let p;e[4]!==c?(p=c?Ft(c):as,e[4]=c,e[5]=p):p=e[5];const m=p;let y;e[6]!==h?(y=Ws(h),e[6]=h,e[7]=y):y=e[7];const k=y,b=s.context&&"shown because a session it started is active";let M;e[8]!==x||e[9]!==o||e[10]!==b?(M=[o,x,b].filter(Boolean),e[8]=x,e[9]=o,e[10]=b,e[11]=M):M=e[11];const N=M.join(", ");let $;e[12]!==s.x||e[13]!==s.y||e[14]!==r?($={left:s.x,top:s.y,width:r,height:ne},e[12]=s.x,e[13]=s.y,e[14]=r,e[15]=$):$=e[15];const _=h.sessionId,O=a?"true":void 0;let E;e[16]!==h||e[17]!==f?(E=()=>f(h),e[16]=h,e[17]=f,e[18]=E):E=e[18];const j=Ys[w],L=a&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=s.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let A;e[19]!==j||e[20]!==L||e[21]!==I?(A=oe("flex size-full cursor-pointer flex-col justify-center gap-1 rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs outline-none","transition-[border-color,opacity,box-shadow] hover:border-foreground/25 hover:shadow-sm focus-visible:ring-2 focus-visible:ring-ring",j,L,I),e[19]=j,e[20]=L,e[21]=I,e[22]=A):A=e[22];let S;e[23]!==N||e[24]!==h.sessionId||e[25]!==w||e[26]!==E||e[27]!==A||e[28]!==O?(S=n.jsx("button",{type:"button","data-crew-map-card":_,"data-crew-map-state":w,"aria-current":O,"aria-label":N,onClick:E,className:A}),e[23]=N,e[24]=h.sessionId,e[25]=w,e[26]=E,e[27]=A,e[28]=O,e[29]=S):S=e[29];let R;e[30]!==m?(R=n.jsx(m,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=m,e[31]=R):R=e[31];let F;e[32]!==o?(F=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:o}),e[32]=o,e[33]=F):F=e[33];let P;e[34]!==R||e[35]!==F?(P=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[R,F]}),e[34]=R,e[35]=F,e[36]=P):P=e[36];const H=fe[w];let D;e[37]!==H?(D=oe("size-1.5 shrink-0 rounded-full",H),e[37]=H,e[38]=D):D=e[38];let Y;e[39]!==D?(Y=n.jsx("span",{className:D,"aria-hidden":"true"}),e[39]=D,e[40]=Y):Y=e[40];let G;e[41]!==h||e[42]!==w?(G=Re(h)?"text-warning":qs[w],e[41]=h,e[42]=w,e[43]=G):G=e[43];let U;e[44]!==G?(U=oe("min-w-0 truncate text-muted-foreground",G),e[44]=G,e[45]=U):U=e[45];let z;e[46]!==x||e[47]!==U?(z=n.jsx("span",{className:U,children:x}),e[46]=x,e[47]=U,e[48]=z):z=e[48];let q;e[49]!==Y||e[50]!==z?(q=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[Y,z]}),e[49]=Y,e[50]=z,e[51]=q):q=e[51];let W;e[52]!==a||e[53]!==k?(W=(k||a)&&n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11.5px] tabular-nums text-muted-foreground/75",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:k}),a&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=a,e[53]=k,e[54]=W):W=e[54];let K;e[55]!==S||e[56]!==P||e[57]!==q||e[58]!==W?(K=n.jsxs(Pt,{delay:700,render:S,children:[P,q,W]}),e[55]=S,e[56]=P,e[57]=q,e[58]=W,e[59]=K):K=e[59];let d;e[60]!==h||e[61]!==o?(d=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Bs,{member:h,name:o})}),e[60]=h,e[61]=o,e[62]=d):d=e[62];let v;e[63]!==K||e[64]!==d?(v=n.jsxs(qt,{children:[K,d]}),e[63]=K,e[64]=d,e[65]=v):v=e[65];let T;e[66]!==o||e[67]!==s||e[68]!==g||e[69]!==i?(T=s.childCount>0&&n.jsx(Us,{node:s,name:o,left:i,onToggle:g}),e[66]=o,e[67]=s,e[68]=g,e[69]=i,e[70]=T):T=e[70];let X;return e[71]!==v||e[72]!==T||e[73]!==$?(X=n.jsxs("li",{className:"group/node absolute",style:$,children:[v,T]}),e[71]=v,e[72]=T,e[73]=$,e[74]=X):X=e[74],X}function Us(t){const e=ue.c(25),{node:s,name:r,left:i,onToggle:a}=t,{collapsed:c,hidden:o}=s;let f=null;o.needsYou>0?f="needs-you":o.working>0&&(f="working");let g;e[0]!==c||e[1]!==o.count||e[2]!==o.needsYou||e[3]!==o.working||e[4]!==r?(g=c?[`Show the ${vt(o.count)} under ${r}`,o.needsYou>0&&`${o.needsYou} waiting on you`,o.working>0&&`${o.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${r}`,e[0]=c,e[1]=o.count,e[2]=o.needsYou,e[3]=o.working,e[4]=r,e[5]=g):g=e[5];const h=g,l=!c,w=c?void 0:"Fold";let u;e[6]!==s.member.sessionId||e[7]!==a?(u=()=>a(s.member.sessionId),e[6]=s.member.sessionId,e[7]=a,e[8]=u):u=e[8];const x=!c&&"opacity-0 group-hover/node:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100";let p;e[9]!==x?(p=oe("absolute z-10 flex h-5 min-w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center gap-1 rounded-full border bg-card px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground shadow-xs outline-none","transition-opacity hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",x),e[9]=x,e[10]=p):p=e[10];let m;e[11]!==i?(m={left:i,top:ne/2},e[11]=i,e[12]=m):m=e[12];let y;e[13]!==f||e[14]!==c||e[15]!==o.count?(y=c?n.jsxs(n.Fragment,{children:[f&&n.jsx("span",{className:oe("size-1.5 rounded-full",fe[f]),"aria-hidden":"true"}),"+",o.count]}):n.jsx(pt,{"aria-hidden":"true",className:"size-3"}),e[13]=f,e[14]=c,e[15]=o.count,e[16]=y):y=e[16];let k;return e[17]!==h||e[18]!==l||e[19]!==w||e[20]!==u||e[21]!==p||e[22]!==m||e[23]!==y?(k=n.jsx("button",{type:"button","aria-expanded":l,"aria-label":h,title:w,onClick:u,className:p,style:m,children:y}),e[17]=h,e[18]=l,e[19]=w,e[20]=u,e[21]=p,e[22]=m,e[23]=y,e[24]=k):k=e[24],k}function Bs(t){var u,x;const e=ue.c(35),{member:s,name:r}=t;let i;e[0]!==s.firstUserMessage?(i=(u=s.firstUserMessage)==null?void 0:u.replace(/\s+/g," ").trim(),e[0]=s.firstUserMessage,e[1]=i):i=e[1];const a=i;let c;e[2]!==s.cwd?(c=(x=s.cwd)==null?void 0:x.split(/[\\/]/).filter(Boolean).at(-1),e[2]=s.cwd,e[3]=c):c=e[3];const o=c;let f;if(e[4]!==o||e[5]!==s.device||e[6]!==s.model||e[7]!==s.startedAt||e[8]!==s.turnCount){if(f=[],s.model){let p;e[10]!==s.model?(p=qe(s.model),e[10]=s.model,e[11]=p):p=e[11];let m;e[12]!==p?(m=["Model",p],e[12]=p,e[13]=m):m=e[13],f.push(m)}if(s.device){let p;e[14]!==s.device.name?(p=["Device",s.device.name],e[14]=s.device.name,e[15]=p):p=e[15],f.push(p)}if(o){let p;e[16]!==o?(p=["Folder",o],e[16]=o,e[17]=p):p=e[17],f.push(p)}if(s.startedAt){let p;e[18]!==s.startedAt?(p=mt(s.startedAt),e[18]=s.startedAt,e[19]=p):p=e[19];let m;e[20]!==p?(m=["Started",p],e[20]=p,e[21]=m):m=e[21],f.push(m)}if(s.turnCount){const p=String(s.turnCount);let m;e[22]!==p?(m=["Turns",p],e[22]=p,e[23]=m):m=e[23],f.push(m)}e[4]=o,e[5]=s.device,e[6]=s.model,e[7]=s.startedAt,e[8]=s.turnCount,e[9]=f}else f=e[9];let g;e[24]!==r?(g=n.jsx("p",{className:"font-medium",children:r}),e[24]=r,e[25]=g):g=e[25];let h;e[26]!==r||e[27]!==a?(h=a&&a!==r&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:a}),e[26]=r,e[27]=a,e[28]=h):h=e[28];let l;e[29]!==f?(l=f.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:f.map(Gs)}),e[29]=f,e[30]=l):l=e[30];let w;return e[31]!==g||e[32]!==h||e[33]!==l?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[g,h,l]}),e[31]=g,e[32]=h,e[33]=l,e[34]=w):w=e[34],w}function Gs(t){const[e,s]=t;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:s})]},e)}const Vs=4e3;function Ks(t){var p;const[e,s]=C.useState(null),[r,i]=C.useState(null),[a,c]=C.useState(new Set),o=(p=Wt())==null?void 0:p.refresh,f=C.useRef(t),g=C.useRef(new Set);C.useLayoutEffect(()=>(f.current=t,()=>{f.current=null}),[t]);const h=C.useCallback(async m=>{if(t)try{const y=await ze(`/api/session-crew/${encodeURIComponent(t)}`);if(!m())return;if(!y.ok){i(y.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const k=await y.json();if(!m())return;s(b=>JSON.stringify(b)===JSON.stringify(k)?b:k),i(null)}catch{m()&&i("Couldn't load the crew.")}},[t]);it(t?h:null,Vs),C.useEffect(()=>{s(m=>m!=null&&m.members.some(y=>y.sessionId===t)?m:null),i(null),c(new Set)},[t]);const l=C.useCallback(async(m,y,k)=>{const b=`${t}:${m}`;if(g.current.has(b))return;const M=()=>f.current===t;g.current.add(b),c(N=>new Set(N).add(m));try{const N=await y();if(!M())return;if(!N.ok&&N.status!==404){i(k);return}o==null||o(),await h(M)}catch{M()&&i(k)}finally{g.current.delete(b),M()&&c(N=>{const $=new Set(N);return $.delete(m),$})}},[h,o,t]),w=C.useCallback((m,y,k)=>l(y,()=>je("/api/session-respond",{sessionId:m,requestId:y,...k}),"Couldn't send the answer."),[l]),u=C.useCallback((m,y)=>l(y,()=>je("/api/delegated-tasks",{sessionId:m,taskId:y,action:"ack"}),"Couldn't mark the result read."),[l]),x=C.useCallback(m=>l(m.sessionId,()=>{var y;return((y=m.result)==null?void 0:y.state)==="running"&&m.parentId?je("/api/delegated-tasks",{sessionId:m.parentId,taskId:m.result.taskId,action:"cancel"}):je("/api/stop-session",{sessionId:m.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[l]);return{crew:e,error:r,busy:a,respond:w,markRead:u,stop:x}}const Xs=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}],Zs={working:"bg-success shadow-[0_0_0_2px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40",failed:"bg-destructive",unreachable:"border border-muted-foreground/50"};function un(t){var U;const e=ue.c(40),{context:s,closePanel:r}=t,i=((U=s.session)==null?void 0:U.sessionId)??null,{crew:a,error:c,busy:o,respond:f,markRead:g,stop:h}=Ks(i),{names:l}=Ht(),[w,u]=C.useState("overview");let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=new Set,e[0]=x):x=e[0];const[p,m]=C.useState(x),y=Ls((a==null?void 0:a.rootId)??"");let k;e[1]!==(a==null?void 0:a.members)?(k=new Map(((a==null?void 0:a.members)??[]).map(Qs)),e[1]=a==null?void 0:a.members,e[2]=k):k=e[2];const b=k;let M;e[3]!==(a==null?void 0:a.members)?(M=new Map(((a==null?void 0:a.members)??[]).flatMap(Js)),e[3]=a==null?void 0:a.members,e[4]=M):M=e[4];const N=M;let $;e[5]!==b||e[6]!==l?($=z=>gs(z,b,l),e[5]=b,e[6]=l,e[7]=$):$=e[7];const _=$;let O;e[8]!==s?(O=z=>{z.address&&z.device?Xt(Zt(z.address.dirName,z.address.fileName,z.device.id)):z.address&&s.openSession?s.openSession(z.address.dirName,z.address.fileName):Jt(z.sessionId)},e[8]=s,e[9]=O):O=e[9];const E=O;let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=z=>m(q=>{const W=new Set(q);return W.delete(z)||W.add(z),W}),e[10]=j):j=e[10];const L=j;let I;e[11]!==b?(I=z=>{m(q=>{var v;const W=new Set(q),K=new Set;let d=z.parentId;for(;d&&!K.has(d);)K.add(d),W.delete(d),d=((v=b.get(d))==null?void 0:v.parentId)??null;return W}),requestAnimationFrame(()=>{var q;return(q=document.querySelector(`[data-crew-row="${z.sessionId}"]`))==null?void 0:q.scrollIntoView({block:"nearest",behavior:"smooth"})})},e[11]=b,e[12]=I):I=e[12];const A=I;let S,R,F;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),F=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),S=n.jsx("div",{className:"flex-1"}),e[13]=S,e[14]=R,e[15]=F):(S=e[13],R=e[14],F=e[15]);let P;e[16]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx(cs,{"data-icon":"inline-start"}),e[16]=P):P=e[16];let H;e[17]!==r?(H=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[R,F,S,n.jsx(te,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":"Close crew",children:P})]}),e[17]=r,e[18]=H):H=e[18];let D;e[19]!==c?(D=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[19]=c,e[20]=D):D=e[20];let Y;e[21]!==o||e[22]!==p||e[23]!==a||e[24]!==c||e[25]!==N||e[26]!==y||e[27]!==g||e[28]!==_||e[29]!==E||e[30]!==f||e[31]!==A||e[32]!==i||e[33]!==h||e[34]!==w?(Y=a?n.jsxs(Ut,{value:w,onValueChange:u,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[n.jsxs(Bt,{variant:"line",className:"mx-3 mb-1",children:[n.jsx(Ae,{value:"overview",children:"Overview"}),n.jsx(Ae,{value:"map",children:"Map"}),n.jsx(Ae,{value:"chat",children:"Chat"})]}),n.jsx(Oe,{value:"overview",className:"min-h-0",children:n.jsxs(ft,{className:"h-full min-h-0",children:[n.jsx(en,{crew:a,hereId:i,nameOf:_,onOpen:E,onReveal:A}),n.jsx(sn,{crew:a,busy:o,nameOf:_,onOpen:E,onRespond:f}),n.jsx(nn,{crew:a,hereId:i,busy:o,nameOf:_,onOpen:E,onMarkRead:g,onStop:h,collapsed:p,onToggle:L})]})}),n.jsx(Oe,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:a,hereId:i,controls:y,kinds:N,nameOf:_,onOpen:E})}),n.jsx(Oe,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:a.rootId,kinds:N,active:w==="chat"},a.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[21]=o,e[22]=p,e[23]=a,e[24]=c,e[25]=N,e[26]=y,e[27]=g,e[28]=_,e[29]=E,e[30]=f,e[31]=A,e[32]=i,e[33]=h,e[34]=w,e[35]=Y):Y=e[35];let G;return e[36]!==H||e[37]!==D||e[38]!==Y?(G=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[H,D,Y]}),e[36]=H,e[37]=D,e[38]=Y,e[39]=G):G=e[39],G}function Js(t){return t.address?[[t.sessionId,Gt(t.address.dirName)]]:[]}function Qs(t){return[t.sessionId,t]}function en(t){var M;const e=ue.c(46),{crew:s,hereId:r,nameOf:i,onOpen:a,onReveal:c}=t;let o,f,g,h,l;if(e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==c){let N;e[10]!==s.rootId?(N=S=>S.sessionId===s.rootId,e[10]=s.rootId,e[11]=N):N=e[11];const $=s.members.find(N),_=s.members.filter(tn);let O;e[12]!==s?(O=bs(s),e[12]=s,e[13]=O):O=e[13],l=O;const E=(M=_[0])==null?void 0:M.startedAt;o="Crew summary",f="border-b px-3 pb-3 pt-1";const j=$&&n.jsx("button",{type:"button",onClick:()=>a($),"aria-current":$.sessionId===r?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:i($)}),L=l.size===1?"session":"sessions",I=E?` · since ${mt(E)}`:"";let A;e[14]!==L||e[15]!==I||e[16]!==l.size?(A=n.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[l.size," ",L,I]}),e[14]=L,e[15]=I,e[16]=l.size,e[17]=A):A=e[17],e[18]!==A||e[19]!==j?(g=n.jsxs("div",{className:"flex items-baseline gap-2",children:[j,A]}),e[18]=A,e[19]=j,e[20]=g):g=e[20],h=_.length>0&&n.jsx("div",{"data-crew-strip":!0,className:"mt-2.5 grid grid-cols-[repeat(auto-fit,minmax(6px,1fr))] gap-[3px]",role:"list","aria-label":"One cell per session, in the order they were started",children:_.map(S=>{const R=he(S);return n.jsx("button",{type:"button",role:"listitem","data-crew-cell":R,title:`${i(S)}: ${Ie(S)}`,"aria-label":`${i(S)}: ${Ie(S)}`,onClick:()=>c(S),className:oe("h-2.5 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",Zs[R],S.sessionId===r&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},S.sessionId)})}),e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=c,e[5]=o,e[6]=f,e[7]=g,e[8]=h,e[9]=l}else o=e[5],f=e[6],g=e[7],h=e[8],l=e[9];let w;e[21]!==l.working?(w=l.working>0&&n.jsx(Ne,{dot:fe.working,value:l.working,label:"working"}),e[21]=l.working,e[22]=w):w=e[22];let u;e[23]!==l.needsYou?(u=l.needsYou>0&&n.jsx(Ne,{dot:fe["needs-you"],value:l.needsYou,label:l.needsYou===1?"needs you":"need you"}),e[23]=l.needsYou,e[24]=u):u=e[24];let x;e[25]!==l.done?(x=l.done>0&&n.jsx(Ne,{dot:fe.done,value:l.done,label:"done"}),e[25]=l.done,e[26]=x):x=e[26];let p;e[27]!==l.failed?(p=l.failed>0&&n.jsx(Ne,{dot:fe.failed,value:l.failed,label:"failed"}),e[27]=l.failed,e[28]=p):p=e[28];let m;e[29]!==l.unreachable?(m=l.unreachable>0&&n.jsx(Ne,{dot:fe.unreachable,value:l.unreachable,label:"away"}),e[29]=l.unreachable,e[30]=m):m=e[30];let y;e[31]!==l.unreadResults?(y=l.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:l.unreadResults})," ",l.unreadResults===1?"result":"results"," unread"]}),e[31]=l.unreadResults,e[32]=y):y=e[32];let k;e[33]!==y||e[34]!==w||e[35]!==u||e[36]!==x||e[37]!==p||e[38]!==m?(k=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[w,u,x,p,m,y]}),e[33]=y,e[34]=w,e[35]=u,e[36]=x,e[37]=p,e[38]=m,e[39]=k):k=e[39];let b;return e[40]!==o||e[41]!==k||e[42]!==f||e[43]!==g||e[44]!==h?(b=n.jsxs("section",{"aria-label":o,className:f,children:[g,h,k]}),e[40]=o,e[41]=k,e[42]=f,e[43]=g,e[44]=h,e[45]=b):b=e[45],b}function tn(t){return t.parentId!==null}function Ne(t){const e=ue.c(10),{dot:s,value:r,label:i}=t;let a;e[0]!==s?(a=oe("size-1.5 rounded-full",s),e[0]=s,e[1]=a):a=e[1];let c;e[2]!==a?(c=n.jsx("span",{className:a,"aria-hidden":"true"}),e[2]=a,e[3]=c):c=e[3];let o;e[4]!==r?(o=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:r}),e[4]=r,e[5]=o):o=e[5];let f;return e[6]!==i||e[7]!==c||e[8]!==o?(f=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,o," ",i]}),e[6]=i,e[7]=c,e[8]=o,e[9]=f):f=e[9],f}function sn(t){const e=ue.c(6),{crew:s,busy:r,nameOf:i,onOpen:a,onRespond:c}=t,o=ws(s),[f,g]=C.useState(0);if(o.length===0)return null;const h=Math.min(f,o.length-1),{member:l,pending:w}=o[h],u=o[h+1];let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=x):x=e[0];let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"flex-1"}),e[1]=p):p=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=n.jsx("span",{className:oe("size-1.5 shrink-0 rounded-full",fe["needs-you"]),"aria-hidden":"true"}),e[2]=m):m=e[2];const y=w.askedAt?`waiting ${We(new Date(w.askedAt).toISOString())}`:"waiting";let k;e[3]!==y?(k=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:y}),e[3]=y,e[4]=k):k=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(De,{"data-icon":"inline-end"}),e[5]=b):b=e[5],n.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[x,n.jsx("span",{className:"tabular-nums",children:o.length}),p,o.length>1&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"tabular-nums",children:[h+1," of ",o.length]}),n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:h===0,onClick:()=>g(h-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:h===o.length-1,onClick:()=>g(h+1),children:n.jsx(De,{"data-icon":"inline-start"})})]})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[m,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:i(l)}),l.device&&n.jsx(Vt,{variant:"outline",children:l.device.name}),k]}),n.jsx(Kt,{sessionId:l.sessionId,pending:w,queued:0,responding:r.has(w.requestId),onRespond:(M,N)=>void c(l.sessionId,M,N),onOpen:()=>a(l)},w.requestId),n.jsxs(te,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>a(l),children:["Open session",b]})]}),u&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:i(u.member)})," ",Ie(u.member).toLowerCase()]})]})}function nn({crew:t,hereId:e,busy:s,nameOf:r,onOpen:i,onMarkRead:a,onStop:c,collapsed:o,onToggle:f}){const[g,h]=C.useState("all");let l=null;const w=xs(t).filter(({member:u,depth:x})=>{if(g!=="all"){const p=he(u);return g==="done"?p!=="working"&&p!=="needs-you":p===g}return l!==null&&x>l?!1:(l=o.has(u.sessionId)?x:null,!0)});return n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),n.jsx("span",{className:"flex-1"}),n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:Xs.map(({id:u,label:x})=>n.jsx("button",{type:"button",role:"radio","aria-checked":g===u,onClick:()=>h(u),className:oe("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",g===u&&"bg-accent text-foreground"),children:x},u))})]}),w.length===0?n.jsx("p",{className:"px-1.5 py-4 text-center text-xs text-muted-foreground",children:"No sessions here."}):n.jsx("ul",{className:"flex flex-col",children:w.map(u=>n.jsx(on,{row:u,here:u.member.sessionId===e,busy:s,name:r(u.member),onOpen:i,onMarkRead:a,onStop:c,collapsed:g==="all"?o.has(u.member.sessionId):void 0,onToggle:()=>f(u.member.sessionId)},u.member.sessionId))})]})}function on(t){var ce,pe;const e=ue.c(81),{row:s,here:r,busy:i,name:a,onOpen:c,onMarkRead:o,onStop:f,collapsed:g,onToggle:h}=t,{member:l,depth:w,children:u}=s;let x;e[0]!==l?(x=he(l),e[0]=l,e[1]=x):x=e[1];const p=x;let m;e[2]!==l?(m=Ie(l),e[2]=l,e[3]=m):m=e[3];const y=m;let k;e[4]!==l.pullRequests?(k=(ce=l.pullRequests)==null?void 0:ce.at(-1),e[4]=l.pullRequests,e[5]=k):k=e[5];const b=k;let M;e[6]!==l?(M=Re(l)&&l.result&&l.parentId,e[6]=l,e[7]=M):M=e[7];const N=M,$=(p==="working"||p==="needs-you")&&(!l.device||((pe=l.result)==null?void 0:pe.state)==="running"&&l.parentId!==null),_=l.sessionId,O=r?"bg-accent":"hover:bg-accent/60",E=w>0&&"border-l border-border/70";let j;e[8]!==O||e[9]!==E?(j=oe("group/crew relative flex items-start rounded-md",O,E),e[8]=O,e[9]=E,e[10]=j):j=e[10];const L=w>0?6+(w-1)*14:0;let I;e[11]!==L?(I={marginLeft:L},e[11]=L,e[12]=I):I=e[12];let A;e[13]!==u||e[14]!==g||e[15]!==a||e[16]!==h?(A=u>0&&g!==void 0&&n.jsx(te,{variant:"ghost",size:"icon-xs","aria-label":`${g?"Expand":"Collapse"} ${a}'s child sessions`,"aria-expanded":!g,onClick:h,children:n.jsx(De,{"data-icon":"inline-start",className:oe("transition-transform",!g&&"rotate-90")})}),e[13]=u,e[14]=g,e[15]=a,e[16]=h,e[17]=A):A=e[17];let S;e[18]!==A?(S=n.jsx("span",{className:"mt-1.5 flex w-6 shrink-0 justify-center",children:A}),e[18]=A,e[19]=S):S=e[19];let R;e[20]!==l||e[21]!==c?(R=()=>c(l),e[20]=l,e[21]=c,e[22]=R):R=e[22];const F=r?"true":void 0,P=`${a}, ${y}`,H=fe[p];let D;e[23]!==H?(D=oe("size-1.5 justify-self-center rounded-full",H),e[23]=H,e[24]=D):D=e[24];let Y;e[25]!==D?(Y=n.jsx("span",{className:D,"aria-hidden":"true"}),e[25]=D,e[26]=Y):Y=e[26];let G;e[27]!==a?(G=n.jsx("span",{className:"truncate",children:a}),e[27]=a,e[28]=G):G=e[28];let U;e[29]!==r?(U=r&&n.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[29]=r,e[30]=U):U=e[30];let z;e[31]!==G||e[32]!==U?(z=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[G,U]}),e[31]=G,e[32]=U,e[33]=z):z=e[33];let q;e[34]!==l.lastActivityAt?(q=l.lastActivityAt?We(l.lastActivityAt):"",e[34]=l.lastActivityAt,e[35]=q):q=e[35];let W;e[36]!==q?(W=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:q}),e[36]=q,e[37]=W):W=e[37];const K=(p==="needs-you"||N)&&"text-warning",d=p==="failed"&&"text-destructive";let v;e[38]!==K||e[39]!==d?(v=oe("min-w-0 flex-1 truncate",K,d),e[38]=K,e[39]=d,e[40]=v):v=e[40];let T;e[41]!==y||e[42]!==v?(T=n.jsx("span",{className:v,children:y}),e[41]=y,e[42]=v,e[43]=T):T=e[43];let X;e[44]!==b?(X=b&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",b.number]}),e[44]=b,e[45]=X):X=e[45];let ae;e[46]!==l.device?(ae=l.device&&n.jsx("span",{className:"shrink-0",children:l.device.name}),e[46]=l.device,e[47]=ae):ae=e[47];let J;e[48]!==u?(J=u>0&&n.jsxs("span",{className:"shrink-0",children:[u," ",u===1?"session":"sessions"]}),e[48]=u,e[49]=J):J=e[49];let Q;e[50]!==l.model?(Q=l.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:qe(l.model)}),e[50]=l.model,e[51]=Q):Q=e[51];let ee;e[52]!==T||e[53]!==X||e[54]!==ae||e[55]!==J||e[56]!==Q?(ee=n.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[T,X,ae,J,Q]}),e[52]=T,e[53]=X,e[54]=ae,e[55]=J,e[56]=Q,e[57]=ee):ee=e[57];let se;e[58]!==R||e[59]!==F||e[60]!==P||e[61]!==Y||e[62]!==z||e[63]!==W||e[64]!==ee?(se=n.jsxs("button",{type:"button",onClick:R,"aria-current":F,"aria-label":P,className:"grid min-w-0 flex-1 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[Y,z,W,ee]}),e[58]=R,e[59]=F,e[60]=P,e[61]=Y,e[62]=z,e[63]=W,e[64]=ee,e[65]=se):se=e[65];let re;e[66]!==i||e[67]!==$||e[68]!==l||e[69]!==a||e[70]!==o||e[71]!==f||e[72]!==N?(re=(N||$)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[N&&l.result&&l.parentId&&n.jsx(te,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${a}'s result read`,title:"Mark the result read",disabled:i.has(l.result.taskId),onClick:()=>void o(l.parentId,l.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),$&&n.jsx(te,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${a}`,title:"Stop this session",disabled:i.has(l.sessionId),onClick:()=>void f(l),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[66]=i,e[67]=$,e[68]=l,e[69]=a,e[70]=o,e[71]=f,e[72]=N,e[73]=re):re=e[73];let Z;return e[74]!==l.sessionId||e[75]!==I||e[76]!==S||e[77]!==se||e[78]!==re||e[79]!==j?(Z=n.jsxs("li",{"data-crew-row":_,className:j,style:I,children:[S,se,re]}),e[74]=l.sessionId,e[75]=I,e[76]=S,e[77]=se,e[78]=re,e[79]=j,e[80]=Z):Z=e[80],Z}export{un as CrewPanel};
@@ -0,0 +1,2 @@
1
+ import{c as T,r as L,j as c}from"./vendor-react-gGw_S5I_.js";import{c$ as _,d0 as C,d1 as D,c as H}from"./index-BVmNox_3.js";function K(r){const e=T.c(26),{value:t,onChange:j,readOnly:i,filePath:k,ariaLabel:R,textareaRef:f,onKeyDown:v,onSelect:w}=r,N=_(),u=L.useRef(null),p=L.useRef(null);let d;e[0]!==k?(d=C(k),e[0]=k,e[1]=d):d=e[1];const h=D(t,d,N,80);let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{u.current&&p.current&&(p.current.scrollTop=u.current.scrollTop,p.current.scrollLeft=u.current.scrollLeft)},e[2]=m):m=e[2];const S=m;let x;e[3]!==f?(x=b=>{u.current=b,f&&(f.current=b)},e[3]=f,e[4]=x):x=e[4];const y=x;let l;e[5]!==h||e[6]!==t?(l=h?h.map(P):c.jsx("code",{className:"text-foreground",children:t}),e[5]=h,e[6]=t,e[7]=l):l=e[7];let n;e[8]!==l?(n=c.jsx("pre",{ref:p,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",children:l}),e[8]=l,e[9]=n):n=e[9];let s;e[10]!==j?(s=b=>j(b.target.value),e[10]=j,e[11]=s):s=e[11];const E=i&&"cursor-default";let a;e[12]!==E?(a=H("absolute inset-0 w-full h-full resize-none bg-transparent font-mono text-[13px] leading-relaxed p-4 outline-none","text-transparent caret-foreground selection:bg-selection","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",E),e[12]=E,e[13]=a):a=e[13];let o;e[14]!==R||e[15]!==y||e[16]!==v||e[17]!==w||e[18]!==i||e[19]!==s||e[20]!==a||e[21]!==t?(o=c.jsx("textarea",{ref:y,"aria-label":R,value:t,onChange:s,onScroll:S,onKeyDown:v,onSelect:w,readOnly:i,spellCheck:!1,className:a,placeholder:"Empty file"}),e[14]=R,e[15]=y,e[16]=v,e[17]=w,e[18]=i,e[19]=s,e[20]=a,e[21]=t,e[22]=o):o=e[22];let g;return e[23]!==n||e[24]!==o?(g=c.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[n,o]}),e[23]=n,e[24]=o,e[25]=g):g=e[25],g}function P(r,e){return c.jsxs("span",{children:[r.map($),`
2
+ `]},e)}function $(r,e){return c.jsx("span",{style:{color:r.color},children:r.content},e)}export{K as H};
@@ -0,0 +1 @@
1
+ import{c as O,j as t,r as I}from"./vendor-react-gGw_S5I_.js";import{o as H,bB as $,bC as T,bD as Q,B as P,bE as Y,bF as _,n as q,l as J,D as M,j as U,S as V,ax as W,az as X,aw as Z,bG as ee,G as te,I as se,m as ae,bH as le,bI as ne,bJ as re}from"./index-BVmNox_3.js";import{bI as F,df as oe,ak as ce}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function pe(e){const s=O.c(6),{open:f,onOpenChange:l}=e,x=f?"open":"closed";let a;s[0]!==x?(a=t.jsx(de,{},x),s[0]=x,s[1]=a):a=s[1];let r;return s[2]!==l||s[3]!==f||s[4]!==a?(r=t.jsx(H,{open:f,onOpenChange:l,children:a}),s[2]=l,s[3]=f,s[4]=a,s[5]=r):r=s[5],r}function de(){const e=O.c(45),[s,f]=I.useState(""),[l,x]=I.useState(null),[a,r]=I.useState(null),[A,B]=I.useState($);let E,k;e[0]!==l?(E=()=>{if(!l)return;const v=l,G=function(n){if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),x(null),r(null);return}if(ie.has(n.key))return;n.preventDefault(),n.stopPropagation();const c=le(n),p=ne(c,v);if(p){r(`Already assigned to “${p.label}”.`);return}re(v,c),B($()),x(null),r(null)};return window.addEventListener("keydown",G,!0),()=>window.removeEventListener("keydown",G,!0)},k=[l],e[0]=l,e[1]=E,e[2]=k):(E=e[1],k=e[2]),I.useEffect(E,k);let b,g,d,j,y,N,S,w,m,u,h;if(e[3]!==A||e[4]!==a||e[5]!==s||e[6]!==l){const v=s.trim().toLowerCase(),G=v?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(v)):T;g=q,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(J,{className:"p-4 pb-3",children:[t.jsxs(M,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(U,{children:"Click a shortcut, then press a new key combination. Changes are saved on this device."})]}),u=t.jsx(V,{}),e[18]=m,e[19]=u):(m=e[18],u=e[19]);let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(W,{children:t.jsx(ce,{"data-icon":"inline-start","aria-hidden":"true"})}),e[20]=K):K=e[20];let n;e[21]===Symbol.for("react.memo_cache_sentinel")?(n=i=>f(i.target.value),e[21]=n):n=e[21];let c;e[22]!==s?(c=t.jsxs(X,{className:"flex-1",children:[K,t.jsx(Z,{"aria-label":"Search keyboard shortcuts",value:s,onChange:n,placeholder:"Search shortcuts…"})]}),e[22]=s,e[23]=c):c=e[23];let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs(P,{variant:"outline",size:"sm",onClick:()=>{ee(),B($()),r(null)},children:[t.jsx(F,{"data-icon":"inline-start"}),"Reset all"]}),e[24]=p):p=e[24],e[25]!==c?(h=t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[c,p]}),e[25]=c,e[26]=h):h=e[26],e[27]!==a?(d=a&&t.jsx(te,{variant:"destructive",className:"mx-3 mb-2 w-auto",children:t.jsxs(se,{children:[a," Press another shortcut or Esc to cancel."]})}),e[27]=a,e[28]=d):d=e[28],b=ae,N="h-[min(28rem,60vh)]",j="flex flex-col gap-4 px-3 pb-4",y=Q.map(i=>{const L=G.filter(o=>o.group===i);return L.length===0?null:t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:i}),L.map(o=>{const z=l===o.command;return t.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm",children:o.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.description})]}),t.jsx(P,{variant:z?"secondary":"outline",size:"sm",className:"min-w-28 font-mono text-xs",onClick:()=>{r(null),x(z?null:o.command)},"aria-label":`Change shortcut for ${o.label}`,children:z?"Press keys…":Y(A[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),B($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(F,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=A,e[4]=a,e[5]=s,e[6]=l,e[7]=b,e[8]=g,e[9]=d,e[10]=j,e[11]=y,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else b=e[7],g=e[8],d=e[9],j=e[10],y=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==j||e[30]!==y?(C=t.jsx("div",{className:j,children:y}),e[29]=j,e[30]=y,e[31]=C):C=e[31];let D;e[32]!==b||e[33]!==C||e[34]!==N?(D=t.jsx(b,{className:N,children:C}),e[32]=b,e[33]=C,e[34]=N,e[35]=D):D=e[35];let R;return e[36]!==g||e[37]!==d||e[38]!==D||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(g,{className:S,showCloseButton:w,children:[m,u,h,d,D]}),e[36]=g,e[37]=d,e[38]=D,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{pe as KeyboardShortcutsDialog};
@@ -0,0 +1,2 @@
1
+ import{c as V,r as X,j as t}from"./vendor-react-gGw_S5I_.js";import{cd as Ee,c as Z,ce as Pe,al as ke,ag as _e,cf as qe,cg as ue,ad as Me,B as Q,ch as Re,ci as Oe,bK as ze,cj as Te,au as me,H as xe,G as ge,bA as $e,ck as ae,aA as Ke,aB as Be,cl as Fe,cm as Le,cn as Ue,co as He,cp as Qe,cq as fe,cr as Ve,cs as Ye,ct as Ge,ah as Xe,cu as We,V as ie,E as Je,f as Ze,i as es,cv as ss,k as ts,cw as re,cx as ns,cy as is,cz as ls,b8 as rs,cA as os}from"./index-BVmNox_3.js";import{bl as pe,aP as as,bM as cs,U as ds,b1 as us,b4 as fs,dv as ms,A as Se,bp as xs,ak as gs,X as ps,al as hs,C as ws}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";const bs=6;function js(u){const e=V.c(72),{recent:s,start:i}=u,[l,r]=X.useState(null),[n,g]=X.useState(""),a=l??s[0]??null;let c,p,d,f,o,x,m,w,h,b,v,j,N;if(e[0]!==l||e[1]!==a||e[2]!==s||e[3]!==i||e[4]!==n){p=(l&&!s.some(E=>we(E,l))?[l,...s]:[...s]).slice(0,bs);let z;e[18]!==n?(z=n.trim(),e[18]=n,e[19]=z):z=e[19];const F=z;c=!!(a&&F);let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(E,Y)=>{r({dirName:E,cwd:Y,name:Y?qe(Y):E})},e[20]=C):C=e[20],d=C;let K;e[21]!==i.defaultAgentKind?(K=E=>d(ue(i.defaultAgentKind,E),E),e[21]=i.defaultAgentKind,e[22]=K):K=e[22],f=K;const G=a==null?void 0:a.cwd;let L;e[23]!==G||e[24]!==a?(L=a&&G?E=>r({...a,dirName:ue(E,G)}):void 0,e[23]=G,e[24]=a,e[25]=L):L=e[25],m=L;let W;e[26]!==F||e[27]!==a||e[28]!==i?(W=E=>{E==null||E.preventDefault(),!(!a||!F)&&(i.onStart(a.dirName,a.cwd,F),g(""))},e[26]=F,e[27]=a,e[28]=i,e[29]=W):W=e[29],x=W;let J;e[30]!==x?(J=E=>{E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),x())},e[30]=x,e[31]=J):J=e[31],o=J,j="Start a session",N="flex min-w-0 flex-col gap-3",w="flex flex-wrap items-center gap-1.5",h="group",b="Projects",v=p.map(E=>{const Y=a!==null&&we(E,a);return t.jsxs("button",{type:"button","aria-pressed":Y,title:E.cwd??E.name,onClick:()=>r(E),className:Z("flex max-w-48 items-center gap-1.5 rounded-full border py-1 pl-1.5 pr-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",Y?"border-foreground/80 bg-foreground text-background":"border-border/70 text-muted-foreground hover:border-foreground/40 hover:text-foreground"),children:[t.jsx(Ee,{projectPath:E.cwd??null,fallback:t.jsx(pe,{className:"size-3.5","aria-hidden":"true"}),className:"size-4"}),t.jsx("span",{className:"truncate",children:E.name})]},E.cwd??E.dirName)}),e[0]=l,e[1]=a,e[2]=s,e[3]=i,e[4]=n,e[5]=c,e[6]=p,e[7]=d,e[8]=f,e[9]=o,e[10]=x,e[11]=m,e[12]=w,e[13]=h,e[14]=b,e[15]=v,e[16]=j,e[17]=N}else c=e[5],p=e[6],d=e[7],f=e[8],o=e[9],x=e[10],m=e[11],w=e[12],h=e[13],b=e[14],v=e[15],j=e[16],N=e[17];const I=p.length>0;let y;e[32]!==d||e[33]!==f||e[34]!==i.defaultAgentKind||e[35]!==I?(y=t.jsx(Ns,{defaultAgentKind:i.defaultAgentKind,onChoose:d,onChooseFolder:f,anyListed:I}),e[32]=d,e[33]=f,e[34]=i.defaultAgentKind,e[35]=I,e[36]=y):y=e[36];let k;e[37]!==w||e[38]!==h||e[39]!==b||e[40]!==v||e[41]!==y?(k=t.jsxs("div",{className:w,role:h,"aria-label":b,children:[v,y]}),e[37]=w,e[38]=h,e[39]=b,e[40]=v,e[41]=y,e[42]=k):k=e[42];let A;e[43]!==l||e[44]!==a?(A=z=>{!l&&a&&r(a),g(z.target.value)},e[43]=l,e[44]=a,e[45]=A):A=e[45];const D=a?`Describe the task for ${a.name}`:"Pick a project, then describe the task";let q;e[46]!==o||e[47]!==A||e[48]!==D||e[49]!==n?(q=t.jsx(Me,{"aria-label":"First message",value:n,onChange:A,onKeyDown:o,placeholder:D,rows:1,className:"max-h-48 min-h-9 flex-1 resize-none rounded-none border-0 bg-transparent px-0 py-2 shadow-none focus-visible:border-transparent focus-visible:ring-0"}),e[46]=o,e[47]=A,e[48]=D,e[49]=n,e[50]=q):q=e[50];let S;e[51]!==a||e[52]!==i.model||e[53]!==m?(S=a&&t.jsx(Pe,{isNewSession:!0,agentKind:ke(a.dirName),onAgentKindChange:m,selectedModel:i.model.selectedModel,onModelChange:i.model.onModelChange,selectedEffort:i.model.selectedEffort,onEffortChange:i.model.onEffortChange}),e[51]=a,e[52]=i.model,e[53]=m,e[54]=S):S=e[54];const _=!c;let R;e[55]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(as,{"data-icon":"icon"}),e[55]=R):R=e[55];let M;e[56]!==_?(M=t.jsx(Q,{type:"submit",size:"icon-xs",disabled:_,"aria-label":"Start session",title:"Start session (Enter)",children:R}),e[56]=_,e[57]=M):M=e[57];let P;e[58]!==S||e[59]!==M?(P=t.jsxs("div",{className:"flex shrink-0 items-center gap-1 pb-0.5",children:[S,M]}),e[58]=S,e[59]=M,e[60]=P):P=e[60];let O;e[61]!==q||e[62]!==P?(O=t.jsxs("div",{className:"flex items-end gap-2 rounded-xl border bg-popover py-2 pl-4 pr-2 shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",children:[q,P]}),e[61]=q,e[62]=P,e[63]=O):O=e[63];let T;e[64]!==x||e[65]!==O?(T=t.jsx("form",{onSubmit:x,className:"min-w-0",children:O}),e[64]=x,e[65]=O,e[66]=T):T=e[66];let $;return e[67]!==T||e[68]!==j||e[69]!==N||e[70]!==k?($=t.jsxs("section",{"aria-label":j,className:N,children:[k,T]}),e[67]=T,e[68]=j,e[69]=N,e[70]=k,e[71]=$):$=e[71],$}function we(u,e){return u.cwd&&e.cwd?u.cwd===e.cwd:u.dirName===e.dirName}function Ns(u){const e=V.c(19),{defaultAgentKind:s,onChoose:i,onChooseFolder:l,anyListed:r}=u,[n,g]=X.useState(!1),a=_e(n),c=r?"ghost":"outline";let p;e[0]!==c?(p=t.jsx(Q,{variant:c,size:"xs",className:"rounded-full text-muted-foreground"}),e[0]=c,e[1]=p):p=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(pe,{"data-icon":"inline-start"}),e[2]=d):d=e[2];const f=r?"Other project":"Choose a project";let o;e[3]!==p||e[4]!==f?(o=t.jsxs(Re,{render:p,children:[d,f]}),e[3]=p,e[4]=f,e[5]=o):o=e[5];let x;e[6]!==i?(x=(b,v)=>{g(!1),i(b,v)},e[6]=i,e[7]=x):x=e[7];let m;e[8]!==l?(m=b=>{g(!1),l(b)},e[8]=l,e[9]=m):m=e[9];let w;e[10]!==s||e[11]!==a||e[12]!==x||e[13]!==m?(w=t.jsx(Oe,{align:"start",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:t.jsx(ze,{projects:a,defaultAgentKind:s,onNewSession:x,onNewFolder:m})}),e[10]=s,e[11]=a,e[12]=x,e[13]=m,e[14]=w):w=e[14];let h;return e[15]!==n||e[16]!==o||e[17]!==w?(h=t.jsxs(Te,{open:n,onOpenChange:g,children:[o,w]}),e[15]=n,e[16]=o,e[17]=w,e[18]=h):h=e[18],h}function ys(u){const e={};for(const s of u)s.type==="boolean"?e[s.name]=s.defaultValue===!0:s.defaultValue!==void 0?e[s.name]=String(s.defaultValue):e[s.name]="";return e}function vs(u,e){const s={};for(const i of u){const l=e[i.name];if(typeof l=="boolean"){s[i.name]=l;continue}l!==""&&(s[i.name]=i.type==="number"||i.type==="integer"?Number(l):l)}return s}function Is(u,e){return u.every(s=>{if(!s.required)return!0;const i=e[s.name];return typeof i=="boolean"?!0:i===""?!1:s.type==="number"||s.type==="integer"?Number.isFinite(Number(i)):!0})}function ks(u){const e=V.c(52),{request:s,responding:i,onAnswer:l}=u;let r;e[0]!==s.fields?(r=()=>ys(s.fields),e[0]=s.fields,e[1]=r):r=e[1];const[n,g]=X.useState(r);let a;e[2]!==s.fields||e[3]!==n?(a=Is(s.fields,n),e[2]=s.fields,e[3]=n,e[4]=a):a=e[4];const c=a,p=s.displayName||s.title||s.serverName;let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=(j,N)=>{g(I=>({...I,[j]:N}))},e[5]=d):d=e[5];const f=d;let o;e[6]!==l||e[7]!==s.requestId?(o=()=>l==null?void 0:l(s.requestId,{action:"decline"}),e[6]=l,e[7]=s.requestId,e[8]=o):o=e[8];const x=o;if(s.mode==="url"&&s.url){const j=s.url;let N;e[9]!==s.message?(N=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[9]=s.message,e[10]=N):N=e[10];let I;e[11]!==j?(I=t.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:j,children:j}),e[11]=j,e[12]=I):I=e[12];let y;e[13]!==x||e[14]!==l||e[15]!==s.requestId||e[16]!==i||e[17]!==j?(y=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsxs(Q,{size:"sm",disabled:i,onClick:()=>{window.open(j,"_blank","noopener,noreferrer"),l(s.requestId,{action:"accept"})},children:["Open link",t.jsx(cs,{"data-icon":"inline-end"})]}),t.jsx(Q,{variant:"ghost",size:"sm",disabled:i,onClick:x,children:"Decline"})]}),e[13]=x,e[14]=l,e[15]=s.requestId,e[16]=i,e[17]=j,e[18]=y):y=e[18];let k;return e[19]!==p||e[20]!==N||e[21]!==I||e[22]!==y?(k=t.jsxs(be,{server:p,children:[N,I,y]}),e[19]=p,e[20]=N,e[21]=I,e[22]=y,e[23]=k):k=e[23],k}let m;e[24]!==s.message?(m=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[24]=s.message,e[25]=m):m=e[25];let w;if(e[26]!==l||e[27]!==s.fields||e[28]!==s.requestId||e[29]!==i||e[30]!==n){let j;e[32]!==l||e[33]!==s.requestId||e[34]!==i||e[35]!==n?(j=N=>t.jsx(qs,{id:`elicit-${s.requestId}-${N.name}`,field:N,value:n[N.name],disabled:i||!l,onChange:I=>f(N.name,I)},N.name),e[32]=l,e[33]=s.requestId,e[34]=i,e[35]=n,e[36]=j):j=e[36],w=s.fields.map(j),e[26]=l,e[27]=s.fields,e[28]=s.requestId,e[29]=i,e[30]=n,e[31]=w}else w=e[31];let h;e[37]!==w?(h=t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:w}),e[37]=w,e[38]=h):h=e[38];let b;e[39]!==c||e[40]!==x||e[41]!==l||e[42]!==s.fields||e[43]!==s.requestId||e[44]!==i||e[45]!==n?(b=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx(Q,{size:"sm",disabled:i||!c,onClick:()=>l(s.requestId,{action:"accept",content:vs(s.fields,n)}),children:"Send"}),t.jsx(Q,{variant:"ghost",size:"sm",disabled:i,onClick:x,children:"Decline"})]}),e[39]=c,e[40]=x,e[41]=l,e[42]=s.fields,e[43]=s.requestId,e[44]=i,e[45]=n,e[46]=b):b=e[46];let v;return e[47]!==p||e[48]!==m||e[49]!==h||e[50]!==b?(v=t.jsxs(be,{server:p,children:[m,h,b]}),e[47]=p,e[48]=m,e[49]=h,e[50]=b,e[51]=v):v=e[51],v}function qs(u){const e=V.c(55),{id:s,field:i,value:l,disabled:r,onChange:n}=u;if(i.type==="boolean"){const x=l===!0;let m;e[0]!==n?(m=v=>n(v===!0),e[0]=n,e[1]=m):m=e[1];let w;e[2]!==r||e[3]!==s||e[4]!==x||e[5]!==m?(w=t.jsx($e,{id:s,checked:x,disabled:r,onCheckedChange:m}),e[2]=r,e[3]=s,e[4]=x,e[5]=m,e[6]=w):w=e[6];let h;e[7]!==i?(h=t.jsx(ce,{field:i}),e[7]=i,e[8]=h):h=e[8];let b;return e[9]!==s||e[10]!==w||e[11]!==h?(b=t.jsxs(ae,{htmlFor:s,className:"items-start gap-2 font-normal",children:[w,h]}),e[9]=s,e[10]=w,e[11]=h,e[12]=b):b=e[12],b}if(i.type==="enum"){let x;e[13]!==i?(x=t.jsx(ce,{field:i}),e[13]=i,e[14]=x):x=e[14];let m;e[15]!==s||e[16]!==x?(m=t.jsx(ae,{htmlFor:s,children:x}),e[15]=s,e[16]=x,e[17]=m):m=e[17];let w;e[18]!==l?(w=typeof l=="string"&&l?[l]:[],e[18]=l,e[19]=w):w=e[19];let h;e[20]!==n?(h=y=>{y[0]&&n(y[0])},e[20]=n,e[21]=h):h=e[21];const b=i.label;let v;e[22]!==i.options?(v=i.options??[],e[22]=i.options,e[23]=v):v=e[23];let j;if(e[24]!==r||e[25]!==v){let y;e[27]!==r?(y=k=>t.jsx(Ke,{value:k.value,disabled:r,className:"w-full justify-start px-3",children:k.label},k.value),e[27]=r,e[28]=y):y=e[28],j=v.map(y),e[24]=r,e[25]=v,e[26]=j}else j=e[26];let N;e[29]!==i.label||e[30]!==s||e[31]!==w||e[32]!==h||e[33]!==j?(N=t.jsx(Be,{id:s,value:w,onValueChange:h,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":b,children:j}),e[29]=i.label,e[30]=s,e[31]=w,e[32]=h,e[33]=j,e[34]=N):N=e[34];let I;return e[35]!==m||e[36]!==N?(I=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,N]}),e[35]=m,e[36]=N,e[37]=I):I=e[37],I}let g;e[38]!==i?(g=t.jsx(ce,{field:i}),e[38]=i,e[39]=g):g=e[39];let a;e[40]!==s||e[41]!==g?(a=t.jsx(ae,{htmlFor:s,children:g}),e[40]=s,e[41]=g,e[42]=a):a=e[42];const c=i.type==="string"?"text":"number",p=typeof l=="string"?l:"";let d;e[43]!==n?(d=x=>n(x.target.value),e[43]=n,e[44]=d):d=e[44];let f;e[45]!==r||e[46]!==i.label||e[47]!==s||e[48]!==c||e[49]!==p||e[50]!==d?(f=t.jsx(me,{id:s,"aria-label":i.label,type:c,value:p,disabled:r,onChange:d}),e[45]=r,e[46]=i.label,e[47]=s,e[48]=c,e[49]=p,e[50]=d,e[51]=f):f=e[51];let o;return e[52]!==a||e[53]!==f?(o=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[a,f]}),e[52]=a,e[53]=f,e[54]=o):o=e[54],o}function ce(u){const e=V.c(8),{field:s}=u;let i;e[0]!==s.required?(i=s.required&&t.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=s.required,e[1]=i):i=e[1];let l;e[2]!==s.description?(l=s.description&&t.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:s.description}),e[2]=s.description,e[3]=l):l=e[3];let r;return e[4]!==s.label||e[5]!==i||e[6]!==l?(r=t.jsxs("span",{className:"min-w-0",children:[s.label,i,l]}),e[4]=s.label,e[5]=i,e[6]=l,e[7]=r):r=e[7],r}function be(u){const e=V.c(8),{server:s,children:i}=u;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(ds,{className:"text-info"}),e[0]=l):l=e[0];let r;e[1]!==s?(r=t.jsxs(xe,{children:[s," needs input"]}),e[1]=s,e[2]=r):r=e[2];let n;e[3]!==i?(n=t.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:i}),e[3]=i,e[4]=n):n=e[4];let g;return e[5]!==r||e[6]!==n?(g=t.jsxs(ge,{className:"border-info/40 bg-info/5",children:[l,r,n]}),e[5]=r,e[6]=n,e[7]=g):g=e[7],g}function Ss(u){const e=V.c(15),{request:s,responding:i,onChoose:l}=u;let r,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(us,{className:"text-warning"}),n=t.jsx(xe,{children:"The agent declined this request"}),e[0]=r,e[1]=n):(r=e[0],n=e[1]);let g;e[2]!==s.originalModel?(g=t.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[s.originalModel," would not answer. Retrying on a fallback model may work."]}),e[2]=s.originalModel,e[3]=g):g=e[3];let a;e[4]!==s.guidanceText?(a=s.guidanceText&&t.jsx("p",{className:"mt-1 text-sm leading-relaxed text-muted-foreground",children:s.guidanceText}),e[4]=s.guidanceText,e[5]=a):a=e[5];let c;e[6]!==l||e[7]!==s.fallbackModel||e[8]!==s.requestId||e[9]!==i?(c=l&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(Q,{size:"sm",disabled:i,onClick:()=>l(s.requestId,"retry_fallback"),children:["Retry on ",s.fallbackModel]}),t.jsx(Q,{variant:"outline",size:"sm",disabled:i,onClick:()=>l(s.requestId,"edit_prompt"),children:"Edit prompt"}),t.jsx(Q,{variant:"ghost",size:"sm",disabled:i,className:"ml-auto text-muted-foreground",onClick:()=>l(s.requestId,"cancelled"),children:"Dismiss"})]}),e[6]=l,e[7]=s.fallbackModel,e[8]=s.requestId,e[9]=i,e[10]=c):c=e[10];let p;return e[11]!==g||e[12]!==a||e[13]!==c?(p=t.jsxs(ge,{className:"border-warning/40 bg-warning/5",children:[r,n,t.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[g,a,c]})]}),e[11]=g,e[12]=a,e[13]=c,e[14]=p):p=e[14],p}function Cs(u){const e=V.c(64),{request:s,input:i,canAnswer:l,onOpen:r}=u;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[g,a]=X.useState(n),{sessionId:c}=s;switch(s.kind){case"permission":{const p=s.request;let d;e[1]!==i.responding||e[2]!==s.request.requestId?(d=i.responding.has(s.request.requestId),e[1]=i.responding,e[2]=s.request.requestId,e[3]=d):d=e[3];let f;e[4]!==l||e[5]!==i||e[6]!==c?(f=l?(x,m)=>void i.respond(c,x,m):void 0,e[4]=l,e[5]=i,e[6]=c,e[7]=f):f=e[7];let o;return e[8]!==s.request||e[9]!==d||e[10]!==f?(o=t.jsx(Le,{request:p,queued:0,responding:d,onRespond:f}),e[8]=s.request,e[9]=d,e[10]=f,e[11]=o):o=e[11],o}case"question":{const p=s.request;let d;e[12]!==i.responding||e[13]!==s.request.toolUseId?(d=i.responding.has(s.request.toolUseId),e[12]=i.responding,e[13]=s.request.toolUseId,e[14]=d):d=e[14];let f;e[15]!==g||e[16]!==s.request.toolUseId?(f=g.has(s.request.toolUseId),e[15]=g,e[16]=s.request.toolUseId,e[17]=f):f=e[17];let o;e[18]!==l||e[19]!==i||e[20]!==c?(o=l?async(m,w)=>{(await i.answerQuestion(c,m,w)).gone&&a(b=>new Set(b).add(m))}:void 0,e[18]=l,e[19]=i,e[20]=c,e[21]=o):o=e[21];let x;return e[22]!==r||e[23]!==s.request||e[24]!==d||e[25]!==f||e[26]!==o?(x=t.jsx(Fe,{request:p,responding:d,gone:f,onAnswer:o,onOpenSession:r}),e[22]=r,e[23]=s.request,e[24]=d,e[25]=f,e[26]=o,e[27]=x):x=e[27],x}case"elicitation":{const p=s.request;let d;e[28]!==i.responding||e[29]!==s.request.requestId?(d=i.responding.has(s.request.requestId),e[28]=i.responding,e[29]=s.request.requestId,e[30]=d):d=e[30];let f;e[31]!==l||e[32]!==i||e[33]!==c?(f=l?(x,m)=>void i.answerElicitation(c,x,m):void 0,e[31]=l,e[32]=i,e[33]=c,e[34]=f):f=e[34];let o;return e[35]!==s.request||e[36]!==d||e[37]!==f?(o=t.jsx(ks,{request:p,responding:d,onAnswer:f}),e[35]=s.request,e[36]=d,e[37]=f,e[38]=o):o=e[38],o}case"dialog":{const p=s.request;let d;e[39]!==i.responding||e[40]!==s.request.requestId?(d=i.responding.has(s.request.requestId),e[39]=i.responding,e[40]=s.request.requestId,e[41]=d):d=e[41];let f;e[42]!==l||e[43]!==i||e[44]!==c?(f=l?(x,m)=>void i.answerDialog(c,x,m):void 0,e[42]=l,e[43]=i,e[44]=c,e[45]=f):f=e[45];let o;return e[46]!==s.request||e[47]!==d||e[48]!==f?(o=t.jsx(Ss,{request:p,responding:d,onChoose:f}),e[46]=s.request,e[47]=d,e[48]=f,e[49]=o):o=e[49],o}case"plan":case"deferred":{let p;e[50]!==s.kind?(p=s.kind==="plan"?t.jsx(fs,{className:"text-warning"}):t.jsx(ms,{className:"text-warning"}),e[50]=s.kind,e[51]=p):p=e[51];const d=s.kind==="plan"?"A plan is waiting for review":"A permission was deferred";let f;e[52]!==d?(f=t.jsx(xe,{children:d}),e[52]=d,e[53]=f):f=e[53];const o=s.kind==="plan"?"Review it in its session.":"Open the session and resume it to answer.";let x;e[54]!==o?(x=t.jsx("p",{className:"col-start-2 mt-1 text-sm text-muted-foreground",children:o}),e[54]=o,e[55]=x):x=e[55];let m;e[56]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Se,{"data-icon":"inline-end"}),e[56]=m):m=e[56];let w;e[57]!==r?(w=t.jsx("div",{className:"col-start-2 mt-2",children:t.jsxs(Q,{size:"xs",onClick:r,children:["Open session",m]})}),e[57]=r,e[58]=w):w=e[58];let h;return e[59]!==p||e[60]!==f||e[61]!==x||e[62]!==w?(h=t.jsxs(ge,{className:"border-warning/40 bg-warning/5",children:[p,f,x,w]}),e[59]=p,e[60]=f,e[61]=x,e[62]=w,e[63]=h):h=e[63],h}}}function As(u,e,s=()=>!0){const i=new Map(e.map(n=>[n.sessionId,n])),l=n=>{const g=i.get(n);return g?fe(g):Date.now()},r=[];for(const[n,g]of u.permissionsBySession)for(const a of g)r.push({kind:"permission",sessionId:n,since:a.timestamp,request:a});for(const[n,g]of u.questionsBySession)for(const a of g)r.push({kind:"question",sessionId:n,since:a.askedAt,request:a});for(const[n,g]of u.elicitationsBySession)for(const a of g)r.push({kind:"elicitation",sessionId:n,since:a.askedAt,request:a});for(const[n,g]of u.dialogsBySession)for(const a of g)r.push({kind:"dialog",sessionId:n,since:a.askedAt,request:a});for(const n of u.awaitingPlan)r.push({kind:"plan",sessionId:n,since:l(n)});for(const n of e)n.agentStatus==="deferred"&&!n.archived&&r.push({kind:"deferred",sessionId:n.sessionId,since:l(n.sessionId)});return r.filter(n=>s(n.sessionId)).sort((n,g)=>n.since-g.since)}function je(u){switch(u.kind){case"permission":return u.request.requestId;case"question":return u.request.toolUseId;case"elicitation":case"dialog":return u.request.requestId;default:return`${u.kind}:${u.sessionId}`}}const Ds=7*864e5,Ne=3,Es=30,Ps=50,ye={"needs-you":0,working:1,done:2};function _s(u,e){const s=u.filter(r=>!r.archived&&!(r.teamName&&r.agentName)),{topLevel:i,crewOf:l}=Ue(s);return i.map(r=>{const n=l.get(r.sessionId)??[],g=n.length?He(r,n):r.lastActivityAt||r.lastModified,a=[r,...n].flatMap(c=>(c.pullRequests??[]).map(p=>({pullRequest:p,by:c}))).sort((c,p)=>Date.parse(p.pullRequest.timestamp)-Date.parse(c.pullRequest.timestamp))[0];return{session:r,state:e(r).state,crew:n.map(c=>({member:c,state:e(c).state})).sort((c,p)=>ye[c.state]-ye[p.state]||fe(p.member)-fe(c.member)),counts:n.length?Qe(n,e):null,activityAt:g,...a&&{landed:{number:a.pullRequest.number,title:a.pullRequest.title,url:a.pullRequest.url,by:a.by}}}}).sort((r,n)=>Date.parse(n.activityAt)-Date.parse(r.activityAt))}function Ms(u,e=Date.now()){const s=u.filter(i=>e-Date.parse(i.activityAt)<Ds);return(s.length>=Ne?s:u.slice(0,Ne)).slice(0,Es)}function Rs(u,e,s=6){const i=[],l=new Set;for(const r of u){const n=e(r.session);if(!(!n.cwd||l.has(n.cwd))&&(l.add(n.cwd),i.push(n),i.length===s))break}return i}function Os(u,e,s){const i=e.toLowerCase().split(/\s+/).filter(Boolean);return i.length===0?[]:u.filter(l=>{const r=s(l).filter(Boolean).join(`
2
+ `).toLowerCase();return i.every(n=>r.includes(n))}).slice(0,Ps)}const ve={"needs-you":re.attention,working:re.working,done:"bg-muted-foreground/40"},zs={"needs-you":"needs you",working:"working",done:"done"},Ts=3;function $s(u,e){const s=u.cwd?os(u.cwd):null,i=(s==null?void 0:s.parentPath)??u.cwd,l=s?ue(ke(u.dirName),s.parentPath):u.dirName;return{dirName:l,cwd:i,name:e[l]??(i?qe(i):u.projectShortName)}}function Ks(u){const e=u.target instanceof HTMLElement&&u.target.closest("input,textarea,select,[contenteditable=true]");return!u.metaKey&&!u.ctrlKey&&!u.altKey&&!e}function st(u){const e=V.c(81),{onOpenSession:s,onBrowseProjects:i,start:l}=u,r=Ve(),n=Ye(),{names:g,rename:a}=Ge(),{names:c}=Xe(),p=We(),[d,f]=X.useState(""),o=X.useRef(null);let x;e[0]!==r.sessions?(x=r.sessions.filter(Ls),e[0]=r.sessions,e[1]=x):x=e[1];const m=x;let w;e[2]!==m?(w=new Map(m.map(Fs)),e[2]=m,e[3]=w):w=e[3];const h=w;let b;e[4]!==n.awaitingDialog||e[5]!==n.awaitingElicitation?(b=new Set([...n.awaitingElicitation,...n.awaitingDialog]),e[4]=n.awaitingDialog,e[5]=n.awaitingElicitation,e[6]=b):b=e[6];let v;e[7]!==n.awaitingPermission||e[8]!==n.awaitingPlan||e[9]!==n.awaitingQuestion||e[10]!==b?(v={awaitingPermission:n.awaitingPermission,awaitingQuestion:n.awaitingQuestion,awaitingPrompt:b,awaitingPlan:n.awaitingPlan},e[7]=n.awaitingPermission,e[8]=n.awaitingPlan,e[9]=n.awaitingQuestion,e[10]=b,e[11]=v):v=e[11];const j=v;let N;e[12]!==r.procBySession||e[13]!==j?(N=U=>ns(U,r.procBySession,j),e[12]=r.procBySession,e[13]=j,e[14]=N):N=e[14];const I=N;let y;e[15]!==h||e[16]!==p?(y=U=>{const B=h.get(U);return p(B==null?void 0:B.access).canInteract},e[15]=h,e[16]=p,e[17]=y):y=e[17];const k=y;let A;e[18]!==k||e[19]!==n||e[20]!==m?(A=As(n,m,k),e[18]=k,e[19]=n,e[20]=m,e[21]=A):A=e[21];const D=A;let q;e[22]!==h||e[23]!==g?(q=U=>is(U,h,g),e[22]=h,e[23]=g,e[24]=q):q=e[24];const S=q;let _;e[25]!==c?(_=U=>c[U.dirName]??ls(U),e[25]=c,e[26]=_):_=e[26];const R=_;let M,P,O;if(e[27]!==S||e[28]!==R||e[29]!==c||e[30]!==d||e[31]!==m||e[32]!==I){M=_s(m,I),O=d.trim().length>0?Os(M,d,H=>{var he;return[S(H.session.sessionId),R(H.session),H.session.gitBranch,H.session.cwd,H.session.lastUserMessage,H.session.firstUserMessage,(he=H.landed)==null?void 0:he.title,H.landed&&`#${H.landed.number}`,...H.crew.map(Ae=>{const{member:De}=Ae;return S(De.sessionId)})]}):Ms(M);let B;e[36]!==c?(B=H=>$s(H,c),e[36]=c,e[37]=B):B=e[37],P=Rs(M,B),e[27]=S,e[28]=R,e[29]=c,e[30]=d,e[31]=m,e[32]=I,e[33]=M,e[34]=P,e[35]=O}else M=e[33],P=e[34],O=e[35];const T=P;let $;e[38]!==h||e[39]!==s?($=U=>{const B=h.get(U);B?s(B.dirName,B.fileName):rs(U)},e[38]=h,e[39]=s,e[40]=$):$=e[40];const z=$;let F;e[41]!==r.processes?(F=r.processes.filter(Bs),e[41]=r.processes,e[42]=F):F=e[42];const C=F.length;let K,G;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{const U=B=>{var H;B.key==="/"&&Ks(B)&&(B.preventDefault(),(H=o.current)==null||H.focus())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},G=[],e[43]=K,e[44]=G):(K=e[43],G=e[44]),X.useEffect(K,G);let L;e[45]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Mission Control"}),e[45]=L):L=e[45];let W;e[46]!==C?(W=C>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[C," ",C===1?"agent":"agents"," running on this machine"]}),e[46]=C,e[47]=W):W=e[47];let J;e[48]!==W?(J=t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[L,W]}),e[48]=W,e[49]=J):J=e[49];let E;e[50]!==T||e[51]!==l?(E=l&&t.jsx(js,{recent:T,start:l}),e[50]=T,e[51]=l,e[52]=E):E=e[52];let Y;e[53]!==J||e[54]!==E?(Y=t.jsxs("div",{className:"mx-auto flex w-full max-w-6xl shrink-0 flex-col gap-8 px-6 pt-16 lg:px-10",children:[J,E]}),e[53]=J,e[54]=E,e[55]=Y):Y=e[55];const oe=D.length>0&&"lg:grid lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)]";let ee;e[56]!==oe?(ee=Z("mx-auto flex w-full max-w-6xl flex-col gap-8 px-6 pb-10 pt-10 lg:h-full lg:px-10",oe),e[56]=oe,e[57]=ee):ee=e[57];let se;e[58]!==h||e[59]!==k||e[60]!==n||e[61]!==S||e[62]!==z||e[63]!==D?(se=D.length>0?t.jsx(Us,{queue:D,input:n,byId:h,nameOf:S,onOpen:z,canAnswer:k}):t.jsxs("p",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success/40","aria-hidden":"true"}),"Nothing is waiting on you."]}),e[58]=h,e[59]=k,e[60]=n,e[61]=S,e[62]=z,e[63]=D,e[64]=se):se=e[64];let te;e[65]!==S||e[66]!==i||e[67]!==z||e[68]!==R||e[69]!==d||e[70]!==a||e[71]!==M.length||e[72]!==O?(te=t.jsx(Qs,{sessions:O,total:M.length,query:d,onQueryChange:f,searchRef:o,nameOf:S,projectLabel:R,onOpen:z,onRename:a,onBrowseProjects:i}),e[65]=S,e[66]=i,e[67]=z,e[68]=R,e[69]=d,e[70]=a,e[71]=M.length,e[72]=O,e[73]=te):te=e[73];let ne;e[74]!==ee||e[75]!==se||e[76]!==te?(ne=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto lg:overflow-hidden",children:t.jsxs("div",{className:ee,children:[se,te]})}),e[74]=ee,e[75]=se,e[76]=te,e[77]=ne):ne=e[77];let le;return e[78]!==Y||e[79]!==ne?(le=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[Y,ne]}),e[78]=Y,e[79]=ne,e[80]=le):le=e[80],le}function Bs(u){return u.sessionId}function Fs(u){return[u.sessionId,u]}function Ls(u){return!u.archived}function Ce(u){const e=V.c(9),{title:s,count:i,children:l}=u;let r;e[0]!==s?(r=t.jsx("h2",{className:"text-sm font-medium",children:s}),e[0]=s,e[1]=r):r=e[1];let n;e[2]!==i?(n=i!==void 0&&t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:i}),e[2]=i,e[3]=n):n=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{className:"flex-1"}),e[4]=g):g=e[4];let a;return e[5]!==l||e[6]!==r||e[7]!==n?(a=t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r,n,g,l]}),e[5]=l,e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function de(u,e){const s=u==null?void 0:u.crew;return s?e(s.rootId)??s.rootTitle??null:null}const Ie={permission:"asked a permission",question:"asked a question",elicitation:"asked for input",dialog:"needs a choice",plan:"has a plan to review",deferred:"has a deferred permission"};function Us(u){const e=V.c(71),{queue:s,input:i,byId:l,nameOf:r,onOpen:n,canAnswer:g}=u,[a,c]=X.useState(0);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,e[0]=p):p=e[0];const d=X.useRef(p),f=Math.min(a,s.length-1),o=s[f];let x;if(e[1]!==l||e[2]!==r||e[3]!==o.sessionId){const C=l.get(o.sessionId);x=de(C,r),e[1]=l,e[2]=r,e[3]=o.sessionId,e[4]=x}else x=e[4];const m=x;let w;e[5]!==f||e[6]!==g||e[7]!==i||e[8]!==n||e[9]!==s.length||e[10]!==o.kind||e[11]!==o.request||e[12]!==o.sessionId?(w=C=>{const K=C.target;if(!(K.closest("input,textarea,select,[contenteditable=true]")||C.metaKey||C.ctrlKey||C.altKey)&&((C.key==="j"||C.key==="n"||C.key==="ArrowDown")&&(C.preventDefault(),c(Math.min(s.length-1,f+1))),(C.key==="k"||C.key==="ArrowUp")&&(C.preventDefault(),c(Math.max(0,f-1))),C.key==="o"&&(C.preventDefault(),n(o.sessionId)),(C.key==="Enter"||C.key==="d")&&K===C.currentTarget&&g(o.sessionId))){if(o.kind!=="permission")return;const G=C.key==="d"||o.request.defaultToNo?"deny":"allow",L=o.request.requestId;if(o.request.availableDecisions&&!o.request.availableDecisions.includes(G)||(C.preventDefault(),d.current.has(L)||i.responding.has(L)))return;d.current.add(L),i.respond(o.sessionId,L,G).finally(()=>d.current.delete(L))}},e[5]=f,e[6]=g,e[7]=i,e[8]=n,e[9]=s.length,e[10]=o.kind,e[11]=o.request,e[12]=o.sessionId,e[13]=w):w=e[13];const h=w;let b;e[14]!==f||e[15]!==s.length?(b=s.length>1&&t.jsxs("span",{className:"flex items-center gap-1 text-xs tabular-nums text-muted-foreground",children:[f+1," of ",s.length,t.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:f===0,onClick:()=>c(f-1),children:t.jsx(xs,{"data-icon":"inline-start"})}),t.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:f===s.length-1,onClick:()=>c(f+1),children:t.jsx(Se,{"data-icon":"inline-start"})})]}),e[14]=f,e[15]=s.length,e[16]=b):b=e[16];let v;e[17]!==s.length||e[18]!==b?(v=t.jsx(Ce,{title:"Needs you",count:s.length,children:b}),e[17]=s.length,e[18]=b,e[19]=v):v=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-warning","aria-hidden":"true"}),e[20]=j):j=e[20];let N;e[21]!==n||e[22]!==o.sessionId?(N=()=>n(o.sessionId),e[21]=n,e[22]=o.sessionId,e[23]=N):N=e[23];let I;e[24]!==r||e[25]!==o.sessionId?(I=r(o.sessionId)??"A session",e[24]=r,e[25]=o.sessionId,e[26]=I):I=e[26];let y;e[27]!==N||e[28]!==I?(y=t.jsx("button",{type:"button",onClick:N,className:"min-w-0 truncate rounded-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:I}),e[27]=N,e[28]=I,e[29]=y):y=e[29];let k;e[30]!==m?(k=m&&t.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:["· ",m]}),e[30]=m,e[31]=k):k=e[31];let A;e[32]!==o.since?(A=ie(new Date(o.since).toISOString()),e[32]=o.since,e[33]=A):A=e[33];let D;e[34]!==A?(D=t.jsxs("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-warning",children:["waiting ",A]}),e[34]=A,e[35]=D):D=e[35];let q;e[36]!==k||e[37]!==D||e[38]!==y?(q=t.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-[13px]",children:[j,y,k,D]}),e[36]=k,e[37]=D,e[38]=y,e[39]=q):q=e[39];const S=Ie[o.kind];let _;e[40]!==S?(_=t.jsx("p",{className:"px-0.5 text-xs text-muted-foreground",children:S}),e[40]=S,e[41]=_):_=e[41];let R;e[42]!==o?(R=je(o),e[42]=o,e[43]=R):R=e[43];let M;e[44]!==g||e[45]!==o.sessionId?(M=g(o.sessionId),e[44]=g,e[45]=o.sessionId,e[46]=M):M=e[46];let P;e[47]!==n||e[48]!==o.sessionId?(P=()=>n(o.sessionId),e[47]=n,e[48]=o.sessionId,e[49]=P):P=e[49];let O;e[50]!==i||e[51]!==o||e[52]!==R||e[53]!==M||e[54]!==P?(O=t.jsx(Cs,{request:o,input:i,canAnswer:M,onOpen:P},R),e[50]=i,e[51]=o,e[52]=R,e[53]=M,e[54]=P,e[55]=O):O=e[55];let T;e[56]!==q||e[57]!==_||e[58]!==O?(T=t.jsxs("div",{className:"flex flex-col gap-2",children:[q,_,O]}),e[56]=q,e[57]=_,e[58]=O,e[59]=T):T=e[59];let $;e[60]!==f||e[61]!==l||e[62]!==r||e[63]!==s?($=s.length>1&&t.jsx("ol",{className:"mt-3 flex flex-col","aria-label":"Also waiting",children:s.map((C,K)=>K===f?null:t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>c(K),className:"grid w-full grid-cols-[18px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left text-[12.5px] outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:"text-right text-[11px] tabular-nums text-muted-foreground/80",children:K+1}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsxs("span",{className:"truncate font-medium",children:[r(C.sessionId)??"A session",de(l.get(C.sessionId),r)&&t.jsxs("span",{className:"font-normal text-muted-foreground",children:[" · ",de(l.get(C.sessionId),r)]})]}),t.jsx("span",{className:"truncate text-[11.5px] text-muted-foreground",children:Ie[C.kind]})]}),t.jsx("span",{className:"text-[11px] tabular-nums text-warning",children:ie(new Date(C.since).toISOString())})]})},je(C)))}),e[60]=f,e[61]=l,e[62]=r,e[63]=s,e[64]=$):$=e[64];let z;e[65]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("p",{className:"mt-2 px-0.5 text-[11px] text-muted-foreground/80",children:"J / K move · Enter answers · D denies · O opens"}),e[65]=z):z=e[65];let F;return e[66]!==h||e[67]!==T||e[68]!==$||e[69]!==v?(F=t.jsxs("section",{"aria-label":"Needs you",tabIndex:0,onKeyDown:h,className:"min-w-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring lg:min-h-0 lg:overflow-y-auto",children:[v,T,$,z]}),e[66]=h,e[67]=T,e[68]=$,e[69]=v,e[70]=F):F=e[70],F}function Hs(u){var e,s;return u.state==="needs-you"||(((e=u.counts)==null?void 0:e.needsYou)??0)>0?re.attention:u.state==="working"||(((s=u.counts)==null?void 0:s.working)??0)>0?re.working:null}function Qs(u){const e=V.c(39),{sessions:s,total:i,query:l,onQueryChange:r,searchRef:n,nameOf:g,projectLabel:a,onOpen:c,onRename:p,onBrowseProjects:d}=u;let f;e[0]!==l?(f=l.trim(),e[0]=l,e[1]=f):f=e[1];const o=f.length>0;let x;e[2]!==r||e[3]!==n?(x=()=>{var q;r(""),(q=n.current)==null||q.focus()},e[2]=r,e[3]=n,e[4]=x):x=e[4];const m=x,w=o?s.length:i;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(gs,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e[5]=h):h=e[5];let b;e[6]!==r?(b=q=>r(q.target.value),e[6]=r,e[7]=b):b=e[7];let v;e[8]!==m||e[9]!==n?(v=q=>{var S;q.key==="Escape"&&(q.preventDefault(),m(),(S=n.current)==null||S.blur())},e[8]=m,e[9]=n,e[10]=v):v=e[10];let j;e[11]!==l||e[12]!==n||e[13]!==b||e[14]!==v?(j=t.jsx(me,{ref:n,type:"search","aria-label":"Search sessions",placeholder:"Search sessions",value:l,onChange:b,onKeyDown:v,className:"h-7 pl-8 pr-7 text-xs [&::-webkit-search-cancel-button]:hidden"}),e[11]=l,e[12]=n,e[13]=b,e[14]=v,e[15]=j):j=e[15];let N;e[16]!==m||e[17]!==o?(N=o?t.jsx("button",{type:"button","aria-label":"Clear search",onClick:m,className:"absolute right-1.5 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(ps,{className:"size-3"})}):t.jsx("kbd",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 font-mono text-[10px] text-muted-foreground/70","aria-hidden":"true",children:"/"}),e[16]=m,e[17]=o,e[18]=N):N=e[18];let I;e[19]!==j||e[20]!==N?(I=t.jsxs("div",{className:"relative w-full max-w-64",children:[h,j,N]}),e[19]=j,e[20]=N,e[21]=I):I=e[21];let y;e[22]!==d?(y=d&&t.jsxs(Q,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:d,children:[t.jsx(pe,{"data-icon":"inline-start"}),"All projects"]}),e[22]=d,e[23]=y):y=e[23];let k;e[24]!==y||e[25]!==w||e[26]!==I?(k=t.jsxs(Ce,{title:"Your sessions",count:w,children:[I,y]}),e[24]=y,e[25]=w,e[26]=I,e[27]=k):k=e[27];let A;e[28]!==g||e[29]!==c||e[30]!==p||e[31]!==a||e[32]!==l||e[33]!==o||e[34]!==s?(A=s.length===0?t.jsx(Je,{children:t.jsx(Ze,{children:t.jsx(es,{children:o?`No session matches “${l.trim()}”.`:"Start a session and it shows up here, with every session it starts."})})}):t.jsx("ul",{className:"flex flex-col lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:s.map(q=>t.jsx(Vs,{entry:q,nameOf:g,projectLabel:a,onOpen:c,onRename:p},q.session.sessionId))}),e[28]=g,e[29]=c,e[30]=p,e[31]=a,e[32]=l,e[33]=o,e[34]=s,e[35]=A):A=e[35];let D;return e[36]!==k||e[37]!==A?(D=t.jsxs("section",{"aria-label":"Your sessions",className:"flex min-w-0 flex-col lg:min-h-0 lg:flex-1",children:[k,A]}),e[36]=k,e[37]=A,e[38]=D):D=e[38],D}function Vs(u){const e=V.c(60),{entry:s,nameOf:i,projectLabel:l,onOpen:r,onRename:n}=u,[g,a]=X.useState(null),{session:c}=s;let p;e[0]!==i||e[1]!==c.sessionId?(p=i(c.sessionId)??"Untitled session",e[0]=i,e[1]=c.sessionId,e[2]=p):p=e[2];const d=p;let f;e[3]!==c?(f=ss(c),e[3]=c,e[4]=f):f=e[4];const o=f;let x,m;if(e[5]!==g||e[6]!==s||e[7]!==i||e[8]!==r||e[9]!==n||e[10]!==o||e[11]!==l||e[12]!==c||e[13]!==d){const v=Hs(s);let j;e[16]!==g||e[17]!==n||e[18]!==o||e[19]!==c.sessionId||e[20]!==d?(j=()=>{if(g===null)return;const P=g.trim();a(null),P!==d&&n(c.sessionId,P===o?"":P)},e[16]=g,e[17]=n,e[18]=o,e[19]=c.sessionId,e[20]=d,e[21]=j):j=e[21];const N=j;let I;e[22]!==s.counts||e[23]!==c.isActive?(I=s.counts?t.jsxs(t.Fragment,{children:[s.counts.working>0&&t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.working})," working"]}),s.counts.needsYou>0&&t.jsxs("span",{className:"text-warning",children:[t.jsx("span",{className:"font-medium tabular-nums",children:s.counts.needsYou})," need you"]}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-foreground tabular-nums",children:s.counts.size})," in crew"]})]}):c.isActive&&t.jsx("span",{children:"working"}),e[22]=s.counts,e[23]=c.isActive,e[24]=I):I=e[24];let y;e[25]!==I?(y=t.jsx("span",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:I}),e[25]=I,e[26]=y):y=e[26];let k;e[27]!==s.landed?(k=s.landed&&t.jsxs(ts,{variant:"outline",className:"shrink-0",children:["#",s.landed.number]}),e[27]=s.landed,e[28]=k):k=e[28];let A;e[29]!==s.landed||e[30]!==i||e[31]!==c.lastUserMessage?(A=s.landed?`${s.landed.title??"Pull request"} · ${i(s.landed.by.sessionId)??""}`:c.lastUserMessage??"",e[29]=s.landed,e[30]=i,e[31]=c.lastUserMessage,e[32]=A):A=e[32];let D;e[33]!==A?(D=t.jsx("span",{className:"truncate",children:A}),e[33]=A,e[34]=D):D=e[34];let q;e[35]!==D||e[36]!==k?(q=t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[k,D]}),e[35]=D,e[36]=k,e[37]=q):q=e[37];let S;e[38]!==s.activityAt||e[39]!==s.counts?(S=s.counts?`crew active ${ie(s.activityAt)}`:ie(s.activityAt),e[38]=s.activityAt,e[39]=s.counts,e[40]=S):S=e[40];let _;e[41]!==S?(_=t.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:S}),e[41]=S,e[42]=_):_=e[42];let R;e[43]!==q||e[44]!==_||e[45]!==y?(R=t.jsxs(t.Fragment,{children:[y,q,_]}),e[43]=q,e[44]=_,e[45]=y,e[46]=R):R=e[46];const M=R;x="group/row relative border-t border-border/70 first:border-t-0",m=g===null?t.jsxs("button",{type:"button",onClick:()=>r(c.sessionId),className:Z("grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]","outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx("span",{className:"truncate text-[13.5px] font-medium",children:d}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(c)})]}),M]}):t.jsxs("div",{className:"grid w-full grid-cols-1 items-center gap-x-4 gap-y-1 rounded-lg py-3 pl-3 pr-10 text-left xl:grid-cols-[minmax(0,1fr)_auto]",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[v&&t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",v),"aria-hidden":"true"}),t.jsx(me,{autoFocus:!0,"aria-label":"Session name",value:g,placeholder:o,onChange:P=>a(P.target.value),onFocus:Ys,onBlur:N,onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),N()),P.key==="Escape"&&(P.preventDefault(),a(null))},className:"h-7 max-w-md text-[13.5px] font-medium"}),t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground sm:inline",children:l(c)})]}),M]}),e[5]=g,e[6]=s,e[7]=i,e[8]=r,e[9]=n,e[10]=o,e[11]=l,e[12]=c,e[13]=d,e[14]=x,e[15]=m}else x=e[14],m=e[15];let w;e[47]!==s||e[48]!==i||e[49]!==r||e[50]!==d?(w=s.crew.length>0&&t.jsx(Gs,{entry:s,title:d,nameOf:i,onOpen:r}),e[47]=s,e[48]=i,e[49]=r,e[50]=d,e[51]=w):w=e[51];let h;e[52]!==g||e[53]!==d?(h=g===null&&t.jsx(Q,{variant:"ghost",size:"icon-xs","aria-label":`Rename ${d}`,title:"Rename",onClick:()=>a(d),className:"absolute right-2 top-2.5 text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",children:t.jsx(hs,{"data-icon":"icon"})}),e[52]=g,e[53]=d,e[54]=h):h=e[54];let b;return e[55]!==x||e[56]!==m||e[57]!==w||e[58]!==h?(b=t.jsxs("li",{className:x,children:[m,w,h]}),e[55]=x,e[56]=m,e[57]=w,e[58]=h,e[59]=b):b=e[59],b}function Ys(u){return u.target.select()}function Gs(u){const e=V.c(50),{entry:s,title:i,nameOf:l,onOpen:r}=u,[n,g]=X.useState(!1);let a,c,p,d,f,o,x,m;if(e[0]!==s.crew||e[1]!==s.session||e[2]!==n||e[3]!==l||e[4]!==r||e[5]!==i){a=s.crew.filter(Xs),c=a.slice(0,Ts);let D;e[14]!==s.session||e[15]!==l?(D=q=>{var _;const S=(_=q.crew)==null?void 0:_.parentId;return S&&S!==s.session.sessionId?l(S):void 0},e[14]=s.session,e[15]=l,e[16]=D):D=e[16],m=D,x="-mt-1.5 flex flex-col gap-1.5 px-3 pb-3",p="group",d=`${i} crew`,f="flex min-w-0 flex-wrap items-center gap-1.5",o=!n&&c.map(q=>{const{member:S,state:_}=q;return t.jsxs("button",{type:"button","aria-label":`Open ${l(S.sessionId)??"crew member"}`,onClick:()=>r(S.sessionId),className:"flex max-w-56 items-center gap-1.5 rounded-md border border-border/70 px-2 py-0.5 text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[t.jsx("span",{className:Z("size-1.5 shrink-0 rounded-full",ve[_]),"aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:l(S.sessionId)??"Crew member"})]},S.sessionId)}),e[0]=s.crew,e[1]=s.session,e[2]=n,e[3]=l,e[4]=r,e[5]=i,e[6]=a,e[7]=c,e[8]=p,e[9]=d,e[10]=f,e[11]=o,e[12]=x,e[13]=m}else a=e[6],c=e[7],p=e[8],d=e[9],f=e[10],o=e[11],x=e[12],m=e[13];let w;e[17]!==n||e[18]!==a||e[19]!==c?(w=!n&&a.length>c.length&&t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:["+",a.length-c.length," more"]}),e[17]=n,e[18]=a,e[19]=c,e[20]=w):w=e[20];let h;e[21]!==n?(h=()=>g(!n),e[21]=n,e[22]=h):h=e[22];const b=n&&"rotate-180";let v;e[23]!==b?(v=Z("transition-transform",b),e[23]=b,e[24]=v):v=e[24];let j;e[25]!==v?(j=t.jsx(ws,{"data-icon":"inline-start",className:v}),e[25]=v,e[26]=j):j=e[26];const N=n?"Hide crew":`Show crew (${s.crew.length})`;let I;e[27]!==n||e[28]!==j||e[29]!==N||e[30]!==h?(I=t.jsxs(Q,{variant:"ghost",size:"xs","aria-expanded":n,onClick:h,className:"text-muted-foreground",children:[j,N]}),e[27]=n,e[28]=j,e[29]=N,e[30]=h,e[31]=I):I=e[31];let y;e[32]!==p||e[33]!==I||e[34]!==d||e[35]!==f||e[36]!==o||e[37]!==w?(y=t.jsxs("div",{role:p,"aria-label":d,className:f,children:[o,w,I]}),e[32]=p,e[33]=I,e[34]=d,e[35]=f,e[36]=o,e[37]=w,e[38]=y):y=e[38];let k;e[39]!==s.crew||e[40]!==n||e[41]!==l||e[42]!==r||e[43]!==i||e[44]!==m?(k=n&&t.jsx("ul",{"aria-label":`${i} crew members`,className:"flex max-h-72 flex-col overflow-y-auto rounded-md border border-border/70",children:s.crew.map(D=>{const{member:q,state:S}=D;return t.jsx("li",{children:t.jsxs("button",{type:"button","aria-label":`Open ${l(q.sessionId)??"crew member"}`,onClick:()=>r(q.sessionId),className:"grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 px-2.5 py-1.5 text-left text-xs outline-none hover:bg-accent focus-visible:bg-accent",children:[t.jsx("span",{className:Z("size-1.5 rounded-full",ve[S]),"aria-hidden":"true"}),t.jsxs("span",{className:"truncate",children:[l(q.sessionId)??"Crew member",m(q)&&t.jsxs("span",{className:"text-muted-foreground",children:[" · via ",m(q)]})]}),t.jsx("span",{className:Z("tabular-nums text-muted-foreground",S==="needs-you"&&"text-warning"),children:S==="done"?ie(q.lastActivityAt||q.lastModified):zs[S]})]})},q.sessionId)})}),e[39]=s.crew,e[40]=n,e[41]=l,e[42]=r,e[43]=i,e[44]=m,e[45]=k):k=e[45];let A;return e[46]!==y||e[47]!==k||e[48]!==x?(A=t.jsxs("div",{className:x,children:[y,k]}),e[46]=y,e[47]=k,e[48]=x,e[49]=A):A=e[49],A}function Xs(u){const{state:e}=u;return e!=="done"}export{st as MissionHome};
@@ -0,0 +1 @@
1
+ import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{O as p,Q as f,T as j,N as g,Y as C,M as S}from"./index-BVmNox_3.js";import"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";const F=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{F as MobileFileChanges};
@@ -0,0 +1 @@
1
+ import{c as ue,r as y,j as t}from"./vendor-react-gGw_S5I_.js";import{ae as Z,bA as $e,ac as Q,b_ as Xe,av as Re,b$ as et,au as re,B as P,aC as Ie,c0 as tt,c1 as st,b2 as Be,b3 as Me,b1 as He,b4 as Ge,b5 as Ke,b6 as Je,G as se,I as ne,c2 as nt,k as De,c3 as We,c4 as it,c5 as Ye,a3 as lt,a4 as at,a8 as ot,a5 as rt,a6 as ct,a7 as dt,a9 as ut,aa as ht,H as Ee,c6 as pt,c7 as mt,o as ft,n as xt,l as gt,D as jt,j as bt,c8 as vt,c9 as yt,ca as wt,cb as Oe,cc as Fe,E as Ct,f as St,U as Nt,h as kt,i as $t}from"./index-BVmNox_3.js";import{V as Rt,cL as Dt}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";function Ze(i){const e=i.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Et(i,e){if(i.length===0&&e.length===0)return 0;if(i.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(i.length,e.length);s+=1){const l=i[s],o=e[s];if(l===void 0)return-1;if(o===void 0)return 1;const a=/^\d+$/.test(l),n=/^\d+$/.test(o);if(a&&n){if(Number(l)!==Number(o))return Number(l)<Number(o)?-1:1;continue}if(a!==n)return a?-1:1;if(l!==o)return l<o?-1:1}return 0}function It(i,e){const s=Ze(i),l=Ze(e);if(!s||!l)return null;for(let o=0;o<3;o+=1)if(s.parts[o]!==l.parts[o])return s.parts[o]<l.parts[o]?-1:1;return Et(s.prerelease,l.prerelease)}function Ue(i){const e=ue.c(33),{value:s,onChange:l,projects:o,disabled:a}=i,n=a===void 0?!1:a,u=y.useId();let r;e[0]!==s.projectIds||e[1]!==s.type?(r=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=r):r=e[2];let v;e[3]!==r?(v=new Set(r),e[3]=r,e[4]=v):v=e[4];const m=v;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Xe,{children:"Available in"}),e[5]=g):g=e[5];const k=`${u}-all`,j=s.type==="all";let c;e[6]!==l?(c=p=>l(p?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=l,e[7]=c):c=e[7];let h;e[8]!==n||e[9]!==k||e[10]!==j||e[11]!==c?(h=t.jsx($e,{id:k,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=k,e[10]=j,e[11]=c,e[12]=h):h=e[12];const f=`${u}-all`;let b;e[13]!==f?(b=t.jsx(Q,{htmlFor:f,children:"All projects on this host, including new projects"}),e[13]=f,e[14]=b):b=e[14];let w;e[15]!==b||e[16]!==h?(w=t.jsxs(Z,{orientation:"horizontal",children:[h,b]}),e[15]=b,e[16]=h,e[17]=w):w=e[17];let S;e[18]!==n||e[19]!==u||e[20]!==l||e[21]!==o||e[22]!==m||e[23]!==s.projectIds||e[24]!==s.type?(S=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:o.map(p=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-${p.id}`,checked:m.has(p.id),disabled:n,onCheckedChange:N=>l({type:"projects",projectIds:N?[...s.projectIds,p.id]:s.projectIds.filter(I=>I!==p.id)})}),t.jsx(Q,{htmlFor:`${u}-${p.id}`,children:p.name})]},p.id))}),e[18]=n,e[19]=u,e[20]=l,e[21]=o,e[22]=m,e[23]=s.projectIds,e[24]=s.type,e[25]=S):S=e[25];const R=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let d;e[26]!==R?(d=t.jsx(Re,{children:R}),e[26]=R,e[27]=d):d=e[27];let C;return e[28]!==n||e[29]!==w||e[30]!==S||e[31]!==d?(C=t.jsxs(et,{disabled:n,children:[g,w,S,d]}),e[28]=n,e[29]=w,e[30]=S,e[31]=d,e[32]=C):C=e[32],C}function Pt(i){const e=ue.c(69),{client:s,run:l,busy:o}=i,a=y.useId(),[n,u]=y.useState(""),[r,v]=y.useState(""),[m,g]=y.useState(null),[k,j]=y.useState(""),[c,h]=y.useState(!1);let f;e[0]!==s||e[1]!==k||e[2]!==r||e[3]!==n||e[4]!==m||e[5]!==l?(f=Y=>{Y.preventDefault(),l(async()=>{var de;if(!m||m.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((de=globalThis.crypto)!=null&&de.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const M=await m.arrayBuffer(),ce=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",M)),Tt).join("");if(ce!==k.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:r,root:new TextDecoder("utf-8",{fatal:!0}).decode(M),fingerprint:ce}),h(!1),u(""),v(""),j("")})},e[0]=s,e[1]=k,e[2]=r,e[3]=n,e[4]=m,e[5]=l,e[6]=f):f=e[6];const b=`${a}-name`;let w;e[7]!==b?(w=t.jsx(Q,{htmlFor:b,children:"Development publisher"}),e[7]=b,e[8]=w):w=e[8];const S=`${a}-name`;let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=Y=>u(Y.target.value),e[9]=R):R=e[9];let d;e[10]!==o||e[11]!==n||e[12]!==S?(d=t.jsx(re,{id:S,value:n,onChange:R,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:o}),e[10]=o,e[11]=n,e[12]=S,e[13]=d):d=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=C):C=e[14];let p;e[15]!==w||e[16]!==d?(p=t.jsxs(Z,{children:[w,d,C]}),e[15]=w,e[16]=d,e[17]=p):p=e[17];const N=`${a}-label`;let I;e[18]!==N?(I=t.jsx(Q,{htmlFor:N,children:"Display name"}),e[18]=N,e[19]=I):I=e[19];const $=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let D;e[21]!==o||e[22]!==r||e[23]!==$?(D=t.jsx(re,{id:$,value:r,onChange:O,maxLength:100,required:!0,disabled:o}),e[21]=o,e[22]=r,e[23]=$,e[24]=D):D=e[24];let q;e[25]!==I||e[26]!==D?(q=t.jsxs(Z,{children:[I,D]}),e[25]=I,e[26]=D,e[27]=q):q=e[27];const H=`${a}-root`;let L;e[28]!==H?(L=t.jsx(Q,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=L):L=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var M;g(((M=Y.target.files)==null?void 0:M[0])??null),h(!1)},e[30]=G):G=e[30];let T;e[31]!==o||e[32]!==ee?(T=t.jsx(re,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:o}),e[31]=o,e[32]=ee,e[33]=T):T=e[33];let K;e[34]!==L||e[35]!==T?(K=t.jsxs(Z,{children:[L,T]}),e[34]=L,e[35]=T,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(Q,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let z;e[39]===Symbol.for("react.memo_cache_sentinel")?(z=Y=>{j(Y.target.value),h(!1)},e[39]=z):z=e[39];let U;e[40]!==o||e[41]!==k||e[42]!==J?(U=t.jsx(re,{id:J,value:k,onChange:z,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:o}),e[40]=o,e[41]=k,e[42]=J,e[43]=U):U=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=F):F=e[44];let V;e[45]!==_||e[46]!==U?(V=t.jsxs(Z,{children:[_,U,F]}),e[45]=_,e[46]=U,e[47]=V):V=e[47];const x=`${a}-trust`;let E;e[48]!==o||e[49]!==x||e[50]!==c?(E=t.jsx($e,{id:x,checked:c,onCheckedChange:h,disabled:o}),e[48]=o,e[49]=x,e[50]=c,e[51]=E):E=e[51];const W=`${a}-trust`;let B;e[52]!==W?(B=t.jsx(Q,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=B):B=e[53];let X;e[54]!==E||e[55]!==B?(X=t.jsxs(Z,{orientation:"horizontal",children:[E,B]}),e[54]=E,e[55]=B,e[56]=X):X=e[56];const ae=o||!c||!m;let ie;e[57]!==ae?(ie=t.jsx(P,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==q||e[60]!==K||e[61]!==V||e[62]!==X||e[63]!==ie||e[64]!==p?(le=t.jsxs(Ie,{children:[p,q,K,V,X,ie]}),e[59]=q,e[60]=K,e[61]=V,e[62]=X,e[63]=ie,e[64]=p,e[65]=le):le=e[65];let oe;return e[66]!==f||e[67]!==le?(oe=t.jsx("form",{onSubmit:f,children:le}),e[66]=f,e[67]=le,e[68]=oe):oe=e[68],oe}function Tt(i){return i.toString(16).padStart(2,"0")}const At={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Ot({client:i,preview:e,activation:s,key:l,onFrame:o,onComplete:a,onError:n}){const u=new AbortController;let r="loading",v,m=0;const g=()=>new Error("The installation check expired. Review the package again to retry.");function k(f){r==="canceled"||r==="finished"||(r="canceled",clearTimeout(v),u.abort(),o(null),n(f))}function j(){r==="canceled"||r==="finished"||(r="finished",clearTimeout(v),a())}async function c(f){if(r==="committing"){r="recovering",clearTimeout(v);try{const b=await i.transactionOutcome(e);if(r!=="recovering")return;b.status==="committed"?(await i.refresh(),r==="recovering"&&j()):k(f)}catch{r==="recovering"&&k(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function h(){if(r==="trial"){if(Date.now()>m){k(g());return}r="committing";try{await i.commit(e,u.signal),r==="committing"&&j()}catch(f){await c(f instanceof Error?f:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const f=await i.payload(e.transactionId,u.signal);if(u.signal.aborted||(e.manifest.entry||await st(f,e.digest),m=await i.beginTrial(e,u.signal),u.signal.aborted))return;const b=m-Date.now();if(b<=0){k(g());return}if(r="trial",v=setTimeout(()=>{r==="committing"?(u.abort(),c(g())):r==="trial"&&k(g())},b),!e.manifest.entry){await h();return}o({key:l,client:i,props:{payload:f,digest:e.digest,activationKey:l,context:At,active:!1,title:"Plugin installation check",execute:async(w,S)=>{if(u.signal.throwIfAborted(),S.throwIfAborted(),w.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{h()},onError:k}})}catch(f){k(f instanceof Error?f:new Error("Plugin trial failed"))}})(),()=>{r="canceled",clearTimeout(v),u.abort()}}function Ft(i){const e=ue.c(22),{client:s,preview:l,activation:o,onComplete:a,onError:n}=i,u=`${o}:trial:${l.transactionId}:${l.digest}:${l.registryRevision}`,[r,v]=y.useState(null);let m;e[0]!==a||e[1]!==n?(m={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=m):m=e[2];const g=y.useRef(m);let k;e[3]!==a||e[4]!==n?(k=()=>{g.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=k):k=e[5],y.useLayoutEffect(k);let j,c;e[6]!==o||e[7]!==s||e[8]!==u||e[9]!==l?(j=()=>Ot({client:s,preview:l,activation:o,key:u,onFrame:v,onComplete:()=>g.current.onComplete(),onError:w=>g.current.onError(w)}),c=[s,l,o,u],e[6]=o,e[7]=s,e[8]=u,e[9]=l,e[10]=j,e[11]=c):(j=e[10],c=e[11]),y.useLayoutEffect(j,c);let h;e[12]!==l.manifest.name?(h=t.jsxs("p",{children:["Checking that ",l.manifest.name," starts correctly…"]}),e[12]=l.manifest.name,e[13]=h):h=e[13];let f;e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==u?(f=o&&(r==null?void 0:r.key)===u&&r.client===s&&t.jsx(tt,{...r.props}),e[14]=o,e[15]=s,e[16]=r,e[17]=u,e[18]=f):f=e[18];let b;return e[19]!==h||e[20]!==f?(b=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[h,f]}),e[19]=h,e[20]=f,e[21]=b):b=e[21],b}function _t({connection:i,resourceId:e,target:s,client:l,disabled:o,save:a}){const n=y.useId(),u=i.definition.resources[e],r=nt(i.definition,e),v=!!u.options&&r.length===0,m=i.selected[e],[g,k]=y.useState(""),[j,c]=y.useState(null),[h,f]=y.useState(!1),[b,w]=y.useState(null),S=y.useRef(null);y.useEffect(()=>()=>{var $;return($=S.current)==null?void 0:$.abort()},[]);const R=r.find($=>!i.selected[$]),d=o||!!R||u.scope==="project"&&!s.projectId,C=y.useCallback(async()=>{var O;(O=S.current)==null||O.abort();const $=new AbortController;S.current=$,f(!0),w(null);try{const D=await l.connectionOptions(s,i.id,e,$.signal);if($.signal.aborted)return;c(D)}catch(D){$.signal.aborted||w(D instanceof Error?D.message:"Unable to load choices")}finally{$.signal.aborted||f(!1)}},[l,s,i.id,e]),p=j===null&&!h&&!b;y.useEffect(()=>{v&&p&&!d&&C()},[v,p,d,C]);const N=m&&!(j!=null&&j.some($=>$.id===m.id))?[m,...j??[]]:j??[],I=t.jsxs(Je,{items:N.map($=>({value:$.id,label:$.label})),value:(m==null?void 0:m.id)??null,disabled:d||h||!j,onValueChange:$=>{$&&$!==(m==null?void 0:m.id)&&a(i.id,"select",{resourceId:e,value:$})},children:[t.jsx(Ke,{id:`${n}-resource`,"aria-invalid":!!b,children:t.jsx(Ge,{placeholder:h?"Loading choices…":`Choose ${u.label}`})}),t.jsx(Be,{children:t.jsx(Me,{children:N.map($=>t.jsx(He,{value:$.id,children:$.label},$.id))})})]});return t.jsxs(Z,{"data-disabled":d,"data-invalid":!!b,children:[t.jsx(Q,{htmlFor:`${n}-resource`,children:u.label}),t.jsx(Re,{children:u.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),m&&!v&&t.jsxs("p",{className:"text-sm",children:["Selected: ",m.label]}),R&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",i.definition.resources[R].label," first."]}),u.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),u.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[v?I:t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:h?"Loading choices…":j?"Refresh choices":"Browse choices"}),!v&&j&&I,v&&b&&t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:"Try again"}),(j==null?void 0:j.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),u.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:$=>{$.preventDefault(),a(i.id,"select",{resourceId:e,value:g.trim()})},children:[t.jsx(re,{id:u.options?`${n}-input`:`${n}-resource`,"aria-label":`${u.label} ${u.input.urls?"URL or ID":"ID"}`,value:g,onChange:$=>k($.target.value),maxLength:2048,disabled:d,autoComplete:"off",spellCheck:!1,placeholder:u.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(P,{type:"submit",size:"sm",variant:"outline",disabled:d||!g.trim(),children:"Validate and select"})]}),m&&t.jsxs(P,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:()=>{a(i.id,"select",{resourceId:e,value:null})},children:["Clear ",u.label]}),b&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:b})]})}function Lt(i){const e=ue.c(45),{connection:s,target:l,client:o,disabled:a,save:n}=i,u=y.useId(),[r,v]=y.useState(""),[m,g]=y.useState(!1),k=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let h;e[2]!==c?(h=t.jsx(De,{variant:"outline",children:c}),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==j||e[5]!==h?(f=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,h]}),e[4]=j,e[5]=h,e[6]=f):f=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=b):b=e[7];let w;e[8]!==s.definition.operations?(w=new Set(Object.values(s.definition.operations).map(zt)),e[8]=s.definition.operations,e[9]=w):w=e[9];let S;e[10]!==w?(S=[...w],e[10]=w,e[11]=S):S=e[11];const R=S.join(", ");let d;e[12]!==R?(d=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",R]}),e[12]=R,e[13]=d):d=e[13];let C;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==u||e[20]!==m||e[21]!==n?(C=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-replace`,checked:m,onCheckedChange:g,disabled:a}),t.jsx(Q,{htmlFor:`${u}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:m})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=u,e[20]=m,e[21]=n,e[22]=C):C=e[22];let p;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==u||e[29]!==n||e[30]!==r?(p=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:$=>{$.preventDefault();const O=r.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Ie,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(Q,{htmlFor:`${u}-secret`,children:s.definition.secret.label}),t.jsx(re,{id:`${u}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:r,onChange:$=>v($.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(P,{type:"submit",size:"sm",disabled:a||!r.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=u,e[29]=n,e[30]=r,e[31]=p):p=e[31];let N;e[32]!==o||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==l?(N=s.status!=="disconnected"&&t.jsx(Ie,{children:Object.keys(s.definition.resources).map($=>t.jsx(_t,{connection:s,resourceId:$,target:l,client:o,disabled:a,save:n},$))}),e[32]=o,e[33]=s,e[34]=a,e[35]=n,e[36]=l,e[37]=N):N=e[37];let I;return e[38]!==s.label||e[39]!==d||e[40]!==C||e[41]!==p||e[42]!==N||e[43]!==f?(I=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":k,children:[f,b,d,C,p,N]}),e[38]=s.label,e[39]=d,e[40]=C,e[41]=p,e[42]=N,e[43]=f,e[44]=I):I=e[44],I}function zt(i){return i.origin}function Vt({client:i,target:e}){const[s,l]=y.useState(null),[o,a]=y.useState(null),[n,u]=y.useState(!1),r=y.useRef(null),v=y.useRef(!1),m=e.pluginId,g=e.projectId;y.useEffect(()=>{const j=new AbortController;return r.current=j,i.connections({pluginId:m,projectId:g},j.signal).then(c=>{j.signal.aborted||l(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),r.current=null}},[i,m,g]);async function k(j,c,h){if(!s||v.current||!r.current||r.current.signal.aborted)return;v.current=!0;const f=r.current.signal;u(!0),a(null);try{const b=await i.changeConnection(e,j,c,h,s.revision,f);f.aborted||l(b)}catch(b){f.aborted||a(b instanceof Error?b.message:"Connection change failed")}finally{v.current=!1,f.aborted||u(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[o&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:o})}),!s&&!o&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Lt,{connection:j,target:e,client:i,disabled:n,save:k},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function qt(i){const e=ue.c(32),{client:s,status:l,pluginId:o,initialProjectId:a}=i,[n,u]=y.useState(a),r=y.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let m;e[1]!==l.projects?(m=[v,...l.projects.map(Bt)],e[1]=l.projects,e[2]=m):m=e[2];const g=m;let k;e[3]!==r?(k=t.jsx(Q,{htmlFor:r,children:"Project settings"}),e[3]=r,e[4]=k):k=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=I=>u(I||null),e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ge,{}),e[6]=h):h=e[6];let f;e[7]!==r?(f=t.jsx(Ke,{id:r,children:h}),e[7]=r,e[8]=f):f=e[8];let b;e[9]!==g?(b=t.jsx(Be,{children:t.jsx(Me,{children:g.map(Ut)})}),e[9]=g,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==j||e[13]!==f||e[14]!==b?(w=t.jsxs(Je,{items:g,value:j,onValueChange:c,children:[f,b]}),e[11]=g,e[12]=j,e[13]=f,e[14]=b,e[15]=w):w=e[15];let S;e[16]!==l.host.name?(S=t.jsxs(Re,{children:["Connection credentials belong to ",l.host.name,". Project resources stay within the project you choose."]}),e[16]=l.host.name,e[17]=S):S=e[17];let R;e[18]!==S||e[19]!==k||e[20]!==w?(R=t.jsxs(Z,{children:[k,w,S]}),e[18]=S,e[19]=k,e[20]=w,e[21]=R):R=e[21];const d=`${o}:${n??"host"}:${l.connectionRevision??0}`;let C;e[22]!==o||e[23]!==n?(C={pluginId:o,projectId:n},e[22]=o,e[23]=n,e[24]=C):C=e[24];let p;e[25]!==s||e[26]!==d||e[27]!==C?(p=t.jsx(Vt,{client:s,target:C},d),e[25]=s,e[26]=d,e[27]=C,e[28]=p):p=e[28];let N;return e[29]!==R||e[30]!==p?(N=t.jsxs("div",{className:"flex flex-col gap-4",children:[R,p]}),e[29]=R,e[30]=p,e[31]=N):N=e[31],N}function Ut(i){return t.jsx(He,{value:i.value,children:i.label},i.value)}function Bt(i){return{value:i.id,label:i.name}}function Mt({client:i,pluginId:e,projectId:s,definition:l}){var R;const o=y.useId(),[a,n]=y.useState(null),[u,r]=y.useState({}),[v,m]=y.useState(null),[g,k]=y.useState(!1),[j,c]=y.useState(""),[h,f]=y.useState(0),b=y.useRef(null),w=l.scope==="project"&&!s;y.useEffect(()=>{var C;if((C=b.current)==null||C.abort(),b.current=null,k(!1),n(null),m(null),c(""),w)return;const d=new AbortController;return i.settings({pluginId:e,projectId:s},d.signal).then(p=>{d.signal.aborted||(n(p),r(We(l,p.values)))}).catch(p=>{d.signal.aborted||m(p instanceof Error?p.message:"Unable to load plugin settings")}),()=>{var p;d.abort(),(p=b.current)==null||p.abort()}},[i,e,s,l,w,h]);async function S(d){if(d.preventDefault(),!a||g)return;let C;try{C=We(l,u)}catch{m("Check the setting values and their limits.");return}k(!0),m(null),c("");const p=new AbortController;b.current=p;try{const N=await i.saveSettings({pluginId:e,projectId:s},C,a.revision,p.signal);p.signal.aborted||(n(N),r(N.values),c("Settings saved."))}catch(N){p.signal.aborted||m(N instanceof Error?N.message:"Unable to save plugin settings")}finally{b.current===p&&(b.current=null,p.signal.aborted||k(!1))}}return w?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a project to edit this plugin's settings."}):t.jsx("form",{onSubmit:d=>{S(d)},children:t.jsxs(Ie,{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:l.scope==="project"?"Settings for this project.":"Settings for your account on this host."}),a&&l.fields.map(d=>{const C=`${o}-${d.id}`,p=N=>{r(I=>({...I,[d.id]:N})),c("")};return t.jsxs(Z,{"data-disabled":g,children:[t.jsx(Q,{htmlFor:C,children:d.label}),d.description&&t.jsx(Re,{children:d.description}),d.type==="boolean"?t.jsx($e,{id:C,checked:u[d.id]===!0,disabled:g,onCheckedChange:N=>p(N===!0)}):d.type==="select"?t.jsxs(Je,{value:String(u[d.id]),items:d.options,disabled:g,onValueChange:N=>{N!==null&&p(String(N))},children:[t.jsx(Ke,{id:C,children:t.jsx(Ge,{})}),t.jsx(Be,{children:t.jsx(Me,{children:d.options.map(N=>t.jsx(He,{value:N.value,children:N.label},N.value))})})]}):t.jsx(re,{id:C,disabled:g,type:d.type==="number"?"number":"text",value:String(u[d.id]??""),...d.type==="number"?{min:d.min,max:d.max,step:d.step??"any"}:{maxLength:d.maxLength},onChange:N=>p(d.type==="number"?N.target.value===""?"":Number(N.target.value):N.target.value)})]},d.id)}),!!((R=a==null?void 0:a.adjustedFields)!=null&&R.length)&&t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Some saved values no longer match this version. Defaults are shown for ",a.adjustedFields.join(", "),"; save to apply them."]}),!a&&!v&&t.jsx("p",{role:"status",children:"Loading settings…"}),v&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v}),j&&t.jsx("p",{role:"status",className:"text-sm",children:j}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(P,{type:"submit",disabled:!a||g,children:g?"Saving…":"Save settings"}),t.jsx(P,{type:"button",variant:"outline",disabled:g,onClick:()=>f(d=>d+1),children:"Reload settings"})]})]})})}function Ht(i){var ie;const e=ue.c(175),{plugin:s,status:l,client:o,busy:a,run:n,onPreview:u,onConnections:r,onUpdate:v}=i,m=y.useId(),[g,k]=y.useState(s.scope),[j,c]=y.useState(!1),[h,f]=y.useState(!1);let b,w,S,R,d,C,p,N,I,$,O,D;if(e[0]!==a||e[1]!==o||e[2]!==r||e[3]!==u||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==g||e[8]!==l.host.name||e[9]!==l.projects||e[10]!==l.runtime||e[11]!==l.store){const le=it(),oe=Ye(s.manifest,le,l.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==o||e[25]!==s.id||e[26]!==n||e[27]!==l.store?(Y=(A,Ae)=>n(()=>o.changeInstalled(s.id,A,Ae,l.store.revision)),e[24]=o,e[25]=s.id,e[26]=n,e[27]=l.store,e[28]=Y):Y=e[28];const M=Y,ce=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let de;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==l.store?(de=s.lastError&&((ie=l.store.availableSeeds)==null?void 0:ie.find(A=>A.manifest.id===s.id&&A.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=l.store,e[33]=de):de=e[33];const _e=de;$="flex flex-col gap-3 rounded-lg border p-4";let he;e[34]!==s.manifest.name?(he=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=he):he=e[35];let pe;e[36]!==s.id||e[37]!==s.manifest.version?(pe=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=pe):pe=e[38];let me;e[39]!==he||e[40]!==pe?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[he,pe]}),e[39]=he,e[40]=pe,e[41]=me):me=e[41];const Le=ce==="Enabled"?"secondary":"outline";let fe;e[42]!==ce||e[43]!==Le?(fe=t.jsx(De,{variant:Le,children:ce}),e[42]=ce,e[43]=Le,e[44]=fe):fe=e[44],e[45]!==me||e[46]!==fe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,fe]}),e[45]=me,e[46]=fe,e[47]=O):O=e[47],e[48]!==s.lastError?(D=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=D):D=e[49],w=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(A=>t.jsxs("p",{children:[A.side==="client"?"This client":A.side==="host"?l.host.name:"This package",": ",A.name," requires ",A.required,"; available ",A.actual??"none","."]},`${A.side}:${A.code}:${A.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==M||e[51]!==s.enabled?(xe=()=>M("enabled",{enabled:!s.enabled}),e[50]=M,e[51]=s.enabled,e[52]=xe):xe=e[52];const ze=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==ze?(ge=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:ze}),e[53]=a,e[54]=xe,e[55]=ze,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==r||e[59]!==s.id||e[60]!==s.manifest.contributes||e[61]!==s.manifest.permissions.connections.length?(je=(s.manifest.permissions.connections.length>0||s.manifest.contributes.settings)&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>r(s.id),children:s.manifest.contributes.settings?"Settings":"Connections"}),e[57]=a,e[58]=r,e[59]=s.id,e[60]=s.manifest.contributes,e[61]=s.manifest.permissions.connections.length,e[62]=je):je=e[62];const Ve=a||s.pinned;let be;e[63]!==v||e[64]!==s?(be=()=>v(s),e[63]=v,e[64]=s,e[65]=be):be=e[65];let ve;e[66]!==Ve||e[67]!==be?(ve=t.jsx(P,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[66]=Ve,e[67]=be,e[68]=ve):ve=e[68];let ye;e[69]!==a||e[70]!==o||e[71]!==u||e[72]!==s.id||e[73]!==s.scope||e[74]!==_e||e[75]!==n?(ye=_e&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>u(await o.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[69]=a,e[70]=o,e[71]=u,e[72]=s.id,e[73]=s.scope,e[74]=_e,e[75]=n,e[76]=ye):ye=e[76];let we;e[77]!==M||e[78]!==s.pinned?(we=()=>M("pin",{pinned:!s.pinned}),e[77]=M,e[78]=s.pinned,e[79]=we):we=e[79];const qe=s.pinned?"Unpin version":"Pin version";let Ce;e[80]!==a||e[81]!==we||e[82]!==qe?(Ce=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:we,children:qe}),e[80]=a,e[81]=we,e[82]=qe,e[83]=Ce):Ce=e[83];let Pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{f(!1),c(!0)},e[84]=Pe):Pe=e[84];let Se;e[85]!==a?(Se=t.jsx(P,{size:"sm",variant:"ghost",disabled:a,onClick:Pe,children:"Uninstall"}),e[85]=a,e[86]=Se):Se=e[86],e[87]!==ge||e[88]!==je||e[89]!==ve||e[90]!==ye||e[91]!==Ce||e[92]!==Se?(S=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,Ce,Se]}),e[87]=ge,e[88]=je,e[89]=ve,e[90]=ye,e[91]=Ce,e[92]=Se,e[93]=S):S=e[93],e[94]!==s.pinned?(R=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[94]=s.pinned,e[95]=R):R=e[95],N="text-sm",e[96]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[96]=I):I=e[96],b="flex flex-col gap-4 pt-4",e[97]!==a||e[98]!==g||e[99]!==l.projects?(d=t.jsx(Ue,{value:g,onChange:k,projects:l.projects,disabled:a}),e[97]=a,e[98]=g,e[99]=l.projects,e[100]=d):d=e[100];let Ne;e[101]!==a||e[102]!==s.scope||e[103]!==g?(Ne=a||JSON.stringify(g)===JSON.stringify(s.scope),e[101]=a,e[102]=s.scope,e[103]=g,e[104]=Ne):Ne=e[104];let ke;e[105]!==M||e[106]!==g?(ke=()=>M("scope",{scope:g}),e[105]=M,e[106]=g,e[107]=ke):ke=e[107],e[108]!==l.host.name||e[109]!==Ne||e[110]!==ke?(C=t.jsxs(P,{size:"sm",variant:"outline",disabled:Ne,onClick:ke,children:["Save projects on ",l.host.name]}),e[108]=l.host.name,e[109]=Ne,e[110]=ke,e[111]=C):C=e[111];let Te;e[112]!==s.selectedDigest?(Te=A=>A.digest!==s.selectedDigest,e[112]=s.selectedDigest,e[113]=Te):Te=e[113],p=s.versions.filter(Te).map(A=>{const Ae=!A.unavailableReason&&Ye(A.manifest,le,l.runtime,{allowPrerelease:A.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(P,{size:"sm",variant:"outline",disabled:a||s.pinned||!Ae,onClick:()=>n(async()=>u({...await o.rollback(s.id,A.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",A.manifest.version]}),!Ae&&t.jsx("p",{className:"text-xs text-muted-foreground",children:A.unavailableReason??"This version is incompatible with the connected host or client."})]},A.digest)}),e[0]=a,e[1]=o,e[2]=r,e[3]=u,e[4]=v,e[5]=s,e[6]=n,e[7]=g,e[8]=l.host.name,e[9]=l.projects,e[10]=l.runtime,e[11]=l.store,e[12]=b,e[13]=w,e[14]=S,e[15]=R,e[16]=d,e[17]=C,e[18]=p,e[19]=N,e[20]=I,e[21]=$,e[22]=O,e[23]=D}else b=e[12],w=e[13],S=e[14],R=e[15],d=e[16],C=e[17],p=e[18],N=e[19],I=e[20],$=e[21],O=e[22],D=e[23];let q;e[114]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[114]=q):q=e[114];let H;e[115]!==b||e[116]!==d||e[117]!==C||e[118]!==p?(H=t.jsxs("div",{className:b,children:[d,C,p,q]}),e[115]=b,e[116]=d,e[117]=C,e[118]=p,e[119]=H):H=e[119];let L;e[120]!==H||e[121]!==N||e[122]!==I?(L=t.jsxs("details",{className:N,children:[I,H]}),e[120]=H,e[121]=N,e[122]=I,e[123]=L):L=e[123];let ee;e[124]!==s.manifest.name?(ee=t.jsxs(lt,{children:["Uninstall ",s.manifest.name,"?"]}),e[124]=s.manifest.name,e[125]=ee):ee=e[125];let G;e[126]!==l.host.name?(G=t.jsxs(at,{children:["This removes the plugin from ",l.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[126]=l.host.name,e[127]=G):G=e[127];let T;e[128]!==ee||e[129]!==G?(T=t.jsxs(rt,{children:[ee,G]}),e[128]=ee,e[129]=G,e[130]=T):T=e[130];const K=`${m}-delete`,te=a||l.connectionRevision===void 0;let _;e[131]!==h||e[132]!==K||e[133]!==te?(_=t.jsx($e,{id:K,checked:h,onCheckedChange:f,disabled:te}),e[131]=h,e[132]=K,e[133]=te,e[134]=_):_=e[134];const J=`${m}-delete`;let z;e[135]!==J?(z=t.jsx(Q,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[135]=J,e[136]=z):z=e[136];let U;e[137]!==_||e[138]!==z?(U=t.jsxs(Z,{orientation:"horizontal",children:[_,z]}),e[137]=_,e[138]=z,e[139]=U):U=e[139];let F;e[140]!==h?(F=h&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[140]=h,e[141]=F):F=e[141];let V;e[142]!==a?(V=t.jsx(ct,{disabled:a,children:"Cancel"}),e[142]=a,e[143]=V):V=e[143];let x;e[144]!==o||e[145]!==h||e[146]!==s.id||e[147]!==n||e[148]!==l.connectionRevision||e[149]!==l.store?(x=()=>{c(!1),n(()=>o.changeInstalled(s.id,"uninstall",h?{deleteData:!0,expectedConnectionRevision:l.connectionRevision}:{deleteData:!1},l.store.revision))},e[144]=o,e[145]=h,e[146]=s.id,e[147]=n,e[148]=l.connectionRevision,e[149]=l.store,e[150]=x):x=e[150];let E;e[151]!==a||e[152]!==l.host.name||e[153]!==x?(E=t.jsxs(ot,{variant:"destructive",disabled:a,onClick:x,children:["Uninstall from ",l.host.name]}),e[151]=a,e[152]=l.host.name,e[153]=x,e[154]=E):E=e[154];let W;e[155]!==V||e[156]!==E?(W=t.jsxs(dt,{children:[V,E]}),e[155]=V,e[156]=E,e[157]=W):W=e[157];let B;e[158]!==T||e[159]!==U||e[160]!==F||e[161]!==W?(B=t.jsxs(ut,{children:[T,U,F,W]}),e[158]=T,e[159]=U,e[160]=F,e[161]=W,e[162]=B):B=e[162];let X;e[163]!==j||e[164]!==B?(X=t.jsx(ht,{open:j,onOpenChange:c,children:B}),e[163]=j,e[164]=B,e[165]=X):X=e[165];let ae;return e[166]!==w||e[167]!==S||e[168]!==R||e[169]!==L||e[170]!==X||e[171]!==$||e[172]!==O||e[173]!==D?(ae=t.jsxs("article",{className:$,children:[O,D,w,S,R,L,X]}),e[166]=w,e[167]=S,e[168]=R,e[169]=L,e[170]=X,e[171]=$,e[172]=O,e[173]=D,e[174]=ae):ae=e[174],ae}const Gt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Kt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",pullReview:"pull request changes and patches",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"},Jt={append:"Append text to your draft message",context:"Add file references with notes to your draft message",drafts:"Read, save and restore your composer drafts, including images and sent-message history kept in this browser"},Wt={snapshot:"Read this project's worktree setup command and recent setup output",scripts:"Read the script names in this project's root package.json",propose:"Propose a setup command that runs in new worktrees; Cogpit shows the exact command and saves it only when you trust it",act:"Retry or cancel a worktree setup that is waiting before the first prompt"};function Yt(i,e){return i==="worktreeSetup"?Wt[e]:e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":e==="submitReview"?"Post review comments to pull requests in the selected GitHub repository when you submit them, using this host's signed-in CLI":e==="reviewGuide"||e==="cancelReviewGuide"?"Read and cancel the review guides this host generates for pull requests":`Read ${Gt[i]} ${Kt[e]} using this host's signed-in CLI`}function Qe(i){const e=i.permissions;return[...new Set([...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(s=>Jt[s]),...e.review.map(()=>"Ask to start a pull request session in a new worktree, which you confirm and choose the provider for"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...i.contributes.settings?[`Add ${i.contributes.settings.fields.length} ${i.contributes.settings.scope} settings fields`]:[],...(i.contributes.skills??[]).map(s=>`Provide agent instructions: ${s.title}`),...(i.contributes.chatBlocks??[]).map(s=>`Render ${s.title} cards and read the text inside their declared chat blocks`),...(i.contributes.sessionActions??[]).map(s=>`Add a ${s.title} button that sends an agent request when clicked`),...i.contributes.dictation?[`Add a ${i.contributes.dictation.title} button that records your microphone only while you dictate, and sends the recording to connection ${i.contributes.dictation.connection} to transcribe`]:[],...e.connections.flatMap(s=>s.operations.map(l=>`Use connection ${s.id}: ${l}`)),...e.integrations.flatMap(s=>s.operations.map(l=>Yt(s.id,l)))])]}function Zt(i){var j;const e=ue.c(32),{preview:s}=i;let l,o,a,n,u,r;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=Qe(s.manifest),h=s.previousManifest?Qe(s.previousManifest):null,f=h?c.filter(S=>!h.includes(S)):[],b=h?h.filter(S=>!c.includes(S)):[],w=s.previousConnectionDefinitions?s.connectionDefinitions.filter(S=>{var d;const R=(d=s.previousConnectionDefinitions)==null?void 0:d.find(C=>C.id===S.id);return!R||JSON.stringify(R)!==JSON.stringify(S)}):[];l="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(o=s.oldVersion&&t.jsxs(se,{children:[t.jsx(Ee,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=o):o=e[14],a=h&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),f.length===0&&b.length===0&&w.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),f.map(as),b.map(ls),w.map(is)]}),n=s.oldVersion&&!h&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=u):u=e[15],r=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(ns)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=l,e[7]=o,e[8]=a,e[9]=n,e[10]=u,e[11]=r}else l=e[6],o=e[7],a=e[8],n=e[9],u=e[10],r=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Qt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let m;e[18]!==s.incompatibleClients?(m=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=m):m=e[19];let g;e[20]!==s.digest?(g=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=g):g=e[21];let k;return e[22]!==l||e[23]!==o||e[24]!==a||e[25]!==n||e[26]!==u||e[27]!==r||e[28]!==v||e[29]!==m||e[30]!==g?(k=t.jsxs("div",{className:l,children:[o,a,n,u,r,v,m,g]}),e[22]=l,e[23]=o,e[24]=a,e[25]=n,e[26]=u,e[27]=r,e[28]=v,e[29]=m,e[30]=g,e[31]=k):k=e[31],k}function Qt(i){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:i.label}),t.jsxs("p",{children:["Access to ",Object.values(i.resources).map(ss).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(i.operations).map(ts))].join(", ")]}),Object.entries(i.operations).filter(es).map(Xt)]},i.id)}function Xt(i){const[e,s]=i;return t.jsxs("p",{className:"text-muted-foreground",children:[s.method," ",e,s.method==="POST"?" — sends supplied data to this service":"",s.upload?" · sends a microphone recording":"",s.response?" · receives audio":""]},e)}function es(i){const[,e]=i;return e.audience==="panel"}function ts(i){return i.origin}function ss(i){return i.label}function ns(i){return t.jsx("li",{children:i},i)}function is(i){return t.jsxs("p",{children:["Changed connection: ",i.label,". Review its destinations and access below."]},i.id)}function ls(i){return t.jsxs("p",{children:["Removed: ",i]},`remove:${i}`)}function as(i){return t.jsxs("p",{children:["Added: ",i]},`add:${i}`)}function us({client:i,state:e,currentPath:s,onClose:l,initialPluginId:o}){var V;const a=y.useId(),n=e.status,u=pt(),r=(n==null?void 0:n.safeMode)||u,{project:v,resolving:m}=mt({client:i,status:n,activation:e.activation,projectPath:s}),[g,k]=y.useState(null),j=g??{type:"projects",projectIds:v?[v.id]:[]},[c,h]=y.useState(null),[f,b]=y.useState({activation:"",hostName:""}),[w,S]=y.useState(!1),[R,d]=y.useState(!1),[C,p]=y.useState(null),[N,I]=y.useState(null),[$,O]=y.useState("installed"),[D,q]=y.useState(null),[H,L]=y.useState(null),[ee,G]=y.useState(o),T=n==null?void 0:n.store.plugins.find(x=>x.id===ee),K=y.useRef(!1),te=!!(n!=null&&n.store.available)&&f.activation===e.activation;function _(x){b({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),h(x)}y.useEffect(()=>{!c||te&&!(r&&w)||(S(!1),h(null),p("The host connection or plugin execution state changed. Review the package again before installing."),i.cancel(c).catch(()=>{}))},[i,c,te,r,w]),y.useEffect(()=>()=>{c&&i.cancel(c).catch(()=>{})},[i,c]);async function J(x){if(!K.current){K.current=!0,d(!0),p(null),I(null);try{await x()}catch(E){p(E instanceof Error?E.message:"Plugin action failed")}finally{K.current=!1,d(!1)}}}function z(){const x=c;S(!1),h(null),x&&i.cancel(x).catch(()=>{})}async function U(){if(!H||!D&&!g&&m)return;const x=await i.stage(H,(D==null?void 0:D.scope)??j);if(D&&x.manifest.id!==D.id)throw await i.cancel(x),new Error(`Choose a package for ${D.manifest.name} (${D.id}).`);_(x)}const F=R||w||!(n!=null&&n.store.available);return t.jsx(ft,{open:!0,onOpenChange:x=>{!x&&!R&&!w&&(z(),l())},children:t.jsxs(xt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!R&&!w,children:[t.jsxs(gt,{children:[t.jsx(jt,{children:"Plugins"}),t.jsx(bt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||C||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:n!=null&&n.store.available&&!C&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:C??e.error??(n==null?void 0:n.store.error)})]}),N&&t.jsx(se,{children:t.jsx(ne,{children:N})}),r&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(P,{size:"sm",variant:"outline",disabled:R||w||(n==null?void 0:n.safeMode),onClick:()=>vt(!u),children:u?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(P,{variant:"outline",disabled:R,onClick:()=>{J(()=>i.refresh())},children:[t.jsx(Rt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&T&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h2",{className:"font-medium",children:T.manifest.name}),t.jsx(P,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),T.manifest.permissions.connections.length>0&&T.manifest.contributes.settings&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect the service first. Its settings below take effect once it is connected."}),T.manifest.permissions.connections.length>0&&t.jsx(qt,{client:i,status:n,pluginId:T.id,initialProjectId:(v==null?void 0:v.id)??null},`${T.id}:${n.store.revision}`),T.manifest.contributes.settings&&t.jsx(Mt,{client:i,pluginId:T.id,projectId:(v==null?void 0:v.id)??null,definition:T.manifest.contributes.settings},`settings:${T.id}:${n.store.revision}`)]}),n&&!T&&!c&&t.jsxs(yt,{value:$,onValueChange:x=>{O(String(x)),q(null),L(null)},children:[t.jsxs(wt,{className:"h-auto flex-wrap",children:[t.jsx(Oe,{value:"installed",children:"Installed"}),t.jsx(Oe,{value:"browse",children:"Browse"}),t.jsx(Oe,{value:"install",children:"Install from file"}),t.jsx(Oe,{value:"publishers",children:"Publishers"})]}),t.jsx(Fe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(x=>t.jsx(Ht,{plugin:x,status:n,client:i,busy:F,run:E=>{J(E)},onPreview:_,onConnections:G,onUpdate:E=>{q(E),L(null),O("install")}},`${x.id}:${n.store.revision}`)):t.jsx(Ct,{children:t.jsxs(St,{children:[t.jsx(Nt,{variant:"icon",children:t.jsx(Dt,{})}),t.jsx(kt,{children:"No installed plugins"}),t.jsx($t,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Fe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),(n.store.availableSeeds??[]).map(x=>{const E=n.store.plugins.find(B=>B.id===x.manifest.id),W=E&&It(x.manifest.version,E.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:x.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.manifest.version," · ",x.manifest.publisher]})]}),W?t.jsx(P,{size:"sm",disabled:F||E.pinned,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,E.scope)))},children:E.pinned?"Pinned to installed version":"Review update"}):E?t.jsx(De,{variant:"outline",children:"Installed"}):t.jsx(P,{size:"sm",disabled:F||!g&&m,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,j)))},children:"Review installation"})]},x.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Fe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:x=>{x.preventDefault(),J(U)},children:t.jsxs(Ie,{children:[D&&t.jsxs("p",{className:"text-sm",children:["Update ",D.manifest.name," from ",D.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(Q,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(re,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:F,required:!0,onChange:x=>{var E;return L(((E=x.target.files)==null?void 0:E[0])??null)}})]}),!D&&t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),t.jsxs(P,{type:"submit",disabled:F||!H||!D&&!g&&m,children:["Review ",D?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Fe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(x=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[x.label," ",t.jsx(De,{variant:"outline",children:x.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[x.id," · ",x.fingerprint]})]},x.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Pt,{client:i,busy:F,run:x=>{J(x)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",f.hostName]}),t.jsx(De,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Zt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(x=>{var E;return((E=n==null?void 0:n.projects.find(W=>W.id===x))==null?void 0:E.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(x=>t.jsxs("li",{children:[x.side,": ",x.name," requires ",x.required,"; available ",x.actual??"none","."]},`${x.side}:${x.code}:${x.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(x=>x.name).join(", "),"."]})}),w&&te&&!r?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{client:i,preview:c,activation:e.activation,onComplete:()=>{S(!1),h(null),I(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${f.hostName}.`),O("installed"),q(null)},onError:x=>{p(x.message),z()}}),t.jsxs(P,{variant:"outline",onClick:z,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(P,{variant:"outline",disabled:R,onClick:z,children:"Cancel"}),t.jsxs(P,{disabled:F||!te||!c.compatibility.compatible||r,onClick:()=>{p(null),S(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",f.hostName]})]})]})]})]})})}export{us as PluginsDialog};
@@ -0,0 +1 @@
1
+ import{r as s,j as t}from"./vendor-react-gGw_S5I_.js";import{aR as ne,B as g,S as K,aC as ie,ae as oe,az as le,aw as ce,ax as de,ay as G,at as ue,aB as he,aA as pe,c as me,E as fe,f as xe,U as we,h as ve,i as ge,aZ as be,F as je,X as b}from"./index-BVmNox_3.js";import{dg as H,X as Se,V as ye,bM as Ne,b5 as Ie,dj as ke,di as Ee,dh as Me,bq as Pe,dt as ze,du as Re}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";const W=360,Ce=560,V="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",k=.5,E=1.5,I=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:Ee},desktop:{label:"Desktop",width:1280,height:800,icon:ke}};function De(){try{const a=Number(localStorage.getItem(V));if(Number.isFinite(a)&&a>=W)return a}catch{}return Ce}function Te(){try{const a=localStorage.getItem(Y);if(a&&a in h)return a}catch{}return"responsive"}function We(){try{const a=localStorage.getItem(_);if(a===null)return 1;const i=Number(a);if(Number.isFinite(i))return Math.min(E,Math.max(k,i))}catch{}return 1}function X(a){return be(`cogpit-preview-url:${a}`)}function A(a){const i=a.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const n=new URL(j);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}catch{return null}}function B(a,i){return`http://${i||"localhost"}:${a}/`}function Fe({cwd:a,onClose:i}){const[M,j]=s.useState([]),[n,P]=s.useState(""),[$,S]=s.useState(""),[z,R]=s.useState(null),[q,J]=s.useState(0),[Q,C]=s.useState(!1),[y,ee]=s.useState(De),[l,te]=s.useState(Te),[o,p]=s.useState(We),c=s.useRef(null),O=s.useRef(null),D=s.useRef(null),{activeDevice:m}=ne(),N=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;s.useEffect(()=>{let e="";try{e=localStorage.getItem(X(a))??""}catch{}const r=e?A(e)??"":"";P(r),S(r),R(null)},[a,re]),s.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(a)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=B(L,N);P(v=>v||w),S(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[a,N]),s.useEffect(()=>{if(n)try{localStorage.setItem(X(a),n)}catch{}},[a,n]),s.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=s.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=s.useCallback(e=>{const r=A(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),S(r),C(!0)},[]),T=s.useCallback(()=>{n&&(C(!0),J(e=>e+1))},[n]);s.useEffect(()=>{function e(r){var d,u,x;if((d=O.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),T();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=D.current)==null||u.focus(),(x=D.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(E,Number((f+I).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(k,Number((f-I).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T]);const ae=s.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:y,currentWidth:y},e.currentTarget.setPointerCapture(e.pointerId)},[y]),se=s.useCallback(e=>{if(!c.current)return;const r=Math.max(W,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(W,d));c.current.currentWidth=u,ee(u)},[]),F=s.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(V,String(e))}catch{}},[]);return t.jsxs("aside",{ref:O,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-canvas",style:{width:y},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:ae,onPointerMove:se,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(Se,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U($)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:D,"aria-label":"Preview URL","aria-invalid":!!z,value:$,onChange:e=>S(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!n,onClick:T,"aria-label":"Refresh preview",children:t.jsx(ye,{"data-icon":"inline-start",className:Q?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!n,onClick:()=>window.open(n,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ne,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(B(e,N)),"aria-label":`Open ${N}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=k,onClick:()=>p(e=>Math.max(k,Number((e-I).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=E,onClick:()=>p(e=>Math.min(E,Number((e+I).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:n?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:n,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>C(!1)},`${n}-${q}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Fe as PreviewPanel,A as normalizePreviewUrl};
@@ -0,0 +1,4 @@
1
+ import{r as l,j as t,c as Ae}from"./vendor-react-gGw_S5I_.js";import{E as X,f as Y,U as W,h as Q,i as q,F as ae,c as ie,cV as ot,x as je,B as A,cW as Ct,t as kt,cX as Et,cY as Rt,S as xe,k as le,az as Dt,ax as Ft,aw as Lt,aB as nt,aA as he,m as Tt,cZ as Mt,c_ as $t,s as zt,o as It,n as At,l as Ut,D as Pt,j as Ot,ad as Bt,aE as Gt,aa as Kt,a9 as Ht,a5 as Vt,a3 as Xt,a4 as Yt,a7 as Wt,a6 as Qt,a8 as qt,X as Jt}from"./index-BVmNox_3.js";import{H as Zt}from"./HighlightedEditor-DPrSCx1c.js";import{T as ge,cE as Ie,bl as _t,c6 as es,A as ts,X as ss,a7 as ns,ak as ls,V as lt,cM as as,dw as at,dr as is,b$ as $e}from"./vendor-ui-CKjyvB3_.js";import{M as rs}from"./vendor-markdown-BEJ8yVzA.js";const os=12,ct="h-6 w-full justify-start gap-1 rounded-none px-2 text-left font-normal";function Se(n,e){return{paddingLeft:8+n*os+(e?0:16)}}function cs(n){const e=n;return typeof e=="object"&&e!==null&&typeof e.name=="string"&&(e.type==="file"||e.type==="directory")}function ds(n){const e=n==null?void 0:n.entries;return Array.isArray(e)?e.filter(cs):[]}async function it(n,e,r){try{const o=await ae(`/api/project-files/tree?cwd=${encodeURIComponent(n)}&dir=${encodeURIComponent(e)}${r?"&refresh=1":""}`);if(!o.ok){const u=await o.json().catch(()=>null),f=u==null?void 0:u.error;throw new Error(typeof f=="string"?f:"Unable to list directory")}const c=await o.json();return{status:"ready",entries:ds(c),scanLimited:c.scanLimited===!0}}catch(o){return{status:"error",message:o instanceof Error?o.message:"Unable to list directory"}}}function fs(n){const e=n.split("/");return e.slice(0,-1).map((r,o)=>e.slice(0,o+1).join("/"))}function us({cwd:n,selectedPath:e,onSelect:r,fileStatus:o,reloadToken:c}){const[u,f]=l.useState(()=>new Map),[g,S]=l.useState(()=>new Set),b=l.useRef(new Set),R=l.useRef(n);R.current=n;const m=l.useCallback(async x=>{if(b.current.has(x))return;b.current.add(x),f(y=>new Map(y).set(x,{status:"loading"}));const w=await it(n,x,!1);b.current.delete(x),R.current===n&&f(y=>new Map(y).set(x,w))},[n]),h=l.useRef(null);l.useEffect(()=>{const x=h.current===n;h.current=n,x||S(new Set),f(new Map([["",{status:"loading"}]]));let w=!1;return it(n,"",x).then(y=>{w||f(new Map([["",y]]))}),()=>{w=!0}},[n,c]),l.useEffect(()=>{if(!e)return;const x=fs(e);x.length!==0&&S(w=>{if(x.every(D=>w.has(D)))return w;const y=new Set(w);for(const D of x)y.add(D);return y})},[e]);const N=l.useCallback(x=>{S(w=>{const y=new Set(w);return y.has(x)?y.delete(x):y.add(x),y})},[]),j=u.get(""),k=ms(j);return t.jsxs("div",{"aria-label":"Project file tree",className:"flex flex-col py-1",children:[k?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(k.Icon,{})}),t.jsx(Q,{children:k.title}),t.jsx(q,{children:k.description})]})}):t.jsx(dt,{directory:"",depth:0,state:j,directories:u,expanded:g,selectedPath:e,onSelect:r,onToggle:N,onLoad:m,fileStatus:o}),(j==null?void 0:j.status)==="ready"&&j.scanLimited&&t.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"This project is too large to scan completely."})]})}function ms(n){return(n==null?void 0:n.status)==="error"?{Icon:ge,title:"Could not load files",description:n.message}:(n==null?void 0:n.status)==="ready"&&n.entries.length===0?{Icon:Ie,title:"No files",description:"This project has no files to show."}:null}function dt(n){const e=Ae.c(22),{directory:r,depth:o,state:c,onLoad:u,...f}=n;let g,S;if(e[0]!==r||e[1]!==u||e[2]!==c?(g=()=>{c===void 0&&r!==""&&u(r)},S=[r,u,c],e[0]=r,e[1]=u,e[2]=c,e[3]=g,e[4]=S):(g=e[3],S=e[4]),l.useEffect(g,S),!c||c.status==="loading"){let m;e[5]!==o?(m=Se(o,!1),e[5]=o,e[6]=m):m=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(je,{className:"size-3"}),e[7]=h):h=e[7];const N=r===""&&"Loading files…";let j;return e[8]!==m||e[9]!==N?(j=t.jsxs("div",{role:"status",className:"flex h-6 items-center gap-2 text-xs text-muted-foreground",style:m,children:[h,N]}),e[8]=m,e[9]=N,e[10]=j):j=e[10],j}if(c.status==="error"){let m;e[11]!==o?(m=Se(o,!1),e[11]=o,e[12]=m):m=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ge,{"aria-hidden":"true",className:"size-3 shrink-0"}),e[13]=h):h=e[13];let N;e[14]!==c.message?(N=t.jsx("span",{className:"truncate",children:c.message}),e[14]=c.message,e[15]=N):N=e[15];let j;return e[16]!==c.message||e[17]!==m||e[18]!==N?(j=t.jsxs("div",{role:"alert",className:"flex h-6 items-center gap-1.5 truncate text-xs text-destructive",style:m,title:c.message,children:[h,N]}),e[16]=c.message,e[17]=m,e[18]=N,e[19]=j):j=e[19],j}const b=c.entries.map(m=>{const h=r?`${r}/${m.name}`:m.name;return m.type==="directory"?t.jsx(xs,{path:h,name:m.name,depth:o,onLoad:u,...f},h):t.jsx(hs,{path:h,name:m.name,depth:o,selected:f.selectedPath===h,status:f.fileStatus(h),onSelect:f.onSelect},h)});let R;return e[20]!==b?(R=t.jsx(t.Fragment,{children:b}),e[20]=b,e[21]=R):R=e[21],R}function xs(n){const e=Ae.c(48);let r,o,c,u,f,g,S,b,R,m,h,N,j,k,x,w,y;e[0]!==n?({path:S,name:f,depth:u,...b}=n,g=b.expanded.has(S),r=g?_t:es,c=A,h="ghost",N="sm",j=g,k=ct,e[18]!==u?(x=Se(u,!0),e[18]=u,e[19]=x):x=e[19],w=()=>b.onToggle(S),y=S,o=ts,R="true",m=ie("size-3 shrink-0 text-muted-foreground transition-transform",g&&"rotate-90"),e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=u,e[5]=f,e[6]=g,e[7]=S,e[8]=b,e[9]=R,e[10]=m,e[11]=h,e[12]=N,e[13]=j,e[14]=k,e[15]=x,e[16]=w,e[17]=y):(r=e[1],o=e[2],c=e[3],u=e[4],f=e[5],g=e[6],S=e[7],b=e[8],R=e[9],m=e[10],h=e[11],N=e[12],j=e[13],k=e[14],x=e[15],w=e[16],y=e[17]);let D;e[20]!==o||e[21]!==R||e[22]!==m?(D=t.jsx(o,{"aria-hidden":R,className:m}),e[20]=o,e[21]=R,e[22]=m,e[23]=D):D=e[23];let L;e[24]!==r?(L=t.jsx(r,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[24]=r,e[25]=L):L=e[25];let F;e[26]!==f?(F=t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:f}),e[26]=f,e[27]=F):F=e[27];let i;e[28]!==c||e[29]!==D||e[30]!==L||e[31]!==F||e[32]!==h||e[33]!==N||e[34]!==j||e[35]!==k||e[36]!==x||e[37]!==w||e[38]!==y?(i=t.jsxs(c,{variant:h,size:N,"aria-expanded":j,className:k,style:x,onClick:w,title:y,children:[D,L,F]}),e[28]=c,e[29]=D,e[30]=L,e[31]=F,e[32]=h,e[33]=N,e[34]=j,e[35]=k,e[36]=x,e[37]=w,e[38]=y,e[39]=i):i=e[39];let T;e[40]!==u||e[41]!==g||e[42]!==S||e[43]!==b?(T=g&&t.jsx("div",{children:t.jsx(dt,{directory:S,depth:u+1,state:b.directories.get(S),...b})}),e[40]=u,e[41]=g,e[42]=S,e[43]=b,e[44]=T):T=e[44];let U;return e[45]!==i||e[46]!==T?(U=t.jsxs("div",{children:[i,T]}),e[45]=i,e[46]=T,e[47]=U):U=e[47],U}function hs(n){const e=Ae.c(28),{path:r,name:o,depth:c,selected:u,status:f,onSelect:g}=n,S=l.useRef(null);let b;e[0]!==r?(b=ot(r),e[0]=r,e[1]=b):b=e[1];const R=b;let m,h;e[2]!==u?(m=()=>{var T,U;u&&((U=(T=S.current)==null?void 0:T.scrollIntoView)==null||U.call(T,{block:"nearest"}))},h=[u],e[2]=u,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);const N=u||void 0,j=u?"secondary":"ghost";let k;e[5]!==c?(k=Se(c,!1),e[5]=c,e[6]=k):k=e[6];let x;e[7]!==g||e[8]!==r?(x=()=>g(r),e[7]=g,e[8]=r,e[9]=x):x=e[9];let w;e[10]!==R?(w=t.jsx(R,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[10]=R,e[11]=w):w=e[11];const y=f&&f.className;let D;e[12]!==y?(D=ie("min-w-0 flex-1 truncate text-xs",y),e[12]=y,e[13]=D):D=e[13];let L;e[14]!==o||e[15]!==D?(L=t.jsx("span",{className:D,children:o}),e[14]=o,e[15]=D,e[16]=L):L=e[16];let F;e[17]!==f?(F=f&&t.jsx("span",{className:ie("shrink-0 font-mono text-[10px]",f.className),title:f.label,children:f.code}),e[17]=f,e[18]=F):F=e[18];let i;return e[19]!==r||e[20]!==L||e[21]!==F||e[22]!==N||e[23]!==j||e[24]!==k||e[25]!==x||e[26]!==w?(i=t.jsxs(A,{ref:S,"aria-current":N,variant:j,size:"sm",className:ct,style:k,onClick:x,title:r,children:[w,L,F]}),e[19]=r,e[20]=L,e[21]=F,e[22]=N,e[23]=j,e[24]=k,e[25]=x,e[26]=w,e[27]=i):i=e[27],i}const ps={"?":{label:"Untracked",className:"text-info"},A:{label:"Added",className:"text-success"},M:{label:"Modified",className:"text-warning"},D:{label:"Deleted",className:"text-destructive"},R:{label:"Renamed",className:"text-info"},C:{label:"Copied",className:"text-info"},U:{label:"Conflicted",className:"text-destructive"}};function ze(n){const e=n.workTreeStatus.trim()||n.indexStatus.trim();return ps[e]??{label:"Changed",className:"text-muted-foreground"}}function js(n){return`${n.indexStatus}${n.workTreeStatus}`.trim()||"?"}const gs=new Set([".md",".mdx",".markdown"]);function rt(n){const e=n.lastIndexOf(".");return e!==-1&&gs.has(n.slice(e).toLowerCase())}function ws(n,e,r){if(!n||/^(?:[a-z]+:|\/|#)/i.test(n))return n;const o=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",c=[];for(const f of[...o.split("/"),...n.split("/")])f===".."?c.pop():f&&f!=="."&&c.push(f);const u=e.includes("\\")?"\\":"/";return[e.replace(/[\\/]+$/,""),...c].join(u)}async function pe(n,e){try{const r=await n.json();if(r&&typeof r=="object"&&typeof r.error=="string")return r.error}catch{}return e}function vs(n){return n<1024?`${n} B`:`${(n/1024).toFixed(n<10*1024?1:0)} KB`}function ys(n,e){let r=0;for(let o=1;o<e;o+=1){const c=n.indexOf(`
2
+ `,r);if(c<0)return r;r=c+1}return r}function Es({cwd:n,onClose:e,onAddToPrompt:r,openRequest:o}){const c=l.useRef(null),u=l.useRef(null),f=l.useRef(null),[g,S]=l.useState(""),[b,R]=l.useState([]),[m,h]=l.useState(!0),[N,j]=l.useState(null),[k,x]=l.useState(0),[w,y]=l.useState(!1),[D,L]=l.useState(0),F=l.useRef(!1),[i,T]=l.useState(null),[U,Ce]=l.useState(!0),[M,J]=l.useState(""),[ft,re]=l.useState(""),[P,oe]=l.useState(null),[ut,Ue]=l.useState(0),[K,Pe]=l.useState(!1),[Z,Oe]=l.useState(!1),[Be,_]=l.useState(null),[mt,ee]=l.useState(!1),[$,ke]=l.useState("all"),[v,Ge]=l.useState(null),[Ke,He]=l.useState(!1),[xt,Ve]=l.useState(null),[C,ce]=l.useState("edit"),[E,we]=l.useState(null),[de,Xe]=l.useState(!1),[Ye,Ee]=l.useState(null),[fe,H]=l.useState(null),[O,ve]=l.useState(null),[ye,Re]=l.useState(""),[G,ue]=l.useState(null),z=i!==null&&M!==ft,I=l.useMemo(()=>new Map(((v==null?void 0:v.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[v==null?void 0:v.files]),te=l.useCallback(async()=>{He(!0),Ve(null);try{const s=await ae(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const a=await s.json();Ge(a),a.isRepository||ke("all")}catch(s){Ge(null),ke("all"),Ve(s instanceof Error?s.message:"Unable to read git status")}finally{He(!1)}},[n]);l.useEffect(()=>{te()},[te]);const De=$==="all"&&g.trim()==="";l.useEffect(()=>{if(De)return;const s=new AbortController,a=window.setTimeout(async()=>{h(!0),j(null);const d=F.current;F.current=!1;try{const p=await ae(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(g)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!p.ok)throw new Error(await pe(p,"Unable to list project files"));const B=await p.json();if(s.signal.aborted)return;const tt=Ct(B),st=B.totalMatches;R(tt),x(typeof st=="number"?st:tt.length),y(B.scanLimited===!0)}catch(p){s.signal.aborted||(R([]),j(p instanceof Error?p.message:"Unable to list project files"))}finally{s.signal.aborted||h(!1)}},120);return()=>{window.clearTimeout(a),s.abort()}},[n,g,D,De]),l.useEffect(()=>{T(null),J(""),re(""),oe(null),_(null),H(null),ce("edit"),we(null),Ee(null),ue(null)},[n]),l.useEffect(()=>{if(!z)return;const s=a=>a.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[z]);const ht=l.useCallback((s,a)=>{const d=u.current;if(!d)return;if(!a||a<1){d.focus();return}const p=ys(s,a);d.blur(),d.setSelectionRange(p,p),d.focus()},[]);l.useEffect(()=>{const s=f.current;!s||!u.current||(f.current=null,ht(s.text,s.line))});const se=l.useCallback(async(s,a)=>{Pe(!0),_(null),ee(!1),H(null);try{const d=await ae(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const p=await d.json();J(p.content),re(p.content),oe(p.mtimeMs),Ue(p.size),f.current={text:p.content,line:a}}catch(d){J(""),re(""),oe(null),_(d instanceof Error?d.message:"Unable to open file")}finally{Pe(!1)}},[n]),ne=l.useCallback(async(s,a)=>{Xe(!0),Ee(null),we(null);try{const d=a?`&originalPath=${encodeURIComponent(a)}`:"",p=await ae(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!p.ok)throw new Error(await pe(p,"Unable to diff file"));we(await p.json())}catch(d){Ee(d instanceof Error?d.message:"Unable to diff file")}finally{Xe(!1)}},[n]),be=l.useCallback(({path:s,mode:a,line:d})=>{var p;if(T(s),Ce(!1),a==="edit"){ce(rt(s)&&!d?"preview":"edit"),se(s,d);return}ce(a),J(""),re(""),oe(null),_(null),ee(!1),H(null),ne(s,(p=I.get(s))==null?void 0:p.originalPath)},[I,ne,se]),Ne=l.useCallback(s=>{if(z){ue({type:"file",target:s});return}be(s)},[z,be]),We=l.useCallback(s=>{if(s===i){Ce(!1);return}const a=$==="changes"&&I.has(s)?"diff":"edit";Ne({path:s,mode:a})},[I,$,Ne,i]),Qe=l.useRef(0);l.useEffect(()=>{!o||o.token===Qe.current||(Qe.current=o.token,Ne({path:o.file,mode:o.mode,line:o.line}))},[o,Ne]);const pt=l.useCallback(()=>{var s;!i||C==="diff"||(ce("diff"),(E==null?void 0:E.path)!==i&&!de&&ne(i,(s=I.get(i))==null?void 0:s.originalPath))},[I,E==null?void 0:E.path,de,ne,i,C]),jt=l.useCallback(s=>{!i||C===s||(ce(s),P===null&&!K&&se(i))},[K,se,P,i,C]),Fe=l.useCallback(()=>{var s;if(i){if(C==="diff"){ne(i,(s=I.get(i))==null?void 0:s.originalPath);return}se(i)}},[I,ne,se,i,C]),gt=l.useCallback(()=>{F.current=!0,L(s=>s+1),te(),C==="diff"&&Fe()},[te,Fe,C]),Le=l.useCallback(async()=>{if(!(!i||P===null||!z||Z)){Oe(!0),_(null),ee(!1);try{const s=await ae("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,path:i,content:M,expectedMtimeMs:P})});if(!s.ok)throw new Error(await pe(s,"Unable to save file"));const a=await s.json();re(M),oe(a.mtimeMs),Ue(a.size),ee(!0),we(null),te()}catch(s){_(s instanceof Error?s.message:"Unable to save file")}finally{Oe(!1)}}},[M,n,z,te,P,Z,i]);l.useEffect(()=>{function s(a){var d;(d=c.current)!=null&&d.contains(document.activeElement)&&Jt("projectFileSave",a)&&(a.preventDefault(),Le())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Le]);const wt=l.useCallback(()=>{if(z){ue({type:"close"});return}e()},[z,e]),vt=l.useCallback(()=>{if(!G)return;const s=G;if(ue(null),s.type==="file"){be(s.target);return}e()},[e,be,G]),yt=l.useCallback(s=>{if(s.key!=="Tab")return;s.preventDefault();const a=s.currentTarget,d=a.selectionStart,p=a.selectionEnd,B=`${M.slice(0,d)} ${M.slice(p)}`;J(B),ee(!1),H(null),requestAnimationFrame(()=>{a.selectionStart=d+2,a.selectionEnd=d+2})},[M]),bt=l.useCallback(s=>{const a=s.currentTarget;if(a.selectionStart===a.selectionEnd){H(null);return}const d=M.slice(a.selectionStart,a.selectionEnd),p=M.slice(0,a.selectionStart).split(`
3
+ `).length,B=p+d.split(`
4
+ `).length-1;H({text:d,startLine:p,endLine:B})},[M]),Te=l.useMemo(()=>(i==null?void 0:i.split("/").at(-1))??null,[i]),me=i?I.get(i):void 0,qe=i!==null&&rt(i),Je=l.useCallback(s=>{const a=I.get(s);return a?{code:js(a),...ze(a)}:null},[I]),Nt=l.useMemo(()=>({...kt,img:s=>t.jsx(Et,{src:ws(s.src,n,i??""),alt:s.alt})}),[n,i]),Me=l.useMemo(()=>E&&!E.binary&&!E.tooLarge?Rt(E.original??"",E.current??""):null,[E]),V=l.useMemo(()=>{if($==="all")return b;const s=g.trim().toLowerCase();return((v==null?void 0:v.files)??[]).map(a=>a.path).filter((a,d,p)=>p.indexOf(a)===d).filter(a=>!s||a.toLowerCase().includes(s)).sort((a,d)=>a.localeCompare(d))},[$,b,v==null?void 0:v.files,g]),Ze=l.useMemo(()=>i&&!V.includes(i)?[i,...V]:V,[V,i]),St=$==="changes"?Ke:m,_e=$==="changes"?xt:N,et=Ke;return t.jsxs("aside",{ref:c,"aria-label":"Project files",className:"relative flex size-full min-h-0 flex-col bg-canvas",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(Ie,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(A,{variant:"ghost",size:"icon-sm",onClick:wt,"aria-label":"Close project files",children:t.jsx(ss,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(v==null?void 0:v.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(ns,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:v.branch??"Detached HEAD",children:v.branch??"detached HEAD"}),v.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",v.upstream]}),(v.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",v.ahead]}),(v.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",v.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[v.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:ie("min-h-0 shrink-0 flex-col md:flex md:w-56",i&&!U?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(Dt,{className:"min-w-0 flex-1",children:[t.jsx(Ft,{children:t.jsx(ls,{"data-icon":"inline-start"})}),t.jsx(Lt,{"aria-label":"Search project files",value:g,onChange:s=>S(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:et,onClick:gt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(lt,{"data-icon":"inline-start",className:et?"animate-spin":void 0})})]}),(v==null?void 0:v.isRepository)&&t.jsxs(nt,{"aria-label":"File scope",value:[$],onValueChange:s=>{const a=s[0];(a==="all"||a==="changes")&&ke(a)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(he,{value:"all",className:"flex-1",children:"All files"}),t.jsx(he,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Tt,{className:"min-h-0 flex-1",children:De?t.jsx(us,{cwd:n,selectedPath:i,onSelect:We,fileStatus:Je,reloadToken:D}):St?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading files…"]}):_e?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(Q,{children:"Could not load files"}),t.jsx(q,{children:_e})]})}):Ze.length===0?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(Q,{children:$==="changes"?"No working-tree changes":"No matching files"}),t.jsx(q,{children:$==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[Ze.map(s=>{const a=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",p=Je(s),B=ot(s);return t.jsxs(A,{variant:i===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>We(s),title:s,children:[t.jsx(B,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:a}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),p&&t.jsx(le,{variant:"outline",className:ie("font-mono",p.className),title:p.label,children:p.code})]},s)}),$==="all"&&(k>V.length||w)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[k>V.length&&`Showing ${V.length} of ${k} matches. Type to narrow the list. `,w&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical",className:"hidden md:block"}),t.jsx("section",{"aria-label":"File editor",className:ie("min-h-0 min-w-0 flex-1 flex-col md:flex",i&&!U?"flex":"hidden"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center gap-2 px-3 py-1 md:flex-nowrap",children:[t.jsx(A,{variant:"ghost",size:"icon-lg",className:"md:hidden",onClick:()=>Ce(!0),"aria-label":"Back to file browser",children:t.jsx(as,{"data-icon":"inline-start"})}),t.jsxs("div",{className:"min-w-0 flex-1 basis-[calc(100%-3.25rem)] md:basis-auto",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:i,children:Te}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:i})]}),(me||C==="diff"||qe)&&t.jsxs(nt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?pt():(s[0]==="edit"||s[0]==="preview")&&jt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(me||C==="diff")&&t.jsx(he,{value:"diff",children:"Diff"}),qe&&t.jsx(he,{value:"preview",children:"Preview"}),t.jsx(he,{value:"edit",children:"Edit"})]}),C==="diff"&&me&&t.jsx(le,{variant:"outline",className:ze(me).className,children:ze(me).label}),C==="diff"&&Me&&t.jsx(Mt,{add:Me.add,del:Me.del}),C!=="diff"&&z&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!z&&mt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&P!==null&&t.jsx("span",{className:"hidden text-xs text-muted-foreground md:inline",children:vs(ut)}),r&&t.jsxs(A,{variant:"outline",size:"sm",disabled:C==="diff"?de||E===null:K||P===null,onClick:()=>{fe?(Re(""),ve(fe)):r({path:i})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(at,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||Z,onClick:Fe,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(lt,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(A,{size:"sm",disabled:!z||K||Z||P===null,onClick:()=>void Le(),children:[Z?t.jsx(je,{"data-icon":"inline-start"}):t.jsx(is,{"data-icon":"inline-start"}),Z?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Be&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(ge,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Be})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading diff…"]}):Ye?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(Q,{children:"Could not diff this file"}),t.jsx(q,{children:Ye})]})}):E===null?null:E.binary||E.tooLarge?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:E.binary?"Binary file":"File is too large to diff"}),t.jsx(q,{children:E.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):E.original===E.current?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:"No content changes"}),t.jsx(q,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx($t,{oldString:E.original??"",newString:E.current??"",filePath:i,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Opening file…"]}),!K&&P!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${i}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(rs,{components:Nt,remarkPlugins:zt,children:M})}):t.jsx(Zt,{textareaRef:u,ariaLabel:`Editing ${i}`,filePath:i,value:M,readOnly:!1,onChange:s=>{J(s),ee(!1),H(null)},onKeyDown:yt,onSelect:bt}))]})]}):t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:"Select a file"}),t.jsx(q,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx(It,{open:O!==null,onOpenChange:s=>{s||ve(null)},children:t.jsxs(At,{children:[t.jsxs(Ut,{children:[t.jsx(Pt,{children:"Comment on selected lines"}),t.jsxs(Ot,{children:["Add a review instruction for ",i," lines ",O==null?void 0:O.startLine,"-",O==null?void 0:O.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const a=ye.trim();!i||!O||!a||!r||(r({path:i,...O,comment:a}),ve(null),Re(""))},children:[t.jsx(Bt,{autoFocus:!0,"aria-label":"Review comment",value:ye,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var a;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&ye.trim()&&(s.preventDefault(),(a=s.currentTarget.form)==null||a.requestSubmit())}}),t.jsxs(Gt,{children:[t.jsx(A,{type:"button",variant:"outline",onClick:()=>ve(null),children:"Cancel"}),t.jsxs(A,{type:"submit",disabled:!ye.trim(),children:[t.jsx(at,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Kt,{open:G!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Ht,{size:"sm",children:[t.jsxs(Vt,{children:[t.jsx(Xt,{children:"Discard unsaved changes?"}),t.jsx(Yt,{children:(G==null?void 0:G.type)==="file"?`Your edits to ${Te??"this file"} will be lost when you open ${G.target.path}.`:`Your edits to ${Te??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(Wt,{children:[t.jsx(Qt,{size:"sm",children:"Keep editing"}),t.jsx(qt,{variant:"destructive",size:"sm",onClick:vt,children:"Discard changes"})]})]})})]})}export{Es as ProjectFilesPanel};
@@ -0,0 +1 @@
1
+ import{c as C,r as E,j as m}from"./vendor-react-gGw_S5I_.js";import{ag as y,l as L,D as F,j as K,n as k,bK as R,o as _,X as A,bL as H}from"./index-BVmNox_3.js";import"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";function X(v){const e=C.c(28),{open:r,onClose:t,onNewSession:i,onNewFolder:j,defaultAgentKind:x,currentProjectDirName:a,currentProjectCwd:o,initialView:D}=v,s=y(r);let h,p;e[0]!==o||e[1]!==a||e[2]!==t||e[3]!==i||e[4]!==r||e[5]!==s?(h=()=>{if(!r)return;const n=function(N){var S;if(A("newSession",N)&&a){N.preventDefault();const P=o?H(s,o,"claude")??((S=s.find(b=>b.path===o))==null?void 0:S.dirName)??a:a;i(P,o??void 0),t()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},p=[r,s,a,o,i,t],e[0]=o,e[1]=a,e[2]=t,e[3]=i,e[4]=r,e[5]=s,e[6]=h,e[7]=p):(h=e[6],p=e[7]),E.useEffect(h,p);let l;e[8]!==t?(l=n=>{n||t()},e[8]=t,e[9]=l):l=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsxs(L,{className:"sr-only",children:[m.jsx(F,{children:"Start a session"}),m.jsx(K,{children:"Choose a project, enter an absolute folder path, or browse the folders."})]}),e[10]=w):w=e[10];let c;e[11]!==t||e[12]!==i?(c=(n,g)=>{i(n,g),t()},e[11]=t,e[12]=i,e[13]=c):c=e[13];let d;e[14]!==t||e[15]!==j?(d=n=>{j(n),t()},e[14]=t,e[15]=j,e[16]=d):d=e[16];let f;e[17]!==o||e[18]!==x||e[19]!==D||e[20]!==s||e[21]!==c||e[22]!==d?(f=m.jsxs(k,{className:"max-w-md gap-0 overflow-hidden p-0",children:[w,m.jsx(R,{projects:s,currentPath:o,onNewSession:c,onNewFolder:d,defaultAgentKind:x,initialView:D})]}),e[17]=o,e[18]=x,e[19]=D,e[20]=s,e[21]=c,e[22]=d,e[23]=f):f=e[23];let u;return e[24]!==r||e[25]!==l||e[26]!==f?(u=m.jsx(_,{open:r,onOpenChange:l,children:f}),e[24]=r,e[25]=l,e[26]=f,e[27]=u):u=e[27],u}export{X as ProjectSwitcherModal};
@@ -1,4 +1,4 @@
1
- import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{aq as Gr,w as as,B as Jr}from"./index-CPTFl4Qh.js";import{a0 as Zr}from"./vendor-ui-DQeMoSiV.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";/**
1
+ import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{W as Gr,X as as,B as Jr}from"./index-BVmNox_3.js";import{d1 as Zr}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *
@@ -46,6 +46,6 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
46
46
  * Fabrice Bellard's javascript vt100 for jslinux:
47
47
  * http://bellard.org/jslinux/
48
48
  * Copyright (c) 2011 Fabrice Bellard
49
- */var _h=class{constructor(e,t,i,s={}){this._terminal=e,this._regex=t,this._handler=i,this._options=s}provideLinks(e,t){let i=ph.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r)}},t))}};function fh(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch{return!1}}var ph=class $t{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,h]=$t._getWindowedLineStrings(t-1,s),l=o.join(""),a,d=[];for(;a=n.exec(l);){let c=a[0];if(!fh(c))continue;let[u,f]=$t._mapStrIdx(s,h,0,a.index),[_,p]=$t._mapStrIdx(s,u,f,c.length);if(u===-1||f===-1||_===-1||p===-1)continue;let v={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};d.push({range:v,text:c,activate:r})}return d}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,h="",l=[];if(s=i.buffer.active.getLine(t)){let a=s.translateToString(!0);if(s.isWrapped&&a[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(h=s.translateToString(!0),o+=h.length,l.push(h),!(!s.isWrapped||h.indexOf(" ")!==-1)););l.reverse()}for(l.push(a),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(h=s.translateToString(!0),o+=h.length,l.push(h),h.indexOf(" ")===-1););}return[l,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),h=s;for(;r;){let l=n.getLine(i);if(!l)return[-1,-1];for(let a=h;a<l.length;++a){l.getCell(a,o);let d=o.getChars();if(o.getWidth()&&(r-=d.length||1,a===l.length-1&&d==="")){let c=n.getLine(i+1);c&&c.isWrapped&&(c.getCell(0,o),o.getWidth()===2&&(r+=1))}if(r<0)return[i,a]}i++,h=0}return[i,h]}},gh=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function vh(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var mh=class{constructor(e=vh,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,i=t.urlRegex||gh;this._linkProvider=this._terminal.registerLinkProvider(new _h(this._terminal,i,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};function ir(e){const t=getComputedStyle(e),i=s=>t.getPropertyValue(`--${s}`).trim();return{background:"#00000000",foreground:i("foreground"),cursor:i("foreground"),cursorAccent:i("canvas"),selectionBackground:i("terminal-selection"),black:i("terminal-black"),brightBlack:i("muted-foreground"),red:i("destructive"),brightRed:i("destructive"),green:i("success"),brightGreen:i("success"),yellow:i("warning"),brightYellow:i("warning"),blue:i("info"),brightBlue:i("info"),magenta:i("terminal-magenta"),brightMagenta:i("terminal-magenta"),cyan:i("terminal-cyan"),brightCyan:i("terminal-cyan"),white:i("terminal-white"),brightWhite:i("terminal-white")}}function Bh({processId:e,autoFocus:t=!1,onRequestNew:i,onRequestClose:s,onAddContext:r}){const n=Gr(),o=Ce.useRef(null),h=Ce.useRef(null),l=Ce.useRef(null),a=Ce.useRef(null),d=Ce.useRef({onRequestNew:i,onRequestClose:s}),[c,u]=Ce.useState("");Ce.useEffect(()=>{d.current={onRequestNew:i,onRequestClose:s}},[s,i]);const f=Ce.useCallback(()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null;const v=l.current,w=h.current;if(!(!v||!w))try{v.fit(),n.resize(e,w.cols,w.rows)}catch{}})},[e,n]),_=Ce.useCallback((v,w)=>{const A=h.current;if(A){if(v==="output"){const M=w;M.data&&A.write(M.data)}else if(v==="exit"){const B=w.code??0;A.write(`\r
49
+ */var _h=class{constructor(e,t,i,s={}){this._terminal=e,this._regex=t,this._handler=i,this._options=s}provideLinks(e,t){let i=ph.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r)}},t))}};function fh(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch{return!1}}var ph=class $t{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,h]=$t._getWindowedLineStrings(t-1,s),l=o.join(""),a,d=[];for(;a=n.exec(l);){let c=a[0];if(!fh(c))continue;let[u,f]=$t._mapStrIdx(s,h,0,a.index),[_,p]=$t._mapStrIdx(s,u,f,c.length);if(u===-1||f===-1||_===-1||p===-1)continue;let v={start:{x:f+1,y:u+1},end:{x:p,y:_+1}};d.push({range:v,text:c,activate:r})}return d}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,h="",l=[];if(s=i.buffer.active.getLine(t)){let a=s.translateToString(!0);if(s.isWrapped&&a[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(h=s.translateToString(!0),o+=h.length,l.push(h),!(!s.isWrapped||h.indexOf(" ")!==-1)););l.reverse()}for(l.push(a),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(h=s.translateToString(!0),o+=h.length,l.push(h),h.indexOf(" ")===-1););}return[l,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),h=s;for(;r;){let l=n.getLine(i);if(!l)return[-1,-1];for(let a=h;a<l.length;++a){l.getCell(a,o);let d=o.getChars();if(o.getWidth()&&(r-=d.length||1,a===l.length-1&&d==="")){let c=n.getLine(i+1);c&&c.isWrapped&&(c.getCell(0,o),o.getWidth()===2&&(r+=1))}if(r<0)return[i,a]}i++,h=0}return[i,h]}},gh=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function vh(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var mh=class{constructor(e=vh,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,i=t.urlRegex||gh;this._linkProvider=this._terminal.registerLinkProvider(new _h(this._terminal,i,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};function ir(e){const t=getComputedStyle(e),i=s=>t.getPropertyValue(`--${s}`).trim();return{background:"#00000000",foreground:i("foreground"),cursor:i("foreground"),cursorAccent:i("canvas"),selectionBackground:i("terminal-selection"),black:i("terminal-black"),brightBlack:i("muted-foreground"),red:i("destructive"),brightRed:i("destructive"),green:i("success"),brightGreen:i("success"),yellow:i("warning"),brightYellow:i("warning"),blue:i("info"),brightBlue:i("info"),magenta:i("terminal-magenta"),brightMagenta:i("terminal-magenta"),cyan:i("terminal-cyan"),brightCyan:i("terminal-cyan"),white:i("terminal-white"),brightWhite:i("terminal-white")}}function Eh({processId:e,autoFocus:t=!1,onRequestNew:i,onRequestClose:s,onAddContext:r}){const n=Gr(),o=Ce.useRef(null),h=Ce.useRef(null),l=Ce.useRef(null),a=Ce.useRef(null),d=Ce.useRef({onRequestNew:i,onRequestClose:s}),[c,u]=Ce.useState("");Ce.useEffect(()=>{d.current={onRequestNew:i,onRequestClose:s}},[s,i]);const f=Ce.useCallback(()=>{a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null;const v=l.current,w=h.current;if(!(!v||!w))try{v.fit(),n.resize(e,w.cols,w.rows)}catch{}})},[e,n]),_=Ce.useCallback((v,w)=>{const A=h.current;if(A){if(v==="output"){const M=w;M.data&&A.write(M.data)}else if(v==="exit"){const B=w.code??0;A.write(`\r
50
50
  \x1B[2m[Process exited with code ${B}]\x1B[0m\r
51
- `)}}},[]);Ce.useEffect(()=>{const v=o.current;if(!v)return;const w=new lh({theme:ir(v),fontFamily:'"JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, monospace',fontSize:12,lineHeight:1.4,cursorBlink:!0,cursorStyle:"block",scrollback:5e3,allowTransparency:!0}),A=new uh,M=new mh;w.loadAddon(A),w.loadAddon(M),w.open(v);const B=new MutationObserver(()=>{w.options.theme=ir(v)});B.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style"]}),w.attachCustomKeyEventHandler(Q=>{var fe,Ve,H,x;return as("newIntegratedTerminal",Q)?(Q.type==="keydown"&&((Ve=(fe=d.current).onRequestNew)==null||Ve.call(fe)),!1):as("closeIntegratedTerminal",Q)?(Q.type==="keydown"&&((x=(H=d.current).onRequestClose)==null||x.call(H)),!1):!0}),h.current=w,l.current=A;try{A.fit(),n.resize(e,w.cols,w.rows)}catch{}n.subscribe(e,_),n.send({type:"attach",id:e}),t&&requestAnimationFrame(()=>w.focus());const T=w.onData(Q=>{n.writeInput(e,Q)}),O=w.onSelectionChange(()=>{u(w.getSelection())}),Y=new ResizeObserver(f);return Y.observe(v),()=>{a.current!==null&&cancelAnimationFrame(a.current),Y.disconnect(),B.disconnect(),T.dispose(),O.dispose(),n.unsubscribe(e),w.dispose(),h.current=null,l.current=null,a.current=null}},[e]);const p=Ce.useCallback(()=>{var v;(v=h.current)==null||v.focus()},[]);return Rt.jsxs("div",{className:"relative size-full bg-background",children:[Rt.jsx("div",{ref:o,className:"size-full p-1",role:"region","aria-label":"Terminal output",tabIndex:0,onClick:p,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&p()}}),c&&r&&Rt.jsxs(Jr,{variant:"secondary",size:"sm",className:"absolute right-3 top-3",onClick:()=>{var v;r(c),(v=h.current)==null||v.clearSelection(),u("")},children:[Rt.jsx(Zr,{"data-icon":"inline-start"}),"Add to prompt"]})]})}export{Bh as TerminalOutput};
51
+ `)}}},[]);Ce.useEffect(()=>{const v=o.current;if(!v)return;const w=new lh({theme:ir(v),fontFamily:'"JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, monospace',fontSize:12,lineHeight:1.4,cursorBlink:!0,cursorStyle:"block",scrollback:5e3,allowTransparency:!0}),A=new uh,M=new mh;w.loadAddon(A),w.loadAddon(M),w.open(v);const B=new MutationObserver(()=>{w.options.theme=ir(v)});B.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style"]}),w.attachCustomKeyEventHandler(Q=>{var fe,Ve,H,x;return as("newIntegratedTerminal",Q)?(Q.type==="keydown"&&((Ve=(fe=d.current).onRequestNew)==null||Ve.call(fe)),!1):as("closeIntegratedTerminal",Q)?(Q.type==="keydown"&&((x=(H=d.current).onRequestClose)==null||x.call(H)),!1):!0}),h.current=w,l.current=A;try{A.fit(),n.resize(e,w.cols,w.rows)}catch{}n.subscribe(e,_),n.send({type:"attach",id:e}),t&&requestAnimationFrame(()=>w.focus());const T=w.onData(Q=>{n.writeInput(e,Q)}),O=w.onSelectionChange(()=>{u(w.getSelection())}),Y=new ResizeObserver(f);return Y.observe(v),()=>{a.current!==null&&cancelAnimationFrame(a.current),Y.disconnect(),B.disconnect(),T.dispose(),O.dispose(),n.unsubscribe(e),w.dispose(),h.current=null,l.current=null,a.current=null}},[e]);const p=Ce.useCallback(()=>{var v;(v=h.current)==null||v.focus()},[]);return Rt.jsxs("div",{className:"relative size-full bg-background",children:[Rt.jsx("div",{ref:o,className:"size-full p-1",role:"region","aria-label":"Terminal output",tabIndex:0,onClick:p,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&p()}}),c&&r&&Rt.jsxs(Jr,{variant:"secondary",size:"sm",className:"absolute right-3 top-3",onClick:()=>{var v;r(c),(v=h.current)==null||v.clearSelection(),u("")},children:[Rt.jsx(Zr,{"data-icon":"inline-start"}),"Add to prompt"]})]})}export{Eh as TerminalOutput};