'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _getClassName2 = require('babel-plugin-react-css-modules/dist/browser/getClassName');

var _getClassName3 = _interopRequireDefault(_getClassName2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _styleModuleImportMap = {
  './card.scss': {
    'main': 'flive_card_main',
    'horizontal': 'flive_card_horizontal',
    'grey': 'flive_card_grey',
    'white': 'flive_card_white',
    'without-border': 'flive_card_without-border',
    'main--1-items-per-row': 'flive_card_main--1-items-per-row',
    'main--2-items-per-row': 'flive_card_main--2-items-per-row',
    'main--3-items-per-row': 'flive_card_main--3-items-per-row',
    'main--4-items-per-row': 'flive_card_main--4-items-per-row'
  }
};

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var Card = function Card(_ref) {
  var _classNames;

  var children = _ref.children,
      itemsPerRow = _ref.itemsPerRow,
      colorVariant = _ref.colorVariant,
      horizontal = _ref.horizontal,
      withoutBorder = _ref.withoutBorder,
      size = _ref.size,
      className = _ref.className,
      Component = _ref.component,
      rest = _objectWithoutProperties(_ref, ['children', 'itemsPerRow', 'colorVariant', 'horizontal', 'withoutBorder', 'size', 'className', 'component']);

  return _react2.default.createElement(
    Component,
    _extends({}, rest, {
      className: (className ? className + ' ' : '') + (0, _getClassName3.default)((0, _classnames2.default)('main', colorVariant, (_classNames = {}, _defineProperty(_classNames, 'main--' + itemsPerRow + '-items-per-row', itemsPerRow && !horizontal), _defineProperty(_classNames, 'without-border', withoutBorder), _defineProperty(_classNames, 'horizontal', horizontal), _classNames)), _styleModuleImportMap)
    }),
    _react2.default.Children.map(children, function (child) {
      if (!_react2.default.isValidElement(child)) {
        return child;
      }

      return _react2.default.cloneElement(child, {
        size: size,
        colorVariant: colorVariant,
        horizontal: horizontal
      });
    })
  );
};

var propTypes = {
  /** @ignore */
  className: _propTypes2.default.string,
  /** @ignore */
  children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.arrayOf(_propTypes2.default.element)]),
  component: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object, _propTypes2.default.func]),
  itemsPerRow: _propTypes2.default.number,
  colorVariant: _propTypes2.default.oneOf(['grey', 'white']),
  size: _propTypes2.default.oneOf(['sm', 'md', 'lg']),
  withoutBorder: _propTypes2.default.bool,
  horizontal: _propTypes2.default.bool
};

var defaultProps = {
  className: undefined,
  children: null,
  itemsPerRow: 1,
  colorVariant: 'grey',
  size: 'md',
  withoutBorder: false,
  horizontal: false,
  component: 'div'
};

Card.propTypes = propTypes;
Card.defaultProps = defaultProps;
Card.componentName = 'Card';

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