@using Iceshrimp.Frontend.Components
@using Iceshrimp.Frontend.Core.Services
@using Microsoft.AspNetCore.Components.Authorization
@inject IJSRuntime    Js;
@* ReSharper disable once UnusedMember.Local *@
@inject UpdateService UpdateSvc;
<ErrorBoundary>
    <ChildContent>
        <Router AppAssembly="@typeof(App).Assembly">
            <Found Context="routeData">
                <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
                    <NotAuthorized>
                        <RedirectToLogin/>
                    </NotAuthorized>
                </AuthorizeRouteView>
                @* <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/> *@
                <FocusOnNavigate RouteData="@routeData" Selector="h1"/>
            </Found>
            <NotFound>
                <PageTitle>Not found</PageTitle>
                <LayoutView Layout="@typeof(MainLayout)">
                    <p role="alert">Page not found.</p>
                </LayoutView>
            </NotFound>
        </Router>
    </ChildContent>
    <ErrorContent Context="Exception">
        <ErrorUi Exception="Exception"></ErrorUi>
    </ErrorContent>
</ErrorBoundary>

<HeadContent>
    <meta name="theme-color" content="@_backgroundColor"/>
</HeadContent>

@code {
    private string? _backgroundColor;

    protected override void OnInitialized()
    {
        _backgroundColor = ((IJSInProcessRuntime)Js).Invoke<string>("eval",
                                                                   "getComputedStyle(document.documentElement).getPropertyValue('--background-color')");
    }
}