import { isPlatformBrowser, CommonModule } from '@angular/common';
import { Inject, PLATFORM_ID, ElementRef, Renderer2, Input, Component, ViewEncapsulation, NgModule } from '@angular/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 __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
let NtBadgeComponent = class NtBadgeComponent {
    constructor(platformId, _elementRef, _renderer) {
        this.platformId = platformId;
        this._elementRef = _elementRef;
        this._renderer = _renderer;
        this._type = 'static';
        this.color = '';
        this.class = '';
    }
    set type(value) {
        if (value === 'float' || value === 'notify') {
            this._resetPosition();
        }
        else {
            this._clearPosition();
        }
        this._type = value;
    }
    get type() { return this._type; }
    ngAfterViewInit() {
        this._resetPosition();
    }
    ngOnDestroy() {
        this._clearPosition();
    }
    _resetPosition() {
        if (isPlatformBrowser(this.platformId)) {
            const style = window.getComputedStyle(this._elementRef.nativeElement.parentElement);
            if (style.position !== 'absolute' || style.position !== 'absolute') {
                this._originalPosition = style.position;
                this._renderer.setStyle(this._elementRef.nativeElement.parentElement, 'position', 'relative');
            }
        }
    }
    _clearPosition() {
        if (isPlatformBrowser(this.platformId)) {
            if (this._originalPosition) {
                this._renderer.removeStyle(this._elementRef.nativeElement.parentElement, 'position');
            }
        }
    }
};
NtBadgeComponent.ctorParameters = () => [
    { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
    { type: ElementRef },
    { type: Renderer2 }
];
__decorate([
    Input()
], NtBadgeComponent.prototype, "color", void 0);
__decorate([
    Input()
], NtBadgeComponent.prototype, "class", void 0);
__decorate([
    Input()
], NtBadgeComponent.prototype, "type", null);
NtBadgeComponent = __decorate([
    Component({
        selector: 'nt-badge, [nt-badge]',
        template: `<ng-content></ng-content>`,
        encapsulation: ViewEncapsulation.None,
        host: {
            '[class]': '["badge", color, class].join(" ")',
            '[class.badge-float]': 'type === "float"',
            '[class.badge-notify]': 'type === "notify"'
        }
    }),
    __param(0, Inject(PLATFORM_ID))
], NtBadgeComponent);

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;
};
let NtBadgeModule = class NtBadgeModule {
};
NtBadgeModule = __decorate$1([
    NgModule({
        imports: [CommonModule],
        declarations: [NtBadgeComponent],
        exports: [NtBadgeComponent]
    })
], NtBadgeModule);

export { NtBadgeComponent, NtBadgeModule };
//# sourceMappingURL=badge.js.map
