import{r as l,j as e}from"./@radix-3bj3otF9.js";import{N as R,O as C,B as h,Q as w,R as b,L as y,M as O}from"./index-1REJ-mbf.js";import{S as m}from"./trash-B0fyghWi.js";import{A as v}from"./AlertDialogDropdownItem-CAlqlfdb.js";import{D as f,a as p}from"./DeleteAlertDialog-BUIIlTob.js";import{c as A}from"./helper-BXlR2ZLp.js";import{u as S}from"./delete-run-CXwbsSWi.js";import{u as T}from"./bulk-delete-C0Pqi-YB.js";const{ContextProvider:F,useContext:c}=A();function x(){const{setRowSelection:n}=c(),{mutateAsync:t}=S();async function s(r){await t({runId:r})}return T({deleteFn:s,queryKeyToInvalidate:["runs"],setRowSelection:n})}function H({id:n}){const[t,s]=l.useState(!1),[r,a]=l.useState(!1),i=l.useRef(null),u=l.useRef(null),{bulkDelete:D}=x();async function g(){await D([n]),d(!1)}function j(){u.current=i.current}function d(o){if(o===!1){a(!1),setTimeout(()=>{s(o)},200);return}s(o)}return e.jsxs(R,{onOpenChange:a,open:r,children:[e.jsx(C,{ref:i,asChild:!0,children:e.jsx(h,{intent:"secondary",emphasis:"minimal",className:"flex aspect-square items-center justify-center p-0",children:e.jsx(w,{className:"h-4 w-4 shrink-0 fill-theme-text-tertiary"})})}),e.jsx(b,{hidden:t,onCloseAutoFocus:o=>{u.current&&(u.current.focus(),u.current=null,o.preventDefault())},align:"end",sideOffset:7,children:e.jsx(v,{onSelect:j,open:t,onOpenChange:d,triggerChildren:"Delete",icon:e.jsx(m,{fill:"red"}),children:e.jsx(f,{title:"Delete Run",handleDelete:g,children:e.jsxs(p,{children:[e.jsx("p",{children:"Are you sure?"}),e.jsx("p",{children:"This action cannot be undone."})]})})})})]})}function I(){const[n,t]=l.useState(!1),{selectedRowCount:s,selectedRowIDs:r}=c(),{bulkDelete:a}=x();async function i(){await a(r),t(!1)}return e.jsxs(y,{open:n,onOpenChange:t,children:[e.jsx(O,{asChild:!0,children:e.jsxs(h,{className:"rounded-sharp border-y-0 bg-white",size:"md",emphasis:"subtle",intent:"secondary",children:[e.jsx(m,{className:"h-5 w-5 shrink-0 gap-1 fill-neutral-400"}),"Delete"]})}),e.jsx(f,{title:`Delete Run${s>=2?"s":""}`,handleDelete:i,children:e.jsxs(p,{children:[e.jsx("p",{children:"Are you sure?"}),e.jsx("p",{children:"This action cannot be undone."})]})})]})}function P(){const{selectedRowCount:n}=c();return e.jsxs("div",{className:"flex items-center divide-x divide-theme-border-moderate overflow-hidden rounded-md border border-theme-border-moderate",children:[e.jsx("div",{className:"bg-primary-25 px-2 py-1 font-semibold text-theme-text-brand",children:`${n} Run${n>1?"s":""} selected`}),e.jsx(I,{})]})}export{F as R,H as a,P as b,c as u};
