import{d as O,G as k,H as r,u as t,J as l,a2 as f,c as u,K as g,bv as j,a4 as d,g as _,e as n,Q as p,al as w,F as y,O as F,r as z,b as o}from"./lucide-C_a_D9Y7.js";import{_ as x}from"./index-BbNFn9nN.js";import{_ as A}from"./index-CT6dMj3N.js";import{_ as D}from"./Checkbox.vue_vue_type_script_setup_true_lang-BjHbz0k8.js";import{_ as E}from"./Input.vue_vue_type_script_setup_true_lang-Dpoevnuc.js";import{_ as G,a as H,b as I}from"./PopoverTrigger.vue_vue_type_script_setup_true_lang-8c85XsX-.js";import{_ as J}from"./Separator.vue_vue_type_script_setup_true_lang-BpPizB7w.js";import{_ as K}from"./index-Cc0s9xHj.js";const M={class:"hidden space-x-1 lg:flex"},P=["onClick"],Q={class:"faceted-filter-content"},T={class:"faceted-filter-list"},U=["onClick"],X=O({__name:"FacetedFilter",props:{title:{},options:{},modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:["update:modelValue"],setup(v,{emit:S}){const m=v,h=S,b=z(""),c=_(()=>new Set(m.modelValue||[])),i=_(()=>c.value.size),B=_(()=>m.options.filter(s=>c.value.has(s.value))),L=_(()=>{const s=b.value.toLowerCase().trim();return s?m.options.filter(a=>a.label.toLowerCase().includes(s)):m.options}),C=s=>{const a=new Set(c.value);a.has(s)?a.delete(s):a.add(s),h("update:modelValue",Array.from(a))},N=s=>{const a=new Set(c.value);a.delete(s),h("update:modelValue",Array.from(a))},V=()=>{h("update:modelValue",[])};return(s,a)=>(o(),k(t(G),null,{default:r(()=>[l(t(H),{"as-child":""},{default:r(()=>[l(t(A),{variant:"outline",class:"border-dashed"},{default:r(()=>[l(t(j),{class:"h-4 w-4"}),f(" "+d(v.title)+" ",1),i.value>0?(o(),u(y,{key:0},[l(t(J),{orientation:"vertical",class:"mx-2 h-4"}),l(t(x),{class:"lg:hidden font-medium rounded-[6px]"},{default:r(()=>[f(d(i.value),1)]),_:1}),n("div",M,[i.value>2?(o(),k(t(x),{key:0,class:"rounded-[6px] gap-2"},{default:r(()=>[f(d(i.value)+" selected ",1),n("button",{type:"button",class:"flex items-center justify-center cursor-pointer hover:opacity-70",onClick:p(V,["stop"])},[l(t(w),{class:"size-2.5"})])]),_:1})):(o(!0),u(y,{key:1},F(B.value,e=>(o(),k(t(x),{key:e.value,class:"font-medium rounded-[6px] gap-2"},{default:r(()=>[f(d(e.label)+" ",1),n("button",{type:"button",class:"flex items-center justify-center cursor-pointer hover:opacity-70",onClick:p($=>N(e.value),["stop"])},[l(t(w),{class:"size-2.5"})],8,P)]),_:2},1024))),128))])],64)):g("",!0)]),_:1})]),_:1}),l(t(I),{class:"w-[220px] p-0",align:"start"},{default:r(()=>[n("div",Q,[l(t(E),{modelValue:b.value,"onUpdate:modelValue":a[0]||(a[0]=e=>b.value=e),placeholder:v.title,class:"mb-2 h-8"},null,8,["modelValue","placeholder"]),n("div",T,[(o(!0),u(y,null,F(L.value,e=>(o(),u("label",{key:`${e.value}-${c.value.has(e.value)}`,class:"faceted-filter-item"},[l(t(D),{checked:c.value.has(e.value),"default-value":c.value.has(e.value),class:"mr-2",onClick:p($=>C(e.value),["stop"])},null,8,["checked","default-value","onClick"]),n("span",{class:"truncate cursor-pointer",onClick:p($=>C(e.value),["stop"])},d(e.label),9,U)]))),128))]),i.value>0?(o(),u("button",{key:0,type:"button",class:"faceted-filter-clear",onClick:V}," Clear filters ")):g("",!0)])]),_:1})]),_:1}))}}),se=K(X,[["__scopeId","data-v-4ebcab1d"]]);export{se as F};
