<!--

    Copyright © 2016-2026 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section [formGroup]="parentForm">
  <mat-form-field class="mat-block flex-1" appearance="outline">
    @if (isDeviceSetting) {
      <mat-label>{{ "device-profile.power-saving-mode" | translate }}</mat-label>
    }
    <mat-select formControlName="powerMode">
      @if (isDeviceSetting) {
        <mat-option [value]="null">{{ "device-profile.power-saving-mode-type.default" | translate }}</mat-option>
      }
      @for (powerMod of powerMods; track powerMod) {
        <mat-option [value]="powerMod">
          {{ powerModeTranslationMap.get(powerMod) | translate}}
        </mat-option>
      }
    </mat-select>
  </mat-form-field>
  @if (parentForm.get('powerMode').value === 'E_DRX') {
    <section class="mat-block flex-1">
      <tb-time-unit-select [labelText]="'device-profile.edrx-cycle'"
                           [requiredText]="'device-profile.edrx-cycle-required'"
                           [patternText]="'device-profile.edrx-cycle-pattern'"
                           [minTime]="5120"
                           [minText]="'device-profile.edrx-cycle-min'"
                           appearance="outline"
                           formControlName="edrxCycle">
      </tb-time-unit-select>
      <tb-time-unit-select [labelText]="'device-profile.paging-transmission-window'"
                           [requiredText]="'device-profile.paging-transmission-window-required'"
                           [patternText]="'device-profile.paging-transmission-window-pattern'"
                           [minTime]="1280"
                           [minText]="'device-profile.paging-transmission-window-min'"
                           appearance="outline"
                           formControlName="pagingTransmissionWindow">
      </tb-time-unit-select>
    </section>
  } @else if (parentForm.get('powerMode').value === 'PSM') {
    <tb-time-unit-select [labelText]="'device-profile.psm-activity-timer'"
                         [requiredText]="'device-profile.psm-activity-timer-required'"
                         [patternText]="'device-profile.psm-activity-timer-pattern'"
                         [minTime]="1280"
                         [minText]="'device-profile.psm-activity-timer-min'"
                         appearance="outline"
                         formControlName="psmActivityTimer">
    </tb-time-unit-select>
  }
</section>
