import{ac as p,dN as u,d7 as f,W as c,A as d,dM as r,z as h,d5 as v,v as y,cZ as E}from"./index-6Jqoo2rk.js";class g extends p{constructor(s,a){super(!1),this.navigationType=s,this.withOverlay=a,this.onClick=i=>{u(i)||this.element&&!(this.element===document.body)&&f(i.target,this.element)||(this.listenerOptions?.capture&&c(i),this.close(i))},this.listenerOptions=a?{}:{capture:!0}}close(s){this.element&&(this.overlay?.remove(),this.element=void 0,this.dispatchEvent("toggle",!1)),d||window.removeEventListener("contextmenu",this.onClick,this.listenerOptions),document.removeEventListener(r,this.onClick,this.listenerOptions),!h&&this.navigationType&&v.removeByType(this.navigationType)}open(s=document.body){this.close(),!h&&this.navigationType&&v.pushItem({type:this.navigationType,onPop:i=>{this.close()}}),this.element=s,!this.overlay&&this.withOverlay&&(this.overlay=document.createElement("div"),this.overlay.classList.add("btn-menu-overlay"),this.overlay.addEventListener(r,i=>{c(i),this.onClick(i)}));const a=this.element===document.body;this.overlay&&(a?this.element.append(this.overlay):this.element.parentElement.insertBefore(this.overlay,this.element)),d||window.addEventListener("contextmenu",this.onClick,{...this.listenerOptions,once:!0}),document.addEventListener(r,this.onClick,this.listenerOptions),this.dispatchEvent("toggle",!0)}}const l=document.createElement("div");l.classList.add("toasts-container");const e=document.createElement("div");e.classList.add("toast");let n;const o=new g("toast");o.addEventListener("toggle",t=>{t||m()});function m(){o.close(),e.classList.remove("is-visible"),n&&clearTimeout(+n),n=window.setTimeout(()=>{e.remove(),n=void 0},200)}function L(t,s){o.close(),E(e,t),e.parentElement||(l.parentNode||document.body.append(l),l.append(e),e.offsetLeft),e.classList.add("is-visible"),n&&clearTimeout(+n),o.open(e),n=window.setTimeout(m,3e3),s&&o.addEventListener("toggle",s,{once:!0})}function w(t){L(y(t.langPackKey,t.langPackArguments),t.onClose)}export{g as O,L as a,m as h,w as t};
//# sourceMappingURL=toast-B3QB1-N7.js.map
