import{aQ as p}from"./@ui-core-DKdciH1Z.js";import{x as m}from"./index-D7KLAbvI.js";function y({deleteFn:u,queryKeyToInvalidate:a,setRowSelection:n}){const i=p(),{toast:o}=m();async function c(s){if(s.length)try{const r=(await Promise.allSettled(s.map(e=>u(e)))).map((e,t)=>({id:s[t],status:e.status,error:e.status==="rejected"?e.reason:null})).filter(e=>e.status==="rejected"),d=Object.fromEntries(r.map(e=>[e.id,!0]));n(d),r.length===0?o({description:"All items deleted successfully.",status:"success",emphasis:"subtle",rounded:!0}):(console.error(`Failed to delete items:
`,r.map(({id:e,error:t})=>`${e}: ${t}`).join(`
`)),r.forEach(({id:e,error:t})=>{o({status:"error",emphasis:"subtle",description:s.length<2?`${t}`:`Failed to delete ${e}: ${t}`,rounded:!0})})),await i.invalidateQueries({queryKey:a})}catch(l){console.error("Bulk delete operation failed:",l),o({status:"error",emphasis:"subtle",description:"Bulk delete operation failed unexpectedly",rounded:!0})}}return{bulkDelete:c}}export{y as u};
