import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import a from"classnames";import o,{forwardRef as r,useRef as s,useCallback as t}from"react";import n from"../../hooks/useMergeRef.js";import{CloseSmall as i,Search as l}from"@vibe/icons";import{getTestId as c,ComponentDefaultTestId as m}from"../../tests/testIds.js";import d from"./Search.module.scss.js";import{BaseInput as u}from"@vibe/base/mockedClassNames";import p from"../../hooks/useDebounceEvent/index.js";import v from"../IconButton/IconButton.js";import{Icon as f}from"@vibe/icon/mockedClassNames";import{Loader as h}from"@vibe/loader/mockedClassNames";import{ComponentVibeId as C}from"../../tests/constants.js";var b=r((function(r,b){var N,E,R,I,g,x,y,A,j,S,k=r.searchIconName,B=void 0===k?l:k,w=r.clearIconName,z=void 0===w?i:w,F=r.clearIconLabel,H=void 0===F?"Clear":F,L=r.renderAction,_=r.hideRenderActionOnInput,D=r.value,P=r.placeholder,T=r.size,V=void 0===T?"medium":T,K=r.disabled,O=r.loading,M=r.autoFocus,U=r.autoComplete,W=void 0===U?"off":U,q=r.inputAriaLabel,G=r.debounceRate,J=void 0===G?400:G,Q=r.searchResultsContainerId,X=r.currentAriaResultId,Y=r.onChange,Z=r.onFocus,$=r.onBlur,ee=r.onClear,ae=r.onKeyDown,oe=r.className,re=r.ariaExpanded,se=r.ariaHasPopup,te=r.showClearIcon,ne=void 0===te||te,ie=r.id,le=r["data-testid"];return N=s(null),E=n(b,N),R=p({delay:J,onChange:Y,initialStateValue:D}),I=R.inputValue,g=R.onEventChanged,y=t((function(){var e,a;K||(null===(a=null===(e=N.current)||void 0===e?void 0:e.focus)||void 0===a||a.call(e),x(),null==ee||ee())}),[K,x=R.clearValue,ee]),A=o.createElement(f,{icon:B,className:d.icon,iconType:"font",iconSize:"small"===V?"16px":"20px"}),j=o.createElement(v,{className:a(d.icon,e({},d.empty,!I)),icon:z,ariaLabel:H,onClick:y,size:"small"===V?"xs":"small","data-testid":c(m.CLEAN_SEARCH_BUTTON,ie)}),S=o.createElement(o.Fragment,null,O&&o.createElement(h,{size:"small"===V?"xs":20,color:"secondary",wrapperClassName:a(e({},d.loader,!I&&!L))}),ne&&I&&!K&&j,!(_&&I)&&L),o.createElement(u,{ref:E,id:ie,type:"search","data-testid":le||c(m.SEARCH,ie),"data-vibe":C.SEARCH,className:a(d.searchWrapper,oe),inputClassName:d.search,value:I,renderLeft:A,renderRight:S,autoFocus:M,placeholder:P,disabled:K,onChange:g,onBlur:$,onFocus:Z,onKeyDown:ae,autoComplete:W,size:V,wrapperRole:"search",inputRole:Q?"combobox":void 0,"aria-label":q,"aria-busy":O,"aria-controls":re?Q:void 0,"aria-activedescendant":X,"aria-haspopup":se,"aria-expanded":re})}));export{b as default};
//# sourceMappingURL=Search.js.map
