import{b as e,n as f,e as w}from"./vendor-lit-BtHfzs80.js";import{au as H,aw as D,av as g}from"./index-rvuS68Al.js";import{a as L,s as r,b as O,f as T,r as j,c as z}from"./delegate-cards-BUepigK_.js";import{B as l}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-mini-lit-Cx886NBU.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function I(d){return d&&d.content?.filter(s=>s.type==="text").map(s=>s.text).join(`
`)||""}class K{render(s,o,x){const i=H(o,x),a=w(),c=w(),u=o?.details;if(!o){if(s?.parallel&&s.parallel.length>0)return{content:e`
						<div>
							${D(i,l,`Delegating to ${s.parallel.length} agents`)}
							<div class="mt-2 space-y-1">
								${s.parallel.map(m=>L(r(m.instructions)))}
							</div>
						</div>
					`,isCustom:!1};const n=s?.instructions?r(s.instructions):"task";return{content:e`
					<div>
						${D(i,l,e`Delegating to agent — <span class="font-mono text-xs">${n}</span>`)}
					</div>
				`,isCustom:!1}}if(u?.delegates&&u.delegates.length>0){const n=u.delegates,m=n.every(t=>t.status==="completed");if(n.length===1){const t=n[0],p=s?.instructions||t.instructions;return{content:e`
						<div>
							${g(i,l,e`Delegated — <span class="font-mono text-xs">${r(p)}</span>
									<span class="${O(t.status)} text-xs ml-1">(${T(t.durationMs)})</span>
									${j(t.sessionId)}`,a,c,!1)}
							<div ${f(a)} class="max-h-0 overflow-hidden transition-all duration-300">
								<div class="mt-2 text-sm whitespace-pre-wrap text-muted-foreground">${I(o)}</div>
							</div>
						</div>
					`,isCustom:!1}}const v=n.filter(t=>t.status==="completed").length,$=n.filter(t=>t.status!=="completed"&&t.status!=="running"&&t.status!=="starting").length,k=e`Delegated to ${n.length} agents —
				${m?e`<span class="text-green-500 text-xs ml-1">all completed</span>`:$>0?e`<span class="text-xs ml-1"><span class="text-green-500">${v} done</span>, <span class="text-destructive">${$} failed</span></span>`:e`<span class="text-xs text-muted-foreground ml-1">${v}/${n.length} completed</span>`}`,b=s?.parallel||[],M=x&&n.some(t=>t.status==="running"),h=n.map((t,p)=>{const B=b[p]?.instructions||t.instructions;return{id:t.id,sessionId:t.sessionId,name:r(B),status:t.status,durationMs:t.durationMs}}),C=M||h.some(t=>t.sessionId);return{content:e`
					<div>
						${g(i,l,k,a,c,C)}
						<div ${f(a)} class="${C?"max-h-[2000px] mt-3":"max-h-0"} overflow-hidden transition-all duration-300">
							${z(h)}
						</div>
					</div>
				`,isCustom:!1}}const y=I(o),R=s?.instructions?r(s.instructions):"task";return{content:e`
				<div>
					${g(i,l,e`Delegated — <span class="font-mono text-xs">${R}</span>`,a,c,!1)}
					<div ${f(a)} class="max-h-0 overflow-hidden transition-all duration-300">
						<div class="mt-2 text-sm whitespace-pre-wrap text-muted-foreground">${y}</div>
					</div>
				</div>
			`,isCustom:!1}}}export{K as DelegateRenderer};
