preline
Version:
Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.
16 lines • 26.2 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(self,(()=>(()=>{"use strict";var e={223:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BREAKPOINTS=t.COMBO_BOX_ACCESSIBILITY_KEY_SET=t.SELECT_ACCESSIBILITY_KEY_SET=t.TABS_ACCESSIBILITY_KEY_SET=t.OVERLAY_ACCESSIBILITY_KEY_SET=t.DROPDOWN_ACCESSIBILITY_KEY_SET=t.POSITIONS=void 0,t.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},t.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Home","End","Enter"],t.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],t.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],t.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"],t.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],t.BREAKPOINTS={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},248:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this.components=[],this.currentlyOpenedComponents=[],this.activeComponent=null,this.allowedKeybindings=new Set(["Escape","Enter"," ","Space","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Tab","Home","End"]),this.initGlobalListeners()}initGlobalListeners(){document.addEventListener("keydown",(e=>this.handleGlobalKeydown(e))),document.addEventListener("focusin",(e=>this.handleGlobalFocusin(e)))}isAllowedKeybinding(e){return!!this.allowedKeybindings.has(e.key)||!(1!==e.key.length||!/^[a-zA-Z]$/.test(e.key)||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)}getActiveComponent(e){if(!e)return null;const t=this.components.filter((t=>t.wrapper.contains(e)||t.context&&t.context.contains(e)));if(0===t.length)return null;if(1===t.length)return t[0];let i=null,n=Number.MAX_SAFE_INTEGER;for(const o of t){let t=0,s=e;for(;s&&s!==o.wrapper&&s!==o.context;)t++,s=s.parentElement;t<n&&(n=t,i=o)}return i}handleGlobalFocusin(e){const t=e.target;this.activeComponent=this.getActiveComponent(t)}handleGlobalKeydown(e){const t=e.target;if(this.activeComponent=this.getActiveComponent(t),this.activeComponent&&this.isAllowedKeybinding(e))switch(e.key){case"Escape":if(this.activeComponent.isOpened)this.activeComponent.handlers.onEsc&&(this.activeComponent.handlers.onEsc(),e.preventDefault(),e.stopPropagation());else{const i=this.findClosestOpenParent(t);(null==i?void 0:i.handlers.onEsc)&&(i.handlers.onEsc(),e.preventDefault(),e.stopPropagation())}break;case"Enter":this.activeComponent.handlers.onEnter&&(this.activeComponent.handlers.onEnter(),e.preventDefault(),e.stopPropagation());break;case" ":case"Space":if("INPUT"===t.tagName||"TEXTAREA"===t.tagName)return;this.activeComponent.handlers.onSpace&&(this.activeComponent.handlers.onSpace(),e.preventDefault(),e.stopPropagation());break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(this.activeComponent.handlers.onArrow){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;this.activeComponent.handlers.onArrow(e),e.preventDefault(),e.stopPropagation()}break;case"Tab":if(!this.activeComponent.handlers.onTab)break;const i=e.shiftKey?this.activeComponent.handlers.onShiftTab:this.activeComponent.handlers.onTab;i&&i();break;case"Home":this.activeComponent.handlers.onHome&&(this.activeComponent.handlers.onHome(),e.preventDefault(),e.stopPropagation());break;case"End":this.activeComponent.handlers.onEnd&&(this.activeComponent.handlers.onEnd(),e.preventDefault(),e.stopPropagation());break;default:this.activeComponent.handlers.onFirstLetter&&1===e.key.length&&/^[a-zA-Z]$/.test(e.key)&&(this.activeComponent.handlers.onFirstLetter(e.key),e.preventDefault(),e.stopPropagation())}}findClosestOpenParent(e){let t=e.parentElement;for(;t;){const e=this.currentlyOpenedComponents.find((e=>e.wrapper===t&&e!==this.activeComponent));if(e)return e;t=t.parentElement}return null}registerComponent(e,t,i=!0,n="",o="",s){const l={wrapper:e,handlers:t,isOpened:i,name:n,selector:o,context:s,isRegistered:!0};return this.components.push(l),l}updateComponentState(e,t){e.isOpened=t,t?this.currentlyOpenedComponents.includes(e)||this.currentlyOpenedComponents.push(e):this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter((t=>t!==e))}unregisterComponent(e){this.components=this.components.filter((t=>t!==e)),this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter((t=>t!==e))}addAllowedKeybinding(e){this.allowedKeybindings.add(e)}removeAllowedKeybinding(e){this.allowedKeybindings.delete(e)}getAllowedKeybindings(){return Array.from(this.allowedKeybindings)}}},292:function(e,t){
/*
* @version: 3.2.3
* @author: Preline Labs Ltd.
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
* Copyright 2024 Preline Labs Ltd.
*/
Object.defineProperty(t,"__esModule",{value:!0}),t.stringToBoolean=t.menuSearchHistory=t.isScrollable=t.isParentOrElementHidden=t.isJson=t.isIpadOS=t.isIOS=t.isFormElement=t.isFocused=t.isEnoughSpace=t.isDirectChild=t.htmlToElement=t.getZIndex=t.getHighestZIndex=t.getClassPropertyAlt=t.getClassProperty=t.dispatch=t.debounce=t.classToClassList=t.afterTransition=void 0;t.stringToBoolean=e=>"true"===e;t.getClassProperty=(e,t,i="")=>(window.getComputedStyle(e).getPropertyValue(t)||i).replace(" ","");t.getClassPropertyAlt=(e,t,i="")=>{let n="";return e.classList.forEach((e=>{e.includes(t)&&(n=e)})),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:i};const i=e=>window.getComputedStyle(e).getPropertyValue("z-index");t.getZIndex=i;t.getHighestZIndex=e=>{let t=Number.NEGATIVE_INFINITY;return e.forEach((e=>{let n=i(e);"auto"!==n&&(n=parseInt(n,10),n>t&&(t=n))})),t};t.isDirectChild=(e,t)=>{const i=e.children;for(let e=0;e<i.length;e++)if(i[e]===t)return!0;return!1};t.isEnoughSpace=(e,t,i="auto",n=10,o=null)=>{const s=t.getBoundingClientRect(),l=o?o.getBoundingClientRect():null,r=window.innerHeight,a=l?s.top-l.top:s.top,d=(o?l.bottom:r)-s.bottom,c=e.clientHeight+n;return"bottom"===i?d>=c:"top"===i?a>=c:a>=c||d>=c};t.isFocused=e=>document.activeElement===e;t.isFormElement=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement;t.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isJson=e=>{if("string"!=typeof e)return!1;const t=e.trim()[0],i=e.trim().slice(-1);if("{"===t&&"}"===i||"["===t&&"]"===i)try{return JSON.parse(e),!0}catch(e){return!1}return!1};const n=e=>{if(!e)return!1;return"none"===window.getComputedStyle(e).display||n(e.parentElement)};t.isParentOrElementHidden=n;t.isScrollable=e=>{const t=window.getComputedStyle(e),i=t.overflowY,n=t.overflowX,o=("scroll"===i||"auto"===i)&&e.scrollHeight>e.clientHeight,s=("scroll"===n||"auto"===n)&&e.scrollWidth>e.clientWidth;return o||s};t.debounce=(e,t=200)=>{let i;return(...n)=>{clearTimeout(i),i=setTimeout((()=>{e.apply(this,n)}),t)}};t.dispatch=(e,t,i=null)=>{const n=new CustomEvent(e,{detail:{payload:i},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(n)};t.afterTransition=(e,t)=>{const i=()=>{t(),e.removeEventListener("transitionend",i,!0)},n=window.getComputedStyle(e),o=n.getPropertyValue("transition-duration");"none"!==n.getPropertyValue("transition-property")&&parseFloat(o)>0?e.addEventListener("transitionend",i,!0):t()};t.htmlToElement=e=>{const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=(e,t,i=" ",n="add")=>{e.split(i).forEach((e=>{e.trim()&&("add"===n?t.classList.add(e):t.classList.remove(e))}))};const o={historyIndex:-1,addHistory(e){this.historyIndex=e},existsInHistory(e){return e>this.historyIndex},clearHistory(){this.historyIndex=-1}};t.menuSearchHistory=o},850:function(e,t,i){
/*
* HSOverlay
* @version: 3.2.3
* @author: Preline Labs Ltd.
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
* Copyright 2024 Preline Labs Ltd.
*/
var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(292),s=i(223),l=n(i(961)),r=n(i(248));class a extends l.default{constructor(e,t,i){var n,l,r,a,d,c;super(e,t,i),this.lastFocusedToggle=null,this.initialZIndex=0,this.toggleButtons=Array.from(document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`));const h=this.collectToggleParameters(this.toggleButtons);this.toggleMinifierButtons=Array.from(document.querySelectorAll(`[data-hs-overlay-minifier="#${this.el.id}"]`));const u=e.getAttribute("data-hs-overlay-options"),p=u?JSON.parse(u):{},m=Object.assign(Object.assign(Object.assign({},p),h),t);this.hiddenClass=(null==m?void 0:m.hiddenClass)||"hidden",this.emulateScrollbarSpace=(null==m?void 0:m.emulateScrollbarSpace)||!1,this.isClosePrev=null===(n=null==m?void 0:m.isClosePrev)||void 0===n||n,this.backdropClasses=null!==(l=null==m?void 0:m.backdropClasses)&&void 0!==l?l:"hs-overlay-backdrop transition duration fixed inset-0 bg-gray-900/50 dark:bg-neutral-900/80",this.backdropParent="string"==typeof m.backdropParent?document.querySelector(m.backdropParent):document.body,this.backdropExtraClasses=null!==(r=null==m?void 0:m.backdropExtraClasses)&&void 0!==r?r:"",this.moveOverlayToBody=(null==m?void 0:m.moveOverlayToBody)||null,this.openNextOverlay=!1,this.autoHide=null,this.initContainer=(null===(a=this.el)||void 0===a?void 0:a.parentElement)||null,this.isCloseWhenClickInside=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--close-when-click-inside","false")||"false"),this.isTabAccessibilityLimited=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--tab-accessibility-limited","true")||"true"),this.isLayoutAffect=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--is-layout-affect","false")||"false"),this.hasAutofocus=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--has-autofocus","true")||"true"),this.hasDynamicZIndex=(0,o.stringToBoolean)((0,o.getClassProperty)(this.el,"--has-dynamic-z-index","false")||"false"),this.hasAbilityToCloseOnBackdropClick=(0,o.stringToBoolean)(this.el.getAttribute("data-hs-overlay-keyboard")||"true");const y=(0,o.getClassProperty)(this.el,"--auto-close"),f=(0,o.getClassProperty)(this.el,"--auto-close-equality-type"),v=(0,o.getClassProperty)(this.el,"--opened");this.autoClose=!isNaN(+y)&&isFinite(+y)?+y:s.BREAKPOINTS[y]||null,this.autoCloseEqualityType=null!==(d=f)&&void 0!==d?d:null,this.openedBreakpoint=(!isNaN(+v)&&isFinite(+v)?+v:s.BREAKPOINTS[v])||null,this.animationTarget=(null===(c=null==this?void 0:this.el)||void 0===c?void 0:c.querySelector(".hs-overlay-animation-target"))||this.el,this.initialZIndex=parseInt(getComputedStyle(this.el).zIndex,10),this.onElementClickListener=[],this.onElementMinifierClickListener=[],this.initiallyOpened=document.body.classList.contains("hs-overlay-body-open"),this.init()}elementClick(){const e=()=>{const e={el:this.el,isOpened:!!this.el.classList.contains("open")};this.fireEvent("toggleClicked",e),(0,o.dispatch)("toggleClicked.hs.overlay",this.el,e)};this.el.classList.contains("opened")?this.close(!1,e):this.open(e)}elementMinifierClick(){const e=()=>{const e={el:this.el,isMinified:!!this.el.classList.contains("minified")};this.fireEvent("toggleMinifierClicked",e),(0,o.dispatch)("toggleMinifierClicked.hs.overlay",this.el,e)};this.el.classList.contains("minified")?this.minify(!1,e):this.minify(!0,e)}minify(e,t=null){e?(this.el.classList.add("minified"),document.body.classList.add("hs-overlay-minified"),t&&t()):(this.el.classList.remove("minified"),document.body.classList.remove("hs-overlay-minified"),t&&t())}overlayClick(e){e.target.id&&`#${e.target.id}`===this.el.id&&this.isCloseWhenClickInside&&this.hasAbilityToCloseOnBackdropClick&&this.close()}backdropClick(){this.close()}init(){if(this.createCollection(window.$hsOverlayCollection,this),this.isLayoutAffect&&this.openedBreakpoint){const e=a.getInstance(this.el,!0);a.setOpened(this.openedBreakpoint,e)}this.onOverlayClickListener=e=>this.overlayClick(e),this.el.addEventListener("click",this.onOverlayClickListener),this.toggleButtons.length&&this.buildToggleButtons(this.toggleButtons),this.toggleMinifierButtons.length&&this.buildToggleMinifierButtons(),"undefined"!=typeof window&&(window.HSAccessibilityObserver||(window.HSAccessibilityObserver=new r.default),this.setupAccessibility())}buildToggleButtons(e){e.forEach((e=>{this.el.classList.contains("opened")?e.ariaExpanded="true":e.ariaExpanded="false",this.onElementClickListener.push({el:e,fn:()=>this.elementClick()}),e.addEventListener("click",this.onElementClickListener.find((t=>t.el===e)).fn)}))}buildToggleMinifierButtons(){this.toggleMinifierButtons.forEach((e=>{this.el.classList.contains("minified")?e.ariaExpanded="true":e.ariaExpanded="false",this.onElementMinifierClickListener.push({el:e,fn:()=>this.elementMinifierClick()}),e.addEventListener("click",this.onElementMinifierClickListener.find((t=>t.el===e)).fn)}))}hideAuto(){const e=parseInt((0,o.getClassProperty)(this.el,"--auto-hide","0"));e&&(this.autoHide=setTimeout((()=>{this.close()}),e))}checkTimer(){this.autoHide&&(clearTimeout(this.autoHide),this.autoHide=null)}buildBackdrop(){const e=this.el.classList.value.split(" "),t=parseInt(window.getComputedStyle(this.el).getPropertyValue("z-index")),i=this.el.getAttribute("data-hs-overlay-backdrop-container")||!1;this.backdrop=document.createElement("div");let n=`${this.backdropClasses} ${this.backdropExtraClasses}`;const s="static"!==(0,o.getClassProperty)(this.el,"--overlay-backdrop","true"),l="false"===(0,o.getClassProperty)(this.el,"--overlay-backdrop","true");this.backdrop.id=`${this.el.id}-backdrop`,"style"in this.backdrop&&(this.backdrop.style.zIndex=""+(t-1));for(const t of e)(t.startsWith("hs-overlay-backdrop-open:")||t.includes(":hs-overlay-backdrop-open:"))&&(n+=` ${t}`);l||(i&&(this.backdrop=document.querySelector(i).cloneNode(!0),this.backdrop.classList.remove("hidden"),n=`${this.backdrop.classList.toString()}`,this.backdrop.classList.value=""),s&&(this.onBackdropClickListener=()=>this.backdropClick(),this.backdrop.addEventListener("click",this.onBackdropClickListener,!0)),this.backdrop.setAttribute("data-hs-overlay-backdrop-template",""),this.backdropParent.appendChild(this.backdrop),setTimeout((()=>{this.backdrop.classList.value=n})))}destroyBackdrop(){const e=document.querySelector(`#${this.el.id}-backdrop`);e&&(this.openNextOverlay&&(e.style.transitionDuration=1.8*parseFloat(window.getComputedStyle(e).transitionDuration.replace(/[^\d.-]/g,""))+"s"),e.classList.add("opacity-0"),(0,o.afterTransition)(e,(()=>{e.remove()})))}focusElement(){const e=this.el.querySelector("[autofocus]");if(!e)return!1;e.focus()}getScrollbarSize(){let e=document.createElement("div");e.style.overflow="scroll",e.style.width="100px",e.style.height="100px",document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t}collectToggleParameters(e){let t={};return e.forEach((e=>{const i=e.getAttribute("data-hs-overlay-options"),n=i?JSON.parse(i):{};t=Object.assign(Object.assign({},t),n)})),t}isElementVisible(){const e=window.getComputedStyle(this.el);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity)return!1;const t=this.el.getBoundingClientRect();if(0===t.width||0===t.height)return!1;let i=this.el.parentElement;for(;i;){const e=window.getComputedStyle(i);if("none"===e.display||"hidden"===e.visibility||"0"===e.opacity)return!1;i=i.parentElement}return!0}isOpened(){return this.el.classList.contains("open")&&!this.el.classList.contains(this.hiddenClass)}open(e=null){this.el.classList.contains("minified")&&this.minify(!1),this.hasDynamicZIndex&&(a.currentZIndex<this.initialZIndex&&(a.currentZIndex=this.initialZIndex),a.currentZIndex++,this.el.style.zIndex=`${a.currentZIndex}`);const t=document.querySelectorAll(".hs-overlay.open"),i=window.$hsOverlayCollection.find((e=>Array.from(t).includes(e.element.el)&&!e.element.isLayoutAffect)),n=document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`),s="true"!==(0,o.getClassProperty)(this.el,"--body-scroll","false");if(this.lastFocusedToggle=document.activeElement,this.isClosePrev&&i)return this.openNextOverlay=!0,i.element.close().then((()=>{this.open(),this.openNextOverlay=!1}));s&&(document.body.style.overflow="hidden",this.emulateScrollbarSpace&&(document.body.style.paddingRight=`${this.getScrollbarSize()}px`)),this.buildBackdrop(),this.checkTimer(),this.hideAuto(),n.forEach((e=>{e.ariaExpanded&&(e.ariaExpanded="true")})),this.el.classList.remove(this.hiddenClass),this.el.setAttribute("aria-overlay","true"),this.el.setAttribute("tabindex","-1"),setTimeout((()=>{if(this.el.classList.contains("opened"))return!1;this.el.classList.add("open","opened"),this.isLayoutAffect&&document.body.classList.add("hs-overlay-body-open"),this.initiallyOpened||(this.el.focus(),this.el.style.outline="none"),this.initiallyOpened=!1,this.fireEvent("open",this.el),(0,o.dispatch)("open.hs.overlay",this.el,this.el),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!0),this.hasAutofocus&&this.focusElement(),"function"==typeof e&&e(),this.isElementVisible()&&a.openedItemsQty++}),50)}close(e=!1,t=null){this.isElementVisible()&&(a.openedItemsQty=a.openedItemsQty<=0?0:a.openedItemsQty-1),0===a.openedItemsQty&&this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open");const i=e=>{if(this.el.classList.contains("open"))return!1;document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`).forEach((e=>{e.ariaExpanded&&(e.ariaExpanded="false")})),this.el.classList.add(this.hiddenClass),this.hasDynamicZIndex&&(this.el.style.zIndex=""),this.destroyBackdrop(),this.fireEvent("close",this.el),(0,o.dispatch)("close.hs.overlay",this.el,this.el),window.HSAccessibilityObserver&&this.accessibilityComponent&&window.HSAccessibilityObserver.updateComponentState(this.accessibilityComponent,!1),document.querySelector(".hs-overlay.opened")||(document.body.style.overflow="",this.emulateScrollbarSpace&&(document.body.style.paddingRight="")),this.lastFocusedToggle&&(this.lastFocusedToggle.focus(),this.lastFocusedToggle=null),e(this.el),"function"==typeof t&&t(),0===a.openedItemsQty&&(document.body.classList.remove("hs-overlay-body-open"),this.hasDynamicZIndex&&(a.currentZIndex=0))};return new Promise((t=>{this.el.classList.remove("open","opened"),this.el.removeAttribute("aria-overlay"),this.el.removeAttribute("tabindex"),this.el.style.outline="",e?i(t):(0,o.afterTransition)(this.animationTarget,(()=>i(t)))}))}updateToggles(){const e=Array.from(document.querySelectorAll(`[data-hs-overlay="#${this.el.id}"]`)).filter((e=>!this.toggleButtons.includes(e)));e.length&&(this.toggleButtons.push(...e),this.buildToggleButtons(e)),this.toggleButtons=this.toggleButtons.filter((e=>{var t;if(document.contains(e))return!0;const i=null===(t=this.onElementClickListener)||void 0===t?void 0:t.find((t=>t.el===e));return i&&e.removeEventListener("click",i.fn),!1}))}destroy(){this.el.classList.remove("open","opened",this.hiddenClass),this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open"),this.el.removeEventListener("click",this.onOverlayClickListener),this.onElementClickListener.length&&(this.onElementClickListener.forEach((({el:e,fn:t})=>{e.removeEventListener("click",t)})),this.onElementClickListener=null),this.backdrop&&this.backdrop.removeEventListener("click",this.onBackdropClickListener),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),window.$hsOverlayCollection=window.$hsOverlayCollection.filter((({element:e})=>e.el!==this.el))}static findInCollection(e){return window.$hsOverlayCollection.find((t=>e instanceof a?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e))||null}static getInstance(e,t){const i="string"==typeof e?document.querySelector(e):e,n=(null==i?void 0:i.getAttribute("data-hs-overlay"))?i.getAttribute("data-hs-overlay"):e,o=window.$hsOverlayCollection.find((e=>e.element.el===("string"==typeof n?document.querySelector(n):n)||e.element.el===("string"==typeof n?document.querySelector(n):n)));return o?t?o:o.element.el:null}static autoInit(){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),window.$hsOverlayCollection&&(window.$hsOverlayCollection=window.$hsOverlayCollection.filter((({element:e})=>document.contains(e.el)))),document.querySelectorAll(".hs-overlay:not(.--prevent-on-load-init)").forEach((e=>{window.$hsOverlayCollection.find((t=>{var i;return(null===(i=null==t?void 0:t.element)||void 0===i?void 0:i.el)===e}))||new a(e)}))}static open(e){const t=a.findInCollection(e);t&&t.element.el.classList.contains(t.element.hiddenClass)&&t.element.open()}static close(e){const t=a.findInCollection(e);t&&!t.element.el.classList.contains(t.element.hiddenClass)&&t.element.close()}static minify(e,t){const i=a.findInCollection(e);i&&i.element.minify(t)}static setOpened(e,t){document.body.clientWidth>=e?(t.element.el.classList.contains("minified")&&t.element.minify(!1),document.body.classList.add("hs-overlay-body-open"),t.element.open()):t.element.close(!0)}setupAccessibility(){this.accessibilityComponent=window.HSAccessibilityObserver.registerComponent(this.el,{onEnter:()=>{this.isOpened()||this.open()},onEsc:()=>{this.isOpened()&&this.close()},onTab:()=>{var e;if(!this.isOpened()||!this.isTabAccessibilityLimited)return;const t=Array.from(this.el.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter((e=>!e.hidden&&"none"!==window.getComputedStyle(e).display));if(0===t.length)return;const i=this.el.querySelector(":focus"),n=i?t.indexOf(i):-1;window.event instanceof KeyboardEvent&&window.event.shiftKey?n<=0?t[t.length-1].focus():t[n-1].focus():n===t.length-1?t[0].focus():t[n+1].focus(),null===(e=window.event)||void 0===e||e.preventDefault()}},this.isOpened(),"Overlay",".hs-overlay"),this.toggleButtons.forEach((e=>{window.HSAccessibilityObserver.registerComponent(e,{onEnter:()=>{this.isOpened()||this.open()},onEsc:()=>{this.isOpened()&&this.close()}},this.isOpened(),"Overlay Toggle",`[data-hs-overlay="#${this.el.id}"]`)}))}static on(e,t,i){const n=a.findInCollection(t);n&&(n.element.events[e]=i)}}a.openedItemsQty=0,a.currentZIndex=0;let d=null;const c=()=>{if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((e=>e.element.moveOverlayToBody)))return!1;window.$hsOverlayCollection.filter((e=>e.element.moveOverlayToBody)).forEach((e=>{const t=e.element.moveOverlayToBody,i=e.element.initContainer,n=document.querySelector("body"),s=e.element.el;if(!i&&s)return!1;document.body.clientWidth<=t&&!(0,o.isDirectChild)(n,s)?n.appendChild(s):document.body.clientWidth>t&&!i.contains(s)&&i.appendChild(s)}))},h=()=>{var e;(null===(e=window.$hsOverlayCollection)||void 0===e?void 0:e.length)&&window.$hsOverlayCollection.forEach((e=>{var t;const i=e.element;(null===(t=i.toggleMinifierButtons)||void 0===t?void 0:t.length)>0&&i.openedBreakpoint&&(document.body.clientWidth>=i.openedBreakpoint?document.body.classList.add("hs-overlay-body-open"):document.body.classList.remove("hs-overlay-body-open"))}))};window.addEventListener("load",(()=>{a.autoInit(),c(),h()})),window.addEventListener("resize",(()=>{((e,t=150)=>{d&&clearTimeout(d),d=setTimeout(e,t)})((()=>{(()=>{if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((e=>e.element.autoClose)))return!1;window.$hsOverlayCollection.filter((e=>e.element.autoClose)).forEach((e=>{const{autoCloseEqualityType:t,autoClose:i}=e.element;("less-than"===t?document.body.clientWidth<=i:document.body.clientWidth>=i)&&e.element.el.classList.contains("opened")?(e.element.el.classList.contains("minified")&&e.element.minify(!1),e.element.close(!0)):e.element.isLayoutAffect&&e.element.el.classList.contains("opened")&&document.body.classList.add("hs-overlay-body-open")}))})(),(()=>{if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((e=>e.element.openedBreakpoint)))return!1;window.$hsOverlayCollection.filter((e=>e.element.openedBreakpoint)).forEach((e=>{const{openedBreakpoint:t}=e.element;document.body.clientWidth>=t?e.element.el.classList.contains("opened")||a.setOpened(t,e):e.element.el.classList.contains("opened")&&(e.element.el.classList.contains("minified")&&e.element.minify(!1),e.element.close(!0))}))})()})),c(),(()=>{if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((e=>e.element.el.classList.contains("opened"))))return!1;window.$hsOverlayCollection.filter((e=>e.element.el.classList.contains("opened"))).forEach((e=>{const t=parseInt(window.getComputedStyle(e.element.el).getPropertyValue("z-index")),i=document.querySelector(`#${e.element.el.id}-backdrop`);return!!i&&(t!==parseInt(window.getComputedStyle(i).getPropertyValue("z-index"))+1&&("style"in i&&(i.style.zIndex=""+(t-1)),void document.body.classList.add("hs-overlay-body-open")))}))})(),h()})),"undefined"!=typeof window&&(window.HSOverlay=a),t.default=a},961:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,i){this.el=e,this.options=t,this.events=i,this.el=e,this.options=t,this.events={}}createCollection(e,t){var i;e.push({id:(null===(i=null==t?void 0:t.el)||void 0===i?void 0:i.id)||e.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}}},t={};var i=function i(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}(850);return i})()));