import{defineProperty as o}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import e from"classnames";import t,{useRef as n,useEffect as i,useCallback as r,useMemo as s}from"react";import{Icon as l}from"@vibe/icon/mockedClassNames";import c from"../../../Tooltip/Tooltip.js";import a from"../../../../hooks/useIsOverflowing/useIsOverflowing.js";import{keyCodes as m}from"../../../../constants/keyCodes.js";import"../../../../constants/sizes.js";import{getOptionId as p}from"../../helpers.js";import{withStaticPropsWithoutForwardRef as f}from"../../../../types/withStaticProps.js";import"../../../../utils/colors-vars-map.js";import{ComboboxOptionIconType as u}from"../ComboboxConstants.js";import{getTestId as d,ComponentDefaultTestId as v}from"../../../../tests/testIds.js";import b from"./ComboboxOption.module.scss.js";var O=f((function(f){var u=f.index,O=f.option,h=f.className,y=f.isActive,g=f.visualFocus,j=f.scrollRef,C=f.scrollOffset,I=void 0===C?100:C,T=f.onOptionClick,E=f.onOptionLeave,k=f.onOptionHover,N=f.optionLineHeight,P=f.shouldScrollWhenActive,S=void 0===P||P,w=f.optionRenderer,x=void 0===w?null:w,L=O.id,H=O.leftIcon,R=O.leftIconType,z=O.rightIcon,A=O.rightIconType,B=O.label,F=O.iconSize,M=void 0===F?18:F,_=O.disabled,W=O.selected,D=O.ariaLabel,K=O.belongToCategory,V=void 0!==K&&K,X=O.tooltipContent,q=n(null),G=n(),J=a({ref:G});i((function(){var o,e=q.current;g&&e&&S&&((null==j?void 0:j.current)&&e?j.current.scrollTop=e.offsetTop-I:null===(o=null==e?void 0:e.scrollIntoView)||void 0===o||o.call(e,{behaviour:"smooth"}))}),[q,g,S,j,I,V]);var Q=function(o,n,i){return"renderer"===n?o(e(b.optionIcon,i)):t.createElement(l,{className:e(b.optionIcon,i),iconType:"font",icon:o,iconSize:M,ignoreFocusStyle:!0})},U=r((function(o){_||T(o,u,O,!0)}),[u,O,T,_]),Y=r((function(o){_||E(o,u,O,!0)}),[u,O,E,_]),Z=r((function(o){_||k(o,u,O,!0)}),[u,O,k,_]),$=r((function(o){o.key!==m.ENTER&&o.key!==m.SPACE||T(o,u,O,!1)}),[T,u,O]);X||(X=J?B:null);var oo=s((function(){return x&&x(O)}),[x,O]),eo=t.createElement(t.Fragment,null,H&&Q(H,R,b.left),t.createElement("div",{ref:G,className:e(b.optionLabel)},B),z&&Q(z,A,""));return t.createElement(c,Object.assign({},O.tooltipProps,{content:X,hideWhenReferenceHidden:!0}),t.createElement("div",{ref:q,key:L||B,"aria-level":V?2:1,"aria-selected":y,"aria-label":D||B,id:p(L,u),"data-testid":d(v.COMBOBOX_OPTION,u),onMouseEnter:Z,onClick:U,onKeyDown:$,onMouseLeave:Y,className:e(b.comboboxOption,h,o(o(o(o({},b.disabled,_),b.selected,W),b.active,y),b.activeOutline,g)),style:{height:N}},oo||eo))}),{iconTypes:u});export{O as default};
//# sourceMappingURL=ComboboxOption.js.map
