import { clsx } from 'clsx';
import Button from '../button/Button.mjs';
import Link from '../link/Link.mjs';
import Title from '../title/Title.mjs';
import { jsx, jsxs } from 'react/jsx-runtime';
import { Typography } from '../common/propsValues/typography.mjs';

const HeaderAction = ({
  action
}) => {
  const props = {
    'aria-label': action['aria-label']
  };
  if ('href' in action) {
    return /*#__PURE__*/jsx(Link, {
      href: action.href,
      target: action.target,
      onClick: action.onClick,
      ...props,
      children: action.text
    });
  }
  return /*#__PURE__*/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__*/jsx(Title, {
      as: as,
      type: Typography.TITLE_GROUP,
      className: 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__*/jsxs("div", {
    className: clsx('np-header', className),
    children: [/*#__PURE__*/jsx(Title, {
      as: as,
      type: Typography.TITLE_GROUP,
      className: "np-header__title",
      children: title
    }), /*#__PURE__*/jsx(HeaderAction, {
      action: action
    })]
  });
};

export { Header, Header as default };
//# sourceMappingURL=Header.mjs.map
