import * as i0 from '@angular/core';
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
import * as i1 from '@aztrix/sdk';
import { ProfilePropertyRepresentation } from '@aztrix/sdk';
import { tap, first } from 'rxjs';
import * as i2 from '@aztrix/components/otp-verification';
import { OtpVerificationModule } from '@aztrix/components/otp-verification';
import * as i3 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i4 from '@aztrix/helpers';
import { HelperPipesModule } from '@aztrix/helpers';

class PropertyOtpVerificationComponent {
    constructor(_properties) {
        this._properties = _properties;
        this.canChangeValue = false;
        this.propertyUpdate = new EventEmitter();
        this.verificationComplete = new EventEmitter();
        this.verification = (code) => {
            return this._properties.verifyPropertyWithOtp(this.property.id, code).pipe(tap((property) => {
                this.property = property;
                this.verificationComplete.emit(this.property);
            }));
        };
        this.retryVerification = () => {
            return this._properties.requestVerificationForProperty(this.property.id);
        };
    }
    ngOnInit() {
        if (this.property.verification === ProfilePropertyRepresentation.VerificationEnum.UNVERIFIED) {
            this._properties
                .requestVerificationForProperty(this.property.id)
                .pipe(first())
                .subscribe((property) => this.propertyUpdate.emit(property));
        }
    }
}
PropertyOtpVerificationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PropertyOtpVerificationComponent, deps: [{ token: i1.PropertiesService }], target: i0.ɵɵFactoryTarget.Component });
PropertyOtpVerificationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: PropertyOtpVerificationComponent, selector: "ax-property-otp-verification", inputs: { property: "property", canChangeValue: "canChangeValue" }, outputs: { propertyUpdate: "propertyUpdate", verificationComplete: "verificationComplete" }, ngImport: i0, template: "<p>\n  {{\n    'agreement.verification.snackbar.message'\n      | translate\n        : {\n            verificationType: ('property.' + property.type + '.label' | translate | lowercase),\n            verificationValue: property.value\n          }\n  }}\n</p>\n<ax-otp-verification\n  [verificationValue]=\"property.value\"\n  [verificationType]=\"property.type\"\n  [verification]=\"verification\"\n  [retryVerification]=\"retryVerification\"\n  [canChangeValue]=\"false\"\n></ax-otp-verification>\n", styles: [":host{display:block;padding:1rem}p{margin:0}\n"], dependencies: [{ kind: "component", type: i2.OtpVerificationComponent, selector: "ax-otp-verification", inputs: ["verified", "verificationValue", "verificationType", "canChangeValue", "verification", "retryVerification"], outputs: ["verificationValueChanges", "verificationComplete"] }, { kind: "pipe", type: i3.LowerCasePipe, name: "lowercase" }, { kind: "pipe", type: i4.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: PropertyOtpVerificationComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-property-otp-verification', template: "<p>\n  {{\n    'agreement.verification.snackbar.message'\n      | translate\n        : {\n            verificationType: ('property.' + property.type + '.label' | translate | lowercase),\n            verificationValue: property.value\n          }\n  }}\n</p>\n<ax-otp-verification\n  [verificationValue]=\"property.value\"\n  [verificationType]=\"property.type\"\n  [verification]=\"verification\"\n  [retryVerification]=\"retryVerification\"\n  [canChangeValue]=\"false\"\n></ax-otp-verification>\n", styles: [":host{display:block;padding:1rem}p{margin:0}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.PropertiesService }]; }, propDecorators: { property: [{
                type: Input
            }], canChangeValue: [{
                type: Input
            }], propertyUpdate: [{
                type: Output
            }], verificationComplete: [{
                type: Output
            }] } });

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

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

export { PropertyOtpVerificationComponent, PropertyOtpVerificationModule };
//# sourceMappingURL=aztrix-components-property-otp-verification.mjs.map
