(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.ToastficVue={},d.Vue))})(this,function(d,e){"use strict";const T=e.ref([]);let Z=0;function u(o,s="info",a={}){const{duration:n,description:l,handle:_}=a;T.value.unshift({id:Z++,title:o,type:s,duration:n,description:l,handle:_})}function x(o){T.value=T.value.filter(s=>s.id!==o)}function E(){return{toasts:T,addToast:u,removeToast:x}}const z=["toastfic-theme"],A=e.defineComponent({__name:"Toast",props:{close:{type:Boolean,default:!0},duration:{default:4e3},automaticClose:{type:Boolean,default:!0},position:{default:"top-right"},colorful:{type:Boolean,default:!0},maxToasts:{default:7},theme:{default:"light"},progressBar:{type:Boolean,default:!0},classes:{default:void 0}},setup(o){const{toasts:s,removeToast:a}=E(),n=o,l=e.computed(()=>{switch(n.position){case"top-center":return"toastfic-top-center";case"top-left":return"toastfic-top-left";case"top-right":return"toastfic-top-right";case"bottom-left":return"toastfic-bottom-left";case"bottom-right":return"toastfic-bottom-right";case"bottom-center":return"toastfic-bottom-center";default:return"toastfic"}}),_=e.computed(()=>s.value.slice(0,n.maxToasts)),C=new Map,I=e.ref({});function pe(){n.automaticClose&&_.value.forEach(c=>{var i;if(!((i=c.handle)!=null&&i.click)&&!C.has(c.id)){const t=c.duration??n.duration,r=Date.now(),p=setInterval(()=>{const g=Date.now()-r,m=Math.min(g/t*100,100);I.value[c.id]=m,m>=100&&clearInterval(p)},100),k=setTimeout(()=>{clearInterval(p),a(c.id),C.delete(c.id)},t);C.set(c.id,k)}})}function _e(c,i){c&&i!==void 0&&(c(),a(i))}function me(c,i){var k,g,m,$;let t=i.description?i.description.length<36?58:80:52;(k=i.handle)!=null&&k.click&&i.description?t+=30:(g=i.handle)!=null&&g.click&&(t+=20);let r=0;for(let B=0;Bi?c.slice(0,i)+"...":c}function ue(c){var i,t,r,p;return c==="default"?((i=n.classes)==null?void 0:i.icon)??"":((r=(t=n.classes)==null?void 0:t.icons)==null?void 0:r[c])??((p=n.classes)==null?void 0:p.icon)??""}function ke(c){var i,t,r;return((t=(i=n.classes)==null?void 0:i.toasts)==null?void 0:t[c])??((r=n.classes)==null?void 0:r.toast)??""}return e.watchEffect(()=>{pe()}),e.onBeforeUnmount(()=>{C.forEach(c=>clearTimeout(c))}),e.provide("isIconColor",e.ref(n.colorful)),(c,i)=>(e.openBlock(),e.createBlock(e.TransitionGroup,{name:l.value},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(t,r)=>{var p,k,g,m,$,B,h,w,V,N;return e.openBlock(),e.createElementBlock("div",{key:t.id,class:e.normalizeClass([[`toastfic-position-${n.position}`,(p=n.classes)==null?void 0:p.toast,{"toastfic-description":t.description},[ke(t.type),(k=n.classes)==null?void 0:k.toast]],"toastfic"]),style:e.normalizeStyle([me(r,t),{alignItems:!t.description&&!((g=t.handle)!=null&&g.click)?"center":"flex-start"}]),"toastfic-theme":c.theme},[n.close?(e.openBlock(),e.createBlock(e.unref(re),{key:0,class:e.normalizeClass((m=n.classes)==null?void 0:m.buttonClose),onClick:y=>e.unref(a)(t.id)},null,8,["class","onClick"])):e.createCommentVNode("",!0),t.type!=="default"?(e.openBlock(),e.createBlock(e.unref(ae),{key:1,class:e.normalizeClass([ue(t.type),($=n.classes)==null?void 0:$.icon]),type:t.type},null,8,["class","type"])):e.createCommentVNode("",!0),e.createElementVNode("section",{style:e.normalizeStyle({justifyContent:!t.description&&!((B=t.handle)!=null&&B.click)?"center":"space-between"})},[e.createElementVNode("div",null,[e.createVNode(e.unref(j),{class:e.normalizeClass((h=n.classes)==null?void 0:h.title)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:2},1032,["class"]),t.description?(e.openBlock(),e.createBlock(e.unref(q),{key:0,class:e.normalizeClass((w=n.classes)==null?void 0:w.description)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(he(t.description||"",65)),1)]),_:2},1032,["class"])):e.createCommentVNode("",!0)]),(V=t.handle)!=null&&V.click?(e.openBlock(),e.createBlock(e.unref(de),{key:0,class:e.normalizeClass((N=n.classes)==null?void 0:N.buttonHandle),onClick:y=>{var S;return _e((S=t.handle)==null?void 0:S.click,t.id)}},{default:e.withCtx(()=>{var y;return[e.createTextVNode(e.toDisplayString((y=t.handle)==null?void 0:y.text),1)]}),_:2},1032,["class","onClick"])):e.createCommentVNode("",!0)],4),n.progressBar?(e.openBlock(),e.createElementBlock("div",{key:2,class:"progress-bar",style:e.normalizeStyle([{width:`${I.value[t.id]}%`},{backgroundColor:t.type!=="default"&&n.colorful?`var(--toastfic-${t.type}-icon)`:"var(--toastfic-icon)"}])},null,4)):e.createCommentVNode("",!0)],14,z)}),128))]),_:1},8,["name"]))}}),f=(o,s)=>{const a=o.__vccOpts||o;for(const[n,l]of s)a[n]=l;return a},L=f(A,[["__scopeId","data-v-0bd71293"]]),M={};function D(o,s){return e.openBlock(),e.createElementBlock("h1",null,[e.renderSlot(o.$slots,"default",{},void 0,!0)])}const j=f(M,[["render",D],["__scopeId","data-v-b0f678f5"]]),H={};function O(o,s){return e.openBlock(),e.createElementBlock("span",null,[e.renderSlot(o.$slots,"default",{},void 0,!0)])}const q=f(H,[["render",O],["__scopeId","data-v-0f8bfdba"]]),F={},G={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:"#1a1a1a",viewBox:"0 0 256 256"},P=[e.createElementVNode("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm45.66,85.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z"},null,-1)];function U(o,s){return e.openBlock(),e.createElementBlock("svg",G,P)}const W=f(F,[["render",U]]),J={},K={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:"#1a1a1a",viewBox:"0 0 256 256"},Q=[e.createElementVNode("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,130.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32L139.31,128Z"},null,-1)];function R(o,s){return e.openBlock(),e.createElementBlock("svg",K,Q)}const b=f(J,[["render",R]]),X={},Y={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:"#1a1a1a",viewBox:"0 0 256 256"},v=[e.createElementVNode("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"},null,-1)];function ee(o,s){return e.openBlock(),e.createElementBlock("svg",Y,v)}const te=f(X,[["render",ee]]),oe={},ne={xmlns:"http://www.w3.org/2000/svg",width:"32",height:"32",fill:"#1a1a1a",viewBox:"0 0 256 256"},se=[e.createElementVNode("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"},null,-1)];function ce(o,s){return e.openBlock(),e.createElementBlock("svg",ne,se)}const ie=f(oe,[["render",ce]]),ae=f(e.defineComponent({__name:"ToastIcon",props:{type:{}},setup(o){const s=o,a={success:W,error:b,info:ie,warning:te},n=e.inject("isIconColor");if(!n)throw new b("isIconColor not provided");return(l,_)=>(e.openBlock(),e.createElementBlock("div",null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a[s.type]),{class:e.normalizeClass(["icon",{[`icon-${s.type}`]:e.unref(n)}])},null,8,["class"]))]))}}),[["__scopeId","data-v-fa13e8fb"]]),le=[(o=>(e.pushScopeId("data-v-e7467c53"),o=o(),e.popScopeId(),o))(()=>e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",fill:"var(--toastfic-icon)",viewBox:"0 0 256 256"},[e.createElementVNode("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})],-1))],re=f(e.defineComponent({__name:"ToastClose",emits:["click"],setup(o,{emit:s}){const a=s;return(n,l)=>(e.openBlock(),e.createElementBlock("button",{class:"toastfic-close",onClick:l[0]||(l[0]=_=>a("click"))},le))}}),[["__scopeId","data-v-e7467c53"]]),de=f(e.defineComponent({__name:"ToastAction",emits:["click"],setup(o,{emit:s}){const a=s;return(n,l)=>(e.openBlock(),e.createElementBlock("span",{class:"toastific-action",onClick:l[0]||(l[0]=_=>a("click"))},[e.renderSlot(n.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-b4f72e47"]]),fe={info(o,s={}){u(o,"info",s)},success(o,s={}){u(o,"success",s)},error(o,s={}){u(o,"error",s)},warning(o,s={}){u(o,"warning",s)},default(o,s={}){u(o,"default",s)}};d.Toast=L,d.addToast=u,d.removeToast=x,d.useToast=fe,d.useToasts=E,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});