@using Zap.BI.Portal.Helpers
@using Zap.JsonSerialization
@model Zap.BI.Portal.Controllers.LoginViewModel

@section Css
{
    @if (Model.IsCustomLogo)
    {
        <style>body { background: @Html.Raw(Model.BackgroundColor) !important; }</style>
    }
    else
    {
        <style>body { background: var(--splash-background, @Html.Raw(Model.BackgroundColor)); }</style>
    }
    <style>
        #app { height: 100%; }
    </style>
    <style>@Model.SplashCss</style>
}

@section Scripts
{
    <script defer src="@Url.Action("ClientObjects", new { hash = Model.ClientObjectsScriptsHash })" type="text/javascript"></script>
    <script defer src="@Url.Action("File", "Content", new { path = "BI/Portal/dist/login.js" })"></script>
}

@Html.AntiForgeryToken()

<div id="app">
</div>

@Model.SplashHtml

@*Needs to come after splash HTML*@
<script> @Model.SplashScript </script>

<script>
    if (Object.create)
        window.addEventListener('load', () => boot(document.getElementById('app'), {
                authUrl: '@Url.Action("Authenticate")',
                challengeUrl: @Html.RawJson(Url.Action("Challenge", new { returnUrl = Model.ReturnUrl, isPopup = Model.IsPopup })),
                returnUrl: @Html.RawJson(Model.ReturnUrl),
                headerImage: '@Url.Action("LoginScreenIcon", "Branding")',
                isCustomLogo: @Html.RawJson(Model.IsCustomLogo),
                isPopup: @Model.IsPopup.ZapToJson(),
                authSupportsForm: @Model.AuthSupportsForm.ZapToJson()
            }));
    else
        location.href = '@Url.Action("UnsupportedDocumentMode", "Error", new
                             {
                                 originalUrl = Request.RawUrl
                             }, Request.Url.Scheme)';
</script>
