// CAPTCHA validation functionality window.ashleyCaptcha = window.ashleyCaptcha || {}; ashleyCaptcha.initAll = function () { const captchaBlocks = document.querySelectorAll(".ashley-captcha-container[data-captcha-id]"); captchaBlocks.forEach(function (block) { const uniqueId = block.getAttribute("data-captcha-id"); if (uniqueId) { ashleyCaptcha.init(uniqueId); } }); }; ashleyCaptcha.init = function (uniqueId) { const captchaBlock = document.querySelector("[data-captcha-id=\"" + uniqueId + "\"]"); if (!captchaBlock) return; const form = captchaBlock.closest("form"); if (!form) return; const validator = function (event) { if (ashleyCaptcha.validate(uniqueId)) return; event.preventDefault(); event.stopImmediatePropagation(); return false; }; // Add validation to this specific form's submit events form.addEventListener("submit", validator, true); // Also add in bubble phase as backup form.addEventListener("submit", validator, false); // Force a CAPTCHA refresh when the form is reset. form.addEventListener("reset", function () { ashleyCaptcha.refresh(uniqueId); }); // Clear error message when user types const inputElement = captchaBlock.querySelector(".ashley-captcha-input"); if (inputElement) { inputElement.addEventListener("input", function () { ashleyCaptcha.clearError(uniqueId); }); } }; ashleyCaptcha.validate = function (uniqueId) { const captchaBlock = document.querySelector("[data-captcha-id=\"" + uniqueId + "\"]"); if (!captchaBlock) return false; const inputElement = captchaBlock.querySelector(".ashley-captcha-input"); const errorElement = captchaBlock.querySelector(".ashley-captcha-error-message"); if (!inputElement || !errorElement) { console.error("CAPTCHA elements not found for validation"); return false; } const userInput = inputElement.value.trim(); if (userInput === "") { ashleyCaptcha.showError(uniqueId, "Please enter the CAPTCHA result."); inputElement.focus(); return false; } // We can't validate the actual result client-side // Just check that something was entered ashleyCaptcha.clearError(uniqueId); return true; }; ashleyCaptcha.showError = function (uniqueId, message) { const captchaBlock = document.querySelector("[data-captcha-id=\"" + uniqueId + "\"]"); if (!captchaBlock) return; const errorElement = captchaBlock.querySelector(".ashley-captcha-error-message"); const inputElement = captchaBlock.querySelector(".ashley-captcha-input"); if (errorElement) { errorElement.textContent = message; errorElement.style.display = "block"; } if (inputElement) { inputElement.style.borderColor = "#c62828"; inputElement.style.borderWidth = "2px"; } // Scroll to CAPTCHA if not visible captchaBlock.scrollIntoView({ behavior: "smooth", block: "center" }); }; ashleyCaptcha.clearError = function (uniqueId) { const captchaBlock = document.querySelector("[data-captcha-id=\"" + uniqueId + "\"]"); if (!captchaBlock) return; const errorElement = captchaBlock.querySelector(".ashley-captcha-error-message"); const inputElement = captchaBlock.querySelector(".ashley-captcha-input"); if (errorElement) { errorElement.style.display = "none"; } if (inputElement) { inputElement.style.borderColor = ""; inputElement.style.borderWidth = ""; } }; ashleyCaptcha.refresh = function (uniqueId) { const captchaBlock = document.querySelector("[data-captcha-id=\"" + uniqueId + "\"]"); if (!captchaBlock) return; const imgElement = captchaBlock.querySelector(".ashley-captcha"); const nonceElement = captchaBlock.querySelector("input[name='ashley_captcha_nonce']"); const inputElement = captchaBlock.querySelector(".ashley-captcha-input"); // Clear any existing errors ashleyCaptcha.clearError(uniqueId); // Show loading state imgElement.style.opacity = "0.5"; inputElement.value = ""; // Make AJAX request to refresh CAPTCHA const xhr = new XMLHttpRequest(); xhr.open("POST", ashleyCaptchaAjax.ajaxUrl, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { try { const response = JSON.parse(xhr.responseText); if (response.success) { imgElement.src = response.data.image_src; nonceElement.value = response.data.nonce; imgElement.style.opacity = "1"; inputElement.focus(); } else { ashleyCaptcha.showError(uniqueId, "Error refreshing CAPTCHA: " + response.data); imgElement.style.opacity = "1"; } } catch (e) { ashleyCaptcha.showError(uniqueId, "Error refreshing CAPTCHA. Please try again."); imgElement.style.opacity = "1"; } } else { ashleyCaptcha.showError(uniqueId, "Network error. Please try again."); imgElement.style.opacity = "1"; } } }; xhr.send("action=ashley_captcha_refresh&captcha_id=" + encodeURIComponent(uniqueId)); }; // Initialize all CAPTCHA blocks when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', ashleyCaptcha.initAll); } else { ashleyCaptcha.initAll(); } ; (function() { function init() { const lightboxImages = document.querySelectorAll('.wp-block-image[data-lightbox-enabled="true"] img'); if (!lightboxImages.length) return; lightboxImages.forEach(img => { img.addEventListener('click', openLightbox); }); } function openLightbox(event) { event.preventDefault(); const sourceImage = event.target; const fullSizeUrl = new URL(sourceImage.src); window.ashley.lightbox.openImage(fullSizeUrl, sourceImage.alt); } // Initialize when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })(); ; (function() { function init() { const shareButtons = document.querySelectorAll('button.image-sharing-button'); shareButtons.forEach(function(button) { button.addEventListener('click', event => { event.preventDefault(); toggleShareOptions(event.currentTarget) }); }); } function toggleShareOptions(button) { const wrapper = button.closest('.image-sharing-wrapper'); const shareButton = wrapper.querySelector('button.image-sharing-button'); const shareButtonIcon = shareButton.querySelector('i'); const optionButtons = wrapper.querySelectorAll('a.image-sharing-option'); if (optionButtons.length) { let isActive = false; for (let i = 0; i < optionButtons.length; i++) isActive = optionButtons[i].classList.toggle('active'); shareButtonIcon.className = isActive ? 'fa-solid fa-xmark' : 'fa-solid fa-share'; return; } const sharingOptions = wrapper.dataset.sharingOptions.split(' '); appendOptions(wrapper, sharingOptions, shareButton); shareButtonIcon.className = 'fa-solid fa-xmark'; } function appendOptions(wrapper, sharingOptions, shareButton) { sharingOptions.forEach(function(action) { const option = document.createElement('a'); option.className = shareButton.className; option.classList.add('image-sharing-option', 'active'); option.style.cssText = shareButton.style.cssText; option.href = getUrl(wrapper, action); option.rel = 'noopener noreferrer nofollow'; option.target = '_blank'; if (action === 'download') option.setAttribute('download', ''); const icon = document.createElement('i'); icon.className = getIconClass(action); option.appendChild(icon); wrapper.appendChild(option); }); } function getUrl(wrapper, action) { const imageUrl = wrapper.dataset.imageUrl; switch(action) { case 'facebook': return `https://www.facebook.com/sharer.php?u=${encodeURIComponent(imageUrl)}`; case 'twitter': return `https://twitter.com/intent/tweet?url=${encodeURIComponent(imageUrl)}`; case 'pinterest': return `https://pinterest.com/pin/create/button/?media=${encodeURIComponent(imageUrl)}`; default: return imageUrl; } } function getIconClass(action) { const icons = { download: 'fa-solid fa-download', facebook: 'fa-brands fa-facebook-f', twitter: 'fa-brands fa-x-twitter', pinterest: 'fa-brands fa-pinterest-p' }; return icons[action] || ''; } // Initialize when DOM is ready if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init(); })(); ; (function(){"use strict";window.kadence={initOutlineToggle:function(){document.body.addEventListener("keydown",function(){document.body.classList.remove("hide-focus-outline")}),document.body.addEventListener("mousedown",function(){document.body.classList.add("hide-focus-outline")})},getOffset:function(a){if(a instanceof HTMLElement){var b=a.getBoundingClientRect();return{top:b.top+window.pageYOffset,left:b.left+window.pageXOffset}}return{top:null,left:null}},findParents:function(a,b){function c(a){var e=a.parentNode;e instanceof HTMLElement&&(e.matches(b)&&d.push(e),c(e))}var d=[];return c(a),d},toggleAttribute:function(a,b,c,d){c===void 0&&(c=!0),d===void 0&&(d=!1),a.getAttribute(b)===c?a.setAttribute(b,d):a.setAttribute(b,c)},initNavToggleSubmenus:function(){var a=document.querySelectorAll(".nav--toggle-sub");if(a.length)for(let b=0;bh)var u=Math.floor(Math.floor(i)-Math.floor(k)+Math.floor(s));else var u=Math.floor(i-k);var v=e.querySelectorAll(".custom-logo"),w=e.querySelector(".site-main-header-inner-wrap"),x=parseInt(w.getAttribute("data-start-height"));if(x||(w.setAttribute("data-start-height",w.offsetHeight),x=w.offsetHeight),window.scrollY<=u){if(w.style.height=x+"px",w.style.minHeight=x+"px",w.style.maxHeight=x+"px",v)for(let a,b=0;bu){var y=Math.max(t,x-(window.scrollY-(i-k)));if(w.style.height=y+"px",w.style.minHeight=y+"px",w.style.maxHeight=y+"px",v)for(let a,b=0;bh;if(A<=z)e.style.transform="translateY(0px)";else if(F)e.classList.add("item-hidden-above"),e.style.transform="translateY("+(Math.abs(E)>B?-B:E)+"px)";else{var z=Math.floor(i-k);e.style.transform="translateY("+(0z?"true"===r?window.scrollY{a.forEach(a=>{b(0{j("updateActive")})}},getTopOffset:function(a="scroll"){if("load"===a)var b=document.querySelector("#main-header .kadence-sticky-header"),c=document.querySelector("#mobile-header .kadence-sticky-header");else var b=document.querySelector("#main-header .kadence-sticky-header:not([data-reveal-scroll-up=\"true\"])"),c=document.querySelector("#mobile-header .kadence-sticky-header:not([data-reveal-scroll-up=\"true\"])");var d=0,e=0;if(kadenceConfig.breakPoints.desktop<=window.innerWidth){if(b){var f=b.getAttribute("data-shrink");d="true"!==f||b.classList.contains("site-header-inner-wrap")?Math.floor(b.offsetHeight):Math.floor(b.getAttribute("data-shrink-height"))}else d=0;document.body.classList.contains("admin-bar")&&(e=32)}else{if(c){var f=c.getAttribute("data-shrink");d="true"===f?Math.floor(c.getAttribute("data-shrink-height")):Math.floor(c.offsetHeight)}else d=0;document.body.classList.contains("admin-bar")&&(e=46)}return Math.floor(d+e+Math.floor(kadenceConfig.scrollOffset))},scrollToElement:function(a,b,c="scroll"){b=!("undefined"!=typeof b)||b;var d=window.kadence.getTopOffset(c),e=Math.floor(a.getBoundingClientRect().top)-d;window.scrollBy({top:e,left:0,behavior:"smooth"}),a.tabIndex="-1",a.focus({preventScroll:!0}),a.classList.contains("kt-title-item")&&a.firstElementChild.click(),b&&window.history.pushState("","","#"+a.id)},anchorScrollToCheck:function(a,b){if(b="undefined"==typeof b?null:b,a.target.getAttribute("href"))var c=a.target;else{var c=a.target.closest("a");if(!c)return;if(!c.getAttribute("href"))return}if(!(c.parentNode&&c.parentNode.hasAttribute("role")&&"tab"===c.parentNode.getAttribute("role"))&&!c.closest(".woocommerce-tabs ul.tabs")){var d=b?b.getAttribute("href").substring(b.getAttribute("href").indexOf("#")):c.getAttribute("href").substring(c.getAttribute("href").indexOf("#"));var e=document.getElementById(d.replace("#",""));e&&(e?.classList?.contains("kt-accordion-pane")||(a.preventDefault(),window.kadence.scrollToElement(e),window.kadence.updateActiveAnchors()))}},initStickySidebarWidget:function(){if(document.body.classList.contains("has-sticky-sidebar-widget")){var a=window.kadence.getTopOffset(),b=document.querySelector("#secondary .sidebar-inner-wrap .widget:last-child");b&&(b.style.top=Math.floor(a+20)+"px",b.style.maxHeight="calc( 100vh - "+Math.floor(a+20)+"px )")}},initStickySidebar:function(){if(document.body.classList.contains("has-sticky-sidebar")){var a=window.kadence.getTopOffset(),b=document.querySelector("#secondary .sidebar-inner-wrap");b&&(b.style.top=Math.floor(a+20)+"px",b.style.maxHeight="calc( 100vh - "+Math.floor(a+20)+"px )")}},initActiveAnchors:function(){""!=window.location.hash&&window.kadence.updateActiveAnchors(),window.onhashchange=function(){window.kadence.updateActiveAnchors()}},updateActiveAnchors:function(){const a=document.querySelectorAll(".menu-item");a.forEach(function(a){const b=a.querySelector("a");b?.href&&b.href.includes("#")&&(window.location.href==b.href?a.classList.add("current-menu-item"):a.classList.remove("current-menu-item"))})},initAnchorScrollTo:function(){if(!document.body.classList.contains("no-anchor-scroll")){if(window.onhashchange=function(){""===window.location.hash&&(window.scrollTo({top:0,behavior:"smooth"}),document.activeElement.blur())},""!=window.location.hash){var a,b=location.hash.substring(1);if(!/^[A-z0-9_-]+$/.test(b))return;a=document.getElementById(b),a&&window.setTimeout(function(){window.kadence.scrollToElement(a,!1,"load")},100)}var c=document.querySelectorAll("a[href*=\\#]:not([href=\\#]):not(.scroll-ignore):not([data-tab]):not([data-toggle]):not(.woocommerce-tabs a):not(.tabs a)");c.length&&c.forEach(function(a){try{var b=new URL(a.href);b.pathname===window.location.pathname&&a.addEventListener("click",function(a){window.kadence.anchorScrollToCheck(a)})}catch(b){console.log("ClassList: "+a.classList,"Invalid URL")}})}},initScrollToTop:function(){var a=document.getElementById("kt-scroll-up");if(a){var b=function(){100b!==a);if(d.forEach(function(a){const b=a.querySelector(":scope > ul.sub-menu");b&&b.classList.remove("opened")}),!b){const b=d=>{a.contains(d.target)||(c.classList.remove("opened"),document.removeEventListener("click",b))};document.addEventListener("click",b)}}})})})},init:function(){window.kadence.initNavToggleSubmenus(),window.kadence.initToggleDrawer(),window.kadence.initMobileToggleAnchor(),window.kadence.initMobileToggleSub(),window.kadence.initOutlineToggle(),window.kadence.initStickyHeader(),window.kadence.initStickySidebar(),window.kadence.initStickySidebarWidget(),window.kadence.initTransHeaderPadding(),window.kadence.initAnchorScrollTo(),window.kadence.initScrollToTop(),window.kadence.initActiveAnchors(),window.kadence.initClickToOpen()}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",window.kadence.init):window.kadence.init()})();; (()=>{"use strict";const t="pg",e={[t]:1,fe:!0,ql_id:0,fc:"",dt:""},s="wp-block-kadence-query-pagination",i="wp-block-kadence-query-result-count",r="kb-query-loaded",n="kb-query-filter-update",o="kb-query-filter-trigger";class l{queryBlock;root;constructor(t){this.queryBlock=t,this.root=t.root,this.queryBlock.infiniteScroll||(this.attachListeners(),window.addEventListener(r,this.attachListeners.bind(this))),window.addEventListener(r,this.setUrlParams.bind(this))}setUrlParams(e){if(!0!==e&&e.qlID&&e.qlID!=this.queryBlock.rootID)return;const s=new URL(window.location.href);1{const[e,i]=t;this.root.querySelector("."+s+e).innerHTML=i})):this.root.querySelectorAll("."+s).forEach((function(t){t.innerHTML=""}))}attachListeners(t=!0){if(!0!==t&&t.qlID&&t.qlID!=this.queryBlock.rootID)return;const e=this;var s=this.root.querySelectorAll(".page-numbers");for(let t=0;t{const[e,s]=t;this.root.querySelector("."+i+e).innerHTML=s})):this.root.querySelectorAll("."+i).forEach((function(t){t.innerHTML=""}))}setFilterShown(t=!0){if(!0!==t&&t.qlID&&t.qlID!=this.queryBlock.rootID)return;const e=this,s=e.queryBlock.components.filters.getFirstFilter(!0);e.root.querySelectorAll("."+i).forEach((function(t){let i=!1;"showFilter"in t.dataset&&t.dataset.showFilter&&(i=!0),i&&e.queryBlock.queryResults&&s&&(t.querySelector(".show-filter").innerHTML=" in "+s)}))}attachListeners(){}}class u{queryBlock;root;constructor(t){this.queryBlock=t,this.root=t.root.querySelector(".wp-block-kadence-query-noresults"),window.addEventListener(r,this.setVisibility.bind(this))}setVisibility(t=!0){!0!==t&&t.qlID&&t.qlID!=this.queryBlock.rootID||this.root&&(1>this.queryBlock.queryResults.postCount?this.root.classList.add("active"):this.root.classList.remove("active"))}}class h{queryBlock;root;uniqueID;hash;isUnique=!0;lastUpdated;type;timer;isRTL;constructor(t,e){if(this.constructor==h)throw new Error("Abstract classes can't be instantiated.");this.queryBlock=t,this.root=e,this.uniqueID=this.root.dataset.uniqueid,this.hash=this.root.dataset.hash,this.lastUpdated=Date.now(),this.isRTL=document.body&&document.body.classList.contains("rtl")}getValue(t=!1){throw new Error("Method 'getValue()' must be implemented.")}reset(){throw new Error("Method 'reset()' must be implemented.")}setValue(){throw new Error("Method 'setValue()' must be implemented.")}prefill(){if(this.hash){const t=window.location.search,e=new URLSearchParams(t);e.has(this.hash)?this.setValue(e.get(this.hash)):"buttons"==this.type&&this.setValue("")}}triggerUpdated(t){t&&t.target&&(this.queryBlock.components.filters.lastSelectedValue=t.target.value),this.lastUpdated=Date.now();var e=new Event(n,{bubbles:!0});e.qlID=this.queryBlock.rootID,this.root.dispatchEvent(e)}triggerReset(){var t=new Event(o,{bubbles:!0});t.qlID=this.queryBlock.rootID,this.root.dispatchEvent(t)}debouncedTriggerUpdated(t){const e=this;clearTimeout(e.timer),e.timer=setTimeout((()=>{e.triggerUpdated()}),t)}}class c extends h{input;constructor(t,e){return super(t,e),this.input=this.root.querySelector(".kb-filter"),this.type="dropdown",this.attachListeners(),this.prefill(),this}getValue(t=!1){return this.input&&"undefined"!=this.input.value&&""!=this.input.value?t?this.input.value:{[this.hash]:this.input.value}:t?"":{[this.hash]:""}}reset(){this.input&&(this.input.value="")}setValue(t){this.input&&(this.input.value=t)}attachListeners(){this.input&&this.input.addEventListener("change",this.triggerUpdated.bind(this))}}class d extends h{inputWrap;constructor(t,e){return super(t,e),this.inputWrap=this.root.querySelector(".kadence-filter-wrap"),this.type="buttons",this.attachListeners(),this.prefill(),this}getValue(t=!1){const e=this.inputWrap.querySelectorAll("button[aria-pressed]");if(e.length>0){var s="";return e.forEach((function(t){const e=t.dataset.value?t.dataset.value:"";e&&(s=s?s+","+e:e)})),t?s:{[this.hash]:s}}return t?"":{[this.hash]:""}}reset(){const t=this.inputWrap.querySelectorAll("button");t.length>0&&t.forEach((function(t){t.removeAttribute("aria-pressed"),t.classList.remove("pressed")}))}setValue(t){const e=t?t.split(","):[],s=this.inputWrap.querySelectorAll("button");s.length>0&&s.forEach((function(s){const i=s.dataset.value?s.dataset.value:"";(e.includes(i)||""==t&&""==i)&&(s.setAttribute("aria-pressed","true"),s.classList.add("pressed"))}))}triggerButtonPress(t){t.preventDefault();const e=t.target,s=e.classList.contains("pressed");this.reset(),s?this.setValue(""):(e.setAttribute("aria-pressed",!0),e.classList.add("pressed")),this.triggerUpdated()}attachListeners(){const t=this,e=this.inputWrap.querySelectorAll("button");e.length>0&&e.forEach((function(e){e.addEventListener("click",t.triggerButtonPress.bind(t))}))}}class p extends h{inputWrap;constructor(t,e){return super(t,e),this.inputWrap=this.root.querySelector(".kadence-filter-wrap"),this.type="checkbox",this.attachListeners(),this.prefill(),this}getValue(t=!1){const e=this.inputWrap.querySelectorAll('input[type="checkbox"]:checked');if(e.length>0){var s="";return e.forEach((function(t){t.value&&(s=s?s+","+t.value:t.value)})),t?s:{[this.hash]:s}}return t?"":{[this.hash]:""}}reset(){const t=this.inputWrap.querySelectorAll('input[type="checkbox"]');t.length>0&&t.forEach((function(t){t.checked=!1}))}setValue(t){const e=this,s=t?t.split(","):[],i=this.inputWrap.querySelectorAll('input[type="checkbox"]');i.length>0&&i.forEach((function(t){s.includes(t.value)&&(t.checked=!0),t.value==e.queryBlock?.components?.filters?.lastSelectedValue&&t.focus()}))}attachListeners(){const t=this,e=this.inputWrap.querySelectorAll('input[type="checkbox"]');e.length>0&&e.forEach((function(e){e.addEventListener("change",t.triggerUpdated.bind(t))}))}}class f extends h{input;constructor(t,e){return super(t,e),this.input=this.root.querySelector(".kb-filter-date"),this.type="date",this.attachListeners(),this.prefill(),this}getValue(t=!1){return this.input&&"undefined"!=this.input.value&&""!=this.input.value?t?this.input.value:{[this.hash]:this.input.value}:t?"":{[this.hash]:""}}reset(){this.input.value=""}setValue(t){this.input.value=t}attachListeners(){this.input&&this.input.addEventListener("change",this.triggerUpdated.bind(this))}}class y extends h{fromSlider;toSlider;fromInput;toInput;fromDisplay;toDisplay;constructor(t,e){return super(t,e),this.type="range",this.fromSlider=this.root.querySelector(".fromSlider"),this.toSlider=this.root.querySelector(".toSlider"),this.fromInput=this.root.querySelector(".fromInput"),this.toInput=this.root.querySelector(".toInput"),this.fromDisplay=this.root.querySelector(".from-display"),this.toDisplay=this.root.querySelector(".to-display"),this.fillSlider(this.fromSlider,this.toSlider,this.toSlider),this.setToggleAccessible(this.toSlider),this.attachListeners(),this.prefill(),this}getValue(t=!1){if(this.toInput&&"undefined"!=this.toInput.value&&""!=this.toInput.value||this.fromInput&&"undefined"!=this.fromInput.value&&""!=this.fromInput.value){const e=this.fromInput.value+","+this.toInput.value;return t?e:{[this.hash]:e}}return t?"":{[this.hash]:""}}reset(){this.fromSlider.value=this.fromSlider.min,this.toSlider.value=this.toSlider.max,this.fromInput.value=this.fromInput.min,this.toInput.value=this.toInput.max,this.fillSlider(this.fromSlider,this.toSlider,this.toSlider),this.setToggleAccessible(this.toSlider)}setValue(t){const[e,s]=t.split(",");e&&(this.fromSlider.value=e,this.fromInput.value=e),s&&(this.toSlider.value=s,this.toInput.value=s),this.fillSlider(this.fromSlider,this.toSlider,this.toSlider),this.setToggleAccessible(this.toSlider)}attachListeners(){const t=this;this.fromSlider.addEventListener("input",this.controlFromSlider.bind(t)),this.toSlider.addEventListener("input",this.controlToSlider.bind(t)),this.fromInput.addEventListener("blur",this.controlFromInput.bind(t)),this.toInput.addEventListener("blur",this.controlToInput.bind(t))}controlFromInput(){const[t,e]=this.getParsed(this.fromInput,this.toInput);t>e?(this.fromSlider.value=e,this.fromInput.value=e):this.fromSlider.value=t,this.fillSlider(this.fromInput,this.toInput,this.toSlider),this.debouncedTriggerUpdated(1e3)}controlToInput(){const[t,e]=this.getParsed(this.fromInput,this.toInput);this.setToggleAccessible(this.toInput),t<=e?(this.toSlider.value=e,this.toInput.value=e):this.toInput.value=t,this.fillSlider(this.fromInput,this.toInput,this.toSlider),this.debouncedTriggerUpdated(1e3)}controlFromSlider(){const[t,e]=this.getParsed(this.fromSlider,this.toSlider);t>e?(this.fromSlider.value=e,this.fromInput.value=e):this.fromInput.value=t,this.fillSlider(this.fromSlider,this.toSlider,this.toSlider),this.debouncedTriggerUpdated(1e3)}controlToSlider(){const[t,e]=this.getParsed(this.fromSlider,this.toSlider);this.setToggleAccessible(this.toSlider),t<=e?(this.toSlider.value=e,this.toInput.value=e):(this.toInput.value=t,this.toSlider.value=t),this.fillSlider(this.fromSlider,this.toSlider,this.toSlider),this.debouncedTriggerUpdated(1e3)}getParsed(t,e){return[parseInt(t.value,10),parseInt(e.value,10)]}fillSlider(t,e,s){const i=e.max-e.min,r=t.value-e.min,n=e.value-e.min;var o="to right";this.isRTL&&(o="to left");const l=s.getAttribute("data-sliderColor"),a=s.getAttribute("data-sliderHighlightColor");s.style.background=`linear-gradient(\n ${o},\n ${l} 0%,\n ${l} ${r/i*100}%,\n ${a} ${r/i*100}%,\n ${a} ${n/i*100}%,\n ${l} ${n/i*100}%,\n ${l} 100%\n )`;const u=`calc( ${r/i*100}% - ( 20px * ${r/i} ) - 1px )`,h=`calc( ${n/i*100}% - ( 20px * ${n/i} ) - 1px )`;this.isRTL?(this.fromDisplay.style.right=u,this.toDisplay.style.right=h):(this.fromDisplay.style.left=u,this.toDisplay.style.left=h),this.fromDisplay.innerHTML=t.value,this.toDisplay.innerHTML=e.value}setToggleAccessible(t){Number(t.value)<=0?this.toSlider.style.zIndex=2:this.toSlider.style.zIndex=0}}class g extends h{inputWrap;constructor(t,e){return super(t,e),this.inputWrap=this.root.querySelector(".kadence-filter-wrap"),this.type="rating",this.attachListeners(),this.prefill(),this}getValue(t=!1){if(this.inputWrap){const s=this.inputWrap.querySelectorAll("span[aria-pressed]");if(s.length>0){var e="";return s.forEach((function(t){const s=t.dataset.value?t.dataset.value:"";s&&(e=e?e+","+s:s)})),t?e:{[this.hash]:e}}}return t?"":{[this.hash]:""}}reset(){const t=this.inputWrap.querySelectorAll("span");t.length>0&&t.forEach((function(t){t.removeAttribute("aria-pressed"),t.classList.remove("pressed")}))}setValue(t){const e=t||[],s=this.inputWrap.querySelectorAll("span");s.length>0&&s.forEach((function(t){const s=t.dataset.value?t.dataset.value:"";e.includes(s)&&(t.setAttribute("aria-pressed","true"),t.classList.add("pressed")),t.classList.contains("kbp-ql-rating-single")&&t.dataset.value0&&void 0===window.kbp_listeners_attached&&(window.kbp_listeners_attached=!0,e.forEach((function(e){e.addEventListener("click",t.triggerButtonPress.bind(t)),e.classList.contains("kbp-ql-rating-single")&&(e.addEventListener("mouseover",t.hoverHighlight.bind(t)),e.addEventListener("mouseout",t.hoverOffHighlight.bind(t)))})))}}}class q extends h{button;constructor(t,e){return super(t,e),this.button=this.root.querySelector(".kb-query-filter-reset-button"),this.type="reset",this.attachListeners(),this}getValue(t=!1){return t?"":{}}reset(){return{}}setValue(t){return null}prefill(){return null}attachListeners(){this.button&&this.button.addEventListener("click",this.triggerReset.bind(this))}}class v extends h{input;constructor(t,e){return super(t,e),this.input=this.root.querySelector(".kb-filter-search"),this.button=this.root.querySelector(".kb-filter-search-btn"),this.isUnique=!1,this.type="search",this.attachListeners(),this.prefill(),this}getValue(t=!1){const e=this.queryBlock.rootID+"_search";return this.input&&"undefined"!=this.input.value&&""!=this.input.value?t?this.input.value:{[e]:this.input.value}:t?"":{[e]:""}}reset(){this.input.value=""}setValue(t){this.input.value=t}prefill(){const t=this.queryBlock.rootID+"_search";if(t){const e=window.location.search,s=new URLSearchParams(e);s.has(t)&&this.setValue(s.get(t))}}attachListeners(){const t=this;this.input&&(this.button.addEventListener("click",this.triggerUpdated.bind(t)),this.input.addEventListener("keyup",(function(e){"Enter"!==e.key&&13!==e.keyCode||t.triggerUpdated()})))}}class m extends h{input;constructor(t,e){return super(t,e),this.input=this.root.querySelector(".kb-sort"),this.isUnique=!1,this.type="sort",this.attachListeners(),this.prefill(),this}getValue(t=!1){const e=this.queryBlock.rootID+"_sort";return this.input&&"undefined"!=this.input.value&&""!=this.input.value?t?this.input.value:{[e]:this.input.value}:t?"":{[e]:""}}reset(){this.input.value=""}setValue(t){this.input.value=t}prefill(){const t=this.queryBlock.rootID+"_sort";if(t){const e=window.location.search,s=new URLSearchParams(e);s.has(t)&&this.setValue(s.get(t))}}attachListeners(){this.input&&this.input.addEventListener("change",this.triggerUpdated.bind(this))}}class b extends p{constructor(t,e){return super(t,e),this.type="woo-attribute",this}}class S{queryBlock;root;filters={};filterValues={};previousFilterValues={};lastSelectedFilterValue="";constructor(t){const e=this;this.queryBlock=t,this.root=t.root,this.initializeFilters(),this.compileFilterValuesAndSetQueryArgs(),window.addEventListener(n,this.runFilters.bind(e)),window.addEventListener(o,this.resetFilters.bind(e)),window.addEventListener("kb-query-filter-trigger",this.runFilters.bind(e))}replaceHtml(t){0!==Object.keys(t).length&&(Object.entries(t).forEach((t=>{const[e,s]=t;[...this.root.querySelectorAll("[data-uniqueid='"+e+"'] .filter-refresh-container")].forEach((t=>{t.innerHTML=s}))})),this.initializeFilters())}initializeFilters(){const t=this;this.root.querySelectorAll(".kadence-query-filter").forEach((function(e){if("uniqueid"in e.dataset){const s=e.dataset.uniqueid;e.classList.contains("wp-block-kadence-query-filter-date")?t.filters[s]=new f(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter")?t.filters[s]=new c(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-reset")?t.filters[s]=new q(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-sort")?t.filters[s]=new m(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-search")?t.filters[s]=new v(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-checkbox")?t.filters[s]=new p(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-woo-attribute")?t.filters[s]=new b(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-buttons")?t.filters[s]=new d(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-range")?t.filters[s]=new y(t.queryBlock,e):e.classList.contains("wp-block-kadence-query-filter-rating")&&(t.filters[s]=new g(t.queryBlock,e))}}))}setUrlParams(){const t=new URL(location.protocol+"//"+location.host+location.pathname),e=Object.keys(this.filterValues);for(let s=0;s{t?i.classList.remove("loading"):i.classList.add("loading")}),100*(e+1))}}async query(){this.startQuery();const t=this.root,e=this.queryArgs.ql_id,s={method:"GET",headers:{"X-WP-Nonce":kbp_query_loop_rest_endpoint.nonce}},i=t.querySelector("input[name='"+e+"_wp_query_hash']"),r=t.querySelector("input[name='"+e+"_wp_query_vars']");i&&r&&(s.method="POST",s.body=JSON.stringify({[this.queryArgs.ql_id+"_wp_query_hash"]:i.value,[this.queryArgs.ql_id+"_wp_query_vars"]:r.value}));try{const i=this.queryArgs,r=t.querySelector("input[name='"+e+"_query_exclude_post_id']"),n=t.querySelector("input[name='"+e+"_pll_slug']"),o=t.querySelector("input[name='"+e+"_random_seed']");r&&(i[this.queryArgs.ql_id+"_query_exclude_post_id"]=r.value),n&&(i.lang=n.value),o&&(i[this.queryArgs.ql_id+"_random_seed"]=o.value);const l=new URLSearchParams(i),a=kbp_query_loop_rest_endpoint.url+(kbp_query_loop_rest_endpoint.url.split("?")[1]?"&":"?")+l,u=await fetch(a,s);if(200==u.status){const t=await u.json();return this.queryResults=t,t}}finally{this.endQuery()}}startQuery(){}endQuery(){}initInfiniteScroll(){const t=this;if(this.infiniteScroll&&this.queryCardContainer){const e=document.createElement("div");e.classList.add("infinite-scroll-trigger"),this.queryCardContainer.insertAdjacentElement("beforeend",e);const s={threshold:1};new IntersectionObserver(this.infiniteScrollCallback.bind(t),s).observe(e)}}infiniteScrollCallback([{isIntersecting:e,target:s}]){e&&3==this.state&&this.queryArgs[t]{window.KBQueryBlocks=[];var t=document.querySelectorAll(".kadence-query-init");for(let s=0;s