import { Component, EventEmitter, forwardRef, Output } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "../../../ui-kit/tooltip/tooltip.directive";
const SWITCH_VALUE_ACCESSOR = {
    provide: NG_VALUE_ACCESSOR,
    useExisting: forwardRef(() => SwitchComponent),
    multi: true,
};
export class SwitchComponent {
    constructor() {
        this.change = new EventEmitter();
        this.onChanged = (value) => { };
        this.onTouched = () => { };
    }
    writeValue(value) {
        this.checked = value ?? false;
    }
    registerOnChange(fn) {
        this.onChanged = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(isDisabled) {
        this.disabled = isDisabled;
    }
    valueChanged() {
        this.checked = !this.checked;
        this.onChanged(this.checked);
        this.onTouched();
        // this.change.emit(this.checked)
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SwitchComponent, selector: "switch", inputs: { disabled: "disabled", checked: "checked", tooltipMessage: "tooltipMessage", value: "value", position: "position" }, outputs: { change: "change" }, providers: [SWITCH_VALUE_ACCESSOR], ngImport: i0, template: "<label class=\"cs-switch\" [class.top]=\"position == 'top'\">\n  <!-- [class.large]=\"large\" -->\n  <span class=\"value\">\n    <span [innerHTML]=\"value\" *ngIf=\"value != undefined\"></span>\n    <!-- <span class=\"notification\" *ngIf=\"!tooltipMessage\" [appTooltip]=\"tooltipMessage\" placement=\"bottom-right\" delay=\"0\" type=\"black\" [tooltipMandatory]=\"true\">\n        <i class=\"vc-icons\">&#xe9f3;</i>\n      </span> -->\n  </span>\n  <!-- [class.last]=\"last\" -->\n\n  <!-- if not tooltip -->\n  <span class=\"switch\" *ngIf=\"tooltipMessage === '' || tooltipMessage === undefined\">\n    <input type=\"checkbox\" [checked]=\"checked\" [disabled]=\"disabled\" (change)=\"valueChanged()\" />\n    <span class=\"switch-box\">\n      <span class=\"switch-ball\"></span>\n    </span>\n  </span>\n\n\n  <!-- if tooltip -->\n  <span\n    class=\"switch\"\n    *ngIf=\"tooltipMessage !== '' && tooltipMessage !== undefined\"\n    [appTooltip]=\"tooltipMessage\"\n    placement=\"bottom-right\"\n    delay=\"0\"\n    type=\"black\"\n    [tooltipMandatory]=\"true\"\n  >\n    <input type=\"checkbox\" [checked]=\"checked\" [disabled]=\"disabled\" (change)=\"valueChanged()\" />\n    <span class=\"switch-box\">\n      <span class=\"switch-ball\"></span>\n    </span>\n  </span>\n</label>\n", styles: ["label.cs-switch{position:relative;display:flex;align-items:center;justify-content:space-between;width:100%;margin:0;padding:0}label.cs-switch.top{align-items:flex-start}label.cs-switch span.value{font-size:12px;color:#161b2f;font-weight:400;display:flex;justify-content:space-between;width:calc(100% - 35px);align-items:flex-start}label.cs-switch span.switch{position:relative;display:block;width:25px;height:14px}label.cs-switch span.switch input{position:absolute;opacity:0;margin:0;width:100%;height:100%;z-index:1;cursor:pointer}label.cs-switch span.switch input:checked+span.switch-box{background:#34aa44;border:1px solid #34aa44}label.cs-switch span.switch input:checked+span.switch-box .switch-ball{left:13px}label.cs-switch span.switch input:disabled{pointer-events:none}label.cs-switch span.switch input:disabled+.switch-box{opacity:.5}label.cs-switch span.switch-box{height:100%;width:100%;border-radius:11px;background:#bcbcbc;border:1px solid #bcbcbc;display:block;transition:all .2s ease-in-out}label.cs-switch span.switch-ball{height:10px;width:10px;background:#fff;border-radius:50%;border:1px solid #ffffff;display:block;position:absolute;left:2px;top:2px;bottom:1px;transition:all .2s ease-in-out}label.cs-switch span.notification{display:inline-flex;font-size:12px;cursor:pointer;color:#4681ef;align-items:center;line-height:20px;margin:0 10px}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.ToolTipDirective, selector: "[appTooltip]", inputs: ["appTooltip", "placement", "type", "tooltipMandatory", "showTooltip", "animate"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SwitchComponent, decorators: [{
            type: Component,
            args: [{ selector: 'switch', providers: [SWITCH_VALUE_ACCESSOR], inputs: ['disabled', 'checked', 'tooltipMessage', 'value', 'position'], template: "<label class=\"cs-switch\" [class.top]=\"position == 'top'\">\n  <!-- [class.large]=\"large\" -->\n  <span class=\"value\">\n    <span [innerHTML]=\"value\" *ngIf=\"value != undefined\"></span>\n    <!-- <span class=\"notification\" *ngIf=\"!tooltipMessage\" [appTooltip]=\"tooltipMessage\" placement=\"bottom-right\" delay=\"0\" type=\"black\" [tooltipMandatory]=\"true\">\n        <i class=\"vc-icons\">&#xe9f3;</i>\n      </span> -->\n  </span>\n  <!-- [class.last]=\"last\" -->\n\n  <!-- if not tooltip -->\n  <span class=\"switch\" *ngIf=\"tooltipMessage === '' || tooltipMessage === undefined\">\n    <input type=\"checkbox\" [checked]=\"checked\" [disabled]=\"disabled\" (change)=\"valueChanged()\" />\n    <span class=\"switch-box\">\n      <span class=\"switch-ball\"></span>\n    </span>\n  </span>\n\n\n  <!-- if tooltip -->\n  <span\n    class=\"switch\"\n    *ngIf=\"tooltipMessage !== '' && tooltipMessage !== undefined\"\n    [appTooltip]=\"tooltipMessage\"\n    placement=\"bottom-right\"\n    delay=\"0\"\n    type=\"black\"\n    [tooltipMandatory]=\"true\"\n  >\n    <input type=\"checkbox\" [checked]=\"checked\" [disabled]=\"disabled\" (change)=\"valueChanged()\" />\n    <span class=\"switch-box\">\n      <span class=\"switch-ball\"></span>\n    </span>\n  </span>\n</label>\n", styles: ["label.cs-switch{position:relative;display:flex;align-items:center;justify-content:space-between;width:100%;margin:0;padding:0}label.cs-switch.top{align-items:flex-start}label.cs-switch span.value{font-size:12px;color:#161b2f;font-weight:400;display:flex;justify-content:space-between;width:calc(100% - 35px);align-items:flex-start}label.cs-switch span.switch{position:relative;display:block;width:25px;height:14px}label.cs-switch span.switch input{position:absolute;opacity:0;margin:0;width:100%;height:100%;z-index:1;cursor:pointer}label.cs-switch span.switch input:checked+span.switch-box{background:#34aa44;border:1px solid #34aa44}label.cs-switch span.switch input:checked+span.switch-box .switch-ball{left:13px}label.cs-switch span.switch input:disabled{pointer-events:none}label.cs-switch span.switch input:disabled+.switch-box{opacity:.5}label.cs-switch span.switch-box{height:100%;width:100%;border-radius:11px;background:#bcbcbc;border:1px solid #bcbcbc;display:block;transition:all .2s ease-in-out}label.cs-switch span.switch-ball{height:10px;width:10px;background:#fff;border-radius:50%;border:1px solid #ffffff;display:block;position:absolute;left:2px;top:2px;bottom:1px;transition:all .2s ease-in-out}label.cs-switch span.notification{display:inline-flex;font-size:12px;cursor:pointer;color:#4681ef;align-items:center;line-height:20px;margin:0 10px}\n"] }]
        }], propDecorators: { change: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 