import{defineProperty as e}from"../../../../../_virtual/_rollupPluginBabelHelpers.js";import{camelCase as o}from"es-toolkit";import{getStyle as t}from"../../../../helpers/typesciptCssModulesHelper.js";import r from"classnames";import n,{forwardRef as l,useMemo as s,useRef as c,useCallback as i,useEffect as a}from"react";import{contentColors as m}from"../../../../utils/colors-vars-map.js";import d from"../../../../utils/colors-utils.js";import u from"../../../Tooltip/Tooltip.js";import{getTestId as p}from"../../../../tests/testIds.js";import{ComponentDefaultTestId as f}from"../../../../tests/constants.js";import v from"./ColorPickerItemComponent.module.scss.js";import I from"../../../../../components/clickable/dist/Clickable/Clickable.js";import C from"../../../../../components/icon/dist/Icon/Icon.js";var g=l((function(l,g){var k=l.color,y=l.onColorClicked,E=l.colorStyle,b=void 0===E?"regular":E,j=l.shouldRenderIndicatorWithoutBackground,S=l.ColorIndicatorIcon,h=l.SelectedIndicatorIcon,L=void 0===h?S:h,M=l.isSelected,N=l.colorSize,P=l.tooltipContent,T=l.isActive,W=l.colorShape,_=l["data-testid"],x=s((function(){return m.includes(k)}),[k]),A=x?d.getMondayColorAsStyle(k,b):k,R=c(null),z=i((function(){return y(k)}),[y,k]);a((function(){if((null==R?void 0:R.current)&&!j&&x){var e=R.current,o=function(e){e.target.style.background=d.getMondayColorAsStyle(k,"selected"===b?"regular":"hover")},t=function(e){e.target.style.background=A};return e.addEventListener("mouseenter",o,!1),e.addEventListener("mouseleave",t,!1),function(){e.removeEventListener("mouseenter",o,!1),e.removeEventListener("mouseleave",t,!1)}}}),[k,A,b,x,R,j]);var B=M||S,D=j?{color:A}:{};return n.createElement(u,{content:P},n.createElement("li",{className:r(v.itemWrapper,e(e(e({},v.selectedColor,M),v.active,T),v.circle,"circle"===W)),"data-testid":_||p(f.COLOR_PICKER_ITEM,k)},n.createElement("div",{className:r(v.feedbackIndicator)}),n.createElement(I,{ref:R,ariaLabel:k,className:r(v.colorItem,t(v,o("color-item-size-"+N)),e({},v.colorItemTextMode,j)),style:{background:j?"transparent":A},onClick:z,tabIndex:"-1",onMouseDown:function(e){return e.preventDefault()}},n.createElement("div",{className:r(v.colorIndicatorWrapper),style:D},B&&n.createElement(C,{icon:M?L:S,className:r(e({},v.colorIconWhite,!j)),ignoreFocusStyle:!0})))))}));export{g as default};
//# sourceMappingURL=ColorPickerItemComponent.js.map
