import{L as Lang}from"./lang-f2a3d40c.js";import{g as getNotificationContainerElement}from"./helpers-ea9d01ce.js";import{S as Store,T as Theme,Q as Query}from"./theme-dedf84ae.js";import{E as Errors}from"./errors-f0c693af.js";import{D as Dialog}from"./dialog-f787c09c.js";var MAX_ELEMENTS_ON_CONTAINER=4;var NotificationService=function(){function t(t,i){if(t===void 0){t=null}if(i===void 0){i=null}this.topContainer=t;this.bottomContainer=i;this.topContainer=getNotificationContainerElement("top");this.bottomContainer=getNotificationContainerElement("bottom")}t.prototype.call=function(t){if(typeof t==="string"){this.prepareNotification({message:t})}else{this.prepareNotification(t)}};t.prototype.shouldQueue=function(t){if(!this.topContainer&&t.position==="top"){this.topContainer=getNotificationContainerElement("top")}if(!this.bottomContainer&&t.position==="bottom"){this.bottomContainer=getNotificationContainerElement("bottom")}return(t.position==="bottom"?this.bottomContainer:this.topContainer).childElementCount>=MAX_ELEMENTS_ON_CONTAINER};t.prototype.prepareNotification=function(t){var i=this;if(this.shouldQueue(t)){setTimeout((function(){return i.prepareNotification(t)}),250)}else{var o=document.createElement("x-notification");if(t.label){var e=document.createElement("h4");e.innerText=t.label;o.appendChild(e)}if(t.onclose){o.addEventListener("close",t.onclose)}var n=document.createElement("p");n.innerHTML=t.message;o.appendChild(n);t.color&&o.setAttribute("color",t.color);t.icon&&o.setAttribute("icon",t.icon);t.interval&&o.setAttribute("interval",t.interval.toString());(t.position==="bottom"?this.bottomContainer:this.topContainer).insertAdjacentElement("afterbegin",o)}};t.prototype.success=function(t,i,o,e){this.prepareNotification({color:"success",label:i||Lang("alert.success"),message:t,icon:o,interval:e})};t.prototype.fail=function(t,i,o,e){this.prepareNotification({color:"danger",label:i||Lang("alert.danger"),message:t,icon:o,interval:e})};t.create=function(){var i=new t;return Object.assign((function(t){return i.call(t)}),{success:function(t,o,e,n){return i.success(t,o,e,n)},fail:function(t,o,e,n){return i.fail(t,o,e,n)}})};return t}();var Notification=NotificationService.create();window.lang=Lang;window.notification=Notification;window.store=Store;window.theme=Theme;window.query=Query;window.errors=Errors;window.dialog=Dialog;var Services={lang:Lang,notification:Notification,store:Store,theme:Theme,query:Query,errors:Errors,dialog:Dialog};var UI=Services;export{UI};