'use strict';

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

var React = require('react');
var Rating_tokens = require('../Rating.tokens.js');
var IconStarFill$1 = require('../../_Icon/Icons/Icon.16/IconStarFill.js');
var IconStarHalfFill$1 = require('../../_Icon/Icons/Icon.16/IconStarHalfFill.js');
var IconStarOutline$1 = require('../../_Icon/Icons/Icon.16/IconStarOutline.js');
var IconStarFill = require('../../_Icon/Icons/Icon.24/IconStarFill.js');
var IconStarHalfFill = require('../../_Icon/Icons/Icon.24/IconStarHalfFill.js');
var IconStarOutline = require('../../_Icon/Icons/Icon.24/IconStarOutline.js');
var IconStarFill$2 = require('../../_Icon/Icons/Icon.36/IconStarFill.js');
var IconStarHalfFill$2 = require('../../_Icon/Icons/Icon.36/IconStarHalfFill.js');
var IconStarOutline$2 = require('../../_Icon/Icons/Icon.36/IconStarOutline.js');
var Rating_styles = require('../Rating.styles.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var iconMap = function iconMap(componentSize) {
  var iconProps = {
    color: 'inherit',
    sizeCustomProperty: Rating_tokens.privateTokens.iconSize
  };
  switch (componentSize) {
    case 'displayL':
    case 'displayM':
    case 'displayS':
    case 'h1':
    case 'h2':
      return {
        fill: /*#__PURE__*/React__default.default.createElement(IconStarFill$2.IconStarFill36, iconProps),
        halfFill: /*#__PURE__*/React__default.default.createElement(IconStarHalfFill$2.IconStarHalfFill36, iconProps),
        outline: /*#__PURE__*/React__default.default.createElement(IconStarOutline$2.IconStarOutline36, iconProps)
      };
    case 'h3':
    case 'h4':
    case 'h5':
    case 'h6':
    case 'l':
    case 'm':
      return {
        fill: /*#__PURE__*/React__default.default.createElement(IconStarFill.IconStarFill24, iconProps),
        halfFill: /*#__PURE__*/React__default.default.createElement(IconStarHalfFill.IconStarHalfFill24, iconProps),
        outline: /*#__PURE__*/React__default.default.createElement(IconStarOutline.IconStarOutline24, iconProps)
      };
    case 's':
    case 'xs':
    case 'xxs':
      return {
        fill: /*#__PURE__*/React__default.default.createElement(IconStarFill$1.IconStarFill16, iconProps),
        halfFill: /*#__PURE__*/React__default.default.createElement(IconStarHalfFill$1.IconStarHalfFill16, iconProps),
        outline: /*#__PURE__*/React__default.default.createElement(IconStarOutline$1.IconStarOutline16, iconProps)
      };
    default:
      return {
        fill: /*#__PURE__*/React__default.default.createElement(IconStarFill.IconStarFill24, iconProps),
        halfFill: /*#__PURE__*/React__default.default.createElement(IconStarHalfFill.IconStarHalfFill24, iconProps),
        outline: /*#__PURE__*/React__default.default.createElement(IconStarOutline.IconStarOutline24, iconProps)
      };
  }
};
var getIcons = function getIcons(_ref) {
  var innerValue = _ref.innerValue,
    size = _ref.size,
    _ref$iconQuantity = _ref.iconQuantity,
    iconQuantity = _ref$iconQuantity === void 0 ? 5 : _ref$iconQuantity,
    iconSlot = _ref.iconSlot,
    iconSlotOutline = _ref.iconSlotOutline,
    iconSlotHalf = _ref.iconSlotHalf;
  var _iconMap = iconMap(size),
    fill = _iconMap.fill,
    halfFill = _iconMap.halfFill,
    outline = _iconMap.outline;
  if (iconQuantity === 1) {
    return /*#__PURE__*/React__default.default.createElement(Rating_styles.Star, {
      className: Rating_tokens.classes.singleIcon
    }, iconSlot || fill);
  }
  var filledIcons = Array.from({
    length: Math.floor(Number(innerValue))
  }, function (_, index) {
    return /*#__PURE__*/React__default.default.createElement(Rating_styles.Star, {
      key: "filled_".concat(index, "_").concat(innerValue)
    }, iconSlot || fill);
  });
  if (Number(innerValue) > 0 && !Number.isInteger(Number(innerValue))) {
    filledIcons.push(/*#__PURE__*/React__default.default.createElement(Rating_styles.Star, {
      key: "half-fill"
    }, iconSlotHalf || halfFill));
  }
  var outlineIconsLength = iconQuantity - filledIcons.length;
  var outlineIcons = Array.from({
    length: outlineIconsLength
  }, function (_, index) {
    return /*#__PURE__*/React__default.default.createElement(Rating_styles.Star, {
      key: "outline_".concat(index, "_").concat(innerValue),
      className: Rating_tokens.classes.iconOutline
    }, iconSlotOutline || outline);
  });
  return [].concat(filledIcons, outlineIcons);
};

exports.getIcons = getIcons;
