import{bc as v,bb as j,aY as r,a_ as N,aT as t,a2 as k,V as w,a as S,a5 as E,aq as d,aE as C,aD as R,g as A,a4 as L,E as q,H as I,U as T,u as $,aR as D,as as z,b9 as F}from"./chunk-02oqS8tD.js";import{s as B}from"./chunk-Cd_gpmCR.js";import"./chunk-B8Q4vgLh.js";import"./chunk-x_Z6cwvR.js";import"./chunk-CoYD1fGq.js";const H={"workflow-replay":"Replay",responsive:"Responsive",accessibility:"Accessibility",visual:"Visual","page-quality":"Page quality","network-session":"Network",manual:"Manual"};function O(){const c=v(s=>s.go),u=j(s=>s.projectId),[m,i]=r.useState("loading"),[a,x]=r.useState([]),[n,p]=r.useState(""),[l,g]=r.useState("all"),o=r.useCallback(async()=>{i("loading");try{x(await N(100,u??void 0)),i("ready")}catch{i("error")}},[u]);r.useEffect(()=>{o()},[o]);const f=r.useMemo(()=>{const s=n.trim().toLowerCase();return a.filter(e=>l==="failed"?e.status==="failed"||e.status==="error":!0).filter(e=>s===""||e.title.toLowerCase().includes(s)||(e.summary??"").toLowerCase().includes(s)||(e.snapshot?.url??"").toLowerCase().includes(s))},[a,n,l]),b=a.filter(s=>s.status==="failed"||s.status==="error").length,y=async s=>{await z(s.id),await o(),F.info("Execution deleted")};return t.jsxs(k,{title:"Executions",subtitle:"Every tool's results, newest first.",onBack:()=>c(D("tools")),sticky:a.length>0?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"relative",children:[t.jsx(T,{className:"absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),t.jsx($,{value:n,onChange:s=>p(s.target.value),placeholder:"Filter by title, result or URL",className:"h-7 pl-7 text-xs"})]}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-stroke/15 p-0.5 dark:bg-white/[0.04]",children:[{id:"all",label:`All ${String(a.length)}`},{id:"failed",label:`Failed ${String(b)}`}].map(s=>t.jsx("button",{type:"button",onClick:()=>g(s.id),className:d("flex-1 rounded px-2 py-1 text-[10px] font-semibold transition-colors",l===s.id?"bg-white text-dynamic-azure shadow-sm dark:bg-midnight-navy":"text-muted-foreground hover:text-foreground"),children:s.label},s.id))})]}):void 0,children:[t.jsx(w,{children:t.jsx(S,{status:m==="loading"?"loading":m==="error"?"error":"ready",data:f,onRetry:()=>void o(),loadingLabel:"Loading executions…",empty:t.jsx(q,{icon:I,title:a.length===0?"No executions yet.":l==="failed"?"Nothing has failed.":`Nothing matches “${n}”`,description:a.length===0?"Run your first browser test and we'll capture everything needed to understand the result.":void 0}),children:s=>t.jsx("div",{className:"space-y-1.5",children:s.map(e=>{const h=e.status==="failed"||e.status==="error";return t.jsxs("div",{className:d("flex items-center gap-2 rounded-lg border px-2.5 py-2",h?"border-alert-orange/30 bg-alert-orange/[0.05]":"border-stroke/70 dark:border-stroke/25"),children:[t.jsxs("button",{type:"button",onClick:()=>c({name:"execution-detail",executionId:e.id}),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[h?t.jsx(E,{className:"h-3 w-3 shrink-0 text-alert-orange"}):t.jsx("span",{className:d("h-1.5 w-1.5 shrink-0 rounded-full",e.status==="running"?"animate-pulse bg-dynamic-azure":"bg-emerald-500")}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium",children:e.title}),t.jsx("span",{className:"shrink-0 rounded bg-stroke/25 px-1 py-0.5 text-[8.5px] font-semibold uppercase text-muted-foreground",children:H[e.kind]})]}),t.jsx("span",{className:"mt-0.5 block truncate text-[9.5px] text-muted-foreground",children:e.summary??e.error??e.status}),e.snapshot&&t.jsx("span",{className:"block truncate text-[9px] text-muted-foreground/80",children:B(e.snapshot)}),t.jsxs("span",{className:"block text-[9px] text-muted-foreground/70",children:[C(e.startedAt),e.finishedAt?` · ${R(e.finishedAt-e.startedAt)}`:"",e.evidenceCount>0?` · ${String(e.evidenceCount)} evidence`:""]})]}),t.jsx(A,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"})]}),t.jsx("button",{type:"button",onClick:()=>void y(e),title:"Delete this execution and its evidence",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-alert-orange/15 hover:text-alert-orange",children:t.jsx(L,{className:"h-3 w-3"})})]},e.id)})})})}),a.length>0&&t.jsx("p",{className:"text-[9.5px] leading-relaxed text-muted-foreground",children:"Executions are kept on this machine, oldest shed first, within a fixed storage budget. Evidence artifacts uploaded to a test run live in TCR and are not affected by that."})]})}export{O as ExecutionsScreen};
//# sourceMappingURL=chunk-BIvv5MVe.js.map
