<!--

    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]="timeUnitSelectFormGroup" class="flex flex-row xs:flex-col gt-xs:gap-2">
  <mat-form-field class="mat-block flex-1" [appearance]="appearance">
    <mat-label>{{ labelText | translate }}</mat-label>
    <input matInput type="number" min="0" formControlName="time" required>
    @if (timeUnitSelectFormGroup.get('time').hasError('required')) {
      <mat-error>
        {{ requiredText | translate }}
      </mat-error>
    }
    @if (timeUnitSelectFormGroup.get('time').hasError('pattern')) {
      <mat-error>
        {{ patternText | translate }}
      </mat-error>
    }
    @if (timeUnitSelectFormGroup.get('time').hasError('min')) {
      <mat-error>
        {{ (minText || patternText) | translate : {min: minTime/1000} }}
      </mat-error>
    }
  </mat-form-field>
  <mat-form-field class="mat-block flex-1" [appearance]="appearance">
    <mat-label translate>device-profile.condition-duration-time-unit</mat-label>
    <mat-select formControlName="unit">
      @for (timeUnit of timeUnits; track timeUnit) {
        <mat-option [value]="timeUnit">
          {{ timeUnitTranslations.get(timeUnit) | translate }}
        </mat-option>
      }
    </mat-select>
  </mat-form-field>
</section>
