1const NOTIFICATION_TYPES={SUCCESS:"success",ERROR:"error",WARNING:"warning"},NOTIFICATION_CONFIG={SHOW_DELAY:10,HIDE_DELAY:300,DEFAULT_DURATION:3e3},ICON_TEMPLATES={[NOTIFICATION_TYPES.SUCCESS]:'<svg width="18" height="18" fill="none" class="flex-auto w-18"><use href="#icon-success"></use></svg>',[NOTIFICATION_TYPES.ERROR]:'<svg width="18" height="18" fill="none" class="flex-auto w-18"><use href="#icon-error"></use></svg>',[NOTIFICATION_TYPES.WARNING]:'<svg width="18" height="18" fill="none" class="flex-auto w-18"><use href="#icon-warning"></use></svg>'};class BaseNotification{constructor(containerId,containerClass){this.container=this.getOrCreateContainer(containerId,containerClass),this.activeTimeouts=new Map}getOrCreateContainer(id,className){let container=id?document.getElementById(id):document.querySelector(`.${className}`);return container||(container=document.createElement("div"),id&&(container.id=id),className&&(container.className=className),document.body.appendChild(container)),container}createIcon(type){const iconContainer=document.createElement("span"),iconTemplate=ICON_TEMPLATES[type]||ICON_TEMPLATES[NOTIFICATION_TYPES.SUCCESS];return iconContainer.innerHTML=iconTemplate,iconContainer.firstElementChild}createTextElement(message,className){const textElement=document.createElement("span");return textElement.className=className,textElement.innerHTML=message,textElement}removeExistingNotification(container,selector){const existing=container.querySelector(selector);existing&&(this.clearNotificationTimeouts(existing),existing.remove())}clearNotificationTimeouts(notification){const timeoutIds=this.activeTimeouts.get(notification);timeoutIds&&(timeoutIds.forEach(clearTimeout),this.activeTimeouts.delete(notification))}scheduleNotificationLifecycle(notification,container,duration){const showTimeout=setTimeout(()=>{notification.classList.add("show")},NOTIFICATION_CONFIG.SHOW_DELAY),hideTimeout=setTimeout(()=>{this.hide(notification,container)},duration);this.activeTimeouts.set(notification,[showTimeout,hideTimeout])}hide(notification,container=null){notification.parentNode&&(this.clearNotificationTimeouts(notification),notification.classList.remove("show"),notification.classList.add("remove"),setTimeout(()=>{try{const parent=container||this.container;parent&&parent.contains(notification)&&parent.removeChild(notification)}catch(error){console.warn("Error removing notification:",error)}},NOTIFICATION_CONFIG.HIDE_DELAY))}destroy(){this.activeTimeouts.forEach(timeoutIds=>{timeoutIds.forEach(clearTimeout)}),this.activeTimeouts.clear()}}class AlertNotify extends BaseNotification{constructor(){super("notification-container",null)}show(message,type=NOTIFICATION_TYPES.WARNING,duration=NOTIFICATION_CONFIG.DEFAULT_DURATION){const notification=this.createNotification(message,type,["notification",type]);this.container.appendChild(notification),this.scheduleNotificationLifecycle(notification,this.container,duration)}showElement(message,element=this.container,type=NOTIFICATION_TYPES.WARNING,duration=NOTIFICATION_CONFIG.DEFAULT_DURATION){const container=element||document.getElementById("notification-container");this.removeExistingNotification(container,".notification");const notification=this.createNotificationWithMessage(message,type,["notification","notification-add-cart",type]);container.appendChild(notification),this.scheduleNotificationLifecycle(notification,container,duration)}createNotification(message,type,classes){const notification=document.createElement("div");notification.classList.add(...classes);const icon=this.createIcon(type),text=this.createTextElement(message);return notification.appendChild(icon),notification.appendChild(text),notification}createNotificationWithMessage(message,type,classes){const notification=document.createElement("div");notification.classList.add(...classes);const messageContainer=document.createElement("div");messageContainer.className="notification-message";const text=this.createTextElement(message);return messageContainer.appendChild(text),notification.appendChild(messageContainer),notification}}class AlertNotifyInline extends BaseNotification{constructor(){super(null,"notification-wrapper")}show(message,type=NOTIFICATION_TYPES.WARNING,container=this.container,duration=NOTIFICATION_CONFIG.DEFAULT_DURATION){this.removeExistingNotification(container,".notification_inline");const notification=this.createInlineNotification(message,type);container.appendChild(notification),this.scheduleNotificationLifecycle(notification,container,duration)}showElement(message,element=this.container,type=NOTIFICATION_TYPES.WARNING,duration=NOTIFICATION_CONFIG.DEFAULT_DURATION){this.removeExistingNotification(element,".n
1otification_inline");const notification=this.createInlineNotification(message,type);element.appendChild(notification),this.scheduleNotificationLifecycle(notification,element,duration)}createInlineNotification(message,type){const notification=document.createElement("div");notification.classList.add("notification_inline",type);const icon=this.createIcon(type),text=this.createTextElement(message);return notification.appendChild(icon),notification.appendChild(text),notification}hide(notification,element=null){super.hide(notification,element||this.container)}}export const notifier=new AlertNotify,notifierInline=new AlertNotifyInline;export{NOTIFICATION_TYPES}; 2//# sourceMappingURL=/cdn/shop/t/40/assets/module-notification.js.map?v=141692269369056109421790398562
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.