import{jsx as e,Fragment as s,jsxs as n}from"react/jsx-runtime";import{forwardRef as i,useRef as t,useMemo as o,Fragment as a}from"react";import r from"classnames";import{noop as c}from"lodash-es";import l from"../../hooks/useMergeRefs.js";import d from"../Tooltip/Tooltip.js";import p from"../Icon/Icon.js";import m from"../Icon/Icons/components/Close.js";import{getWidthHeight as u}from"./services/IconButton-helpers.js";import{getTestId as f}from"../../tests/testIds.js";import{ComponentDefaultTestId as b}from"../../tests/constants.js";import g from"../Button/Button.js";import{BUTTON_ICON_SIZE as j}from"../Button/ButtonConstants.js";import v from"./IconButton.module.scss.js";var h=i((function(i,c){var m=i.wrapperClassName,h=i.id,N=i.icon,C=i.size,O=i.tooltipProps,I=i.tooltipContent,T=i.ariaLabel,k=i.hideTooltip,y=i.kind,_=i.active,B=i.disabled,z=i.disabledReason,S=i.onClick,L=i.color,F=i.dataTestId,R=i.insetFocus,P=i.label,w=i.labelInButton,A=i.shape,G=t(null),W=l({refs:[c,G]}),M=o((function(){return(null==O?void 0:O.content)||I}),[null==O?void 0:O.content,I]),U=o((function(){return T||("string"==typeof M?M:void 0)}),[T,M]),X=o((function(){switch(C){case g.sizes.XXS:case g.sizes.XS:case g.sizes.SMALL:return 16;case g.sizes.LARGE:return j;default:return 24}}),[C]),x=o((function(){var e={justifyContent:"center",alignItems:"center",padding:0};return C&&(e=Object.assign(Object.assign({},e),u(C))),e}),[C]),E=o((function(){return k?null:B&&z?z:M||T}),[k,B,z,M,T]),V=m?"div":a,q=o((function(){return m?{className:r(m,v.wrapper)}:{}}),[m]),Y="Circle"===A?v.l3_style_circle_button:v.l3_style_square_button,D=16===X?v.label_styles_small:v.label_styles_large;return e(s,{children:P?n("div",Object.assign({className:v.iconButtonContainer},{children:[e(V,Object.assign({},q,{children:e(d,Object.assign({},O,{content:E,referenceWrapperClassName:v.referenceWrapper},{children:e(g,Object.assign({onClick:S,disabled:B,color:L,kind:y,ariaLabel:U,ref:W,id:h,dataTestId:F||f(b.ICON_BUTTON,h),noSidePadding:!0,active:_,className:Y,style:x,insetFocus:R},{children:w?e(s,{children:e("span",Object.assign({className:D},{children:w}))}):e(p,{icon:N,iconType:p.type.SVG,iconSize:X,ignoreFocusStyle:!0,className:"icon-button-padding",clickable:!1})}))}))})),e("span",Object.assign({className:D},{children:P}))]})):e("div",Object.assign({className:v.iconButtonContainer},{children:e(V,Object.assign({},q,{children:e(d,Object.assign({},O,{content:E,referenceWrapperClassName:v.referenceWrapper},{children:e(g,Object.assign({onClick:S,disabled:B,color:L,kind:y,ariaLabel:U,ref:W,id:h,dataTestId:F||f(b.ICON_BUTTON,h),noSidePadding:!0,active:_,className:Y,style:x,insetFocus:R},{children:w?e(s,{children:e("span",Object.assign({className:D},{children:w}))}):e(p,{icon:N,iconType:p.type.SVG,iconSize:X,ignoreFocusStyle:!0,className:"icon-button-padding",clickable:!1})}))}))}))}))})}));Object.assign(h,{sizes:g.sizes,kinds:g.kinds,colors:g.colors,defaultTestId:b.ICON_BUTTON}),h.defaultProps={className:void 0,wrapperClassName:void 0,onClick:c,id:void 0,icon:m,ariaLabel:void 0,size:null==h?void 0:h.sizes.LARGE,hideTooltip:!1,tooltipContent:void 0,tooltipProps:{},kind:h.kinds.PRIMARY,disabled:!1,disabledReason:void 0,color:void 0,dataTestId:void 0,insetFocus:!1,shape:"Circle"};var N=h;export{N as default};
