import{L as t}from"./p-7d7c5a26.js";import{g as o}from"./p-ab760d78.js";import{T as s,S as i,Q as e}from"./p-02206696.js";import{E as n}from"./p-c38765d6.js";import{D as r}from"./p-7b056a4f.js";class c{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)}calculateItemsByPosition(t){if(this.topContainer&&"top"===t){const t=this.topContainer.childElementCount;this.topContainer.classList.remove("more-odd","more-even"),t>1&&this.topContainer.classList.add("more-odd"),t>2&&this.topContainer.classList.add("more-even")}if(this.bottomContainer&&"bottom"===t){const t=this.bottomContainer.childElementCount;this.bottomContainer.classList.remove("more-odd","more-even"),t>1&&this.bottomContainer.classList.add("more-odd"),t>2&&this.bottomContainer.classList.add("more-even")}}shouldQueue(t){return this.topContainer||"top"!==t.position||(this.topContainer=o("top"),this.topContainer.addEventListener("slotchange",(()=>console.log("change")))),this.bottomContainer||"bottom"!==t.position||(this.bottomContainer=o("bottom")),("bottom"===t.position?this.bottomContainer:this.topContainer).childElementCount>=(s.isMobile()?1:4)}prepareNotification(t){var o;if(this.shouldQueue(t))setTimeout((()=>this.prepareNotification(t)),250);else{const s=document.createElement("x-notification");if(t.label){const o=document.createElement("h4");o.innerText=t.label,s.appendChild(o)}t.onclose&&s.addEventListener("close",t.onclose);const i=document.createElement("p");i.innerHTML=t.message,s.appendChild(i),t.color&&s.setAttribute("color",t.color),t.icon&&s.setAttribute("icon",t.icon),t.interval&&s.setAttribute("interval",t.interval.toString()),("bottom"===t.position?this.bottomContainer:this.topContainer).insertAdjacentElement("afterbegin",s),this.calculateItemsByPosition(null!==(o=t.position)&&void 0!==o?o:"top")}}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 c;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=c.create();window.lang=t,window.notification=a,window.store=i,window.theme=s,window.query=e,window.errors=n,window.dialog=r;const h={lang:t,notification:a,store:i,theme:s,query:e,errors:n,dialog:r};export{h as UI}