<!--

    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]="signalStrengthWidgetSettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.signal-strength.signal-strength-card-style</div>
    <tb-image-cards-select rowHeight="2:1"
                           [cols]="{columns: 2,
                                    breakpoints: {
                                      'lt-sm': 1
                                    }}"
      label="{{ 'widgets.signal-strength.layout' | translate }}" formControlName="layout">
      @for (layout of signalStrengthLayouts; track layout) {
        <tb-image-cards-select-option
          [value]="layout"
          [image]="signalStrengthLayoutImageMap.get(layout)">
          {{ signalStrengthLayoutTranslationMap.get(layout) | translate }}
        </tb-image-cards-select-option>
      }
    </tb-image-cards-select>
    <div class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showDate">
        {{ 'widgets.signal-strength.date' | translate }}
      </mat-slide-toggle>
      <div class="flex flex-row items-center justify-start gap-2 gt-xs:flex-1">
        <tb-date-format-select class="flex-1" formControlName="dateFormat"></tb-date-format-select>
        <tb-font-settings formControlName="dateFont"
                          [previewText]="datePreviewFn">
        </tb-font-settings>
        <tb-color-input asBoxInput
                        colorClearButton
                        formControlName="dateColor">
        </tb-color-input>
      </div>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.signal-strength.active-bars-color' | translate }}</div>
      <tb-color-settings formControlName="activeBarsColor"
                         settingsKey="{{'widgets.signal-strength.active-bars-color' | translate }}">
      </tb-color-settings>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widgets.signal-strength.inactive-bars-color' | translate }}</div>
      <tb-color-input asBoxInput
                      formControlName="inactiveBarsColor">
      </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 class="tb-form-row space-between">
      <div translate>widgets.signal-strength.no-signal-rssi-value</div>
      <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
        <input matInput formControlName="noSignalRssiValue" type="number" step="1"
               placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </div>
  </div>
  <div class="tb-form-panel tb-slide-toggle">
    <mat-expansion-panel class="tb-settings" [expanded]="signalStrengthWidgetSettingsForm.get('showTooltip').value"
                         [disabled]="!signalStrengthWidgetSettingsForm.get('showTooltip').value">
      <mat-expansion-panel-header class="flex flex-row flex-wrap">
        <mat-panel-title>
          <mat-slide-toggle class="mat-slide flex items-stretch justify-center" formControlName="showTooltip" (click)="$event.stopPropagation()">
            {{ 'widget-config.tooltip' | translate }}
          </mat-slide-toggle>
        </mat-panel-title>
      </mat-expansion-panel-header>
      <ng-template matExpansionPanelContent>
        <div class="tb-form-row space-between">
          <mat-slide-toggle class="mat-slide" formControlName="showTooltipValue">
            {{ 'tooltip.value' | translate }}
          </mat-slide-toggle>
          <div class="flex flex-row items-center justify-start gap-2">
            <tb-font-settings formControlName="tooltipValueFont"
                              [previewText]="tooltipValuePreviewFn">
            </tb-font-settings>
            <tb-color-input asBoxInput
                            colorClearButton
                            formControlName="tooltipValueColor">
            </tb-color-input>
          </div>
        </div>
        <div class="tb-form-row column-xs">
          <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showTooltipDate">
            {{ 'tooltip.date' | translate }}
          </mat-slide-toggle>
          <div class="flex flex-row items-center justify-start gap-2 gt-xs:flex-1">
            <tb-date-format-select class="flex-1" formControlName="tooltipDateFormat"></tb-date-format-select>
            <tb-font-settings formControlName="tooltipDateFont"
                              [previewText]="tooltipDatePreviewFn">
            </tb-font-settings>
            <tb-color-input asBoxInput
                            colorClearButton
                            formControlName="tooltipDateColor">
            </tb-color-input>
          </div>
        </div>
        <div class="tb-form-row space-between">
          <div>{{ 'tooltip.background-color' | translate }}</div>
          <tb-color-input asBoxInput
                          formControlName="tooltipBackgroundColor">
          </tb-color-input>
        </div>
        <div class="tb-form-row space-between">
          <div translate>tooltip.background-blur</div>
          <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
            <input matInput formControlName="tooltipBackgroundBlur" type="number" min="0" step="1"
                   placeholder="{{ 'widget-config.set' | translate }}">
            <div matSuffix>px</div>
          </mat-form-field>
        </div>
      </ng-template>
    </mat-expansion-panel>
  </div>
</ng-container>
