<ng-container *transloco="let t; read: 'register'">
  <app-splash-container>
    <ng-container title><h2>{{t('title')}}</h2></ng-container>
    <ng-container body>
      <p>{{t('description')}}</p>
      <form [formGroup]="registerForm" (ngSubmit)="submit()">
        <div class="mb-3">
          <label for="username" class="form-label">{{t('username-label')}}</label>
          <input id="username" class="form-control" formControlName="username" type="text"
                 [class.is-invalid]="registerForm.get('username')?.invalid && registerForm.get('username')?.touched" aria-describedby="username-validations">
          <div id="username-validations" class="invalid-feedback" *ngIf="registerForm.dirty || registerForm.touched">
            <div *ngIf="registerForm.get('username')?.errors?.required">
              {{t('required-field')}}
            </div>
          </div>
        </div>

        <div class="mb-3" style="width:100%">
          <label for="email" class="form-label">{{t('email-label')}}</label>&nbsp;<i class="fa fa-info-circle" placement="right" [ngbTooltip]="emailTooltip" role="button" tabindex="0"></i>
          <ng-template #emailTooltip>{{t('email-tooltip')}}</ng-template>
          <span class="visually-hidden" id="email-help">
            <ng-container [ngTemplateOutlet]="emailTooltip"></ng-container>
          </span>
          <input class="form-control" type="email" inputmode="email" id="email" formControlName="email" required aria-describedby="email-help"
                 [class.is-invalid]="registerForm.get('email')?.invalid && registerForm.get('email')?.touched">
          <div id="email-validations" class="invalid-feedback" *ngIf="registerForm.dirty || registerForm.touched">
            <div *ngIf="registerForm.get('email')?.errors?.required">
              {{t('required-field')}}
            </div>
            <div *ngIf="registerForm.get('email')?.errors?.email">
              {{t('valid-email')}}
            </div>
          </div>
        </div>

        <div class="mb-3">
          <label for="password" class="form-label">Password</label>&nbsp;<i class="fa fa-info-circle" placement="right" [ngbTooltip]="passwordTooltip" role="button" tabindex="0"></i>
          <ng-template #passwordTooltip>
            {{t('password-validation')}}
          </ng-template>
          <span class="visually-hidden" id="password-help"><ng-container [ngTemplateOutlet]="passwordTooltip"></ng-container></span>
          <input id="password" class="form-control" maxlength="32" minlength="6" pattern="^.{6,32}$" formControlName="password"
                 type="password" aria-describedby="password-help" [class.is-invalid]="registerForm.get('password')?.invalid && registerForm.get('password')?.touched">
          <div id="password-validations" class="invalid-feedback" *ngIf="registerForm.dirty || registerForm.touched">
            <div *ngIf="registerForm.get('password')?.errors?.required">
              {{t('required-field')}}
            </div>
            <div *ngIf="registerForm.get('password')?.errors?.minlength || registerForm.get('password')?.errors?.maxLength || registerForm.get('password')?.errors?.pattern">
              {{t('password-validation')}}
            </div>
          </div>
        </div>

        <div class="float-end">
          <button class="btn btn-secondary alt" type="submit" [disabled]="!registerForm.valid">{{t('register')}}</button>
        </div>
      </form>
    </ng-container>
  </app-splash-container>

</ng-container>
