import { Component, ElementRef, forwardRef, Injector, ViewEncapsulation } from '@angular/core';
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OMatErrorDirective } from '../../../directives/o-mat-error.directive';
import { OTranslatePipe } from '../../../pipes/o-translate.pipe';
import { OFormValue } from '../../form/o-form-value';
import { OBooleanFormDataComponent } from '../o-boolean-form-data-component.class';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/material/slide-toggle";
import * as i3 from "@angular/material/form-field";
import * as i4 from "@angular/material/tooltip";
export const DEFAULT_INPUTS_O_SLIDETOGGLE = [
    'trueValue: true-value',
    'falseValue: false-value',
    'booleanType: boolean-type',
    'color',
    'labelPosition: label-position'
];
export class OSlideToggleComponent extends OBooleanFormDataComponent {
    constructor(elRef, injector) {
        super(elRef, injector);
        this.labelPosition = 'after';
    }
    isChecked() {
        if (this.value instanceof OFormValue) {
            return this.value.value === this.trueValue;
        }
        return false;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OSlideToggleComponent, deps: [{ token: i0.ElementRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OSlideToggleComponent, isStandalone: true, selector: "o-slide-toggle", inputs: { trueValue: ["true-value", "trueValue"], falseValue: ["false-value", "falseValue"], booleanType: ["boolean-type", "booleanType"], color: "color", labelPosition: ["label-position", "labelPosition"] }, host: { properties: { "class.o-slide-toggle": "true" } }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OSlideToggleComponent), multi: true }], usesInheritance: true, ngImport: i0, template: "<div [class.custom-width]=\"hasCustomWidth\" [formGroup]=\"getFormGroup()\" class=\"relative\" [matTooltip]=\"tooltip\"\n  [matTooltipClass]=\"tooltipClass\" [matTooltipPosition]=\"tooltipPosition\" [matTooltipShowDelay]=\"tooltipShowDelay\"\n  [matTooltipHideDelay]=\"tooltipHideDelay\" class=\"o-flex-row o-layout-align-start-center o-flex-fill\">\n  <mat-slide-toggle [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" [checked]=\"isChecked()\"\n    [required]=\"isRequired\" [labelPosition]=\"labelPosition\" [color]=\"color\" (change)=\"onChangeEvent($event)\">\n    @if (labelVisible) {\n      {{ olabel | oTranslate }}\n    }\n    <mat-error *oMatError=\"hasError('required')\">\n      {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n    </mat-error>\n    @for (oError of getActiveOErrors(); track oError) {\n      <mat-error>\n        {{ oError.text | oTranslate }}\n      </mat-error>\n    }\n  </mat-slide-toggle>\n  @if (isReadOnly) {\n    <div (click)=\"onClickBlocker($event)\" class=\"read-only-blocker o-flex-fill\"></div>\n  }\n</div>", styles: [".o-slide-toggle .read-only-blocker{z-index:2;position:absolute;top:0;left:0;right:0}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatSlideToggleModule }, { kind: "component", type: i2.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "color", "disabled", "disableRipple", "tabIndex", "checked", "hideIcon", "disabledInteractive"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: OMatErrorDirective, selector: "[oMatError]", inputs: ["oMatError"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OSlideToggleComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatSlideToggleModule, MatFormFieldModule, MatTooltipModule, OMatErrorDirective, OTranslatePipe], selector: 'o-slide-toggle', inputs: DEFAULT_INPUTS_O_SLIDETOGGLE, encapsulation: ViewEncapsulation.None, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OSlideToggleComponent), multi: true }], host: {
                        '[class.o-slide-toggle]': 'true'
                    }, template: "<div [class.custom-width]=\"hasCustomWidth\" [formGroup]=\"getFormGroup()\" class=\"relative\" [matTooltip]=\"tooltip\"\n  [matTooltipClass]=\"tooltipClass\" [matTooltipPosition]=\"tooltipPosition\" [matTooltipShowDelay]=\"tooltipShowDelay\"\n  [matTooltipHideDelay]=\"tooltipHideDelay\" class=\"o-flex-row o-layout-align-start-center o-flex-fill\">\n  <mat-slide-toggle [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" [checked]=\"isChecked()\"\n    [required]=\"isRequired\" [labelPosition]=\"labelPosition\" [color]=\"color\" (change)=\"onChangeEvent($event)\">\n    @if (labelVisible) {\n      {{ olabel | oTranslate }}\n    }\n    <mat-error *oMatError=\"hasError('required')\">\n      {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n    </mat-error>\n    @for (oError of getActiveOErrors(); track oError) {\n      <mat-error>\n        {{ oError.text | oTranslate }}\n      </mat-error>\n    }\n  </mat-slide-toggle>\n  @if (isReadOnly) {\n    <div (click)=\"onClickBlocker($event)\" class=\"read-only-blocker o-flex-fill\"></div>\n  }\n</div>", styles: [".o-slide-toggle .read-only-blocker{z-index:2;position:absolute;top:0;left:0;right:0}\n"] }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Injector }] });
//# sourceMappingURL=data:application/json;base64, 