'use strict';

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

var React = require('react');
var Combobox_tokens = require('../../Combobox.tokens.js');
var ItemView_styles = require('./ItemView.styles.js');
var mapCheckedVariants = require('../../utils/mapCheckedVariants.js');
var sizeToIconSize = require('../../utils/sizeToIconSize.js');

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

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

var _StyledIndicator;
var ItemSelectionIcon = function ItemSelectionIcon(_ref) {
  var checked = _ref.checked,
    disabled = _ref.disabled,
    multiple = _ref.multiple,
    size = _ref.size,
    variant = _ref.variant,
    renderSelectionIcon = _ref.renderSelectionIcon,
    checkboxAppearance = _ref.checkboxAppearance,
    withMargin = _ref.withMargin,
    onChange = _ref.onChange;
  return /*#__PURE__*/React__default.default.createElement(ItemView_styles.IconWrapper, {
    variant: variant,
    withMargin: withMargin
  }, renderSelectionIcon ? renderSelectionIcon(mapCheckedVariants.mapCheckedVariants(checked, multiple)) : /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, multiple && /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledCheckboxWrapper, {
    onClick: function onClick(e) {
      return e.stopPropagation();
    }
  }, /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledCheckbox, {
    disabled: disabled,
    checked: Boolean(checked),
    indeterminate: checked === 'indeterminate',
    onChange: onChange,
    appearance: checkboxAppearance !== null && checkboxAppearance !== void 0 ? checkboxAppearance : 'default'
  })), !multiple && checked === 'dot' && (_StyledIndicator || (_StyledIndicator = /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledIndicator, {
    size: "s",
    view: "default"
  }))), !multiple && checked === 'done' && /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledIconDone, {
    size: sizeToIconSize.sizeToIconSize(size, variant),
    color: "inherit"
  })));
};
var ItemContent = function ItemContent(_ref2) {
  var item = _ref2.item,
    renderItem = _ref2.renderItem,
    singleLine = _ref2.singleLine;
  var label = item.label,
    contentLeft = item.contentLeft,
    contentRight = item.contentRight;
  if (renderItem) {
    return /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledText, null, renderItem(item));
  }
  return /*#__PURE__*/React__default.default.createElement(ItemView_styles.StyledCell, {
    contentLeft: contentLeft,
    contentRight: contentRight,
    title: label,
    className: singleLine ? Combobox_tokens.classes.singleLineMode : ''
  });
};

exports.ItemContent = ItemContent;
exports.ItemSelectionIcon = ItemSelectionIcon;
