'use strict';

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

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var Body = require('../body/Body.js');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
require('../common/propsValues/breakpoint.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('react');
require('react-intl');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');

const InstructionsList = ({
  className,
  dos,
  donts,
  sort = 'dosFirst'
}) => {
  const dosInstructions = dos?.map((doThis, index) =>
  /*#__PURE__*/
  // eslint-disable-next-line react/no-array-index-key
  jsxRuntime.jsx(Instruction, {
    item: doThis,
    type: "do"
  }, index)) ?? null;
  const dontsInstructions = donts?.map((dont, index) =>
  /*#__PURE__*/
  // eslint-disable-next-line react/no-array-index-key
  jsxRuntime.jsx(Instruction, {
    item: dont,
    type: "dont"
  }, index)) ?? null;
  const orderedInstructions = sort === 'dosFirst' ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [dosInstructions, dontsInstructions]
  }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [dontsInstructions, dosInstructions]
  });
  return /*#__PURE__*/jsxRuntime.jsx("ul", {
    className: clsx.clsx('tw-instructions', className),
    children: orderedInstructions
  });
};
function Instruction({
  item,
  type
}) {
  const isInstructionNode = typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;
  return /*#__PURE__*/jsxRuntime.jsxs("li", {
    className: "instruction",
    children: [type === 'do' ? /*#__PURE__*/jsxRuntime.jsx(icons.CheckCircleFill, {
      size: 24,
      className: type,
      title: isInstructionNode ? item['aria-label'] : undefined
    }) : /*#__PURE__*/jsxRuntime.jsx(icons.CrossCircleFill, {
      size: 24,
      className: type,
      title: isInstructionNode ? item['aria-label'] : undefined
    }), /*#__PURE__*/jsxRuntime.jsx(Body.default, {
      className: "text-primary",
      type: typography.Typography.BODY_LARGE,
      preserveNewlines: true,
      children: isInstructionNode ? item.content : item
    })]
  });
}

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