import{M as B,S as y,ak as p,O as k,aF as M,Q as z,$ as v,o as L,s as N,f as a,p as b,aA as j,P as U,I as F,aG as H,W as h,au as V,aH as q,av as A,r as D,aw as G,aI as Q}from"./index-BV0H45HW.js";import{L as W}from"./index-BtHEBb5f.js";let m=0;function _(e){e?(m||document.body.classList.add("van-toast--unclickable"),m++):m&&(m--,m||document.body.classList.remove("van-toast--unclickable"))}const[$,i]=z("toast"),E=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],J={icon:String,show:Boolean,type:k("text"),overlay:Boolean,message:y,iconSize:y,duration:M(2e3),position:k("middle"),teleport:[String,Object],wordBreak:String,className:p,iconPrefix:String,transition:k("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:p,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:y};var K=B({name:$,props:J,emits:["update:show"],setup(e,{emit:t,slots:s}){let c,r=!1;const d=()=>{const o=e.show&&e.forbidClick;r!==o&&(r=o,_(r))},u=o=>t("update:show",o),g=()=>{e.closeOnClick&&u(!1)},f=()=>clearTimeout(c),P=()=>{const{icon:o,type:n,iconSize:C,iconPrefix:I,loadingType:T}=e;if(o||n==="success"||n==="fail")return a(F,{name:o||n,size:C,class:i("icon"),classPrefix:I},null);if(n==="loading")return a(W,{class:i("loading"),size:C,type:T},null)},x=()=>{const{type:o,message:n}=e;if(s.message)return a("div",{class:i("text")},[s.message()]);if(H(n)&&n!=="")return o==="html"?a("div",{key:0,class:i("text"),innerHTML:String(n)},null):a("div",{class:i("text")},[n])};return v(()=>[e.show,e.forbidClick],d),v(()=>[e.show,e.type,e.message,e.duration],()=>{f(),e.show&&e.duration>0&&(c=setTimeout(()=>{u(!1)},e.duration))}),L(d),N(d),()=>a(U,b({class:[i([e.position,e.wordBreak==="normal"?"break-normal":e.wordBreak,{[e.type]:!e.icon}]),e.className],lockScroll:!1,onClick:g,onClosed:f,"onUpdate:show":u},j(e,E)),{default:()=>[P(),x()]})}});const R={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let l=[],X=!1,O=h({},R);const Y=new Map;function S(e){return q(e)?e:{message:e}}function Z(){const{instance:e}=A({setup(){const t=D(""),{open:s,state:c,close:r,toggle:d}=G(),u=()=>{},g=()=>a(K,b(c,{onClosed:u,"onUpdate:show":d}),null);return v(t,f=>{c.message=f}),Q().render=g,{open:s,close:r,message:t}}});return e}function ee(){if(!l.length||X){const e=Z();l.push(e)}return l[l.length-1]}function te(e={}){if(!V)return{};const t=ee(),s=S(e);return t.open(h({},O,Y.get(s.type||O.type),s)),t}const w=e=>t=>te(h({type:e},S(t))),ae=w("loading"),ie=w("success"),le=w("fail"),ce=e=>{l.length&&l[0].close()};export{ie as a,le as b,ae as c,ce as d,K as e,te as s};
