"use client"
import{b}from"./chunk-RZFRMYKW.mjs";import{d as g,i as u}from"./chunk-S3YYTHI7.mjs";import{AnimatePresence as k,motion as x}from"framer-motion";import{X as L}from"lucide-react";import{isValidElement as A}from"react";import{Fragment as C,jsx as t,jsxs as s}from"react/jsx-runtime";function I({filters:l,activeFilters:i,onRemove:h,onRemoveAll:w,className:v}){return t(b,{height:!0,className:"w-full",transition:{type:"tween",duration:.3},children:s("div",{className:(void 0)("flex w-full flex-wrap items-start gap-4 sm:flex-nowrap sm:items-center",v),children:[t("div",{className:"flex grow flex-wrap gap-x-4 gap-y-2",children:t(k,{children:i==null?void 0:i.map(({key:o,value:a})=>{if(o==="loader")return t(x.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-${a}`);let e=l.find(r=>r.key===o);if(!e)throw new Error("Filter.List received an activeFilter without a corresponding filter");return(e.multiple&&Array.isArray(a)?a:[a]).map(r=>{var d,c,y;let n=(d=e.options)==null?void 0:d.find(p=>typeof p.value=="string"&&typeof r=="string"?p.value.toLowerCase()===r.toLowerCase():p.value===r),m=(n==null?void 0:n.icon)??((c=e.getOptionIcon)==null?void 0:c.call(e,r,{key:e.key,option:n}))??e.icon,N=(n==null?void 0:n.label)??((y=e.getOptionLabel)==null?void 0:y.call(e,r,{key:e.key,option:n}))??r;return s(x.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:[s("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[t("span",{className:"shrink-0 text-gray-600",children:f(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?s(C,{children:[t("span",{className:"shrink-0 text-gray-600",children:f(m)?m:t(m,{className:"h-4 w-4"})}),(void 0)(N,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:()=>h(o,r),children:t(L,{className:"h-3.5 w-3.5"})})]},o)})})})}),(i==null?void 0:i.length)!==0&&t("button",{type:"button",className:"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:w,children:"Clear Filters"})]})})}var f=l=>A(l);export{I as a};
