(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/coercion'), require('@angular/core'), require('@angular/forms'), require('@angular/common')) :
    typeof define === 'function' && define.amd ? define('@ng-tangram/components/switch', ['exports', '@angular/cdk/coercion', '@angular/core', '@angular/forms', '@angular/common'], factory) :
    (global = global || self, factory((global.nt = global.nt || {}, global.nt.components = global.nt.components || {}, global.nt.components.switch = {}), global.ng.cdk.coercion, global.ng.core, global.ng.forms, global.ng.common));
}(this, (function (exports, coercion, core, forms, common) { 'use strict';

    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __param = (this && this.__param) || function (paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    };
    var uniqueId = 0;
    var NtSwitchChange = (function () {
        function NtSwitchChange(source, checked) {
            this.source = source;
            this.checked = checked;
        }
        return NtSwitchChange;
    }());
    var NtSwitchComponent = (function () {
        function NtSwitchComponent(_changeDetectorRef, tabIndex, ngControl) {
            this._changeDetectorRef = _changeDetectorRef;
            this.ngControl = ngControl;
            this.id = "nt-switch-" + uniqueId++;
            this._disabled = false;
            this._checked = false;
            this._circle = false;
            this.change = new core.EventEmitter();
            this._onChange = function () { };
            this._onTouched = function () { };
            if (this.ngControl) {
                this.ngControl.valueAccessor = this;
            }
            this.tabIndex = parseInt(tabIndex) || 0;
        }
        Object.defineProperty(NtSwitchComponent.prototype, "disabled", {
            get: function () { return this._disabled; },
            set: function (value) {
                if (value !== this.disabled) {
                    this._disabled = coercion.coerceBooleanProperty(value);
                    this._changeDetectorRef.markForCheck();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtSwitchComponent.prototype, "checked", {
            get: function () { return this._checked; },
            set: function (value) {
                if (value !== this.checked) {
                    this._checked = coercion.coerceBooleanProperty(value);
                    this._changeDetectorRef.markForCheck();
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(NtSwitchComponent.prototype, "circle", {
            get: function () { return this._circle; },
            set: function (value) {
                if (value !== this.circle) {
                    this._circle = coercion.coerceBooleanProperty(value);
                }
            },
            enumerable: true,
            configurable: true
        });
        NtSwitchComponent.prototype.writeValue = function (value) {
            this._checked = !!value;
        };
        NtSwitchComponent.prototype.registerOnChange = function (fn) {
            this._onChange = fn;
        };
        NtSwitchComponent.prototype.registerOnTouched = function (fn) {
            this._onTouched = fn;
        };
        NtSwitchComponent.prototype.setDisabledState = function (isDisabled) {
            this.disabled = isDisabled;
        };
        NtSwitchComponent.prototype._onInputClick = function (event) {
            event.stopPropagation();
            if (!this.disabled) {
                this._checked = !this._checked;
                this._onTouched();
                this._emitChangeEvent();
            }
        };
        NtSwitchComponent.prototype._onInteractionEvent = function (event) {
            event.stopPropagation();
        };
        NtSwitchComponent.prototype._emitChangeEvent = function () {
            var event = new NtSwitchChange(this, this.checked);
            this._onChange(this.checked);
            this.change.emit(event);
        };
        NtSwitchComponent.ctorParameters = function () { return [
            { type: core.ChangeDetectorRef },
            { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] },
            { type: forms.NgControl, decorators: [{ type: core.Self }, { type: core.Optional }] }
        ]; };
        __decorate([
            core.Input()
        ], NtSwitchComponent.prototype, "disabled", null);
        __decorate([
            core.Input()
        ], NtSwitchComponent.prototype, "checked", null);
        __decorate([
            core.Input()
        ], NtSwitchComponent.prototype, "circle", null);
        __decorate([
            core.Output()
        ], NtSwitchComponent.prototype, "change", void 0);
        NtSwitchComponent = __decorate([
            core.Component({
                selector: 'nt-switch',
                template: "<input class=\"switch-input\" type=\"checkbox\"\n  [attr.id]=\"id\"\n  [tabIndex]=\"tabIndex\"\n  [checked]=\"checked\"\n  [disabled]=\"disabled\"\n  (change)=\"_onInteractionEvent($event)\"\n  (click)=\"_onInputClick($event)\">\n<label class=\"switch-paddle\" [attr.for]=\"id\"></label>\n",
                encapsulation: core.ViewEncapsulation.None,
                changeDetection: core.ChangeDetectionStrategy.OnPush,
                host: {
                    'class': 'switch nt-switch',
                    '[class.nt-switch-checked]': 'checked',
                    '[class.nt-switch-disabled]': 'disabled',
                    '[class.nt-switch-circle]': 'circle'
                }
            }),
            __param(1, core.Attribute('tabindex')),
            __param(2, core.Self()), __param(2, core.Optional())
        ], NtSwitchComponent);
        return NtSwitchComponent;
    }());

    var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var NtSwitchModule = (function () {
        function NtSwitchModule() {
        }
        NtSwitchModule = __decorate$1([
            core.NgModule({
                imports: [common.CommonModule],
                exports: [NtSwitchComponent],
                declarations: [NtSwitchComponent]
            })
        ], NtSwitchModule);
        return NtSwitchModule;
    }());

    exports.NtSwitchChange = NtSwitchChange;
    exports.NtSwitchComponent = NtSwitchComponent;
    exports.NtSwitchModule = NtSwitchModule;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=switch.umd.js.map
