"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorBoundary = exports.ErrorMessage = void 0;
const React = require("react");
const ErrorMessage = () => (React.createElement("div", { css: {
        margin: 15,
        borderRadius: 4,
        border: '1px solid rgba(150, 0, 0, 0.35)',
        color: 'rgba(150, 0, 0, 1)',
        backgroundColor: 'rgba(255, 0, 0, 0.1)',
        padding: 15,
        fontSize: 14,
        textAlign: 'center',
    } },
    "Oh no! We had an error :( Try",
    ' ',
    React.createElement("a", { onClick: () => location.reload(), css: { color: 'steelblue', cursor: 'pointer', fontWeight: 'bold' } }, "refreshing this page"),
    ' ',
    "and",
    ' ',
    React.createElement("a", { css: { color: 'steelblue', cursor: 'pointer', fontWeight: 'bold' }, onClick: () => {
            window.Intercom('showNewMesage', 'I am getting an error - please help');
        } }, "chat us"),
    ' ',
    "or contact",
    ' ',
    React.createElement("a", { css: { color: 'steelblue', cursor: 'pointer', fontWeight: 'bold' }, target: "_blank", href: "mailto:support@builder.io" }, "support@builder.io"),
    ' ',
    "if this continues"));
exports.ErrorMessage = ErrorMessage;
/**
 * Provides error boundaries for safety (one component errors won't crash the whole app)
 */
class ErrorBoundary extends React.Component {
    constructor() {
        super(...arguments);
        this.state = { hasError: false };
    }
    static getDerivedStateFromError() {
        // Update state so the next render will show the fallback UI.
        return { hasError: true };
    }
    render() {
        if (this.state.hasError) {
            return React.createElement(exports.ErrorMessage, null);
        }
        return this.props.children;
    }
}
exports.ErrorBoundary = ErrorBoundary;
//# sourceMappingURL=error-boundary.js.map