var W=Object.defineProperty;var X=(z)=>z;function Y(z,j){this[z]=X.bind(null,j)}var $=(z,j)=>{for(var B in j)W(z,B,{get:j[B],enumerable:!0,configurable:!0,set:Y.bind(j,B)})};var A=(z,j)=>()=>(z&&(j=z(z=0)),j);import{useCallback as G,useMemo as I,useState as Z}from"react";var J={search:"",tags:[],stability:[],domain:[]};function D(z){let[j,B]=Z(J),K=G((x)=>{B((q)=>({...q,search:x}))},[]),N=G((x)=>{B((q)=>({...q,tags:q.tags.includes(x)?q.tags.filter((E)=>E!==x):[...q.tags,x]}))},[]),O=G((x)=>{B((q)=>({...q,stability:q.stability.includes(x)?q.stability.filter((E)=>E!==x):[...q.stability,x]}))},[]),Q=G((x)=>{B((q)=>({...q,domain:q.domain.includes(x)?q.domain.filter((E)=>E!==x):[...q.domain,x]}))},[]),R=G(()=>B(J),[]),U=I(()=>{return j.search.length>0||j.tags.length>0||j.stability.length>0||j.domain.length>0},[j]),V=I(()=>{return z.filter((x)=>{if(j.search){let q=j.search.toLowerCase();if(!((x.meta.title??"").toLowerCase().includes(q)||x.meta.description?.toLowerCase().includes(q)||x.meta.key.toLowerCase().includes(q)))return!1}if(j.tags.length>0){if(!j.tags.some((E)=>x.meta.tags?.includes(E)))return!1}if(j.stability.length>0){if(!j.stability.includes(x.meta.stability??"unknown"))return!1}if(j.domain.length>0){if(!j.domain.includes(x.meta.domain??"unknown"))return!1}return!0})},[z,j]);return{filters:j,setSearch:K,toggleTag:N,toggleStability:O,toggleDomain:Q,clearFilters:R,filteredFeatures:V,hasActiveFilters:U}}export{D as useFeatureFilters};
