import{_ as M,o as N,j as y,c as h,b as a,Q as d,t as m,v,r as g,S as c,aw as i,ax as O}from"./index-CIAVq8iD-1776148658686.js";const B={key:0,class:"modal-icon"},$={key:1,class:"modal-title"},A={class:"modal-message"},I={class:"modal-actions"},K={__name:"Toast",props:{title:{type:String,default:"Notice"},message:{type:String,required:!0},type:{type:String,default:"error",validator:s=>["error","warning","success","info","simple"].includes(s)},confirmText:{type:String,default:"OK"},clickToClose:{type:Boolean,default:!0},duration:{type:Number,default:null}},emits:["confirm","close"],setup(s,{expose:t,emit:e}){const o=s,n=e,l=g(!1),p=g(""),b=c(()=>o.type==="simple"),w=c(()=>{const f={error:"✕",warning:"⚠",success:"✓",info:"i"};return f[o.type]||f.error}),T=c(()=>`modal-${o.type}`),x=c(()=>`icon-circle-${o.type}`),_=c(()=>`icon-symbol-${o.type}`),k=c(()=>`modal-btn-${o.type}`),C=()=>{l.value=!0,p.value="modal-enter",o.duration&&o.duration>0&&setTimeout(()=>{u()},o.duration)},u=()=>{p.value="modal-leave",setTimeout(()=>{l.value=!1,n("close")},200)},S=()=>{n("confirm"),u()},E=()=>{o.clickToClose&&u()};return N(()=>{C()}),t({show:C,close:u}),(f,q)=>l.value?(y(),h("div",{key:0,class:"modal-overlay",onClick:E},[a("div",{class:d(["modal",[p.value,T.value]])},[b.value?v("",!0):(y(),h("div",B,[a("div",{class:d(["icon-circle",x.value])},[a("span",{class:d(["icon-symbol",_.value])},m(w.value),3)],2)])),s.title&&!b.value?(y(),h("div",$,m(s.title),1)):v("",!0),a("div",A,m(s.message),1),a("div",I,[a("button",{class:d(["modal-btn",k.value]),onClick:S},m(s.confirmText),3)])],2)])):v("",!0)}},V=M(K,[["__scopeId","data-v-b96bc318"]]);class j{constructor(){this.instances=[]}show(t,e={}){const o=document.createElement("div");document.body.appendChild(o);const n=O(V,{message:t,...e,onConfirm:()=>{e.onConfirm&&e.onConfirm(),this.cleanup(n,o)},onClose:()=>{e.onClose&&e.onClose(),this.cleanup(n,o)}});n.use(i);const l=n.mount(o);return this.instances.push(n),{close:()=>l.close(),instance:l}}cleanup(t,e){setTimeout(()=>{e&&e.parentNode&&e.parentNode.removeChild(e),t.unmount();const o=this.instances.indexOf(t);o>-1&&this.instances.splice(o,1)},100)}closeAll(){this.instances.forEach(t=>{const e=t._instance;e&&e.exposed&&e.exposed.close&&e.exposed.close()}),this.instances=[]}}const r=new j,D=(s,t=null)=>{const e=t||i.global.t("error");return r.show(s,{title:e,type:"error"})},Q=(s,t=null)=>{const e=t||i.global.t("information");return r.show(s,{title:e,type:"info"})},W=(s,t=null)=>{const e=t||i.global.t("success");return r.show(s,{title:e,type:"success"})},F=(s,t=null)=>{const e=t||i.global.t("warning");return r.show(s,{title:e,type:"warning"})},G=(s,t={})=>{const e={confirmText:i.global.t("ok")||"OK",type:"simple",...t};return r.show(s,e)};export{D as a,F as b,Q as c,G as d,W as s};
