import { take } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, HostListener, HostBinding, Directive, ViewContainerRef, ChangeDetectorRef, ComponentFactoryResolver, ViewChild, Injectable, Injector, ApplicationRef, NgModule } from '@angular/core';
import { trigger, transition, group, query, style, animate } from '@angular/animations';
import { Patch } from '@bravobit/bb-foundation';
import { BbButton, ElementsModule } from '@bravobit/bb-foundation/elements';
import { LocalizeModule } from '@bravobit/bb-foundation/localize';
import { CommonModule } from '@angular/common';

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.ref.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * @template T
 */
class BbDialogRef {
    constructor() {
        // Data.
        this._afterClosed$ = new Subject();
        this._overlayClicked$ = new Subject();
    }
    /**
     * @return {?}
     */
    get afterClosed() {
        return this._afterClosed$.pipe(take(1));
    }
    /**
     * @return {?}
     */
    get overlayClicked() {
        return this._overlayClicked$.pipe(take(1));
    }
    /**
     * @return {?}
     */
    onOverlayClicked() {
        this._overlayClicked$.next();
    }
    /**
     * @param {?=} result
     * @return {?}
     */
    close(result) {
        this._afterClosed$.next(result);
    }
}
if (false) {
    /**
     * @type {?}
     * @private
     */
    BbDialogRef.prototype._afterClosed$;
    /**
     * @type {?}
     * @private
     */
    BbDialogRef.prototype._overlayClicked$;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.interfaces.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * @template T
 */
class BbDialogConfig {
}
if (false) {
    /** @type {?} */
    BbDialogConfig.prototype.data;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-overlay/dialog-overlay.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogOverlay {
    constructor() {
        // Inputs.
        this.animations = true;
        // Outputs.
        this.closeRequested = new EventEmitter();
        // State.
        this._state = 'open';
        this._closed$ = new Subject();
    }
    /**
     * @return {?}
     */
    get state() {
        return this.animations
            ? this._state
            : 'none';
    }
    /**
     * @return {?}
     */
    onOverlayClicked() {
        this.closeRequested.emit();
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onKeyEvent(event) {
        if (event.key === 'Escape') {
            this.closeRequested.emit();
        }
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onAnimationDone(event) {
        // Check if the dialog is being destroyed.
        if (!['close', 'none'].includes(event.toState)) {
            return;
        }
        this._closed$.next();
        this._closed$.complete();
    }
    /**
     * @return {?}
     */
    close() {
        this._state = 'close';
        return this._closed$.pipe(take(1)).toPromise();
    }
}
BbDialogOverlay.decorators = [
    { type: Component, args: [{
                selector: 'bb-dialog-overlay',
                template: "<div class=\"bb-dialog-overlay-backdrop\"></div>\r\n\r\n<ng-content select=\"[bb-dialog-modal]\"></ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: { 'class': 'bb-dialog-overlay', '[@bbDialogAnimation]': 'state' },
                animations: [
                    trigger('bbDialogAnimation', [
                        transition('* => none', []),
                        transition(':enter, * => open', [
                            group([
                                query('.bb-dialog-overlay-backdrop', [
                                    style({ opacity: 0 }),
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 1 }))
                                ]),
                                query('.bb-dialog-modal', [
                                    style({ transform: 'scale(0.95)' }),
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({ transform: 'scale(1)' }))
                                ])
                            ])
                        ]),
                        transition(':leave, * => close', [
                            group([
                                query('.bb-dialog-overlay-backdrop', [
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0 }))
                                ]),
                                query('.bb-dialog-modal', [
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0, transform: 'scale(0.95)' }))
                                ])
                            ])
                        ])
                    ])
                ],
                styles: [".bb-dialog-overlay,.bb-dialog-overlay-backdrop{top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;z-index:1000;position:fixed;-ms-flex-direction:column;flex-direction:column}.bb-dialog-overlay{padding:20px}.bb-dialog-overlay-backdrop{background-color:rgba(0,0,0,.5)}.bb-dialog-overlay-component{z-index:1001;display:block;position:relative}"]
            }] }
];
BbDialogOverlay.propDecorators = {
    animations: [{ type: Input }],
    closeRequested: [{ type: Output }],
    onOverlayClicked: [{ type: HostListener, args: ['click',] }],
    onKeyEvent: [{ type: HostListener, args: ['window:keyup', ['$event'],] }],
    onAnimationDone: [{ type: HostListener, args: ['@bbDialogAnimation.done', ['$event'],] }]
};
if (false) {
    /** @type {?} */
    BbDialogOverlay.prototype.animations;
    /** @type {?} */
    BbDialogOverlay.prototype.closeRequested;
    /**
     * @type {?}
     * @private
     */
    BbDialogOverlay.prototype._state;
    /**
     * @type {?}
     * @private
     */
    BbDialogOverlay.prototype._closed$;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-modal/dialog-modal.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogModal {
    /**
     * @param {?} _patch
     */
    constructor(_patch) {
        this._patch = _patch;
        // Styling.
        this.maxWidth = '420px';
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onOverlayClickedEvent(event) {
        event.stopPropagation();
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this._patch.mobileVerticalHeight();
    }
}
BbDialogModal.decorators = [
    { type: Component, args: [{
                selector: '[bb-dialog-modal]',
                template: "<ng-content select=\"[bb-dialog-header]\">\r\n\r\n</ng-content>\r\n\r\n<div class=\"bb-dialog-modal-body\">\r\n    <ng-content></ng-content>\r\n</div>\r\n\r\n<ng-content select=\"[bb-dialog-actions]\">\r\n\r\n</ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dialog-modal',
                    'role': 'dialog'
                },
                styles: [".bb-dialog-modal{width:100%;margin:auto;z-index:1001;display:-ms-flexbox;display:flex;max-width:420px;border-radius:4px;position:relative;-ms-flex-direction:column;flex-direction:column;background-color:#fff;max-height:calc((var(--vh,1vh) * 100) - 40px)}.bb-dialog-modal-body{padding:20px;color:#738694;font-size:13px;overflow-y:auto;line-height:1.4;background-color:#f1f3f6}"]
            }] }
];
/** @nocollapse */
BbDialogModal.ctorParameters = () => [
    { type: Patch }
];
BbDialogModal.propDecorators = {
    maxWidth: [{ type: HostBinding, args: ['style.max-width',] }, { type: Input }],
    onOverlayClickedEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
};
if (false) {
    /** @type {?} */
    BbDialogModal.prototype.maxWidth;
    /**
     * @type {?}
     * @private
     */
    BbDialogModal.prototype._patch;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-header/dialog-header.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogHeader {
    constructor() {
        // Inputs.
        this.iconName = null;
        this.iconColor = 'black';
        // Outputs.
        this.closeRequested = new EventEmitter();
    }
}
BbDialogHeader.decorators = [
    { type: Component, args: [{
                selector: '[bb-dialog-header]',
                template: "<div class=\"bb-dialog-header-row\">\r\n    <div *ngIf=\"iconName as icon\"\r\n         [style.color]=\"iconColor\"\r\n         class=\"bb-dialog-header-icon\">\r\n        <i class=\"material-icons\">{{ icon }}</i>\r\n    </div>\r\n\r\n    <div class=\"bb-dialog-header-content\">\r\n        <ng-content></ng-content>\r\n    </div>\r\n\r\n    <button *ngIf=\"closeRequested?.observers?.length > 0\"\r\n            (click)=\"closeRequested?.emit()\"\r\n            type=\"button\"\r\n            class=\"bb-dialog-header-close\">\r\n    </button>\r\n</div>\r\n\r\n<nav class=\"bb-dialog-header-navigation\">\r\n    <ng-content select=\"[bb-dialog-link]\"></ng-content>\r\n</nav>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: { 'class': 'bb-dialog-header' },
                styles: [".bb-dialog-header{display:-ms-flexbox;display:flex;min-height:60px;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;background-color:#fff;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:1px solid #d8d8d8}.bb-dialog-header .bb-dialog-header-content,.bb-dialog-header .bb-dialog-header-content h1{max-width:100%;font-size:20px;font-weight:500;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.bb-dialog-header-navigation,.bb-dialog-header-row{width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.bb-dialog-header-row{padding:10px 20px}.bb-dialog-header-navigation{width:100%;padding:0 20px;overflow-x:auto;white-space:nowrap}.bb-dialog-header-navigation:empty{margin:0;height:0;padding:0;visibility:hidden}.bb-dialog-header-content{-ms-flex:1;flex:1}.bb-dialog-header-icon{width:40px;height:40px;display:-ms-flexbox;display:flex;min-width:40px;overflow:hidden;min-height:40px;margin-right:10px;border-radius:50%;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.bb-dialog-header-icon:after{top:0;left:0;right:0;bottom:0;content:\"\";opacity:.14;position:absolute;background-color:currentColor}.bb-dialog-header-close{width:32px;height:32px;border:none;min-width:32px;min-height:32px;overflow:hidden;margin-left:10px;border-radius:4px;position:relative;margin-right:-10px;display:inline-block;background-color:transparent}.bb-dialog-header-close:after,.bb-dialog-header-close:before{top:50%;left:20%;width:60%;height:2px;content:\"\";margin-top:-1px;position:absolute;background-color:#a2a9ba}.bb-dialog-header-close:before{-ms-transform:rotate(45deg);transform:rotate(45deg)}.bb-dialog-header-close:after{-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.bb-dialog-header-close:hover{background-color:rgba(0,0,0,.08)}.bb-dialog-header-close:focus{background-color:rgba(0,0,0,.12)}.bb-dialog-header-close:active{background-color:rgba(0,0,0,.16)}"]
            }] }
];
BbDialogHeader.propDecorators = {
    iconName: [{ type: Input }],
    iconColor: [{ type: Input }],
    closeRequested: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    BbDialogHeader.prototype.iconName;
    /** @type {?} */
    BbDialogHeader.prototype.iconColor;
    /** @type {?} */
    BbDialogHeader.prototype.closeRequested;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-link/dialog-link.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogLink {
}
BbDialogLink.decorators = [
    { type: Component, args: [{
                selector: '[bb-dialog-link]',
                template: "<ng-content></ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: { 'class': 'bb-dialog-link' },
                styles: [".bb-dialog-link{height:30px;display:-ms-flexbox;display:flex;font-size:16px;font-weight:500;white-space:nowrap;-ms-flex-align:center;align-items:center;color:#6b5c5c!important;background-color:transparent;text-decoration:none!important;border-bottom:2px solid transparent}.bb-dialog-link+.bb-dialog-link{margin-left:10px}.bb-dialog-link:hover:not(.disabled){border-bottom:2px solid rgba(117,119,148,.2)}.bb-dialog-link.active,.bb-dialog-link.active:hover{color:#5b53ff!important;border-bottom-color:#5b53ff}.bb-dialog-link.disabled,.bb-dialog-link.disabled:active,.bb-dialog-link.disabled:focus,.bb-dialog-link.disabled:hover{opacity:.4;cursor:default;box-shadow:none}"]
            }] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-actions/dialog-actions.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogActions {
}
BbDialogActions.decorators = [
    { type: Component, args: [{
                selector: '[bb-dialog-actions]',
                template: "<bb-form-group class=\"end\">\r\n    <ng-content></ng-content>\r\n</bb-form-group>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: { 'class': 'bb-dialog-actions' },
                styles: [".bb-dialog-actions{padding:20px;display:block;background-color:#fff;border-top:1px solid #d8d8d8;border-bottom-left-radius:4px;border-bottom-right-radius:4px}"]
            }] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.insertion.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogInsertion {
    /**
     * @param {?} viewContainerRef
     */
    constructor(viewContainerRef) {
        this.viewContainerRef = viewContainerRef;
    }
}
BbDialogInsertion.decorators = [
    { type: Directive, args: [{
                selector: '[bbDialogInsertion]'
            },] }
];
/** @nocollapse */
BbDialogInsertion.ctorParameters = () => [
    { type: ViewContainerRef }
];
if (false) {
    /** @type {?} */
    BbDialogInsertion.prototype.viewContainerRef;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-container/dialog-container.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogContainer {
    /**
     * @param {?} _changeDetection
     * @param {?} _componentFactoryResolver
     */
    constructor(_changeDetection, _componentFactoryResolver) {
        this._changeDetection = _changeDetection;
        this._componentFactoryResolver = _componentFactoryResolver;
        // Data.
        this.componentRef = null;
        this.childComponentType = null;
        // State.
        this.overlayClicked$ = new Subject();
    }
    /**
     * @return {?}
     */
    get onOverlayClicked() {
        return this.overlayClicked$.pipe(take(1));
    }
    /**
     * @return {?}
     */
    ngAfterViewInit() {
        // Load the child component.
        this.loadChildComponent(this.childComponentType);
        // Detect changes to notify change detection.
        this._changeDetection.detectChanges();
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onAnimationDone(event) {
        // Check if the dialog is being destroyed.
        if (event.toState !== 'void') {
            return;
        }
        // Destroy the ref if it exists.
        this.componentRef && this.componentRef.destroy();
    }
    /**
     * @return {?}
     */
    onOverlayClickedEvent() {
        this.overlayClicked$.next();
    }
    /**
     * @private
     * @param {?} componentType
     * @return {?}
     */
    loadChildComponent(componentType) {
        // Resolve the component.
        /** @type {?} */
        const componentFactory = this._componentFactoryResolver.resolveComponentFactory(componentType);
        // Get the view container ref and clear it.
        /** @type {?} */
        const viewContainerRef = this.insertion.viewContainerRef;
        viewContainerRef.clear();
        // Create an instance of the component.
        this.componentRef = viewContainerRef.createComponent(componentFactory);
    }
}
BbDialogContainer.decorators = [
    { type: Component, args: [{
                selector: 'bb-dialog-container',
                template: "<div class=\"bb-dialog-container-backdrop\">\r\n</div>\r\n\r\n<div class=\"bb-dialog-container-component\">\r\n    <ng-container bbDialogInsertion>\r\n    </ng-container>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                host: { 'class': 'bb-dialog-container', '[@bbDialogAnimation]': 'true' },
                preserveWhitespaces: false,
                animations: [
                    trigger('bbDialogAnimation', [
                        transition(':enter', [
                            group([
                                query('.bb-dialog-container-backdrop', [
                                    style({
                                        opacity: 0
                                    }),
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({
                                        opacity: 1
                                    }))
                                ]),
                                query('.bb-dialog-container-component', [
                                    style({
                                        transform: 'scale(0.95)'
                                    }),
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({
                                        transform: 'scale(1)'
                                    }))
                                ])
                            ])
                        ]),
                        transition(':leave', [
                            group([
                                query('.bb-dialog-container-backdrop', [
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({
                                        opacity: 0
                                    }))
                                ]),
                                query('.bb-dialog-container-component', [
                                    animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({
                                        opacity: 0,
                                        transform: 'scale(0.95)'
                                    }))
                                ])
                            ])
                        ])
                    ])
                ],
                styles: [".bb-dialog-container,.bb-dialog-container-backdrop{top:0;left:0;right:0;bottom:0;z-index:1000;position:fixed}.bb-dialog-container{display:-ms-flexbox;display:flex}.bb-dialog-container-backdrop{background-color:rgba(0,0,0,.5)}.bb-dialog-container-component{width:100%;margin:auto;padding:20px;z-index:1001;display:block}"]
            }] }
];
/** @nocollapse */
BbDialogContainer.ctorParameters = () => [
    { type: ChangeDetectorRef },
    { type: ComponentFactoryResolver }
];
BbDialogContainer.propDecorators = {
    insertion: [{ type: ViewChild, args: [BbDialogInsertion, { static: true },] }],
    onAnimationDone: [{ type: HostListener, args: ['@bbDialogAnimation.done', ['$event'],] }],
    onOverlayClickedEvent: [{ type: HostListener, args: ['click',] }]
};
if (false) {
    /** @type {?} */
    BbDialogContainer.prototype.insertion;
    /** @type {?} */
    BbDialogContainer.prototype.componentRef;
    /** @type {?} */
    BbDialogContainer.prototype.childComponentType;
    /** @type {?} */
    BbDialogContainer.prototype.overlayClicked$;
    /**
     * @type {?}
     * @private
     */
    BbDialogContainer.prototype._changeDetection;
    /**
     * @type {?}
     * @private
     */
    BbDialogContainer.prototype._componentFactoryResolver;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog-confirm/dialog-confirm.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @type {?} */
let nextUniqueId = 0;
class BbDialogConfirm {
    /**
     * @param {?} config
     * @param {?} dialogRef
     */
    constructor(config, dialogRef) {
        this.config = config;
        this.dialogRef = dialogRef;
        // Id.
        this.dialogId = `bb-dialog-confirm-${nextUniqueId++}`;
    }
    /**
     * @return {?}
     */
    ngAfterViewInit() {
        // Initial focus the button.
        this.confirmButton.focus();
    }
    /**
     * @param {?} result
     * @return {?}
     */
    onClose(result) {
        this.dialogRef.close(result);
    }
}
BbDialogConfirm.decorators = [
    { type: Component, args: [{
                selector: 'bb-dialog-confirm',
                template: "<div [attr.aria-labelledby]=\"dialogId\"\r\n     bb-dialog-modal\r\n     bbFocusTrap>\r\n    <header bb-dialog-header>\r\n        <h1 *ngIf=\"config?.data?.title as title\"\r\n            [id]=\"dialogId\">\r\n            {{ title | bbLocalize:{optional: true} }}\r\n        </h1>\r\n    </header>\r\n\r\n    <p>\r\n        {{ config?.data?.description | bbLocalize:{optional: true} }}\r\n    </p>\r\n\r\n    <footer bb-dialog-actions>\r\n        <button *ngIf=\"config?.data?.cancelButtonText as cancelButtonText\"\r\n                (click)=\"onClose(false)\"\r\n                bb-button\r\n                type=\"button\">\r\n            {{ cancelButtonText | bbLocalize:{optional: true} }}\r\n        </button>\r\n        <button #confirm\r\n                *ngIf=\"config?.data?.confirmButtonText as confirmButtonText\"\r\n                (click)=\"onClose(true)\"\r\n                bb-button\r\n                type=\"button\"\r\n                class=\"destructive\">\r\n            {{ confirmButtonText | bbLocalize:{optional: true} }}\r\n        </button>\r\n    </footer>\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: { 'class': 'bb-dialog-confirm' },
                styles: [".bb-dialog-confirm{display:block}"]
            }] }
];
/** @nocollapse */
BbDialogConfirm.ctorParameters = () => [
    { type: BbDialogConfig },
    { type: BbDialogRef }
];
BbDialogConfirm.propDecorators = {
    confirmButton: [{ type: ViewChild, args: ['confirm', { read: BbButton, static: false },] }]
};
if (false) {
    /** @type {?} */
    BbDialogConfirm.prototype.confirmButton;
    /** @type {?} */
    BbDialogConfirm.prototype.dialogId;
    /** @type {?} */
    BbDialogConfirm.prototype.config;
    /** @type {?} */
    BbDialogConfirm.prototype.dialogRef;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.injector.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDialogInjector {
    /**
     * @param {?} _parentInjector
     * @param {?} _additionalTokens
     */
    constructor(_parentInjector, _additionalTokens) {
        this._parentInjector = _parentInjector;
        this._additionalTokens = _additionalTokens;
    }
    /**
     * @param {?} token
     * @param {?=} notFoundValue
     * @return {?}
     */
    get(token, notFoundValue) {
        // First check if the additional token
        // contains the token.
        /** @type {?} */
        const value = this._additionalTokens.get(token);
        // If that value exists return it.
        if (value) {
            return value;
        }
        // Else query the parent injector.
        return this._parentInjector.get(token, notFoundValue);
    }
}
if (false) {
    /**
     * @type {?}
     * @private
     */
    BbDialogInjector.prototype._parentInjector;
    /**
     * @type {?}
     * @private
     */
    BbDialogInjector.prototype._additionalTokens;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class Dialog {
    /**
     * @param {?} _injector
     * @param {?} _applicationRef
     * @param {?} _componentFactoryResolver
     */
    constructor(_injector, _applicationRef, _componentFactoryResolver) {
        this._injector = _injector;
        this._applicationRef = _applicationRef;
        this._componentFactoryResolver = _componentFactoryResolver;
    }
    /**
     * @template T
     * @param {?} componentType
     * @param {?} config
     * @return {?}
     */
    open(componentType, config) {
        return this.createDialog(componentType, config);
    }
    /**
     * @param {?} title
     * @param {?} description
     * @param {?=} options
     * @return {?}
     */
    confirm(title, description, options = {}) {
        return this.open(BbDialogConfirm, {
            data: {
                title,
                description,
                cancelButtonText: options.cancelButtonText || 'dialog.default_cancel_button',
                confirmButtonText: options.confirmButtonText || 'dialog.default_confirm_button'
            }
        });
    }
    /**
     * @private
     * @template T
     * @param {?} componentType
     * @param {?} config
     * @return {?}
     */
    createDialog(componentType, config) {
        // Create a reference.
        /** @type {?} */
        const dialogRef = new BbDialogRef();
        // Create a map with the config.
        /** @type {?} */
        const map = new WeakMap();
        map.set(BbDialogConfig, config);
        map.set(BbDialogRef, dialogRef);
        // Create a custom injector.
        /** @type {?} */
        const dialogInjector = new BbDialogInjector(this._injector, map);
        // Resolve the dialog component reference.
        /** @type {?} */
        const dialogComponentRef = this._componentFactoryResolver
            .resolveComponentFactory(BbDialogContainer)
            .create(dialogInjector);
        // Attach the host view to the application.
        this._applicationRef.attachView(dialogComponentRef.hostView);
        try {
            // Remove the current focus.
            /** @type {?} */
            const activeElement = (/** @type {?} */ (document.activeElement));
            activeElement.blur();
            // Append the element to the DOM.
            document.body.appendChild(dialogComponentRef.location.nativeElement);
        }
        catch (_a) {
            // Don't do anything, because it must've failed.
        }
        // Set the child component type on the component.
        dialogComponentRef.instance.childComponentType = componentType;
        dialogComponentRef.instance.onOverlayClicked.subscribe((/**
         * @return {?}
         */
        () => dialogRef.onOverlayClicked()));
        // Listen for close events.
        dialogRef.afterClosed.subscribe((/**
         * @return {?}
         */
        () => this.deleteDialog(dialogComponentRef)));
        // Return the reference.
        return dialogRef;
    }
    /**
     * @private
     * @param {?} dialogComponentRef
     * @return {?}
     */
    deleteDialog(dialogComponentRef) {
        // Only continue if the dialog component ref exists.
        if (!dialogComponentRef) {
            return;
        }
        // Detach the dialog.
        this._applicationRef.detachView(dialogComponentRef.hostView);
        // Destroy the dialog.
        dialogComponentRef.destroy();
        dialogComponentRef = null;
    }
}
Dialog.decorators = [
    { type: Injectable }
];
/** @nocollapse */
Dialog.ctorParameters = () => [
    { type: Injector },
    { type: ApplicationRef },
    { type: ComponentFactoryResolver }
];
if (false) {
    /**
     * @type {?}
     * @private
     */
    Dialog.prototype._injector;
    /**
     * @type {?}
     * @private
     */
    Dialog.prototype._applicationRef;
    /**
     * @type {?}
     * @private
     */
    Dialog.prototype._componentFactoryResolver;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dialog.module.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class DialogModule {
    /**
     * @return {?}
     */
    static forRoot() {
        return {
            ngModule: DialogModule,
            providers: [Dialog]
        };
    }
}
DialogModule.decorators = [
    { type: NgModule, args: [{
                imports: [
                    CommonModule,
                    LocalizeModule,
                    ElementsModule
                ],
                declarations: [
                    BbDialogContainer,
                    BbDialogOverlay,
                    BbDialogModal,
                    BbDialogHeader,
                    BbDialogLink,
                    BbDialogActions,
                    BbDialogConfirm,
                    BbDialogInsertion
                ],
                entryComponents: [
                    BbDialogContainer,
                    BbDialogConfirm
                ],
                exports: [
                    BbDialogOverlay,
                    BbDialogModal,
                    BbDialogHeader,
                    BbDialogLink,
                    BbDialogActions
                ]
            },] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: public_api.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

/**
 * @fileoverview added by tsickle
 * Generated from: bravobit-bb-foundation-dialog.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

export { BbDialogActions, BbDialogConfig, BbDialogHeader, BbDialogLink, BbDialogModal, BbDialogOverlay, BbDialogRef, Dialog, DialogModule, BbDialogContainer as ɵa, BbDialogInsertion as ɵb, BbDialogConfirm as ɵc };
//# sourceMappingURL=bravobit-bb-foundation-dialog.js.map
