import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{$ as t}from"./vendor-charts-iXlq6Rne.js";import{_ as n}from"./vendor-flow-IzlrcDx6.js";import{Sn as r,jn as i,rn as a}from"./index-HkVQGc9M.js";var o=e(t(),1),s=n();function c({label:e,options:t,value:n,onChange:c,emptyHint:l=`Nothing to choose from yet.`,maxHeight:u=`max-h-44`}){let[d,f]=(0,o.useState)(``),p=(0,o.useMemo)(()=>{let e=d.trim().toLowerCase();return e?t.filter(t=>t.label.toLowerCase().includes(e)||t.hint?.toLowerCase().includes(e)):t},[t,d]),m=(0,o.useMemo)(()=>n.map(e=>t.find(t=>t.value===e)).filter(Boolean),[n,t]),h=e=>c(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between`,children:[(0,s.jsx)(`label`,{className:`text-sm font-medium text-[var(--color-text-primary)]`,children:e}),n.length>0&&(0,s.jsxs)(`button`,{type:`button`,onClick:()=>c([]),className:`text-[11.5px] font-medium text-[var(--color-text-muted)] transition-colors hover:text-[var(--color-error)]`,children:[`Clear `,n.length]})]}),(0,s.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-[var(--color-border)]`,children:[m.length>0&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1 border-b border-[var(--color-border)] bg-[var(--color-background)] p-2`,children:m.map(e=>(0,s.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-[var(--color-accent-soft)] py-0.5 pl-2 pr-1 text-[11.5px] font-medium text-[var(--color-accent-ink)]`,children:[e.label,(0,s.jsx)(`button`,{type:`button`,onClick:()=>h(e.value),"aria-label":`Remove ${e.label}`,children:(0,s.jsx)(r,{className:`h-3 w-3`})})]},e.value))}),(0,s.jsxs)(`div`,{className:`relative border-b border-[var(--color-border)]`,children:[(0,s.jsx)(i,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--color-text-muted)]`}),(0,s.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`Filter…`,className:`h-9 w-full bg-transparent pl-8 pr-3 text-[12.5px] text-[var(--color-text-primary)] outline-none placeholder:text-[var(--color-text-muted)]`})]}),(0,s.jsx)(`div`,{className:a(`overflow-y-auto`,u),children:t.length===0?(0,s.jsx)(`p`,{className:`px-3 py-4 text-center text-[12px] text-[var(--color-text-muted)]`,children:l}):p.length===0?(0,s.jsxs)(`p`,{className:`px-3 py-4 text-center text-[12px] text-[var(--color-text-muted)]`,children:[`No match for “`,d,`”.`]}):p.map(e=>(0,s.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5 px-3 py-1.5 transition-colors hover:bg-[var(--color-background)]`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:n.includes(e.value),onChange:()=>h(e.value),className:`h-3.5 w-3.5 rounded border-[var(--color-border)] accent-[var(--color-accent)]`}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-[var(--color-text-primary)]`,children:e.label}),e.hint&&(0,s.jsx)(`span`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:e.hint})]},e.value))})]})]})}export{c as t};