<commit_before><!-- Hide modal for children under 19. -->
<form #formRef='ngForm' novalidate>

  <button type="button" class="btn btn-default btn-xs pull-right" (click)="cancelDependent()" [innerHTML]="lang('./en/index.js').clearButton[person.relationship]">
  </button>

  <h2 [innerHTML]="lang('./en/index.js').sectionTitle[person.relationship]"></h2>
  <p [innerHTML]="lang('./en/index.js').sectionBody[person.relationship]"></p>

  <div class="row">
    <div class="col-lg-6 form-group" [ngClass]="{'has-error': showError && (person.isExistingBeneficiary === undefined || person.isExistingBeneficiary === null)}" >
  <label #firstFocus  for="isExistingBeneficiary-{{person.id}}" [innerHtml]="lang('./en/index.js').isExistingBeneficiaryQuestion[person.relationship]"  class="control-label"></label>


  <msp-toggle #isExistingBeneficiary [id]="'isExistingBeneficiary-'+ person.id" (dataChange)="handleBeneficiaryChange($event)" [(data)]="person.isExistingBeneficiary"></msp-toggle>

      <div *ngIf='showError && (person.isExistingBeneficiary === undefined || person.isExistingBeneficiary === null)'
           role="alert" aria-live="assertive">
        <div class="text-danger"
             [innerHtml]="lang('./en/index.js').mustAnswerQuestion"></div>
      </div>
    </div>

  </div>
  <msp-status-in-canada-radio [showError]="showError" [showServicesCardModal]="true"
    *ngIf="person.isExistingBeneficiary===false"
    [person]='person' (onChange)="change($event)">
  </msp-status-in-canada-radio>  


  <!-- Show this form to existing beneficiary's immediately, and only show it to
  new beneficiaries once they have set their status. -->
  <ng-container *ngIf="person.isExistingBeneficiary || (person.status || person.status === 0)">
    
    <msp-account-personal-details 
      [person]='person'  [showError]="showError"
      [id]='person.id'
      (onChange)="change($event)" 
      embedded=true
      [requirePHN]="person.isExistingBeneficiary">
    </msp-account-personal-details>

    <!-- Spouse-only Section, marriage date etc. -->
    <ng-container *ngIf="person.relationship === Relationship.Spouse">
      <div class="row">
        <div class="col-lg-4 form-group"
          [ngClass]="{'has-error': !formRef.controls['spousePrevLastname-'+person.id]?.valid && (prevNameRef.touched || showError)}">
          
          <label for='addSpousePreviousLastName-{{person.id}}' [innerHTML]="lang('./en/index.js').previousName"></label>
          <input type="text" 
            name="spousePrevLastname-{{person.id}}" 
            class="form-control" 
            id='addSpousePreviousLastName-{{person.id}}' 
            maxlength="30"
            [pattern]="Person.NameRegEx"
            #prevNameRef="ngModel"
            [(ngModel)]="person.prevLastName">
          
          <div *ngIf='prevNameRef.touched || showError' role="alert" aria-live="assertive">
              <div class="text-danger" *ngIf="prevNameRef.errors?.pattern"[innerHtml]="lang('./en/index.js').previousNameErrorPattern"></div>
          </div>

        </div>
        <div class="col-lg-4">
          <msp-date
            [label]="lang('./en/index.js').marriageDate"
            [showError]='showError'
            [(date)]="person.marriageDate"
            required=false
          ></msp-date>
        </div>
      </div>
    </ng-container> 
    <!-- End Spouse-only Section -->

    <!-- School information for child 19 to 24 -->
    <ng-container *ngIf="person.relationship === Relationship.Child19To24">
      <div class="row form-group">
        <div class="col-lg-4">
            <label for='schoolName-{{person.id}}' [innerHTML]="lang('./en/index.js').schoolName"></label>

            <input type="text" 
            name="schoolName-{{person.id}}" 
            class="form-control" 
            id='schoolName-{{person.id}}' 
            maxlength="30"
            #schoolNameRef="ngModel"
            [pattern]="Person.NameRegEx"
            required
            [(ngModel)]="person.schoolName">

            <div *ngIf='schoolNameRef.touched || showError' role="alert" aria-live="assertive">
                <div class="text-danger" *ngIf="schoolNameRef.errors?.required"
                [innerHtml]="lang('./en/index.js').schoolNameRequired"></div>
                <div class="text-danger" *ngIf="schoolNameRef.errors?.pattern"[innerHtml]="lang('./en/index.js').previousNameErrorPattern"></div>
            </div>
        </div>
      </div>

      <div class="row form-group" [ngClass]="{'has-error': showError && (person.schoolOutsideOfBC === undefined || person.schoolOutsideOfBC === null)}">
        <div class="col-lg-4">
          <label for="isOutsideBC-{{person.id}}" [innerHtml]="lang('./en/index.js').schoolOutsideBC" class="control-label"></label>
      
          <msp-toggle [id]="'isOutsideBC-'+ person.id" [(data)]="person.schoolOutsideOfBC" (dataChange)="outsideBCchange($event)" ></msp-toggle>
        </div>

        <div class="col-lg-4 form-inline" *ngIf="person.schoolOutsideOfBC">
          <msp-date
            [label]="lang('./en/index.js').departureDate"
            [showError]='showError' [futureDate]="true"
            [(date)]="person.studiesDepartureSimple"
          ></msp-date>
        </div>
      </div>

      <msp-address #schoolAddress
      [mailingAddressHeading]="lang('./en/index.js').schoolAddressLabel"
      [mailingAddress]="person.schoolAddress"
      [mailingOnly]="true"
      [showError] = "showError"
      [isBCPostalCode]='!person.schoolOutsideOfBC'
      [hideProvinceAndCountry]='!person.schoolOutsideOfBC'
      ></msp-address>

      <div class="row">
        <div class="col-lg-6">
          <msp-date #studiesBegin
            [label]="lang('./en/index.js').studiesBegin"
            [showError]='showError'
            [(date)]="person.studiesBeginSimple" [futureDate]="true"
               ></msp-date>
        </div>

        <div class="col-lg-6">
          <msp-date #studiesFinishedSimple
            [label]="lang('./en/index.js').studiesFinish"
                    [showError]='showError' (onChange) = "onChange.emit($event)" [futureDate]="true"
                    [(date)]="person.studiesFinishedSimple"
          ></msp-date>
          <div *ngIf='person.isStudyDatesInValid'>
            <div class="text-danger"[innerHtml]="lang('./en/index.js').dateStudiesStartBeforeEndError"></div>
          </div>
        </div>
      </div>

    </ng-container>

    <!-- Contains all questions if the user is a new beneficiary. -->
    <msp-add-new-dependent-beneficiary   [showError]='showError'
      *ngIf="(!person.isExistingBeneficiary && (person.status || person.status === 0))"
      [person]="person"   (onChange)="change($event)"
    ></msp-add-new-dependent-beneficiary>

  </ng-container> <!-- end dependent form container -->

</form>

<hr class='strong-hr'><commit_msg>spouse prev last name not triggering the storing into session<commit_after><!-- Hide modal for children under 19. -->
<form #formRef='ngForm' novalidate>

  <button type="button" class="btn btn-default btn-xs pull-right" (click)="cancelDependent()" [innerHTML]="lang('./en/index.js').clearButton[person.relationship]">
  </button>

  <h2 [innerHTML]="lang('./en/index.js').sectionTitle[person.relationship]"></h2>
  <p [innerHTML]="lang('./en/index.js').sectionBody[person.relationship]"></p>

  <div class="row">
    <div class="col-lg-6 form-group" [ngClass]="{'has-error': showError && (person.isExistingBeneficiary === undefined || person.isExistingBeneficiary === null)}" >
  <label #firstFocus  for="isExistingBeneficiary-{{person.id}}" [innerHtml]="lang('./en/index.js').isExistingBeneficiaryQuestion[person.relationship]"  class="control-label"></label>


  <msp-toggle #isExistingBeneficiary [id]="'isExistingBeneficiary-'+ person.id" (dataChange)="handleBeneficiaryChange($event)" [(data)]="person.isExistingBeneficiary"></msp-toggle>

      <div *ngIf='showError && (person.isExistingBeneficiary === undefined || person.isExistingBeneficiary === null)'
           role="alert" aria-live="assertive">
        <div class="text-danger"
             [innerHtml]="lang('./en/index.js').mustAnswerQuestion"></div>
      </div>
    </div>

  </div>
  <msp-status-in-canada-radio [showError]="showError" [showServicesCardModal]="true"
    *ngIf="person.isExistingBeneficiary===false"
    [person]='person' (onChange)="change($event)">
  </msp-status-in-canada-radio>  


  <!-- Show this form to existing beneficiary's immediately, and only show it to
  new beneficiaries once they have set their status. -->
  <ng-container *ngIf="person.isExistingBeneficiary || (person.status || person.status === 0)">
    
    <msp-account-personal-details 
      [person]='person'  [showError]="showError"
      [id]='person.id'
      (onChange)="change($event)" 
      embedded=true
      [requirePHN]="person.isExistingBeneficiary">
    </msp-account-personal-details>

    <!-- Spouse-only Section, marriage date etc. -->
    <ng-container *ngIf="person.relationship === Relationship.Spouse">
      <div class="row">
        <div class="col-lg-4 form-group"
          [ngClass]="{'has-error': !formRef.controls['spousePrevLastname-'+person.id]?.valid && (prevNameRef.touched || showError)}">
          
          <label for='addSpousePreviousLastName-{{person.id}}' [innerHTML]="lang('./en/index.js').previousName"></label>
          <input type="text" 
            name="spousePrevLastname-{{person.id}}" 
            class="form-control" 
            id='addSpousePreviousLastName-{{person.id}}' 
            maxlength="30"
            [pattern]="Person.NameRegEx"
            #prevNameRef="ngModel"
            [(ngModel)]="person.prevLastName"   (ngModelChange)="change($event)" >
          
          <div *ngIf='prevNameRef.touched || showError' role="alert" aria-live="assertive">
              <div class="text-danger" *ngIf="prevNameRef.errors?.pattern"[innerHtml]="lang('./en/index.js').previousNameErrorPattern"></div>
          </div>

        </div>
        <div class="col-lg-4">
          <msp-date
            [label]="lang('./en/index.js').marriageDate"
            [showError]='showError'
            [(date)]="person.marriageDate"
            required=false
          ></msp-date>
        </div>
      </div>
    </ng-container> 
    <!-- End Spouse-only Section -->

    <!-- School information for child 19 to 24 -->
    <ng-container *ngIf="person.relationship === Relationship.Child19To24">
      <div class="row form-group">
        <div class="col-lg-4">
            <label for='schoolName-{{person.id}}' [innerHTML]="lang('./en/index.js').schoolName"></label>

            <input type="text" 
            name="schoolName-{{person.id}}" 
            class="form-control" 
            id='schoolName-{{person.id}}' 
            maxlength="30"
            #schoolNameRef="ngModel"
            [pattern]="Person.NameRegEx"
            required
            [(ngModel)]="person.schoolName">

            <div *ngIf='schoolNameRef.touched || showError' role="alert" aria-live="assertive">
                <div class="text-danger" *ngIf="schoolNameRef.errors?.required"
                [innerHtml]="lang('./en/index.js').schoolNameRequired"></div>
                <div class="text-danger" *ngIf="schoolNameRef.errors?.pattern"[innerHtml]="lang('./en/index.js').previousNameErrorPattern"></div>
            </div>
        </div>
      </div>

      <div class="row form-group" [ngClass]="{'has-error': showError && (person.schoolOutsideOfBC === undefined || person.schoolOutsideOfBC === null)}">
        <div class="col-lg-4">
          <label for="isOutsideBC-{{person.id}}" [innerHtml]="lang('./en/index.js').schoolOutsideBC" class="control-label"></label>
      
          <msp-toggle [id]="'isOutsideBC-'+ person.id" [(data)]="person.schoolOutsideOfBC" (dataChange)="outsideBCchange($event)" ></msp-toggle>
        </div>

        <div class="col-lg-4 form-inline" *ngIf="person.schoolOutsideOfBC">
          <msp-date
            [label]="lang('./en/index.js').departureDate"
            [showError]='showError' [futureDate]="true"
            [(date)]="person.studiesDepartureSimple"
          ></msp-date>
        </div>
      </div>

      <msp-address #schoolAddress
      [mailingAddressHeading]="lang('./en/index.js').schoolAddressLabel"
      [mailingAddress]="person.schoolAddress"
      [mailingOnly]="true"
      [showError] = "showError"
      [isBCPostalCode]='!person.schoolOutsideOfBC'
      [hideProvinceAndCountry]='!person.schoolOutsideOfBC'
      ></msp-address>

      <div class="row">
        <div class="col-lg-6">
          <msp-date #studiesBegin
            [label]="lang('./en/index.js').studiesBegin"
            [showError]='showError'
            [(date)]="person.studiesBeginSimple" [futureDate]="true"
               ></msp-date>
        </div>

        <div class="col-lg-6">
          <msp-date #studiesFinishedSimple
            [label]="lang('./en/index.js').studiesFinish"
                    [showError]='showError' (onChange) = "onChange.emit($event)" [futureDate]="true"
                    [(date)]="person.studiesFinishedSimple"
          ></msp-date>
          <div *ngIf='person.isStudyDatesInValid'>
            <div class="text-danger"[innerHtml]="lang('./en/index.js').dateStudiesStartBeforeEndError"></div>
          </div>
        </div>
      </div>

    </ng-container>

    <!-- Contains all questions if the user is a new beneficiary. -->
    <msp-add-new-dependent-beneficiary   [showError]='showError'
      *ngIf="(!person.isExistingBeneficiary && (person.status || person.status === 0))"
      [person]="person"   (onChange)="change($event)"
    ></msp-add-new-dependent-beneficiary>

  </ng-container> <!-- end dependent form container -->

</form>

<hr class='strong-hr'>
{'fraction_non_alphanumeric': 0.1851100811123986, 'fraction_numerical': 0.0037659327925840093, 'mean_word_length': 2.8964446952595937, 'pattern_counts': {'":': 0, '<': 195, '<?xml version=': 0, '>': 195, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4942541', 'n_tokens_mistral': 4481, 'n_tokens_neox': 4206, 'n_words': 603}