import * as i0 from '@angular/core';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewChild, Output, NgModule } from '@angular/core';
import * as i1 from '@aztrix/helpers';
import { HelperPipesModule } from '@aztrix/helpers';
import Passbase from '@passbase/button';
import { filter, first } from 'rxjs';
import { CommonModule } from '@angular/common';
import { ButtonModule } from '@aztrix/components/button';
import { IconsModule } from '@aztrix/icons';

class PassbaseButtonComponent {
    constructor(_environment) {
        this._environment = _environment;
        this.verificationFinished = new EventEmitter();
    }
    ngAfterViewInit() {
        this._environment
            .string$('PASSBASE_API_KEY')
            .pipe(filter((value) => !!value), first())
            .subscribe((passbaseApiKey) => {
            Passbase.default.renderButton(this.passbaseButton.nativeElement, passbaseApiKey, {
                onFinish: (identityAccessKey) => {
                    this.verificationFinished.emit(identityAccessKey);
                },
            });
        });
    }
}
PassbaseButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonComponent, deps: [{ token: i1.EnvironmentService }], target: i0.ɵɵFactoryTarget.Component });
PassbaseButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: PassbaseButtonComponent, selector: "ax-passbase-button", outputs: { verificationFinished: "verificationFinished" }, viewQueries: [{ propertyName: "passbaseButton", first: true, predicate: ["passbaseButton"], descendants: true }], ngImport: i0, template: "<div #passbaseButton></div>\n", styles: [":host{display:flex;align-items:center;justify-content:space-between}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-passbase-button', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div #passbaseButton></div>\n", styles: [":host{display:flex;align-items:center;justify-content:space-between}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.EnvironmentService }]; }, propDecorators: { passbaseButton: [{
                type: ViewChild,
                args: ['passbaseButton']
            }], verificationFinished: [{
                type: Output
            }] } });

class PassbaseButtonModule {
}
PassbaseButtonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
PassbaseButtonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonModule, declarations: [PassbaseButtonComponent], imports: [CommonModule, IconsModule, ButtonModule, HelperPipesModule], exports: [PassbaseButtonComponent] });
PassbaseButtonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonModule, imports: [CommonModule, IconsModule, ButtonModule, HelperPipesModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PassbaseButtonModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, IconsModule, ButtonModule, HelperPipesModule],
                    declarations: [PassbaseButtonComponent],
                    exports: [PassbaseButtonComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { PassbaseButtonComponent, PassbaseButtonModule };
//# sourceMappingURL=aztrix-components-passbase-button.mjs.map
//# sourceMappingURL=aztrix-components-passbase-button.mjs.map
