import React, { Component } from 'react';
import { Adornment } from '../UI';
import { Sticky } from '../UI';
import { Typography } from '../UI/dataDisplay/typography';
class ErrorBoundary extends Component {
    constructor(props) {
        super(props);
        this.state = {
            hasError: false,
        };
        if (import.meta.env && import.meta.env.DEV && import.meta.hot) {
            // reset the error boundary when there are HMR changes detected
            import.meta.hot.on('vite:beforeUpdate', () => {
                // If this boundary caught an error, reset it on HMR
                if (this.state.hasError) {
                    this.setState({ hasError: false });
                }
            });
        }
    }
    static getDerivedStateFromError(error) {
        return {
            hasError: true,
        };
    }
    componentDidCatch(error, info) {
        console.log(error);
        console.log(info);
    }
    render() {
        const { hasError } = this.state;
        const { children } = this.props;
        if (hasError) {
            return (React.createElement("div", { style: { height: "100%", display: "flex" } }, React.createElement("div", null, React.createElement(Adornment, { color: "error" })), React.createElement("div", { style: { marginLeft: 32 } }, React.createElement("div", { style: { marginTop: 64 } }, React.createElement(Typography, { style: { margin: 8 }, variant: "h3" }, "A fatal error has occurred."), React.createElement(Typography, { style: { margin: 8 }, variant: "body2" }, "We are sorry this happened. A log of this error has been recorded and sent to support")), React.createElement("div", { style: { marginTop: 118, display: "flex", flexDirection: "column", alignItems: "flex-start" } }, React.createElement(Sticky, { text: "Create a support ticket", size: "small", color: "success" }), React.createElement(Sticky, { text: "Report this bug", size: "small", color: "warning" }), React.createElement(Sticky, { text: "View Documents", size: "small", color: "info" })))));
        }
        return children;
    }
}
export default ErrorBoundary;
//# sourceMappingURL=ErrorBoundary.js.map