<!--

    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]="stateSettingsFormGroup">
  @if (layout !== StatusWidgetLayout.icon) {
    <div class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showLabel">
        {{ 'widgets.status-widget.label' | translate }}
      </mat-slide-toggle>
      <div class="flex flex-1 flex-row items-center justify-start gap-2">
        <tb-string-pattern-autocomplete class="flex-1"
                                        appearance="outline"
                                        brackets="curly"
                                        subscriptSizing="dynamic"
                                        predefinedValuesButton="true"
                                        [disabled]="!stateSettingsFormGroup.get('showLabel').value"
                                        [predefinedValues]="predefinedValues"
                                        placeholderText="{{ 'widget-config.set' | translate }}"
                                        formControlName="label"
        ></tb-string-pattern-autocomplete>
        <tb-font-settings formControlName="labelFont"
                          [previewText]="stateSettingsFormGroup.get('label').value">
        </tb-font-settings>
      </div>
    </div>
  }
  @if (layout !== StatusWidgetLayout.icon) {
    <div class="tb-form-row column-xs">
      <mat-slide-toggle class="mat-slide fixed-title-width" formControlName="showStatus">
        {{ 'widgets.status-widget.status' | translate }}
      </mat-slide-toggle>
      <div class="flex flex-1 flex-row items-center justify-start gap-2">
        <mat-form-field class="flex" appearance="outline" subscriptSizing="dynamic">
          <input matInput formControlName="status" placeholder="{{ 'widget-config.set' | translate }}">
        </mat-form-field>
        <tb-font-settings formControlName="statusFont"
                          [previewText]="stateSettingsFormGroup.get('status').value">
        </tb-font-settings>
      </div>
    </div>
  }
  <div class="tb-form-row">
    <div class="fixed-title-width">
      {{ 'widgets.status-widget.icon' | translate }}
    </div>
    <div class="flex flex-1 flex-row items-center justify-start gap-2">
      <mat-form-field appearance="outline" class="number flex" subscriptSizing="dynamic">
        <input matInput type="number" min="0" formControlName="iconSize" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
      <tb-css-unit-select class="flex-1" formControlName="iconSizeUnit"></tb-css-unit-select>
      <tb-material-icon-select asBoxInput
                               formControlName="icon">
      </tb-material-icon-select>
    </div>
  </div>
  <div class="tb-form-row space-between" [class]="{'column-xs': layout === StatusWidgetLayout.icon, 'column-lt-md': layout !== StatusWidgetLayout.icon}">
    <div>{{ 'widgets.status-widget.color-palette' | translate }}</div>
    <div class="flex flex-row flex-wrap items-center justify-start gap-3 lt-sm:justify-between"
         [class.lt-md:justify-start]="layout === StatusWidgetLayout.icon"
         [class.lt-md:justify-between]="layout !== StatusWidgetLayout.icon">
      <div class="flex flex-row items-center justify-start gap-2">
        <div tb-hint-tooltip-icon="{{'widgets.status-widget.primary-color-hint' | translate}}" translate>widgets.status-widget.primary</div>
        <tb-color-input asBoxInput
                        formControlName="primaryColor">
        </tb-color-input>
      </div>
      @if (layout !== StatusWidgetLayout.icon) {
        <mat-divider vertical class="lt-md:!hidden"></mat-divider>
      }
      @if (layout !== StatusWidgetLayout.icon) {
        <div class="flex flex-row items-center justify-start gap-2">
          <div tb-hint-tooltip-icon="{{'widgets.status-widget.secondary-color-hint' | translate}}" translate>widgets.status-widget.secondary</div>
          <tb-color-input asBoxInput
                          formControlName="secondaryColor">
          </tb-color-input>
        </div>
      }
      <mat-divider vertical class="lt-sm:!hidden" [class.lt-md:!hidden]="layout !== StatusWidgetLayout.icon"></mat-divider>
      <div class="flex flex-row items-center justify-start gap-2">
        <div translate>widgets.status-widget.background</div>
        <tb-background-settings formControlName="background">
        </tb-background-settings>
      </div>
    </div>
  </div>
  <div class="tb-form-row space-between" [class]="{'column-xs': layout === StatusWidgetLayout.icon, 'column-lt-md': layout !== StatusWidgetLayout.icon}">
    <div>{{ 'widgets.status-widget.disabled-color-palette' | translate }}</div>
    <div class="flex flex-row flex-wrap items-center justify-start gap-3 lt-sm:justify-between"
         [class.lt-md:justify-start]="layout === StatusWidgetLayout.icon"
         [class.lt-md:justify-between]="layout !== StatusWidgetLayout.icon">
      <div class="flex flex-row items-center justify-start gap-2">
        <div tb-hint-tooltip-icon="{{'widgets.status-widget.primary-color-hint' | translate}}" translate>widgets.status-widget.primary</div>
        <tb-color-input asBoxInput
                        formControlName="primaryColorDisabled">
        </tb-color-input>
      </div>
      @if (layout !== StatusWidgetLayout.icon) {
        <mat-divider vertical class="lt-md:!hidden"></mat-divider>
      }
      @if (layout !== StatusWidgetLayout.icon) {
        <div class="flex flex-row items-center justify-start gap-2">
          <div tb-hint-tooltip-icon="{{'widgets.status-widget.secondary-color-hint' | translate}}" translate>widgets.status-widget.secondary</div>
          <tb-color-input asBoxInput
                          formControlName="secondaryColorDisabled">
          </tb-color-input>
        </div>
      }
      <mat-divider vertical class="lt-sm:!hidden" [class.lt-md:!hidden]="layout !== StatusWidgetLayout.icon"></mat-divider>
      <div class="flex flex-row items-center justify-start gap-2">
        <div translate>widgets.status-widget.background</div>
        <tb-background-settings formControlName="backgroundDisabled">
        </tb-background-settings>
      </div>
    </div>
  </div>
</ng-container>
