'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

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

var CompositeAvatar = function CompositeAvatar(props) {
  var children = props.children,
      size = props.size,
      className = props.className;


  var isAvatar = function isAvatar() {
    return children.reduce(function (prev, child) {
      return prev && child.type.displayName === 'Avatar';
    }, true);
  };

  var getChildren = function getChildren() {
    if (children.length === 2 && isAvatar()) {
      return children;
    }
    throw new Error('Children should have 2 Avatar component');
  };

  return _react2.default.createElement(
    'div',
    {
      className: 'cui-composite-avatar' + (' cui-composite-avatar--' + size) + ('' + (className && ' ' + className || ''))
    },
    getChildren()
  );
};

CompositeAvatar.displayName = 'CompositeAvatar';

CompositeAvatar.defaultProps = {
  className: '',
  size: 'medium',
  children: null
};

exports.default = CompositeAvatar;
module.exports = exports['default'];