'use client';import { a as a$1 } from './chunk-37TUZSO4.js';
import { a } from './chunk-UKJSEI2I.js';
import * as s from '@radix-ui/react-popover';
import { DownIcon, SuccessIcon } from '@onbeam/icons';
import { cx } from '@onbeam/styled-system/css';
import { useDisclosure } from '@onbeam/utils';
import { Command } from 'cmdk';
import { combobox, gridBackground, noiseBackground } from '@onbeam/styled-system/recipes';
import { forwardRef } from 'react';
import { jsxs, jsx } from 'react/jsx-runtime';

var K=({label:I,hasError:h=!1,errorMessage:u,className:P,inputClassName:y,value:n,onChange:w,placeholder:T,searchPlaceholder:R,items:i,emptyMessage:E,disabled:p,disableSearch:l,searchKeys:L=["name","value"],renderItem:v,...k},F)=>{let{isOpen:d,onClose:O,setOpen:B}=useDisclosure(!1),o=combobox(),c=i.find(a=>a.value===n),D=!!u||h,M=(a,b)=>{let r=i.find(f=>f.value===a);if(!r)return 0;let x=!1;for(let f of L)r[f]?.toString().toLowerCase().includes(b.toLowerCase())&&(x=!0);return Number(x)};return jsxs(s.Root,{open:d,onOpenChange:B,children:[jsxs("label",{className:cx(o.root,P),children:[I,jsx(s.Trigger,{asChild:!0,children:jsxs("button",{ref:F,type:"button",role:"combobox","aria-controls":"combobox-list","aria-expanded":d,className:cx(o.button,y),"data-error":D,disabled:p,"aria-disabled":p,...k,children:[c?.image&&jsx("div",{className:o.image,children:c?.image}),jsx("span",{className:o.name,children:c?.name||T}),jsx(DownIcon,{"data-open":d,"data-disabled":p,className:o.chevron})]})}),u]}),jsx(s.Content,{sideOffset:4,align:"start",side:"bottom",className:o.popover,id:"combobox-list",children:jsxs(Command,{filter:M,shouldFilter:!l,className:cx(gridBackground(),noiseBackground()),children:[jsx("div",{className:o.input,"data-hidden":l,children:jsx(Command.Input,{placeholder:R,asChild:!0,children:jsx(a,{"aria-disabled":l})})}),jsxs(Command.List,{className:o.list,children:[jsx(Command.Empty,{className:o.emptyMessage,children:E}),i.map((a,b)=>jsxs(Command.Item,{className:o.row,value:a.value,onSelect:r=>{w?.(r===n?"":r),O();},children:[v?v(a,a.value===n):jsxs("div",{className:o.rowContent,children:[a.image&&jsx("div",{className:o.image,children:a.image}),jsx("span",{className:o.name,children:a.name}),a.value===n&&jsx(SuccessIcon,{height:16,width:16,className:o.selectedIcon})]}),b!==i.length-1&&jsx(a$1,{})]},a.value))]})]})})]})},Q=forwardRef(K);

export { Q as a };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-7PXDUZJZ.js.map