import{slicedToArray as e,defineProperty as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import o,{forwardRef as r,useState as n}from"react";import s from"classnames";import i from"./TableHeaderCell.module.scss.js";import a from"../../IconButton/IconButton.js";import l from"../../Text/Text.js";import{getSortIcon as c,getNextSortState as m,getAriaSort as d}from"../Table/tableHelpers.js";import p from"../../Tooltip/Tooltip.js";import{getTestId as f}from"../../../tests/testIds.js";import{ComponentDefaultTestId as u}from"../../../tests/constants.js";import{getStyle as j}from"../../../helpers/typesciptCssModulesHelper.js";import E from"../../../../components/layout/dist/Flex/Flex.js";import b from"../../../../components/icon/dist/Icon/Icon.js";import v from"../../../../icons/dist/react/Info.js";var C=r((function(r,C){var y=r.id,x=r.className,T=r["data-testid"],H=r.title,I=r.onSortClicked,L=r.infoContent,N=r.icon,g=r.sortState,B=void 0===g?"none":g,h=r.sortButtonAriaLabel,k=void 0===h?"Sort":h,A=r.sticky,w=n(!1),S=e(w,2),_=S[0],F=S[1],M=d(B),P="none"!==M||_;return o.createElement("div",{ref:C,id:y,className:s(i.tableHeaderCell,t(t({},i.sortActive,I&&"none"!==M),i.sticky,A),x),"data-testid":T||f(u.TABLE_HEADER_CELL,y),role:"columnheader",onMouseOver:function(){return F(!0)},onMouseLeave:function(){return F(!1)},onFocus:function(){return F(!0)},onBlur:function(){return F(!1)},"aria-sort":I?M:void 0,tabIndex:I?0:void 0},o.createElement(E,{direction:"row",align:"center",className:i.tableHeaderCellContent,gap:"xs"},N&&o.createElement(b,{icon:N,className:i.icon}),"string"==typeof H?o.createElement(l,{type:"text2",weight:"medium",color:"secondary"},H):H,L&&o.createElement(p,{content:L,referenceWrapperClassName:i.infoTooltip},o.createElement(b,{icon:v,iconLabel:L}))),I&&o.createElement(E,{direction:"row",align:"center",className:i.tableHeaderCellSort},o.createElement(a,{icon:c(B),kind:"tertiary",size:"xs",ariaLabel:k,"aria-hidden":!P,className:s(i.sort,j(i,B),t({},i.show,P)),onClick:function(){return I(m(B))}})))}));export{C as default};
//# sourceMappingURL=TableHeaderCell.js.map
