'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var clsx = require('clsx');
var Button = require('../button/src/Button.js');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
require('../common/propsValues/breakpoint.js');
require('../common/propsValues/size.js');
var typography = require('../common/propsValues/typography.js');
require('../common/propsValues/width.js');
require('../common/propsValues/type.js');
require('../common/propsValues/dateMode.js');
require('../common/propsValues/monthFormat.js');
require('../common/propsValues/position.js');
require('../common/propsValues/layouts.js');
require('../common/propsValues/status.js');
require('../common/propsValues/sentiment.js');
require('../common/propsValues/profileType.js');
require('../common/propsValues/variant.js');
require('../common/propsValues/scroll.js');
require('../common/propsValues/markdownNodeType.js');
require('../common/fileType.js');
require('@transferwise/icons');
require('react');
require('react-intl');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var Link = require('../link/Link.js');
var Title = require('../title/Title.js');

const HeaderAction = ({
  action
}) => {
  const props = {
    'aria-label': action['aria-label']
  };
  if ('href' in action) {
    return /*#__PURE__*/jsxRuntime.jsx(Link, {
      href: action.href,
      target: action.target,
      onClick: action.onClick,
      ...props,
      children: action.text
    });
  }
  return /*#__PURE__*/jsxRuntime.jsx(Button, {
    className: "np-header__button",
    priority: "tertiary",
    size: "sm",
    onClick: action.onClick,
    ...props,
    children: action.text
  });
};
/**
 *
 * Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
 *
 */
const Header = ({
  action,
  as = 'h5',
  title,
  className
}) => {
  if (!action) {
    return /*#__PURE__*/jsxRuntime.jsx(Title, {
      as: as,
      type: typography.Typography.TITLE_GROUP,
      className: clsx.clsx('np-header', 'np-header__title', className),
      children: title
    });
  }
  if (as === 'legend') {
    // eslint-disable-next-line no-console
    console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
  }
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    className: clsx.clsx('np-header', className),
    children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
      as: as,
      type: typography.Typography.TITLE_GROUP,
      className: "np-header__title",
      children: title
    }), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
      action: action
    })]
  });
};

exports.Header = Header;
exports.default = Header;
//# sourceMappingURL=Header.js.map
