import { isPlatformBrowser, CommonModule } from '@angular/common';
import { Input, Component, ViewEncapsulation, Inject, PLATFORM_ID, ElementRef, Renderer2, ComponentFactoryResolver, ViewContainerRef, Directive, NgModule } from '@angular/core';
import { trigger, transition } from '@angular/animations';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { fadeIn, fadeOut } from '@ng-tangram/components/core';

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 NtScrimComponent = (function () {
    function NtScrimComponent() {
        this._isOpen = false;
        this.text = '';
    }
    Object.defineProperty(NtScrimComponent.prototype, "isOpen", {
        get: function () { return this._isOpen; },
        set: function (value) { this._isOpen = coerceBooleanProperty(value); },
        enumerable: true,
        configurable: true
    });
    __decorate([
        Input()
    ], NtScrimComponent.prototype, "text", void 0);
    NtScrimComponent = __decorate([
        Component({
            selector: '[nt-scrim], nt-scrim',
            template: "<div class=\"nt-scrim\" *ngIf=\"isOpen\" [@fade]>\n  <div class=\"nt-scrim-animation\">\n    <div class=\"nt-scrim-loading\"></div>\n  </div>\n  <h3 class=\"nt-scrim-text\">{{ text }}</h3>\n</div>\n",
            encapsulation: ViewEncapsulation.None,
            animations: [
                trigger('fade', [
                    transition('void => *', fadeIn(.15)),
                    transition('* => void', fadeOut(.15))
                ])
            ]
        })
    ], NtScrimComponent);
    return NtScrimComponent;
}());

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 __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var NtScrimDirective = (function () {
    function NtScrimDirective(platformId, _elementRef, _renderer, _componentFactoryResolver, _viewContainerRef) {
        this.platformId = platformId;
        this._elementRef = _elementRef;
        this._renderer = _renderer;
        this._componentFactoryResolver = _componentFactoryResolver;
        this._viewContainerRef = _viewContainerRef;
        var componentFactory = this._componentFactoryResolver.resolveComponentFactory(NtScrimComponent);
        this._componentRef = this._viewContainerRef.createComponent(componentFactory);
        if (isPlatformBrowser(this.platformId)) {
            var style = window.getComputedStyle(this._elementRef.nativeElement);
            if (style.position !== 'absolute' || style.position !== 'absolute') {
                this._renderer.setStyle(this._elementRef.nativeElement, 'position', 'relative');
            }
            this._renderer.appendChild(this._elementRef.nativeElement, this._componentRef.location.nativeElement);
        }
    }
    Object.defineProperty(NtScrimDirective.prototype, "text", {
        set: function (value) { this._componentRef.instance.text = value; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtScrimDirective.prototype, "scrim", {
        set: function (value) { this._componentRef.instance.isOpen = coerceBooleanProperty(value); },
        enumerable: true,
        configurable: true
    });
    NtScrimDirective.prototype.ngOnDestroy = function () {
        if (isPlatformBrowser(this.platformId)) {
            this._renderer.removeChild(this._elementRef.nativeElement, this._componentRef.location.nativeElement);
            this._componentRef.destroy();
        }
    };
    NtScrimDirective.ctorParameters = function () { return [
        { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
        { type: ElementRef },
        { type: Renderer2 },
        { type: ComponentFactoryResolver },
        { type: ViewContainerRef }
    ]; };
    __decorate$1([
        Input('scrimText')
    ], NtScrimDirective.prototype, "text", null);
    __decorate$1([
        Input('ntScrim')
    ], NtScrimDirective.prototype, "scrim", null);
    NtScrimDirective = __decorate$1([
        Directive({
            selector: '[ntScrim]'
        }),
        __param(0, Inject(PLATFORM_ID))
    ], NtScrimDirective);
    return NtScrimDirective;
}());

var __decorate$2 = (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 NtScrimModule = (function () {
    function NtScrimModule() {
    }
    NtScrimModule = __decorate$2([
        NgModule({
            imports: [CommonModule],
            exports: [NtScrimComponent, NtScrimDirective],
            declarations: [NtScrimComponent, NtScrimDirective],
            entryComponents: [NtScrimComponent]
        })
    ], NtScrimModule);
    return NtScrimModule;
}());

export { NtScrimComponent, NtScrimDirective, NtScrimModule };
//# sourceMappingURL=scrim.js.map
