"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ErrorBoundary = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _helpers = require("./helpers");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
class InternalErrorBoundary extends _react.default.Component {
  constructor(props) {
    super(props);
    this.state = {
      error: undefined
    };
  }
  componentDidCatch(error) {
    (0, _helpers.trackError)((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error', error === null || error === void 0 ? void 0 : error.stack);
    this.setState({
      error
    });
  }
  render() {
    const {
      children
    } = this.props;
    const {
      error
    } = this.state;
    if (error) throw error;
    return children || null;
  }
}
InternalErrorBoundary.displayName = 'core:components:ErrorBoundary';
InternalErrorBoundary.propTypes = {
  children: _propTypes.default.node
};
const ErrorBoundary = props => /*#__PURE__*/_react.default.createElement(InternalErrorBoundary, props);
exports.ErrorBoundary = ErrorBoundary;
ErrorBoundary.displayName = InternalErrorBoundary.displayName;
ErrorBoundary.propTypes = InternalErrorBoundary.propTypes;
//# sourceMappingURL=Core.ErrorBoundary.js.map