text: "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 __metadata = (this && this.__metadata) || function (k, v) {
      if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var core_1 = require("@angular/core");
  var dialog_wrapper_component_1 = require("./dialog-wrapper.component");
  var DialogHolderComponent = (function () {
      function DialogHolderComponent(resolver) {
          this.resolver = resolver;
          this.dialogs = [];
      }
      DialogHolderComponent.prototype.addDialog = function (component, data, options) {
          var _this = this;
          options = options || {};
          var factory = this.resolver.resolveComponentFactory(dialog_wrapper_component_1.DialogWrapperComponent);
          var componentRef = this.element.createComponent(factory, options.index);
          var dialogWrapper = componentRef.instance;
          var _component = dialogWrapper.addComponent(component);
          if (typeof (options.index) !== 'undefined') {
              this.dialogs.splice(options.index, 0, _component);
          }
          else {
              this.dialogs.push(_component);
          }
          setTimeout(function () {
              dialogWrapper.container.nativeElement.classList.add('show');
              dialogWrapper.container.nativeElement.classList.add('in');
          });
          if (options.autoCloseTimeout) {
              setTimeout(function () {
                  _this.removeDialog(_component);
              }, options.autoCloseTimeout);
          }
          if (options.closeByClickingOutside) {
              dialogWrapper.closeByClickOutside();
          }
          if (options.backdropColor) {
              dialogWrapper.container.nativeElement.style.backgroundColor = options.backdropColor;
          }
          return _component.fillData(data);
      };
      DialogHolderComponent.prototype.removeDialog = function (component) {
          var _this = this;
          var element = component.wrapper.container.nativeElement;
          element.classList.remove('show');
          element.classList.remove('in');
          setTimeout(function () {
              _this._removeElement(component);
          }, 300);
      };
      DialogHolderComponent.prototype._removeElement = function (component) {
          var index = this.dialogs.indexOf(component);
          if (index > -1) {
              this.element.remove(index);
              this.dialogs.splice(index, 1);
          }
      };
      DialogHolderComponent.prototype.clear = function () {
          this.element.clear();
          this.dialogs = [];
      };
      return DialogHolderComponent;
  }());
  __decorate([
      core_1.ViewChild('element', { read: core_1.ViewContainerRef }),
      __metadata("design:type", core_1.ViewContainerRef)
  ], DialogHolderComponent.prototype, "element", void 0);
  DialogHolderComponent = __decorate([
      core_1.Component({
          selector: 'dialog-holder',
          template: '<template #element></template>',
      }),
      __metadata("design:paramtypes", [core_1.ComponentFactoryResolver])
  ], DialogHolderComponent);
  exports.DialogHolderComponent = DialogHolderComponent;
  //# sourceMappingURL=dialog-holder.component.js.map