{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

{{#if this.cspError}}
  <Hds::Alert @type="page" @color="critical" data-test-page-error as |A|>
    <A.Description>{{this.cspError}}</A.Description>
  </Hds::Alert>
{{/if}}

{{#if this.mfaAuthData}}
  <Mfa::MfaForm
    @authData={{this.mfaAuthData}}
    @clusterId={{@cluster.id}}
    @loginAndTransition={{@loginAndTransition}}
    @onCancel={{this.onCancelMfa}}
  />
{{else}}
  <SplashPage>
    <:header>
      {{#if @oidcProviderQueryParam}}
        <div class="box is-shadowless is-flex-v-centered" data-test-auth-logo>
          <LogoEdition aria-label="Sign in with Hashicorp Vault" role="img" />
        </div>
      {{else}}
        <div class="is-flex-v-centered has-bottom-margin-xxl">
          <div class="brand-icon-large">
            <Icon @name="vault" @size="24" @stretched={{true}} />
          </div>
        </div>
        <h1 class="title is-3">
          Sign in to Vault
        </h1>
      {{/if}}
    </:header>

    <:content>
      <Auth::FormTemplate
        @alternateView={{this.formViews.alternateView}}
        @cluster={{@cluster}}
        @defaultView={{this.formViews.defaultView}}
        @formQueryParams={{this.formQueryParams}}
        @handleAuthResponse={{this.onAuthResponse}}
        @initialFormState={{this.initialFormState}}
        @loginTransitionIsRunning={{@loginAndTransition.isRunning}}
        @visibleMountTypes={{this.visibleMountTypes}}
      >
        {{! yielded for accessibility so namespace submits as an input of the <form> element }}
        {{#if (has-feature "Namespaces")}}
          <Auth::NamespaceInput
            @disabled={{if @oidcProviderQueryParam true false}}
            @handleNamespaceUpdate={{@onNamespaceUpdate}}
            @namespaceQueryParam={{@namespaceQueryParam}}
            @shouldRefocusNamespaceInput={{@shouldRefocusNamespaceInput}}
          />
        {{/if}}
      </Auth::FormTemplate>
    </:content>

    <:footer>
      <div class="has-short-padding">
        <p class="help has-text-grey-dark" data-test-auth-helptext>
          {{#if @oidcProviderQueryParam}}
            Once you log in, you will be redirected back to your application. If you require login credentials, contact your
            administrator.
          {{else}}
            Contact your administrator for login credentials.
          {{/if}}
        </p>
      </div>
    </:footer>
  </SplashPage>
{{/if}}