import*as t from"@wordpress/interactivity";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};e.d(r,{H:()=>g});const o=(n={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},s={},e.d(s,n),s);var n,s;function i(t,e){if(!t)return null;const r=window.getComputedStyle(t)[e];if(!("transparent"===r||r.startsWith("rgba(")&&0===parseFloat(r.split(",")[3]))){const t=r.match(/\d+/g);if(!t||t.length<3)return null;const[e,o,n]=t.slice(0,3);return`rgb(${e}, ${o}, ${n})`}return i(t.parentElement,e)}const c="--wc-product-filter-chips-background",a="--wc-product-filter-chips-text";function l(t){if(t)return(0,o.store)(t)}function u(){return(0,o.getContext)().item}function p(t,e){return(t.style.getPropertyValue(e)||window.getComputedStyle(t).getPropertyValue(e)).trim()}const{state:g}=(0,o.store)("woocommerce/product-filter-chips",{state:{get items(){const{storeNamespace:t,isExpanded:e,displayLimit:r}=(0,o.getContext)(),n=l(t)?.state?.selectableItems;if(!Array.isArray(n))return[];const s=function(t){const e=Number(t);return!Number.isFinite(e)||e<0?15:Math.floor(e)}(r);return n.map((t,r)=>({...t,index:r,hidden:t.hidden||!e&&!t.selected&&r>=s}))},get swatchHidden(){const t=u();return e=t?.visual,!e||"none"===e.type||!e.value;var e},get swatchStyle(){const t=u();return r=t?.visual,r&&"none"!==r.type&&r.value?"image"===r.type?`background-image: url('${e=r.value,e.split("'").join("%27")}');`:`background-color: ${r.value};`:"";var e,r}},actions:{toggle(){const t=u();if(!t)return;const{storeNamespace:e}=(0,o.getContext)();l(e)?.actions?.toggle?.(t)},showAll(){(0,o.getContext)().isExpanded=!0}},callbacks:{initColors:()=>{const t=(0,o.getElement)();t.ref&&function(t){const e=t.style;if(!p(t,c)){const r=i(t,"backgroundColor");r&&e.setProperty(c,r)}if(!p(t,a)){const r=i(t,"color");r&&e.setProperty(a,r)}}(t.ref)}}},{lock:!0});var d=r.H;export{d as chipsState};