<!--

    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 class="tb-slider-panel" [class.no-pointer-events]="ctx.isEdit" [style.padding]="padding" [style]="backgroundStyle$ | async">
  <div class="tb-slider-overlay" [style]="overlayStyle"></div>
  @if (showWidgetTitlePanel) {
    <div class="tb-slider-title-panel">
      <ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
    </div>
  }
  <div #sliderContent class="tb-slider-content">
    @if (showValue) {
      <div #sliderValueContainer class="tb-slider-value-container" >
        <div #sliderValue class="tb-slider-value" [style]="valueStyle">{{ valueText }}</div>
      </div>
    }
    <div class="tb-slider-container" [class.tb-min-height]="!showValue">
      @if (showLeftRightIcon) {
        <div #leftSliderIconContainer >
          <tb-icon #leftSliderIcon [style]="leftIconStyle"
          [style.color]="(disabled || (loading$ | async)) ? settings.mainColorDisabled : settings.leftIconColor">{{ leftIcon }}</tb-icon>
        </div>
      }
      <div class="tb-slider-column">
        <mat-slider class="tb-slider"
                    [disabled]="disabled || (loading$ | async)"
                    [displayWith]="sliderValueText"
                    [showTickMarks]="settings.showTickMarks"
                    [step]="sliderStep"
                    [min]="settings.tickMin"
                    [max]="settings.tickMax"
                    discrete>
          <input matSliderThumb [(ngModel)]="value" (valueChange)="onSliderChange()">
        </mat-slider>
        @if (showTicks) {
          <div class="tb-slider-ticks" [style]="ticksStyle">
            <div #sliderTickMinContainer>
              <div #sliderTickMin>{{ tickMinText }}</div>
            </div>
            <div #sliderTickMaxContainer>
              <div #sliderTickMax>{{ tickMaxText }}</div>
            </div>
          </div>
        }
      </div>
      @if (showLeftRightIcon) {
        <div #rightSliderIconContainer >
          <tb-icon #rightSliderIcon [style]="rightIconStyle"
          [style.color]="(disabled || (loading$ | async)) ? settings.mainColorDisabled : settings.rightIconColor">{{ rightIcon }}</tb-icon>
        </div>
      }
    </div>
  </div>
  @if (loading$ | async) {
    <mat-progress-bar class="tb-action-widget-progress" style="height: 4px;" color="accent" mode="indeterminate"></mat-progress-bar>
  }
</div>
