'use strict';

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var reactIntl = require('react-intl');
var Circle = require('../common/circle/Circle.js');
var useMedia = require('../common/hooks/useMedia.js');
var StatusIcon_messages = require('./StatusIcon.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var sentiment = require('../common/propsValues/sentiment.js');
var breakpoint = require('../common/propsValues/breakpoint.js');
var size = require('../common/propsValues/size.js');

const mapLegacySize = {
  [String(size.Size.SMALL)]: 16,
  [String(size.Size.MEDIUM)]: 40,
  [String(size.Size.LARGE)]: 48
};
const StatusIcon = ({
  sentiment: sentiment$1 = 'neutral',
  size: sizeProp = 'md',
  iconLabel
}) => {
  const intl = reactIntl.useIntl();
  const iconMetaBySentiment = {
    [sentiment.Sentiment.NEGATIVE]: {
      Icon: icons.Cross,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.errorLabel)
    },
    [sentiment.Sentiment.POSITIVE]: {
      Icon: icons.Check,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.successLabel)
    },
    [sentiment.Sentiment.WARNING]: {
      Icon: icons.Alert,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.warningLabel)
    },
    [sentiment.Sentiment.PENDING]: {
      Icon: icons.ClockBorderless,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.pendingLabel)
    },
    [sentiment.Sentiment.NEUTRAL]: {
      Icon: icons.Info,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.informationLabel)
    },
    // deprecated
    [sentiment.Sentiment.ERROR]: {
      Icon: icons.Cross,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.errorLabel)
    },
    [sentiment.Sentiment.INFO]: {
      Icon: icons.Info,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.informationLabel)
    },
    [sentiment.Sentiment.SUCCESS]: {
      Icon: icons.Check,
      defaultIconLabel: intl.formatMessage(StatusIcon_messages.successLabel)
    }
  };
  const {
    Icon,
    defaultIconLabel
  } = iconMetaBySentiment[sentiment$1];
  const iconColor = sentiment$1 === 'warning' || sentiment$1 === 'pending' ? 'dark' : 'light';
  const isTinyViewport = useMedia.useMedia(`(max-width: ${breakpoint.Breakpoint.ZOOM_400}px)`);
  const size$1 = sizeProp === size.Size.SMALL && isTinyViewport ? 32 : mapLegacySize[sizeProp];
  return /*#__PURE__*/jsxRuntime.jsx(Circle, {
    as: "span",
    size: size$1,
    "data-testid": "status-icon",
    className: clsx.clsx('status-circle', `status-circle-${sizeProp}`, sentiment$1),
    children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
      className: clsx.clsx('status-icon', iconColor),
      title: iconLabel === null ? undefined : iconLabel || defaultIconLabel
    })
  });
};

module.exports = StatusIcon;
//# sourceMappingURL=StatusIcon.js.map
