import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Ci as t}from"./control-ui-foundation-CeFMP1Ly.js";import{Js as n,bc as r,qs as i,r as a}from"./control-ui-core-pH6nakZ-.js";import{i as o,l as s,u as c}from"./catalog-target-DMha_lm_.js";async function l(e,r){let i=a(r),o=i.agentId.trim(),l=``,u=!1,d,f,p;if(i.group){let t=e.sessions.groupsGeneration(),n=await e.sessions.groupsLoad();f=e.sessions.groupsGeneration(),p=e.sessions.groupsStatus();let r=t===f&&p===`ready`?n:null,a=r?.find(e=>e.name===i.group);d=r===null?`unavailable`:a?`resolved`:`missing`,l=a?.cwd??``,u=a?.worktree===!0}if(!i.catalogId)return{...i,requestedAgentId:o,groupStatus:d,groupCwd:l,groupWorktree:u,groupCatalogGeneration:f,groupDefaultsStatus:p,model:``,catalogLabel:``,startTerminal:!1};let m=(e=``)=>({...i,agentId:e,requestedAgentId:o,groupStatus:d,groupCwd:l,groupWorktree:u,groupCatalogGeneration:f,groupDefaultsStatus:p,model:``,catalogLabel:``,startTerminal:!1}),h=e.gateway.snapshot,g=e.agents.state;if(h.phase!==`connected`||!h.client||!g.connected||g.client!==h.client)return m();let _=g.agentsList??await e.agents.ensureList(),v=e.gateway.snapshot,y=e.agents.state;if(v.phase!==`connected`||!v.client||v.client!==h.client||!y.connected||y.client!==v.client||y.agentsList!==_)return m();let b=_,x=n(b?.agents??[]),S=v.phase===`connected`&&v.hello?v.assistantAgentId:null;if(!b&&o&&(!S||t(o)!==t(S)))return m();let C=b?x.some(e=>e.id===b.defaultId)?b.defaultId:x[0]?.id:S,w=C?b?s(i,x,C):s(void 0,[],C):``,T=m(w);if(v.phase!==`connected`||!v.client||!w)return T;let E=await c(v.client,i.catalogId,w);return E?{...T,...E}:T}function u(){return(u=e((()=>{i(),r(),o()})))()}u();export{l as load};
//# sourceMappingURL=route-loader-DN1qfp1j.js.map