"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _map = _interopRequireDefault(require("lodash/fp/map"));
var _buttonLink = _interopRequireDefault(require("../../atom/button-link"));
var _buttonLinkIcon = _interopRequireDefault(require("../../atom/button-link-icon"));
var _tag = _interopRequireDefault(require("../../atom/tag"));
var _bulletPointMenuButton = _interopRequireDefault(require("../../molecule/bullet-point-menu-button"));
var _types = _interopRequireDefault(require("./types"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const getDataName = suffix => `header-with-actions-${suffix}`;
// @ts-expect-error (need to get the index)
const uncappedMap = _map.default.convert({
  cap: false
});
const HeaderWithActions = props => {
  const {
    closeButton,
    title,
    tag,
    saveStatus,
    bulletPointMenuButton,
    actionButtons
  } = props;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.headerWrapper,
    "data-name": getDataName('wrapper')
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.titleAndButtonWrapper,
    "data-name": getDataName('title-and-button-wrapper')
  }, /*#__PURE__*/_react.default.createElement(_buttonLinkIcon.default, _extends({}, closeButton, {
    className: _style.default.button
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.titleWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.statusWrapper
  }, /*#__PURE__*/_react.default.createElement(_tag.default, tag), saveStatus.display && saveStatus.label ? /*#__PURE__*/_react.default.createElement("p", {
    className: _style.default.saveStatus
  }, saveStatus.label) : null), /*#__PURE__*/_react.default.createElement("h3", {
    className: _style.default.title,
    "aria-label": title,
    "data-name": getDataName('title')
  }, title))), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.buttonsWrapper,
    "data-name": getDataName('buttons-wrapper')
  }, bulletPointMenuButton && !(0, _isEmpty.default)(bulletPointMenuButton.buttons) ? /*#__PURE__*/_react.default.createElement(_bulletPointMenuButton.default, _extends({}, bulletPointMenuButton, {
    buttonAriaLabel: "More actions"
  })) : null, uncappedMap((action, key) => {
    return /*#__PURE__*/_react.default.createElement(_buttonLink.default, _extends({}, action, {
      key: key
    }));
  }, actionButtons)));
};
HeaderWithActions.propTypes = process.env.NODE_ENV !== "production" ? _types.default : {};
var _default = exports.default = HeaderWithActions;
//# sourceMappingURL=index.js.map