'use strict';

var icons = require('@transferwise/icons');
var clsx = require('clsx');
var Body = require('../body/Body.js');
var jsxRuntime = require('react/jsx-runtime');
var typography = require('../common/propsValues/typography.js');

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, {
      className: "text-primary",
      type: typography.Typography.BODY_LARGE,
      children: isInstructionNode ? item.content : item
    })]
  });
}

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