import{b as t,n as A,e as T}from"./vendor-lit-B2r-dKc0.js";import{aC as C,aE as u,aF as h,aD as _}from"./app-session-runtime-CeFJDILJ.js";import{r as S}from"./delegate-cards-BbatMXY8.js";import{aA as v,aB as g,aC as b}from"./vendor-lucide-B9Yl1Gez.js";import"./vendor-mini-lit-CpUQub-j.js";import"./vendor-marked-_iteVaMm.js";import"./app-review-C3CmcSYC.js";import"./app-panel-workspace-C3XDRCgE.js";import"./app-routing-C_r2pdnC.js";import"./app-message-reducer-wATqnZGf.js";import"./vendor-sortable-B1o3v0Qs.js";import"./app-inbox-CaZD85aD.js";import"./app-pr-walkthrough-WipZACSB.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 w(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 M{render(n,e,x){const r=C(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 i=h(e);return{content:t`<div>
					${u(r,g,i?"Aborted task list":"Task list failed")}
					<div class="mt-1 text-xs ${i?"text-amber-600 dark:text-amber-400":"text-destructive"}">${o}</div>
				</div>`,isCustom:!1}}const d=a?.tasks||(Array.isArray(a)?a:[]);if(d.length===0)return{content:t`<div>${u(r,g,"No tasks")}</div>`,isCustom:!1};const c=new Map;for(const i of d)c.set(i.state||"todo",(c.get(i.state||"todo")||0)+1);const p=Array.from(c.entries()).map(([i,k])=>`${k} ${i}`).join(", "),l=T(),f=T();return{content:t`<div>
				${_(r,g,t`${d.length} tasks <span class="text-xs text-muted-foreground ml-1">(${p})</span>`,l,f,!1)}
				<div ${A(l)} class="max-h-0 overflow-hidden transition-all duration-300">
					<div class="mt-2 space-y-1">${d.map(w)}</div>
				</div>
			</div>`,isCustom:!1}}}class O{render(n,e,x){const r=C(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:p}=$(e),l=h(e),f=p.includes("409")||p.toLowerCase().includes("gate"),i=l?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=l||f?"text-amber-600 dark:text-amber-400":"text-destructive";return{content:t`<div>
					${u(r,v,i)}
					<div class="mt-1 text-xs ${k}">${p}</div>
				</div>`,isCustom:!1}}const{data:d}=$(e),c=d?.id?d.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 z{render(n,e,x){const r=C(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 d=o.join(", ");if(!e)return{content:t`<div>${u(r,b,t`Updating <span class="font-mono text-xs">${a}</span> ${d?t`<span class="text-xs text-muted-foreground">(${d})</span>`:""}`)}</div>`,isCustom:!1};if(e.isError){const{text:f}=$(e),i=h(e);return{content:t`<div>
					${u(r,b,i?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 ${i?"text-amber-600 dark:text-amber-400":"text-destructive"}">${f}</div>
				</div>`,isCustom:!1}}const{data:c}=$(e),p=c?.title?m(c.title,40):"",l=c?.state;return{content:t`<div>${u(r,b,t`Updated <span class="font-mono text-xs">${a}</span> ${p?t`<span class="font-medium text-xs">${p}</span>`:""} ${l?R(l):""} ${n?.assigned_to?t`<span class="text-xs text-muted-foreground">→</span> ${S(n.assigned_to)}`:""}`)}</div>`,isCustom:!1}}}export{O as TaskCreateRenderer,M as TaskListRenderer,z as TaskUpdateRenderer};
