import{r as l,j as e}from"./@radix-B1sy0Lhr.js";import{L as j,M as R,N as w,O as C,J as b,K as y,B as O}from"./index-CO6UN3UX.js";import{S as h}from"./trash-D9LA4VFD.js";import{A as v}from"./AlertDialogDropdownItem-BpLj419i.js";import{D as f,a as p}from"./DeleteAlertDialog-CzhTVQaC.js";import{c as A,u as S}from"./bulk-delete-wdObjfps.js";import{u as T}from"./delete-run-XSre8ru-.js";const{ContextProvider:F,useContext:c}=A();function m(){const{setRowSelection:n}=c(),{mutateAsync:t}=T();async function s(r){await t({runId:r})}return S({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:x}=m();async function D(){await x([n]),d(!1)}function g(){u.current=i.current}function d(o){if(o===!1){a(!1),setTimeout(()=>{s(o)},200);return}s(o)}return e.jsxs(j,{onOpenChange:a,open:r,children:[e.jsx(R,{ref:i,children:e.jsx(w,{className:"h-4 w-4 fill-theme-text-tertiary"})}),e.jsx(C,{hidden:t,onCloseAutoFocus:o=>{u.current&&(u.current.focus(),u.current=null,o.preventDefault())},align:"end",sideOffset:7,children:e.jsx(v,{onSelect:g,open:t,onOpenChange:d,triggerChildren:"Delete",icon:e.jsx(h,{fill:"red"}),children:e.jsx(f,{title:"Delete Run",handleDelete:D,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}=m();async function i(){await a(r),t(!1)}return e.jsxs(b,{open:n,onOpenChange:t,children:[e.jsx(y,{asChild:!0,children:e.jsxs(O,{className:"rounded-sharp border-y-0 bg-white",size:"md",emphasis:"subtle",intent:"secondary",children:[e.jsx(h,{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 K(){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{H as R,K as a,F as b,c as u};
