import{L as Lang}from"./lang-ab474817.js";import{g as getNotificationContainerElement}from"./helpers-3d0ba5b1.js";import{T as Theme,S as Store,Q as Query}from"./theme-83657d68.js";import{E as Errors}from"./errors-2db24f13.js";import{D as Dialog}from"./dialog-38393991.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.calculateItemsByPosition=function(t){if(this.topContainer&&t==="top"){var i=this.topContainer.childElementCount;this.topContainer.classList.remove("more-odd","more-even");i>1&&this.topContainer.classList.add("more-odd");i>2&&this.topContainer.classList.add("more-even")}if(this.bottomContainer&&t==="bottom"){var i=this.bottomContainer.childElementCount;this.bottomContainer.classList.remove("more-odd","more-even");i>1&&this.bottomContainer.classList.add("more-odd");i>2&&this.bottomContainer.classList.add("more-even")}};t.prototype.shouldQueue=function(t){if(!this.topContainer&&t.position==="top"){this.topContainer=getNotificationContainerElement("top");this.topContainer.addEventListener("slotchange",(function(){return console.log("change")}))}if(!this.bottomContainer&&t.position==="bottom"){this.bottomContainer=getNotificationContainerElement("bottom")}return(t.position==="bottom"?this.bottomContainer:this.topContainer).childElementCount>=(Theme.isMobile()?1:MAX_ELEMENTS_ON_CONTAINER)};t.prototype.prepareNotification=function(t){var i=this;var o;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 r=document.createElement("p");r.innerHTML=t.message;e.appendChild(r);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);this.calculateItemsByPosition((o=t.position)!==null&&o!==void 0?o:"top")}};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};