text: import { DOCUMENT } from '@angular/common';
  import { Component, Output, EventEmitter, Input, Inject, ElementRef, Renderer2 } from '@angular/core';
  import { ModalDismissReasons } from './modal-dismiss-reasons';
  import { ngbFocusTrap } from '../util/focus-trap';
  var NgbModalWindow = /** @class */ (function () {
      function NgbModalWindow(document, _elRef, _renderer) {
          this._elRef = _elRef;
          this._renderer = _renderer;
          this.backdrop = true;
          this.keyboard = true;
          this.dismissEvent = new EventEmitter();
          this._document = document;
          ngbFocusTrap(this._elRef.nativeElement, this.dismissEvent);
      }
      NgbModalWindow.prototype.backdropClick = function ($event) {
          if (this.backdrop === true && this._elRef.nativeElement === $event.target) {
              this.dismiss(ModalDismissReasons.BACKDROP_CLICK);
          }
      };
      NgbModalWindow.prototype.escKey = function ($event) {
          if (this.keyboard && !$event.defaultPrevented) {
              this.dismiss(ModalDismissReasons.ESC);
          }
      };
      NgbModalWindow.prototype.dismiss = function (reason) { this.dismissEvent.emit(reason); };
      NgbModalWindow.prototype.ngOnInit = function () {
          this._elWithFocus = this._document.activeElement;
          this._renderer.addClass(this._document.body, 'modal-open');
      };
      NgbModalWindow.prototype.ngAfterViewInit = function () {
          if (!this._elRef.nativeElement.contains(document.activeElement)) {
              this._elRef.nativeElement['focus'].apply(this._elRef.nativeElement, []);
          }
      };
      NgbModalWindow.prototype.ngOnDestroy = function () {
          var body = this._document.body;
          var elWithFocus = this._elWithFocus;
          var elementToFocus;
          if (elWithFocus && elWithFocus['focus'] && body.contains(elWithFocus)) {
              elementToFocus = elWithFocus;
          }
          else {
              elementToFocus = body;
          }
          elementToFocus['focus'].apply(elementToFocus, []);
          this._elWithFocus = null;
          this._renderer.removeClass(body, 'modal-open');
      };
      NgbModalWindow.decorators = [
          { type: Component, args: [{
                      selector: 'ngb-modal-window',
                      host: {
                          '[class]': '"modal fade show d-block" + (windowClass ? " " + windowClass : "")',
                          'role': 'dialog',
                          'tabindex': '-1',
                          '(keyup.esc)': 'escKey($event)',
                          '(click)': 'backdropClick($event)',
                          '[attr.aria-labelledby]': 'ariaLabelledBy',
                      },
                      template: "\n    <div [class]=\"'modal-dialog' + (size ? ' modal-' + size : '') + (centered ? ' modal-dialog-centered' : '')\" role=\"document\">\n        <div class=\"modal-content\"><ng-content></ng-content></div>\n    </div>\n    "
                  },] },
      ];
      /** @nocollapse */
      NgbModalWindow.ctorParameters = function () { return [
          { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] },
          { type: ElementRef, },
          { type: Renderer2, },
      ]; };
      NgbModalWindow.propDecorators = {
          "ariaLabelledBy": [{ type: Input },],
          "backdrop": [{ type: Input },],
          "centered": [{ type: Input },],
          "keyboard": [{ type: Input },],
          "size": [{ type: Input },],
          "windowClass": [{ type: Input },],
          "dismissEvent": [{ type: Output, args: ['dismiss',] },],
      };
      return NgbModalWindow;
  }());
  export { NgbModalWindow };
  //# sourceMappingURL=modal-window.js.map