import { Component, ElementRef, forwardRef, Injector, ViewEncapsulation } from '@angular/core';
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OMatErrorDirective } from '../../../directives/o-mat-error.directive';
import { OTranslatePipe } from '../../../pipes/o-translate.pipe';
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/checkbox";
import * as i3 from "@angular/material/form-field";
import * as i4 from "@angular/material/tooltip";
export const DEFAULT_INPUTS_O_CHECKBOX = [
    'color',
    'labelPosition: label-position'
];
export class OCheckboxComponent extends OBooleanFormDataComponent {
    constructor(elRef, injector) {
        super(elRef, injector);
        this.labelPosition = 'after';
    }
    initialize() {
        super.initialize();
        const checkboxCtx = this;
        this.getFormControl().getValue = function () {
            return this.value ? checkboxCtx.trueValue : checkboxCtx.falseValue;
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OCheckboxComponent, 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: OCheckboxComponent, isStandalone: true, selector: "o-checkbox", inputs: { color: "color", labelPosition: ["label-position", "labelPosition"] }, host: { properties: { "class.o-checkbox": "true" } }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OCheckboxComponent), 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-checkbox [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" (change)=\"onChangeEvent($event)\"\n    [labelPosition]=\"labelPosition\" [color]=\"color\">\n    {{ olabel | oTranslate }}\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-checkbox>\n  @if (isReadOnly) {\n    <div (click)=\"onClickBlocker($event)\" class=\"read-only-blocker o-flex-fill\"></div>\n  }\n</div>", styles: [".o-checkbox mat-checkbox{z-index:1}.o-checkbox .custom-width{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.o-checkbox .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.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: MatCheckboxModule }, { kind: "component", type: i2.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { 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: OCheckboxComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatCheckboxModule, MatFormFieldModule, MatTooltipModule, OMatErrorDirective, OTranslatePipe], selector: 'o-checkbox', inputs: DEFAULT_INPUTS_O_CHECKBOX, encapsulation: ViewEncapsulation.None, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OCheckboxComponent), multi: true }], host: {
                        '[class.o-checkbox]': '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-checkbox [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" (change)=\"onChangeEvent($event)\"\n    [labelPosition]=\"labelPosition\" [color]=\"color\">\n    {{ olabel | oTranslate }}\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-checkbox>\n  @if (isReadOnly) {\n    <div (click)=\"onClickBlocker($event)\" class=\"read-only-blocker o-flex-fill\"></div>\n  }\n</div>", styles: [".o-checkbox mat-checkbox{z-index:1}.o-checkbox .custom-width{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.o-checkbox .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, 