import{L as Lang}from"./lang-0f829b62.js";import{g as getNotificationContainerElement}from"./helpers-e48a05ff.js";import{S as Store,T as Theme,Q as Query}from"./theme-dedf84ae.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 e=document.createElement("x-notification");if(t.label){var n=document.createElement("h4");n.innerText=t.label;e.appendChild(n)}if(t.onclose){e.addEventListener("close",t.onclose)}var o=document.createElement("p");o.innerHTML=t.message;e.appendChild(o);t.color&&e.setAttribute("color",t.color);t.icon&&e.setAttribute("icon",t.icon);t.interval&&e.setAttribute("interval",t.interval.toString());(t.position==="bottom"?this.bottomContainer:this.topContainer).insertAdjacentElement("afterbegin",e)}};t.prototype.success=function(t,i,e,n){this.prepareNotification({color:"success",label:i||Lang("alert.success"),message:t,icon:e,interval:n})};t.prototype.fail=function(t,i,e,n){this.prepareNotification({color:"danger",label:i||Lang("alert.danger"),message:t,icon:e,interval:n})};t.create=function(){var i=new t;return Object.assign((function(t){return i.call(t)}),{success:function(t,e,n,o){return i.success(t,e,n,o)},fail:function(t,e,n,o){return i.fail(t,e,n,o)}})};return t}();var Notification=NotificationService.create();window.lang=Lang;window.notification=Notification;window.store=Store;window.theme=Theme;window.query=Query;var Services={lang:Lang,notification:Notification,store:Store,theme:Theme,query:Query};var UI=Services;export{UI};