import { extend, mergeData } from '../../vue';
import { NAME_CARD_BODY } from '../../constants/components';
import { PROP_TYPE_ARRAY_OBJECT_STRING, PROP_TYPE_BOOLEAN } from '../../constants/props';
import { sortKeys } from '../../utils/object';
import { makePropsConfigurable, copyProps, prefixPropName, makeProp, pluckProps } from '../../utils/props';
import { props as props$3 } from '../../mixins/card';
import { props as props$1, BCardTitle } from './card-title';
import { props as props$2, BCardSubTitle } from './card-sub-title';

// --- Props ---

const props = makePropsConfigurable(sortKeys({
  ...props$1,
  ...props$2,
  ...copyProps(props$3, prefixPropName.bind(null, 'body')),
  bodyClass: makeProp(PROP_TYPE_ARRAY_OBJECT_STRING),
  overlay: makeProp(PROP_TYPE_BOOLEAN, false)
}), NAME_CARD_BODY);

// --- Main component ---

// @vue/component
const BCardBody = /*#__PURE__*/extend({
  name: NAME_CARD_BODY,
  functional: true,
  props,
  render(h, _ref) {
    let {
      props,
      data,
      children
    } = _ref;
    const {
      bodyBgVariant,
      bodyBorderVariant,
      bodyTextVariant
    } = props;
    let $title = h();
    if (props.title) {
      $title = h(BCardTitle, {
        props: pluckProps(props$1, props)
      });
    }
    let $subTitle = h();
    if (props.subTitle) {
      $subTitle = h(BCardSubTitle, {
        props: pluckProps(props$2, props),
        class: ['mb-2']
      });
    }
    return h(props.bodyTag, mergeData(data, {
      staticClass: 'card-body',
      class: [{
        'card-img-overlay': props.overlay,
        [`bg-${bodyBgVariant}`]: bodyBgVariant,
        [`border-${bodyBorderVariant}`]: bodyBorderVariant,
        [`text-${bodyTextVariant}`]: bodyTextVariant
      }, props.bodyClass]
    }), [$title, $subTitle, children]);
  }
});

export { BCardBody, props };
