'use strict';

exports.__esModule = true;

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Avatar = require('../Avatar');

var _Avatar2 = _interopRequireDefault(_Avatar);

var _Icon = require('../Icon');

var _Icon2 = _interopRequireDefault(_Icon);

var _ListItem = require('../ListItem');

var _ListItem2 = _interopRequireDefault(_ListItem);

var _ListItemSection = require('../ListItemSection');

var _ListItemSection2 = _interopRequireDefault(_ListItemSection);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * @category containers
 * @component list-item
 * @variations collab-ui-react
 */

var _ref = _react2.default.createElement(_Icon2.default, { color: '$white-60', name: 'alert-muted_12' });

var _ref2 = _react2.default.createElement(_Icon2.default, { color: 'blue', name: 'mention_12' });

var _ref3 = _react2.default.createElement(_Icon2.default, { color: '$white-60', name: 'alert_12' });

var _ref4 = _react2.default.createElement(_Avatar2.default, { isOverview: true, icon: _react2.default.createElement(_Icon2.default, { name: 'handset_24' }) });

var _ref5 = _react2.default.createElement(_Avatar2.default, { title: 'NA' });

var SpaceListItem = function (_React$PureComponent) {
  (0, _inherits3.default)(SpaceListItem, _React$PureComponent);

  function SpaceListItem() {
    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, SpaceListItem);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args))), _this), _this.state = {
      id: _lodash2.default.uniqueId(_this.props.id && _this.props.id + '-' || 'cui-space-list-item-')
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  SpaceListItem.prototype.render = function render() {
    var _props = this.props,
        className = _props.className,
        childrenLeft = _props.childrenLeft,
        childrenRight = _props.childrenRight,
        header = _props.header,
        subheader = _props.subheader,
        isAlertOn = _props.isAlertOn,
        isOverview = _props.isOverview,
        isMentioned = _props.isMentioned,
        isMuted = _props.isMuted,
        isUnread = _props.isUnread,
        props = (0, _objectWithoutProperties3.default)(_props, ['className', 'childrenLeft', 'childrenRight', 'header', 'subheader', 'isAlertOn', 'isOverview', 'isMentioned', 'isMuted', 'isUnread']);
    var id = this.state.id;


    var getIcon = function getIcon() {
      if (isMuted) {
        return _ref;
      } else if (isUnread) {
        return _react2.default.createElement('i', { style: { fontSize: '12px', color: '#07C1E4' }, className: 'icon icon-unread-badge_16' });
      } else if (isMentioned) {
        return _ref2;
      } else if (isAlertOn) {
        return _ref3;
      }

      return null;
    };

    var leftSection = isOverview ? _ref4 : childrenLeft;

    var rightSection = childrenRight ? childrenRight : getIcon();

    var children = [_react2.default.createElement(
      _ListItemSection2.default,
      { key: 'child-0', position: 'left' },
      leftSection || _ref5
    ), _react2.default.createElement(
      _ListItemSection2.default,
      { key: 'child-1', position: 'center' },
      _react2.default.createElement(
        'div',
        {
          className: 'cui-list-item__header' + ('' + (isOverview && ' cui-list-item__header--overview' || ''))
        },
        header
      ),
      _react2.default.createElement(
        'div',
        { className: 'cui-list-item__subheader' },
        subheader
      )
    ), _react2.default.createElement(
      _ListItemSection2.default,
      { key: 'child-2', position: 'right' },
      rightSection
    )];

    var highlightFont = function highlightFont() {
      return isMuted ? false : isUnread || isMentioned;
    };

    return _react2.default.createElement(
      _ListItem2.default,
      (0, _extends3.default)({
        className: '' + (highlightFont() && ' cui-list-item--unread' || '') + ('' + (className && ' ' + className || '')),
        id: id,
        type: 'space'
      }, props),
      children
    );
  };

  return SpaceListItem;
}(_react2.default.PureComponent);

SpaceListItem.displayName = 'SpaceListItem';
exports.default = SpaceListItem;


/**
* @name Space List
*
* @category containers
* @component list-item
* @section space
*
* @js
*
import { List, SpaceListItem } from '@collab-ui/react';
import { NavLink } from 'react-router-dom';

export default class SpaceListExamples extends React.PureComponent {

  render() {
    const anchorNode = <NavLink to='/containers/list-item' />;
    return(
      <div className="medium-4 columns cui--dark">
        <List style={{backgroundColor: 'rgba(40,40,40,0.72)'}}>
          <SpaceListItem header='Header' subheader='must be very long long long long long message message' isUnread/>
          <SpaceListItem header='isMentioned' isMentioned/>
          <SpaceListItem header='isMuted' isMuted/>
          <SpaceListItem header='isAlertOn' isAlertOn/>
          <SpaceListItem header='iconsPrioritized' isMuted isAlertOn isMentioned isUnread/>
          <SpaceListItem header='Header' subheader='subheader' disabled/>
          <SpaceListItem header='Header' subheader='subheader' customRefProp='innerRef' customAnchorNode={anchorNode}/>
          <SpaceListItem header='SingleRead' />
          <SpaceListItem isOverview header='Summary List Item' />
        </List>
      </div>
    );
  }
}
**/
SpaceListItem.defaultProps = {
  className: '',
  childrenLeft: null,
  childrenRight: null,
  id: '',
  isAlertOn: false,
  isMentioned: false,
  isMuted: false,
  isUnread: false,
  isOverview: false,
  subheader: ''
};

module.exports = exports['default'];