var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from 'react';
import classnames from 'classnames';
import { pick, pipe, defaultTo } from 'ramda';
import MoreVertIcon from '@mui/icons-material/MoreVert';
import DefaultHeadCellRenderer from 'react-components/dist/Table/DefaultHeadCellRenderer/DefaultHeadCellRenderer';
import { withTableContext } from '../HOCs/withTableContext';
import { ExpandedValueTooltip } from '../ExpandedValueTooltip';
import { SmallIconButton } from '../SmallIconButton';
import { HeadColorVariant, TableVariant } from '../types/basicTable';
import styles from './DefaultHeadCellRendererWithTooltip.module.css';
var DefaultHeadCellRendererWithTooltip = function (_a) {
    var _b;
    var _c = _a.classes, classes = _c === void 0 ? {} : _c, dataReltioIdPrefix = _a.dataReltioIdPrefix, _d = _a.headColorVariant, headColorVariant = _d === void 0 ? HeadColorVariant.White : _d, headCellData = _a.headCellData, className = _a.className, openConfigColumnPopup = _a.openConfigColumnPopup, headIndex = _a.headIndex, _e = _a.variant, variant = _e === void 0 ? TableVariant.Wide : _e, props = __rest(_a, ["classes", "dataReltioIdPrefix", "headColorVariant", "headCellData", "className", "openConfigColumnPopup", "headIndex", "variant"]);
    var headCell = (classes === null || classes === void 0 ? void 0 : classes.headCell) || styles.headCell;
    var headLabel = (classes === null || classes === void 0 ? void 0 : classes.headLabel) || styles.headLabel;
    var hasConfigButton = Boolean(openConfigColumnPopup);
    return (React.createElement("div", __assign({ className: classnames(headCell, className, (_b = {}, _b[styles.withConfigButton] = hasConfigButton, _b), styles[headColorVariant], styles[variant]) }, (dataReltioIdPrefix ? { 'data-reltio-id': "".concat(dataReltioIdPrefix, "-table-head-cell") } : {})),
        React.createElement(DefaultHeadCellRenderer, __assign({}, props, { headIndex: headIndex, headCellData: __assign(__assign({}, headCellData), { label: (React.createElement(ExpandedValueTooltip, { value: headCellData.label },
                    React.createElement("div", { className: headLabel }, headCellData.label))) }) })),
        hasConfigButton && (React.createElement("div", { className: styles.menuButtonWrapper },
            React.createElement(SmallIconButton, { icon: MoreVertIcon, onClick: function (e) { return openConfigColumnPopup && openConfigColumnPopup(headIndex, e); }, size: "S" })))));
};
export default withTableContext(pipe(defaultTo({}), pick(['openConfigColumnPopup', 'dataReltioIdPrefix', 'headColorVariant', 'variant'])))(DefaultHeadCellRendererWithTooltip);
