import*as e from"@wordpress/interactivity";var t={438:e=>{e.exports=import("@wordpress/interactivity-router")}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const n=(i={getConfig:()=>e.getConfig,getContext:()=>e.getContext,getElement:()=>e.getElement,getServerContext:()=>e.getServerContext,store:()=>e.store},c={},o.d(c,i),c),a=e=>{if("string"!=typeof e)return"";const t=document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body.textContent||""};var i,c;function s(e,t){if(!e)return null;const r=window.getComputedStyle(e)[t];if(!("transparent"===r||r.startsWith("rgba(")&&0===parseFloat(r.split(",")[3]))){const e=r.match(/\d+/g);if(!e||e.length<3)return null;const[t,o,n]=e.slice(0,3);return`rgb(${t}, ${o}, ${n})`}return s(e.parentElement,t)}const{getContext:l,getElement:p,store:u,getServerContext:y,getConfig:v}=n,d="woocommerce/product-filters";function f(e){const t=e.ariaLabel??e.label;return"string"==typeof t&&t.length>0?t:e.value}const m={state:{get params(){const e={};function t(t,r){if(t in e&&e[t].length>0)return e[t]=`${e[t]},${r}`;e[t]=r}const r=v(d),o=r?.taxonomyParamsMap||{};return g.activeFilters.forEach(r=>{const{type:n,value:a}=r;if(a){if("price"===n){const[t,r]=a.split("|");t&&(e.min_price=t),r&&(e.max_price=r)}if("status"===n&&t("filter_stock_status",a),"rating"===n&&t("rating_filter",a),n.includes("attribute")){const[,o]=n.split("/");t(`filter_${o}`,a),e[`query_type_${o}`]=r.attributeQueryType||"or"}if(n.includes("taxonomy")){const[,e]=n.split("/");t(o[e],a)}}}),e},get activeFilters(){const{activeFilters:e}=l();return e.filter(e=>!!e.value).sort((e,t)=>e.activeLabel.toLowerCase().localeCompare(t.activeLabel.toLowerCase())).map(e=>({...e,activeLabel:a(e.activeLabel),uid:`${e.type}/${e.value}`}))},get selectableItems(){const e=(y?y():l()).items;return Array.isArray(e)?e.map(e=>({...e,selected:g.activeFilters.some(t=>t.type===e.type&&t.value===e.value)})):[]}},actions:{openOverlay:()=>{if(l().isOverlayOpened=!0,document.getElementById("wpadminbar")){const e=(document.documentElement||document.body.parentNode||document.body).scrollTop;document.body.style.setProperty("--adminbar-mobile-padding",`max(calc(var(--wp-admin--admin-bar--height) - ${e}px), 0px)`)}},closeOverlay:()=>{l().isOverlayOpened=!1},closeOverlayOnEscape:e=>{l().isOverlayOpened&&"Escape"===e.key&&b.closeOverlay()},removeActiveFiltersBy:e=>{const t=l();t.activeFilters=t.activeFilters.filter(t=>!e(t))},toggle:e=>{const t=l(),r=!e||e instanceof Event?t.item:e;r&&function(e){return"string"==typeof e.type&&e.type.length>0&&"string"==typeof e.value&&e.value.length>0}(r)&&(g.activeFilters.some(e=>e.type===r.type&&e.value===r.value)?function(e){b.removeActiveFiltersBy(t=>t.type===e.type&&t.value===e.value)}(r):function(e){const t=l(),r={value:e.value,type:e.type,activeLabel:t.activeLabelTemplate.replace("{{label}}",f(e))};e.attributeQueryType&&(r.attributeQueryType=e.attributeQueryType);const o=t.activeFilters.filter(e=>!(e.value===r.value&&e.type===r.type));o.push(r),t.activeFilters=o}(r),b.navigate())},*navigate(){const e=y?y():l(),t=v(d),r=new URL(t.canonicalUrl),{searchParams:n}=r;for(const t in e.params)n.delete(t);for(const e in g.params){const t=g.params[e];let r=t;try{r=decodeURIComponent(t)}catch(t){t instanceof URIError&&console.warn("woocommerce/product-filters: Failed to decode filter parameter",e,t)}n.set(e,r)}if(window.location.href===r.href)return;if("boolean"==typeof e.forcePageReload?e.forcePageReload:t?.forcePageReload)return void window.location.assign(r.href);const a=yield Promise.resolve().then(o.bind(o,438));yield a.actions.navigate(r.href)}},callbacks:{initColors:()=>{const e=p();if(!e.ref)return;const t=e.ref.style,r=t.getPropertyValue("--wc-product-filters-background-color"),o=t.getPropertyValue("--wc-product-filters-text-color");if(!r){const r=s(e.ref,"backgroundColor");r&&t.setProperty("--wc-product-filters-background-color",r)}if(!o){const r=s(e.ref,"color");r&&t.setProperty("--wc-product-filters-text-color",r)}},scrollLimit:()=>{const{isOverlayOpened:e}=l();document.body.style.overflow=e?"hidden":"auto"},syncActiveFiltersWithServer:()=>{if(!y)return;const e=l(),t=y();e.activeFilters=Array.isArray(t.activeFilters)?t.activeFilters.map(e=>({...e})):[]}}},{state:g,actions:b}=u(d,m);