'use strict';

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

var clsx = require('clsx');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
var breakpoint = require('../common/propsValues/breakpoint.js');
var size = require('../common/propsValues/size.js');
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/icons');
require('react');
require('react-intl');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var useScreenSize = require('../common/hooks/useScreenSize.js');
var NavigationOption = require('../navigationOption/NavigationOption.js');
var Tile = require('../tile/Tile.js');

exports.DecisionPresentation = void 0;
(function (DecisionPresentation) {
  DecisionPresentation["LIST"] = "LIST";
  DecisionPresentation["LIST_BLOCK"] = "LIST_BLOCK";
  DecisionPresentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
})(exports.DecisionPresentation || (exports.DecisionPresentation = {}));
exports.DecisionType = void 0;
(function (DecisionType) {
  DecisionType["NAVIGATION"] = "NAVIGATION";
})(exports.DecisionType || (exports.DecisionType = {}));
const Decision = ({
  options,
  presentation = exports.DecisionPresentation.LIST,
  size: size$1 = size.Size.MEDIUM,
  type = exports.DecisionType.NAVIGATION,
  showMediaCircleInList = true,
  isContainerAligned = false
}) => {
  const screenXs = useScreenSize.useScreenSize(breakpoint.Breakpoint.EXTRA_SMALL);
  const screenSm = useScreenSize.useScreenSize(breakpoint.Breakpoint.SMALL);
  if (type === exports.DecisionType.NAVIGATION) {
    const renderedOptions = options.map(({
      'aria-label': ariaLabel,
      title,
      description,
      disabled,
      href,
      target,
      media: {
        list
      },
      onClick
    }, key) => /*#__PURE__*/jsxRuntime.jsx(NavigationOption.default
    // eslint-disable-next-line react/no-array-index-key
    , {
      "aria-label": ariaLabel,
      complex: false,
      content: description,
      disabled: disabled,
      href: href,
      target: target,
      media: list,
      showMediaAtAllSizes: true,
      showMediaCircle: showMediaCircleInList,
      isContainerAligned: isContainerAligned,
      title: title,
      onClick: onClick
    }, `nav-${key}`));
    if (presentation === exports.DecisionPresentation.LIST_BLOCK || presentation === exports.DecisionPresentation.LIST_BLOCK_GRID) {
      const isSmall = size$1 === size.Size.SMALL;
      const breakpoint = isSmall ? screenXs : screenSm;
      const isGrid = presentation === exports.DecisionPresentation.LIST_BLOCK_GRID;
      return /*#__PURE__*/jsxRuntime.jsx("div", {
        className: clsx.clsx('np-decision d-flex', {
          'np-decision--small': isSmall,
          'np-decision--grid': isGrid
        }, breakpoint ? isGrid && 'flex-wrap' : 'flex-column'),
        children: breakpoint ? options.map(({
          'aria-label': ariaLabel,
          description,
          disabled,
          href,
          target,
          media: {
            block
          },
          onClick,
          title
        }, key) => /*#__PURE__*/jsxRuntime.jsx(Tile.default
        // eslint-disable-next-line react/no-array-index-key
        , {
          className: clsx.clsx(`np-decision__tile${isSmall ? '--small' : ''}`, {
            'np-decision__tile--fixed-width': isGrid
          }),
          "aria-label": ariaLabel,
          description: description,
          disabled: disabled,
          href: href,
          target: target,
          media: block,
          size: isSmall ? size.Size.SMALL : size.Size.MEDIUM,
          title: title,
          onClick: onClick
        }, `tile-${key}`)) : renderedOptions
      });
    }
    // LIST
    return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
      children: renderedOptions
    });
  }
  return null;
};

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