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; };

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; }

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { tagPropType, mapToCssModules, deprecated } from './Shared/helper.js';
import CCardBody from './CCardBody';
import CCardHeader from './CCardHeader';
import CCardFooter from './CCardFooter';

//component - CoreUI / CCard

var CCard = function CCard(props) {
  var Tag = props.tag,
      children = props.children,
      className = props.className,
      cssModule = props.cssModule,
      custom = props.custom,
      innerRef = props.innerRef,
      color = props.color,
      textColor = props.textColor,
      borderColor = props.borderColor,
      accentColor = props.accentColor,
      headerSlot = props.headerSlot,
      footerSlot = props.footerSlot,
      align = props.align,
      bodyClassName = props.bodyClassName,
      bodyProps = props.bodyProps,
      attributes = _objectWithoutProperties(props, ['tag', 'children', 'className', 'cssModule', 'custom', 'innerRef', 'color', 'textColor', 'borderColor', 'accentColor', 'headerSlot', 'footerSlot', 'align', 'bodyClassName', 'bodyProps']);

  //render

  var classes = mapToCssModules(classNames(className, 'card', align ? 'text-' + align : false, textColor ? 'text-' + textColor : false, color ? 'bg-' + color : false, borderColor ? 'border-' + borderColor : false, accentColor ? 'card-accent-' + accentColor : false), cssModule);

  if (!custom) return React.createElement(
    Tag,
    _extends({}, attributes, { className: classes, ref: innerRef }),
    headerSlot ? React.createElement(
      CCardHeader,
      null,
      headerSlot
    ) : '',
    React.createElement(
      CCardBody,
      _extends({}, bodyProps, { className: bodyClassName }),
      children
    ),
    footerSlot ? React.createElement(
      CCardFooter,
      null,
      footerSlot
    ) : ''
  );

  return React.createElement(Tag, _extends({}, attributes, { className: classes, ref: innerRef, children: children }));
};

CCard.sharedPropTypes = {
  align: PropTypes.string,
  color: PropTypes.string,
  borderColor: PropTypes.string,
  textColor: PropTypes.string,
  accentColor: PropTypes.string,
  bodyClassName: PropTypes.string,
  bodyProps: PropTypes.object
};

CCard.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, CCard.sharedPropTypes, {
  tag: tagPropType,
  className: PropTypes.string,
  cssModule: PropTypes.object,
  custom: PropTypes.bool,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  align: PropTypes.string,
  color: PropTypes.string,
  borderColor: PropTypes.string,
  textColor: PropTypes.string,
  accentColor: PropTypes.string,
  bodyClassName: PropTypes.string,
  bodyProps: PropTypes.object,
  headerSlot: PropTypes.node,
  footerSlot: PropTypes.node
}) : {};

CCard.defaultProps = {
  tag: 'div'
};

export default CCard;