import{b as t,A as r,n as k,e as f}from"./vendor-lit-BtHfzs80.js";import{a as x}from"./vendor-mini-lit-Cx886NBU.js";import{av as w,aw as N}from"./index-rvuS68Al.js";import{f as S}from"./delegate-cards-BUepigK_.js";import{C as A,X as M,$ as P,at as T}from"./vendor-lucide-DBEJLfdn.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";function D(s){return s.state?s.state:s.success===!1?"error":"complete"}function E(s){const n=(s.error||"").trim();return!n||/^unknown error\.?$/i.test(n)?null:n}class j{render(n,v,R,F){const e=v?.details??n,m=f(),g=f();if(!e)return{content:t`<div class="text-xs text-muted-foreground">Compacting…</div>`,isCustom:!1};const o=D(e),c=o==="in-progress",a=o==="error",$=o==="complete",l=c?"inprogress":a?"error":"complete",u=a?P:T,b=c?"Compacting context…":a?"Compaction failed":"Context compacted",C=$?t`<span
					class="ml-1 inline-flex items-center text-green-600 dark:text-green-500"
					data-test="verdict"
					data-verdict="ok"
				>${x(A,"sm")}</span>`:a?t`<span
						class="ml-1 inline-flex items-center text-destructive"
						data-test="verdict"
						data-verdict="fail"
					>${x(M,"sm")}</span>`:r,d=(()=>{if(c){const i=e.startedAt?Date.parse(e.startedAt):NaN;return Number.isFinite(i)?t`<span
					class="text-xs text-muted-foreground tabular-nums"
					title="Elapsed since compaction started"
				><live-timer .startTime=${i} .running=${!0}></live-timer></span>`:r}return typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)?t`<span
					class="text-xs text-muted-foreground tabular-nums"
					title="Total compaction duration"
				>${S(e.durationMs)}</span>`:r})(),p=t`
			<span>${b}</span>
			${C}
		`,y=(()=>{const i=E(e);return i?t`<div class="mt-2 text-sm text-destructive" data-test="error">${i}</div>`:r})(),h=a?t`<details class="mt-2">
					<summary class="cursor-pointer text-xs text-muted-foreground">
						payload
					</summary>
					<pre class="mt-1 overflow-x-auto rounded bg-muted/40 p-2 text-xs">
${JSON.stringify(e,null,2)}</pre>
				</details>`:r;return a?{content:t`
					<div
						data-testid="compaction-summary-card"
						data-state=${o}
						class="rounded-md border border-border bg-card p-3"
					>
						${w(l,u,p,m,g,!0,d===r?void 0:d)}
						<div
							${k(m)}
							class="max-h-[2000px] mt-3 overflow-hidden transition-all duration-300"
						>
							${y} ${h}
						</div>
					</div>
				`,isCustom:!1}:{content:t`
				<div
					data-testid="compaction-summary-card"
					data-state=${o}
					class="rounded-md border border-border bg-card p-3"
				>
					${N(l,u,p,d===r?void 0:d)}
				</div>
			`,isCustom:!1}}}export{j as CompactionSummaryRenderer};
