"use client"
import{c as x}from"./chunk-IE3AOWCW.mjs";import{a as f}from"./chunk-2GR7LSEE.mjs";import{g as b,j as u}from"./chunk-HIGE3J6C.mjs";import{AnimatePresence as C,motion as h}from"framer-motion";import{X as L}from"lucide-react";import{isValidElement as A}from"react";import{Fragment as O,jsx as t,jsxs as i}from"react/jsx-runtime";function K({filters:l,activeFilters:n,onRemove:N,onRemoveAll:d,className:v}){return x("esc",d,{priority:1}),t(f,{height:!0,className:"w-full",transition:{type:"tween",duration:.3},children:i("div",{className:u("flex w-full flex-wrap items-start gap-4 sm:flex-nowrap",v),children:[t("div",{className:"flex grow flex-wrap gap-x-4 gap-y-2",children:t(C,{children:n==null?void 0:n.map(({key:a,value:s})=>{if(a==="loader")return t(h.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"h-9 w-48 animate-pulse rounded-md border border-gray-200 bg-white"},`loader-${s}`);let e=l.find(r=>r.key===a);if(!e)throw new Error("Filter.List received an activeFilter without a corresponding filter");return(e.multiple&&Array.isArray(s)?s:[s]).map(r=>{var c,y,g;let o=(c=e.options)==null?void 0:c.find(p=>typeof p.value=="string"&&typeof r=="string"?p.value.toLowerCase()===r.toLowerCase():p.value===r),m=(o==null?void 0:o.icon)??((y=e.getOptionIcon)==null?void 0:y.call(e,r,{key:e.key,option:o}))??e.icon,k=(o==null?void 0:o.label)??((g=e.getOptionLabel)==null?void 0:g.call(e,r,{key:e.key,option:o}))??r;return i(h.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"flex items-center divide-x rounded-md border border-gray-200 bg-white text-sm text-black",children:[i("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[t("span",{className:"shrink-0 text-gray-600",children:w(e.icon)?e.icon:t(e.icon,{className:"h-4 w-4"})}),e.label]}),t("div",{className:"px-3 py-2 text-gray-500",children:"is"}),t("div",{className:"flex items-center gap-2.5 px-3 py-2",children:e.options?i(O,{children:[t("span",{className:"shrink-0 text-gray-600",children:w(m)?m:t(m,{className:"h-4 w-4"})}),b(k,30)]}):t("div",{className:"h-5 w-12 animate-pulse rounded-md bg-gray-200"})}),t("button",{type:"button",className:"h-full rounded-r-md p-2 text-gray-500 ring-inset ring-gray-500 hover:bg-gray-100 hover:text-gray-800 focus:outline-none focus-visible:ring-1",onClick:()=>N(a,r),children:t(L,{className:"h-3.5 w-3.5"})})]},a)})})})}),(n==null?void 0:n.length)!==0&&i("button",{type:"button",className:"mt-px whitespace-nowrap rounded-lg border border-transparent px-3 py-2 text-sm text-gray-500 ring-inset ring-gray-500 transition-colors hover:border-gray-200 hover:bg-white hover:text-black focus:outline-none",onClick:d,children:["Clear Filters",t("kbd",{className:"ml-1.5 inline-block rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono text-[10px] leading-none text-gray-500",children:"ESC"})]})]})})}var w=l=>A(l);export{K as a};
