import { NavigateAway } from '@transferwise/icons';
import { clsx } from 'clsx';
import { useIntl } from 'react-intl';
import PrimitiveButton from '../primitives/PrimitiveButton/PrimitiveButton.mjs';
import PrimitiveAnchor from '../primitives/PrimitiveAnchor/PrimitiveAnchor.mjs';
import '../common/theme.mjs';
import '../common/direction.mjs';
import '@transferwise/neptune-tokens';
import '../common/propsValues/control.mjs';
import '../common/propsValues/size.mjs';
import { Typography } from '../common/propsValues/typography.mjs';
import '../common/propsValues/width.mjs';
import '../common/propsValues/type.mjs';
import '../common/propsValues/dateMode.mjs';
import '../common/propsValues/monthFormat.mjs';
import '../common/propsValues/position.mjs';
import '../common/propsValues/layouts.mjs';
import '../common/propsValues/status.mjs';
import '../common/propsValues/sentiment.mjs';
import '../common/propsValues/profileType.mjs';
import '../common/propsValues/variant.mjs';
import '../common/propsValues/scroll.mjs';
import '../common/propsValues/markdownNodeType.mjs';
import '../common/fileType.mjs';
import '@transferwise/formatting';
import 'react';
import '../common/closeButton/CloseButton.messages.mjs';
import { jsx, jsxs } from 'react/jsx-runtime';
import messages from './Link.messages.mjs';

const Link = ({
  className,
  children,
  href,
  target,
  type = Typography.LINK_DEFAULT,
  'aria-label': ariaLabel,
  onClick,
  disabled,
  ...props
}) => {
  const {
    formatMessage
  } = useIntl();
  const isButton = Boolean(onClick) && href === undefined;
  const isBlank = target === '_blank';
  const classNames = clsx('np-link', 'd-inline-flex', {
    [`np-text-${type}`]: type,
    'np-link--disabled': disabled
  }, className);
  return isButton ? /*#__PURE__*/jsx(PrimitiveButton, {
    type: "button",
    "aria-label": ariaLabel,
    className: clsx(classNames, 'btn-unstyled'),
    disabled: disabled,
    onClick: onClick,
    children: children
  }) : /*#__PURE__*/jsxs(PrimitiveAnchor, {
    href: href,
    target: target,
    className: classNames,
    "aria-label": ariaLabel,
    rel: isBlank ? 'noreferrer' : undefined,
    disabled: disabled,
    onClick: onClick,
    ...props,
    children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
      title: formatMessage(messages.opensInNewTab)
    })]
  });
};

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