'use client';'use strict';

var chunkIFXORR66_cjs = require('./chunk-IFXORR66.cjs');
var chunk4IQP4J4C_cjs = require('./chunk-4IQP4J4C.cjs');
var s = require('@radix-ui/react-popover');
var icons = require('@onbeam/icons');
var css = require('@onbeam/styled-system/css');
var utils = require('@onbeam/utils');
var cmdk = require('cmdk');
var recipes = require('@onbeam/styled-system/recipes');
var react = require('react');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
	if (e && e.__esModule) return e;
	var n = Object.create(null);
	if (e) {
		Object.keys(e).forEach(function (k) {
			if (k !== 'default') {
				var d = Object.getOwnPropertyDescriptor(e, k);
				Object.defineProperty(n, k, d.get ? d : {
					enumerable: true,
					get: function () { return e[k]; }
				});
			}
		});
	}
	n.default = e;
	return Object.freeze(n);
}

var s__namespace = /*#__PURE__*/_interopNamespace(s);

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}=utils.useDisclosure(!1),o=recipes.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 jsxRuntime.jsxs(s__namespace.Root,{open:d,onOpenChange:B,children:[jsxRuntime.jsxs("label",{className:css.cx(o.root,P),children:[I,jsxRuntime.jsx(s__namespace.Trigger,{asChild:!0,children:jsxRuntime.jsxs("button",{ref:F,type:"button",role:"combobox","aria-controls":"combobox-list","aria-expanded":d,className:css.cx(o.button,y),"data-error":D,disabled:p,"aria-disabled":p,...k,children:[c?.image&&jsxRuntime.jsx("div",{className:o.image,children:c?.image}),jsxRuntime.jsx("span",{className:o.name,children:c?.name||T}),jsxRuntime.jsx(icons.DownIcon,{"data-open":d,"data-disabled":p,className:o.chevron})]})}),u]}),jsxRuntime.jsx(s__namespace.Content,{sideOffset:4,align:"start",side:"bottom",className:o.popover,id:"combobox-list",children:jsxRuntime.jsxs(cmdk.Command,{filter:M,shouldFilter:!l,className:css.cx(recipes.gridBackground(),recipes.noiseBackground()),children:[jsxRuntime.jsx("div",{className:o.input,"data-hidden":l,children:jsxRuntime.jsx(cmdk.Command.Input,{placeholder:R,asChild:!0,children:jsxRuntime.jsx(chunk4IQP4J4C_cjs.a,{"aria-disabled":l})})}),jsxRuntime.jsxs(cmdk.Command.List,{className:o.list,children:[jsxRuntime.jsx(cmdk.Command.Empty,{className:o.emptyMessage,children:E}),i.map((a,b)=>jsxRuntime.jsxs(cmdk.Command.Item,{className:o.row,value:a.value,onSelect:r=>{w?.(r===n?"":r),O();},children:[v?v(a,a.value===n):jsxRuntime.jsxs("div",{className:o.rowContent,children:[a.image&&jsxRuntime.jsx("div",{className:o.image,children:a.image}),jsxRuntime.jsx("span",{className:o.name,children:a.name}),a.value===n&&jsxRuntime.jsx(icons.SuccessIcon,{height:16,width:16,className:o.selectedIcon})]}),b!==i.length-1&&jsxRuntime.jsx(chunkIFXORR66_cjs.a,{})]},a.value))]})]})})]})},Q=react.forwardRef(K);

exports.a = Q;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-W4S2LQ7X.cjs.map