import{b as o,n as h,e as g}from"./vendor-lit-B2r-dKc0.js";import{aC as v,aE as x,aD as w}from"./app-session-runtime-CeFJDILJ.js";import{a3 as y}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";const l=new Map,b=new Map,$=new WeakMap;function k(t,n){const e=n?.toolCallId;if(e){let i=b.get(e);return i===void 0&&(i=$.get(t)??Date.now(),b.set(e,i)),i}let a=$.get(t);return a===void 0&&(a=Date.now(),$.set(t,a)),a}function C(t,n){if(!n||!t)return;const a=(typeof n.content=="string"?n.content:n.content?.filter(i=>i.type==="text").map(i=>i.text).join(`
`)||"").match(/bg-\d+\s+\(([^)]+)\)/);a?.[1]&&l.set(t,a[1])}function P(t,n){const e=t.id;if(t.action==="create"&&t.name){if(n){const i=(typeof n.content=="string"?n.content:n.content?.filter(r=>r.type==="text").map(r=>r.text).join(`
`)||"").match(/ID:\s*(bg-\d+)/);i?.[1]&&l.set(i[1],t.name)}return t.name}return e&&l.has(e)||(C(e,n),e&&l.has(e))?l.get(e):t.name}function S(t){if(t<60)return`${t}s`;const n=Math.floor(t/60),e=t%60;return e>0?`${n}m ${e}s`:`${n}m`}const s={badge:"font-family:var(--font-mono,monospace);font-size:0.75em;font-weight:500;opacity:0.5;background:color-mix(in srgb, currentColor 10%, transparent);padding:0.1em 0.4em;border-radius:3px;vertical-align:baseline",action:"font-weight:600",name:"font-weight:500",id:"font-family:var(--font-mono,monospace);font-size:0.85em;opacity:0.5;vertical-align:baseline",sep:"opacity:0.35",detail:"opacity:0.5",mono:"font-family:var(--font-mono,monospace);font-size:0.85em;opacity:0.5;vertical-align:baseline",codePill:"font-family:var(--font-mono,monospace);font-size:0.85em;opacity:0.65;background:color-mix(in srgb, currentColor 10%, transparent);padding:0.1em 0.4em;border-radius:3px;vertical-align:baseline",wrap:"display:inline-flex;align-items:baseline;gap:0.4em;flex-wrap:wrap"};function D(t,n,e){const a=P(t,n),i=t.id||"",r=o`<span style="${s.badge}">bash_bg</span>`,p=o`<span style="${s.action}">${t.action}</span>`,d=a&&i?o` <span style="${s.name}">${a}</span> <span style="${s.id}">(${i})</span>`:a?o` <span style="${s.name}">${a}</span>`:i?o` <span style="${s.id}">${i}</span>`:o``;let c="";switch(t.action){case"create":c=t.command?o`<span style="${s.mono}">${t.command.slice(0,60)}</span>`:"";break;case"logs":t.tail&&(c=o`<span style="${s.detail}">tail ${t.tail}</span>`);break;case"grep":t.pattern&&(c=o`<span style="${s.codePill}">/${t.pattern}/</span>`);break;case"head":t.lines&&(c=o`<span style="${s.detail}">${t.lines} lines</span>`);break;case"slice":c=o`<span style="${s.detail}">lines ${t.from||"?"}–${t.to||"?"}</span>`;break;case"wait":t.timeout&&(c=o`<span style="${s.detail}">up to ${S(t.timeout)}</span>`);break;case"list":return o`<span style="${s.wrap}">${r} ${p}${e}</span>`}const f=c?o`<span style="${s.sep}">—</span>`:o``;return o`<span style="${s.wrap}">${r} ${p}${d} ${f} ${c}${e}</span>`}function M(t,n,e){const a=k(t,n);return o` <span style="${s.detail}" title="Elapsed since the tool call started">· <live-timer .startTime=${a} .running=${e}></live-timer></span>`}class _{render(n,e,a){const i=!e||!!a,r=n?.action==="wait"?M(n,e,i):o``,p=n?D(n,e,r):o`<span>background process</span>`,d=v(e,!e),c=typeof e?.content=="string"?e.content:e?.content?.filter(m=>m.type==="text").map(m=>m.text).join(`
`)||"";if(!e)return{content:x(d,y,p),isCustom:!1};const f=g(),u=g();return{content:o`
				<div>
					${w(d,y,p,f,u,!1)}
					<div ${h(f)} class="max-h-0 overflow-hidden transition-all duration-300">
						<console-block .content=${c||"(no output)"}></console-block>
					</div>
				</div>
			`,isCustom:!1}}}export{_ as BgProcessRenderer};
