import { combineLatest } from 'rxjs' ; import { Injectable } from '@angular/core' ; import { ContainerContent , Overlay , DialogRef , Modal as Modal_ , CSSBackdrop , PromiseCompleter } from 'ngx-modialog' ; import { BSModalContainer } from './modal-container.component' ; import { OneButtonPresetBuilder } from './presets/one-button-preset' ; import { TwoButtonPresetBuilder , PromptPresetBuilder } from './presets/two-button-preset' ; const isDoc = ! ( typeof document === 'undefined' || ! document ) ; let animationClass = 'show' ; deprecated export function bootstrap4Mode ( ) { } /**
 * Execute this method to flag that you are working with Bootstrap version 3.
 */ export function bootstrap3Mode ( ) { animationClass = 'in' ; } @ Injectable ( ) export class Modal extends Modal_ { constructor ( overlay ) { super ( overlay ) ; } alert ( ) { return new OneButtonPresetBuilder ( this , < any > { isBlocking : false } ) ; } prompt ( ) { return new PromptPresetBuilder ( this , < any > { isBlocking : true , keyboard : null } ) ; } confirm ( ) { return new TwoButtonPresetBuilder ( this , < any > { isBlocking : true , keyboard : null } ) ; } protected create ( dialogRef , content ) { const backdropRef = this . createBackdrop ( dialogRef , CSSBackdrop ) ; const containerRef = this . createContainer ( dialogRef , BSModalContainer , content ) ; let overlay = dialogRef . overlayRef . instance ; let backdrop = backdropRef . instance ; let container = containerRef . instance ; dialogRef . inElement ? overlay . insideElement ( ) : overlay . fullscreen ( ) ; if ( isDoc && ! document . body . classList . contains ( 'modal-open' ) ) { document . body . classList . add ( 'modal-open' ) ; } if ( dialogRef . inElement ) { backdrop . setStyle ( 'position' , 'absolute' ) ; } backdrop . addClass ( 'modal-backdrop fade' , true ) ; backdrop . addClass ( animationClass ) ; container . addClass ( animationClass ) ; if ( containerRef . location . nativeElement ) { containerRef . location . nativeElement . focus ( ) ; } overlay . beforeDestroy ( ( ) => { const completer = new PromiseCompleter < void > ( ) ; backdrop . removeClass ( animationClass ) ; container . removeClass ( animationClass ) ; combineLatest . call ( backdrop . myAnimationEnd$ ( ) , container . myAnimationEnd$ ( ) , ( s1 , s2 ) => [ s1 , s2 ] ) . subscribe ( sources => { isDoc && this . overlay . groupStackLength ( dialogRef ) === 1 && document . body . classList . remove ( 'modal-open' ) ; completer . resolve ( ) ; } ) ; return completer . promise ; } ) ; return dialogRef ; } }