import React__default from 'react';
import { classes } from '../../Combobox.tokens.js';
import { IconWrapper, StyledCheckboxWrapper, StyledCheckbox, StyledIndicator, StyledIconDone, StyledText, StyledCell } from './ItemView.styles.js';
import { mapCheckedVariants } from '../../utils/mapCheckedVariants.js';
import { sizeToIconSize } from '../../utils/sizeToIconSize.js';

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.createElement(IconWrapper, {
    variant: variant,
    withMargin: withMargin
  }, renderSelectionIcon ? renderSelectionIcon(mapCheckedVariants(checked, multiple)) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, multiple && /*#__PURE__*/React__default.createElement(StyledCheckboxWrapper, {
    onClick: function onClick(e) {
      return e.stopPropagation();
    }
  }, /*#__PURE__*/React__default.createElement(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.createElement(StyledIndicator, {
    size: "s",
    view: "default"
  }))), !multiple && checked === 'done' && /*#__PURE__*/React__default.createElement(StyledIconDone, {
    size: 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.createElement(StyledText, null, renderItem(item));
  }
  return /*#__PURE__*/React__default.createElement(StyledCell, {
    contentLeft: contentLeft,
    contentRight: contentRight,
    title: label,
    className: singleLine ? classes.singleLineMode : ''
  });
};

export { ItemContent, ItemSelectionIcon };
