import * as i0 from '@angular/core';
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { FormControl } from '@ngneat/reactive-forms';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@aztrix/components/avatar';
import { AvatarModule } from '@aztrix/components/avatar';
import * as i3 from '@aztrix/components/button';
import { ButtonModule } from '@aztrix/components/button';
import * as i4 from '@aztrix/components/password-edit';
import { PasswordEditModule } from '@aztrix/components/password-edit';
import * as i5 from '@aztrix/helpers';
import { HelperPipesModule } from '@aztrix/helpers';
import * as i6 from '@aztrix/translate';
import { TranslatePipe } from '@aztrix/translate';
import { ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { IconsModule } from '@aztrix/icons';

class ProvidePasswordModalComponent {
    ngOnInit() {
        this.passwordForm = new FormControl('');
    }
    ngOnDestroy() {
        this.passwordForm.setValue(null);
    }
    providedWrongPassword() {
        if (this.passwordForm.value.length <= 8) {
            this.passwordForm.setErrors({ minlength: true });
            this.passwordForm.markAsTouched();
        }
        else {
            this.passwordForm.setErrors({ invalid: true });
            this.passwordForm.markAsTouched();
        }
    }
    executeConfirmAction() {
        this.didClickConfirm(this.passwordForm.value);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ProvidePasswordModalComponent, selector: "ax-provide-password-modal", ngImport: i0, template: "<div class=\"modal-content-wrapper\" [ngClass]=\"{'is-invalid': passwordForm.errors}\">\n  <!--avatar-->\n  <div class=\"c-modal__avatar\">\n    <ax-avatar-profile [profile]=\"profile\"></ax-avatar-profile>\n  </div>\n  <!--display name-->\n  <span class=\"c-modal__text\">{{ profile | displayName }}</span>\n\n  <!--password-->\n  <div class=\"c-modal__input-wrapper modal-padding\" (keyup.enter)=\"executeConfirmAction()\">\n    <ax-password-edit\n      [label]=\"passwordPlaceholder\"\n      [form]=\"passwordForm\"\n      [autofocus]=\"true\"\n      [showToggle]=\"true\"\n    ></ax-password-edit>\n  </div>\n  <!--button-->\n  <div class=\"h-button-wrapper\">\n    <button\n      axButton\n      (click)=\"executeConfirmAction()\"\n      [disabled]=\"passwordForm.value.length <= 7 || !!errorMessage\"\n      color=\"primary\"\n      filled\n    >\n      {{ 'label.confirm' | translate }}\n    </button>\n  </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: i2.AvatarProfileComponent, selector: "ax-avatar-profile", inputs: ["profile", "edit", "blocked", "border", "putBadge"], outputs: ["update"] }, { kind: "directive", type: i3.ButtonDirective, selector: "[axButton]", inputs: ["color", "labelHideMobile", "smallButton", "bigButton", "fullWidth", "filled", "outline", "icon-button", "hoverLabel", "hover", "lowercase", "disabled"] }, { kind: "component", type: i4.PasswordEditComponent, selector: "ax-password-edit", inputs: ["username", "showToggle", "forgotPasswordHint", "saveInPasswordManager", "minLength"] }, { kind: "pipe", type: i5.DisplayNamePipe, name: "displayName" }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-provide-password-modal', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"modal-content-wrapper\" [ngClass]=\"{'is-invalid': passwordForm.errors}\">\n  <!--avatar-->\n  <div class=\"c-modal__avatar\">\n    <ax-avatar-profile [profile]=\"profile\"></ax-avatar-profile>\n  </div>\n  <!--display name-->\n  <span class=\"c-modal__text\">{{ profile | displayName }}</span>\n\n  <!--password-->\n  <div class=\"c-modal__input-wrapper modal-padding\" (keyup.enter)=\"executeConfirmAction()\">\n    <ax-password-edit\n      [label]=\"passwordPlaceholder\"\n      [form]=\"passwordForm\"\n      [autofocus]=\"true\"\n      [showToggle]=\"true\"\n    ></ax-password-edit>\n  </div>\n  <!--button-->\n  <div class=\"h-button-wrapper\">\n    <button\n      axButton\n      (click)=\"executeConfirmAction()\"\n      [disabled]=\"passwordForm.value.length <= 7 || !!errorMessage\"\n      color=\"primary\"\n      filled\n    >\n      {{ 'label.confirm' | translate }}\n    </button>\n  </div>\n</div>\n" }]
        }] });

class ProvidePasswordModalModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalModule, declarations: [ProvidePasswordModalComponent], imports: [CommonModule,
            ReactiveFormsModule,
            MatFormFieldModule,
            MatInputModule,
            IconsModule,
            AvatarModule,
            HelperPipesModule,
            TranslatePipe,
            ButtonModule,
            PasswordEditModule], exports: [ProvidePasswordModalComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalModule, imports: [CommonModule,
            ReactiveFormsModule,
            MatFormFieldModule,
            MatInputModule,
            IconsModule,
            AvatarModule,
            HelperPipesModule,
            ButtonModule,
            PasswordEditModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ProvidePasswordModalModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [ProvidePasswordModalComponent],
                    imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        MatFormFieldModule,
                        MatInputModule,
                        IconsModule,
                        AvatarModule,
                        HelperPipesModule,
                        TranslatePipe,
                        ButtonModule,
                        PasswordEditModule,
                    ],
                    exports: [ProvidePasswordModalComponent],
                }]
        }] });

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

export { ProvidePasswordModalComponent, ProvidePasswordModalModule };
//# sourceMappingURL=aztrix-components-provide-password-modal.mjs.map
