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 __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { ElementRef, Injectable, RendererFactory2 } from '@angular/core';
var ElementShowHideService = /** @class */ (function () {
    function ElementShowHideService(rendererFactory) {
        var _this = this;
        this.setStyle = function (el, style) {
            if (el instanceof ElementRef) {
                _this.renderer.setAttribute(el.nativeElement, ElementShowHideService_1.STYLE_ATTRIBUTE, style);
            }
        };
        this.renderer = rendererFactory.createRenderer(null, null);
    }
    ElementShowHideService_1 = ElementShowHideService;
    ElementShowHideService.prototype.show = function (el) {
        var style = this.getStyle(el).replace(ElementShowHideService_1.STYLE_DISPLAY_NONE_REGEX, '');
        this.setStyle(el, style);
    };
    ElementShowHideService.prototype.hide = function (el) {
        var style = this.getStyle(el).concat(ElementShowHideService_1.STYLE_DISPLAY_NONE);
        this.setStyle(el, style);
    };
    ElementShowHideService.prototype.isHidden = function (el) {
        return this.getStyle(el).indexOf(ElementShowHideService_1.STYLE_DISPLAY_NONE) !== -1;
    };
    ElementShowHideService.prototype.getStyle = function (el) {
        if (el instanceof ElementRef) {
            return el.nativeElement.getAttribute(ElementShowHideService_1.STYLE_ATTRIBUTE) || '';
        }
        return '';
    };
    var ElementShowHideService_1;
    ElementShowHideService.STYLE_ATTRIBUTE = 'style';
    ElementShowHideService.STYLE_DISPLAY_NONE = 'display: none !important;';
    ElementShowHideService.STYLE_DISPLAY_NONE_REGEX = new RegExp(ElementShowHideService_1.STYLE_DISPLAY_NONE, 'gi');
    ElementShowHideService = ElementShowHideService_1 = __decorate([
        Injectable(),
        __metadata("design:paramtypes", [RendererFactory2])
    ], ElementShowHideService);
    return ElementShowHideService;
}());
export { ElementShowHideService };
//# sourceMappingURL=element-show-hide.service.js.map