import{L as t}from"./p-70e3d1bd.js";import{g as o}from"./p-efbc3883.js";import{S as s,T as i,Q as e}from"./p-07dc3dc6.js";import{E as c}from"./p-3b10ff5c.js";import{D as n}from"./p-c27902e4.js";class r{constructor(t=null,s=null){this.topContainer=t,this.bottomContainer=s,this.topContainer=o("top"),this.bottomContainer=o("bottom")}call(t){this.prepareNotification("string"==typeof t?{message:t}:t)}shouldQueue(t){return this.topContainer||"top"!==t.position||(this.topContainer=o("top")),this.bottomContainer||"bottom"!==t.position||(this.bottomContainer=o("bottom")),("bottom"===t.position?this.bottomContainer:this.topContainer).childElementCount>=4}prepareNotification(t){if(this.shouldQueue(t))setTimeout((()=>this.prepareNotification(t)),250);else{const o=document.createElement("x-notification");if(t.label){const s=document.createElement("h4");s.innerText=t.label,o.appendChild(s)}t.onclose&&o.addEventListener("close",t.onclose);const s=document.createElement("p");s.innerHTML=t.message,o.appendChild(s),t.color&&o.setAttribute("color",t.color),t.icon&&o.setAttribute("icon",t.icon),t.interval&&o.setAttribute("interval",t.interval.toString()),("bottom"===t.position?this.bottomContainer:this.topContainer).insertAdjacentElement("afterbegin",o)}}success(o,s,i,e){this.prepareNotification({color:"success",label:s||t("alert.success"),message:o,icon:i,interval:e})}fail(o,s,i,e){this.prepareNotification({color:"danger",label:s||t("alert.danger"),message:o,icon:i,interval:e})}static create(){const t=new r;return Object.assign((o=>t.call(o)),{success:(o,s,i,e)=>t.success(o,s,i,e),fail:(o,s,i,e)=>t.fail(o,s,i,e)})}}const a=r.create();window.lang=t,window.notification=a,window.store=s,window.theme=i,window.query=e,window.errors=c,window.dialog=n;const l={lang:t,notification:a,store:s,theme:i,query:e,errors:c,dialog:n};export{l as UI}