<form
  [formGroup]="formGroup"
  [bitSubmit]="submit"
  bit-dialog
  [loading]="loading()"
  [title]="policy.v2?.name ?? policy.name | i18n"
  subtitle=""
>
  <span bitBadge [variant]="policyEnabled() ? 'success' : 'secondary'" bitDialogHeaderEnd>{{
    (policyEnabled() ? "on" : "off") | i18n
  }}</span>
  <ng-container bitDialogContent>
    @if (loading()) {
      <bit-spinner></bit-spinner>
    } @else {
      @if (policy.v2?.prerequisiteKey) {
        <bit-callout type="info" [title]="'prerequisite' | i18n">
          {{ policy.v2.prerequisiteKey | i18n }}
          @if (policy.v2.prerequisiteLinkHref && policy.v2.prerequisiteLinkTextKey) {
            <a bitLink [href]="policy.v2.prerequisiteLinkHref" target="_blank" rel="noreferrer">
              {{ policy.v2.prerequisiteLinkTextKey | i18n }}
            </a>
          }
        </bit-callout>
      }
      @if (policy.warningKey) {
        <bit-callout type="warning">{{ policy.warningKey | i18n }}</bit-callout>
      }
      @if (policy.v2?.showDescription ?? policy.showDescription) {
        <p bitTypography="body1">{{ policy.v2?.description ?? policy.description | i18n }}</p>
      }
      <ng-template #policyForm></ng-template>
    }
  </ng-container>
  <ng-container bitDialogFooter>
    <button bitButton buttonType="primary" [disabled]="saveDisabled()" bitFormButton type="submit">
      {{ "save" | i18n }}
    </button>
  </ng-container>
</form>
