UNPKG

preline

Version:

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.

33 lines 397 kB
var e={189(e,t,i){i.d(t,{LO:()=>n,lP:()=>s});const s={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"},n={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},8862(e,t,i){i.d(t,{A:()=>n});var s=i(1926);const n=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,s=Number.MAX_SAFE_INTEGER;for(const n of t){let t=0,o=e;for(;o&&o!==n.wrapper&&o!==n.context;)t++,o=o.parentElement;t<s&&(s=t,i=n)}return i}getActiveComponentForKey(e,t){if(!e)return null;const i=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));if(0===i.length)return null;const s=i.filter(e=>{const i=e.handlers;switch(t){case"Escape":return!!i.onEsc;case"Enter":return!!i.onEnter;case" ":case"Space":return!!i.onSpace;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":return!!i.onArrow;case"Tab":return!!i.onTab||!!i.onShiftTab;case"Home":return!!i.onHome;case"End":return!!i.onEnd;default:return!!i.onFirstLetter}});if(0===s.length)return this.getActiveComponent(e);if(1===s.length)return s[0];let n=null,o=Number.MAX_SAFE_INTEGER;for(const t of s){let i=0,s=e;for(;s&&s!==t.wrapper&&s!==t.context;)i++,s=s.parentElement;i<o&&(o=i,n=t)}return n}getDistanceToComponent(e,t){let i=0,s=e;for(;s&&s!==t.wrapper&&s!==t.context;)i++,s=s.parentElement;return i}getComponentsByNesting(e){if(!e)return[];const t=this.components.filter(t=>t.wrapper.contains(e)||t.context&&t.context.contains(e));return t.length<=1?t:[...t].sort((t,i)=>this.getDistanceToComponent(e,i)-this.getDistanceToComponent(e,t))}getSequentialHandlersForKey(e,t){const i=this.getComponentsByNesting(e);return 0===i.length?[]:i.map(e=>"Enter"===t?e.handlers.onEnter:e.handlers.onSpace).filter(e=>"function"==typeof e)}executeSequentialHandlers(e,t){let i=!1,s=!1;for(const n of e){i=!0;if(!1===n(t)){s=!0;break}}return{called:i,stopped:s}}handleGlobalFocusin(e){const t=e.target;this.activeComponent=this.getActiveComponent(t)}handleGlobalKeydown(e){var t;const i=e.target;this.activeComponent=this.getActiveComponentForKey(i,e.key);const n=this.activeComponent,o="Enter"===e.key||" "===e.key||"Space"===e.key;if((n||o)&&this.isAllowedKeybinding(e))switch(e.key){case"Escape":if(!n)break;if(n.isOpened){if(n.handlers.onEsc){const t=n.handlers.onEsc();if(e.preventDefault(),e.stopPropagation(),!1===t){const e=this.findClosestOpenParent(i);(null==e?void 0:e.handlers.onEsc)&&e.handlers.onEsc()}}}else{const t=this.findClosestOpenParent(i);(null==t?void 0:t.handlers.onEsc)&&(t.handlers.onEsc(),e.preventDefault(),e.stopPropagation())}break;case"Enter":{const t=this.getSequentialHandlersForKey(i,"Enter");if(0===t.length)break;const{called:n,stopped:o}=this.executeSequentialHandlers(t,e);if(n&&!(0,s.V6)(i)&&(e.stopPropagation(),e.preventDefault()),o)break;break}case" ":case"Space":{if("INPUT"===i.tagName||"TEXTAREA"===i.tagName)return;const t=this.getActiveComponent(i),s=this.getSequentialHandlersForKey(i,"Space");if(0===s.length)break;const{stopped:n}=this.executeSequentialHandlers(s);(n||(null==t?void 0:t.handlers.onSpace))&&(e.preventDefault(),e.stopPropagation());break}case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(!n)break;if(n.handlers.onArrow){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;n.handlers.onArrow(e),e.preventDefault(),e.stopPropagation()}break;case"Tab":if(!n)break;if(!n.handlers.onTab)break;const o=e.shiftKey?n.handlers.onShiftTab:n.handlers.onTab;o&&o(e);break;case"Home":if(!n)break;n.handlers.onHome&&(n.handlers.onHome(),e.preventDefault(),e.stopPropagation());break;case"End":if(!n)break;n.handlers.onEnd&&(n.handlers.onEnd(),e.preventDefault(),e.stopPropagation());break;default:if(!n)break;if(n.handlers.onFirstLetter&&1===e.key.length&&/^[a-zA-Z]$/.test(e.key)){if(n.handlers.onFirstLetter(e.key),!(null===(t=n.stopPropagation)||void 0===t?void 0:t.onFirstLetter))return;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,s="",n="",o,l){const a={wrapper:e,handlers:t,isOpened:i,name:s,selector:n,context:o,isRegistered:!0,stopPropagation:l};return this.components.push(a),a}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)}}},2407(e,t,i){i.d(t,{A:()=>l});var s=i(1926),n=i(7615); /* * HSAccordion * @version: 4.2.0 * @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. */ class o extends n.A{constructor(e,t,i){super(e,t,i),this.toggle=this.el.querySelector(".hs-accordion-toggle")||null,this.content=this.el.querySelector(".hs-accordion-content")||null,this.group=this.el.closest(".hs-accordion-group")||null,this.isAlwaysOpened=!1,this.keepOneOpen=!1,this.isToggleStopPropagated=!1,window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),this.update(),this.isToggleStopPropagated=(0,s.PK)((0,s.gj)(this.toggle,"--stop-propagation","false")||"false"),this.keepOneOpen=!!this.group&&(0,s.PK)((0,s.gj)(this.group,"--keep-one-open","false")||"false"),this.toggle&&this.content&&this.init()}init(){this.createCollection(window.$hsAccordionCollection,this),this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener)}toggleClick(e){if(this.el.classList.contains("active")&&this.keepOneOpen)return!1;this.isToggleStopPropagated&&e.stopPropagation(),this.el.classList.contains("active")?this.hide():this.show()}show(){var e;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(":scope > .hs-accordion.active")&&this.group.querySelector(":scope > .hs-accordion.active")!==this.el){window.$hsAccordionCollection.find(e=>e.element.el===this.group.querySelector(":scope > .hs-accordion.active")).element.hide()}if(this.el.classList.contains("active"))return!1;this.el.classList.add("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.fireEvent("beforeOpen",this.el),(0,s.JD)("beforeOpen.hs.accordion",this.el,this.el),this.content.style.display="block",this.content.style.height="0",setTimeout(()=>{this.content.style.height=`${this.content.scrollHeight}px`,(0,s.yd)(this.content,()=>{this.content.style.display="block",this.content.style.height="",this.fireEvent("open",this.el),(0,s.JD)("open.hs.accordion",this.el,this.el)})})}hide(){var e;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.fireEvent("beforeClose",this.el),(0,s.JD)("beforeClose.hs.accordion",this.el,this.el),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout(()=>{this.content.style.height="0"}),(0,s.yd)(this.content,()=>{this.content.style.display="none",this.content.style.height="",this.fireEvent("close",this.el),(0,s.JD)("close.hs.accordion",this.el,this.el)})}update(){return this.group=this.el.closest(".hs-accordion-group")||null,!!this.group&&(this.isAlwaysOpened=this.group.hasAttribute("data-hs-accordion-always-open")||!1,!!window.$hsAccordionCollection&&void window.$hsAccordionCollection.map(e=>(e.id===this.el.id&&(e.element.group=this.group,e.element.isAlwaysOpened=this.isAlwaysOpened),e)))}destroy(){var e;(null===(e=null==o?void 0:o.selectable)||void 0===e?void 0:e.length)&&o.selectable.forEach(e=>{e.listeners.forEach(({el:e,listener:t})=>{e.removeEventListener("click",t)})}),this.onToggleClickListener&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.toggle=null,this.content=null,this.group=null,this.onToggleClickListener=null,window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>e.el!==this.el)}static findInCollection(e){return window.$hsAccordionCollection.find(t=>e instanceof o?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e)||null}static autoInit(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),window.$hsAccordionCollection&&(window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach(e=>{window.$hsAccordionCollection.find(t=>{var i;return(null===(i=null==t?void 0:t.element)||void 0===i?void 0:i.el)===e})||new o(e)})}static getInstance(e,t){const i=window.$hsAccordionCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return i?t?i:i.element.el:null}static show(e){const t=o.findInCollection(e);t&&"block"!==t.element.content.style.display&&t.element.show()}static hide(e){const t=o.findInCollection(e),i=t?window.getComputedStyle(t.element.content):null;t&&"none"!==i.display&&t.element.hide()}static treeView(){if(!document.querySelectorAll(".hs-accordion-treeview-root").length)return!1;this.selectable=[],document.querySelectorAll(".hs-accordion-treeview-root").forEach(e=>{const t=null==e?void 0:e.getAttribute("data-hs-accordion-options"),i=t?JSON.parse(t):{};this.selectable.push({el:e,options:Object.assign({},i),listeners:[]})}),this.selectable.length&&this.selectable.forEach(e=>{const{el:t}=e;t.querySelectorAll(".hs-accordion-selectable").forEach(t=>{const i=i=>this.onSelectableClick(i,e,t);t.addEventListener("click",i),e.listeners.push({el:t,listener:i})})})}static toggleSelected(e,t){t.classList.contains("selected")?t.classList.remove("selected"):(e.el.querySelectorAll(".hs-accordion-selectable").forEach(e=>e.classList.remove("selected")),t.classList.add("selected"))}static on(e,t,i){const s=o.findInCollection(t);s&&(s.element.events[e]=i)}}o.onSelectableClick=(e,t,i)=>{e.stopPropagation(),o.toggleSelected(t,i)};const l=o},7615(e,t,i){i.d(t,{A:()=>s}); /* * HSBasePlugin * @version: 4.2.0 * @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. */ class s{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,s;let n=e;if(!Array.isArray(n)&&"undefined"!=typeof window){const e=null===(i=this.constructor)||void 0===i?void 0:i.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),n=window[t])}Array.isArray(n)&&n.push({id:(null===(s=null==t?void 0:t.el)||void 0===s?void 0:s.id)||n.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}}},4571(e,t,i){i.d(t,{A:()=>a});var s=i(1926),n=i(7615),o=i(189); /* * HSCarousel * @version: 4.2.0 * @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. */ class l extends n.A{constructor(e,t){var i,s,n,o,l;super(e,t);const a=e.getAttribute("data-hs-carousel"),r=a?JSON.parse(a):{},c=Object.assign(Object.assign({},r),t);this.currentIndex=c.currentIndex||0,this.loadingClasses=c.loadingClasses?`${c.loadingClasses}`.split(","):null,this.dotsItemClasses=c.dotsItemClasses?c.dotsItemClasses:null,this.isAutoHeight=void 0!==c.isAutoHeight&&c.isAutoHeight,this.isAutoPlay=void 0!==c.isAutoPlay&&c.isAutoPlay,this.isCentered=void 0!==c.isCentered&&c.isCentered,this.isDraggable=void 0!==c.isDraggable&&c.isDraggable,this.isInfiniteLoop=void 0!==c.isInfiniteLoop&&c.isInfiniteLoop,this.isRTL=void 0!==c.isRTL&&c.isRTL,this.isSnap=void 0!==c.isSnap&&c.isSnap,this.hasSnapSpacers=void 0===c.hasSnapSpacers||c.hasSnapSpacers,this.speed=c.speed||4e3,this.updateDelay=c.updateDelay||0,this.slidesQty=c.slidesQty||1,this.loadingClassesRemove=(null===(i=this.loadingClasses)||void 0===i?void 0:i[0])?this.loadingClasses[0].split(" "):"opacity-0",this.loadingClassesAdd=(null===(s=this.loadingClasses)||void 0===s?void 0:s[1])?this.loadingClasses[1].split(" "):"",this.afterLoadingClassesAdd=(null===(n=this.loadingClasses)||void 0===n?void 0:n[2])?this.loadingClasses[2].split(" "):"",this.container=this.el.querySelector(".hs-carousel")||null,this.inner=this.el.querySelector(".hs-carousel-body")||null,this.slides=this.el.querySelectorAll(".hs-carousel-slide")||[],this.prev=this.el.querySelector(".hs-carousel-prev")||null,this.next=this.el.querySelector(".hs-carousel-next")||null,this.dots=this.el.querySelector(".hs-carousel-pagination")||null,this.info=this.el.querySelector(".hs-carousel-info")||null,this.infoTotal=(null===(o=null==this?void 0:this.info)||void 0===o?void 0:o.querySelector(".hs-carousel-info-total"))||null,this.infoCurrent=(null===(l=null==this?void 0:this.info)||void 0===l?void 0:l.querySelector(".hs-carousel-info-current"))||null,this.sliderWidth=this.el.getBoundingClientRect().width,this.isDragging=!1,this.dragStartX=null,this.initialTranslateX=null,this.touchX={start:0,end:0},this.touchY={start:0,end:0},this.resizeContainer=document.querySelector("body"),this.resizeContainerWidth=0,this.init()}setIsSnap(){const e=this.container.getBoundingClientRect(),t=e.left+e.width/2;let i=null,s=null,n=1/0;Array.from(this.inner.children).forEach(e=>{const s=e.getBoundingClientRect(),o=this.inner.getBoundingClientRect(),l=s.left+s.width/2-o.left,a=Math.abs(t-(o.left+l));a<n&&(n=a,i=e)}),i&&(s=Array.from(this.slides).findIndex(e=>e===i)),this.setIndex(s),this.dots&&this.setCurrentDot()}prevClick(){this.goToPrev(),this.isAutoPlay&&(this.resetTimer(),this.setTimer())}nextClick(){this.goToNext(),this.isAutoPlay&&(this.resetTimer(),this.setTimer())}containerScroll(){clearTimeout(this.isScrolling),this.isScrolling=setTimeout(()=>{this.setIsSnap()},100)}elementTouchStart(e){this.touchX.start=e.changedTouches[0].screenX,this.touchY.start=e.changedTouches[0].screenY}elementTouchEnd(e){this.touchX.end=e.changedTouches[0].screenX,this.touchY.end=e.changedTouches[0].screenY,this.detectDirection()}innerMouseDown(e){this.handleDragStart(e)}innerTouchStart(e){this.handleDragStart(e)}documentMouseMove(e){this.handleDragMove(e)}documentTouchMove(e){this.handleDragMove(e)}documentMouseUp(){this.handleDragEnd()}documentTouchEnd(){this.handleDragEnd()}dotClick(e){this.goTo(e),this.isAutoPlay&&(this.resetTimer(),this.setTimer())}init(){this.createCollection(window.$hsCarouselCollection,this),this.inner&&(this.calculateWidth(),this.isDraggable&&!this.isSnap&&this.initDragHandling()),this.prev&&(this.onPrevClickListener=()=>this.prevClick(),this.prev.addEventListener("click",this.onPrevClickListener)),this.next&&(this.onNextClickListener=()=>this.nextClick(),this.next.addEventListener("click",this.onNextClickListener)),this.dots&&this.initDots(),this.info&&this.buildInfo(),this.slides.length&&(this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass(),this.isAutoPlay&&this.autoPlay()),setTimeout(()=>{this.isSnap&&this.setIsSnap(),this.loadingClassesRemove&&("string"==typeof this.loadingClassesRemove?this.inner.classList.remove(this.loadingClassesRemove):this.inner.classList.remove(...this.loadingClassesRemove)),this.loadingClassesAdd&&("string"==typeof this.loadingClassesAdd?this.inner.classList.add(this.loadingClassesAdd):this.inner.classList.add(...this.loadingClassesAdd)),this.inner&&this.afterLoadingClassesAdd&&setTimeout(()=>{"string"==typeof this.afterLoadingClassesAdd?this.inner.classList.add(this.afterLoadingClassesAdd):this.inner.classList.add(...this.afterLoadingClassesAdd)})},400),this.isSnap&&(this.onContainerScrollListener=()=>this.containerScroll(),this.container.addEventListener("scroll",this.onContainerScrollListener)),this.el.classList.add("init"),this.isSnap||(this.onElementTouchStartListener=e=>this.elementTouchStart(e),this.onElementTouchEndListener=e=>this.elementTouchEnd(e),this.el.addEventListener("touchstart",this.onElementTouchStartListener),this.el.addEventListener("touchend",this.onElementTouchEndListener)),this.observeResize()}initDragHandling(){const e=this.inner;this.onInnerMouseDownListener=e=>this.innerMouseDown(e),this.onInnerTouchStartListener=e=>this.innerTouchStart(e),this.onDocumentMouseMoveListener=e=>this.documentMouseMove(e),this.onDocumentTouchMoveListener=e=>this.documentTouchMove(e),this.onDocumentMouseUpListener=()=>this.documentMouseUp(),this.onDocumentTouchEndListener=()=>this.documentTouchEnd(),e&&(e.addEventListener("mousedown",this.onInnerMouseDownListener),e.addEventListener("touchstart",this.onInnerTouchStartListener,{passive:!0}),document.addEventListener("mousemove",this.onDocumentMouseMoveListener),document.addEventListener("touchmove",this.onDocumentTouchMoveListener,{passive:!1}),document.addEventListener("mouseup",this.onDocumentMouseUpListener),document.addEventListener("touchend",this.onDocumentTouchEndListener))}getTranslateXValue(){var e;const t=window.getComputedStyle(this.inner).transform;if("none"!==t){const i=null===(e=t.match(/matrix.*\((.+)\)/))||void 0===e?void 0:e[1].split(", ");if(i){let e=parseFloat(6===i.length?i[4]:i[12]);return this.isRTL&&(e=-e),isNaN(e)||0===e?0:-e}}return 0}removeClickEventWhileDragging(e){e.preventDefault()}handleDragStart(e){e.preventDefault(),this.isDragging=!0,this.dragStartX=this.getEventX(e),this.initialTranslateX=this.isRTL?this.getTranslateXValue():-this.getTranslateXValue(),this.inner.classList.add("dragging")}handleDragMove(e){if(!this.isDragging)return;this.inner.querySelectorAll("a:not(.prevented-click)").forEach(e=>{e.classList.add("prevented-click"),e.addEventListener("click",this.removeClickEventWhileDragging)});let t=this.getEventX(e)-this.dragStartX;this.isRTL&&(t=-t);const i=this.initialTranslateX+t;this.setTranslate((()=>{let e=this.sliderWidth*this.slides.length/this.getCurrentSlidesQty()-this.sliderWidth;const t=this.sliderWidth,s=(t-t/this.getCurrentSlidesQty())/2,n=this.isCentered?s:0;this.isCentered&&(e+=s);const o=-e;return this.isRTL?i<n?n:i>e?o:-i:i>n?n:i<-e?o:i})())}handleDragEnd(){if(!this.isDragging)return;this.isDragging=!1;const e=this.sliderWidth/this.getCurrentSlidesQty(),t=this.getTranslateXValue();let i=Math.round(t/e);this.isRTL&&(i=Math.round(t/e)),this.inner.classList.remove("dragging"),setTimeout(()=>{this.calculateTransform(i),this.dots&&this.setCurrentDot(),this.dragStartX=null,this.initialTranslateX=null,this.inner.querySelectorAll("a.prevented-click").forEach(e=>{e.classList.remove("prevented-click"),e.removeEventListener("click",this.removeClickEventWhileDragging)})})}getEventX(e){return e instanceof MouseEvent?e.clientX:e.touches[0].clientX}getCurrentSlidesQty(){if("object"==typeof this.slidesQty){const e=document.body.clientWidth;let t=0;return Object.keys(this.slidesQty).forEach(i=>{e>=(typeof i+1=="number"?this.slidesQty[i]:o.LO[i])&&(t=this.slidesQty[i])}),t}return this.slidesQty}buildSnapSpacers(){const e=this.inner.querySelector(".hs-snap-before"),t=this.inner.querySelector(".hs-snap-after");e&&e.remove(),t&&t.remove();const i=this.sliderWidth,n=i/2-i/this.getCurrentSlidesQty()/2,o=(0,s.fc)(`<div class="hs-snap-before" style="height: 100%; width: ${n}px"></div>`),l=(0,s.fc)(`<div class="hs-snap-after" style="height: 100%; width: ${n}px"></div>`);this.inner.prepend(o),this.inner.appendChild(l)}initDots(){this.el.querySelectorAll(".hs-carousel-pagination-item").length?this.setDots():this.buildDots(),this.dots&&this.setCurrentDot()}buildDots(){this.dots.innerHTML="";const e=!this.isCentered&&this.slidesQty?this.slides.length-(this.getCurrentSlidesQty()-1):this.slides.length;for(let t=0;t<e;t++){const e=this.buildSingleDot(t);this.dots.append(e)}}setDots(){this.dotsItems=this.dots.querySelectorAll(".hs-carousel-pagination-item"),this.dotsItems.forEach((e,t)=>{const i=e.getAttribute("data-carousel-pagination-item-target");this.singleDotEvents(e,i?+i:t)})}goToCurrentDot(){const e=this.dots,t=e.getBoundingClientRect(),i=e.scrollLeft,s=e.scrollTop,n=e.clientWidth,o=e.clientHeight,l=this.dotsItems[this.currentIndex],a=l.getBoundingClientRect(),r=a.left-t.left+i,c=r+l.clientWidth,d=a.top-t.top+s,h=d+l.clientHeight;let u=i,p=s;(r<i||c>i+n)&&(u=c-n),(d<s||h>s+o)&&(p=h-o),e.scrollTo({left:u,top:p,behavior:"smooth"})}buildInfo(){this.infoTotal&&this.setInfoTotal(),this.infoCurrent&&this.setInfoCurrent()}setInfoTotal(){this.infoTotal.innerText=`${this.slides.length}`}setInfoCurrent(){this.infoCurrent.innerText=`${this.currentIndex+1}`}buildSingleDot(e){const t=(0,s.fc)("<span></span>");return this.dotsItemClasses&&(0,s.en)(this.dotsItemClasses,t),this.singleDotEvents(t,e),t}singleDotEvents(e,t){this.onDotClickListener=()=>this.dotClick(t),e.addEventListener("click",this.onDotClickListener)}observeResize(){new ResizeObserver((0,s.sg)(e=>{for(let t of e){const e=t.contentRect.width;e!==this.resizeContainerWidth&&(this.recalculateWidth(),this.dots&&this.initDots(),this.addCurrentClass(),this.resizeContainerWidth=e)}},this.updateDelay)).observe(this.resizeContainer)}calculateWidth(){this.isSnap||(this.inner.style.width=this.sliderWidth*this.slides.length/this.getCurrentSlidesQty()+"px"),this.slides.forEach(e=>{e.style.width=this.sliderWidth/this.getCurrentSlidesQty()+"px"}),this.calculateTransform()}addCurrentClass(){if(this.isSnap){const e=Math.floor(this.getCurrentSlidesQty()/2);for(let t=0;t<this.slides.length;t++){const i=this.slides[t];t<=this.currentIndex+e&&t>=this.currentIndex-e?i.classList.add("active"):i.classList.remove("active")}}else{const e=this.isCentered?this.currentIndex+this.getCurrentSlidesQty()+(this.getCurrentSlidesQty()-1):this.currentIndex+this.getCurrentSlidesQty();this.slides.forEach((t,i)=>{i>=this.currentIndex&&i<e?t.classList.add("active"):t.classList.remove("active")})}}setCurrentDot(){const e=(e,t)=>{let i=!1;const s=Math.floor(this.getCurrentSlidesQty()/2);i=this.isSnap&&!this.hasSnapSpacers?t===(this.getCurrentSlidesQty()%2==0?this.currentIndex-s+1:this.currentIndex-s):t===this.currentIndex,i?e.classList.add("active"):e.classList.remove("active")};this.dotsItems?this.dotsItems.forEach((t,i)=>e(t,i)):this.dots.querySelectorAll(":scope > *").forEach((t,i)=>e(t,i))}setElementToDisabled(e){e.classList.add("disabled"),"BUTTON"!==e.tagName&&"INPUT"!==e.tagName||e.setAttribute("disabled","disabled")}unsetElementToDisabled(e){e.classList.remove("disabled"),"BUTTON"!==e.tagName&&"INPUT"!==e.tagName||e.removeAttribute("disabled")}addDisabledClass(){if(!this.prev||!this.next)return!1;const e=getComputedStyle(this.inner).getPropertyValue("gap"),t=Math.floor(this.getCurrentSlidesQty()/2);let i=0,s=0,n=!1,o=!1;this.isSnap?(i=this.currentIndex,s=this.hasSnapSpacers?this.slides.length-1:this.slides.length-t-1,n=this.hasSnapSpacers?0===i:this.getCurrentSlidesQty()%2==0?i-t<0:i-t===0,o=i>=s&&this.container.scrollLeft+this.container.clientWidth+(parseFloat(e)||0)>=this.container.scrollWidth):(i=this.currentIndex,s=this.isCentered?this.slides.length-this.getCurrentSlidesQty()+(this.getCurrentSlidesQty()-1):this.slides.length-this.getCurrentSlidesQty(),n=0===i,o=i>=s),n?(this.unsetElementToDisabled(this.next),this.setElementToDisabled(this.prev)):o?(this.unsetElementToDisabled(this.prev),this.setElementToDisabled(this.next)):(this.unsetElementToDisabled(this.prev),this.unsetElementToDisabled(this.next))}autoPlay(){this.setTimer()}setTimer(){this.timer=setInterval(()=>{this.currentIndex===this.slides.length-1?this.goTo(0):this.goToNext()},this.speed)}resetTimer(){clearInterval(this.timer)}detectDirection(){const e=this.touchX.end-this.touchX.start,t=this.touchY.end-this.touchY.start,i=Math.abs(e),s=Math.abs(t);if(i<30||i<s)return;const n=this.isRTL?e>0:e<0;this.isInfiniteLoop?n?this.goToNext():this.goToPrev():(n&&this.currentIndex<this.slides.length-this.getCurrentSlidesQty()&&this.goToNext(),!n&&this.currentIndex>0&&this.goToPrev())}calculateTransform(e){void 0!==e&&(this.currentIndex=e);const t=this.sliderWidth,i=t/this.getCurrentSlidesQty();let s=this.currentIndex*i;if(this.isSnap&&!this.isCentered&&this.container.scrollLeft<t&&this.container.scrollLeft+i/2>t&&(this.container.scrollLeft=this.container.scrollWidth),this.isCentered&&!this.isSnap){const e=(t-i)/2;if(0===this.currentIndex)s=-e;else if(this.currentIndex>=this.slides.length-this.getCurrentSlidesQty()+(this.getCurrentSlidesQty()-1)){s=this.slides.length*i-t+e}else s=this.currentIndex*i-e}this.isSnap||this.setTransform(s),this.isAutoHeight&&(this.inner.style.height=`${this.slides[this.currentIndex].clientHeight}px`),this.dotsItems&&this.goToCurrentDot(),this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass(),this.isSnap&&this.hasSnapSpacers&&this.buildSnapSpacers(),this.infoCurrent&&this.setInfoCurrent()}setTransform(e){this.slides.length>this.getCurrentSlidesQty()?this.inner.style.transform=this.isRTL?`translate(${e}px, 0px)`:`translate(${-e}px, 0px)`:this.inner.style.transform="translate(0px, 0px)"}setTranslate(e){this.inner.style.transform=this.isRTL?`translate(${-e}px, 0px)`:`translate(${e}px, 0px)`}setIndex(e){this.currentIndex=e,this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass()}recalculateWidth(){this.sliderWidth=this.inner.parentElement.getBoundingClientRect().width,this.calculateWidth(),this.sliderWidth!==this.inner.parentElement.getBoundingClientRect().width&&this.recalculateWidth()}goToPrev(){if(this.currentIndex>0?this.currentIndex--:this.currentIndex=this.slides.length-this.getCurrentSlidesQty(),this.fireEvent("update",this.currentIndex),this.isSnap){const e=this.sliderWidth/this.getCurrentSlidesQty();this.container.scrollBy({left:Math.max(-this.container.scrollLeft,-e),behavior:"smooth"}),this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass()}else this.calculateTransform();this.dots&&this.setCurrentDot()}goToNext(){const e=this.isCentered?this.slides.length-this.getCurrentSlidesQty()+(this.getCurrentSlidesQty()-1):this.slides.length-this.getCurrentSlidesQty();if(this.currentIndex<e?this.currentIndex++:this.currentIndex=0,this.fireEvent("update",this.currentIndex),this.isSnap){const e=this.sliderWidth/this.getCurrentSlidesQty(),t=this.container.scrollWidth-this.container.clientWidth;this.container.scrollBy({left:Math.min(e,t-this.container.scrollLeft),behavior:"smooth"}),this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass()}else this.calculateTransform();this.dots&&this.setCurrentDot()}goTo(e){const t=this.currentIndex;if(this.currentIndex=e,this.fireEvent("update",this.currentIndex),this.isSnap){const e=this.sliderWidth/this.getCurrentSlidesQty(),i=t>this.currentIndex?t-this.currentIndex:this.currentIndex-t,s=t>this.currentIndex?-e*i:e*i;this.container.scrollBy({left:s,behavior:"smooth"}),this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass()}else this.calculateTransform();this.dots&&this.setCurrentDot()}destroy(){var e,t;if(this.loadingClassesAdd&&("string"==typeof this.loadingClassesAdd?this.inner.classList.remove(this.loadingClassesAdd):this.inner.classList.remove(...this.loadingClassesAdd)),this.inner&&this.afterLoadingClassesAdd&&setTimeout(()=>{"string"==typeof this.afterLoadingClassesAdd?this.inner.classList.remove(this.afterLoadingClassesAdd):this.inner.classList.remove(...this.afterLoadingClassesAdd)}),this.el.classList.remove("init"),this.inner.classList.remove("dragging"),this.slides.forEach(e=>e.classList.remove("active")),(null===(e=null==this?void 0:this.dotsItems)||void 0===e?void 0:e.length)&&this.dotsItems.forEach(e=>e.classList.remove("active")),this.prev.classList.remove("disabled"),this.next.classList.remove("disabled"),this.inner.style.width="",this.slides.forEach(e=>e.style.width=""),this.isSnap||(this.inner.style.transform=""),this.isAutoHeight&&(this.inner.style.height=""),this.prev.removeEventListener("click",this.onPrevClickListener),this.next.removeEventListener("click",this.onNextClickListener),this.container.removeEventListener("scroll",this.onContainerScrollListener),this.el.removeEventListener("touchstart",this.onElementTouchStartListener),this.el.removeEventListener("touchend",this.onElementTouchEndListener),this.inner.removeEventListener("mousedown",this.onInnerMouseDownListener),this.inner.removeEventListener("touchstart",this.onInnerTouchStartListener),document.removeEventListener("mousemove",this.onDocumentMouseMoveListener),document.removeEventListener("touchmove",this.onDocumentTouchMoveListener),document.removeEventListener("mouseup",this.onDocumentMouseUpListener),document.removeEventListener("touchend",this.onDocumentTouchEndListener),this.inner.querySelectorAll("a:not(.prevented-click)").forEach(e=>{e.classList.remove("prevented-click"),e.removeEventListener("click",this.removeClickEventWhileDragging)}),(null===(t=null==this?void 0:this.dotsItems)||void 0===t?void 0:t.length)||this.dots.querySelectorAll(":scope > *").length){((null==this?void 0:this.dotsItems)||this.dots.querySelectorAll(":scope > *")).forEach(e=>e.removeEventListener("click",this.onDotClickListener)),this.dots.innerHTML=null}this.isSnap&&this.hasSnapSpacers&&(this.inner.querySelector(".hs-snap-before").remove(),this.inner.querySelector(".hs-snap-after").remove()),this.dotsItems=null,this.isDragging=!1,this.dragStartX=null,this.initialTranslateX=null,window.$hsCarouselCollection=window.$hsCarouselCollection.filter(({element:e})=>e.el!==this.el)}static getInstance(e,t){const i=window.$hsCarouselCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return i?t?i:i.element:null}static autoInit(){window.$hsCarouselCollection||(window.$hsCarouselCollection=[]),window.$hsCarouselCollection&&(window.$hsCarouselCollection=window.$hsCarouselCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll("[data-hs-carousel]:not(.--prevent-on-load-init)").forEach(e=>{window.$hsCarouselCollection.find(t=>{var i;return(null===(i=null==t?void 0:t.element)||void 0===i?void 0:i.el)===e})||new l(e)})}}const a=l},9632(e,t,i){i.d(t,{A:()=>l});var s=i(1926),n=i(7615); /* * HSCollapse * @version: 4.2.0 * @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. */ class o extends n.A{constructor(e,t,i){super(e,t,i),this.contentId=this.el.dataset.hsCollapse,this.content=document.querySelector(this.contentId),this.animationInProcess=!1,this.content&&this.init()}elementClick(){this.content.classList.contains("open")?this.hide():this.show()}init(){var e;this.createCollection(window.$hsCollapseCollection,this),this.onElementClickListener=()=>this.elementClick(),(null===(e=null==this?void 0:this.el)||void 0===e?void 0:e.ariaExpanded)&&(this.el.classList.contains("open")?this.el.ariaExpanded="true":this.el.ariaExpanded="false"),this.el.addEventListener("click",this.onElementClickListener)}hideAllMegaMenuItems(){this.content.querySelectorAll(".hs-mega-menu-content.block").forEach(e=>{e.classList.remove("block"),e.classList.add("hidden")})}show(){var e;if(this.animationInProcess||this.el.classList.contains("open"))return!1;this.animationInProcess=!0,this.el.classList.add("open"),(null===(e=null==this?void 0:this.el)||void 0===e?void 0:e.ariaExpanded)&&(this.el.ariaExpanded="true"),this.content.classList.add("open"),this.content.classList.remove("hidden"),this.content.style.height="0",setTimeout(()=>{this.content.style.height=`${this.content.scrollHeight}px`,this.fireEvent("beforeOpen",this.el),(0,s.JD)("beforeOpen.hs.collapse",this.el,this.el),(0,s.yd)(this.content,()=>{this.content.style.height="",this.fireEvent("open",this.el),(0,s.JD)("open.hs.collapse",this.el,this.el),this.animationInProcess=!1})})}hide(){var e;if(this.animationInProcess||!this.el.classList.contains("open"))return!1;this.animationInProcess=!0,this.el.classList.remove("open"),(null===(e=null==this?void 0:this.el)||void 0===e?void 0:e.ariaExpanded)&&(this.el.ariaExpanded="false"),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout(()=>{this.content.style.height="0"}),this.content.classList.remove("open"),(0,s.yd)(this.content,()=>{this.content.classList.add("hidden"),this.content.style.height="",this.fireEvent("hide",this.el),(0,s.JD)("hide.hs.collapse",this.el,this.el),this.animationInProcess=!1}),this.content.querySelectorAll(".hs-mega-menu-content.block").length&&this.hideAllMegaMenuItems()}destroy(){this.el.removeEventListener("click",this.onElementClickListener),this.content=null,this.animationInProcess=!1,window.$hsCollapseCollection=window.$hsCollapseCollection.filter(({element:e})=>e.el!==this.el)}static findInCollection(e){return window.$hsCollapseCollection.find(t=>e instanceof o?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e)||null}static getInstance(e,t=!1){const i=window.$hsCollapseCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return i?t?i:i.element.el:null}static autoInit(){window.$hsCollapseCollection||(window.$hsCollapseCollection=[]),window.$hsCollapseCollection&&(window.$hsCollapseCollection=window.$hsCollapseCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".hs-collapse-toggle:not(.--prevent-on-load-init)").forEach(e=>{window.$hsCollapseCollection.find(t=>{var i;return(null===(i=null==t?void 0:t.element)||void 0===i?void 0:i.el)===e})||new o(e)})}static show(e){const t=o.findInCollection(e);t&&t.element.content.classList.contains("hidden")&&t.element.show()}static hide(e){const t=o.findInCollection(e);t&&!t.element.content.classList.contains("hidden")&&t.element.hide()}static on(e,t,i){const s=o.findInCollection(t);s&&(s.element.events[e]=i)}}const l=o},3200(e,t,i){i.d(t,{A:()=>r});var s=i(1926),n=i(7615),o=i(8862),l=function(e,t,i,s){return new(i||(i=Promise))(function(n,o){function l(e){try{r(s.next(e))}catch(e){o(e)}}function a(e){try{r(s.throw(e))}catch(e){o(e)}}function r(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(l,a)}r((s=s.apply(e,t||[])).next())})};class a extends n.A{constructor(e,t,i){var s,n,o,l,a,r,c,d,h,u,p,m,g,v,f,y,b,w,C,x,S,k,L,E,T,A,I,M,D,O,$;super(e,t,i),this.isSearchLengthExceeded=!1,this.lastQuery="";const P=e.getAttribute("data-hs-combo-box"),N=P?JSON.parse(P):{},H=Object.assign(Object.assign({},N),t);this.gap=5,this.viewport=null!==(s="string"==typeof(null==H?void 0:H.viewport)?document.querySelector(null==H?void 0:H.viewport):null==H?void 0:H.viewport)&&void 0!==s?s:null,this.preventVisibility=null!==(n=null==H?void 0:H.preventVisibility)&&void 0!==n&&n,this.minSearchLength=null!==(o=null==H?void 0:H.minSearchLength)&&void 0!==o?o:0,this.apiUrl=null!==(l=null==H?void 0:H.apiUrl)&&void 0!==l?l:null,this.apiDataPart=null!==(a=null==H?void 0:H.apiDataPart)&&void 0!==a?a:null,this.apiQuery=null!==(r=null==H?void 0:H.apiQuery)&&void 0!==r?r:null,this.apiSearchQuery=null!==(c=null==H?void 0:H.apiSearchQuery)&&void 0!==c?c:null,this.apiSearchPath=null!==(d=null==H?void 0:H.apiSearchPath)&&void 0!==d?d:null,this.apiSearchDefaultPath=null!==(h=null==H?void 0:H.apiSearchDefaultPath)&&void 0!==h?h:null,this.apiHeaders=null!==(u=null==H?void 0:H.apiHeaders)&&void 0!==u?u:{},this.apiGroupField=null!==(p=null==H?void 0:H.apiGroupField)&&void 0!==p?p:null,this.outputItemTemplate=null!==(m=null==H?void 0:H.outputItemTemplate)&&void 0!==m?m:'<div class="cursor-pointer py-2 px-4 w-full text-sm text-gray-800 hover:bg-gray-100 rounded-lg focus:outline-hidden focus:bg-gray-100 dark:bg-neutral-900 dark:hover:bg-neutral-800 dark:text-neutral-200 dark:focus:bg-neutral-800" data-hs-combo-box-output-item>\n\t\t\t\t<div class="flex justify-between items-center w-full">\n\t\t\t\t\t<span data-hs-combo-box-search-text></span>\n\t\t\t\t\t<span class="hidden hs-combo-box-selected:block">\n\t\t\t\t\t\t<svg class="shrink-0 size-3.5 text-blue-600 dark:text-blue-500" xmlns="http:.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n\t\t\t\t\t\t\t<polyline points="20 6 9 17 4 12"></polyline>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</div>',this.outputEmptyTemplate=null!==(g=null==H?void 0:H.outputEmptyTemplate)&&void 0!==g?g:'<div class="py-2 px-4 w-full text-sm text-gray-800 rounded-lg dark:bg-neutral-900 dark:text-neutral-200">Nothing found...</div>',this.outputLoaderTemplate=null!==(v=null==H?void 0:H.outputLoaderTemplate)&&void 0!==v?v:'<div class="flex justify-center items-center py-2 px-4 text-sm text-gray-800 rounded-lg bg-white dark:bg-neutral-900 dark:text-neutral-200">\n\t\t\t\t<div class="animate-spin inline-block size-6 border-3 border-current border-t-transparent text-blue-600 rounded-[999px] dark:text-blue-500" role="status" aria-label="loading">\n\t\t\t\t\t<span class="sr-only">Loading...</span>\n\t\t\t\t</div>\n\t\t\t</div>',this.groupingType=null!==(f=null==H?void 0:H.groupingType)&&void 0!==f?f:null,this.groupingTitleTemplate=null!==(y=null==H?void 0:H.groupingTitleTemplate)&&void 0!==y?y:"default"===this.groupingType?'<div class="block mb-1 text-xs font-semibold uppercase text-blue-600 dark:text-blue-500"></div>':'<button type="button" class="py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold whitespace-nowrap rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none"></button>',this.tabsWrapperTemplate=null!==(b=null==H?void 0:H.tabsWrapperTemplate)&&void 0!==b?b:'<div class="overflow-x-auto p-4"></div>',this.preventSelection=null!==(w=null==H?void 0:H.preventSelection)&&void 0!==w&&w,this.preventAutoPosition=null!==(C=null==H?void 0:H.preventAutoPosition)&&void 0!==C&&C,this.preventClientFiltering=null!==(x=null==t?void 0:t.preventClientFiltering)&&void 0!==x?x:!!(null==H?void 0:H.apiSearchQuery)||!!(null==H?void 0:H.apiSearchPath),this.isOpenOnFocus=null!==(S=null==H?void 0:H.isOpenOnFocus)&&void 0!==S&&S,this.keepOriginalOrder=null!==(k=null==H?void 0:H.keepOriginalOrder)&&void 0!==k&&k,this.preserveSelectionOnEmpty=null===(L=null==H?void 0:H.preserveSelectionOnEmpty)||void 0===L||L,this.input=null!==(E=this.el.querySelector("[data-hs-combo-box-input]"))&&void 0!==E?E:null,this.output=null!==(T=this.el.querySelector("[data-hs-combo-box-output]"))&&void 0!==T?T:null,this.itemsWrapper=null!==(A=this.el.querySelector("[data-hs-combo-box-output-items-wrapper]"))&&void 0!==A?A:null,this.items=null!==(I=Array.from(this.el.querySelectorAll("[data-hs-combo-box-output-item]")))&&void 0!==I?I:[],this.tabs=[],this.toggle=null!==(M=this.el.querySelector("[data-hs-combo-box-toggle]"))&&void 0!==M?M:null,this.toggleClose=null!==(D=this.el.querySelector("[data-hs-combo-box-close]"))&&void 0!==D?D:null,this.toggleOpen=null!==(O=this.el.querySelector("[data-hs-combo-box-open]"))&&void 0!==O?O:null,this.outputPlaceholder=null,this.selected=this.value=null!==($=this.el.querySelector("[data-hs-combo-box-input]").value)&&void 0!==$?$:"",this.currentData=null,this.isOpened=!1,this.isCurrent=!1,this.animationInProcess=!1,this.selectedGroup="all",this.init()}inputFocus(){this.isOpened||(this.setResultAndRender(),this.open())}inputInput(){const e=this.input.value.trim();e.length<=this.minSearchLength?this.setResultAndRender(""):this.setResultAndRender(e),this.preserveSelectionOnEmpty||""!==e||(this.selected="",this.value="",this.currentData=null),""!==this.input.value?this.el.classList.add("has-value"):this.el.classList.remove("has-value"),this.isOpened||this.open()}toggleClick(){this.isOpened?this.close():this.open(this.toggle.getAttribute("data-hs-combo-box-toggle"))}toggleCloseClick(){this.close()}toggleOpenClick(){this.open()}init(){a.ensureGlobalHandlers(),this.createCollection(window.$hsComboBoxCollection,this),this.build(),"undefined"!=typeof window&&(window.HSAccessibilityObserver||(window.HSAccessibilityObserver=new o.A),this.setupAccessibility())}build(){this.buildInput(),this.groupingType&&this.setGroups(),this.buildItems(),this.preventVisibility&&(this.preventAutoPosition||this.recalculateDirection()),this.toggle&&this.buildToggle(),this.toggleClose&&this.buildToggleClose(),this.toggleOpen&&this.buildToggleOpen()}getNestedProperty(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}setValue(e,t=null){this.selected=e,this.value=e,this.input.value=e,t&&(this.currentData=t),this.fireEvent("select",this.currentData),(0,s.JD)("select.hs.combobox",this.el,this.currentData)}setValueAndOpen(e){this.value=e,this.items.length&&this.setItemsVisibility()}setValueAndClear(e,t=null){e?this.setValue(e,t):this.setValue(this.selected,t),this.outputPlaceholder&&this.destroyOutputPlaceholder()}setSelectedByValue(e){this.items.forEach(t=>{const i=t.querySelector("[data-hs-combo-box-value]");i&&e.includes(i.textContent)?t.classList.add("selected"):t.classList.remove("selected")})}setResultAndRender(e=""){const t=(this.preventVisibility?this.input.value:e).trim(),i=t.length<this.minSearchLength;this.isSearchLengthExceeded=i,t!==this.lastQuery?(this.lastQuery=t,this.setResults(t),!i&&(this.apiSearchQuery||this.apiSearchPath||this.apiSearchDefaultPath)&&this.itemsFromJson(),this.updatePlaceholderVisibility()):this.updatePlaceholderVisibility()}setResults(e){this.value=e,this.resultItems(),this.updatePlaceholderVisibility()}updatePlaceholderVisibility(){this.hasVisibleItems()?this.destroyOutputPlaceholder():this.buildOutputPlaceholder()}setGroups(){const e=[];this.items.forEach(t=>{const{group:i}=JSON.parse(t.getAttribute("data-hs-combo-box-output-item"));e.some(e=>(null==e?void 0:e.name)===i.name)||e.push(i)}),this.groups=e}setApiGroups(e){const t=[];e.forEach(e=>{const i=e[this.apiGroupField];t.some(e=>e.name===i)||t.push({name:i,title:i})}),this.groups=t}setItemsVisibility(){if(this.preventClientFiltering)return this.items.forEach(e=>{e.style.display=""}),!1;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&this.items.forEach(e=>{e.style.display="none"});const e="tabs"===this.groupingType?"all"===this.selectedGroup?this.items:this.items.filter(e=>{const{group:t}=JSON.parse(e.getAttribute("data-hs-combo-box-output-item"));return t.name===this.selectedGroup}):this.items;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&e.forEach(e=>{e.style.display="block"}),e.forEach(e=>{this.isTextExistsAny(e,this.value)?e.style.display="block":e.style.display="none"}),"default"===this.groupingType&&this.output.querySelectorAll("[data-hs-combo-box-group-title]").forEach(e=>{const t=e.getAttribute("data-hs-combo-box-group-title");this.items.filter(e=>{const{group:i}=JSON.parse(e.getAttribute("data-hs-combo-box-output-item"));return i.name===t&&"block"===e.style.display}).length?e.style.display="block":e.style.display="none"})}isTextExistsAny(e,t){return Array.from(e.querySelectorAll("[data-hs-combo-box-search-text]")).some(e=>e.getAttribute("data-hs-combo-box-search-text").toLowerCase().includes(t.toLowerCase()))}hasVisibleItems(){return!!this.items.length&&this.items.some(e=>{const t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility})}valuesBySelector(e){return Array.from(e.querySelectorAll("[data-hs-combo-box-search-text]")).reduce((e,t)=>[...e,t.getAttribute("data-hs-combo-box-search-text")],[])}sortItems(){if(this.keepOriginalOrder)return this.items;return this.items.sort((e,t)=>{const i=e.querySelector("[data-hs-combo-box-value]").textContent,s=t.querySelector("[data-hs-combo-box-value]").textContent;return i<s?-1:i>s?1:0})}buildInput(){this.isOpenOnFocus&&(this.onInputFocusListener=()=>this.inputFocus(),this.input.addEventListener("focus",this.onInputFocusListener)),this.onInputInputListener=(0,s.sg)(()=>this.inputInput()),this.input.addEventListener("input",this.onInputInputListener),this.input.addEventListener("paste",e=>{var t,i,s,n,o;const l=null!==(i=null===(t=e.clipboardData)||void 0===t?void 0:t.getData("text"))&&void 0!==i?i:"";e.preventDefault();const a=null!==(s=this.input.selectionStart)&&void 0!==s?s:this.input.value.length,r=null!==(n=this.input.selectionEnd)&&void 0!==n?n:this.input.value.length,c=this.input.value.slice(0,a)+l+this.input.value.slice(r);this.input.value=c,null===(o=this.onInputInputListener)||void 0===o||o.call(this,new InputEvent("input",{inputType:"insertFromPaste",data:l}))})}buildItems(){return l(this,void 0,void 0,function*(){this.output.role="listbox",this.output.tabIndex=-1,this.output.ariaOrientation="vertical",this.apiUrl?yield this.itemsFromJson():(this.itemsWrapper?this.itemsWrapper.innerHTML="":this.output.innerHTML="",this.itemsFromHtml()),(null==this?void 0:this.items.length)&&this.items[0].classList.contains("selected")&&(this.currentData=JSON.parse(this.items[0].getAttribute("data-hs-combo-box-item-stored-data")))})}buildOutputLoader(){if(this.outputLoader)return!1;this.outputLoader=(0,s.fc)(this.outputLoaderTemplate),this.items.length||this.outputPlaceholder?(this.outputLoader.style.position="absolute",this.outputLoader.style.top="0",this.outputLoader.style.bottom="0",this.outputLoader.style.left="0",this.outputLoader.style.right="0",this.outputLoader.style.zIndex="2"):(this.outputLoader.style.position="",this.outputLoader.style.top="",this.outputLoader.style.bottom="",this.outputLoader.style.left="",this.outputLoader.style.right="",this.outputLoader.style.zIndex="",this.outputLoader.style.height="30px"),this.output.append(this.outputLoader)}buildToggle(){var e,t,i,s;this.isOpened?((null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),(null===(t=null==this?void 0:this.input)||void 0===t?void 0:t.ariaExpanded)&&(this.input.ariaExpanded="true")):((null===(i=null==this?void 0:this.toggle)||void 0===i?void 0:i.ariaExpanded)&&(this.toggle.ariaExpanded="false"),(null===(s=null==this?void 0:this.input)||void 0===s?void 0:s.ariaExpanded)&&(this.input.ariaExpanded="false")),this.onToggleClickListener=()=>this.toggleClick(),this.toggle.addEventListener("click",this.onToggleClickListener)}buildToggleClose(){this.onToggleCloseClickListener=()=>this.toggleCloseClick(),this.toggleClose.addEventListener("click",this.onToggleCloseClickListener)}buildToggleOpen(){this.onToggleOpenClickListener=()=>this.toggleOpenClick(),this.toggleOpen.addEventListener("click",this.onToggleOpenClickListener)}buildOutputPlaceholder(){this.outputPlaceholder||(this.outputPlaceholder=(0,s.fc)(this.outputEmptyTemplate)),this.appendItemsToWrapper(this.outputPlaceholder)}destroyOutputLoader(){this.outputLoader&&this.outputLoader.remove(),this.outputLoader=null}itemRender(e){var t;const i=e.querySelector("[data-hs-combo-box-value]").textContent,s=null!==(t=JSON.parse(e.getAttribute("data-hs-combo-box-item-stored-data")))&&void 0!==t?t:null;this.itemsWrapper?this.itemsWrapper.append(e):this.output.append(e),this.preventSelection||e.addEventListener("click",()=>{this.close(i,s),this.setSelectedByValue(this.valuesBySelector(e))})}plainRender(e){e.forEach(e=>{this.itemRender(e)})}jsonItemsRender(e,t=0){e.forEach(e=>{const i=(0,s.fc)(this.outputItemTemplate);i.setAttribute("data-hs-combo-box-item-stored-data",JSON.stringify(e)),i.querySelectorAll("[data-hs-combo-box-output-item-field]").forEach(t=>{const i=t.getAttribute("data-hs-combo-box-output-item-field");let s="";try{const t=JSON.parse(i);s=Array.isArray(t)?t.map(t=>this.getNestedProperty(e,t)).filter(Boolean).join(" "):this.getNestedProperty(e,i)}catch(t){s=this.getNestedProperty(e,i)}t.textContent=null!=s?s:"",!s&&t.hasAttribute("data-hs-combo-box-output-item-hide-if-empty")&&(t.style.display="none")}),i.querySelectorAll("[data-hs-combo-box-search-text]").forEach(t=>{const i=t.getAttribute("data-hs-combo-box-output-item-field");let s="";try{const t=JSON.parse(i);s=Array.isArray(t)?t.map(t=>this.getNestedProperty(e,t)).filter(Boolean).join(" "):this.getNestedProperty(e,i)}catch(t){s=this.getNestedProperty(e,i)}t.setAttribute("data-hs-combo-box-search-text",null!=s?s:"")}),i.querySelectorAll("[data-hs-combo-box-output-item-attr]").forEach(t=>{JSON.parse(t.getAttribute("data-hs-combo-box-output-item-attr")).forEach(i=>{let s=e[i.valueFrom];"class"===i.attr&&t.className?t.className=`${t.className} ${s}`.trim():t.setAttribute(i.attr,s)})}),i.setAttribute("tabIndex",`${t}`),"tabs"!==this.groupingType&&"default"!==this.groupingType||i.setAttribute("data-hs-combo-box-output-item",`{"group": {"name": "${e[this.apiGroupField]}", "title": "${e[this.apiGroupField]}"}}`),this.items=[...this.items,i],this.preventSelection||i.addEventListener("click",()=>{this.close(i.querySelector("[data-hs-combo-box-value]").textContent,JSON.parse(i.getAttribute("data-hs-combo-box-item-sto