"use client"
import{a as u}from"./chunk-H4UN7NPI.mjs";import{AnimatePresence as N,motion as b}from"framer-motion";import{X as k}from"lucide-react";import{isValidElement as L}from"react";import{Fragment as A,jsx as t,jsxs as s}from"react/jsx-runtime";function z({filters:m,activeFilters:i,onRemove:f,onRemoveAll:h,className:w}){return t(u,{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",w),children:[t("div",{className:"flex grow flex-wrap gap-x-4 gap-y-2",children:t(N,{children:i==null?void 0:i.map(({key:o,value:a})=>{if(o==="loader")return t(b.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=m.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 c,y,g;let n=(c=e.options)==null?void 0:c.find(d=>typeof d.value=="string"&&typeof r=="string"?d.value.toLowerCase()===r.toLowerCase():d.value===r),p=(n==null?void 0:n.icon)??((y=e.getOptionIcon)==null?void 0:y.call(e,r,{key:e.key,option:n}))??e.icon,v=(n==null?void 0:n.label)??((g=e.getOptionLabel)==null?void 0:g.call(e,r,{key:e.key,option:n}))??r;return s(b.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:x(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(A,{children:[t("span",{className:"shrink-0 text-gray-600",children:x(p)?p:t(p,{className:"h-4 w-4"})}),(void 0)(v,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:()=>f(o,r),children:t(k,{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:h,children:"Clear Filters"})]})})}var x=m=>L(m);export{z as a};
