import{j as e,L as D,h as f}from"./vendor-tanstack-BpuysabX.js";import{q as g,I as x,y as s,cN as y}from"./index-CREafGO4.js";import{D as w,a as j,b as C,c as B,d as m}from"./dropdown-menu-DZExFL3b.js";import{u as v}from"./use-delete-confirmation-dialog-BgQibraR.js";const E=({blockDocument:n,onDelete:l})=>{const t=u=>{navigator.clipboard.writeText(u),s.success("Copied to clipboard!")},{id:c,name:r}=n;return e.jsxs(w,{children:[e.jsx(j,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"size-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(x,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(C,{align:"end",children:[e.jsx(B,{children:"Actions"}),r&&e.jsx(m,{onClick:()=>t(r),children:"Copy Name"}),e.jsx(D,{to:"/blocks/block/$id/edit",params:{id:c},children:e.jsx(m,{children:"Edit"})}),e.jsx(m,{variant:"destructive",onClick:l,children:"Delete"})]})]})},I=()=>{const n=f(),[l,t]=v(),{deleteBlockDocument:c,mutateAsync:r}=y();return[l,(o,{shouldNavigate:h=!1,onSuccess:p=()=>{}}={})=>{if(Array.isArray(o)){const d=async()=>{try{await Promise.all(o.map(a=>r(a))),s.success("Blocks deleted"),h&&n({to:"/blocks"})}catch(a){const k=a instanceof Error?a.message:"Unknown error while deleting block.";s.error(k),console.error(k)}},i=o.length>1?`Are you sure you want to delete these ${o.length} selected blocks?`:"Are you sure you want to delete this selected block?";t({title:"Delete Blocks",description:i,onConfirm:()=>{d(),p()}})}else t({title:"Delete Block",description:`Are you sure you want to delete ${o.name?o.name:"this block"}?`,onConfirm:()=>{c(o.id,{onSuccess:()=>{s.success("Block deleted"),h&&n({to:"/blocks"}),p()},onError:d=>{const i=d.message||"Unknown error while deleting block.";s.error(i),console.error(i)}})}})}]};export{E as B,I as u};
//# sourceMappingURL=use-delete-block-document-confirmation-dialog-DV_EAvQF.js.map
