import{b as t,n as w,e as T}from"./vendor-lit-BtHfzs80.js";import{au as h,aw as u,ax as C,av as _}from"./index-rvuS68Al.js";import{r as S}from"./delegate-cards-BUepigK_.js";import{ax as v,ay as g,az as b}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-mini-lit-Cx886NBU.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function $(s){const n=s?.content?.filter(x=>x.type==="text").map(x=>x.text).join(`
`)||"";let e=null;try{e=JSON.parse(n)}catch{}return{text:n,data:e}}function R(s){const e={todo:"bg-muted text-muted-foreground","in-progress":"bg-blue-500/20 text-blue-600 dark:text-blue-400",blocked:"bg-red-500/20 text-red-600 dark:text-red-400",complete:"bg-green-500/20 text-green-600 dark:text-green-400",skipped:"bg-muted text-muted-foreground line-through"}[s]||"bg-muted text-muted-foreground";return t`<span class="px-1.5 py-0.5 rounded text-xs font-medium ${e}">${s}</span>`}function y(s){const e={implementation:"text-blue-600 dark:text-blue-400","code-review":"text-purple-600 dark:text-purple-400",testing:"text-green-600 dark:text-green-400","bug-fix":"text-red-600 dark:text-red-400",refactor:"text-amber-600 dark:text-amber-400",custom:"text-muted-foreground"}[s]||"text-muted-foreground";return t`<span class="text-xs ${e}">${s}</span>`}function m(s,n=60){return s?s.length>n?s.slice(0,n)+"…":s:""}function A(s){return t`
		<div class="flex items-center gap-2 text-xs py-0.5">
			${R(s.state||"todo")}
			${y(s.type||"custom")}
			<span class="font-medium truncate">${m(s.title||s.name||"Untitled",50)}</span>
			${s.assignedTo?t`<span class="text-muted-foreground">→</span> ${S(s.assignedTo)}`:""}
		</div>
	`}class H{render(n,e,x){const r=h(e,x);if(!e)return{content:t`<div>${u(r,g,"Listing tasks…")}</div>`,isCustom:!1};const{data:a,text:o}=$(e);if(e.isError){const d=C(e);return{content:t`<div>
					${u(r,g,d?"Aborted task list":"Task list failed")}
					<div class="mt-1 text-xs ${d?"text-amber-600 dark:text-amber-400":"text-destructive"}">${o}</div>
				</div>`,isCustom:!1}}const i=a?.tasks||(Array.isArray(a)?a:[]);if(i.length===0)return{content:t`<div>${u(r,g,"No tasks")}</div>`,isCustom:!1};const c=new Map;for(const d of i)c.set(d.state||"todo",(c.get(d.state||"todo")||0)+1);const l=Array.from(c.entries()).map(([d,k])=>`${k} ${d}`).join(", "),p=T(),f=T();return{content:t`<div>
				${_(r,g,t`${i.length} tasks <span class="text-xs text-muted-foreground ml-1">(${l})</span>`,p,f,!1)}
				<div ${w(p)} class="max-h-0 overflow-hidden transition-all duration-300">
					<div class="mt-2 space-y-1">${i.map(A)}</div>
				</div>
			</div>`,isCustom:!1}}}class I{render(n,e,x){const r=h(e,x),a=n?.title||"task",o=n?.type;if(!e)return{content:t`<div>${u(r,v,t`Creating task — ${o?y(o):""} <span class="font-medium text-xs">${m(a)}</span>`)}</div>`,isCustom:!1};if(e.isError){const{text:l}=$(e),p=C(e),f=l.includes("409")||l.toLowerCase().includes("gate"),d=p?t`Aborted creation of task — <span class="font-medium text-xs">${m(a)}</span>`:t`Failed to create task — <span class="font-medium text-xs">${m(a)}</span>`,k=p||f?"text-amber-600 dark:text-amber-400":"text-destructive";return{content:t`<div>
					${u(r,v,d)}
					<div class="mt-1 text-xs ${k}">${l}</div>
				</div>`,isCustom:!1}}const{data:i}=$(e),c=i?.id?i.id.slice(0,8):"";return{content:t`<div>${u(r,v,t`Created ${o?y(o):""} <span class="font-medium text-xs">${m(a)}</span> ${c?t`<span class="text-xs text-muted-foreground font-mono">${c}</span>`:""}`)}</div>`,isCustom:!1}}}class N{render(n,e,x){const r=h(e,x),a=n?.task_id?n.task_id.slice(0,8):"task",o=[];n?.state&&o.push(`→ ${n.state}`),n?.assigned_to&&o.push("assign"),n?.title&&o.push("title"),n?.spec&&o.push("spec"),n?.result_summary&&o.push("result");const i=o.join(", ");if(!e)return{content:t`<div>${u(r,b,t`Updating <span class="font-mono text-xs">${a}</span> ${i?t`<span class="text-xs text-muted-foreground">(${i})</span>`:""}`)}</div>`,isCustom:!1};if(e.isError){const{text:f}=$(e),d=C(e);return{content:t`<div>
					${u(r,b,d?t`Aborted update of <span class="font-mono text-xs">${a}</span>`:t`Failed to update <span class="font-mono text-xs">${a}</span>`)}
					<div class="mt-1 text-xs ${d?"text-amber-600 dark:text-amber-400":"text-destructive"}">${f}</div>
				</div>`,isCustom:!1}}const{data:c}=$(e),l=c?.title?m(c.title,40):"",p=c?.state;return{content:t`<div>${u(r,b,t`Updated <span class="font-mono text-xs">${a}</span> ${l?t`<span class="font-medium text-xs">${l}</span>`:""} ${p?R(p):""} ${n?.assigned_to?t`<span class="text-xs text-muted-foreground">→</span> ${S(n.assigned_to)}`:""}`)}</div>`,isCustom:!1}}}export{I as TaskCreateRenderer,H as TaskListRenderer,N as TaskUpdateRenderer};
