<!--

    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]="statusWidgetConfigForm">
  <tb-target-device formControlName="targetDevice" appearance="outline"></tb-target-device>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.status-widget.behavior</div>
    <div class="tb-form-row">
      <div class="fixed-title-width" tb-hint-tooltip-icon="{{'widgets.rpc-state.initial-state-hint' | translate}}" translate>widgets.rpc-state.initial-state</div>
      <tb-get-value-action-settings class="flex-1"
                                    panelTitle="{{ 'widgets.rpc-state.initial-state' | translate }}"
                                    [valueType]="valueType.BOOLEAN"
                                    trueLabel="{{ 'widgets.rpc-state.on' | translate }}"
                                    falseLabel="{{ 'widgets.rpc-state.off' | translate }}"
                                    stateLabel="{{ 'widgets.rpc-state.on' | translate }}"
                                    [aliasController]="aliasController"
                                    [targetDevice]="targetDevice"
                                    [widgetType]="widgetType"
      formControlName="initialState"></tb-get-value-action-settings>
    </div>
    <div class="tb-form-row">
      <div class="fixed-title-width" tb-hint-tooltip-icon="{{'widgets.rpc-state.disabled-state-hint' | translate}}" translate>widgets.rpc-state.disabled-state</div>
      <tb-get-value-action-settings class="flex-1"
                                    panelTitle="{{ 'widgets.rpc-state.disabled-state' | translate }}"
                                    [valueType]="valueType.BOOLEAN"
                                    stateLabel="{{ 'widgets.rpc-state.disabled' | translate }}"
                                    [aliasController]="aliasController"
                                    [targetDevice]="targetDevice"
                                    [widgetType]="widgetType"
      formControlName="disabledState"></tb-get-value-action-settings>
    </div>
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widget-config.appearance</div>
    <tb-image-cards-select rowHeight="1:1"
                           [cols]="{columns: 3,
                                    breakpoints: {
                                      'lt-sm': 1,
                                      'lt-md': 2
                                    }}"
      label="{{ 'widgets.status-widget.layout' | translate }}" formControlName="layout">
      @for (layout of statusWidgetLayouts; track layout) {
        <tb-image-cards-select-option
          [value]="layout"
          [image]="statusWidgetLayoutImageMap.get(layout)">
          {{ statusWidgetLayoutTranslationMap.get(layout) | translate }}
        </tb-image-cards-select-option>
      }
    </tb-image-cards-select>
  </div>
  <div class="tb-form-panel">
    <div class="flex flex-row items-center justify-between">
      <div class="tb-form-panel-title" translate>widget-config.card-style</div>
      <tb-toggle-select [(ngModel)]="cardStyleMode"
                        [ngModelOptions]="{ standalone: true }">
        <tb-toggle-option value="on">{{ 'widgets.status-widget.on' | translate }}</tb-toggle-option>
        <tb-toggle-option value="off">{{ 'widgets.status-widget.off' | translate }}</tb-toggle-option>
      </tb-toggle-select>
    </div>
    @if (cardStyleMode === 'on') {
      <tb-status-widget-state-settings
        [layout]="statusWidgetConfigForm.get('layout').value"
        formControlName="onState">
      </tb-status-widget-state-settings>
    }
    @if (cardStyleMode === 'off') {
      <tb-status-widget-state-settings
        [layout]="statusWidgetConfigForm.get('layout').value"
        formControlName="offState">
      </tb-status-widget-state-settings>
    }
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widget-config.card-appearance</div>
    <div class="tb-form-row space-between column-lt-md">
      <div translate>widget-config.show-card-buttons</div>
      <mat-chip-listbox multiple formControlName="cardButtons">
        <mat-chip-option value="fullscreen">{{ 'fullscreen.fullscreen' | translate }}</mat-chip-option>
      </mat-chip-listbox>
    </div>
    <div class="tb-form-row space-between">
      <div>{{ 'widget-config.card-border-radius' | translate }}</div>
      <mat-form-field appearance="outline" subscriptSizing="dynamic">
        <input matInput formControlName="borderRadius" placeholder="{{ 'widget-config.set' | translate }}">
      </mat-form-field>
    </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>
  <tb-widget-actions-panel
    formControlName="actions">
  </tb-widget-actions-panel>
</ng-container>
