import{j as r}from"./@radix-3bj3otF9.js";import{h as f}from"./@tanstack-CByuvRcg.js";import{x as h}from"./index-Cs2FY84s.js";function b({deleteFn:i,queryKeyToInvalidate:a,setRowSelection:u}){const c=f(),{toast:n}=h();async function d(o){if(o.length)try{const s=(await Promise.allSettled(o.map(e=>i(e)))).map((e,t)=>({id:o[t],status:e.status,error:e.status==="rejected"?e.reason:null})).filter(e=>e.status==="rejected"),m=Object.fromEntries(s.map(e=>[e.id,!0]));if(u(m),s.length===0)n({description:"All items deleted successfully.",status:"success",emphasis:"subtle",rounded:!0});else{const e=s.length;console.error(`Failed to delete items:
`,s.map(({id:t,error:p})=>`${t}: ${p}`).join(`
`)),n({status:"error",emphasis:"subtle",description:r.jsxs("p",{children:["Failed to delete ",e," item",e>1?"s":"",":",s.map(({id:t})=>r.jsxs(r.Fragment,{children:[r.jsx("br",{}),r.jsx("span",{children:t})]},t))]}),rounded:!0})}await c.invalidateQueries({queryKey:a})}catch(l){console.error("Bulk delete operation failed:",l),n({status:"error",emphasis:"subtle",description:"Bulk delete operation failed unexpectedly",rounded:!0})}}return{bulkDelete:d}}export{b as u};
