<!--

    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.

-->
<ng-container [formGroup]="progressBarWidgetSettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.progress-bar.progress-bar-card-style</div>
    <tb-image-cards-select rowHeight="2:1"
                           [cols]="{columns: 2,
                                    breakpoints: {
                                      'lt-sm': 1
                                    }}"
      label="{{ 'widgets.progress-bar.layout' | translate }}" formControlName="layout">
      @for (layout of progressBarLayouts; track layout) {
        <tb-image-cards-select-option
          [value]="layout"
          [image]="progressBarLayoutImageMap.get(layout)">
          {{ progressBarLayoutTranslationMap.get(layout) | translate }}
        </tb-image-cards-select-option>
      }
    </tb-image-cards-select>
    <div class="tb-form-row">
      <mat-slide-toggle class="mat-slide" formControlName="autoScale">
        {{ 'widgets.progress-bar.auto-scale' | translate }}
      </mat-slide-toggle>
    </div>
    <div class="tb-form-row space-between">
      <mat-slide-toggle class="mat-slide" formControlName="showValue">
        {{ 'widgets.progress-bar.value' | translate }}
      </mat-slide-toggle>
      <div class="flex flex-row items-center justify-start gap-2">
        <tb-font-settings formControlName="valueFont"
                          [previewText]="valuePreviewFn">
        </tb-font-settings>
        <tb-color-settings formControlName="valueColor"
                           [minValue]="progressBarWidgetSettingsForm.get('tickMin').value"
                           [maxValue]="progressBarWidgetSettingsForm.get('tickMax').value"
                           settingsKey="{{'widgets.progress-bar.value' | translate }}">
        </tb-color-settings>
      </div>
    </div>
    <div class="tb-form-row space-between  column-xs">
      <div>{{ 'widgets.progress-bar.range' | translate }}</div>
      <div class="flex flex-row items-center justify-start gap-2">
        <div class="tb-small-label" translate>widgets.progress-bar.min</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput formControlName="tickMin" type="number" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <div class="tb-small-label" translate>widgets.progress-bar.max</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput formControlName="tickMax" type="number" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
      </div>
    </div>
    @if (progressBarWidgetSettingsForm.get('layout').value === progressBarLayout.default) {
      <div class="tb-form-row space-between">
        <mat-slide-toggle class="mat-slide" formControlName="showTicks">
          {{ 'widgets.progress-bar.range-ticks' | translate }}
        </mat-slide-toggle>
        <div class="flex flex-row items-center justify-start gap-2">
          <tb-font-settings formControlName="ticksFont"
                            previewText="100">
          </tb-font-settings>
          <tb-color-input asBoxInput
                          colorClearButton
                          formControlName="ticksColor">
          </tb-color-input>
        </div>
      </div>
    }
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.progress-bar.bar-color' | translate }}</div>
      <tb-color-settings formControlName="barColor"
                         [minValue]="progressBarWidgetSettingsForm.get('tickMin').value"
                         [maxValue]="progressBarWidgetSettingsForm.get('tickMax').value"
                         settingsKey="{{'widgets.progress-bar.bar-color' | translate }}">
      </tb-color-settings>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.progress-bar.bar-background' | translate }}</div>
      <tb-color-input asBoxInput
                      colorClearButton
                      formControlName="barBackground">
      </tb-color-input>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.background.background' | translate }}</div>
      <tb-background-settings formControlName="background">
      </tb-background-settings>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widget-config.card-padding' | translate }}</div>
      <mat-form-field appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="padding" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </div>
  </div>
</ng-container>
