<!--

    Copyright © 2016-2023 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.

-->
<div class="date-range-navigator"
     [ngClass]="{'short-mode':ctx.width < 400, 'labels-hidden': settings.hideLabels, 'long-mode': ctx.width >= 400}">
  <mat-form-field class="mat-block" [fxHide]="settings.hidePicker" (click)="openNavigatorPanel($event)">
    <mat-label *ngIf="!settings.hideLabels" translate>widgets.date-range-navigator.localizationMap.Date picker</mat-label>
    <mat-select #datePicker [ngModel]="advancedModel.chosenLabel">
      <mat-option [value]="advancedModel.chosenLabel">
        {{advancedModel.chosenLabel}}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <mat-form-field class="mat-block" [fxHide]="settings.hideInterval">
    <mat-label translate *ngIf="!settings.hideLabels">widgets.date-range-navigator.localizationMap.Interval</mat-label>
    <mat-select [(ngModel)]="selectedDateInterval" (ngModelChange)="changeInterval()">
      <mat-option *ngIf="customInterval" [value]="customInterval.ts">
        {{'widgets.date-range-navigator.localizationMap.' + customInterval.label | translate}}
      </mat-option>
      <mat-option *ngFor="let date of datesMap | keyvalue: originalOrder" [value]="date.value.ts">
        {{'widgets.date-range-navigator.localizationMap.' + date.value.label | translate}}
      </mat-option>
    </mat-select>
  </mat-form-field>

  <div class="drn__element step" [fxHide]="settings.hideStepSize">
    <button mat-icon-button (click)="goBack()">
      <mat-icon>keyboard_arrow_left</mat-icon>
    </button>
    <mat-form-field class="mat-block" fxFlex.gt-sm>
      <mat-label translate *ngIf="!settings.hideLabels">widgets.date-range-navigator.localizationMap.Step size</mat-label>
      <mat-select [(ngModel)]="selectedStepSize">
        <mat-option *ngFor="let date of datesMap | keyvalue: originalOrder" [value]="date.value.ts">
          {{'widgets.date-range-navigator.localizationMap.' + date.value.label | translate}}
        </mat-option>
      </mat-select>
    </mat-form-field>
    <button mat-icon-button (click)="goForth()">
      <mat-icon>keyboard_arrow_right</mat-icon>
    </button>
  </div>
</div>
