cogpit 3.3.2 → 3.3.5

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 (36) hide show
  1. package/dist/cli-runtime.js +1893 -710
  2. package/dist/instance-worker.js +383 -133
  3. package/dist/web/assets/{CogpitBlock-DslWkKoF.js → CogpitBlock-erlqla7o.js} +11 -11
  4. package/dist/web/assets/{CommandPaletteHost-DUZHK9Zh.js → CommandPaletteHost-CuOrr39_.js} +1 -1
  5. package/dist/web/assets/{ConfigBrowser-CWys9Rgj.js → ConfigBrowser-C2DsAcvc.js} +1 -1
  6. package/dist/web/assets/CrewPanel-DICdtFaE.js +1 -0
  7. package/dist/web/assets/{HighlightedEditor-BF3a6ok2.js → HighlightedEditor-CP5_qp0D.js} +1 -1
  8. package/dist/web/assets/{KeyboardShortcutsDialog-DHxjcyzu.js → KeyboardShortcutsDialog-DB1DgAfw.js} +1 -1
  9. package/dist/web/assets/MissionHome-D8vtj_X6.js +2 -0
  10. package/dist/web/assets/{MobileFileChanges-B0k6kNod.js → MobileFileChanges-B5ADNE1K.js} +1 -1
  11. package/dist/web/assets/{PluginsDialog-CuaR5Cs1.js → PluginsDialog-B_69f-f3.js} +1 -1
  12. package/dist/web/assets/{PreviewPanel-CV3itR4d.js → PreviewPanel-Dg9ZZMgz.js} +1 -1
  13. package/dist/web/assets/{ProjectFilesPanel-B7DRMwMm.js → ProjectFilesPanel-DkSythhf.js} +3 -3
  14. package/dist/web/assets/{ProjectSwitcherModal-DhWTU3Op.js → ProjectSwitcherModal-ztUOYaYv.js} +1 -1
  15. package/dist/web/assets/{TerminalOutput-CsysWxZc.js → TerminalOutput-LYCC1x6i.js} +1 -1
  16. package/dist/web/assets/{ThemeSelectorModal-DbCAl7RY.js → ThemeSelectorModal-C3Mbqa4u.js} +1 -1
  17. package/dist/web/assets/{WorkflowsPanel-BkDClgyj.js → WorkflowsPanel-BOmbzwo_.js} +1 -1
  18. package/dist/web/assets/WorktreePanel-CdYUr34j.js +1 -0
  19. package/dist/web/assets/{edition-ui-xOZzffb-.js → edition-ui-acJKBfUS.js} +1 -1
  20. package/dist/web/assets/index-CNaiQBmD.js +1 -0
  21. package/dist/web/assets/index-D1VvcJwM.css +1 -0
  22. package/dist/web/assets/index-DeMgVaXr.js +493 -0
  23. package/dist/web/assets/{index-CFF4usU2.js → index-DxwM8M7d.js} +4 -4
  24. package/dist/web/assets/{index-y28pnuxv.js → index-RkopwWeC.js} +1 -1
  25. package/dist/web/assets/session-parser.worker-BZQCzzKl.js +30 -0
  26. package/dist/web/assets/switch-BqBbmo4j.js +1 -0
  27. package/dist/web/assets/{vendor-ui-Dxtv9P3W.js → vendor-ui-Cj1G8Clp.js} +204 -184
  28. package/dist/web/index.html +3 -3
  29. package/package.json +1 -1
  30. package/dist/web/assets/CrewPanel-CWubmgOn.js +0 -1
  31. package/dist/web/assets/MissionHome-Ckt9lu1H.js +0 -1
  32. package/dist/web/assets/WorktreePanel-DyQpVHNe.js +0 -1
  33. package/dist/web/assets/index-D2Gn2VwC.js +0 -1
  34. package/dist/web/assets/index-D6mWk1bF.css +0 -1
  35. package/dist/web/assets/index-DUfVcKxj.js +0 -483
  36. package/dist/web/assets/session-parser.worker-D3SBmcaP.js +0 -30
@@ -0,0 +1 @@
1
+ import{r as S,c as re,j as n}from"./vendor-react-gGw_S5I_.js";import{U as ze,bH as it,bI as be,bJ as jt,bK as yt,bL as Nt,B as J,L as rt,M as ct,N as It,O as dt,Q as ut,C as Ze,bM as kt,b6 as Je,z as Qe,bN as Ct,bO as St,q as ft,aK as Mt,bP as $t,b7 as Rt,bA as At,bQ as Tt,aP as Ot,R as Et,D as Lt,h as _t,j as zt,k as Dt,J as se,bR as Ft,bS as Pt,bT as Yt,bU as qt,bV as Ye,$ as qe,bW as Wt,bx as Ht,bX as Ut,bY as Bt,bZ as Te,b_ as Oe,bi as Kt,Z as Gt,b$ as Vt,c0 as Xt,c1 as Zt,bF as Jt}from"./index-DeMgVaXr.js";import{S as Qt}from"./switch-BqBbmo4j.js";import{m as es,aq as ts,ak as ss,e as ns,ar as ht,as as pt,P as os,a7 as as,$ as ls,C as et,at as is,au as rs,X as cs}from"./vendor-ui-Cj1G8Clp.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function Ce(s){if(s.ok)return s;const e=await s.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Ee(s,e){return[...new Map([...s,...e].map(t=>[t.sequence,t])).values()].sort((t,i)=>t.sequence-i.sequence)}function ds(s){const[e,t]=S.useState(null),[i,a]=S.useState([]),[l,c]=S.useState(null),[o,u]=S.useState(!1),[r,d]=S.useState(!1),[m,w]=S.useState(!1),[g,x]=S.useState(new Set),p=S.useRef(0),h=S.useRef(null),v=S.useRef(!1),N=S.useRef(!1),b=S.useRef(new Set),k=S.useRef(!1),C=S.useRef(null),M=S.useCallback(async j=>{const R=++p.current;try{const I=C.current,E=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!j()||R!==p.current)return;t(T=>T&&JSON.stringify(T.members)===JSON.stringify(E.members)?{...E,members:T.members}:E),a(T=>Ee(T,E.messages)),C.current=E.nextCursor,k.current||(k.current=!0,w(E.hasMore)),c(null)}catch(I){j()&&R===p.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[s]);it(M,2e3);const _=S.useCallback(async j=>{var R;if(v.current)return!1;v.current=!0,u(!0),((R=h.current)==null?void 0:R.text)!==j&&(h.current={text:j,id:crypto.randomUUID()});try{const $=await(await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{text:j,commandId:h.current.id}))).json();return p.current++,a(E=>Ee(E,[$.message])),h.current=null,c($.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{v.current=!1,u(!1)}},[s]),O=S.useCallback(async(j,R)=>{if(!b.current.has(j)){b.current.add(j),x(I=>new Set(I).add(j));try{await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{sessionId:j,listening:R},{method:"PATCH"})),p.current++,t(I=>I&&{...I,members:I.members.map($=>$.sessionId===j?{...$,listening:R}:$)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(j),x(I=>{const $=new Set(I);return $.delete(j),$})}}},[s]),L=S.useCallback(async()=>{if(!(!i.length||N.current)){N.current=!0,d(!0);try{const R=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}?before=${i[0].sequence}`))).json();a(I=>Ee(I,R.messages)),w(R.hasMore)}catch(j){c(j instanceof Error?j.message:"Couldn't load older messages.")}finally{N.current=!1,d(!1)}}},[i,s]);return{page:e,messages:i,error:l,posting:o,busyMembers:g,hasOlder:m,loadingOlder:r,post:_,setListening:O,older:L}}const us=[],fs=new Map;function hs(s){var We,He,Ue,Be,Ke,Ge,Ve;const e=re.c(111),{rootId:t,kinds:i,active:a}=s,l=i===void 0?fs:i,c=a===void 0?!0:a,o=ds(t),[u,r]=S.useState(""),d=S.useRef(null),m=S.useRef(!0);let w;e[0]!==o.messages?(w=(We=o.messages.at(-1))==null?void 0:We.sequence,e[0]=o.messages,e[1]=w):w=e[1];const g=w,x=((He=o.page)==null?void 0:He.members)??us;let p;e[2]!==x?(p=jt(x),e[2]=x,e[3]=p):p=e[3];const h=p;let v;e[4]!==x||e[5]!==t?(v=yt(x,t),e[4]=x,e[5]=t,e[6]=v):v=e[6];const N=v;let b;e[7]!==x?(b=new Map(x.map(ms)),e[7]=x,e[8]=b):b=e[8];const k=b;let C;e[9]!==o.messages||e[10]!==t?(C=Nt(o.messages,t),e[9]=o.messages,e[10]=t,e[11]=C):C=e[11];const M=C;let _;e[12]!==c?(_=()=>{var q,P;c&&m.current&&((P=(q=d.current)==null?void 0:q.scrollIntoView)==null||P.call(q,{block:"end"}))},e[12]=c,e[13]=_):_=e[13];let O;e[14]!==c||e[15]!==g?(O=[c,g],e[14]=c,e[15]=g,e[16]=O):O=e[16],S.useEffect(_,O);let L;e[17]!==o||e[18]!==u?(L=async()=>{const q=u.trim();!q||o.posting||await o.post(q)&&(r(P=>P.trim()===q?"":P),m.current=!0)},e[17]=o,e[18]=u,e[19]=L):L=e[19];const j=L;let R;e[20]!==o.page||e[21]!==x?(R=o.page?`${x.filter(ps).length} listening · Members & mentions`:"Loading chat…",e[20]=o.page,e[21]=x,e[22]=R):R=e[22];let I;e[23]!==R?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:R}),e[23]=R,e[24]=I):I=e[24];let $;if(e[25]!==o||e[26]!==l||e[27]!==x||e[28]!==t||e[29]!==N){let q;e[31]!==o||e[32]!==l||e[33]!==t||e[34]!==N?(q=P=>{var Xe;return n.jsxs(Ze,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(kt,{role:P.sessionId===t?"lead":"agent",sessionId:P.sessionId,kinds:l,tints:N,className:"size-5"}),n.jsxs(Je,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${P.sessionId}`,"aria-label":`Listen for ${P.name}`,children:[n.jsx("span",{className:"truncate",children:P.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",P.handle]})]}),n.jsx(J,{variant:"ghost",size:"icon-xs",disabled:!((Xe=o.page)!=null&&Xe.canPost)||!P.canInteract,onClick:()=>r(je=>`${je}${je&&!/\s$/.test(je)?" ":""}@${P.handle} `),"aria-label":`Mention ${P.name}`,title:`Mention @${P.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${P.sessionId}`,size:"sm",checked:P.listening,disabled:!P.canInteract||o.busyMembers.has(P.sessionId),onCheckedChange:je=>void o.setListening(P.sessionId,je)})]},P.sessionId)},e[31]=o,e[32]=l,e[33]=t,e[34]=N,e[35]=q):q=e[35],$=x.map(q),e[25]=o,e[26]=l,e[27]=x,e[28]=t,e[29]=N,e[30]=$}else $=e[30];let E;e[36]!==$?(E=n.jsx(Qe,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:$}),e[36]=$,e[37]=E):E=e[37];let T;e[38]===Symbol.for("react.memo_cache_sentinel")?(T=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]=T):T=e[38];let z;e[39]!==I||e[40]!==E?(z=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,E,T]}),e[39]=I,e[40]=E,e[41]=z):z=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=q=>{const P=q.target;m.current=P.scrollHeight-P.scrollTop-P.clientHeight<80},e[42]=D):D=e[42];let W;e[43]!==o?(W=o.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(J,{variant:"ghost",size:"xs",disabled:o.loadingOlder,onClick:()=>void o.older(),children:o.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=o,e[44]=W):W=e[44];let F;e[45]!==o.messages.length||e[46]!==o.page?(F=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]=F):F=e[47];let Y;if(e[48]!==k||e[49]!==h||e[50]!==l||e[51]!==t||e[52]!==M||e[53]!==N){let q;e[55]!==k||e[56]!==h||e[57]!==l||e[58]!==t||e[59]!==N?(q=P=>n.jsxs(S.Fragment,{children:[P.day!==void 0&&n.jsx(Ct,{day:P.day}),n.jsx(St,{run:P,members:k,handles:h,kinds:l,tints:N,rootId:t})]},P.messages[0].sequence),e[55]=k,e[56]=h,e[57]=l,e[58]=t,e[59]=N,e[60]=q):q=e[60],Y=M.map(q),e[48]=k,e[49]=h,e[50]=l,e[51]=t,e[52]=M,e[53]=N,e[54]=Y}else Y=e[54];let K;e[61]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("div",{ref:d}),e[61]=K):K=e[61];let B;e[62]!==Y?(B=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,K]}),e[62]=Y,e[63]=B):B=e[63];let X;e[64]!==W||e[65]!==F||e[66]!==B?(X=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:D,children:[W,F,B]}),e[64]=W,e[65]=F,e[66]=B,e[67]=X):X=e[67];let H;e[68]!==j?(H=q=>{q.preventDefault(),j()},e[68]=j,e[69]=H):H=e[69];const U=!!o.error,G=`crew-chat-${t}`;let f;e[70]!==G?(f=n.jsx(Je,{htmlFor:G,className:"sr-only",children:"Message the crew"}),e[70]=G,e[71]=f):f=e[71];const y=`crew-chat-${t}`,A=!((Ue=o.page)!=null&&Ue.canPost),V=!!o.error;let ee;e[72]===Symbol.for("react.memo_cache_sentinel")?(ee=q=>r(q.target.value),e[72]=ee):ee=e[72];let Z;e[73]!==j?(Z=q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&!q.nativeEvent.isComposing&&(q.preventDefault(),j())},e[73]=j,e[74]=Z):Z=e[74];let te;e[75]!==u||e[76]!==y||e[77]!==A||e[78]!==V||e[79]!==Z?(te=n.jsx(Mt,{id:y,value:u,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:A,"aria-invalid":V,onChange:ee,onKeyDown:Z}),e[75]=u,e[76]=y,e[77]=A,e[78]=V,e[79]=Z,e[80]=te):te=e[80];let ae;e[81]!==o.error?(ae=o.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o.error}),e[81]=o.error,e[82]=ae):ae=e[82];let ce;e[83]!==U||e[84]!==f||e[85]!==te||e[86]!==ae?(ce=n.jsxs(Ze,{"data-invalid":U,children:[f,te,ae]}),e[83]=U,e[84]=f,e[85]=te,e[86]=ae,e[87]=ce):ce=e[87];const ve=((Be=o.page)==null?void 0:Be.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let le;e[88]!==ve?(le=n.jsx(Rt,{className:"flex-1",children:ve}),e[88]=ve,e[89]=le):le=e[89];let de;e[90]!==((Ke=o.page)==null?void 0:Ke.canPost)||e[91]!==o.posting||e[92]!==u?(de=!((Ge=o.page)!=null&&Ge.canPost)||!u.trim()||o.posting,e[90]=(Ve=o.page)==null?void 0:Ve.canPost,e[91]=o.posting,e[92]=u,e[93]=de):de=e[93];let Ie;e[94]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=Ie):Ie=e[94];const Ae=o.posting?"Sending…":"Send";let pe;e[95]!==de||e[96]!==Ae?(pe=n.jsxs(J,{type:"submit",size:"sm",disabled:de,children:[Ie,Ae]}),e[95]=de,e[96]=Ae,e[97]=pe):pe=e[97];let me;e[98]!==le||e[99]!==pe?(me=n.jsxs("div",{className:"flex items-center gap-2",children:[le,pe]}),e[98]=le,e[99]=pe,e[100]=me):me=e[100];let ge;e[101]!==ce||e[102]!==me?(ge=n.jsxs(Qe,{className:"gap-2",children:[ce,me]}),e[101]=ce,e[102]=me,e[103]=ge):ge=e[103];let xe;e[104]!==H||e[105]!==ge?(xe=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:H,children:ge}),e[104]=H,e[105]=ge,e[106]=xe):xe=e[106];let ke;return e[107]!==z||e[108]!==X||e[109]!==xe?(ke=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[z,X,xe]}),e[107]=z,e[108]=X,e[109]=xe,e[110]=ke):ke=e[110],ke}function ps(s){return s.listening}function ms(s){return[s.sessionId,s]}const ue={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(s){const e=new Date(s),t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?t:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${t}`}function fe(s){if(s.status==="deferred")return"needs-you";switch(s.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(s,e){var t,i;return{sessionId:s.sessionId,dirName:((t=s.address)==null?void 0:t.dirName)??"",fileName:((i=s.address)==null?void 0:i.fileName)??"",projectShortName:"",lastModified:s.lastActivityAt??"",lastActivityAt:s.lastActivityAt,size:0,cwd:s.cwd,customTitle:s.customTitle,aiTitle:s.aiTitle,firstUserMessage:s.firstUserMessage,...s.parentId&&{crew:{rootId:e,parentId:s.parentId,startedAt:s.startedAt??0,...s.name&&{name:s.name}}}}}function gs(s,e,t){var o;const i=((o=[...e.values()].find(u=>u.parentId===null))==null?void 0:o.sessionId)??s.sessionId,a=t[s.sessionId],l=tt(s,i);if(!s.parentId)return At(l,a);const c=e.get(s.parentId);return Tt(l,{customName:a,parent:c&&tt(c,i)})}function xs(s){const e=new Map;for(const l of s.members){if(!l.parentId)continue;const c=e.get(l.parentId);c?c.push(l):e.set(l.parentId,[l])}const t=[],i=new Set,a=(l,c)=>{var u;const o=[...e.get(l)??[]].sort((r,d)=>(r.startedAt??0)-(d.startedAt??0));for(const r of o)i.has(r.sessionId)||(i.add(r.sessionId),t.push({member:r,depth:c,children:((u=e.get(r.sessionId))==null?void 0:u.length)??0}),a(r.sessionId,c+1))};a(s.rootId,0);for(const l of s.members)l.parentId&&!i.has(l.sessionId)&&(i.add(l.sessionId),t.push({member:l,depth:0,children:0}));return t}function ws(s){const e=({member:t,pending:i})=>i.askedAt??(Date.parse(t.lastActivityAt??"")||0);return s.members.flatMap(t=>t.waiting.map(i=>({member:t,pending:i}))).sort((t,i)=>e(t)-e(i))}function bs(s){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const t of s.members){if(!t.parentId)continue;e.size++;const i=fe(t);i==="working"?e.working++:i==="needs-you"?e.needsYou++:i==="failed"?e.failed++:i==="unreachable"?e.unreachable++:e.done++,Re(t)&&e.unreadResults++}return e}function Re(s){return!!(s.result&&s.result.state!=="running"&&!s.result.acknowledged)}function Ne(s){const[e]=s.waiting;switch(fe(s)){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&&s.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return s.status==="tool_use"&&s.toolName?s.toolName:s.status==="thinking"?"Thinking":s.status==="compacting"?"Compacting":s.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return s.error?`Failed · ${s.error}`:"Failed";case"unreachable":return s.device?`${s.device.name} is not answering`:"Not found";default:return Re(s)?"Finished · result unread":"Finished"}}const ne=196,Q=86,ie=40,we=12,vs=28,Me=6,st=8,he=10,js=6,$e=28,De=36;function gt(s){const e=fe(s);return e==="working"||e==="needs-you"}function ys(s){const e={all:s.members.length,active:0,working:0,needsYou:0};for(const t of s.members){const i=fe(t);i==="working"?e.working++:i==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(s,e)=>(s.startedAt??0)-(e.startedAt??0)||s.sessionId.localeCompare(e.sessionId);function xt(s){const e=new Map(s.members.map(a=>[a.sessionId,a])),t=new Map,i=[];for(const a of s.members){const l=a.parentId&&a.sessionId!==s.rootId?e.get(a.parentId):void 0;if(!l){i.push(a);continue}const c=t.get(l.sessionId);c?c.push(a):t.set(l.sessionId,[a])}for(const a of t.values())a.sort(nt);return i.sort((a,l)=>+(l.sessionId===s.rootId)-+(a.sessionId===s.rootId)||nt(a,l)),{roots:i,childrenOf:t}}function Ns(s,e){if(e==="all")return new Set(s.members.map(a=>a.sessionId));const t=new Map(s.members.map(a=>[a.sessionId,a])),i=new Set;for(const a of s.members){if(!gt(a))continue;let l=a;for(;l&&!i.has(l.sessionId);)i.add(l.sessionId),l=l.sessionId===s.rootId||!l.parentId?void 0:t.get(l.parentId)}return i}function Is(s){const{roots:e,childrenOf:t}=xt(s),i=new Set;let a=0;const l=e.map(c=>({member:c,depth:0}));for(;l.length>0;){const{member:c,depth:o}=l.pop();if(!i.has(c.sessionId)){i.add(c.sessionId),a=Math.max(a,o);for(const u of t.get(c.sessionId)??[])l.push({member:u,depth:o+1})}}return a}function ks(s){return(s+1)*ne+s*ie}function Cs(s,e,t,{group:i=!1,stacked:a}={}){const{roots:l,childrenOf:c}=xt(s),o=Ns(s,e),u=C=>(c.get(C)??[]).filter(M=>o.has(M.sessionId)),r=(a==null?void 0:a.cardWidth)??ne,d=[],m=[],w=[],g=new Set;let x=0,p=0;const h=C=>{const M={count:0,working:0,needsYou:0},_=new Set(g),O=[...u(C)];for(;O.length>0;){const L=O.pop();if(_.has(L.sessionId))continue;_.add(L.sessionId),M.count++;const j=fe(L);j==="working"?M.working++:j==="needs-you"&&M.needsYou++,O.push(...u(L.sessionId))}return M},v=C=>u(C).filter(M=>!g.has(M.sessionId)),N=C=>v(C.sessionId).length===0||t.has(C.sessionId),b=(C,M,_)=>{g.add(C.sessionId);const O=v(C.sessionId),L=O.length>0&&t.has(C.sessionId),j=L?[]:O,R=i&&!a&&j.length>=st?j.filter(N):[],I=R.length>=st?R:[],$=new Set(I),E=j.filter(D=>!$.has(D)),T={member:C,depth:M,x:(_==null?void 0:_.x)??M*(a?$e:ne+ie),y:(_==null?void 0:_.y)??x+(E.length===0&&I.length>0?he:0),childCount:O.length,collapsed:L,hidden:L?h(C.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!gt(C),grouped:!!_};if(d.push(T),p=Math.max(p,T.x+r+(a&&O.length>0?De:0)),a){x+=Q+we;const D=j.map(W=>b(W,M+1));return D.length>0&&m.push({parentId:C.sessionId,path:Ms(T.x,T.y,D)}),T.y}if(L){const D=T.y+Q/2;m.push({parentId:C.sessionId,path:`M${T.x+ne} ${D}H${T.x+ne+ie/2}`})}if(_)return T.y;if(j.length===0)return x+=Q+we,T.y;const z=E.map(D=>b(D,M+1));return I.length>0&&z.push(k(C.sessionId,I,M+1)+he),m.push({parentId:C.sessionId,path:Ss(T.x+ne,T.y,z)}),T.y},k=(C,M,_)=>{const O=Math.min(js,Math.max(2,Math.ceil(Math.sqrt(M.length/1.5)))),L=Math.ceil(M.length/O),j={parentId:C,x:_*(ne+ie),y:x,width:O*ne+(O-1)*ie+2*he,height:L*Q+(L-1)*we+2*he};return w.push(j),M.forEach((R,I)=>b(R,_,{x:j.x+he+I%O*(ne+ie),y:j.y+he+Math.floor(I/O)*(Q+we)})),p=Math.max(p,j.x+j.width),x+=j.height+we,j.y};for(const C of l)!o.has(C.sessionId)||g.has(C.sessionId)||(d.length>0&&(x+=vs),b(C,0));return{orientation:a?"stacked":"across",cardWidth:r,nodes:d,edges:m,groups:w,width:p,height:Math.max(0,x-we)}}function Ss(s,e,t){const i=e+Q/2,a=[`M${s} ${i}H${s+ie}`];for(const l of t)l!==e&&a.push(wt(s,i,l+Q/2));return a.join("")}function wt(s,e,t){const i=s+ie/2;return`M${i} ${e}V${t-Me}Q${i} ${t} ${i+Me} ${t}H${s+ie}`}function Ms(s,e,t){return t.map(i=>bt(s,e,i)).join("")}function bt(s,e,t){const i=s+$e/2,a=t+Q/2;return`M${i} ${e+Q}V${a-Me}Q${i} ${a} ${i+Me} ${a}H${s+$e}`}function $s(s,e){const t=new Map(s.nodes.map(c=>[c.member.sessionId,c])),i=new Map(s.groups.map(c=>[c.parentId,c]));let a=e?t.get(e):void 0;const l=[];for(;a!=null&&a.member.parentId;){const c=a.member.parentId,o=t.get(c);if(!o||o.depth!==a.depth-1)break;if(s.orientation==="stacked"){l.unshift(bt(o.x,o.y,a.y)),a=o;continue}const u=o.x+ne,r=o.y+Q/2,d=a.grouped?i.get(c):void 0,m=(d?d.y+he:a.y)+Q/2;l.unshift(m===r?`M${u} ${r}H${u+ie}`:`M${u} ${r}H${u+ie/2}${wt(u,r,m)}`),a=o}return l.length>0?l.join(""):null}const oe=14,Fe=.25,ot=1.5,Rs=.7,Se=1.2,As=56,Ts=900,Os=.85,Es=320,Le={all:new Set,active:new Set};function Ls(s){const[e,t]=Ot(Et("crew-map-filter"),"all"),i=e==="active"?"active":"all",[a,l]=S.useState({rootId:s,folds:Le}),c=S.useRef(new Map),o=a.rootId===s?a.folds:Le,u=S.useCallback(d=>l(m=>{const w=m.rootId===s?m.folds:Le,g=new Set(w[i]);return g.delete(d)||g.add(d),{rootId:s,folds:{...w,[i]:g}}}),[i,s]),r=S.useMemo(()=>({get current(){return c.current.get(s)??null},set current(d){c.current.set(s,d)}}),[s]);return{filter:i,setFilter:t,collapsed:o[i],toggle:u,viewport:r}}function _s(s){const e=re.c(86),{crew:t,hereId:i,controls:a,kinds:l,nameOf:c,onOpen:o}=s,[u,r]=S.useState(!1),{filter:d,collapsed:m,toggle:w}=a;let g,x,p,h,v,N,b,k,C,M,_,O,L,j,R,I;if(e[0]!==m||e[1]!==a||e[2]!==t||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==l||e[7]!==c||e[8]!==o||e[9]!==w){let B;e[26]!==t.rootId?(B=y=>y.sessionId===t.rootId,e[26]=t.rootId,e[27]=B):B=e[27];const X=t.members.find(B);let H;e[28]!==m||e[29]!==a||e[30]!==t||e[31]!==d||e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==w?(H=(y,A)=>n.jsx(Ps,{crew:t,collapsed:m,groups:!y,filter:d,hereId:i,kinds:l,nameOf:c,memory:y,onOpen:A,onToggle:w,onShowAll:()=>a.setFilter("all")}),e[28]=m,e[29]=a,e[30]=t,e[31]=d,e[32]=i,e[33]=l,e[34]=c,e[35]=w,e[36]=H):H=e[36],p=H,N="flex h-full min-h-0 flex-col";let U;e[37]!==a||e[38]!==t?(U=n.jsx(at,{crew:t,controls:a}),e[37]=a,e[38]=t,e[39]=U):U=e[39];let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("span",{className:"flex-1"}),e[40]=G):G=e[40];let f;e[41]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>r(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=f):f=e[41],e[42]!==U?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[U,G,f]}),e[42]=U,e[43]=b):b=e[43],e[44]!==p||e[45]!==a.viewport||e[46]!==o?(k=p(a.viewport,o),e[44]=p,e[45]=a.viewport,e[46]=o,e[47]=k):k=e[47],x=Lt,I=u,v=r,g=_t,O=!0,L="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"}),R=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=j,e[49]=R):(j=e[48],R=e[49]),M="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],h="min-w-0 truncate text-sm font-medium",C=X?c(X):"Crew",e[0]=m,e[1]=a,e[2]=t,e[3]=u,e[4]=d,e[5]=i,e[6]=l,e[7]=c,e[8]=o,e[9]=w,e[10]=g,e[11]=x,e[12]=p,e[13]=h,e[14]=v,e[15]=N,e[16]=b,e[17]=k,e[18]=C,e[19]=M,e[20]=_,e[21]=O,e[22]=L,e[23]=j,e[24]=R,e[25]=I}else g=e[10],x=e[11],p=e[12],h=e[13],v=e[14],N=e[15],b=e[16],k=e[17],C=e[18],M=e[19],_=e[20],O=e[21],L=e[22],j=e[23],R=e[24],I=e[25];let $;e[51]!==h||e[52]!==C?($=n.jsx("span",{className:h,children:C}),e[51]=h,e[52]=C,e[53]=$):$=e[53];let E;e[54]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("span",{className:"flex-1"}),e[54]=E):E=e[54];let T;e[55]!==a||e[56]!==t?(T=n.jsx(at,{crew:t,controls:a}),e[55]=a,e[56]=t,e[57]=T):T=e[57];let z;e[58]!==$||e[59]!==T||e[60]!==M||e[61]!==_?(z=n.jsxs("header",{className:M,children:[_,$,E,T]}),e[58]=$,e[59]=T,e[60]=M,e[61]=_,e[62]=z):z=e[62];let D;e[63]!==o?(D=B=>{r(!1),o(B)},e[63]=o,e[64]=D):D=e[64];let W;e[65]!==p||e[66]!==D?(W=p(null,D),e[65]=p,e[66]=D,e[67]=W):W=e[67];let F;e[68]!==g||e[69]!==z||e[70]!==W||e[71]!==O||e[72]!==L||e[73]!==j||e[74]!==R?(F=n.jsxs(g,{showCloseButton:O,className:L,children:[j,R,z,W]}),e[68]=g,e[69]=z,e[70]=W,e[71]=O,e[72]=L,e[73]=j,e[74]=R,e[75]=F):F=e[75];let Y;e[76]!==x||e[77]!==v||e[78]!==F||e[79]!==I?(Y=n.jsx(x,{open:I,onOpenChange:v,children:F}),e[76]=x,e[77]=v,e[78]=F,e[79]=I,e[80]=Y):Y=e[80];let K;return e[81]!==N||e[82]!==b||e[83]!==k||e[84]!==Y?(K=n.jsxs("div",{className:N,children:[b,k,Y]}),e[81]=N,e[82]=b,e[83]=k,e[84]=Y,e[85]=K):K=e[85],K}function at(s){const e=re.c(3),{crew:t,controls:i}=s;let a;if(e[0]!==i||e[1]!==t){const l=ys(t),c=[{id:"all",label:"All",count:l.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:l.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];a=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:u,label:r,count:d,hint:m}=o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":i.filter===u,"aria-label":`${r}, ${vt(d)}`,title:m,onClick:()=>i.setFilter(u),className:se("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",i.filter===u&&"bg-accent text-foreground"),children:[r,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:d})]},u)})}),e[0]=i,e[1]=t,e[2]=a}else a=e[2];return a}function vt(s){return`${s} ${s===1?"session":"sessions"}`}function _e(s,e,t){return s.orientation==="stacked"?{scale:e,left:oe,top:oe}:{scale:e,left:Math.max(oe,(t.width-s.width*e)/2),top:Math.max(oe,Math.min((t.height-s.height*e)/2,t.height*.12))}}function zs(s,e,t){return{width:Math.max(t.width,e.left+s.width*e.scale+oe),height:Math.max(t.height,e.top+s.height*e.scale+As)}}function lt(s,e,{widthOnly:t=!1}={}){if(s.width===0||e.width===0)return 1;const i=(e.width-2*oe)/s.width,a=t?i:Math.min(i,(e.height-2*oe)/s.height);return Pe(a,Fe,1)}const Pe=(s,e,t)=>Math.min(t,Math.max(e,s));function Ds(s,e,t,i,a){var w;const l=new Map(e.layout.nodes.map(g=>[g.member.sessionId,g])),c=new Map(t.nodes.map(g=>[g.member.sessionId,g]));if(e.frame===i&&l.size===c.size&&t.nodes.every(g=>{const x=l.get(g.member.sessionId);return x!==void 0&&x.x===g.x&&x.y===g.y}))return null;const u=g=>({x:e.frame.left+g.x*e.frame.scale-s.left,y:e.frame.top+g.y*e.frame.scale-s.top}),r=a&&l.has(a)&&c.has(a)?a:(w=e.layout.nodes.filter(g=>c.has(g.member.sessionId)).map(g=>({node:g,screen:u(g)})).filter(({screen:g})=>g.y+Q*e.frame.scale>0&&g.x+e.layout.cardWidth*e.frame.scale>0).sort((g,x)=>g.screen.y-x.screen.y||g.screen.x-x.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!r)return null;const d=u(l.get(r)),m=c.get(r);return{left:i.left+m.x*i.scale-d.x,top:i.top+m.y*i.scale-d.y}}function Fs(s,e,t,i){const a=new Map(s.nodes.map(x=>[x.member.sessionId,x])),l=e?a.get(e):void 0;if(!l)return{left:0,top:0};const{scale:c}=t,o=t.left+l.x*c,u=t.top+l.y*c,r=o+s.cardWidth*c,d=u+Q*c;if(r<=i.clientWidth&&d<=i.clientHeight)return{left:0,top:0};const m=l.member.parentId&&a.get(l.member.parentId)||l;let w=t.left+Math.min(m.x,l.x)*c-oe,g=t.top+Math.min(m.y,l.y)*c-oe;return r-w>i.clientWidth&&(w=o-oe),d-g>i.clientHeight&&(g=u-i.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,g)}}function Ps({crew:s,collapsed:e,groups:t,filter:i,hereId:a,kinds:l,nameOf:c,memory:o,onOpen:u,onToggle:r,onShowAll:d}){const m=S.useRef(null),[w,g]=S.useState({width:0,height:0}),x=t&&w.width>=Ts,p=S.useMemo(()=>Is(s),[s]),h=w.width-2*oe,v=!t&&w.width>0&&ks(p)*Os>h,N=v?Pe(h-p*$e-De,ne,Es):ne,b=S.useMemo(()=>Cs(s,i,e,{group:x,...v&&{stacked:{cardWidth:N}}}),[s,i,e,x,v,N]),[k,C]=S.useState(()=>{var f;return((f=o==null?void 0:o.current)==null?void 0:f.frame)??{scale:1,left:oe,top:oe}}),[M,_]=S.useState(!1),O=S.useRef(null),L=S.useRef(null),j=S.useRef({left:0,top:0}),R=S.useRef(null),I=S.useRef(null),$=zs(b,k,w),{scale:E}=k;S.useLayoutEffect(()=>{const f=m.current;if(!f)return;const y=()=>g(V=>V.width===f.clientWidth&&V.height===f.clientHeight?V:{width:f.clientWidth,height:f.clientHeight});y();const A=new ResizeObserver(y);return A.observe(f),()=>A.disconnect()},[]);const T=S.useCallback(f=>{const y=m.current;o&&y&&(o.current={frame:f,left:y.scrollLeft,top:y.scrollTop})},[o]),z=S.useCallback((f,y)=>{O.current={frame:f,scroll:y},C(f)},[]),D=S.useCallback(f=>{const y=_e(f,Math.max(lt(f,w,{widthOnly:!0}),Rs),w);z(y,()=>{const A=m.current;return A?Fs(f,a,y,A):{left:0,top:0}})},[z,a,w]);S.useLayoutEffect(()=>{const f=m.current;if(w.width===0||!f)return;const y=R.current;if(y){if(y.filter!==i||y.layout.orientation!==b.orientation)D(b);else if(y.layout!==b){const A=Ds(j.current,y,b,k,L.current);A&&(f.scrollLeft=A.left,f.scrollTop=A.top,j.current={left:f.scrollLeft,top:f.scrollTop})}}else{const A=o==null?void 0:o.current;A?z(A.frame,()=>({left:A.left,top:A.top})):D(b)}L.current=null,R.current={layout:b,filter:i,frame:k}}),S.useLayoutEffect(()=>{const f=O.current,y=m.current;if(!f||!y||f.frame!==k)return;O.current=null;const{left:A,top:V}=f.scroll();y.scrollLeft=A,y.scrollTop=V,j.current={left:y.scrollLeft,top:y.scrollTop},T(k)});const W=S.useRef(a);S.useEffect(()=>{var f,y;W.current!==a&&(W.current=a,a&&((y=(f=m.current)==null?void 0:f.querySelector(`[data-crew-map-card="${CSS.escape(a)}"]`))==null||y.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[a]);const F=S.useCallback((f,y)=>{var de;const A=m.current,V=((de=O.current)==null?void 0:de.frame.scale)??E,ee=Pe(V*f,Fe,ot);if(!A||ee===V)return;const Z=A.getBoundingClientRect(),te=y?y.clientX-Z.left:A.clientWidth/2,ae=y?y.clientY-Z.top:A.clientHeight/2,ce=(A.scrollLeft+te-k.left)/E,ve=(A.scrollTop+ae-k.top)/E,le=_e(b,ee,w);z(le,()=>({left:le.left+ce*le.scale-te,top:le.top+ve*le.scale-ae}))},[z,k.left,k.top,b,E,w]),Y=S.useRef(F);S.useLayoutEffect(()=>{Y.current=F}),S.useEffect(()=>{const f=m.current;if(!f)return;const y=A=>{!A.ctrlKey&&!A.metaKey||(A.preventDefault(),Y.current(Math.exp(-A.deltaY*.01),A))};return f.addEventListener("wheel",y,{passive:!1}),()=>f.removeEventListener("wheel",y)},[]);const K=f=>{const y=m.current;!y||f.pointerType!=="mouse"||f.button!==0||f.target.closest("button")||(I.current={pointerId:f.pointerId,x:f.clientX,y:f.clientY,left:y.scrollLeft,top:y.scrollTop},y.setPointerCapture(f.pointerId),_(!0))},B=f=>{const y=I.current,A=m.current;!y||!A||y.pointerId!==f.pointerId||(A.scrollLeft=y.left-(f.clientX-y.x),A.scrollTop=y.top-(f.clientY-y.y))},X=f=>{var y,A;((y=I.current)==null?void 0:y.pointerId)===f.pointerId&&(I.current=null,(A=m.current)==null||A.releasePointerCapture(f.pointerId),_(!1))},H=S.useMemo(()=>$s(b,a),[b,a]),U=b.nodes.length===0,G=b.orientation==="stacked"?b.cardWidth+De/2:ne+ie/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:m,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:f=>{j.current={left:f.currentTarget.scrollLeft,top:f.currentTarget.scrollTop},O.current||T(k)},onPointerDown:K,onPointerMove:B,onPointerUp:X,onPointerCancel:X,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="+"||f.key==="="?F(Se):f.key==="-"&&F(1/Se))},tabIndex:-1,className:se("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]",M?"cursor-grabbing select-none":"cursor-grab"),children:U?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(J,{variant:"outline",size:"xs",onClick:d,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:$.width,height:$.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:k.left,top:k.top,width:b.width,height:b.height,transform:`scale(${E})`},children:[b.groups.map(f=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:f.x,top:f.y,width:f.width,height:f.height}},f.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(f=>n.jsx("path",{d:f.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},f.parentId)),H&&n.jsx("path",{d:H,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(f=>n.jsx(Hs,{node:f,width:b.cardWidth,toggleLeft:G,here:f.member.sessionId===a,kind:l.get(f.member.sessionId),name:c(f.member),onOpen:u,onToggle:y=>{L.current=y,r(y)}},f.member.sessionId))})]})})}),!U&&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(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:E<=Fe,onClick:()=>F(1/Se),children:n.jsx(pt,{"data-icon":"inline-start"})}),n.jsxs(J,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>F(1/E),children:[Math.round(E*100),"%"]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:E>=ot,onClick:()=>F(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(J,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>z(_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(s){var t,i;const e=(t=s.pullRequests)==null?void 0:t.at(-1);return[s.model&&Ye(s.model),(i=s.device)==null?void 0:i.name,e&&`#${e.number}`,s.lastActivityAt&&qe(s.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(s){const e=re.c(75),{node:t,width:i,toggleLeft:a,here:l,kind:c,name:o,onOpen:u,onToggle:r}=s,{member:d}=t;let m;e[0]!==d?(m=fe(d),e[0]=d,e[1]=m):m=e[1];const w=m;let g;e[2]!==d?(g=Ne(d),e[2]=d,e[3]=g):g=e[3];const x=g;let p;e[4]!==c?(p=c?Ft(c):as,e[4]=c,e[5]=p):p=e[5];const h=p;let v;e[6]!==d?(v=Ws(d),e[6]=d,e[7]=v):v=e[7];const N=v,b=t.context&&"shown because a session it started is active";let k;e[8]!==x||e[9]!==o||e[10]!==b?(k=[o,x,b].filter(Boolean),e[8]=x,e[9]=o,e[10]=b,e[11]=k):k=e[11];const C=k.join(", ");let M;e[12]!==t.x||e[13]!==t.y||e[14]!==i?(M={left:t.x,top:t.y,width:i,height:Q},e[12]=t.x,e[13]=t.y,e[14]=i,e[15]=M):M=e[15];const _=d.sessionId,O=l?"true":void 0;let L;e[16]!==d||e[17]!==u?(L=()=>u(d),e[16]=d,e[17]=u,e[18]=L):L=e[18];const j=Ys[w],R=l&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=t.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let $;e[19]!==j||e[20]!==R||e[21]!==I?($=se("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,R,I),e[19]=j,e[20]=R,e[21]=I,e[22]=$):$=e[22];let E;e[23]!==C||e[24]!==d.sessionId||e[25]!==w||e[26]!==L||e[27]!==$||e[28]!==O?(E=n.jsx("button",{type:"button","data-crew-map-card":_,"data-crew-map-state":w,"aria-current":O,"aria-label":C,onClick:L,className:$}),e[23]=C,e[24]=d.sessionId,e[25]=w,e[26]=L,e[27]=$,e[28]=O,e[29]=E):E=e[29];let T;e[30]!==h?(T=n.jsx(h,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=h,e[31]=T):T=e[31];let z;e[32]!==o?(z=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:o}),e[32]=o,e[33]=z):z=e[33];let D;e[34]!==T||e[35]!==z?(D=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[T,z]}),e[34]=T,e[35]=z,e[36]=D):D=e[36];const W=ue[w];let F;e[37]!==W?(F=se("size-1.5 shrink-0 rounded-full",W),e[37]=W,e[38]=F):F=e[38];let Y;e[39]!==F?(Y=n.jsx("span",{className:F,"aria-hidden":"true"}),e[39]=F,e[40]=Y):Y=e[40];let K;e[41]!==d||e[42]!==w?(K=Re(d)?"text-warning":qs[w],e[41]=d,e[42]=w,e[43]=K):K=e[43];let B;e[44]!==K?(B=se("min-w-0 truncate text-muted-foreground",K),e[44]=K,e[45]=B):B=e[45];let X;e[46]!==x||e[47]!==B?(X=n.jsx("span",{className:B,children:x}),e[46]=x,e[47]=B,e[48]=X):X=e[48];let H;e[49]!==Y||e[50]!==X?(H=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[Y,X]}),e[49]=Y,e[50]=X,e[51]=H):H=e[51];let U;e[52]!==l||e[53]!==N?(U=(N||l)&&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:N}),l&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=l,e[53]=N,e[54]=U):U=e[54];let G;e[55]!==E||e[56]!==D||e[57]!==H||e[58]!==U?(G=n.jsxs(Pt,{delay:700,render:E,children:[D,H,U]}),e[55]=E,e[56]=D,e[57]=H,e[58]=U,e[59]=G):G=e[59];let f;e[60]!==d||e[61]!==o?(f=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Bs,{member:d,name:o})}),e[60]=d,e[61]=o,e[62]=f):f=e[62];let y;e[63]!==G||e[64]!==f?(y=n.jsxs(qt,{children:[G,f]}),e[63]=G,e[64]=f,e[65]=y):y=e[65];let A;e[66]!==o||e[67]!==t||e[68]!==r||e[69]!==a?(A=t.childCount>0&&n.jsx(Us,{node:t,name:o,left:a,onToggle:r}),e[66]=o,e[67]=t,e[68]=r,e[69]=a,e[70]=A):A=e[70];let V;return e[71]!==y||e[72]!==A||e[73]!==M?(V=n.jsxs("li",{className:"group/node absolute",style:M,children:[y,A]}),e[71]=y,e[72]=A,e[73]=M,e[74]=V):V=e[74],V}function Us(s){const e=re.c(25),{node:t,name:i,left:a,onToggle:l}=s,{collapsed:c,hidden:o}=t;let u=null;o.needsYou>0?u="needs-you":o.working>0&&(u="working");let r;e[0]!==c||e[1]!==o.count||e[2]!==o.needsYou||e[3]!==o.working||e[4]!==i?(r=c?[`Show the ${vt(o.count)} under ${i}`,o.needsYou>0&&`${o.needsYou} waiting on you`,o.working>0&&`${o.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${i}`,e[0]=c,e[1]=o.count,e[2]=o.needsYou,e[3]=o.working,e[4]=i,e[5]=r):r=e[5];const d=r,m=!c,w=c?void 0:"Fold";let g;e[6]!==t.member.sessionId||e[7]!==l?(g=()=>l(t.member.sessionId),e[6]=t.member.sessionId,e[7]=l,e[8]=g):g=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=se("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 h;e[11]!==a?(h={left:a,top:Q/2},e[11]=a,e[12]=h):h=e[12];let v;e[13]!==u||e[14]!==c||e[15]!==o.count?(v=c?n.jsxs(n.Fragment,{children:[u&&n.jsx("span",{className:se("size-1.5 rounded-full",ue[u]),"aria-hidden":"true"}),"+",o.count]}):n.jsx(pt,{"aria-hidden":"true",className:"size-3"}),e[13]=u,e[14]=c,e[15]=o.count,e[16]=v):v=e[16];let N;return e[17]!==d||e[18]!==m||e[19]!==w||e[20]!==g||e[21]!==p||e[22]!==h||e[23]!==v?(N=n.jsx("button",{type:"button","aria-expanded":m,"aria-label":d,title:w,onClick:g,className:p,style:h,children:v}),e[17]=d,e[18]=m,e[19]=w,e[20]=g,e[21]=p,e[22]=h,e[23]=v,e[24]=N):N=e[24],N}function Bs(s){var g,x;const e=re.c(35),{member:t,name:i}=s;let a;e[0]!==t.firstUserMessage?(a=(g=t.firstUserMessage)==null?void 0:g.replace(/\s+/g," ").trim(),e[0]=t.firstUserMessage,e[1]=a):a=e[1];const l=a;let c;e[2]!==t.cwd?(c=(x=t.cwd)==null?void 0:x.split(/[\\/]/).filter(Boolean).at(-1),e[2]=t.cwd,e[3]=c):c=e[3];const o=c;let u;if(e[4]!==o||e[5]!==t.device||e[6]!==t.model||e[7]!==t.startedAt||e[8]!==t.turnCount){if(u=[],t.model){let p;e[10]!==t.model?(p=Ye(t.model),e[10]=t.model,e[11]=p):p=e[11];let h;e[12]!==p?(h=["Model",p],e[12]=p,e[13]=h):h=e[13],u.push(h)}if(t.device){let p;e[14]!==t.device.name?(p=["Device",t.device.name],e[14]=t.device.name,e[15]=p):p=e[15],u.push(p)}if(o){let p;e[16]!==o?(p=["Folder",o],e[16]=o,e[17]=p):p=e[17],u.push(p)}if(t.startedAt){let p;e[18]!==t.startedAt?(p=mt(t.startedAt),e[18]=t.startedAt,e[19]=p):p=e[19];let h;e[20]!==p?(h=["Started",p],e[20]=p,e[21]=h):h=e[21],u.push(h)}if(t.turnCount){const p=String(t.turnCount);let h;e[22]!==p?(h=["Turns",p],e[22]=p,e[23]=h):h=e[23],u.push(h)}e[4]=o,e[5]=t.device,e[6]=t.model,e[7]=t.startedAt,e[8]=t.turnCount,e[9]=u}else u=e[9];let r;e[24]!==i?(r=n.jsx("p",{className:"font-medium",children:i}),e[24]=i,e[25]=r):r=e[25];let d;e[26]!==i||e[27]!==l?(d=l&&l!==i&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:l}),e[26]=i,e[27]=l,e[28]=d):d=e[28];let m;e[29]!==u?(m=u.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:u.map(Ks)}),e[29]=u,e[30]=m):m=e[30];let w;return e[31]!==r||e[32]!==d||e[33]!==m?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[r,d,m]}),e[31]=r,e[32]=d,e[33]=m,e[34]=w):w=e[34],w}function Ks(s){const[e,t]=s;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:t})]},e)}const Gs=4e3;function Vs(s){var p;const[e,t]=S.useState(null),[i,a]=S.useState(null),[l,c]=S.useState(new Set),o=(p=Wt())==null?void 0:p.refresh,u=S.useRef(s),r=S.useRef(new Set);S.useLayoutEffect(()=>(u.current=s,()=>{u.current=null}),[s]);const d=S.useCallback(async h=>{if(s)try{const v=await ze(`/api/session-crew/${encodeURIComponent(s)}`);if(!h())return;if(!v.ok){a(v.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const N=await v.json();if(!h())return;t(b=>JSON.stringify(b)===JSON.stringify(N)?b:N),a(null)}catch{h()&&a("Couldn't load the crew.")}},[s]);it(s?d:null,Gs),S.useEffect(()=>{t(h=>h!=null&&h.members.some(v=>v.sessionId===s)?h:null),a(null),c(new Set)},[s]);const m=S.useCallback(async(h,v,N)=>{const b=`${s}:${h}`;if(r.current.has(b))return;const k=()=>u.current===s;r.current.add(b),c(C=>new Set(C).add(h));try{const C=await v();if(!k())return;if(!C.ok&&C.status!==404){a(N);return}o==null||o(),await d(k)}catch{k()&&a(N)}finally{r.current.delete(b),k()&&c(C=>{const M=new Set(C);return M.delete(h),M})}},[d,o,s]),w=S.useCallback((h,v,N)=>m(v,()=>be("/api/session-respond",{sessionId:h,requestId:v,...N}),"Couldn't send the answer."),[m]),g=S.useCallback((h,v)=>m(v,()=>be("/api/delegated-tasks",{sessionId:h,taskId:v,action:"ack"}),"Couldn't mark the result read."),[m]),x=S.useCallback(h=>m(h.sessionId,()=>{var v;return((v=h.result)==null?void 0:v.state)==="running"&&h.parentId?be("/api/delegated-tasks",{sessionId:h.parentId,taskId:h.result.taskId,action:"cancel"}):be("/api/stop-session",{sessionId:h.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[m]);return{crew:e,error:i,busy:l,respond:w,markRead:g,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 fn(s){var T;const e=re.c(34),{context:t,closePanel:i}=s,a=((T=t.session)==null?void 0:T.sessionId)??null,{crew:l,error:c,busy:o,respond:u,markRead:r,stop:d}=Vs(a),{names:m}=Ht(),[w,g]=S.useState("overview"),x=Ls((l==null?void 0:l.rootId)??"");let p;e[0]!==(l==null?void 0:l.members)?(p=new Map(((l==null?void 0:l.members)??[]).map(Qs)),e[0]=l==null?void 0:l.members,e[1]=p):p=e[1];const h=p;let v;e[2]!==(l==null?void 0:l.members)?(v=new Map(((l==null?void 0:l.members)??[]).flatMap(Js)),e[2]=l==null?void 0:l.members,e[3]=v):v=e[3];const N=v;let b;e[4]!==h||e[5]!==m?(b=z=>gs(z,h,m),e[4]=h,e[5]=m,e[6]=b):b=e[6];const k=b;let C;e[7]!==t?(C=z=>{z.address&&z.device?Xt(Zt(z.address.dirName,z.address.fileName,z.device.id)):z.address&&t.openSession?t.openSession(z.address.dirName,z.address.fileName):Jt(z.sessionId)},e[7]=t,e[8]=C):C=e[8];const M=C;let _,O,L;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),O=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),L=n.jsx("div",{className:"flex-1"}),e[9]=_,e[10]=O,e[11]=L):(_=e[9],O=e[10],L=e[11]);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(cs,{"data-icon":"inline-start"}),e[12]=j):j=e[12];let R;e[13]!==i?(R=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[_,O,L,n.jsx(J,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close crew",children:j})]}),e[13]=i,e[14]=R):R=e[14];let I;e[15]!==c?(I=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[15]=c,e[16]=I):I=e[16];let $;e[17]!==o||e[18]!==l||e[19]!==c||e[20]!==N||e[21]!==x||e[22]!==r||e[23]!==k||e[24]!==M||e[25]!==u||e[26]!==a||e[27]!==d||e[28]!==w?($=l?n.jsxs(Ut,{value:w,onValueChange:g,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(Te,{value:"overview",children:"Overview"}),n.jsx(Te,{value:"map",children:"Map"}),n.jsx(Te,{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:l,hereId:a,nameOf:k,onOpen:M}),n.jsx(sn,{crew:l,busy:o,nameOf:k,onOpen:M,onRespond:u}),n.jsx(nn,{crew:l,hereId:a,busy:o,nameOf:k,onOpen:M,onMarkRead:r,onStop:d})]})}),n.jsx(Oe,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:l,hereId:a,controls:x,kinds:N,nameOf:k,onOpen:M})}),n.jsx(Oe,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:l.rootId,kinds:N,active:w==="chat"},l.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[17]=o,e[18]=l,e[19]=c,e[20]=N,e[21]=x,e[22]=r,e[23]=k,e[24]=M,e[25]=u,e[26]=a,e[27]=d,e[28]=w,e[29]=$):$=e[29];let E;return e[30]!==I||e[31]!==$||e[32]!==R?(E=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[R,I,$]}),e[30]=I,e[31]=$,e[32]=R,e[33]=E):E=e[33],E}function Js(s){return s.address?[[s.sessionId,Kt(s.address.dirName)]]:[]}function Qs(s){return[s.sessionId,s]}function en(s){var b;const e=re.c(45),{crew:t,hereId:i,nameOf:a,onOpen:l}=s;let c,o,u,r,d;if(e[0]!==t||e[1]!==i||e[2]!==a||e[3]!==l){let k;e[9]!==t.rootId?(k=$=>$.sessionId===t.rootId,e[9]=t.rootId,e[10]=k):k=e[10];const C=t.members.find(k),M=t.members.filter(tn);let _;e[11]!==t?(_=bs(t),e[11]=t,e[12]=_):_=e[12],d=_;const O=(b=M[0])==null?void 0:b.startedAt;c="Crew summary",o="border-b px-3 pb-3 pt-1";const L=C&&n.jsx("button",{type:"button",onClick:()=>l(C),"aria-current":C.sessionId===i?"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:a(C)}),j=d.size===1?"session":"sessions",R=O?` · since ${mt(O)}`:"";let I;e[13]!==j||e[14]!==R||e[15]!==d.size?(I=n.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[d.size," ",j,R]}),e[13]=j,e[14]=R,e[15]=d.size,e[16]=I):I=e[16],e[17]!==I||e[18]!==L?(u=n.jsxs("div",{className:"flex items-baseline gap-2",children:[L,I]}),e[17]=I,e[18]=L,e[19]=u):u=e[19],r=M.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:M.map($=>{const E=fe($);return n.jsx("button",{type:"button",role:"listitem","data-crew-cell":E,title:`${a($)}: ${Ne($)}`,"aria-label":`${a($)}: ${Ne($)}`,onClick:()=>{var T;return(T=document.querySelector(`[data-crew-row="${$.sessionId}"]`))==null?void 0:T.scrollIntoView({block:"nearest",behavior:"smooth"})},className:se("h-2.5 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",Zs[E],$.sessionId===i&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},$.sessionId)})}),e[0]=t,e[1]=i,e[2]=a,e[3]=l,e[4]=c,e[5]=o,e[6]=u,e[7]=r,e[8]=d}else c=e[4],o=e[5],u=e[6],r=e[7],d=e[8];let m;e[20]!==d.working?(m=d.working>0&&n.jsx(ye,{dot:ue.working,value:d.working,label:"working"}),e[20]=d.working,e[21]=m):m=e[21];let w;e[22]!==d.needsYou?(w=d.needsYou>0&&n.jsx(ye,{dot:ue["needs-you"],value:d.needsYou,label:d.needsYou===1?"needs you":"need you"}),e[22]=d.needsYou,e[23]=w):w=e[23];let g;e[24]!==d.done?(g=d.done>0&&n.jsx(ye,{dot:ue.done,value:d.done,label:"done"}),e[24]=d.done,e[25]=g):g=e[25];let x;e[26]!==d.failed?(x=d.failed>0&&n.jsx(ye,{dot:ue.failed,value:d.failed,label:"failed"}),e[26]=d.failed,e[27]=x):x=e[27];let p;e[28]!==d.unreachable?(p=d.unreachable>0&&n.jsx(ye,{dot:ue.unreachable,value:d.unreachable,label:"away"}),e[28]=d.unreachable,e[29]=p):p=e[29];let h;e[30]!==d.unreadResults?(h=d.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:d.unreadResults})," ",d.unreadResults===1?"result":"results"," unread"]}),e[30]=d.unreadResults,e[31]=h):h=e[31];let v;e[32]!==h||e[33]!==m||e[34]!==w||e[35]!==g||e[36]!==x||e[37]!==p?(v=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[m,w,g,x,p,h]}),e[32]=h,e[33]=m,e[34]=w,e[35]=g,e[36]=x,e[37]=p,e[38]=v):v=e[38];let N;return e[39]!==c||e[40]!==v||e[41]!==o||e[42]!==u||e[43]!==r?(N=n.jsxs("section",{"aria-label":c,className:o,children:[u,r,v]}),e[39]=c,e[40]=v,e[41]=o,e[42]=u,e[43]=r,e[44]=N):N=e[44],N}function tn(s){return s.parentId!==null}function ye(s){const e=re.c(10),{dot:t,value:i,label:a}=s;let l;e[0]!==t?(l=se("size-1.5 rounded-full",t),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==l?(c=n.jsx("span",{className:l,"aria-hidden":"true"}),e[2]=l,e[3]=c):c=e[3];let o;e[4]!==i?(o=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:i}),e[4]=i,e[5]=o):o=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==o?(u=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,o," ",a]}),e[6]=a,e[7]=c,e[8]=o,e[9]=u):u=e[9],u}function sn(s){const e=re.c(6),{crew:t,busy:i,nameOf:a,onOpen:l,onRespond:c}=s,o=ws(t),[u,r]=S.useState(0);if(o.length===0)return null;const d=Math.min(u,o.length-1),{member:m,pending:w}=o[d],g=o[d+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 h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:se("size-1.5 shrink-0 rounded-full",ue["needs-you"]),"aria-hidden":"true"}),e[2]=h):h=e[2];const v=w.askedAt?`waiting ${qe(new Date(w.askedAt).toISOString())}`:"waiting";let N;e[3]!==v?(N=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:v}),e[3]=v,e[4]=N):N=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(et,{"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:[d+1," of ",o.length]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:d===0,onClick:()=>r(d-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:d===o.length-1,onClick:()=>r(d+1),children:n.jsx(et,{"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:[h,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:a(m)}),m.device&&n.jsx(Gt,{variant:"outline",children:m.device.name}),N]}),n.jsx(Vt,{sessionId:m.sessionId,pending:w,queued:0,responding:i.has(w.requestId),onRespond:(k,C)=>void c(m.sessionId,k,C),onOpen:()=>l(m)},w.requestId),n.jsxs(J,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>l(m),children:["Open session",b]})]}),g&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:a(g.member)})," ",Ne(g.member).toLowerCase()]})]})}function nn(s){const e=re.c(17),{crew:t,hereId:i,busy:a,nameOf:l,onOpen:c,onMarkRead:o,onStop:u}=s,[r,d]=S.useState("all");let m;if(e[0]!==a||e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==l||e[5]!==o||e[6]!==c||e[7]!==u){let w;e[9]!==r?(w=N=>{const{member:b}=N;if(r==="all")return!0;const k=fe(b);return r==="done"?k!=="working"&&k!=="needs-you":k===r},e[9]=r,e[10]=w):w=e[10];const g=xs(t).filter(w);let x,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),p=n.jsx("span",{className:"flex-1"}),e[11]=x,e[12]=p):(x=e[11],p=e[12]);let h;e[13]!==r?(h=Xs.map(N=>{const{id:b,label:k}=N;return n.jsx("button",{type:"button",role:"radio","aria-checked":r===b,onClick:()=>d(b),className:se("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",r===b&&"bg-accent text-foreground"),children:k},b)}),e[13]=r,e[14]=h):h=e[14];let v;e[15]!==h?(v=n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[x,p,n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:h})]}),e[15]=h,e[16]=v):v=e[16],m=n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[v,g.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:g.map(N=>n.jsx(on,{row:N,here:N.member.sessionId===i,busy:a,name:l(N.member),onOpen:c,onMarkRead:o,onStop:u},N.member.sessionId))})]}),e[0]=a,e[1]=t,e[2]=r,e[3]=i,e[4]=l,e[5]=o,e[6]=c,e[7]=u,e[8]=m}else m=e[8];return m}function on(s){var ae,ce;const e=re.c(73),{row:t,here:i,busy:a,name:l,onOpen:c,onMarkRead:o,onStop:u}=s,{member:r,depth:d,children:m}=t;let w;e[0]!==r?(w=fe(r),e[0]=r,e[1]=w):w=e[1];const g=w;let x;e[2]!==r?(x=Ne(r),e[2]=r,e[3]=x):x=e[3];const p=x;let h;e[4]!==r.pullRequests?(h=(ae=r.pullRequests)==null?void 0:ae.at(-1),e[4]=r.pullRequests,e[5]=h):h=e[5];const v=h;let N;e[6]!==r?(N=Re(r)&&r.result&&r.parentId,e[6]=r,e[7]=N):N=e[7];const b=N,k=(g==="working"||g==="needs-you")&&(!r.device||((ce=r.result)==null?void 0:ce.state)==="running"&&r.parentId!==null),C=r.sessionId,M=i?"bg-accent":"hover:bg-accent/60",_=d>0&&"border-l border-border/70";let O;e[8]!==M||e[9]!==_?(O=se("group/crew relative rounded-md",M,_),e[8]=M,e[9]=_,e[10]=O):O=e[10];const L=d>0?6+(d-1)*14:0;let j;e[11]!==L?(j={marginLeft:L},e[11]=L,e[12]=j):j=e[12];let R;e[13]!==r||e[14]!==c?(R=()=>c(r),e[13]=r,e[14]=c,e[15]=R):R=e[15];const I=i?"true":void 0,$=`${l}, ${p}`,E=ue[g];let T;e[16]!==E?(T=se("size-1.5 justify-self-center rounded-full",E),e[16]=E,e[17]=T):T=e[17];let z;e[18]!==T?(z=n.jsx("span",{className:T,"aria-hidden":"true"}),e[18]=T,e[19]=z):z=e[19];let D;e[20]!==l?(D=n.jsx("span",{className:"truncate",children:l}),e[20]=l,e[21]=D):D=e[21];let W;e[22]!==i?(W=i&&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[22]=i,e[23]=W):W=e[23];let F;e[24]!==D||e[25]!==W?(F=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[D,W]}),e[24]=D,e[25]=W,e[26]=F):F=e[26];let Y;e[27]!==r.lastActivityAt?(Y=r.lastActivityAt?qe(r.lastActivityAt):"",e[27]=r.lastActivityAt,e[28]=Y):Y=e[28];let K;e[29]!==Y?(K=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:Y}),e[29]=Y,e[30]=K):K=e[30];const B=(g==="needs-you"||b)&&"text-warning",X=g==="failed"&&"text-destructive";let H;e[31]!==B||e[32]!==X?(H=se("min-w-0 flex-1 truncate",B,X),e[31]=B,e[32]=X,e[33]=H):H=e[33];let U;e[34]!==p||e[35]!==H?(U=n.jsx("span",{className:H,children:p}),e[34]=p,e[35]=H,e[36]=U):U=e[36];let G;e[37]!==v?(G=v&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",v.number]}),e[37]=v,e[38]=G):G=e[38];let f;e[39]!==r.device?(f=r.device&&n.jsx("span",{className:"shrink-0",children:r.device.name}),e[39]=r.device,e[40]=f):f=e[40];let y;e[41]!==m?(y=m>0&&n.jsxs("span",{className:"shrink-0",children:[m," ",m===1?"session":"sessions"]}),e[41]=m,e[42]=y):y=e[42];let A;e[43]!==r.model?(A=r.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:Ye(r.model)}),e[43]=r.model,e[44]=A):A=e[44];let V;e[45]!==U||e[46]!==G||e[47]!==f||e[48]!==y||e[49]!==A?(V=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:[U,G,f,y,A]}),e[45]=U,e[46]=G,e[47]=f,e[48]=y,e[49]=A,e[50]=V):V=e[50];let ee;e[51]!==R||e[52]!==I||e[53]!==$||e[54]!==z||e[55]!==F||e[56]!==K||e[57]!==V?(ee=n.jsxs("button",{type:"button",onClick:R,"aria-current":I,"aria-label":$,className:"grid w-full 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:[z,F,K,V]}),e[51]=R,e[52]=I,e[53]=$,e[54]=z,e[55]=F,e[56]=K,e[57]=V,e[58]=ee):ee=e[58];let Z;e[59]!==a||e[60]!==k||e[61]!==r||e[62]!==l||e[63]!==o||e[64]!==u||e[65]!==b?(Z=(b||k)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[b&&r.result&&r.parentId&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${l}'s result read`,title:"Mark the result read",disabled:a.has(r.result.taskId),onClick:()=>void o(r.parentId,r.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),k&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${l}`,title:"Stop this session",disabled:a.has(r.sessionId),onClick:()=>void u(r),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[59]=a,e[60]=k,e[61]=r,e[62]=l,e[63]=o,e[64]=u,e[65]=b,e[66]=Z):Z=e[66];let te;return e[67]!==r.sessionId||e[68]!==j||e[69]!==ee||e[70]!==Z||e[71]!==O?(te=n.jsxs("li",{"data-crew-row":C,className:O,style:j,children:[ee,Z]}),e[67]=r.sessionId,e[68]=j,e[69]=ee,e[70]=Z,e[71]=O,e[72]=te):te=e[72],te}export{fn as CrewPanel};
@@ -1,2 +1,2 @@
1
- import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-DUfVcKxj.js";const F=2e5;function W(l){const e=G.c(32),{value:t,onChange:v,readOnly:f,filePath:E,ariaLabel:L,textareaRef:u,onKeyDown:S,onSelect:_}=l,p=M(),[h,N]=H.useState(null),d=H.useRef(null),m=H.useRef(null);let x;e[0]!==E?(x=P(E)??"markdown",e[0]=E,e[1]=x):x=e[1];const g=x,b=t.length>F;let j,k;e[2]!==p||e[3]!==g||e[4]!==b||e[5]!==t?(j=()=>{if(b){N(null);return}let r=!1;const I=setTimeout(()=>{z(t,g,p).then(A=>{r||N(A)})},80);return()=>{r=!0,clearTimeout(I)}},k=[t,g,p,b],e[2]=p,e[3]=g,e[4]=b,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]),H.useEffect(j,k);let R;e[8]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{d.current&&m.current&&(m.current.scrollTop=d.current.scrollTop,m.current.scrollLeft=d.current.scrollLeft)},e[8]=R):R=e[8];const D=R;let T;e[9]!==u?(T=r=>{d.current=r,u&&(u.current=r)},e[9]=u,e[10]=T):T=e[10];const y=T;let n;e[11]!==h||e[12]!==t?(n=h?h.map(J):i.jsx("code",{className:"text-foreground",children:t}),e[11]=h,e[12]=t,e[13]=n):n=e[13];let s;e[14]!==n?(s=i.jsx("pre",{ref:m,"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:n}),e[14]=n,e[15]=s):s=e[15];let o;e[16]!==v?(o=r=>v(r.target.value),e[16]=v,e[17]=o):o=e[17];const C=f&&"cursor-default";let a;e[18]!==C?(a=X("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",C),e[18]=C,e[19]=a):a=e[19];let c;e[20]!==L||e[21]!==y||e[22]!==S||e[23]!==_||e[24]!==f||e[25]!==a||e[26]!==o||e[27]!==t?(c=i.jsx("textarea",{ref:y,"aria-label":L,value:t,onChange:o,onScroll:D,onKeyDown:S,onSelect:_,readOnly:f,spellCheck:!1,className:a,placeholder:"Empty file"}),e[20]=L,e[21]=y,e[22]=S,e[23]=_,e[24]=f,e[25]=a,e[26]=o,e[27]=t,e[28]=c):c=e[28];let w;return e[29]!==c||e[30]!==s?(w=i.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[s,c]}),e[29]=c,e[30]=s,e[31]=w):w=e[31],w}function J(l,e){return i.jsxs("span",{children:[l.map(K),`
1
+ import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-DeMgVaXr.js";const F=2e5;function W(l){const e=G.c(32),{value:t,onChange:v,readOnly:f,filePath:E,ariaLabel:L,textareaRef:u,onKeyDown:S,onSelect:_}=l,p=M(),[h,N]=H.useState(null),d=H.useRef(null),m=H.useRef(null);let x;e[0]!==E?(x=P(E)??"markdown",e[0]=E,e[1]=x):x=e[1];const g=x,b=t.length>F;let j,k;e[2]!==p||e[3]!==g||e[4]!==b||e[5]!==t?(j=()=>{if(b){N(null);return}let r=!1;const I=setTimeout(()=>{z(t,g,p).then(A=>{r||N(A)})},80);return()=>{r=!0,clearTimeout(I)}},k=[t,g,p,b],e[2]=p,e[3]=g,e[4]=b,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]),H.useEffect(j,k);let R;e[8]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{d.current&&m.current&&(m.current.scrollTop=d.current.scrollTop,m.current.scrollLeft=d.current.scrollLeft)},e[8]=R):R=e[8];const D=R;let T;e[9]!==u?(T=r=>{d.current=r,u&&(u.current=r)},e[9]=u,e[10]=T):T=e[10];const y=T;let n;e[11]!==h||e[12]!==t?(n=h?h.map(J):i.jsx("code",{className:"text-foreground",children:t}),e[11]=h,e[12]=t,e[13]=n):n=e[13];let s;e[14]!==n?(s=i.jsx("pre",{ref:m,"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:n}),e[14]=n,e[15]=s):s=e[15];let o;e[16]!==v?(o=r=>v(r.target.value),e[16]=v,e[17]=o):o=e[17];const C=f&&"cursor-default";let a;e[18]!==C?(a=X("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",C),e[18]=C,e[19]=a):a=e[19];let c;e[20]!==L||e[21]!==y||e[22]!==S||e[23]!==_||e[24]!==f||e[25]!==a||e[26]!==o||e[27]!==t?(c=i.jsx("textarea",{ref:y,"aria-label":L,value:t,onChange:o,onScroll:D,onKeyDown:S,onSelect:_,readOnly:f,spellCheck:!1,className:a,placeholder:"Empty file"}),e[20]=L,e[21]=y,e[22]=S,e[23]=_,e[24]=f,e[25]=a,e[26]=o,e[27]=t,e[28]=c):c=e[28];let w;return e[29]!==c||e[30]!==s?(w=i.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[s,c]}),e[29]=c,e[30]=s,e[31]=w):w=e[31],w}function J(l,e){return i.jsxs("span",{children:[l.map(K),`
2
2
  `]},e)}function K(l,e){return i.jsx("span",{style:{color:l.color},children:l.content},e)}export{W as H};
@@ -1 +1 @@
1
- import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-DUfVcKxj.js";import{R as O,K as oe,S as ce}from"./vendor-ui-Dxtv9P3W.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function fe(e){const s=q.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(F,{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=q.c(45),[s,f]=k.useState(""),[l,x]=k.useState(null),[a,r]=k.useState(null),[B,G]=k.useState($);let E,I;e[0]!==l?(E=()=>{if(!l)return;const D=l,A=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,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),G($()),x(null),r(null)};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},I=[l],e[0]=l,e[1]=E,e[2]=I):(E=e[1],I=e[2]),k.useEffect(E,I);let g,j,d,y,b,N,S,w,m,u,h;if(e[3]!==B||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),A=D?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):T;j=H,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(M,{className:"p-4 pb-3",children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(J,{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(),G($()),r(null)},children:[t.jsx(O,{"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],g=ae,N="h-[min(28rem,60vh)]",y="flex flex-col gap-4 px-3 pb-4",b=Q.map(i=>{const L=A.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(B[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),G($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(O,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=B,e[4]=a,e[5]=s,e[6]=l,e[7]=g,e[8]=j,e[9]=d,e[10]=y,e[11]=b,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else g=e[7],j=e[8],d=e[9],y=e[10],b=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==y||e[30]!==b?(C=t.jsx("div",{className:y,children:b}),e[29]=y,e[30]=b,e[31]=C):C=e[31];let v;e[32]!==g||e[33]!==C||e[34]!==N?(v=t.jsx(g,{className:N,children:C}),e[32]=g,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==j||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(j,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=j,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{fe as KeyboardShortcutsDialog};
1
+ import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-DeMgVaXr.js";import{R as O,K as oe,S as ce}from"./vendor-ui-Cj1G8Clp.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function fe(e){const s=q.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(F,{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=q.c(45),[s,f]=k.useState(""),[l,x]=k.useState(null),[a,r]=k.useState(null),[B,G]=k.useState($);let E,I;e[0]!==l?(E=()=>{if(!l)return;const D=l,A=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,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),G($()),x(null),r(null)};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},I=[l],e[0]=l,e[1]=E,e[2]=I):(E=e[1],I=e[2]),k.useEffect(E,I);let g,j,d,y,b,N,S,w,m,u,h;if(e[3]!==B||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),A=D?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):T;j=H,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(M,{className:"p-4 pb-3",children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(J,{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(),G($()),r(null)},children:[t.jsx(O,{"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],g=ae,N="h-[min(28rem,60vh)]",y="flex flex-col gap-4 px-3 pb-4",b=Q.map(i=>{const L=A.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(B[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),G($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(O,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=B,e[4]=a,e[5]=s,e[6]=l,e[7]=g,e[8]=j,e[9]=d,e[10]=y,e[11]=b,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else g=e[7],j=e[8],d=e[9],y=e[10],b=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==y||e[30]!==b?(C=t.jsx("div",{className:y,children:b}),e[29]=y,e[30]=b,e[31]=C):C=e[31];let v;e[32]!==g||e[33]!==C||e[34]!==N?(v=t.jsx(g,{className:N,children:C}),e[32]=g,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==j||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(j,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=j,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{fe as KeyboardShortcutsDialog};
@@ -0,0 +1,2 @@
1
+ import{c as Y,r as W,j as t}from"./vendor-react-gGw_S5I_.js";import{bg as Se,J as Z,bh as Ce,bi as ye,v as Ae,bj as ve,bk as de,aK as De,B as H,bl as Pe,bm as _e,P as Ee,bn as Me,bb as ue,b0 as fe,A as me,bf as Re,bo as oe,H as $e,T as ze,bp as Ke,bq as Oe,br as Te,bs as Le,bt as Fe,bu as Be,bv as Qe,bw as Ue,bx as He,by as Ve,bz as Ye,$ as le,L as Ge,M as Xe,Q as Je,bA as We,Z as Ze,bB as pe,bC as es,bD as ss,bE as ts,bF as ns,bG as is}from"./index-DeMgVaXr.js";import{n as xe,ak as ls,b as rs,al as os,am as as,an as cs,ao as ds,C as Ie,$ as us,ap as fs,S as ms,X as xs}from"./vendor-ui-Cj1G8Clp.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const gs=6;function ps(c){const e=Y.c(72),{recent:s,start:n}=c,[l,r]=W.useState(null),[i,x]=W.useState(""),a=l??s[0]??null;let u,h,d,f,o,g,m,b,p,j,v,N,w;if(e[0]!==l||e[1]!==a||e[2]!==s||e[3]!==n||e[4]!==i){h=(l&&!s.some(A=>he(A,l))?[l,...s]:[...s]).slice(0,gs);let z;e[18]!==i?(z=i.trim(),e[18]=i,e[19]=z):z=e[19];const F=z;u=!!(a&&F);let q;e[20]===Symbol.for("react.memo_cache_sentinel")?(q=(A,V)=>{r({dirName:A,cwd:V,name:V?ve(V):A})},e[20]=q):q=e[20],d=q;let T;e[21]!==n.defaultAgentKind?(T=A=>d(de(n.defaultAgentKind,A),A),e[21]=n.defaultAgentKind,e[22]=T):T=e[22],f=T;const G=a==null?void 0:a.cwd;let B;e[23]!==G||e[24]!==a?(B=a&&G?A=>r({...a,dirName:de(A,G)}):void 0,e[23]=G,e[24]=a,e[25]=B):B=e[25],m=B;let X;e[26]!==F||e[27]!==a||e[28]!==n?(X=A=>{A==null||A.preventDefault(),!(!a||!F)&&(n.onStart(a.dirName,a.cwd,F),x(""))},e[26]=F,e[27]=a,e[28]=n,e[29]=X):X=e[29],g=X;let J;e[30]!==g?(J=A=>{A.key==="Enter"&&!A.shiftKey&&!A.nativeEvent.isComposing&&(A.preventDefault(),g())},e[30]=g,e[31]=J):J=e[31],o=J,N="Start a session",w="flex min-w-0 flex-col gap-3",b="flex flex-wrap items-center gap-1.5",p="group",j="Projects",v=h.map(A=>{const V=a!==null&&he(A,a);return t.jsxs("button",{type:"button","aria-pressed":V,title:A.cwd??A.name,onClick:()=>r(A),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",V?"border-foreground/80 bg-foreground text-background":"border-border/70 text-muted-foreground hover:border-foreground/40 hover:text-foreground"),children:[t.jsx(Se,{projectPath:A.cwd??null,fallback:t.jsx(xe,{className:"size-3.5","aria-hidden":"true"}),className:"size-4"}),t.jsx("span",{className:"truncate",children:A.name})]},A.cwd??A.dirName)}),e[0]=l,e[1]=a,e[2]=s,e[3]=n,e[4]=i,e[5]=u,e[6]=h,e[7]=d,e[8]=f,e[9]=o,e[10]=g,e[11]=m,e[12]=b,e[13]=p,e[14]=j,e[15]=v,e[16]=N,e[17]=w}else u=e[5],h=e[6],d=e[7],f=e[8],o=e[9],g=e[10],m=e[11],b=e[12],p=e[13],j=e[14],v=e[15],N=e[16],w=e[17];const I=h.length>0;let y;e[32]!==d||e[33]!==f||e[34]!==n.defaultAgentKind||e[35]!==I?(y=t.jsx(hs,{defaultAgentKind:n.defaultAgentKind,onChoose:d,onChooseFolder:f,anyListed:I}),e[32]=d,e[33]=f,e[34]=n.defaultAgentKind,e[35]=I,e[36]=y):y=e[36];let k;e[37]!==b||e[38]!==p||e[39]!==j||e[40]!==v||e[41]!==y?(k=t.jsxs("div",{className:b,role:p,"aria-label":j,children:[v,y]}),e[37]=b,e[38]=p,e[39]=j,e[40]=v,e[41]=y,e[42]=k):k=e[42];let D;e[43]!==l||e[44]!==a?(D=z=>{!l&&a&&r(a),x(z.target.value)},e[43]=l,e[44]=a,e[45]=D):D=e[45];const _=a?`Describe the task for ${a.name}`:"Pick a project, then describe the task";let S;e[46]!==o||e[47]!==D||e[48]!==_||e[49]!==i?(S=t.jsx(De,{"aria-label":"First message",value:i,onChange:D,onKeyDown:o,placeholder:_,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]=D,e[48]=_,e[49]=i,e[50]=S):S=e[50];let P;e[51]!==a||e[52]!==n.model||e[53]!==m?(P=a&&t.jsx(Ce,{isNewSession:!0,agentKind:ye(a.dirName),onAgentKindChange:m,selectedModel:n.model.selectedModel,onModelChange:n.model.onModelChange,selectedEffort:n.model.selectedEffort,onEffortChange:n.model.onEffortChange}),e[51]=a,e[52]=n.model,e[53]=m,e[54]=P):P=e[54];const $=!u;let M;e[55]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(ls,{"data-icon":"icon"}),e[55]=M):M=e[55];let E;e[56]!==$?(E=t.jsx(H,{type:"submit",size:"icon-xs",disabled:$,"aria-label":"Start session",title:"Start session (Enter)",children:M}),e[56]=$,e[57]=E):E=e[57];let C;e[58]!==P||e[59]!==E?(C=t.jsxs("div",{className:"flex shrink-0 items-center gap-1 pb-0.5",children:[P,E]}),e[58]=P,e[59]=E,e[60]=C):C=e[60];let R;e[61]!==S||e[62]!==C?(R=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:[S,C]}),e[61]=S,e[62]=C,e[63]=R):R=e[63];let K;e[64]!==g||e[65]!==R?(K=t.jsx("form",{onSubmit:g,className:"min-w-0",children:R}),e[64]=g,e[65]=R,e[66]=K):K=e[66];let O;return e[67]!==K||e[68]!==N||e[69]!==w||e[70]!==k?(O=t.jsxs("section",{"aria-label":N,className:w,children:[k,K]}),e[67]=K,e[68]=N,e[69]=w,e[70]=k,e[71]=O):O=e[71],O}function he(c,e){return c.cwd&&e.cwd?c.cwd===e.cwd:c.dirName===e.dirName}function hs(c){const e=Y.c(19),{defaultAgentKind:s,onChoose:n,onChooseFolder:l,anyListed:r}=c,[i,x]=W.useState(!1),a=Ae(i),u=r?"ghost":"outline";let h;e[0]!==u?(h=t.jsx(H,{variant:u,size:"xs",className:"rounded-full text-muted-foreground"}),e[0]=u,e[1]=h):h=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(xe,{"data-icon":"inline-start"}),e[2]=d):d=e[2];const f=r?"Other project":"Choose a project";let o;e[3]!==h||e[4]!==f?(o=t.jsxs(Pe,{render:h,children:[d,f]}),e[3]=h,e[4]=f,e[5]=o):o=e[5];let g;e[6]!==n?(g=(j,v)=>{x(!1),n(j,v)},e[6]=n,e[7]=g):g=e[7];let m;e[8]!==l?(m=j=>{x(!1),l(j)},e[8]=l,e[9]=m):m=e[9];let b;e[10]!==s||e[11]!==a||e[12]!==g||e[13]!==m?(b=t.jsx(_e,{align:"start",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:t.jsx(Ee,{projects:a,defaultAgentKind:s,onNewSession:g,onNewFolder:m})}),e[10]=s,e[11]=a,e[12]=g,e[13]=m,e[14]=b):b=e[14];let p;return e[15]!==i||e[16]!==o||e[17]!==b?(p=t.jsxs(Me,{open:i,onOpenChange:x,children:[o,b]}),e[15]=i,e[16]=o,e[17]=b,e[18]=p):p=e[18],p}function bs(c){const e={};for(const s of c)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 js(c,e){const s={};for(const n of c){const l=e[n.name];if(typeof l=="boolean"){s[n.name]=l;continue}l!==""&&(s[n.name]=n.type==="number"||n.type==="integer"?Number(l):l)}return s}function ws(c,e){return c.every(s=>{if(!s.required)return!0;const n=e[s.name];return typeof n=="boolean"?!0:n===""?!1:s.type==="number"||s.type==="integer"?Number.isFinite(Number(n)):!0})}function Ns(c){const e=Y.c(52),{request:s,responding:n,onAnswer:l}=c;let r;e[0]!==s.fields?(r=()=>bs(s.fields),e[0]=s.fields,e[1]=r):r=e[1];const[i,x]=W.useState(r);let a;e[2]!==s.fields||e[3]!==i?(a=ws(s.fields,i),e[2]=s.fields,e[3]=i,e[4]=a):a=e[4];const u=a,h=s.displayName||s.title||s.serverName;let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=(N,w)=>{x(I=>({...I,[N]:w}))},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 g=o;if(s.mode==="url"&&s.url){const N=s.url;let w;e[9]!==s.message?(w=t.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:s.message}),e[9]=s.message,e[10]=w):w=e[10];let I;e[11]!==N?(I=t.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:N,children:N}),e[11]=N,e[12]=I):I=e[12];let y;e[13]!==g||e[14]!==l||e[15]!==s.requestId||e[16]!==n||e[17]!==N?(y=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>{window.open(N,"_blank","noopener,noreferrer"),l(s.requestId,{action:"accept"})},children:["Open link",t.jsx(rs,{"data-icon":"inline-end"})]}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[13]=g,e[14]=l,e[15]=s.requestId,e[16]=n,e[17]=N,e[18]=y):y=e[18];let k;return e[19]!==h||e[20]!==w||e[21]!==I||e[22]!==y?(k=t.jsxs(be,{server:h,children:[w,I,y]}),e[19]=h,e[20]=w,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 b;if(e[26]!==l||e[27]!==s.fields||e[28]!==s.requestId||e[29]!==n||e[30]!==i){let N;e[32]!==l||e[33]!==s.requestId||e[34]!==n||e[35]!==i?(N=w=>t.jsx(ys,{id:`elicit-${s.requestId}-${w.name}`,field:w,value:i[w.name],disabled:n||!l,onChange:I=>f(w.name,I)},w.name),e[32]=l,e[33]=s.requestId,e[34]=n,e[35]=i,e[36]=N):N=e[36],b=s.fields.map(N),e[26]=l,e[27]=s.fields,e[28]=s.requestId,e[29]=n,e[30]=i,e[31]=b}else b=e[31];let p;e[37]!==b?(p=t.jsx("div",{className:"mt-3 flex flex-col gap-3",children:b}),e[37]=b,e[38]=p):p=e[38];let j;e[39]!==u||e[40]!==g||e[41]!==l||e[42]!==s.fields||e[43]!==s.requestId||e[44]!==n||e[45]!==i?(j=l&&t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx(H,{size:"sm",disabled:n||!u,onClick:()=>l(s.requestId,{action:"accept",content:js(s.fields,i)}),children:"Send"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,onClick:g,children:"Decline"})]}),e[39]=u,e[40]=g,e[41]=l,e[42]=s.fields,e[43]=s.requestId,e[44]=n,e[45]=i,e[46]=j):j=e[46];let v;return e[47]!==h||e[48]!==m||e[49]!==p||e[50]!==j?(v=t.jsxs(be,{server:h,children:[m,p,j]}),e[47]=h,e[48]=m,e[49]=p,e[50]=j,e[51]=v):v=e[51],v}function ys(c){const e=Y.c(55),{id:s,field:n,value:l,disabled:r,onChange:i}=c;if(n.type==="boolean"){const g=l===!0;let m;e[0]!==i?(m=v=>i(v===!0),e[0]=i,e[1]=m):m=e[1];let b;e[2]!==r||e[3]!==s||e[4]!==g||e[5]!==m?(b=t.jsx(Re,{id:s,checked:g,disabled:r,onCheckedChange:m}),e[2]=r,e[3]=s,e[4]=g,e[5]=m,e[6]=b):b=e[6];let p;e[7]!==n?(p=t.jsx(ae,{field:n}),e[7]=n,e[8]=p):p=e[8];let j;return e[9]!==s||e[10]!==b||e[11]!==p?(j=t.jsxs(oe,{htmlFor:s,className:"items-start gap-2 font-normal",children:[b,p]}),e[9]=s,e[10]=b,e[11]=p,e[12]=j):j=e[12],j}if(n.type==="enum"){let g;e[13]!==n?(g=t.jsx(ae,{field:n}),e[13]=n,e[14]=g):g=e[14];let m;e[15]!==s||e[16]!==g?(m=t.jsx(oe,{htmlFor:s,children:g}),e[15]=s,e[16]=g,e[17]=m):m=e[17];let b;e[18]!==l?(b=typeof l=="string"&&l?[l]:[],e[18]=l,e[19]=b):b=e[19];let p;e[20]!==i?(p=y=>{y[0]&&i(y[0])},e[20]=i,e[21]=p):p=e[21];const j=n.label;let v;e[22]!==n.options?(v=n.options??[],e[22]=n.options,e[23]=v):v=e[23];let N;if(e[24]!==r||e[25]!==v){let y;e[27]!==r?(y=k=>t.jsx($e,{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],N=v.map(y),e[24]=r,e[25]=v,e[26]=N}else N=e[26];let w;e[29]!==n.label||e[30]!==s||e[31]!==b||e[32]!==p||e[33]!==N?(w=t.jsx(ze,{id:s,value:b,onValueChange:p,orientation:"vertical",variant:"outline",size:"sm",className:"w-full items-stretch","aria-label":j,children:N}),e[29]=n.label,e[30]=s,e[31]=b,e[32]=p,e[33]=N,e[34]=w):w=e[34];let I;return e[35]!==m||e[36]!==w?(I=t.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,w]}),e[35]=m,e[36]=w,e[37]=I):I=e[37],I}let x;e[38]!==n?(x=t.jsx(ae,{field:n}),e[38]=n,e[39]=x):x=e[39];let a;e[40]!==s||e[41]!==x?(a=t.jsx(oe,{htmlFor:s,children:x}),e[40]=s,e[41]=x,e[42]=a):a=e[42];const u=n.type==="string"?"text":"number",h=typeof l=="string"?l:"";let d;e[43]!==i?(d=g=>i(g.target.value),e[43]=i,e[44]=d):d=e[44];let f;e[45]!==r||e[46]!==n.label||e[47]!==s||e[48]!==u||e[49]!==h||e[50]!==d?(f=t.jsx(ue,{id:s,"aria-label":n.label,type:u,value:h,disabled:r,onChange:d}),e[45]=r,e[46]=n.label,e[47]=s,e[48]=u,e[49]=h,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 ae(c){const e=Y.c(8),{field:s}=c;let n;e[0]!==s.required?(n=s.required&&t.jsx("span",{className:"ml-0.5 text-warning",children:"*"}),e[0]=s.required,e[1]=n):n=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]!==n||e[6]!==l?(r=t.jsxs("span",{className:"min-w-0",children:[s.label,n,l]}),e[4]=s.label,e[5]=n,e[6]=l,e[7]=r):r=e[7],r}function be(c){const e=Y.c(8),{server:s,children:n}=c;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(os,{className:"text-info"}),e[0]=l):l=e[0];let r;e[1]!==s?(r=t.jsxs(fe,{children:[s," needs input"]}),e[1]=s,e[2]=r):r=e[2];let i;e[3]!==n?(i=t.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:n}),e[3]=n,e[4]=i):i=e[4];let x;return e[5]!==r||e[6]!==i?(x=t.jsxs(me,{className:"border-info/40 bg-info/5",children:[l,r,i]}),e[5]=r,e[6]=i,e[7]=x):x=e[7],x}function vs(c){const e=Y.c(15),{request:s,responding:n,onChoose:l}=c;let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(as,{className:"text-warning"}),i=t.jsx(fe,{children:"The agent declined this request"}),e[0]=r,e[1]=i):(r=e[0],i=e[1]);let x;e[2]!==s.originalModel?(x=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]=x):x=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 u;e[6]!==l||e[7]!==s.fallbackModel||e[8]!==s.requestId||e[9]!==n?(u=l&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(H,{size:"sm",disabled:n,onClick:()=>l(s.requestId,"retry_fallback"),children:["Retry on ",s.fallbackModel]}),t.jsx(H,{variant:"outline",size:"sm",disabled:n,onClick:()=>l(s.requestId,"edit_prompt"),children:"Edit prompt"}),t.jsx(H,{variant:"ghost",size:"sm",disabled:n,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]=n,e[10]=u):u=e[10];let h;return e[11]!==x||e[12]!==a||e[13]!==u?(h=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[r,i,t.jsxs("div",{className:"col-start-2 mt-1 min-w-0",children:[x,a,u]})]}),e[11]=x,e[12]=a,e[13]=u,e[14]=h):h=e[14],h}function Is(c){const e=Y.c(64),{request:s,input:n,canAnswer:l,onOpen:r}=c;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[x,a]=W.useState(i),{sessionId:u}=s;switch(s.kind){case"permission":{const h=s.request;let d;e[1]!==n.responding||e[2]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[1]=n.responding,e[2]=s.request.requestId,e[3]=d):d=e[3];let f;e[4]!==l||e[5]!==n||e[6]!==u?(f=l?(g,m)=>void n.respond(u,g,m):void 0,e[4]=l,e[5]=n,e[6]=u,e[7]=f):f=e[7];let o;return e[8]!==s.request||e[9]!==d||e[10]!==f?(o=t.jsx(Oe,{request:h,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 h=s.request;let d;e[12]!==n.responding||e[13]!==s.request.toolUseId?(d=n.responding.has(s.request.toolUseId),e[12]=n.responding,e[13]=s.request.toolUseId,e[14]=d):d=e[14];let f;e[15]!==x||e[16]!==s.request.toolUseId?(f=x.has(s.request.toolUseId),e[15]=x,e[16]=s.request.toolUseId,e[17]=f):f=e[17];let o;e[18]!==l||e[19]!==n||e[20]!==u?(o=l?async(m,b)=>{(await n.answerQuestion(u,m,b)).gone&&a(j=>new Set(j).add(m))}:void 0,e[18]=l,e[19]=n,e[20]=u,e[21]=o):o=e[21];let g;return e[22]!==r||e[23]!==s.request||e[24]!==d||e[25]!==f||e[26]!==o?(g=t.jsx(Ke,{request:h,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]=g):g=e[27],g}case"elicitation":{const h=s.request;let d;e[28]!==n.responding||e[29]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[28]=n.responding,e[29]=s.request.requestId,e[30]=d):d=e[30];let f;e[31]!==l||e[32]!==n||e[33]!==u?(f=l?(g,m)=>void n.answerElicitation(u,g,m):void 0,e[31]=l,e[32]=n,e[33]=u,e[34]=f):f=e[34];let o;return e[35]!==s.request||e[36]!==d||e[37]!==f?(o=t.jsx(Ns,{request:h,responding:d,onAnswer:f}),e[35]=s.request,e[36]=d,e[37]=f,e[38]=o):o=e[38],o}case"dialog":{const h=s.request;let d;e[39]!==n.responding||e[40]!==s.request.requestId?(d=n.responding.has(s.request.requestId),e[39]=n.responding,e[40]=s.request.requestId,e[41]=d):d=e[41];let f;e[42]!==l||e[43]!==n||e[44]!==u?(f=l?(g,m)=>void n.answerDialog(u,g,m):void 0,e[42]=l,e[43]=n,e[44]=u,e[45]=f):f=e[45];let o;return e[46]!==s.request||e[47]!==d||e[48]!==f?(o=t.jsx(vs,{request:h,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 h;e[50]!==s.kind?(h=s.kind==="plan"?t.jsx(cs,{className:"text-warning"}):t.jsx(ds,{className:"text-warning"}),e[50]=s.kind,e[51]=h):h=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(fe,{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 g;e[54]!==o?(g=t.jsx("p",{className:"col-start-2 mt-1 text-sm text-muted-foreground",children:o}),e[54]=o,e[55]=g):g=e[55];let m;e[56]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Ie,{"data-icon":"inline-end"}),e[56]=m):m=e[56];let b;e[57]!==r?(b=t.jsx("div",{className:"col-start-2 mt-2",children:t.jsxs(H,{size:"xs",onClick:r,children:["Open session",m]})}),e[57]=r,e[58]=b):b=e[58];let p;return e[59]!==h||e[60]!==f||e[61]!==g||e[62]!==b?(p=t.jsxs(me,{className:"border-warning/40 bg-warning/5",children:[h,f,g,b]}),e[59]=h,e[60]=f,e[61]=g,e[62]=b,e[63]=p):p=e[63],p}}}function ks(c,e,s=()=>!0){const n=new Map(e.map(i=>[i.sessionId,i])),l=i=>{const x=n.get(i);return x?Be(x):Date.now()},r=[];for(const[i,x]of c.permissionsBySession)for(const a of x)r.push({kind:"permission",sessionId:i,since:a.timestamp,request:a});for(const[i,x]of c.questionsBySession)for(const a of x)r.push({kind:"question",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.elicitationsBySession)for(const a of x)r.push({kind:"elicitation",sessionId:i,since:a.askedAt,request:a});for(const[i,x]of c.dialogsBySession)for(const a of x)r.push({kind:"dialog",sessionId:i,since:a.askedAt,request:a});for(const i of c.awaitingPlan)r.push({kind:"plan",sessionId:i,since:l(i)});for(const i of e)i.agentStatus==="deferred"&&!i.archived&&r.push({kind:"deferred",sessionId:i.sessionId,since:l(i.sessionId)});return r.filter(i=>s(i.sessionId)).sort((i,x)=>i.since-x.since)}function je(c){switch(c.kind){case"permission":return c.request.requestId;case"question":return c.request.toolUseId;case"elicitation":case"dialog":return c.request.requestId;default:return`${c.kind}:${c.sessionId}`}}const qs=7*864e5,we=3,Ss=30,Cs=50;function As(c,e){const s=c.filter(r=>!r.archived&&!(r.teamName&&r.agentName)),{topLevel:n,crewOf:l}=Te(s);return n.map(r=>{const i=l.get(r.sessionId)??[],x=i.length?Le(r,i):r.lastActivityAt||r.lastModified,a=[r,...i].flatMap(u=>(u.pullRequests??[]).map(h=>({pullRequest:h,by:u}))).sort((u,h)=>Date.parse(h.pullRequest.timestamp)-Date.parse(u.pullRequest.timestamp))[0];return{session:r,state:e(r).state,members:i,cells:i.map(u=>e(u).state),counts:i.length?Fe(i,e):null,activityAt:x,...a&&{landed:{number:a.pullRequest.number,title:a.pullRequest.title,url:a.pullRequest.url,by:a.by}}}}).sort((r,i)=>Date.parse(i.activityAt)-Date.parse(r.activityAt))}function Ds(c,e=Date.now()){const s=c.filter(n=>e-Date.parse(n.activityAt)<qs);return(s.length>=we?s:c.slice(0,we)).slice(0,Ss)}function Ps(c,e,s=6){const n=[],l=new Set;for(const r of c){const i=e(r.session);if(!(!i.cwd||l.has(i.cwd))&&(l.add(i.cwd),n.push(i),n.length===s))break}return n}function _s(c,e,s){const n=e.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[]:c.filter(l=>{const r=s(l).filter(Boolean).join(`
2
+ `).toLowerCase();return n.every(i=>r.includes(i))}).slice(0,Cs)}const Es={working:"bg-success shadow-[0_0_0_1.5px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40"};function Ms(c,e){const s=c.cwd?is(c.cwd):null,n=(s==null?void 0:s.parentPath)??c.cwd,l=s?de(ye(c.dirName),s.parentPath):c.dirName;return{dirName:l,cwd:n,name:e[l]??(n?ve(n):c.projectShortName)}}function Rs(c){const e=c.target instanceof HTMLElement&&c.target.closest("input,textarea,select,[contenteditable=true]");return!c.metaKey&&!c.ctrlKey&&!c.altKey&&!e}function Gs(c){const e=Y.c(81),{onOpenSession:s,onBrowseProjects:n,start:l}=c,r=Qe(),i=Ue(),{names:x,rename:a}=He(),{names:u}=Ve(),h=Ye(),[d,f]=W.useState(""),o=W.useRef(null);let g;e[0]!==r.sessions?(g=r.sessions.filter(Ks),e[0]=r.sessions,e[1]=g):g=e[1];const m=g;let b;e[2]!==m?(b=new Map(m.map(zs)),e[2]=m,e[3]=b):b=e[3];const p=b;let j;e[4]!==i.awaitingDialog||e[5]!==i.awaitingElicitation?(j=new Set([...i.awaitingElicitation,...i.awaitingDialog]),e[4]=i.awaitingDialog,e[5]=i.awaitingElicitation,e[6]=j):j=e[6];let v;e[7]!==i.awaitingPermission||e[8]!==i.awaitingPlan||e[9]!==i.awaitingQuestion||e[10]!==j?(v={awaitingPermission:i.awaitingPermission,awaitingQuestion:i.awaitingQuestion,awaitingPrompt:j,awaitingPlan:i.awaitingPlan},e[7]=i.awaitingPermission,e[8]=i.awaitingPlan,e[9]=i.awaitingQuestion,e[10]=j,e[11]=v):v=e[11];const N=v;let w;e[12]!==r.procBySession||e[13]!==N?(w=Q=>es(Q,r.procBySession,N),e[12]=r.procBySession,e[13]=N,e[14]=w):w=e[14];const I=w;let y;e[15]!==p||e[16]!==h?(y=Q=>{const L=p.get(Q);return h(L==null?void 0:L.access).canInteract},e[15]=p,e[16]=h,e[17]=y):y=e[17];const k=y;let D;e[18]!==k||e[19]!==i||e[20]!==m?(D=ks(i,m,k),e[18]=k,e[19]=i,e[20]=m,e[21]=D):D=e[21];const _=D;let S;e[22]!==p||e[23]!==x?(S=Q=>ss(Q,p,x),e[22]=p,e[23]=x,e[24]=S):S=e[24];const P=S;let $;e[25]!==u?($=Q=>u[Q.dirName]??ts(Q),e[25]=u,e[26]=$):$=e[26];const M=$;let E,C,R;if(e[27]!==P||e[28]!==M||e[29]!==u||e[30]!==d||e[31]!==m||e[32]!==I){E=As(m,I),R=d.trim().length>0?_s(E,d,U=>{var ge;return[P(U.session.sessionId),M(U.session),U.session.gitBranch,U.session.cwd,U.session.lastUserMessage,U.session.firstUserMessage,(ge=U.landed)==null?void 0:ge.title,U.landed&&`#${U.landed.number}`,...U.members.map(qe=>P(qe.sessionId))]}):Ds(E);let L;e[36]!==u?(L=U=>Ms(U,u),e[36]=u,e[37]=L):L=e[37],C=Ps(E,L),e[27]=P,e[28]=M,e[29]=u,e[30]=d,e[31]=m,e[32]=I,e[33]=E,e[34]=C,e[35]=R}else E=e[33],C=e[34],R=e[35];const K=C;let O;e[38]!==p||e[39]!==s?(O=Q=>{const L=p.get(Q);L?s(L.dirName,L.fileName):ns(Q)},e[38]=p,e[39]=s,e[40]=O):O=e[40];const z=O;let F;e[41]!==r.processes?(F=r.processes.filter($s),e[41]=r.processes,e[42]=F):F=e[42];const q=F.length;let T,G;e[43]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{const Q=L=>{var U;L.key==="/"&&Rs(L)&&(L.preventDefault(),(U=o.current)==null||U.focus())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},G=[],e[43]=T,e[44]=G):(T=e[43],G=e[44]),W.useEffect(T,G);let B;e[45]===Symbol.for("react.memo_cache_sentinel")?(B=t.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Mission Control"}),e[45]=B):B=e[45];let X;e[46]!==q?(X=q>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[q," ",q===1?"agent":"agents"," running on this machine"]}),e[46]=q,e[47]=X):X=e[47];let J;e[48]!==X?(J=t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[B,X]}),e[48]=X,e[49]=J):J=e[49];let A;e[50]!==K||e[51]!==l?(A=l&&t.jsx(ps,{recent:K,start:l}),e[50]=K,e[51]=l,e[52]=A):A=e[52];let V;e[53]!==J||e[54]!==A?(V=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,A]}),e[53]=J,e[54]=A,e[55]=V):V=e[55];const re=_.length>0&&"lg:grid lg:grid-cols-[minmax(0,380px)_minmax(0,1fr)] lg:grid-rows-[minmax(0,1fr)]";let ee;e[56]!==re?(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",re),e[56]=re,e[57]=ee):ee=e[57];let se;e[58]!==p||e[59]!==k||e[60]!==i||e[61]!==P||e[62]!==z||e[63]!==_?(se=_.length>0?t.jsx(Os,{queue:_,input:i,byId:p,nameOf:P,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]=p,e[59]=k,e[60]=i,e[61]=P,e[62]=z,e[63]=_,e[64]=se):se=e[64];let te;e[65]!==P||e[66]!==n||e[67]!==z||e[68]!==M||e[69]!==d||e[70]!==a||e[71]!==E.length||e[72]!==R?(te=t.jsx(Ls,{sessions:R,total:E.length,query:d,onQueryChange:f,searchRef:o,nameOf:P,projectLabel:M,onOpen:z,onRename:a,onBrowseProjects:n}),e[65]=P,e[66]=n,e[67]=z,e[68]=M,e[69]=d,e[70]=a,e[71]=E.length,e[72]=R,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 ie;return e[78]!==V||e[79]!==ne?(ie=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[V,ne]}),e[78]=V,e[79]=ne,e[80]=ie):ie=e[80],ie}function $s(c){return c.sessionId}function zs(c){return[c.sessionId,c]}function Ks(c){return!c.archived}function ke(c){const e=Y.c(9),{title:s,count:n,children:l}=c;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 i;e[2]!==n?(i=n!==void 0&&t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n}),e[2]=n,e[3]=i):i=e[3];let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("span",{className:"flex-1"}),e[4]=x):x=e[4];let a;return e[5]!==l||e[6]!==r||e[7]!==i?(a=t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r,i,x,l]}),e[5]=l,e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function ce(c,e){const s=c==null?void 0:c.crew;return s?e(s.rootId)??s.rootTitle??null:null}const Ne={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 Os(c){const e=Y.c(71),{queue:s,input:n,byId:l,nameOf:r,onOpen:i,canAnswer:x}=c,[a,u]=W.useState(0);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=new Set,e[0]=h):h=e[0];const d=W.useRef(h),f=Math.min(a,s.length-1),o=s[f];let g;if(e[1]!==l||e[2]!==r||e[3]!==o.sessionId){const q=l.get(o.sessionId);g=ce(q,r),e[1]=l,e[2]=r,e[3]=o.sessionId,e[4]=g}else g=e[4];const m=g;let b;e[5]!==f||e[6]!==x||e[7]!==n||e[8]!==i||e[9]!==s.length||e[10]!==o.kind||e[11]!==o.request||e[12]!==o.sessionId?(b=q=>{const T=q.target;if(!(T.closest("input,textarea,select,[contenteditable=true]")||q.metaKey||q.ctrlKey||q.altKey)&&((q.key==="j"||q.key==="n"||q.key==="ArrowDown")&&(q.preventDefault(),u(Math.min(s.length-1,f+1))),(q.key==="k"||q.key==="ArrowUp")&&(q.preventDefault(),u(Math.max(0,f-1))),q.key==="o"&&(q.preventDefault(),i(o.sessionId)),(q.key==="Enter"||q.key==="d")&&T===q.currentTarget&&x(o.sessionId))){if(o.kind!=="permission")return;const G=q.key==="d"||o.request.defaultToNo?"deny":"allow",B=o.request.requestId;if(o.request.availableDecisions&&!o.request.availableDecisions.includes(G)||(q.preventDefault(),d.current.has(B)||n.responding.has(B)))return;d.current.add(B),n.respond(o.sessionId,B,G).finally(()=>d.current.delete(B))}},e[5]=f,e[6]=x,e[7]=n,e[8]=i,e[9]=s.length,e[10]=o.kind,e[11]=o.request,e[12]=o.sessionId,e[13]=b):b=e[13];const p=b;let j;e[14]!==f||e[15]!==s.length?(j=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(H,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:f===0,onClick:()=>u(f-1),children:t.jsx(us,{"data-icon":"inline-start"})}),t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:f===s.length-1,onClick:()=>u(f+1),children:t.jsx(Ie,{"data-icon":"inline-start"})})]}),e[14]=f,e[15]=s.length,e[16]=j):j=e[16];let v;e[17]!==s.length||e[18]!==j?(v=t.jsx(ke,{title:"Needs you",count:s.length,children:j}),e[17]=s.length,e[18]=j,e[19]=v):v=e[19];let N;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-warning","aria-hidden":"true"}),e[20]=N):N=e[20];let w;e[21]!==i||e[22]!==o.sessionId?(w=()=>i(o.sessionId),e[21]=i,e[22]=o.sessionId,e[23]=w):w=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]!==w||e[28]!==I?(y=t.jsx("button",{type:"button",onClick:w,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]=w,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 D;e[32]!==o.since?(D=le(new Date(o.since).toISOString()),e[32]=o.since,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsxs("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-warning",children:["waiting ",D]}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==k||e[37]!==_||e[38]!==y?(S=t.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-[13px]",children:[N,y,k,_]}),e[36]=k,e[37]=_,e[38]=y,e[39]=S):S=e[39];const P=Ne[o.kind];let $;e[40]!==P?($=t.jsx("p",{className:"px-0.5 text-xs text-muted-foreground",children:P}),e[40]=P,e[41]=$):$=e[41];let M;e[42]!==o?(M=je(o),e[42]=o,e[43]=M):M=e[43];let E;e[44]!==x||e[45]!==o.sessionId?(E=x(o.sessionId),e[44]=x,e[45]=o.sessionId,e[46]=E):E=e[46];let C;e[47]!==i||e[48]!==o.sessionId?(C=()=>i(o.sessionId),e[47]=i,e[48]=o.sessionId,e[49]=C):C=e[49];let R;e[50]!==n||e[51]!==o||e[52]!==M||e[53]!==E||e[54]!==C?(R=t.jsx(Is,{request:o,input:n,canAnswer:E,onOpen:C},M),e[50]=n,e[51]=o,e[52]=M,e[53]=E,e[54]=C,e[55]=R):R=e[55];let K;e[56]!==S||e[57]!==$||e[58]!==R?(K=t.jsxs("div",{className:"flex flex-col gap-2",children:[S,$,R]}),e[56]=S,e[57]=$,e[58]=R,e[59]=K):K=e[59];let O;e[60]!==f||e[61]!==l||e[62]!==r||e[63]!==s?(O=s.length>1&&t.jsx("ol",{className:"mt-3 flex flex-col","aria-label":"Also waiting",children:s.map((q,T)=>T===f?null:t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>u(T),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:T+1}),t.jsxs("span",{className:"flex min-w-0 flex-col",children:[t.jsxs("span",{className:"truncate font-medium",children:[r(q.sessionId)??"A session",ce(l.get(q.sessionId),r)&&t.jsxs("span",{className:"font-normal text-muted-foreground",children:[" · ",ce(l.get(q.sessionId),r)]})]}),t.jsx("span",{className:"truncate text-[11.5px] text-muted-foreground",children:Ne[q.kind]})]}),t.jsx("span",{className:"text-[11px] tabular-nums text-warning",children:le(new Date(q.since).toISOString())})]})},je(q)))}),e[60]=f,e[61]=l,e[62]=r,e[63]=s,e[64]=O):O=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]!==p||e[67]!==K||e[68]!==O||e[69]!==v?(F=t.jsxs("section",{"aria-label":"Needs you",tabIndex:0,onKeyDown:p,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,K,O,z]}),e[66]=p,e[67]=K,e[68]=O,e[69]=v,e[70]=F):F=e[70],F}function Ts(c){var e,s;return c.state==="needs-you"||(((e=c.counts)==null?void 0:e.needsYou)??0)>0?pe.attention:c.state==="working"||(((s=c.counts)==null?void 0:s.working)??0)>0?pe.working:null}function Ls(c){const e=Y.c(39),{sessions:s,total:n,query:l,onQueryChange:r,searchRef:i,nameOf:x,projectLabel:a,onOpen:u,onRename:h,onBrowseProjects:d}=c;let f;e[0]!==l?(f=l.trim(),e[0]=l,e[1]=f):f=e[1];const o=f.length>0;let g;e[2]!==r||e[3]!==i?(g=()=>{var S;r(""),(S=i.current)==null||S.focus()},e[2]=r,e[3]=i,e[4]=g):g=e[4];const m=g,b=o?s.length:n;let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(ms,{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]=p):p=e[5];let j;e[6]!==r?(j=S=>r(S.target.value),e[6]=r,e[7]=j):j=e[7];let v;e[8]!==m||e[9]!==i?(v=S=>{var P;S.key==="Escape"&&(S.preventDefault(),m(),(P=i.current)==null||P.blur())},e[8]=m,e[9]=i,e[10]=v):v=e[10];let N;e[11]!==l||e[12]!==i||e[13]!==j||e[14]!==v?(N=t.jsx(ue,{ref:i,type:"search","aria-label":"Search sessions",placeholder:"Search sessions",value:l,onChange:j,onKeyDown:v,className:"h-7 pl-8 pr-7 text-xs [&::-webkit-search-cancel-button]:hidden"}),e[11]=l,e[12]=i,e[13]=j,e[14]=v,e[15]=N):N=e[15];let w;e[16]!==m||e[17]!==o?(w=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(xs,{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]=w):w=e[18];let I;e[19]!==N||e[20]!==w?(I=t.jsxs("div",{className:"relative w-full max-w-64",children:[p,N,w]}),e[19]=N,e[20]=w,e[21]=I):I=e[21];let y;e[22]!==d?(y=d&&t.jsxs(H,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:d,children:[t.jsx(xe,{"data-icon":"inline-start"}),"All projects"]}),e[22]=d,e[23]=y):y=e[23];let k;e[24]!==y||e[25]!==b||e[26]!==I?(k=t.jsxs(ke,{title:"Your sessions",count:b,children:[I,y]}),e[24]=y,e[25]=b,e[26]=I,e[27]=k):k=e[27];let D;e[28]!==x||e[29]!==u||e[30]!==h||e[31]!==a||e[32]!==l||e[33]!==o||e[34]!==s?(D=s.length===0?t.jsx(Ge,{children:t.jsx(Xe,{children:t.jsx(Je,{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(S=>t.jsx(Fs,{entry:S,nameOf:x,projectLabel:a,onOpen:u,onRename:h},S.session.sessionId))}),e[28]=x,e[29]=u,e[30]=h,e[31]=a,e[32]=l,e[33]=o,e[34]=s,e[35]=D):D=e[35];let _;return e[36]!==k||e[37]!==D?(_=t.jsxs("section",{"aria-label":"Your sessions",className:"flex min-w-0 flex-col lg:min-h-0 lg:flex-1",children:[k,D]}),e[36]=k,e[37]=D,e[38]=_):_=e[38],_}function Fs(c){const e=Y.c(63),{entry:s,nameOf:n,projectLabel:l,onOpen:r,onRename:i}=c,[x,a]=W.useState(null),{session:u}=s;let h;e[0]!==n||e[1]!==u.sessionId?(h=n(u.sessionId)??"Untitled session",e[0]=n,e[1]=u.sessionId,e[2]=h):h=e[2];const d=h;let f;e[3]!==u?(f=We(u),e[3]=u,e[4]=f):f=e[4];const o=f;let g,m,b;if(e[5]!==x||e[6]!==s||e[7]!==n||e[8]!==r||e[9]!==i||e[10]!==o||e[11]!==l||e[12]!==u||e[13]!==d){const v=Ts(s);let N;e[17]!==x||e[18]!==i||e[19]!==o||e[20]!==u.sessionId||e[21]!==d?(N=()=>{if(x===null)return;const C=x.trim();a(null),C!==d&&i(u.sessionId,C===o?"":C)},e[17]=x,e[18]=i,e[19]=o,e[20]=u.sessionId,e[21]=d,e[22]=N):N=e[22];const w=N;let I;e[23]!==s.counts||e[24]!==u.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"]})]}):u.isActive&&t.jsx("span",{children:"working"}),e[23]=s.counts,e[24]=u.isActive,e[25]=I):I=e[25];let y;e[26]!==I?(y=t.jsx("span",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:I}),e[26]=I,e[27]=y):y=e[27];let k;e[28]!==s.landed?(k=s.landed&&t.jsxs(Ze,{variant:"outline",className:"shrink-0",children:["#",s.landed.number]}),e[28]=s.landed,e[29]=k):k=e[29];let D;e[30]!==s.landed||e[31]!==n||e[32]!==u.lastUserMessage?(D=s.landed?`${s.landed.title??"Pull request"} · ${n(s.landed.by.sessionId)??""}`:u.lastUserMessage??"",e[30]=s.landed,e[31]=n,e[32]=u.lastUserMessage,e[33]=D):D=e[33];let _;e[34]!==D?(_=t.jsx("span",{className:"truncate",children:D}),e[34]=D,e[35]=_):_=e[35];let S;e[36]!==_||e[37]!==k?(S=t.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[k,_]}),e[36]=_,e[37]=k,e[38]=S):S=e[38];let P;e[39]!==s.activityAt||e[40]!==s.counts?(P=s.counts?`crew active ${le(s.activityAt)}`:le(s.activityAt),e[39]=s.activityAt,e[40]=s.counts,e[41]=P):P=e[41];let $;e[42]!==P?($=t.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:P}),e[42]=P,e[43]=$):$=e[43];let M;e[44]!==S||e[45]!==$||e[46]!==y?(M=t.jsxs(t.Fragment,{children:[y,S,$]}),e[44]=S,e[45]=$,e[46]=y,e[47]=M):M=e[47];const E=M;g="group/row relative border-t border-border/70 first:border-t-0",e[48]!==s.cells||e[49]!==s.members||e[50]!==n||e[51]!==r||e[52]!==d?(m=s.members.length>0&&t.jsx("div",{role:"group","aria-label":`${d} crew`,className:"flex flex-wrap gap-1 px-3 pt-3",children:s.members.map((C,R)=>t.jsx("button",{type:"button","aria-label":`Open ${n(C.sessionId)??"crew member"}`,title:`${n(C.sessionId)}: ${s.cells[R]}`,onClick:()=>r(C.sessionId),className:"flex size-5 items-center justify-center rounded-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx("span",{className:Z("size-2 rounded-[2px]",Es[s.cells[R]])})},C.sessionId))}),e[48]=s.cells,e[49]=s.members,e[50]=n,e[51]=r,e[52]=d,e[53]=m):m=e[53],b=x===null?t.jsxs("button",{type:"button",onClick:()=>r(u.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(u)})]}),E]}):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(ue,{autoFocus:!0,"aria-label":"Session name",value:x,placeholder:o,onChange:C=>a(C.target.value),onFocus:Bs,onBlur:w,onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),w()),C.key==="Escape"&&(C.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(u)})]}),E]}),e[5]=x,e[6]=s,e[7]=n,e[8]=r,e[9]=i,e[10]=o,e[11]=l,e[12]=u,e[13]=d,e[14]=g,e[15]=m,e[16]=b}else g=e[14],m=e[15],b=e[16];let p;e[54]!==x||e[55]!==s.members.length||e[56]!==d?(p=x===null&&t.jsx(H,{variant:"ghost",size:"icon-xs","aria-label":`Rename ${d}`,title:"Rename",onClick:()=>a(d),className:Z("absolute right-2 text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",s.members.length>0?"top-[42px]":"top-2.5"),children:t.jsx(fs,{"data-icon":"icon"})}),e[54]=x,e[55]=s.members.length,e[56]=d,e[57]=p):p=e[57];let j;return e[58]!==g||e[59]!==m||e[60]!==b||e[61]!==p?(j=t.jsxs("li",{className:g,children:[m,b,p]}),e[58]=g,e[59]=m,e[60]=b,e[61]=p,e[62]=j):j=e[62],j}function Bs(c){return c.target.select()}export{Gs as MissionHome};
@@ -1 +1 @@
1
- import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-DUfVcKxj.js";import"./vendor-ui-Dxtv9P3W.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=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{E as MobileFileChanges};
1
+ import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-DeMgVaXr.js";import"./vendor-ui-Cj1G8Clp.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=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{E as MobileFileChanges};
@@ -1 +1 @@
1
- import{c as ue,r as C,j as t}from"./vendor-react-gGw_S5I_.js";import{C as Z,b7 as Ie,bw as X,bE as Ze,bx as Re,bF as Xe,b5 as de,B as E,z as Fe,bG as et,bH as Ge,bI as Ke,bJ as Je,bK as We,bL as Qe,bM as Ye,A as se,p as ne,bN as tt,Z as $e,bO as st,bP as qe,a8 as nt,a9 as it,ac as lt,a6 as at,ab as ot,aa as rt,a5 as ct,a4 as dt,b6 as De,bQ as ut,bR as ft,D as ht,h as mt,i as pt,j as xt,k as gt,bS as jt,bT as bt,bU as vt,bV as Ae,bW as Oe,L as yt,M as Ct,N as wt,O as Nt,Q as St}from"./index-DUfVcKxj.js";import{a as kt,ar as $t}from"./vendor-ui-Dxtv9P3W.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Be(l){const e=l.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 Dt(l,e){if(l.length===0&&e.length===0)return 0;if(l.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(l.length,e.length);s+=1){const i=l[s],r=e[s];if(i===void 0)return-1;if(r===void 0)return 1;const a=/^\d+$/.test(i),n=/^\d+$/.test(r);if(a&&n){if(Number(i)!==Number(r))return Number(i)<Number(r)?-1:1;continue}if(a!==n)return a?-1:1;if(i!==r)return i<r?-1:1}return 0}function It(l,e){const s=Be(l),i=Be(e);if(!s||!i)return null;for(let r=0;r<3;r+=1)if(s.parts[r]!==i.parts[r])return s.parts[r]<i.parts[r]?-1:1;return Dt(s.prerelease,i.prerelease)}function Me(l){const e=ue.c(33),{value:s,onChange:i,projects:r,disabled:a}=l,n=a===void 0?!1:a,d=C.useId();let o;e[0]!==s.projectIds||e[1]!==s.type?(o=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=o):o=e[2];let v;e[3]!==o?(v=new Set(o),e[3]=o,e[4]=v):v=e[4];const y=v;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ze,{children:"Available in"}),e[5]=h):h=e[5];const w=`${d}-all`,j=s.type==="all";let c;e[6]!==i?(c=N=>i(N?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==n||e[9]!==w||e[10]!==j||e[11]!==c?(p=t.jsx(Ie,{id:w,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=w,e[10]=j,e[11]=c,e[12]=p):p=e[12];const m=`${d}-all`;let x;e[13]!==m?(x=t.jsx(X,{htmlFor:m,children:"All projects on this host, including new projects"}),e[13]=m,e[14]=x):x=e[14];let g;e[15]!==x||e[16]!==p?(g=t.jsxs(Z,{orientation:"horizontal",children:[p,x]}),e[15]=x,e[16]=p,e[17]=g):g=e[17];let b;e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==r||e[22]!==y||e[23]!==s.projectIds||e[24]!==s.type?(b=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:r.map(N=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-${N.id}`,checked:y.has(N.id),disabled:n,onCheckedChange:D=>i({type:"projects",projectIds:D?[...s.projectIds,N.id]:s.projectIds.filter(R=>R!==N.id)})}),t.jsx(X,{htmlFor:`${d}-${N.id}`,children:N.name})]},N.id))}),e[18]=n,e[19]=d,e[20]=i,e[21]=r,e[22]=y,e[23]=s.projectIds,e[24]=s.type,e[25]=b):b=e[25];const k=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 S;e[26]!==k?(S=t.jsx(Re,{children:k}),e[26]=k,e[27]=S):S=e[27];let u;return e[28]!==n||e[29]!==g||e[30]!==b||e[31]!==S?(u=t.jsxs(Xe,{disabled:n,children:[h,g,b,S]}),e[28]=n,e[29]=g,e[30]=b,e[31]=S,e[32]=u):u=e[32],u}function Rt(l){const e=ue.c(69),{client:s,run:i,busy:r}=l,a=C.useId(),[n,d]=C.useState(""),[o,v]=C.useState(""),[y,h]=C.useState(null),[w,j]=C.useState(""),[c,p]=C.useState(!1);let m;e[0]!==s||e[1]!==w||e[2]!==o||e[3]!==n||e[4]!==y||e[5]!==i?(m=Q=>{Q.preventDefault(),i(async()=>{var ce;if(!y||y.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((ce=globalThis.crypto)!=null&&ce.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const B=await y.arrayBuffer(),re=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",B)),Et).join("");if(re!==w.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:o,root:new TextDecoder("utf-8",{fatal:!0}).decode(B),fingerprint:re}),p(!1),d(""),v(""),j("")})},e[0]=s,e[1]=w,e[2]=o,e[3]=n,e[4]=y,e[5]=i,e[6]=m):m=e[6];const x=`${a}-name`;let g;e[7]!==x?(g=t.jsx(X,{htmlFor:x,children:"Development publisher"}),e[7]=x,e[8]=g):g=e[8];const b=`${a}-name`;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=Q=>d(Q.target.value),e[9]=k):k=e[9];let S;e[10]!==r||e[11]!==n||e[12]!==b?(S=t.jsx(de,{id:b,value:n,onChange:k,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:r}),e[10]=r,e[11]=n,e[12]=b,e[13]=S):S=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=u):u=e[14];let N;e[15]!==g||e[16]!==S?(N=t.jsxs(Z,{children:[g,S,u]}),e[15]=g,e[16]=S,e[17]=N):N=e[17];const D=`${a}-label`;let R;e[18]!==D?(R=t.jsx(X,{htmlFor:D,children:"Display name"}),e[18]=D,e[19]=R):R=e[19];const A=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Q=>v(Q.target.value),e[20]=O):O=e[20];let I;e[21]!==r||e[22]!==o||e[23]!==A?(I=t.jsx(de,{id:A,value:o,onChange:O,maxLength:100,required:!0,disabled:r}),e[21]=r,e[22]=o,e[23]=A,e[24]=I):I=e[24];let U;e[25]!==R||e[26]!==I?(U=t.jsxs(Z,{children:[R,I]}),e[25]=R,e[26]=I,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(X,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Q=>{var B;h(((B=Q.target.files)==null?void 0:B[0])??null),p(!1)},e[30]=G):G=e[30];let F;e[31]!==r||e[32]!==ee?(F=t.jsx(de,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:r}),e[31]=r,e[32]=ee,e[33]=F):F=e[33];let K;e[34]!==z||e[35]!==F?(K=t.jsxs(Z,{children:[z,F]}),e[34]=z,e[35]=F,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(X,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=Q=>{j(Q.target.value),p(!1)},e[39]=L):L=e[39];let M;e[40]!==r||e[41]!==w||e[42]!==J?(M=t.jsx(de,{id:J,value:w,onChange:L,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:r}),e[40]=r,e[41]=w,e[42]=J,e[43]=M):M=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=T):T=e[44];let V;e[45]!==_||e[46]!==M?(V=t.jsxs(Z,{children:[_,M,T]}),e[45]=_,e[46]=M,e[47]=V):V=e[47];const f=`${a}-trust`;let $;e[48]!==r||e[49]!==f||e[50]!==c?($=t.jsx(Ie,{id:f,checked:c,onCheckedChange:p,disabled:r}),e[48]=r,e[49]=f,e[50]=c,e[51]=$):$=e[51];const W=`${a}-trust`;let q;e[52]!==W?(q=t.jsx(X,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=q):q=e[53];let Y;e[54]!==$||e[55]!==q?(Y=t.jsxs(Z,{orientation:"horizontal",children:[$,q]}),e[54]=$,e[55]=q,e[56]=Y):Y=e[56];const ae=r||!c||!y;let ie;e[57]!==ae?(ie=t.jsx(E,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==V||e[62]!==Y||e[63]!==ie||e[64]!==N?(le=t.jsxs(Fe,{children:[N,U,K,V,Y,ie]}),e[59]=U,e[60]=K,e[61]=V,e[62]=Y,e[63]=ie,e[64]=N,e[65]=le):le=e[65];let oe;return e[66]!==m||e[67]!==le?(oe=t.jsx("form",{onSubmit:m,children:le}),e[66]=m,e[67]=le,e[68]=oe):oe=e[68],oe}function Et(l){return l.toString(16).padStart(2,"0")}const Pt={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Tt({client:l,preview:e,activation:s,key:i,onFrame:r,onComplete:a,onError:n}){const d=new AbortController;let o="loading",v,y=0;const h=()=>new Error("The installation check expired. Review the package again to retry.");function w(m){o==="canceled"||o==="finished"||(o="canceled",clearTimeout(v),d.abort(),r(null),n(m))}function j(){o==="canceled"||o==="finished"||(o="finished",clearTimeout(v),a())}async function c(m){if(o==="committing"){o="recovering",clearTimeout(v);try{const x=await l.transactionOutcome(e);if(o!=="recovering")return;x.status==="committed"?(await l.refresh(),o==="recovering"&&j()):w(m)}catch{o==="recovering"&&w(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function p(){if(o==="trial"){if(Date.now()>y){w(h());return}o="committing";try{await l.commit(e,d.signal),o==="committing"&&j()}catch(m){await c(m instanceof Error?m:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const m=await l.payload(e.transactionId,d.signal);if(d.signal.aborted||(y=await l.beginTrial(e,d.signal),d.signal.aborted))return;const x=y-Date.now();if(x<=0){w(h());return}o="trial",v=setTimeout(()=>{o==="committing"?(d.abort(),c(h())):o==="trial"&&w(h())},x),r({key:i,client:l,props:{payload:m,digest:e.digest,activationKey:i,context:Pt,active:!1,title:"Plugin installation check",execute:async(g,b)=>{if(d.signal.throwIfAborted(),b.throwIfAborted(),g.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{p()},onError:w}})}catch(m){w(m instanceof Error?m:new Error("Plugin trial failed"))}})(),()=>{o="canceled",clearTimeout(v),d.abort()}}function At(l){const e=ue.c(22),{client:s,preview:i,activation:r,onComplete:a,onError:n}=l,d=`${r}:trial:${i.transactionId}:${i.digest}:${i.registryRevision}`,[o,v]=C.useState(null);let y;e[0]!==a||e[1]!==n?(y={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=y):y=e[2];const h=C.useRef(y);let w;e[3]!==a||e[4]!==n?(w=()=>{h.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=w):w=e[5],C.useLayoutEffect(w);let j,c;e[6]!==r||e[7]!==s||e[8]!==d||e[9]!==i?(j=()=>Tt({client:s,preview:i,activation:r,key:d,onFrame:v,onComplete:()=>h.current.onComplete(),onError:g=>h.current.onError(g)}),c=[s,i,r,d],e[6]=r,e[7]=s,e[8]=d,e[9]=i,e[10]=j,e[11]=c):(j=e[10],c=e[11]),C.useLayoutEffect(j,c);let p;e[12]!==i.manifest.name?(p=t.jsxs("p",{children:["Checking that ",i.manifest.name," starts correctly…"]}),e[12]=i.manifest.name,e[13]=p):p=e[13];let m;e[14]!==r||e[15]!==s||e[16]!==o||e[17]!==d?(m=r&&(o==null?void 0:o.key)===d&&o.client===s&&t.jsx(et,{...o.props}),e[14]=r,e[15]=s,e[16]=o,e[17]=d,e[18]=m):m=e[18];let x;return e[19]!==p||e[20]!==m?(x=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[p,m]}),e[19]=p,e[20]=m,e[21]=x):x=e[21],x}function Ot({connection:l,resourceId:e,target:s,client:i,disabled:r,save:a}){const n=C.useId(),d=l.definition.resources[e],o=l.selected[e],[v,y]=C.useState(""),[h,w]=C.useState(null),[j,c]=C.useState(!1),[p,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>()=>{var u;return(u=x.current)==null?void 0:u.abort()},[]);const g=tt(l.definition,e).find(u=>!l.selected[u]),b=r||!!g||d.scope==="project"&&!s.projectId;async function k(){var N;(N=x.current)==null||N.abort();const u=new AbortController;x.current=u,c(!0),m(null);try{const D=await i.connectionOptions(s,l.id,e,u.signal);u.signal.aborted||w(D)}catch(D){u.signal.aborted||m(D instanceof Error?D.message:"Unable to load choices")}finally{u.signal.aborted||c(!1)}}const S=o&&!(h!=null&&h.some(u=>u.id===o.id))?[o,...h??[]]:h??[];return t.jsxs(Z,{"data-disabled":b,"data-invalid":!!p,children:[t.jsx(X,{htmlFor:`${n}-resource`,children:d.label}),t.jsx(Re,{children:d.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),o&&t.jsxs("p",{className:"text-sm",children:["Selected: ",o.label]}),g&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",l.definition.resources[g].label," first."]}),d.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),d.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"button",variant:"outline",size:"sm",disabled:b||j,onClick:()=>{k()},children:j?"Loading choices…":h?"Refresh choices":"Browse choices"}),h&&t.jsxs(Ye,{items:S.map(u=>({value:u.id,label:u.label})),value:(o==null?void 0:o.id)??null,disabled:b||j,onValueChange:u=>{u&&u!==(o==null?void 0:o.id)&&a(l.id,"select",{resourceId:e,value:u})},children:[t.jsx(Qe,{id:`${n}-resource`,"aria-invalid":!!p,children:t.jsx(We,{placeholder:`Choose ${d.label}`})}),t.jsx(Ge,{children:t.jsx(Ke,{children:S.map(u=>t.jsx(Je,{value:u.id,children:u.label},u.id))})})]}),(h==null?void 0:h.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),d.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{u.preventDefault(),a(l.id,"select",{resourceId:e,value:v.trim()})},children:[t.jsx(de,{id:d.options?`${n}-input`:`${n}-resource`,"aria-label":`${d.label} ${d.input.urls?"URL or ID":"ID"}`,value:v,onChange:u=>y(u.target.value),maxLength:2048,disabled:b,autoComplete:"off",spellCheck:!1,placeholder:d.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(E,{type:"submit",size:"sm",variant:"outline",disabled:b||!v.trim(),children:"Validate and select"})]}),o&&t.jsxs(E,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{a(l.id,"select",{resourceId:e,value:null})},children:["Clear ",d.label]}),p&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p})]})}function Ft(l){const e=ue.c(45),{connection:s,target:i,client:r,disabled:a,save:n}=l,d=C.useId(),[o,v]=C.useState(""),[y,h]=C.useState(!1),w=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 p;e[2]!==c?(p=t.jsx($e,{variant:"outline",children:c}),e[2]=c,e[3]=p):p=e[3];let m;e[4]!==j||e[5]!==p?(m=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,p]}),e[4]=j,e[5]=p,e[6]=m):m=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=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]=x):x=e[7];let g;e[8]!==s.definition.operations?(g=new Set(Object.values(s.definition.operations).map(_t)),e[8]=s.definition.operations,e[9]=g):g=e[9];let b;e[10]!==g?(b=[...g],e[10]=g,e[11]=b):b=e[11];const k=b.join(", ");let S;e[12]!==k?(S=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",k]}),e[12]=k,e[13]=S):S=e[13];let u;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==d||e[20]!==y||e[21]!==n?(u=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(Ie,{id:`${d}-replace`,checked:y,onCheckedChange:h,disabled:a}),t.jsx(X,{htmlFor:`${d}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:y})},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]=d,e[20]=y,e[21]=n,e[22]=u):u=e[22];let N;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==d||e[29]!==n||e[30]!==o?(N=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:A=>{A.preventDefault();const O=o.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Fe,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(X,{htmlFor:`${d}-secret`,children:s.definition.secret.label}),t.jsx(de,{id:`${d}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:o,onChange:A=>v(A.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"submit",size:"sm",disabled:a||!o.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(E,{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]=d,e[29]=n,e[30]=o,e[31]=N):N=e[31];let D;e[32]!==r||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==i?(D=s.status!=="disconnected"&&t.jsx(Fe,{children:Object.keys(s.definition.resources).map(A=>t.jsx(Ot,{connection:s,resourceId:A,target:i,client:r,disabled:a,save:n},A))}),e[32]=r,e[33]=s,e[34]=a,e[35]=n,e[36]=i,e[37]=D):D=e[37];let R;return e[38]!==s.label||e[39]!==S||e[40]!==u||e[41]!==N||e[42]!==D||e[43]!==m?(R=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":w,children:[m,x,S,u,N,D]}),e[38]=s.label,e[39]=S,e[40]=u,e[41]=N,e[42]=D,e[43]=m,e[44]=R):R=e[44],R}function _t(l){return l.origin}function zt({client:l,target:e}){const[s,i]=C.useState(null),[r,a]=C.useState(null),[n,d]=C.useState(!1),o=C.useRef(null),v=C.useRef(!1),y=e.pluginId,h=e.projectId;C.useEffect(()=>{const j=new AbortController;return o.current=j,l.connections({pluginId:y,projectId:h},j.signal).then(c=>{j.signal.aborted||i(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),o.current=null}},[l,y,h]);async function w(j,c,p){if(!s||v.current||!o.current||o.current.signal.aborted)return;v.current=!0;const m=o.current.signal;d(!0),a(null);try{const x=await l.changeConnection(e,j,c,p,s.revision,m);m.aborted||i(x)}catch(x){m.aborted||a(x instanceof Error?x.message:"Connection change failed")}finally{v.current=!1,m.aborted||d(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[r&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:r})}),!s&&!r&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Ft,{connection:j,target:e,client:l,disabled:n,save:w},`${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 Lt(l){const e=ue.c(32),{client:s,status:i,pluginId:r,initialProjectId:a}=l,[n,d]=C.useState(a),o=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let y;e[1]!==i.projects?(y=[v,...i.projects.map(Ut)],e[1]=i.projects,e[2]=y):y=e[2];const h=y;let w;e[3]!==o?(w=t.jsx(X,{htmlFor:o,children:"Project settings"}),e[3]=o,e[4]=w):w=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=R=>d(R||null),e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(We,{}),e[6]=p):p=e[6];let m;e[7]!==o?(m=t.jsx(Qe,{id:o,children:p}),e[7]=o,e[8]=m):m=e[8];let x;e[9]!==h?(x=t.jsx(Ge,{children:t.jsx(Ke,{children:h.map(Vt)})}),e[9]=h,e[10]=x):x=e[10];let g;e[11]!==h||e[12]!==j||e[13]!==m||e[14]!==x?(g=t.jsxs(Ye,{items:h,value:j,onValueChange:c,children:[m,x]}),e[11]=h,e[12]=j,e[13]=m,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==i.host.name?(b=t.jsxs(Re,{children:["Connection credentials belong to ",i.host.name,". Project resources stay within the project you choose."]}),e[16]=i.host.name,e[17]=b):b=e[17];let k;e[18]!==b||e[19]!==w||e[20]!==g?(k=t.jsxs(Z,{children:[w,g,b]}),e[18]=b,e[19]=w,e[20]=g,e[21]=k):k=e[21];const S=`${r}:${n??"host"}:${i.connectionRevision??0}`;let u;e[22]!==r||e[23]!==n?(u={pluginId:r,projectId:n},e[22]=r,e[23]=n,e[24]=u):u=e[24];let N;e[25]!==s||e[26]!==S||e[27]!==u?(N=t.jsx(zt,{client:s,target:u},S),e[25]=s,e[26]=S,e[27]=u,e[28]=N):N=e[28];let D;return e[29]!==k||e[30]!==N?(D=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,N]}),e[29]=k,e[30]=N,e[31]=D):D=e[31],D}function Vt(l){return t.jsx(Je,{value:l.value,children:l.label},l.value)}function Ut(l){return{value:l.id,label:l.name}}function Mt(l){var ie;const e=ue.c(174),{plugin:s,status:i,client:r,busy:a,run:n,onPreview:d,onConnections:o,onUpdate:v}=l,y=C.useId(),[h,w]=C.useState(s.scope),[j,c]=C.useState(!1),[p,m]=C.useState(!1);let x,g,b,k,S,u,N,D,R,A,O,I;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==d||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==h||e[8]!==i.host.name||e[9]!==i.projects||e[10]!==i.runtime||e[11]!==i.store){const le=st(),oe=qe(s.manifest,le,i.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Q;e[24]!==r||e[25]!==s.id||e[26]!==n||e[27]!==i.store?(Q=(P,Te)=>n(()=>r.changeInstalled(s.id,P,Te,i.store.revision)),e[24]=r,e[25]=s.id,e[26]=n,e[27]=i.store,e[28]=Q):Q=e[28];const B=Q,re=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let ce;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==i.store?(ce=s.lastError&&((ie=i.store.availableSeeds)==null?void 0:ie.find(P=>P.manifest.id===s.id&&P.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=i.store,e[33]=ce):ce=e[33];const _e=ce;A="flex flex-col gap-3 rounded-lg border p-4";let fe;e[34]!==s.manifest.name?(fe=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=fe):fe=e[35];let he;e[36]!==s.id||e[37]!==s.manifest.version?(he=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]=he):he=e[38];let me;e[39]!==fe||e[40]!==he?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[fe,he]}),e[39]=fe,e[40]=he,e[41]=me):me=e[41];const ze=re==="Enabled"?"secondary":"outline";let pe;e[42]!==re||e[43]!==ze?(pe=t.jsx($e,{variant:ze,children:re}),e[42]=re,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==me||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,pe]}),e[45]=me,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(I=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=I):I=e[49],g=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(P=>t.jsxs("p",{children:[P.side==="client"?"This client":P.side==="host"?i.host.name:"This package",": ",P.name," requires ",P.required,"; available ",P.actual??"none","."]},`${P.side}:${P.code}:${P.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]!==B||e[51]!==s.enabled?(xe=()=>B("enabled",{enabled:!s.enabled}),e[50]=B,e[51]=s.enabled,e[52]=xe):xe=e[52];const Le=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Le?(ge=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Le}),e[53]=a,e[54]=xe,e[55]=Le,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==o||e[59]!==s.id||e[60]!==s.manifest.permissions.connections.length?(je=s.manifest.permissions.connections.length>0&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>o(s.id),children:"Connections"}),e[57]=a,e[58]=o,e[59]=s.id,e[60]=s.manifest.permissions.connections.length,e[61]=je):je=e[61];const Ve=a||s.pinned;let be;e[62]!==v||e[63]!==s?(be=()=>v(s),e[62]=v,e[63]=s,e[64]=be):be=e[64];let ve;e[65]!==Ve||e[66]!==be?(ve=t.jsx(E,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[65]=Ve,e[66]=be,e[67]=ve):ve=e[67];let ye;e[68]!==a||e[69]!==r||e[70]!==d||e[71]!==s.id||e[72]!==s.scope||e[73]!==_e||e[74]!==n?(ye=_e&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>d(await r.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[68]=a,e[69]=r,e[70]=d,e[71]=s.id,e[72]=s.scope,e[73]=_e,e[74]=n,e[75]=ye):ye=e[75];let Ce;e[76]!==B||e[77]!==s.pinned?(Ce=()=>B("pin",{pinned:!s.pinned}),e[76]=B,e[77]=s.pinned,e[78]=Ce):Ce=e[78];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[79]!==a||e[80]!==Ce||e[81]!==Ue?(we=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[79]=a,e[80]=Ce,e[81]=Ue,e[82]=we):we=e[82];let Ee;e[83]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{m(!1),c(!0)},e[83]=Ee):Ee=e[83];let Ne;e[84]!==a?(Ne=t.jsx(E,{size:"sm",variant:"ghost",disabled:a,onClick:Ee,children:"Uninstall"}),e[84]=a,e[85]=Ne):Ne=e[85],e[86]!==ge||e[87]!==je||e[88]!==ve||e[89]!==ye||e[90]!==we||e[91]!==Ne?(b=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Ne]}),e[86]=ge,e[87]=je,e[88]=ve,e[89]=ye,e[90]=we,e[91]=Ne,e[92]=b):b=e[92],e[93]!==s.pinned?(k=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[93]=s.pinned,e[94]=k):k=e[94],D="text-sm",e[95]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[95]=R):R=e[95],x="flex flex-col gap-4 pt-4",e[96]!==a||e[97]!==h||e[98]!==i.projects?(S=t.jsx(Me,{value:h,onChange:w,projects:i.projects,disabled:a}),e[96]=a,e[97]=h,e[98]=i.projects,e[99]=S):S=e[99];let Se;e[100]!==a||e[101]!==s.scope||e[102]!==h?(Se=a||JSON.stringify(h)===JSON.stringify(s.scope),e[100]=a,e[101]=s.scope,e[102]=h,e[103]=Se):Se=e[103];let ke;e[104]!==B||e[105]!==h?(ke=()=>B("scope",{scope:h}),e[104]=B,e[105]=h,e[106]=ke):ke=e[106],e[107]!==i.host.name||e[108]!==Se||e[109]!==ke?(u=t.jsxs(E,{size:"sm",variant:"outline",disabled:Se,onClick:ke,children:["Save projects on ",i.host.name]}),e[107]=i.host.name,e[108]=Se,e[109]=ke,e[110]=u):u=e[110];let Pe;e[111]!==s.selectedDigest?(Pe=P=>P.digest!==s.selectedDigest,e[111]=s.selectedDigest,e[112]=Pe):Pe=e[112],N=s.versions.filter(Pe).map(P=>{const Te=!P.unavailableReason&&qe(P.manifest,le,i.runtime,{allowPrerelease:P.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(E,{size:"sm",variant:"outline",disabled:a||s.pinned||!Te,onClick:()=>n(async()=>d({...await r.rollback(s.id,P.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",P.manifest.version]}),!Te&&t.jsx("p",{className:"text-xs text-muted-foreground",children:P.unavailableReason??"This version is incompatible with the connected host or client."})]},P.digest)}),e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=v,e[5]=s,e[6]=n,e[7]=h,e[8]=i.host.name,e[9]=i.projects,e[10]=i.runtime,e[11]=i.store,e[12]=x,e[13]=g,e[14]=b,e[15]=k,e[16]=S,e[17]=u,e[18]=N,e[19]=D,e[20]=R,e[21]=A,e[22]=O,e[23]=I}else x=e[12],g=e[13],b=e[14],k=e[15],S=e[16],u=e[17],N=e[18],D=e[19],R=e[20],A=e[21],O=e[22],I=e[23];let U;e[113]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[113]=U):U=e[113];let H;e[114]!==x||e[115]!==S||e[116]!==u||e[117]!==N?(H=t.jsxs("div",{className:x,children:[S,u,N,U]}),e[114]=x,e[115]=S,e[116]=u,e[117]=N,e[118]=H):H=e[118];let z;e[119]!==H||e[120]!==D||e[121]!==R?(z=t.jsxs("details",{className:D,children:[R,H]}),e[119]=H,e[120]=D,e[121]=R,e[122]=z):z=e[122];let ee;e[123]!==s.manifest.name?(ee=t.jsxs(nt,{children:["Uninstall ",s.manifest.name,"?"]}),e[123]=s.manifest.name,e[124]=ee):ee=e[124];let G;e[125]!==i.host.name?(G=t.jsxs(it,{children:["This removes the plugin from ",i.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[125]=i.host.name,e[126]=G):G=e[126];let F;e[127]!==ee||e[128]!==G?(F=t.jsxs(at,{children:[ee,G]}),e[127]=ee,e[128]=G,e[129]=F):F=e[129];const K=`${y}-delete`,te=a||i.connectionRevision===void 0;let _;e[130]!==p||e[131]!==K||e[132]!==te?(_=t.jsx(Ie,{id:K,checked:p,onCheckedChange:m,disabled:te}),e[130]=p,e[131]=K,e[132]=te,e[133]=_):_=e[133];const J=`${y}-delete`;let L;e[134]!==J?(L=t.jsx(X,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[134]=J,e[135]=L):L=e[135];let M;e[136]!==_||e[137]!==L?(M=t.jsxs(Z,{orientation:"horizontal",children:[_,L]}),e[136]=_,e[137]=L,e[138]=M):M=e[138];let T;e[139]!==p?(T=p&&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[139]=p,e[140]=T):T=e[140];let V;e[141]!==a?(V=t.jsx(ot,{disabled:a,children:"Cancel"}),e[141]=a,e[142]=V):V=e[142];let f;e[143]!==r||e[144]!==p||e[145]!==s.id||e[146]!==n||e[147]!==i.connectionRevision||e[148]!==i.store?(f=()=>{c(!1),n(()=>r.changeInstalled(s.id,"uninstall",p?{deleteData:!0,expectedConnectionRevision:i.connectionRevision}:{deleteData:!1},i.store.revision))},e[143]=r,e[144]=p,e[145]=s.id,e[146]=n,e[147]=i.connectionRevision,e[148]=i.store,e[149]=f):f=e[149];let $;e[150]!==a||e[151]!==i.host.name||e[152]!==f?($=t.jsxs(lt,{variant:"destructive",disabled:a,onClick:f,children:["Uninstall from ",i.host.name]}),e[150]=a,e[151]=i.host.name,e[152]=f,e[153]=$):$=e[153];let W;e[154]!==V||e[155]!==$?(W=t.jsxs(rt,{children:[V,$]}),e[154]=V,e[155]=$,e[156]=W):W=e[156];let q;e[157]!==F||e[158]!==M||e[159]!==T||e[160]!==W?(q=t.jsxs(ct,{children:[F,M,T,W]}),e[157]=F,e[158]=M,e[159]=T,e[160]=W,e[161]=q):q=e[161];let Y;e[162]!==j||e[163]!==q?(Y=t.jsx(dt,{open:j,onOpenChange:c,children:q}),e[162]=j,e[163]=q,e[164]=Y):Y=e[164];let ae;return e[165]!==g||e[166]!==b||e[167]!==k||e[168]!==z||e[169]!==Y||e[170]!==A||e[171]!==O||e[172]!==I?(ae=t.jsxs("article",{className:A,children:[O,I,g,b,k,z,Y]}),e[165]=g,e[166]=b,e[167]=k,e[168]=z,e[169]=Y,e[170]=A,e[171]=O,e[172]=I,e[173]=ae):ae=e[173],ae}const qt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Bt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function Ht(l,e){return 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":`Read ${qt[l]} ${Bt[e]} using this host's signed-in CLI`}function He(l){const e=l.permissions;return[...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(()=>"Append text to your draft message"),...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`]:[],...e.connections.flatMap(s=>s.operations.map(i=>`Use connection ${s.id}: ${i}`)),...e.integrations.flatMap(s=>s.operations.map(i=>Ht(s.id,i)))]}function Gt(l){var j;const e=ue.c(32),{preview:s}=l;let i,r,a,n,d,o;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=He(s.manifest),p=s.previousManifest?He(s.previousManifest):null,m=p?c.filter(b=>!p.includes(b)):[],x=p?p.filter(b=>!c.includes(b)):[],g=s.previousConnectionDefinitions?s.connectionDefinitions.filter(b=>{var S;const k=(S=s.previousConnectionDefinitions)==null?void 0:S.find(u=>u.id===b.id);return!k||JSON.stringify(k)!==JSON.stringify(b)}):[];i="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(r=s.oldVersion&&t.jsxs(se,{children:[t.jsx(De,{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]=r):r=e[14],a=p&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),m.length===0&&x.length===0&&g.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),m.map(Xt),x.map(Zt),g.map(Yt)]}),n=s.oldVersion&&!p&&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")?(d=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=d):d=e[15],o=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(Qt)}):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]=i,e[7]=r,e[8]=a,e[9]=n,e[10]=d,e[11]=o}else i=e[6],r=e[7],a=e[8],n=e[9],d=e[10],o=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Kt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let y;e[18]!==s.incompatibleClients?(y=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(De,{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]=y):y=e[19];let h;e[20]!==s.digest?(h=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=h):h=e[21];let w;return e[22]!==i||e[23]!==r||e[24]!==a||e[25]!==n||e[26]!==d||e[27]!==o||e[28]!==v||e[29]!==y||e[30]!==h?(w=t.jsxs("div",{className:i,children:[r,a,n,d,o,v,y,h]}),e[22]=i,e[23]=r,e[24]=a,e[25]=n,e[26]=d,e[27]=o,e[28]=v,e[29]=y,e[30]=h,e[31]=w):w=e[31],w}function Kt(l){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:l.label}),t.jsxs("p",{children:["Access to ",Object.values(l.resources).map(Wt).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(l.operations).map(Jt))].join(", ")]})]},l.id)}function Jt(l){return l.origin}function Wt(l){return l.label}function Qt(l){return t.jsx("li",{children:l},l)}function Yt(l){return t.jsxs("p",{children:["Changed connection: ",l.label,". Review its destinations and access below."]},l.id)}function Zt(l){return t.jsxs("p",{children:["Removed: ",l]},`remove:${l}`)}function Xt(l){return t.jsxs("p",{children:["Added: ",l]},`add:${l}`)}function ls({client:l,state:e,currentPath:s,onClose:i,initialPluginId:r}){var V;const a=C.useId(),n=e.status,d=ut(),o=(n==null?void 0:n.safeMode)||d,{project:v,resolving:y}=ft({client:l,status:n,activation:e.activation,projectPath:s}),[h,w]=C.useState(null),j=h??{type:"projects",projectIds:v?[v.id]:[]},[c,p]=C.useState(null),[m,x]=C.useState({activation:"",hostName:""}),[g,b]=C.useState(!1),[k,S]=C.useState(!1),[u,N]=C.useState(null),[D,R]=C.useState(null),[A,O]=C.useState("installed"),[I,U]=C.useState(null),[H,z]=C.useState(null),[ee,G]=C.useState(r),F=n==null?void 0:n.store.plugins.find(f=>f.id===ee),K=C.useRef(!1),te=!!(n!=null&&n.store.available)&&m.activation===e.activation;function _(f){x({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),p(f)}C.useEffect(()=>{!c||te&&!(o&&g)||(b(!1),p(null),N("The host connection or plugin execution state changed. Review the package again before installing."),l.cancel(c).catch(()=>{}))},[l,c,te,o,g]),C.useEffect(()=>()=>{c&&l.cancel(c).catch(()=>{})},[l,c]);async function J(f){if(!K.current){K.current=!0,S(!0),N(null),R(null);try{await f()}catch($){N($ instanceof Error?$.message:"Plugin action failed")}finally{K.current=!1,S(!1)}}}function L(){const f=c;b(!1),p(null),f&&l.cancel(f).catch(()=>{})}async function M(){if(!H||!I&&!h&&y)return;const f=await l.stage(H,(I==null?void 0:I.scope)??j);if(I&&f.manifest.id!==I.id)throw await l.cancel(f),new Error(`Choose a package for ${I.manifest.name} (${I.id}).`);_(f)}const T=k||g||!(n!=null&&n.store.available);return t.jsx(ht,{open:!0,onOpenChange:f=>{!f&&!k&&!g&&(L(),i())},children:t.jsxs(mt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!k&&!g,children:[t.jsxs(pt,{children:[t.jsx(xt,{children:"Plugins"}),t.jsx(gt,{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||u||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:n!=null&&n.store.available&&!u&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:u??e.error??(n==null?void 0:n.store.error)})]}),D&&t.jsx(se,{children:t.jsx(ne,{children:D})}),o&&t.jsxs(se,{children:[t.jsx(De,{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(E,{size:"sm",variant:"outline",disabled:k||g||(n==null?void 0:n.safeMode),onClick:()=>jt(!d),children:d?"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(E,{variant:"outline",disabled:k,onClick:()=>{J(()=>l.refresh())},children:[t.jsx(kt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&F&&!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.jsxs("h2",{className:"font-medium",children:[F.manifest.name," connections"]}),t.jsx(E,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),t.jsx(Lt,{client:l,status:n,pluginId:F.id,initialProjectId:(v==null?void 0:v.id)??null},`${F.id}:${n.store.revision}`)]}),n&&!F&&!c&&t.jsxs(bt,{value:A,onValueChange:f=>{O(String(f)),U(null),z(null)},children:[t.jsxs(vt,{className:"h-auto flex-wrap",children:[t.jsx(Ae,{value:"installed",children:"Installed"}),t.jsx(Ae,{value:"browse",children:"Browse"}),t.jsx(Ae,{value:"install",children:"Install from file"}),t.jsx(Ae,{value:"publishers",children:"Publishers"})]}),t.jsx(Oe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(f=>t.jsx(Mt,{plugin:f,status:n,client:l,busy:T,run:$=>{J($)},onPreview:_,onConnections:G,onUpdate:$=>{U($),z(null),O("install")}},`${f.id}:${n.store.revision}`)):t.jsx(yt,{children:t.jsxs(Ct,{children:[t.jsx(wt,{variant:"icon",children:t.jsx($t,{})}),t.jsx(Nt,{children:"No installed plugins"}),t.jsx(St,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Oe,{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(Me,{value:j,onChange:w,projects:n.projects,disabled:T}),(n.store.availableSeeds??[]).map(f=>{const $=n.store.plugins.find(q=>q.id===f.manifest.id),W=$&&It(f.manifest.version,$.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:f.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.manifest.version," · ",f.manifest.publisher]})]}),W?t.jsx(E,{size:"sm",disabled:T||$.pinned,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,$.scope)))},children:$.pinned?"Pinned to installed version":"Review update"}):$?t.jsx($e,{variant:"outline",children:"Installed"}):t.jsx(E,{size:"sm",disabled:T||!h&&y,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,j)))},children:"Review installation"})]},f.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(Oe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:f=>{f.preventDefault(),J(M)},children:t.jsxs(Fe,{children:[I&&t.jsxs("p",{className:"text-sm",children:["Update ",I.manifest.name," from ",I.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(X,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(de,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:T,required:!0,onChange:f=>{var $;return z((($=f.target.files)==null?void 0:$[0])??null)}})]}),!I&&t.jsx(Me,{value:j,onChange:w,projects:n.projects,disabled:T}),t.jsxs(E,{type:"submit",disabled:T||!H||!I&&!h&&y,children:["Review ",I?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Oe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(f=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[f.label," ",t.jsx($e,{variant:"outline",children:f.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[f.id," · ",f.fingerprint]})]},f.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(Rt,{client:l,busy:T,run:f=>{J(f)}})})]})]})})]}),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 ",m.hostName]}),t.jsx($e,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Gt,{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(f=>{var $;return(($=n==null?void 0:n.projects.find(W=>W.id===f))==null?void 0:$.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(f=>t.jsxs("li",{children:[f.side,": ",f.name," requires ",f.required,"; available ",f.actual??"none","."]},`${f.side}:${f.code}:${f.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(f=>f.name).join(", "),"."]})}),g&&te&&!o?t.jsxs(t.Fragment,{children:[t.jsx(At,{client:l,preview:c,activation:e.activation,onComplete:()=>{b(!1),p(null),R(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${m.hostName}.`),O("installed"),U(null)},onError:f=>{N(f.message),L()}}),t.jsxs(E,{variant:"outline",onClick:L,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(E,{variant:"outline",disabled:k,onClick:L,children:"Cancel"}),t.jsxs(E,{disabled:T||!te||!c.compatibility.compatible||o,onClick:()=>{N(null),b(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",m.hostName]})]})]})]})]})})}export{ls as PluginsDialog};
1
+ import{c as ue,r as C,j as t}from"./vendor-react-gGw_S5I_.js";import{C as Q,bf as Ie,b6 as X,c2 as Qe,b7 as Re,c3 as Xe,bb as de,B as E,z as _e,c4 as et,c5 as Ge,c6 as Ke,c7 as Je,c8 as We,c9 as Ye,ca as Ze,A as se,p as ne,cb as tt,Z as $e,cc as st,cd as Me,a9 as nt,aa as it,ad as lt,a7 as at,ac as ot,ab as rt,a6 as ct,a5 as dt,b0 as De,ce as ut,cf as ft,D as ht,h as mt,i as pt,j as xt,k as gt,cg as jt,bX as bt,bY as vt,bZ as Ae,b_ as Oe,L as yt,M as Ct,N as wt,O as Nt,Q as St}from"./index-DeMgVaXr.js";import{a as kt,av as $t}from"./vendor-ui-Cj1G8Clp.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Be(l){const e=l.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 Dt(l,e){if(l.length===0&&e.length===0)return 0;if(l.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(l.length,e.length);s+=1){const i=l[s],r=e[s];if(i===void 0)return-1;if(r===void 0)return 1;const a=/^\d+$/.test(i),n=/^\d+$/.test(r);if(a&&n){if(Number(i)!==Number(r))return Number(i)<Number(r)?-1:1;continue}if(a!==n)return a?-1:1;if(i!==r)return i<r?-1:1}return 0}function It(l,e){const s=Be(l),i=Be(e);if(!s||!i)return null;for(let r=0;r<3;r+=1)if(s.parts[r]!==i.parts[r])return s.parts[r]<i.parts[r]?-1:1;return Dt(s.prerelease,i.prerelease)}function qe(l){const e=ue.c(33),{value:s,onChange:i,projects:r,disabled:a}=l,n=a===void 0?!1:a,d=C.useId();let o;e[0]!==s.projectIds||e[1]!==s.type?(o=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=o):o=e[2];let v;e[3]!==o?(v=new Set(o),e[3]=o,e[4]=v):v=e[4];const y=v;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Qe,{children:"Available in"}),e[5]=h):h=e[5];const w=`${d}-all`,j=s.type==="all";let c;e[6]!==i?(c=N=>i(N?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==n||e[9]!==w||e[10]!==j||e[11]!==c?(p=t.jsx(Ie,{id:w,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=w,e[10]=j,e[11]=c,e[12]=p):p=e[12];const m=`${d}-all`;let x;e[13]!==m?(x=t.jsx(X,{htmlFor:m,children:"All projects on this host, including new projects"}),e[13]=m,e[14]=x):x=e[14];let g;e[15]!==x||e[16]!==p?(g=t.jsxs(Q,{orientation:"horizontal",children:[p,x]}),e[15]=x,e[16]=p,e[17]=g):g=e[17];let b;e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==r||e[22]!==y||e[23]!==s.projectIds||e[24]!==s.type?(b=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:r.map(N=>t.jsxs(Q,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-${N.id}`,checked:y.has(N.id),disabled:n,onCheckedChange:D=>i({type:"projects",projectIds:D?[...s.projectIds,N.id]:s.projectIds.filter(R=>R!==N.id)})}),t.jsx(X,{htmlFor:`${d}-${N.id}`,children:N.name})]},N.id))}),e[18]=n,e[19]=d,e[20]=i,e[21]=r,e[22]=y,e[23]=s.projectIds,e[24]=s.type,e[25]=b):b=e[25];const k=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 S;e[26]!==k?(S=t.jsx(Re,{children:k}),e[26]=k,e[27]=S):S=e[27];let u;return e[28]!==n||e[29]!==g||e[30]!==b||e[31]!==S?(u=t.jsxs(Xe,{disabled:n,children:[h,g,b,S]}),e[28]=n,e[29]=g,e[30]=b,e[31]=S,e[32]=u):u=e[32],u}function Rt(l){const e=ue.c(69),{client:s,run:i,busy:r}=l,a=C.useId(),[n,d]=C.useState(""),[o,v]=C.useState(""),[y,h]=C.useState(null),[w,j]=C.useState(""),[c,p]=C.useState(!1);let m;e[0]!==s||e[1]!==w||e[2]!==o||e[3]!==n||e[4]!==y||e[5]!==i?(m=Y=>{Y.preventDefault(),i(async()=>{var ce;if(!y||y.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((ce=globalThis.crypto)!=null&&ce.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const B=await y.arrayBuffer(),re=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",B)),Et).join("");if(re!==w.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:o,root:new TextDecoder("utf-8",{fatal:!0}).decode(B),fingerprint:re}),p(!1),d(""),v(""),j("")})},e[0]=s,e[1]=w,e[2]=o,e[3]=n,e[4]=y,e[5]=i,e[6]=m):m=e[6];const x=`${a}-name`;let g;e[7]!==x?(g=t.jsx(X,{htmlFor:x,children:"Development publisher"}),e[7]=x,e[8]=g):g=e[8];const b=`${a}-name`;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>d(Y.target.value),e[9]=k):k=e[9];let S;e[10]!==r||e[11]!==n||e[12]!==b?(S=t.jsx(de,{id:b,value:n,onChange:k,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:r}),e[10]=r,e[11]=n,e[12]=b,e[13]=S):S=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=u):u=e[14];let N;e[15]!==g||e[16]!==S?(N=t.jsxs(Q,{children:[g,S,u]}),e[15]=g,e[16]=S,e[17]=N):N=e[17];const D=`${a}-label`;let R;e[18]!==D?(R=t.jsx(X,{htmlFor:D,children:"Display name"}),e[18]=D,e[19]=R):R=e[19];const A=`${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 I;e[21]!==r||e[22]!==o||e[23]!==A?(I=t.jsx(de,{id:A,value:o,onChange:O,maxLength:100,required:!0,disabled:r}),e[21]=r,e[22]=o,e[23]=A,e[24]=I):I=e[24];let U;e[25]!==R||e[26]!==I?(U=t.jsxs(Q,{children:[R,I]}),e[25]=R,e[26]=I,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(X,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var B;h(((B=Y.target.files)==null?void 0:B[0])??null),p(!1)},e[30]=G):G=e[30];let _;e[31]!==r||e[32]!==ee?(_=t.jsx(de,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:r}),e[31]=r,e[32]=ee,e[33]=_):_=e[33];let K;e[34]!==z||e[35]!==_?(K=t.jsxs(Q,{children:[z,_]}),e[34]=z,e[35]=_,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let F;e[37]!==te?(F=t.jsx(X,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=F):F=e[38];const J=`${a}-fingerprint`;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=Y=>{j(Y.target.value),p(!1)},e[39]=L):L=e[39];let q;e[40]!==r||e[41]!==w||e[42]!==J?(q=t.jsx(de,{id:J,value:w,onChange:L,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:r}),e[40]=r,e[41]=w,e[42]=J,e[43]=q):q=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=T):T=e[44];let V;e[45]!==F||e[46]!==q?(V=t.jsxs(Q,{children:[F,q,T]}),e[45]=F,e[46]=q,e[47]=V):V=e[47];const f=`${a}-trust`;let $;e[48]!==r||e[49]!==f||e[50]!==c?($=t.jsx(Ie,{id:f,checked:c,onCheckedChange:p,disabled:r}),e[48]=r,e[49]=f,e[50]=c,e[51]=$):$=e[51];const W=`${a}-trust`;let M;e[52]!==W?(M=t.jsx(X,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=M):M=e[53];let Z;e[54]!==$||e[55]!==M?(Z=t.jsxs(Q,{orientation:"horizontal",children:[$,M]}),e[54]=$,e[55]=M,e[56]=Z):Z=e[56];const ae=r||!c||!y;let ie;e[57]!==ae?(ie=t.jsx(E,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==V||e[62]!==Z||e[63]!==ie||e[64]!==N?(le=t.jsxs(_e,{children:[N,U,K,V,Z,ie]}),e[59]=U,e[60]=K,e[61]=V,e[62]=Z,e[63]=ie,e[64]=N,e[65]=le):le=e[65];let oe;return e[66]!==m||e[67]!==le?(oe=t.jsx("form",{onSubmit:m,children:le}),e[66]=m,e[67]=le,e[68]=oe):oe=e[68],oe}function Et(l){return l.toString(16).padStart(2,"0")}const Pt={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Tt({client:l,preview:e,activation:s,key:i,onFrame:r,onComplete:a,onError:n}){const d=new AbortController;let o="loading",v,y=0;const h=()=>new Error("The installation check expired. Review the package again to retry.");function w(m){o==="canceled"||o==="finished"||(o="canceled",clearTimeout(v),d.abort(),r(null),n(m))}function j(){o==="canceled"||o==="finished"||(o="finished",clearTimeout(v),a())}async function c(m){if(o==="committing"){o="recovering",clearTimeout(v);try{const x=await l.transactionOutcome(e);if(o!=="recovering")return;x.status==="committed"?(await l.refresh(),o==="recovering"&&j()):w(m)}catch{o==="recovering"&&w(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function p(){if(o==="trial"){if(Date.now()>y){w(h());return}o="committing";try{await l.commit(e,d.signal),o==="committing"&&j()}catch(m){await c(m instanceof Error?m:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const m=await l.payload(e.transactionId,d.signal);if(d.signal.aborted||(y=await l.beginTrial(e,d.signal),d.signal.aborted))return;const x=y-Date.now();if(x<=0){w(h());return}o="trial",v=setTimeout(()=>{o==="committing"?(d.abort(),c(h())):o==="trial"&&w(h())},x),r({key:i,client:l,props:{payload:m,digest:e.digest,activationKey:i,context:Pt,active:!1,title:"Plugin installation check",execute:async(g,b)=>{if(d.signal.throwIfAborted(),b.throwIfAborted(),g.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{p()},onError:w}})}catch(m){w(m instanceof Error?m:new Error("Plugin trial failed"))}})(),()=>{o="canceled",clearTimeout(v),d.abort()}}function At(l){const e=ue.c(22),{client:s,preview:i,activation:r,onComplete:a,onError:n}=l,d=`${r}:trial:${i.transactionId}:${i.digest}:${i.registryRevision}`,[o,v]=C.useState(null);let y;e[0]!==a||e[1]!==n?(y={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=y):y=e[2];const h=C.useRef(y);let w;e[3]!==a||e[4]!==n?(w=()=>{h.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=w):w=e[5],C.useLayoutEffect(w);let j,c;e[6]!==r||e[7]!==s||e[8]!==d||e[9]!==i?(j=()=>Tt({client:s,preview:i,activation:r,key:d,onFrame:v,onComplete:()=>h.current.onComplete(),onError:g=>h.current.onError(g)}),c=[s,i,r,d],e[6]=r,e[7]=s,e[8]=d,e[9]=i,e[10]=j,e[11]=c):(j=e[10],c=e[11]),C.useLayoutEffect(j,c);let p;e[12]!==i.manifest.name?(p=t.jsxs("p",{children:["Checking that ",i.manifest.name," starts correctly…"]}),e[12]=i.manifest.name,e[13]=p):p=e[13];let m;e[14]!==r||e[15]!==s||e[16]!==o||e[17]!==d?(m=r&&(o==null?void 0:o.key)===d&&o.client===s&&t.jsx(et,{...o.props}),e[14]=r,e[15]=s,e[16]=o,e[17]=d,e[18]=m):m=e[18];let x;return e[19]!==p||e[20]!==m?(x=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[p,m]}),e[19]=p,e[20]=m,e[21]=x):x=e[21],x}function Ot({connection:l,resourceId:e,target:s,client:i,disabled:r,save:a}){const n=C.useId(),d=l.definition.resources[e],o=l.selected[e],[v,y]=C.useState(""),[h,w]=C.useState(null),[j,c]=C.useState(!1),[p,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>()=>{var u;return(u=x.current)==null?void 0:u.abort()},[]);const g=tt(l.definition,e).find(u=>!l.selected[u]),b=r||!!g||d.scope==="project"&&!s.projectId;async function k(){var N;(N=x.current)==null||N.abort();const u=new AbortController;x.current=u,c(!0),m(null);try{const D=await i.connectionOptions(s,l.id,e,u.signal);u.signal.aborted||w(D)}catch(D){u.signal.aborted||m(D instanceof Error?D.message:"Unable to load choices")}finally{u.signal.aborted||c(!1)}}const S=o&&!(h!=null&&h.some(u=>u.id===o.id))?[o,...h??[]]:h??[];return t.jsxs(Q,{"data-disabled":b,"data-invalid":!!p,children:[t.jsx(X,{htmlFor:`${n}-resource`,children:d.label}),t.jsx(Re,{children:d.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),o&&t.jsxs("p",{className:"text-sm",children:["Selected: ",o.label]}),g&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",l.definition.resources[g].label," first."]}),d.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),d.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"button",variant:"outline",size:"sm",disabled:b||j,onClick:()=>{k()},children:j?"Loading choices…":h?"Refresh choices":"Browse choices"}),h&&t.jsxs(Ze,{items:S.map(u=>({value:u.id,label:u.label})),value:(o==null?void 0:o.id)??null,disabled:b||j,onValueChange:u=>{u&&u!==(o==null?void 0:o.id)&&a(l.id,"select",{resourceId:e,value:u})},children:[t.jsx(Ye,{id:`${n}-resource`,"aria-invalid":!!p,children:t.jsx(We,{placeholder:`Choose ${d.label}`})}),t.jsx(Ge,{children:t.jsx(Ke,{children:S.map(u=>t.jsx(Je,{value:u.id,children:u.label},u.id))})})]}),(h==null?void 0:h.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),d.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{u.preventDefault(),a(l.id,"select",{resourceId:e,value:v.trim()})},children:[t.jsx(de,{id:d.options?`${n}-input`:`${n}-resource`,"aria-label":`${d.label} ${d.input.urls?"URL or ID":"ID"}`,value:v,onChange:u=>y(u.target.value),maxLength:2048,disabled:b,autoComplete:"off",spellCheck:!1,placeholder:d.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(E,{type:"submit",size:"sm",variant:"outline",disabled:b||!v.trim(),children:"Validate and select"})]}),o&&t.jsxs(E,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{a(l.id,"select",{resourceId:e,value:null})},children:["Clear ",d.label]}),p&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p})]})}function _t(l){const e=ue.c(45),{connection:s,target:i,client:r,disabled:a,save:n}=l,d=C.useId(),[o,v]=C.useState(""),[y,h]=C.useState(!1),w=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 p;e[2]!==c?(p=t.jsx($e,{variant:"outline",children:c}),e[2]=c,e[3]=p):p=e[3];let m;e[4]!==j||e[5]!==p?(m=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,p]}),e[4]=j,e[5]=p,e[6]=m):m=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=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]=x):x=e[7];let g;e[8]!==s.definition.operations?(g=new Set(Object.values(s.definition.operations).map(Ft)),e[8]=s.definition.operations,e[9]=g):g=e[9];let b;e[10]!==g?(b=[...g],e[10]=g,e[11]=b):b=e[11];const k=b.join(", ");let S;e[12]!==k?(S=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",k]}),e[12]=k,e[13]=S):S=e[13];let u;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==d||e[20]!==y||e[21]!==n?(u=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(Q,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-replace`,checked:y,onCheckedChange:h,disabled:a}),t.jsx(X,{htmlFor:`${d}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(E,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:y})},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]=d,e[20]=y,e[21]=n,e[22]=u):u=e[22];let N;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==d||e[29]!==n||e[30]!==o?(N=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:A=>{A.preventDefault();const O=o.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(_e,{children:[t.jsxs(Q,{"data-disabled":a,children:[t.jsx(X,{htmlFor:`${d}-secret`,children:s.definition.secret.label}),t.jsx(de,{id:`${d}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:o,onChange:A=>v(A.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(E,{type:"submit",size:"sm",disabled:a||!o.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(E,{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]=d,e[29]=n,e[30]=o,e[31]=N):N=e[31];let D;e[32]!==r||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==i?(D=s.status!=="disconnected"&&t.jsx(_e,{children:Object.keys(s.definition.resources).map(A=>t.jsx(Ot,{connection:s,resourceId:A,target:i,client:r,disabled:a,save:n},A))}),e[32]=r,e[33]=s,e[34]=a,e[35]=n,e[36]=i,e[37]=D):D=e[37];let R;return e[38]!==s.label||e[39]!==S||e[40]!==u||e[41]!==N||e[42]!==D||e[43]!==m?(R=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":w,children:[m,x,S,u,N,D]}),e[38]=s.label,e[39]=S,e[40]=u,e[41]=N,e[42]=D,e[43]=m,e[44]=R):R=e[44],R}function Ft(l){return l.origin}function zt({client:l,target:e}){const[s,i]=C.useState(null),[r,a]=C.useState(null),[n,d]=C.useState(!1),o=C.useRef(null),v=C.useRef(!1),y=e.pluginId,h=e.projectId;C.useEffect(()=>{const j=new AbortController;return o.current=j,l.connections({pluginId:y,projectId:h},j.signal).then(c=>{j.signal.aborted||i(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),o.current=null}},[l,y,h]);async function w(j,c,p){if(!s||v.current||!o.current||o.current.signal.aborted)return;v.current=!0;const m=o.current.signal;d(!0),a(null);try{const x=await l.changeConnection(e,j,c,p,s.revision,m);m.aborted||i(x)}catch(x){m.aborted||a(x instanceof Error?x.message:"Connection change failed")}finally{v.current=!1,m.aborted||d(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[r&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:r})}),!s&&!r&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(_t,{connection:j,target:e,client:l,disabled:n,save:w},`${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 Lt(l){const e=ue.c(32),{client:s,status:i,pluginId:r,initialProjectId:a}=l,[n,d]=C.useState(a),o=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let y;e[1]!==i.projects?(y=[v,...i.projects.map(Ut)],e[1]=i.projects,e[2]=y):y=e[2];const h=y;let w;e[3]!==o?(w=t.jsx(X,{htmlFor:o,children:"Project settings"}),e[3]=o,e[4]=w):w=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=R=>d(R||null),e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(We,{}),e[6]=p):p=e[6];let m;e[7]!==o?(m=t.jsx(Ye,{id:o,children:p}),e[7]=o,e[8]=m):m=e[8];let x;e[9]!==h?(x=t.jsx(Ge,{children:t.jsx(Ke,{children:h.map(Vt)})}),e[9]=h,e[10]=x):x=e[10];let g;e[11]!==h||e[12]!==j||e[13]!==m||e[14]!==x?(g=t.jsxs(Ze,{items:h,value:j,onValueChange:c,children:[m,x]}),e[11]=h,e[12]=j,e[13]=m,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==i.host.name?(b=t.jsxs(Re,{children:["Connection credentials belong to ",i.host.name,". Project resources stay within the project you choose."]}),e[16]=i.host.name,e[17]=b):b=e[17];let k;e[18]!==b||e[19]!==w||e[20]!==g?(k=t.jsxs(Q,{children:[w,g,b]}),e[18]=b,e[19]=w,e[20]=g,e[21]=k):k=e[21];const S=`${r}:${n??"host"}:${i.connectionRevision??0}`;let u;e[22]!==r||e[23]!==n?(u={pluginId:r,projectId:n},e[22]=r,e[23]=n,e[24]=u):u=e[24];let N;e[25]!==s||e[26]!==S||e[27]!==u?(N=t.jsx(zt,{client:s,target:u},S),e[25]=s,e[26]=S,e[27]=u,e[28]=N):N=e[28];let D;return e[29]!==k||e[30]!==N?(D=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,N]}),e[29]=k,e[30]=N,e[31]=D):D=e[31],D}function Vt(l){return t.jsx(Je,{value:l.value,children:l.label},l.value)}function Ut(l){return{value:l.id,label:l.name}}function qt(l){var ie;const e=ue.c(174),{plugin:s,status:i,client:r,busy:a,run:n,onPreview:d,onConnections:o,onUpdate:v}=l,y=C.useId(),[h,w]=C.useState(s.scope),[j,c]=C.useState(!1),[p,m]=C.useState(!1);let x,g,b,k,S,u,N,D,R,A,O,I;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==d||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==h||e[8]!==i.host.name||e[9]!==i.projects||e[10]!==i.runtime||e[11]!==i.store){const le=st(),oe=Me(s.manifest,le,i.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==r||e[25]!==s.id||e[26]!==n||e[27]!==i.store?(Y=(P,Te)=>n(()=>r.changeInstalled(s.id,P,Te,i.store.revision)),e[24]=r,e[25]=s.id,e[26]=n,e[27]=i.store,e[28]=Y):Y=e[28];const B=Y,re=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let ce;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==i.store?(ce=s.lastError&&((ie=i.store.availableSeeds)==null?void 0:ie.find(P=>P.manifest.id===s.id&&P.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=i.store,e[33]=ce):ce=e[33];const Fe=ce;A="flex flex-col gap-3 rounded-lg border p-4";let fe;e[34]!==s.manifest.name?(fe=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=fe):fe=e[35];let he;e[36]!==s.id||e[37]!==s.manifest.version?(he=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]=he):he=e[38];let me;e[39]!==fe||e[40]!==he?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[fe,he]}),e[39]=fe,e[40]=he,e[41]=me):me=e[41];const ze=re==="Enabled"?"secondary":"outline";let pe;e[42]!==re||e[43]!==ze?(pe=t.jsx($e,{variant:ze,children:re}),e[42]=re,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==me||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,pe]}),e[45]=me,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(I=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=I):I=e[49],g=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(P=>t.jsxs("p",{children:[P.side==="client"?"This client":P.side==="host"?i.host.name:"This package",": ",P.name," requires ",P.required,"; available ",P.actual??"none","."]},`${P.side}:${P.code}:${P.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]!==B||e[51]!==s.enabled?(xe=()=>B("enabled",{enabled:!s.enabled}),e[50]=B,e[51]=s.enabled,e[52]=xe):xe=e[52];const Le=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Le?(ge=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Le}),e[53]=a,e[54]=xe,e[55]=Le,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==o||e[59]!==s.id||e[60]!==s.manifest.permissions.connections.length?(je=s.manifest.permissions.connections.length>0&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>o(s.id),children:"Connections"}),e[57]=a,e[58]=o,e[59]=s.id,e[60]=s.manifest.permissions.connections.length,e[61]=je):je=e[61];const Ve=a||s.pinned;let be;e[62]!==v||e[63]!==s?(be=()=>v(s),e[62]=v,e[63]=s,e[64]=be):be=e[64];let ve;e[65]!==Ve||e[66]!==be?(ve=t.jsx(E,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[65]=Ve,e[66]=be,e[67]=ve):ve=e[67];let ye;e[68]!==a||e[69]!==r||e[70]!==d||e[71]!==s.id||e[72]!==s.scope||e[73]!==Fe||e[74]!==n?(ye=Fe&&t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>d(await r.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[68]=a,e[69]=r,e[70]=d,e[71]=s.id,e[72]=s.scope,e[73]=Fe,e[74]=n,e[75]=ye):ye=e[75];let Ce;e[76]!==B||e[77]!==s.pinned?(Ce=()=>B("pin",{pinned:!s.pinned}),e[76]=B,e[77]=s.pinned,e[78]=Ce):Ce=e[78];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[79]!==a||e[80]!==Ce||e[81]!==Ue?(we=t.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[79]=a,e[80]=Ce,e[81]=Ue,e[82]=we):we=e[82];let Ee;e[83]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{m(!1),c(!0)},e[83]=Ee):Ee=e[83];let Ne;e[84]!==a?(Ne=t.jsx(E,{size:"sm",variant:"ghost",disabled:a,onClick:Ee,children:"Uninstall"}),e[84]=a,e[85]=Ne):Ne=e[85],e[86]!==ge||e[87]!==je||e[88]!==ve||e[89]!==ye||e[90]!==we||e[91]!==Ne?(b=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Ne]}),e[86]=ge,e[87]=je,e[88]=ve,e[89]=ye,e[90]=we,e[91]=Ne,e[92]=b):b=e[92],e[93]!==s.pinned?(k=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[93]=s.pinned,e[94]=k):k=e[94],D="text-sm",e[95]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[95]=R):R=e[95],x="flex flex-col gap-4 pt-4",e[96]!==a||e[97]!==h||e[98]!==i.projects?(S=t.jsx(qe,{value:h,onChange:w,projects:i.projects,disabled:a}),e[96]=a,e[97]=h,e[98]=i.projects,e[99]=S):S=e[99];let Se;e[100]!==a||e[101]!==s.scope||e[102]!==h?(Se=a||JSON.stringify(h)===JSON.stringify(s.scope),e[100]=a,e[101]=s.scope,e[102]=h,e[103]=Se):Se=e[103];let ke;e[104]!==B||e[105]!==h?(ke=()=>B("scope",{scope:h}),e[104]=B,e[105]=h,e[106]=ke):ke=e[106],e[107]!==i.host.name||e[108]!==Se||e[109]!==ke?(u=t.jsxs(E,{size:"sm",variant:"outline",disabled:Se,onClick:ke,children:["Save projects on ",i.host.name]}),e[107]=i.host.name,e[108]=Se,e[109]=ke,e[110]=u):u=e[110];let Pe;e[111]!==s.selectedDigest?(Pe=P=>P.digest!==s.selectedDigest,e[111]=s.selectedDigest,e[112]=Pe):Pe=e[112],N=s.versions.filter(Pe).map(P=>{const Te=!P.unavailableReason&&Me(P.manifest,le,i.runtime,{allowPrerelease:P.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(E,{size:"sm",variant:"outline",disabled:a||s.pinned||!Te,onClick:()=>n(async()=>d({...await r.rollback(s.id,P.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",P.manifest.version]}),!Te&&t.jsx("p",{className:"text-xs text-muted-foreground",children:P.unavailableReason??"This version is incompatible with the connected host or client."})]},P.digest)}),e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=v,e[5]=s,e[6]=n,e[7]=h,e[8]=i.host.name,e[9]=i.projects,e[10]=i.runtime,e[11]=i.store,e[12]=x,e[13]=g,e[14]=b,e[15]=k,e[16]=S,e[17]=u,e[18]=N,e[19]=D,e[20]=R,e[21]=A,e[22]=O,e[23]=I}else x=e[12],g=e[13],b=e[14],k=e[15],S=e[16],u=e[17],N=e[18],D=e[19],R=e[20],A=e[21],O=e[22],I=e[23];let U;e[113]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[113]=U):U=e[113];let H;e[114]!==x||e[115]!==S||e[116]!==u||e[117]!==N?(H=t.jsxs("div",{className:x,children:[S,u,N,U]}),e[114]=x,e[115]=S,e[116]=u,e[117]=N,e[118]=H):H=e[118];let z;e[119]!==H||e[120]!==D||e[121]!==R?(z=t.jsxs("details",{className:D,children:[R,H]}),e[119]=H,e[120]=D,e[121]=R,e[122]=z):z=e[122];let ee;e[123]!==s.manifest.name?(ee=t.jsxs(nt,{children:["Uninstall ",s.manifest.name,"?"]}),e[123]=s.manifest.name,e[124]=ee):ee=e[124];let G;e[125]!==i.host.name?(G=t.jsxs(it,{children:["This removes the plugin from ",i.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[125]=i.host.name,e[126]=G):G=e[126];let _;e[127]!==ee||e[128]!==G?(_=t.jsxs(at,{children:[ee,G]}),e[127]=ee,e[128]=G,e[129]=_):_=e[129];const K=`${y}-delete`,te=a||i.connectionRevision===void 0;let F;e[130]!==p||e[131]!==K||e[132]!==te?(F=t.jsx(Ie,{id:K,checked:p,onCheckedChange:m,disabled:te}),e[130]=p,e[131]=K,e[132]=te,e[133]=F):F=e[133];const J=`${y}-delete`;let L;e[134]!==J?(L=t.jsx(X,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[134]=J,e[135]=L):L=e[135];let q;e[136]!==F||e[137]!==L?(q=t.jsxs(Q,{orientation:"horizontal",children:[F,L]}),e[136]=F,e[137]=L,e[138]=q):q=e[138];let T;e[139]!==p?(T=p&&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[139]=p,e[140]=T):T=e[140];let V;e[141]!==a?(V=t.jsx(ot,{disabled:a,children:"Cancel"}),e[141]=a,e[142]=V):V=e[142];let f;e[143]!==r||e[144]!==p||e[145]!==s.id||e[146]!==n||e[147]!==i.connectionRevision||e[148]!==i.store?(f=()=>{c(!1),n(()=>r.changeInstalled(s.id,"uninstall",p?{deleteData:!0,expectedConnectionRevision:i.connectionRevision}:{deleteData:!1},i.store.revision))},e[143]=r,e[144]=p,e[145]=s.id,e[146]=n,e[147]=i.connectionRevision,e[148]=i.store,e[149]=f):f=e[149];let $;e[150]!==a||e[151]!==i.host.name||e[152]!==f?($=t.jsxs(lt,{variant:"destructive",disabled:a,onClick:f,children:["Uninstall from ",i.host.name]}),e[150]=a,e[151]=i.host.name,e[152]=f,e[153]=$):$=e[153];let W;e[154]!==V||e[155]!==$?(W=t.jsxs(rt,{children:[V,$]}),e[154]=V,e[155]=$,e[156]=W):W=e[156];let M;e[157]!==_||e[158]!==q||e[159]!==T||e[160]!==W?(M=t.jsxs(ct,{children:[_,q,T,W]}),e[157]=_,e[158]=q,e[159]=T,e[160]=W,e[161]=M):M=e[161];let Z;e[162]!==j||e[163]!==M?(Z=t.jsx(dt,{open:j,onOpenChange:c,children:M}),e[162]=j,e[163]=M,e[164]=Z):Z=e[164];let ae;return e[165]!==g||e[166]!==b||e[167]!==k||e[168]!==z||e[169]!==Z||e[170]!==A||e[171]!==O||e[172]!==I?(ae=t.jsxs("article",{className:A,children:[O,I,g,b,k,z,Z]}),e[165]=g,e[166]=b,e[167]=k,e[168]=z,e[169]=Z,e[170]=A,e[171]=O,e[172]=I,e[173]=ae):ae=e[173],ae}const Mt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Bt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function Ht(l,e){return 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":`Read ${Mt[l]} ${Bt[e]} using this host's signed-in CLI`}function He(l){const e=l.permissions;return[...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(()=>"Append text to your draft message"),...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`]:[],...e.connections.flatMap(s=>s.operations.map(i=>`Use connection ${s.id}: ${i}`)),...e.integrations.flatMap(s=>s.operations.map(i=>Ht(s.id,i)))]}function Gt(l){var j;const e=ue.c(32),{preview:s}=l;let i,r,a,n,d,o;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=He(s.manifest),p=s.previousManifest?He(s.previousManifest):null,m=p?c.filter(b=>!p.includes(b)):[],x=p?p.filter(b=>!c.includes(b)):[],g=s.previousConnectionDefinitions?s.connectionDefinitions.filter(b=>{var S;const k=(S=s.previousConnectionDefinitions)==null?void 0:S.find(u=>u.id===b.id);return!k||JSON.stringify(k)!==JSON.stringify(b)}):[];i="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(r=s.oldVersion&&t.jsxs(se,{children:[t.jsx(De,{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]=r):r=e[14],a=p&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),m.length===0&&x.length===0&&g.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),m.map(Xt),x.map(Qt),g.map(Zt)]}),n=s.oldVersion&&!p&&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")?(d=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=d):d=e[15],o=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(Yt)}):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]=i,e[7]=r,e[8]=a,e[9]=n,e[10]=d,e[11]=o}else i=e[6],r=e[7],a=e[8],n=e[9],d=e[10],o=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Kt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let y;e[18]!==s.incompatibleClients?(y=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(De,{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]=y):y=e[19];let h;e[20]!==s.digest?(h=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=h):h=e[21];let w;return e[22]!==i||e[23]!==r||e[24]!==a||e[25]!==n||e[26]!==d||e[27]!==o||e[28]!==v||e[29]!==y||e[30]!==h?(w=t.jsxs("div",{className:i,children:[r,a,n,d,o,v,y,h]}),e[22]=i,e[23]=r,e[24]=a,e[25]=n,e[26]=d,e[27]=o,e[28]=v,e[29]=y,e[30]=h,e[31]=w):w=e[31],w}function Kt(l){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:l.label}),t.jsxs("p",{children:["Access to ",Object.values(l.resources).map(Wt).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(l.operations).map(Jt))].join(", ")]})]},l.id)}function Jt(l){return l.origin}function Wt(l){return l.label}function Yt(l){return t.jsx("li",{children:l},l)}function Zt(l){return t.jsxs("p",{children:["Changed connection: ",l.label,". Review its destinations and access below."]},l.id)}function Qt(l){return t.jsxs("p",{children:["Removed: ",l]},`remove:${l}`)}function Xt(l){return t.jsxs("p",{children:["Added: ",l]},`add:${l}`)}function ls({client:l,state:e,currentPath:s,onClose:i,initialPluginId:r}){var V;const a=C.useId(),n=e.status,d=ut(),o=(n==null?void 0:n.safeMode)||d,{project:v,resolving:y}=ft({client:l,status:n,activation:e.activation,projectPath:s}),[h,w]=C.useState(null),j=h??{type:"projects",projectIds:v?[v.id]:[]},[c,p]=C.useState(null),[m,x]=C.useState({activation:"",hostName:""}),[g,b]=C.useState(!1),[k,S]=C.useState(!1),[u,N]=C.useState(null),[D,R]=C.useState(null),[A,O]=C.useState("installed"),[I,U]=C.useState(null),[H,z]=C.useState(null),[ee,G]=C.useState(r),_=n==null?void 0:n.store.plugins.find(f=>f.id===ee),K=C.useRef(!1),te=!!(n!=null&&n.store.available)&&m.activation===e.activation;function F(f){x({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),p(f)}C.useEffect(()=>{!c||te&&!(o&&g)||(b(!1),p(null),N("The host connection or plugin execution state changed. Review the package again before installing."),l.cancel(c).catch(()=>{}))},[l,c,te,o,g]),C.useEffect(()=>()=>{c&&l.cancel(c).catch(()=>{})},[l,c]);async function J(f){if(!K.current){K.current=!0,S(!0),N(null),R(null);try{await f()}catch($){N($ instanceof Error?$.message:"Plugin action failed")}finally{K.current=!1,S(!1)}}}function L(){const f=c;b(!1),p(null),f&&l.cancel(f).catch(()=>{})}async function q(){if(!H||!I&&!h&&y)return;const f=await l.stage(H,(I==null?void 0:I.scope)??j);if(I&&f.manifest.id!==I.id)throw await l.cancel(f),new Error(`Choose a package for ${I.manifest.name} (${I.id}).`);F(f)}const T=k||g||!(n!=null&&n.store.available);return t.jsx(ht,{open:!0,onOpenChange:f=>{!f&&!k&&!g&&(L(),i())},children:t.jsxs(mt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!k&&!g,children:[t.jsxs(pt,{children:[t.jsx(xt,{children:"Plugins"}),t.jsx(gt,{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||u||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:n!=null&&n.store.available&&!u&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:u??e.error??(n==null?void 0:n.store.error)})]}),D&&t.jsx(se,{children:t.jsx(ne,{children:D})}),o&&t.jsxs(se,{children:[t.jsx(De,{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(E,{size:"sm",variant:"outline",disabled:k||g||(n==null?void 0:n.safeMode),onClick:()=>jt(!d),children:d?"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(E,{variant:"outline",disabled:k,onClick:()=>{J(()=>l.refresh())},children:[t.jsx(kt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&_&&!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.jsxs("h2",{className:"font-medium",children:[_.manifest.name," connections"]}),t.jsx(E,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),t.jsx(Lt,{client:l,status:n,pluginId:_.id,initialProjectId:(v==null?void 0:v.id)??null},`${_.id}:${n.store.revision}`)]}),n&&!_&&!c&&t.jsxs(bt,{value:A,onValueChange:f=>{O(String(f)),U(null),z(null)},children:[t.jsxs(vt,{className:"h-auto flex-wrap",children:[t.jsx(Ae,{value:"installed",children:"Installed"}),t.jsx(Ae,{value:"browse",children:"Browse"}),t.jsx(Ae,{value:"install",children:"Install from file"}),t.jsx(Ae,{value:"publishers",children:"Publishers"})]}),t.jsx(Oe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(f=>t.jsx(qt,{plugin:f,status:n,client:l,busy:T,run:$=>{J($)},onPreview:F,onConnections:G,onUpdate:$=>{U($),z(null),O("install")}},`${f.id}:${n.store.revision}`)):t.jsx(yt,{children:t.jsxs(Ct,{children:[t.jsx(wt,{variant:"icon",children:t.jsx($t,{})}),t.jsx(Nt,{children:"No installed plugins"}),t.jsx(St,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Oe,{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(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),(n.store.availableSeeds??[]).map(f=>{const $=n.store.plugins.find(M=>M.id===f.manifest.id),W=$&&It(f.manifest.version,$.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:f.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.manifest.version," · ",f.manifest.publisher]})]}),W?t.jsx(E,{size:"sm",disabled:T||$.pinned,onClick:()=>{J(async()=>F(await l.stageSeed(f.manifest.id,$.scope)))},children:$.pinned?"Pinned to installed version":"Review update"}):$?t.jsx($e,{variant:"outline",children:"Installed"}):t.jsx(E,{size:"sm",disabled:T||!h&&y,onClick:()=>{J(async()=>F(await l.stageSeed(f.manifest.id,j)))},children:"Review installation"})]},f.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(Oe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:f=>{f.preventDefault(),J(q)},children:t.jsxs(_e,{children:[I&&t.jsxs("p",{className:"text-sm",children:["Update ",I.manifest.name," from ",I.manifest.version,". Existing project access is retained."]}),t.jsxs(Q,{children:[t.jsx(X,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(de,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:T,required:!0,onChange:f=>{var $;return z((($=f.target.files)==null?void 0:$[0])??null)}})]}),!I&&t.jsx(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),t.jsxs(E,{type:"submit",disabled:T||!H||!I&&!h&&y,children:["Review ",I?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Oe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(f=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[f.label," ",t.jsx($e,{variant:"outline",children:f.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[f.id," · ",f.fingerprint]})]},f.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(Rt,{client:l,busy:T,run:f=>{J(f)}})})]})]})})]}),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 ",m.hostName]}),t.jsx($e,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Gt,{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(f=>{var $;return(($=n==null?void 0:n.projects.find(W=>W.id===f))==null?void 0:$.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(f=>t.jsxs("li",{children:[f.side,": ",f.name," requires ",f.required,"; available ",f.actual??"none","."]},`${f.side}:${f.code}:${f.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(f=>f.name).join(", "),"."]})}),g&&te&&!o?t.jsxs(t.Fragment,{children:[t.jsx(At,{client:l,preview:c,activation:e.activation,onComplete:()=>{b(!1),p(null),R(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${m.hostName}.`),O("installed"),U(null)},onError:f=>{N(f.message),L()}}),t.jsxs(E,{variant:"outline",onClick:L,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(E,{variant:"outline",disabled:k,onClick:L,children:"Cancel"}),t.jsxs(E,{disabled:T||!te||!c.compatibility.compatible||o,onClick:()=>{N(null),b(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",m.hostName]})]})]})]})]})})}export{ls as PluginsDialog};