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 l(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 l(e.parentElement,t)}const{getContext:s,getElement:p,store:u,getServerContext:y,getConfig:d}=n,f="woocommerce/product-filters";function v(e){const t=e.ariaLabel??e.label;return"string"==typeof t&&t.length>0?t:e.value}const m={state:{get params(){const{activeFilters:e}=s(),t={};function r(e,r){if(e in t&&t[e].length>0)return t[e]=`${t[e]},${r}`;t[e]=r}const o=d(f),n=o?.taxonomyParamsMap||{};return e.forEach(e=>{const{type:o,value:a}=e;if(a){if("price"===o){const[e,r]=a.split("|");e&&(t.min_price=e),r&&(t.max_price=r)}if("status"===o&&r("filter_stock_status",a),"rating"===o&&r("rating_filter",a),o.includes("attribute")){const[,n]=o.split("/");r(`filter_${n}`,a),t[`query_type_${n}`]=e.attributeQueryType||"or"}if(o.includes("taxonomy")){const[,e]=o.split("/");r(n[e],a)}}}),t},get activeFilters(){const{activeFilters:e}=s();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():s()).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(s().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:()=>{s().isOverlayOpened=!1},closeOverlayOnEscape:e=>{s().isOverlayOpened&&"Escape"===e.key&&b.closeOverlay()},removeActiveFiltersBy:e=>{const t=s();t.activeFilters=t.activeFilters.filter(t=>!e(t))},toggle:e=>{const t=s(),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)&&(t.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=s(),r={value:e.value,type:e.type,activeLabel:t.activeLabelTemplate.replace("{{label}}",v(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():s(),t=d(f),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=l(e.ref,"backgroundColor");r&&t.setProperty("--wc-product-filters-background-color",r)}if(!o){const r=l(e.ref,"color");r&&t.setProperty("--wc-product-filters-text-color",r)}},scrollLimit:()=>{const{isOverlayOpened:e}=s();document.body.style.overflow=e?"hidden":"auto"}}},{state:g,actions:b}=u(f,m);