import { Component, EventEmitter, Inject, Optional, Output, ViewChild } from '@angular/core';
import { NG_ASYNC_VALIDATORS, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgModel } from '@angular/forms';
import { ElementBase } from '../../base/element-base';
import { INPUT_FORMS_CONFIG } from '../../input-forms-config.constants';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
let identifier = 0;
export class InputSwitchComponent extends ElementBase {
    constructor(validators, asyncValidators, config) {
        super(validators, asyncValidators, config);
        this.config = config;
        this.onChange = new EventEmitter();
        this.identifier = `input-switch-${identifier++}`;
    }
    Toggle() {
        if (this.disabled)
            return;
        this.value = !this.value;
        this.onChange.emit(this.value);
    }
}
InputSwitchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputSwitchComponent, deps: [{ token: NG_VALIDATORS, optional: true }, { token: NG_ASYNC_VALIDATORS, optional: true }, { token: INPUT_FORMS_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
InputSwitchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: InputSwitchComponent, selector: "input-switch", outputs: { onChange: "onChange" }, providers: [{
            provide: NG_VALUE_ACCESSOR,
            useExisting: InputSwitchComponent,
            multi: true
        }], viewQueries: [{ propertyName: "model", first: true, predicate: NgModel, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ui-switch\">\n  <div class=\"d-flex align-items-center\">\n    <div class=\"switch\" (click)=\"Toggle()\" [ngClass]=\"{'on': value, 'disabled': disabled}\">\n      <div class=\"switch-toggler\"></div>\n    </div>\n    <label class=\"ml-2 mb-0\" *ngIf=\"label\">\n      {{label}}\n    </label>\n  </div>\n</div>", styles: [".ui-switch .switch{position:relative;background-color:#f9f9f9;border:1px solid #dfdfdf;min-width:50px;height:30px;border-radius:30px;box-shadow:#dfdfdf 0 0 inset;transition:.3s ease-out all;cursor:pointer}.ui-switch .switch .switch-toggler{position:absolute;top:0;right:calc(100% - 30px);background-color:#fff;border-radius:100%;box-shadow:0 1px 3px #0006;width:30px;height:28px;transition:.3s ease-out all}.ui-switch .switch.on{background-color:#64bd63}.ui-switch .switch.on .switch-toggler{left:auto;right:0}.ui-switch .switch.disabled{background-color:#d2d2d2;border-color:#bdbdbd}.ui-switch .switch.disabled .switch-toggler{background-color:#eee}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: InputSwitchComponent, decorators: [{
            type: Component,
            args: [{ selector: 'input-switch', providers: [{
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: InputSwitchComponent,
                            multi: true
                        }], template: "<div class=\"ui-switch\">\n  <div class=\"d-flex align-items-center\">\n    <div class=\"switch\" (click)=\"Toggle()\" [ngClass]=\"{'on': value, 'disabled': disabled}\">\n      <div class=\"switch-toggler\"></div>\n    </div>\n    <label class=\"ml-2 mb-0\" *ngIf=\"label\">\n      {{label}}\n    </label>\n  </div>\n</div>", styles: [".ui-switch .switch{position:relative;background-color:#f9f9f9;border:1px solid #dfdfdf;min-width:50px;height:30px;border-radius:30px;box-shadow:#dfdfdf 0 0 inset;transition:.3s ease-out all;cursor:pointer}.ui-switch .switch .switch-toggler{position:absolute;top:0;right:calc(100% - 30px);background-color:#fff;border-radius:100%;box-shadow:0 1px 3px #0006;width:30px;height:28px;transition:.3s ease-out all}.ui-switch .switch.on{background-color:#64bd63}.ui-switch .switch.on .switch-toggler{left:auto;right:0}.ui-switch .switch.disabled{background-color:#d2d2d2;border-color:#bdbdbd}.ui-switch .switch.disabled .switch-toggler{background-color:#eee}\n"] }]
        }], ctorParameters: function () { return [{ type: Array, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_VALIDATORS]
                }] }, { type: Array, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [NG_ASYNC_VALIDATORS]
                }] }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [INPUT_FORMS_CONFIG]
                }] }]; }, propDecorators: { model: [{
                type: ViewChild,
                args: [NgModel, { static: true }]
            }], onChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 