import e,{useCallback as t}from"react";import o from"../../hooks/useKeyEvent/index.js";import r from"../Avatar/Avatar.js";import i from"./AvatarGroupCounterTooltipContent.module.scss.js";import n from"../../hooks/useEventListener/index.js";import a from"../../hooks/useListenFocusTriggers/index.js";import{AVATAR_GROUP_COUNTER_TOOLTIP_SHOW_DELAY as l,AVATAR_GROUP_COUNTER_AVATAR_SIZE as s}from"./AvatarGroupConstants.js";import{keyCodes as c}from"../../constants/keyCodes.js";import"../../constants/sizes.js";import u from"../../../components/clickable/dist/Clickable/ClickableWrapper.js";import f from"../../../components/layout/dist/Flex/Flex.js";var m=[c.TAB],d=[c.ESCAPE];function p(e){var r=e.counterContainerRef,i=void 0===r?void 0:r,s=e.tooltipContentContainerRef,c=e.focusPrevPlaceholderRef,u=e.focusNextPlaceholderRef,f=e.isKeyboardTooltipVisible,p=e.setIsKeyboardTooltipVisible,v=t((function(){f||setTimeout((function(){return p(!0)}),l)}),[f,p]),b=t((function(){f&&p(!1)}),[f,p]);a({ref:i,onFocusByKeyboard:v}),n({eventName:"blur",ref:s,callback:b}),o({keys:m,ref:i,withoutAnyModifier:!0,preventDefault:!0,callback:t((function(){f&&(null==s?void 0:s.current)&&s.current.focus()}),[f,s])}),o({keys:m,modifier:o.modifiers.SHIFT,ref:i,callback:b}),o({keys:m,ref:s,withoutAnyModifier:!0,callback:t((function(){(null==u?void 0:u.current)&&u.current.focus(),f&&p(!1)}),[u,f,p])}),o({keys:m,ref:s,modifier:o.modifiers.SHIFT,callback:t((function(){(null==c?void 0:c.current)&&c.current.focus(),f&&p(!1)}),[c,f,p])}),o({keys:d,ref:s,callback:t((function(){(null==i?void 0:i.current)&&i.current.focus(),f&&p(!1)}),[i,f,p])}),o({keys:d,ref:i,callback:b}),n({eventName:"focus",ref:u,callback:b})}var v=function(t,o,n,a,l){var c=t.value,m=Object.assign(Object.assign({},n),{width:l?void 0:"100%"}),d="tooltip-item-".concat(o,"-label");return e.createElement(u,{key:o,isClickable:!!(null==c?void 0:c.onClick),clickableProps:{onClick:function(e){return c.onClick(e,c.id)},tabIndex:"-1"}},e.createElement("div",{style:m},e.createElement(f,{direction:"row",gap:"xs",ariaLabelledby:d},e.createElement(r,Object.assign({},c,{tooltipProps:void 0,ariaLabel:"",customSize:s,type:a||(null==c?void 0:c.type),tabIndex:-1,size:r.sizes.SMALL,className:i.tooltipAvatarItemAvatar})),!l&&e.createElement("div",{id:d,className:i.tooltipAvatarItemTitle},c.tooltipContent))))};export{v as avatarRenderer,p as useTooltipContentTabNavigation};
//# sourceMappingURL=AvatarGroupCounterTooltipHelper.js.map
