'use strict';

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

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var reactIntl = require('react-intl');
var PrimitiveButton = require('../primitives/PrimitiveButton/PrimitiveButton.js');
var PrimitiveAnchor = require('../primitives/PrimitiveAnchor/PrimitiveAnchor.js');
require('../common/theme.js');
require('../common/direction.js');
require('@transferwise/neptune-tokens');
require('../common/propsValues/control.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/formatting');
require('react');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var Link_messages = require('./Link.messages.js');

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

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