import{r as S,b as x,d as k,o,c,a as t,n as E,t as d,e as u,w as f,f as I,g as M,h as N,i as h,M as b}from"./app-91dba96b.js";import{u as C}from"./useEmitter-cde057d4.js";import{i as T}from"./index-0653e21c.js";import"./appFunction-1b5b1f43.js";const p=["id","aria-labelledby"],L={class:"modal-dialog modal-dialog-centered"},V={class:"modal-content"},Y={class:"modal-body"},_={class:"text-left"},F=t("br",null,null,-1),U={class:"text-left font-weight-bold msg-white"},$={key:0,class:"text-center"},z={class:"text-left"},A=t("div",{class:"border-top my-4"},null,-1),D={key:1,class:"text-left d-flex gap-2"},j=["disabled"],q=t("i",{class:"bi bi-trash"},null,-1),G={key:2,class:"text-left"},P={__name:"deleteModal",props:{modalId:{type:String,default:"app-delete-modal"},title:String,icon:String,subTitle:String,message:String,modalClass:String,firstButtonName:String,secondButtonName:String,showFooter:{type:Boolean,default:!0},selectedUrl:String,callBackEmit:{type:Boolean,default:!1}},emits:["cancelled","confirmed","confirmSuccess"],setup(e,{emit:g}){const l=e,m=g,n=S(!1),y=C(),v=()=>{r(),m("cancelled",!1)},B=async()=>{n.value=!0,await T.delete(l.selectedUrl).then(a=>{r(),h.success(a.data.message),y.emit("reload-table"),l.callBackEmit&&m("confirmSuccess")}).catch(a=>{var s,i;(i=(s=a.response)==null?void 0:s.data)!=null&&i.message&&h.error(a.response.data.message)}).finally(()=>n.value=!1)},w=()=>{new b(document.getElementById(l.modalId)).show()},r=()=>{b.getInstance(document.getElementById(l.modalId)).hide()};return x(()=>{w();let a=document.getElementById(l.modalId),s=document.getElementsByTagName("html")[0];a.addEventListener("hidden.bs.modal",()=>{m("cancelled"),s.style.overflowY="auto"}),a.addEventListener("shown.bs.modal",()=>{s.style.overflowY="hidden"})}),(a,s)=>{const i=k("app-button-loader");return o(),c("div",{class:"modal fade",id:e.modalId,tabindex:"-1","aria-labelledby":`${e.modalId}-ModalLabel`,"aria-hidden":"true"},[t("div",L,[t("div",V,[t("div",Y,[t("div",_,[t("i",{class:E([[e.icon?e.icon:"bi bi-trash-fill",e.modalClass?e.modalClass:"text-danger"],"custom-delete-icon display-3"])},null,2)]),F,t("h4",U,d(e.title?e.title:"Are you sure you want to delete?"),1),e.subTitle?(o(),c("p",$,d(e.subTitle),1)):u("",!0),t("p",z,d(e.message?e.message:"This content will be deleted permanently"),1),A,e.showFooter?(o(),c("div",D,[t("button",{class:"btn btn-secondary mx-1","data-dismiss":"modal",onClick:f(v,["prevent"])},d(e.secondButtonName?e.secondButtonName:"Cancel"),1),t("button",{class:"btn btn-info","data-dismiss":"modal",onClick:f(B,["prevent"]),disabled:n.value},[n.value?(o(),I(i,{key:0})):u("",!0),q,M(" "+d(e.firstButtonName?e.firstButtonName:"Yes"),1)],8,j)])):(o(),c("div",G,[N(a.$slots,"footer")]))])])])],8,p)}}};export{P as default};
