<!--

    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.

-->
<div [formGroup]="axisFormGroup" class="tb-form-table-row tb-axis-row">
  <div class="tb-axis-id-field">
    {{ modelValue.id }}
  </div>
  <mat-checkbox class="tb-show-field" formControlName="show"></mat-checkbox>
  <mat-form-field class="tb-inline-field tb-label-field" appearance="outline" subscriptSizing="dynamic">
    <input matInput formControlName="label" placeholder="{{ 'widget-config.set' | translate }}">
  </mat-form-field>
  <mat-form-field class="tb-inline-field tb-position-field" appearance="outline" subscriptSizing="dynamic">
    <mat-select formControlName="position">
      @for (position of axisPositions; track position) {
        <mat-option [value]="position">
          {{ timeSeriesAxisPositionTranslations.get(position) | translate }}
        </mat-option>
      }
    </mat-select>
  </mat-form-field>
  <div class="tb-min-field" formGroupName="min">
    <mat-form-field appearance="outline" class="tb-inline-field number" subscriptSizing="dynamic">
      <input matInput formControlName="value" type="number" placeholder="{{ 'widgets.chart.chart-axis.scale-auto' | translate }}">
    </mat-form-field>
  </div>
  <div class="tb-max-field" formGroupName="max">
    <mat-form-field appearance="outline" class="tb-inline-field number" subscriptSizing="dynamic">
      <input matInput formControlName="value" type="number" placeholder="{{ 'widgets.chart.chart-axis.scale-auto' | translate }}">
    </mat-form-field>
  </div>
  <div class="tb-units-field">
    <tb-unit-input formControlName="units" [supportsUnitConversion]="supportsUnitConversion">
    </tb-unit-input>
  </div>
  <div class="tb-decimals-field">
    <mat-form-field appearance="outline" class="tb-inline-field number" subscriptSizing="dynamic">
      <input matInput formControlName="decimals" type="number" min="0" max="15" step="1" placeholder="{{ 'widget-config.set' | translate }}">
    </mat-form-field>
  </div>
  <div class="tb-form-table-row-cell-buttons">
    <button type="button"
            mat-icon-button
            #matButton
            (click)="editAxis($event, matButton)"
            matTooltip="{{ 'widgets.time-series-chart.axis.y-axis-settings' | translate }}"
            matTooltipPosition="above">
      <mat-icon>settings</mat-icon>
    </button>
    <div class="tb-remove-button">
      @if (modelValue.id !== 'default') {
        <button
          type="button"
          mat-icon-button
          (click)="axisRemoved.emit()"
          matTooltip="{{ 'widgets.time-series-chart.axis.remove-y-axis' | translate }}"
          matTooltipPosition="above">
          <mat-icon>delete</mat-icon>
        </button>
      }
    </div>
  </div>
</div>
