"use strict";

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _DataChecker = _interopRequireDefault(require("./utils/DataChecker"));

var _CivicCardLayoutFull = _interopRequireDefault(require("./CivicCardLayoutFull"));

var _ErrorBoundary = _interopRequireDefault(require("../ErrorBoundary/ErrorBoundary"));

var _cardMetaTypes = require("./cardMetaTypes");

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

var CivicCard = function CivicCard(_ref) {
  var cardMeta = _ref.cardMeta,
      data = _ref.data,
      isLoading = _ref.isLoading,
      Layout = _ref.Layout;
  return _react["default"].createElement(_ErrorBoundary["default"], {
    customMessage: "CivicCard: \"".concat(cardMeta(data).title, "\" failed to load")
  }, _react["default"].createElement(_DataChecker["default"], {
    data: cardMeta(data),
    dataAccessors: _cardMetaTypes.cardMetaKeys,
    optionalKeys: _cardMetaTypes.optionalCardMetaKeys,
    dataIsObject: true,
    message: "Invalid cardMeta"
  }, _react["default"].createElement(Layout, {
    cardMeta: cardMeta(data),
    isLoading: isLoading,
    data: data
  })));
};

CivicCard.propTypes = {
  cardMeta: _propTypes["default"].func.isRequired,
  data: _propTypes["default"].oneOfType([_propTypes["default"].shape({}), _propTypes["default"].array]),
  isLoading: _propTypes["default"].bool,
  Layout: _propTypes["default"].func
};
CivicCard.defaultProps = {
  Layout: _CivicCardLayoutFull["default"]
};
var _default = CivicCard;
exports["default"] = _default;