//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// TypeScript support for Blazor-WASM application | Author: Sergei Y.Kitaev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Fatal breakdown functions for access from WASM (static class):
class FatalBreakdown {
    static ShowWasmErrorReloadSPA(message, traceError = true) {
        let errorText = HOps.NullSubst(message, 'Undefined error in SPA.');
        traceError = HOps.BoolDefaultTrue(traceError);
        if (traceError)
            console.error(errorText);
        let reloadPage = page_loaded && App.IsReleaseConfiguration();
        let leavePageForDebug = !reloadPage;
        errorText += leavePageForDebug ?
            '\n\nFurther app.functioning is incorrect; reload the page maually.' +
                '\n(See error details in browser debug-console.)'
            : '\n\nWeb-application will be reloaded (SPA).';
        Breakdown.SetUseDefaultErrorReporting();
        alert(errorText);
        if (reloadPage)
            window.location.href = ""; // reload from root
    }
    static BlockSPA() {
        AFXUI.Invoke('wasm_FatalBreakdown_BlockSPA');
    }
    static HandlePageError(message, url, line, col, errorObj) {
        if (FatalBreakdown._WasBreakdownInvoked_)
            return false; // do not filter default error output
        FatalBreakdown._WasBreakdownInvoked_ = true;
        let errorText = message ?
            'Error on web-page.' :
            'Undefined error on web-page.';
        if (url)
            errorText += '\nURL: ' + url;
        /*
              if (line)
                 errorText += '\nLine: '+line
        */
        let errorObjectAdded = false;
        if (errorObj) {
            try {
                errorText += '\n\n' + errorObj;
                errorObjectAdded = true;
            }
            catch (_a) { }
        }
        if (message && !errorObjectAdded)
            errorText += '\n\n' + message;
        FatalBreakdown.BlockSPA();
        FatalBreakdown.ShowWasmErrorReloadSPA(errorText);
        return true; // filter default error output (allready printed in "ShowWasmErrorReloadSPA")
    }
} // FatalBreakdown
FatalBreakdown._WasBreakdownInvoked_ = false;
//==================================================================================================
// FATAL BREAKDOWN — FUNCTIONS:
//--------------------------------------------------------------------------------------------------
function FatalBreakdown_ShowWasmErrorReloadSPA(message) {
    FatalBreakdown.ShowWasmErrorReloadSPA(message, false);
}
//==================================================================================================
//# sourceMappingURL=FatalBreakdown.js.map