Joomla=window.Joomla||{};((e,y)=>{function u(e,t){const o=t.size?`?${t.toString()}`:"";return`${e.pathname}${o}`}function l(t){let e=t.target.closest("[data-easystore-filter-by]")?.dataset["easystoreFilterBy"]??"";if(!e){const o={"[easystore-filter-range]":["filter_min_price","filter_max_price"],"[easystore-filter-sort]":["filter_sortby"]};const s=Object.keys(o).find(e=>t.target.closest(e));e=s?o[s].join(","):""}return e}const t=e=>{e.preventDefault();const t=e.target.closest(".easystore-product-filter");const o=new URL(window.location);const s=new URLSearchParams(window.location.search);const n=e.target.closest("[easystore-sort-by]");if(n){const r=e.target.value;const a=e.target.name;s.set(a,r);window.location.href=u(o,s);return}if(t){const c=e.target.closest("[data-easystore-filter-by]");if(c){const i=c.dataset["easystoreFilterBy"];const l=y.querySelectorAll(`[data-easystore-filter-by="${i}"]`);const f=[];l.forEach(e=>{const t=e.querySelectorAll('input[type="checkbox"]:checked');const o=e.querySelectorAll('input[type="radio"]:checked');if(t.length){f.push(...t)}if(o.length){f.push(...o)}});if(f.length){const d=[...f].reduce((e,t)=>[...e,t.value],[]).join(",");s.set(i,d)}else{s.delete(i)}window.location.href=u(o,s);return}}};const f=(e,r,a,c)=>{const i=e?.parentElement?.nextElementSibling;if(!i)return;["checkbox","radio"].forEach(e=>{const t=i.querySelectorAll(`input[type="${e}"]:checked`);if(!t.length)return;const o=c.searchParams.get(r)?.split(",")||[];const s=new Set([...t].map(e=>e.value));const n=o.filter(e=>!s.has(e));if(n.length){a.set(r,n.join(","))}else{a.delete(r)}})};const o=e=>{const t=e.target.closest("[easystore-filter-reset]");const o=l(e);if(t&&o){const r=new URL(window.location);const a=new URLSearchParams(window.location.search);o.split(",").forEach(e=>{if(e==="filter_variants"){f(t,e,a,r)}else{a.delete(e)}});window.location.href=u(r,a);return}const s=e.target.closest(".easystore-filter-title-wrapper");const n=s?.querySelector(".easystore-svg");if(s&&n){const c=s?.parentElement?.nextElementSibling;if(c){const i=c.style.display==="none";if(i){c.style.display="";n.style.transform=""}else{c.style.display="none";n.style.transform="rotate(-90deg)"}}}};const s=()=>{function o(e){const t=e.querySelector("[easystore-filter-reset]");t.style.display="block"}const e=new URLSearchParams(window.location.search);const s=[...e.keys()];for(let t of s){if(t==="filter_variants"||t==="filter_tags"){const n=e.get(t).split(",");for(let e of n){const r=y.querySelector(`input[name="${t}[]"][value="${e}"]`)||y.querySelector(`input[name="${t}"][value="${e}"]`);if(r){const a=r.closest(".easystore-product-filter");if(a){o(a)}}}}else{const c={filter_min_price:"[easystore-filter-range]",filter_max_price:"[easystore-filter-range]"};const i=c[t]??`[data-easystore-filter-by="${t}"]`;const a=y.querySelector(i);if(a){o(a)}}}};const n=()=>{y.addEventListener("change",t);y.addEventListener("click",o);window.addEventListener("load",s)};y.addEventListener("DOMContentLoaded",n)})(Joomla,document);function completeImageLoading(e){let t=e.closest("[easystore-thumbnail-wrapper]");let o=t.querySelector(".easystore-thumb-skeleton");if(o){o.remove()}}Joomla.imageLazyLoading=function(){const e=[...document.querySelectorAll("[easystore-thumbnail-wrapper] [loading=lazy]")];if(!("IntersectionObserver"in window)){e.forEach(e=>{const t=e.getAttribute("data-src");e.src=t;completeImageLoading(e)});return}const t=new IntersectionObserver((e,s)=>{e.forEach(e=>{if(e.isIntersecting){const t=e.target;const o=t.getAttribute("data-src");t.src=o;t.addEventListener("load",()=>{completeImageLoading(t)});s.unobserve(t)}})});e.forEach(e=>{t.observe(e)})};document.addEventListener("DOMContentLoaded",()=>{Joomla.imageLazyLoading()});