import * as React from "react";
import { toPx } from "@microsoft/fast-jss-utilities";
import manageJss from "@microsoft/fast-jss-manager-react";
const styles = {
    errorBoundary: {
        display: "flex",
        flexDirection: "column",
        justifyContent: "center",
        height: "100%"
    },
    errorBoundary_error: {
        fontSize: toPx(15),
        marginTop: "0",
        color: "red"
    },
    errorBoundary_notification: {
        fontSize: toPx(18),
        fontWeight: "700"
    }
};
class ErrorBoundary extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            hasError: false,
            error: void 0
        };
    }
    componentDidCatch(error, info) {
        const MISSING_ERROR = "Error was swallowed during propagation.";
        this.setState({
            hasError: true,
            error: error || new Error(MISSING_ERROR)
        });
    }
    render() {
        if (this.state.hasError && this.state.error) {
            return (React.createElement("div", { className: this.props.managedClasses.errorBoundary },
                React.createElement("p", { className: this.props.managedClasses.errorBoundary_notification }, "Something went wrong."),
                React.createElement("p", { className: this.props.managedClasses.errorBoundary_error }, `${this.state.error}`)));
        }
        return this.props.children;
    }
}
export default manageJss(styles)(ErrorBoundary);
//# sourceMappingURL=error-boundary.js.map