'use strict';

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

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var React = require('react');
var reactIntl = require('react-intl');
var Body = require('../body/Body.js');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
require('../common/propsValues/breakpoint.js');
var size = 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');
var status = require('../common/propsValues/status.js');
var sentiment = 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('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
require('../info/infoPresentations.js');
var Info = require('../info/Info.js');
var StatusIcon = require('../statusIcon/StatusIcon.js');
var Summary_messages = require('./Summary.messages.js');
var Link = require('../link/Link.js');

/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
const BadgeIcons = {
  [status.Status.DONE]: icons.CheckCircleFill,
  [status.Status.PENDING]: icons.ClockFill
};
const statusLabels = {
  [status.Status.NOT_DONE]: 'statusNotDone',
  [status.Status.DONE]: 'statusDone',
  [status.Status.PENDING]: 'statusPending'
};
const statusMapping = {
  [status.Status.DONE]: sentiment.Sentiment.POSITIVE,
  [status.Status.PENDING]: sentiment.Sentiment.PENDING
};
/**
 * @deprecated Please use `<ListItem />` instead.
 * @deprecatedSince 46.104.0
 * @see [Source](../listItem/ListItem.tsx)
 * @see [Storybook](https://storybook.wise.design/?path=/docs/content-listitem--docs)
 * @see [Design docs](https://wise.design/components/list-item)
 * @see [Release notes](https://transferwise.atlassian.net/wiki/spaces/DS/pages/3647251055/List+Item+release+notes)
 */
const Summary = ({
  action,
  as: Element = 'div',
  className,
  content = null,
  description = content,
  help,
  icon,
  illustration = null,
  info = help,
  status,
  title
}) => {
  const intl = reactIntl.useIntl();
  let media = illustration;
  if (icon) {
    // @ts-expect-error if icon is present it has props and size prop
    const iconSize = icon?.props?.size;
    media = iconSize !== 24 ?
    /*#__PURE__*/
    // @ts-expect-error we need icon to adjust it's size
    React.cloneElement(icon, {
      size: 24
    }) : icon;
  }
  // @ts-expect-error Badge can be null, this is handled in code
  const Badge = status && BadgeIcons[status];
  return /*#__PURE__*/jsxRuntime.jsxs(Element, {
    className: clsx.clsx('np-summary d-flex align-items-start', className)
    // @ts-expect-error we check whether `status` is not null before index `statusLabels` and `messages`
    ,
    "aria-label": status && intl.formatMessage(Summary_messages.default[statusLabels[status]]),
    children: [icon && /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: "np-summary__icon",
      children: [media, Badge && /*#__PURE__*/jsxRuntime.jsx("div", {
        children: /*#__PURE__*/jsxRuntime.jsx(StatusIcon.default, {
          size: size.Size.SMALL,
          sentiment: statusMapping[status]
        })
      })]
    }), /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: `np-summary__body ${icon ? 'm-l-2' : ''}`,
      children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
        className: "np-summary__title d-flex",
        children: [/*#__PURE__*/jsxRuntime.jsx(Body.default, {
          as: "span",
          role: "heading",
          "aria-level": 6,
          type: typography.Typography.BODY_LARGE_BOLD,
          className: "text-primary text-overflow-wrap m-b-1",
          children: title
        }), info && /*#__PURE__*/jsxRuntime.jsx(Info.default, {
          "aria-label": info['aria-label'],
          className: "m-l-1 hidden-xs",
          content: info.content,
          presentation: info.presentation,
          size: size.Size.LARGE,
          title: info.title,
          onClick: info.onClick
        })]
      }), description && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
        as: "span",
        type: typography.Typography.BODY_DEFAULT,
        className: `d-block text-overflow-wrap ${icon ? 'np-summary__description' : 'np-summary__description-icon'}`,
        children: description
      }), action && /*#__PURE__*/jsxRuntime.jsx(Link.default, {
        href: action.href,
        target: action.target,
        className: "np-summary__action",
        "aria-label": action['aria-label'],
        onClick: action.onClick,
        children: action.text
      })]
    }), info && /*#__PURE__*/jsxRuntime.jsx(Info.default, {
      "aria-label": info['aria-label'],
      className: "m-l-2 hidden-sm hidden-md hidden-lg hidden-xl",
      content: info.content,
      presentation: info.presentation,
      size: size.Size.LARGE,
      title: info.title,
      onClick: info.onClick
    })]
  });
};

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