import{as as K,cg as H,cj as z,j as t,ci as J,cr as T,aw as $,ag as q,J as G}from"./main-TIUJvpaR.js";import{C as Q}from"./select-T49HzTXy.js";function U(s,f){var m;const{children:W,items:X,isAsync:Y,isLoading:l,isPending:C,isFetching:b,openMenuOnFocus:g=!0,endAdornmentIcon:h,onItemSelected:Z,maxItems:_,clearInputOnItemSelection:I,inputValue:ee,selectedValue:ne,onSelectionChange:te,allowCustomValue:v=!1,onInputValueChange:oe,defaultInputValue:ae,selectionMode:O="single",useOptionLabelAsInputValue:F,showEmptyMessage:se,floatingMaxHeight:L,hideEndAdornment:V=!1,blurReferenceOnItemSelection:w,clearSelectionOnInputClear:le,isOpen:ie,onOpenChange:re,prependListbox:A,listboxClassName:j,contentClassName:N,searchFieldClassName:S,onEndAdornmentClick:i,autoFocusFirstItem:ce=!0,focusLoopingMode:ue,...r}=s,o=H({...s,floatingMaxHeight:L,blurReferenceOnItemSelection:w,selectionMode:O,role:"listbox",virtualFocus:!0,clearSelectionOnInputClear:!0},f),{reference:y,listboxId:E,onInputChange:P,state:{isOpen:n,setIsOpen:c,inputValue:R,setInputValue:D,selectValues:u,selectedValues:a,setActiveCollection:M},collection:k}=o,d=a[0]?(m=k.get(a[0]))==null?void 0:m.textLabel:void 0,{handleListboxSearchFieldKeydown:B}=z(o),p=q(e=>{g&&!n&&c(!0),e.target.select()});return t.jsx(J,{prepend:A,className:j,contentClassName:N,listbox:o,mobileOverlay:T,isLoading:l,isPending:C,onPointerDown:e=>{e.preventDefault()},children:t.jsx($,{inputRef:y,className:S,...r,endAdornment:V?null:t.jsx(G,{size:"md",tabIndex:-1,disabled:r.disabled,className:"pointer-events-auto",onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),i?i():(M("all"),c(!n))},children:t.jsx(Q,{isLoading:l||b,icon:h})}),"aria-expanded":n?"true":"false","aria-haspopup":"listbox","aria-controls":n?E:void 0,"aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:"false",onChange:P,value:F&&d?d:R,onBlur:e=>{if(v)u(e.target.value);else if(!I){const x=a[0];D(u.length&&x!=null?`${x}`:"")}},onFocus:p,onClick:p,onKeyDown:e=>B(e)})})}const me=K.forwardRef(U);export{me as C};
