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);
  };
  var __param = (this && this.__param) || function (paramIndex, decorator) {
      return function (target, key) { decorator(target, key, paramIndex); }
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var core_1 = require("@angular/core");
  var common_1 = require("@angular/common");
  var animations_1 = require("@angular/animations");
  var messageservice_1 = require("../common/messageservice");
  var Messages = /** @class */ (function () {
      function Messages(messageService) {
          this.messageService = messageService;
          this.closable = true;
          this.enableService = true;
          this.showTransitionOptions = '300ms ease-out';
          this.hideTransitionOptions = '250ms ease-in';
          this.valueChange = new core_1.EventEmitter();
      }
      Messages.prototype.ngOnInit = function () {
          var _this = this;
          if (this.messageService && this.enableService) {
              this.messageSubscription = this.messageService.messageObserver.subscribe(function (messages) {
                  if (messages) {
                      if (messages instanceof Array) {
                          var filteredMessages = messages.filter(function (m) { return _this.key === m.key; });
                          _this.value = _this.value ? _this.value.concat(filteredMessages) : filteredMessages.slice();
                      }
                      else if (_this.key === messages.key) {
                          _this.value = _this.value ? _this.value.concat([messages]) : [messages];
                      }
                  }
              });
              this.clearSubscription = this.messageService.clearObserver.subscribe(function (key) {
                  if (key) {
                      if (_this.key === key) {
                          _this.value = null;
                      }
                  }
                  else {
                      _this.value = null;
                  }
              });
          }
      };
      Messages.prototype.hasMessages = function () {
          return this.value && this.value.length > 0;
      };
      Messages.prototype.getSeverityClass = function () {
          return this.value[0].severity;
      };
      Messages.prototype.clear = function (event) {
          this.value = [];
          this.valueChange.emit(this.value);
          event.preventDefault();
      };
      Object.defineProperty(Messages.prototype, "icon", {
          get: function () {
              var icon = null;
              if (this.hasMessages()) {
                  var msg = this.value[0];
                  switch (msg.severity) {
                      case 'success':
                          icon = 'pi-check';
                          break;
                      case 'info':
                          icon = 'pi-info-circle';
                          break;
                      case 'error':
                          icon = 'pi-times';
                          break;
                      case 'warn':
                          icon = 'pi-exclamation-triangle';
                          break;
                      default:
                          icon = 'pi-info-circle';
                          break;
                  }
              }
              return icon;
          },
          enumerable: true,
          configurable: true
      });
      Messages.prototype.ngOnDestroy = function () {
          if (this.messageSubscription) {
              this.messageSubscription.unsubscribe();
          }
          if (this.clearSubscription) {
              this.clearSubscription.unsubscribe();
          }
      };
      __decorate([
          core_1.Input(),
          __metadata("design:type", Array)
      ], Messages.prototype, "value", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", Boolean)
      ], Messages.prototype, "closable", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", Object)
      ], Messages.prototype, "style", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", String)
      ], Messages.prototype, "styleClass", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", Boolean)
      ], Messages.prototype, "enableService", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", String)
      ], Messages.prototype, "key", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", String)
      ], Messages.prototype, "showTransitionOptions", void 0);
      __decorate([
          core_1.Input(),
          __metadata("design:type", String)
      ], Messages.prototype, "hideTransitionOptions", void 0);
      __decorate([
          core_1.Output(),
          __metadata("design:type", core_1.EventEmitter)
      ], Messages.prototype, "valueChange", void 0);
      Messages = __decorate([
          core_1.Component({
              selector: 'p-messages',
              template: "\n        <div *ngIf=\"hasMessages()\" class=\"ui-messages ui-widget ui-corner-all\" style=\"display:block\"\n                    [ngClass]=\"{'ui-messages-info':(value[0].severity === 'info'),\n                    'ui-messages-warn':(value[0].severity === 'warn'),\n                    'ui-messages-error':(value[0].severity === 'error'),\n                    'ui-messages-success':(value[0].severity === 'success')}\"\n                    [ngStyle]=\"style\" [class]=\"styleClass\" [@messageAnimation]=\"{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\">\n            <a tabindex=\"0\" class=\"ui-messages-close\" (click)=\"clear($event)\" (keydown.enter)=\"clear($event)\" *ngIf=\"closable\">\n                <i class=\"pi pi-times\"></i>\n            </a>\n            <span class=\"ui-messages-icon pi\" [ngClass]=\"icon\"></span>\n            <ul>\n                <li *ngFor=\"let msg of value\">\n                    <span *ngIf=\"msg.summary\" class=\"ui-messages-summary\" [innerHTML]=\"msg.summary\"></span>\n                    <span *ngIf=\"msg.detail\" class=\"ui-messages-detail\" [innerHTML]=\"msg.detail\"></span>\n                </li>\n            </ul>\n        </div>\n    ",
              animations: [
                  animations_1.trigger('messageAnimation', [
                      animations_1.state('visible', animations_1.style({
                          transform: 'translateY(0)',
                          opacity: 1
                      })),
                      animations_1.transition('void => *', [
                          animations_1.style({ transform: 'translateY(-25%)', opacity: 0 }),
                          animations_1.animate('{{showTransitionParams}}')
                      ]),
                      animations_1.transition('* => void', [
                          animations_1.animate(('{{hideTransitionParams}}'), animations_1.style({
                              opacity: 0,
                              transform: 'translateY(-25%)'
                          }))
                      ])
                  ])
              ]
          }),
          __param(0, core_1.Optional()),
          __metadata("design:paramtypes", [messageservice_1.MessageService])
      ], Messages);
      return Messages;
  }());
  exports.Messages = Messages;
  var MessagesModule = /** @class */ (function () {
      function MessagesModule() {
      }
      MessagesModule = __decorate([
          core_1.NgModule({
              imports: [common_1.CommonModule],
              exports: [Messages],
              declarations: [Messages]
          })
      ], MessagesModule);
      return MessagesModule;
  }());
  exports.MessagesModule = MessagesModule;
  //# sourceMappingURL=messages.js.map