"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.hasThumbnail = hasThumbnail;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _overrides = require("../helpers/overrides.js");

var _styledComponents = require("./styled-components.js");

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

function _extends() { _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; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function hasThumbnail(props) {
  return Boolean(props.thumbnail);
}

function Card(props) {
  var action = props.action,
      children = props.children,
      hasThumbnail = props.hasThumbnail,
      headerImage = props.headerImage,
      thumbnailSrc = props.thumbnail,
      title = props.title,
      overrides = props.overrides,
      otherProps = _objectWithoutProperties(props, ["action", "children", "hasThumbnail", "headerImage", "thumbnail", "title", "overrides"]);

  var ActionOverride = overrides.Action,
      BodyOverride = overrides.Body,
      ContentsOverride = overrides.Contents,
      HeaderImageOverride = overrides.HeaderImage,
      RootOverride = overrides.Root,
      ThumbnailOverride = overrides.Thumbnail,
      TitleOverride = overrides.Title;

  var Action = (0, _overrides.getOverride)(ActionOverride) || _styledComponents.Action;

  var Body = (0, _overrides.getOverride)(BodyOverride) || _styledComponents.Body;

  var Contents = (0, _overrides.getOverride)(ContentsOverride) || _styledComponents.Contents;

  var HeaderImage = (0, _overrides.getOverride)(HeaderImageOverride) || _styledComponents.HeaderImage;

  var Root = (0, _overrides.getOverride)(RootOverride) || _styledComponents.Root;

  var Thumbnail = (0, _overrides.getOverride)(ThumbnailOverride) || _styledComponents.Thumbnail;

  var Title = (0, _overrides.getOverride)(TitleOverride) || _styledComponents.Title;

  var $hasThumbnail = hasThumbnail(props);
  return _react.default.createElement(Root, _extends({
    "data-baseweb": "card"
  }, otherProps, (0, _overrides.getOverrideProps)(RootOverride)), headerImage && _react.default.createElement(HeaderImage, _extends({
    src: headerImage
  }, (0, _overrides.getOverrideProps)(HeaderImageOverride))), _react.default.createElement(Contents, (0, _overrides.getOverrideProps)(ContentsOverride), thumbnailSrc && _react.default.createElement(Thumbnail, _extends({
    src: thumbnailSrc
  }, (0, _overrides.getOverrideProps)(ThumbnailOverride))), title && _react.default.createElement(Title, _extends({
    $hasThumbnail: $hasThumbnail
  }, (0, _overrides.getOverrideProps)(TitleOverride)), title), _react.default.createElement(Body, (0, _overrides.getOverrideProps)(BodyOverride), children), action && _react.default.createElement(Action, (0, _overrides.getOverrideProps)(ActionOverride), action)));
}

Card.defaultProps = {
  action: null,
  children: null,
  hasThumbnail: hasThumbnail,
  overrides: {}
};
var _default = Card;
exports.default = _default;