'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 _ = require('./..');

var _lodash = require('lodash');

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

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

var _ref5 = _react2.default.createElement(_.Icon, { name: 'people_12' });

var _ref6 = _react2.default.createElement(_.Icon, { name: 'spark-board_16' });

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

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

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

    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: (0, _lodash.uniqueId)(_this.props.id && _this.props.id + '-' || 'cui-space-list-meeting-')
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  SpaceListMeeting.prototype.render = function render() {
    var _props = this.props,
        className = _props.className,
        childrenLeft = _props.childrenLeft,
        childrenRight = _props.childrenRight,
        header = _props.header,
        subheader = _props.subheader,
        attendees = _props.attendees,
        buttonLabel = _props.buttonLabel,
        buttonOnClick = _props.buttonOnClick,
        meetingType = _props.meetingType,
        props = (0, _objectWithoutProperties3.default)(_props, ['className', 'childrenLeft', 'childrenRight', 'header', 'subheader', 'attendees', 'buttonLabel', 'buttonOnClick', 'meetingType']);
    var id = this.state.id;

    var _ref = _react2.default.createElement(_.Avatar, { title: header, alt: header, type: 'group' });

    var _ref2 = _react2.default.createElement(_.Avatar, { title: '#', alt: header });

    var _ref3 = _react2.default.createElement(_.Avatar, { icon: _ref6, alt: header });

    var _ref4 = _react2.default.createElement(_.Avatar, { title: header, alt: header });

    var getLeftSection = function getLeftSection() {
      switch (meetingType) {
        case 'group':
          return _ref;
        case 'number':
          return _ref2;
        case 'device':
          return _ref3;
        default:
          return _ref4;
      }
    };

    var getPopoverContent = _react2.default.createElement(
      _.List,
      null,
      attendees.map(function (ele, idx) {
        return _react2.default.createElement(
          _.ListItem,
          { key: 'attendee-' + idx },
          _react2.default.createElement(
            _.ListItemSection,
            { position: 'left' },
            _react2.default.createElement(_.Avatar, {
              size: 'small',
              title: ele.title,
              alt: ele.alt || ele.title,
              src: ele.src || '',
              type: 'group'
            })
          ),
          _react2.default.createElement(
            _.ListItemSection,
            { position: 'center' },
            _react2.default.createElement(
              'div',
              { className: 'cui-list-item__header' },
              ele.title
            )
          )
        );
      })
    );

    var children = [_react2.default.createElement(
      _.ListItemSection,
      { key: 'child-0', position: 'left' },
      childrenLeft || getLeftSection()
    ), _react2.default.createElement(
      _.ListItemSection,
      { key: 'child-1', position: 'center' },
      _react2.default.createElement(
        'div',
        {
          className: 'cui-list-item__header' + ('' + (buttonLabel ? ' cui-list-item__header--active' : ''))
        },
        header
      ),
      _react2.default.createElement(
        'div',
        { className: 'cui-list-item__subheader' },
        subheader
      )
    ), _react2.default.createElement(
      _.ListItemSection,
      { key: 'child-2', position: 'right' },
      childrenRight || attendees.length > 0 && _react2.default.createElement(
        _.Popover,
        {
          content: getPopoverContent,
          direction: 'bottom-center',
          targetOffset: { vertical: 3 },
          isDynamic: true,
          popoverTrigger: 'Click'
        },
        _react2.default.createElement(
          'span',
          {
            role: 'button',
            tabIndex: 0,
            className: 'cui-list-item--space-meeting--attendees'
          },
          attendees.length,
          _ref5
        )
      ),
      buttonLabel && _react2.default.createElement(_.Button, {
        color: 'green',
        ariaLabel: buttonLabel,
        children: buttonLabel,
        onClick: buttonOnClick
      })
    )];

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

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

SpaceListMeeting.displayName = 'SpaceListMeeting';
exports.default = SpaceListMeeting;


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

export default class SpaceListExamples extends React.PureComponent {

  render() {
    return(
      <div className="medium-4 columns">
        <List style={{backgroundColor: 'rgba(40,40,40,0.72)'}}>
          <SpaceListMeeting 
            buttonLabel='Now'
            attendees={[
              {title: 'Joe Bojangles'},
              {title: 'Joe Boe'},
              {title: 'Joe Coe'},
              {title: 'Joe Doe'},
              {title: 'Joe Foe'},
              {title: 'Joe Goe'},
              {title: 'Joe Joe'},
              {title: 'Joe Koe'},
              {title: 'Joe Loe'},
              {title: 'Joe Moe'},
              {title: 'Joe Noe'},
              {title: 'Joe Poe'},
              {title: 'Moe Moe'},
              {title: 'Toe Toe'}
            ]}
            header='Header'
            subheader='must be very long long long long long message message' 
          />
          <SpaceListMeeting
            buttonLabel='In 5 Min'
            header='Header'
            subheader='subheader'
            meetingType='group'
          />
          <SpaceListMeeting
            buttonLabel='2:25'
            header='555-555-5555'
            subheader='subheader'
            meetingType='number'
          />
          <SpaceListMeeting
            attendees={[
              {title: 'Joe Boe'},
              {title: 'Moe Moe'},
              {title: 'Toe Toe'}
            ]}
            buttonLabel='30:25'
            header='SJC21-Babelfish'
            meetingType='device'
          />
        </List>
      </div>
    );
  }
}
**/
SpaceListMeeting.defaultProps = {
  buttonLabel: '',
  buttonOnClick: null,
  className: '',
  childrenLeft: null,
  childrenRight: null,
  id: '',
  attendees: [],
  subheader: ''
};

module.exports = exports['default'];