import{E as g,r as v,c as i,a as r,i as f,e as y,w as s,g as w,n as $,d as b,t as n,b as c,o as l,j as C}from"./app-CYVHboi-.js";import{_ as R}from"./DialogModal-BGpz32gV.js";import{_ as B}from"./SecondaryButton-CHQvCfls.js";import{_ as h}from"./DangerButton-dMO1Xwz1.js";const x={class:"text-mute flex items-center gap-4"},N={class:"text-red-500"},V={key:0,class:"mt-4 font-extrabold text-red-500"},D={class:"mt-2"},F={__name:"Actions",props:{row:{type:Object},record:{type:String},deleted:{type:Boolean},editRow:{type:Function},deleting:{type:Boolean},permission:{type:String},deleteRow:{type:Function}},setup(e){const m=e,a=C(!1);g(()=>m.deleted,t=>{console.log("watch deleted",t),t==m.row.id&&(a.value=!1)});function k(t){m.deleteRow(t)}return(t,o)=>{const u=v("Icon");return l(),i("div",x,[e.editRow&&t.$can("update-"+e.permission)?(l(),i("button",{key:0,type:"button",class:"link",onClick:o[0]||(o[0]=d=>e.editRow(e.row))},[r(u,{name:"edit-o"})])):f("",!0),e.deleteRow&&t.$can("delete-"+e.permission)?(l(),i("button",{key:1,type:"button",onClick:o[1]||(o[1]=d=>a.value=!0)},[e.row.deleted_at?(l(),y(u,{key:0,name:"trash",class:"link-red"})):(l(),y(u,{key:1,name:"trash-o",class:"link-red"}))])):f("",!0),r(w(R),{show:a.value,onClose:o[4]||(o[4]=d=>a.value=!1),"max-width":"sm",backdrop:!e.deleting,closeable:!e.deleting},{title:s(()=>[c("span",N,n(t.$t("Delete {x}",{x:e.record||t.$t("record")}))+"? ",1)]),content:s(()=>[c("p",null,n(t.$t("Are you sure you want to delete the {record}?",{record:e.record||t.$t("record")})),1),e.row.deleted_at?(l(),i("div",V,[c("p",null,n(t.$t("{x} will be deleted permanently from system.",{x:e.record||t.$t("Record")})),1),c("p",D,n(t.$t("This action is not reversible!",{x:e.record||t.$t("Record")})),1)])):f("",!0)]),footer:s(()=>[r(w(B),{onClick:o[2]||(o[2]=d=>a.value=!1),class:$({"opacity-25":e.deleting}),disabled:e.deleting},{default:s(()=>[b(n(t.$t("Cancel")),1)]),_:1},8,["class","disabled"]),r(w(h),{class:$(["ms-3",{"opacity-25":e.deleting}]),onClick:o[3]||(o[3]=d=>k(e.row)),disabled:e.deleting},{default:s(()=>[b(n(t.$t("Delete {x}",{x:e.record||t.$t("record")})),1)]),_:1},8,["class","disabled"])]),_:1},8,["show","backdrop","closeable"])])}}};export{F as _};
