import{slicedToArray as o,defineProperty as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{forwardRef as a,useRef as r,useMemo as t,useCallback as l}from"react";import n from"classnames";import c from"../Icon/Icon.js";import m from"../../hooks/useMergeRefs.js";import d from"../Icon/Icons/components/CloseSmall.js";import{getCSSVar as u}from"../../services/themes.js";import{tagElementColorsNames as p,getTagElementColor as v}from"../../utils/colors-vars-map.js";import f from"../Avatar/Avatar.js";import b from"../IconButton/IconButton.js";import{getTestId as g}from"../../tests/testIds.js";import{TagsSize as j}from"./TagsConstants.js";import{AvatarType as I}from"../Avatar/AvatarConstants.js";import k from"../../hooks/useHover.js";import h from"../Clickable/ClickableWrapper.js";import{ComponentDefaultTestId as T}from"../../tests/constants.js";import C from"./Tags.module.scss.js";var N=a((function(a,N){var A,O,y=a.className,S=a.id,z=a.label,w=void 0===z?"":z,R=a.leftIcon,_=void 0===R?null:R,M=a.rightIcon,B=void 0===M?null:M,P=a.leftAvatar,D=void 0===P?null:P,F=a.rightAvatar,G=void 0===F?null:F,L=a.disabled,x=void 0!==L&&L,W=a.readOnly,H=void 0!==W&&W,X=a.allowTextSelection,Y=void 0!==X&&X,E=a.color,U=void 0===E?p.gradient_blue:E,q=a.iconSize,J=void 0===q?16:q,K=a.onDelete,Q=void 0===K?function(o,e){}:K,V=a.onMouseDown,Z=a.onClick,$=a.noAnimation,oo=void 0!==$&&$,eo=a.ariaLabel,io=a.isClickable,so=void 0!==io&&io,ao=a.size,ro=void 0===ao?"large":ao,to=a.outlined,lo=void 0!==to&&to,no=a.dataTestId||g(T.TAG,S),co=so&&(!!Z||!!V),mo=!H&&!x,uo=k(),po=o(uo,2),vo=po[0],fo=po[1],bo=r(null),go=r(null),jo=m({refs:[N,go,vo]}),Io=t((function(){var o;return o=x?u("disabled-background-color"):fo&&co?v(U,!0,!0):v(U,!0),lo?{borderColor:o}:{background:o}}),[x,fo,co,U,lo]),ko=l((function(o){o.stopPropagation(),Q&&Q(S,o)}),[S,Q]),ho=l((function(o){o.target!==bo.current&&Z&&(o.preventDefault(),Z(o))}),[Z]);return i("div",Object.assign({className:n(C.tagsWrapper,y,(A={},e(A,C.sizeSmall,"small"===ro),e(A,C.outlined,lo),A))},{children:i(h,Object.assign({isClickable:co,clickableProps:{onClick:ho,onMouseDown:V,disabled:x,ariaLabel:eo||w,className:C.clickableWrapper}},{children:s("div",Object.assign({ref:jo,className:n(C.tags,"tags--wrapper",y,(O={},e(O,C.disabled,x),e(O,C.withClose,mo),e(O,C.noAnimation,oo),e(O,C.withUserSelect,Y),O)),id:S,style:Io,"data-testid":no},{children:[D?i(f,{withoutBorder:!0,className:n(C.avatar,C.left),customSize:18,src:D,type:I.IMG},S):null,_?i(c,{className:n(C.icon,C.left),iconType:c.type.ICON_FONT,clickable:!1,icon:_,iconSize:J,ignoreFocusStyle:!0}):null,i("div",Object.assign({className:n(C.label)},{children:w})),B?i(c,{className:n(C.icon,C.right),iconType:c.type.ICON_FONT,clickable:!1,icon:B,iconSize:J,ignoreFocusStyle:!0}):null,G?i(f,{withoutBorder:!0,className:n(C.avatar,C.right),customSize:16,src:G,type:I.IMG},S):null,mo&&i(b,{size:j.XXS,color:b.colors.ON_PRIMARY_COLOR,className:n(C.icon,C.close),ariaLabel:"Remove",hideTooltip:!0,icon:d,onClick:ko,dataTestId:"".concat(no,"-close"),ref:bo,kind:b.kinds.TERTIARY})]}))}))}))}));Object.assign(N,{sizes:j,defaultTestId:T.TAG,colors:p});var A=N;export{A as default};
