!function(e){"use strict";var t=function(t){var s=this;return this.isOpen=!1,this.init=function(){this.$searchblock=e(t),this.$searchInput=e('input[type="search"]',this.$searchblock),this.$searchInput.length&&(this.$searchblock.closest(".--inline-layout-ov").length?this.layout="overlay":this.$searchblock.closest(".--inline-layout-drop").length&&(this.layout="drop"),"overlay"===this.layout&&this.$searchblock.closest(".--prevent-results-overlay").length||this.events())},this.events=function(){this.$searchInput.on("focus",(function(e){rey.vars.is_global_section_mode||s.isOpen||s.open()})),e(document.body).on("click",(function(e){s.isOpen&&(e.target.closest(".rey-headerSearch--inline")||s.close())})),e(".rey-searchPanel__suggestions button",this.$searchblock).on("click",(function(t){t.preventDefault(),s.$searchInput.val(e(this).text()).trigger("input",[!0])})),e(".rey-headerSearch-toggle",this.$searchblock).on("click",(function(e){e.preventDefault(),s.isOpen||(s.open(),s.$searchInput.trigger("focus"))})),e(".rey-inlineSearch-mobileClose",this.$searchblock).on("click",(function(e){e.preventDefault(),s.isOpen&&s.close()})),e(window).on("resize",rey.util.debounce((function(){s.positionOnMobiles()}),300))},this.positionOnMobiles=function(){window.matchMedia("(max-width: 1024px)").matches&&e(".rey-inlineSearch-wrapper",this.$searchblock).css("inset-inline-start",`calc( -1 * ( ${this.$searchblock.offset().left}px - var(--left-distance, 0px) ) )`)},this.open=function(){this.isOpen=!0,this.positionOnMobiles(),"overlay"===this.layout&&(rey.frontend.panels.init(this.close.bind(this)),rey.frontend.overlay.open("header",{darken:!0}),rey.elements.body.classList.add("search-inline--active")),this.$searchblock.addClass("--active")},this.close=function(){this.isOpen&&(this.isOpen=!1,"overlay"===this.layout&&(rey.frontend.panels.reset(),rey.elements.body.classList.remove("search-inline--active"),rey.frontend.overlay.close()),this.$searchblock.removeClass("--active"))},this.init()};document.addEventListener("rey-DOMContentLoaded",(function(s){e(".rey-headerSearch--inline").each((function(){new t(this)}))}))}(jQuery);