!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/utils"),require("ngx-bootstrap/component-loader"),require("ngx-bootstrap/positioning")):"function"==typeof define&&define.amd?define("ngx-bootstrap/modal",["exports","@angular/core","ngx-bootstrap/utils","ngx-bootstrap/component-loader","ngx-bootstrap/positioning"],t):t(((e=e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].modal={}),e.ng.core,e.utils,e.componentLoader,e.positioning)}(this,function(e,t,i,o,n){"use strict";var s=function(){function e(){this.hide=Function,this.setClass=Function}return e.decorators=[{type:t.Injectable}],e}(),r=function(e){this.animate=!0,Object.assign(this,e)},d=function(){function e(){}return e.decorators=[{type:t.Injectable}],e}(),a={backdrop:!0,keyboard:!0,focus:!0,show:!1,ignoreBackdropClick:!1,class:"",animated:!0,initialState:{}},h={SCROLLBAR_MEASURER:"modal-scrollbar-measure",BACKDROP:"modal-backdrop",OPEN:"modal-open",FADE:"fade",IN:"in",SHOW:"show"},c=300,l=150,p="backdrop-click",m="esc",u=function(){function e(e,t,i){this._element=t,this._renderer=i,this.isShown=!1,this.isModalHiding=!1,this.config=Object.assign({},e)}return e.prototype.ngOnInit=function(){var e=this;this.isAnimated&&this._renderer.addClass(this._element.nativeElement,h.FADE),this._renderer.setStyle(this._element.nativeElement,"display","block"),setTimeout(function(){e.isShown=!0,e._renderer.addClass(e._element.nativeElement,i.isBs3()?h.IN:h.SHOW)},this.isAnimated?l:0),document&&document.body&&(1===this.bsModalService.getModalsCount()&&(this.bsModalService.checkScrollbar(),this.bsModalService.setScrollbar()),this._renderer.addClass(document.body,h.OPEN)),this._element.nativeElement&&this._element.nativeElement.focus()},e.prototype.onClick=function(e){this.config.ignoreBackdropClick||"static"===this.config.backdrop||e.target!==this._element.nativeElement||(this.bsModalService.setDismissReason(p),this.hide())},e.prototype.onEsc=function(e){this.isShown&&(27!==e.keyCode&&"Escape"!==e.key||e.preventDefault(),this.config.keyboard&&this.level===this.bsModalService.getModalsCount()&&(this.bsModalService.setDismissReason(m),this.hide()))},e.prototype.ngOnDestroy=function(){this.isShown&&this.hide()},e.prototype.hide=function(){var e=this;!this.isModalHiding&&this.isShown&&(this.isModalHiding=!0,this._renderer.removeClass(this._element.nativeElement,i.isBs3()?h.IN:h.SHOW),setTimeout(function(){e.isShown=!1,document&&document.body&&1===e.bsModalService.getModalsCount()&&e._renderer.removeClass(document.body,h.OPEN),e.bsModalService.hide(e.level),e.isModalHiding=!1},this.isAnimated?c:0))},e.decorators=[{type:t.Component,args:[{selector:"modal-container",template:"\n
\n ",host:{class:"modal",role:"dialog",tabindex:"-1","[attr.aria-modal]":"true"}}]}],e.ctorParameters=function(){return[{type:d},{type:t.ElementRef},{type:t.Renderer2}]},e.propDecorators={onClick:[{type:t.HostListener,args:["click",["$event"]]}],onEsc:[{type:t.HostListener,args:["window:keydown.esc",["$event"]]}]},e}(),f=function(){function e(e,t){this._isShown=!1,this.element=e,this.renderer=t}return Object.defineProperty(e.prototype,"isAnimated",{get:function(){return this._isAnimated},set:function(e){this._isAnimated=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isShown",{get:function(){return this._isShown},set:function(e){this._isShown=e,e?this.renderer.addClass(this.element.nativeElement,""+h.IN):this.renderer.removeClass(this.element.nativeElement,""+h.IN),i.isBs3()||(e?this.renderer.addClass(this.element.nativeElement,""+h.SHOW):this.renderer.removeClass(this.element.nativeElement,""+h.SHOW))},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.isAnimated&&(this.renderer.addClass(this.element.nativeElement,""+h.FADE),i.Utils.reflow(this.element.nativeElement)),this.isShown=!0},e.decorators=[{type:t.Component,args:[{selector:"bs-modal-backdrop",template:" ",host:{class:h.BACKDROP}}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2}]},e}(),y=function(){function e(e,i,o,n){this._element=e,this._renderer=o,this.onShow=new t.EventEmitter,this.onShown=new t.EventEmitter,this.onHide=new t.EventEmitter,this.onHidden=new t.EventEmitter,this._isShown=!1,this.isBodyOverflowing=!1,this.originalBodyPadding=0,this.scrollbarWidth=0,this.timerHideModal=0,this.timerRmBackDrop=0,this.isNested=!1,this._backdrop=n.createLoader(e,i,o)}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},set:function(e){this._config=this.getConfig(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isShown",{get:function(){return this._isShown},enumerable:!0,configurable:!0}),e.prototype.onClick=function(e){this.config.ignoreBackdropClick||"static"===this.config.backdrop||e.target!==this._element.nativeElement||(this.dismissReason=p,this.hide(e))},e.prototype.onEsc=function(e){this._isShown&&(27!==e.keyCode&&"Escape"!==e.key||e.preventDefault(),this.config.keyboard&&(this.dismissReason=m,this.hide()))},e.prototype.ngOnDestroy=function(){this.config=void 0,this._isShown&&(this._isShown=!1,this.hideModal(),this._backdrop.dispose())},e.prototype.ngOnInit=function(){var e=this;this._config=this._config||this.getConfig(),setTimeout(function(){e._config.show&&e.show()},0)},e.prototype.toggle=function(){return this._isShown?this.hide():this.show()},e.prototype.show=function(){var e=this;this.dismissReason=null,this.onShow.emit(this),this._isShown||(clearTimeout(this.timerHideModal),clearTimeout(this.timerRmBackDrop),this._isShown=!0,this.checkScrollbar(),this.setScrollbar(),i.document&&i.document.body&&(i.document.body.classList.contains(h.OPEN)?this.isNested=!0:this._renderer.addClass(i.document.body,h.OPEN)),this.showBackdrop(function(){e.showElement()}))},e.prototype.hide=function(e){var t=this;e&&e.preventDefault(),this.onHide.emit(this),this._isShown&&(i.window.clearTimeout(this.timerHideModal),i.window.clearTimeout(this.timerRmBackDrop),this._isShown=!1,this._renderer.removeClass(this._element.nativeElement,h.IN),i.isBs3()||this._renderer.removeClass(this._element.nativeElement,h.SHOW),this._config.animated?this.timerHideModal=i.window.setTimeout(function(){return t.hideModal()},300):this.hideModal())},e.prototype.getConfig=function(e){return Object.assign({},a,e)},e.prototype.showElement=function(){var e=this;this._element.nativeElement.parentNode&&this._element.nativeElement.parentNode.nodeType===Node.ELEMENT_NODE||i.document&&i.document.body&&i.document.body.appendChild(this._element.nativeElement),this._renderer.setAttribute(this._element.nativeElement,"aria-hidden","false"),this._renderer.setAttribute(this._element.nativeElement,"aria-modal","true"),this._renderer.setStyle(this._element.nativeElement,"display","block"),this._renderer.setProperty(this._element.nativeElement,"scrollTop",0),this._config.animated&&i.Utils.reflow(this._element.nativeElement),this._renderer.addClass(this._element.nativeElement,h.IN),i.isBs3()||this._renderer.addClass(this._element.nativeElement,h.SHOW);var t=function(){e._config.focus&&e._element.nativeElement.focus(),e.onShown.emit(e)};this._config.animated?setTimeout(t,300):t()},e.prototype.hideModal=function(){var e=this;this._renderer.setAttribute(this._element.nativeElement,"aria-hidden","true"),this._renderer.setStyle(this._element.nativeElement,"display","none"),this.showBackdrop(function(){e.isNested||(i.document&&i.document.body&&e._renderer.removeClass(i.document.body,h.OPEN),e.resetScrollbar()),e.resetAdjustments(),e.focusOtherModal(),e.onHidden.emit(e)})},e.prototype.showBackdrop=function(e){var t=this;if(!this._isShown||!this.config.backdrop||this.backdrop&&this.backdrop.instance.isShown)if(!this._isShown&&this.backdrop){this.backdrop.instance.isShown=!1;var o=function(){t.removeBackdrop(),e&&e()};this.backdrop.instance.isAnimated?this.timerRmBackDrop=i.window.setTimeout(o,150):o()}else e&&e();else{if(this.removeBackdrop(),this._backdrop.attach(f).to("body").show({isAnimated:this._config.animated}),this.backdrop=this._backdrop._componentRef,!e)return;if(!this._config.animated)return void e();setTimeout(e,150)}},e.prototype.removeBackdrop=function(){this._backdrop.hide()},e.prototype.focusOtherModal=function(){if(null!=this._element.nativeElement.parentElement){var e=this._element.nativeElement.parentElement.querySelectorAll(".in[bsModal]");e.length&&e[e.length-1].focus()}},e.prototype.resetAdjustments=function(){this._renderer.setStyle(this._element.nativeElement,"paddingLeft",""),this._renderer.setStyle(this._element.nativeElement,"paddingRight","")},e.prototype.checkScrollbar=function(){this.isBodyOverflowing=i.document.body.clientWidth=1?this.modalsCount-1:0,setTimeout(function(){t._hideModal(e),t.removeLoaders(e)},this.config.animated?l:0)},e.prototype._showBackdrop=function(){var e=this.config.backdrop||"static"===this.config.backdrop,t=!this.backdropRef||!this.backdropRef.instance.isShown;1===this.modalsCount&&(this.removeBackdrop(),e&&t&&(this._backdropLoader.attach(f).to("body").show({isAnimated:this.config.animated}),this.backdropRef=this._backdropLoader._componentRef))},e.prototype._hideBackdrop=function(){var e=this;if(this.backdropRef){this.backdropRef.instance.isShown=!1;var t=this.config.animated?l:0;setTimeout(function(){return e.removeBackdrop()},t)}},e.prototype._showModal=function(e){var t=this.loaders[this.loaders.length-1],i=new s,o=t.provide({provide:d,useValue:this.config}).provide({provide:s,useValue:i}).attach(u).to("body").show({content:e,isAnimated:this.config.animated,initialState:this.config.initialState,bsModalService:this});return o.instance.level=this.getModalsCount(),i.hide=function(){o.instance.hide()},i.content=t.getInnerComponent()||null,i.setClass=function(e){o.instance.config.class=e},i},e.prototype._hideModal=function(e){var t=this.loaders[e-1];t&&t.hide()},e.prototype.getModalsCount=function(){return this.modalsCount},e.prototype.setDismissReason=function(e){this.lastDismissReason=e},e.prototype.removeBackdrop=function(){this._backdropLoader.hide(),this.backdropRef=null},e.prototype.checkScrollbar=function(){this.isBodyOverflowing=document.body.clientWidth