/**
 * @license
 * Copyright ASW (A Software World) All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file
 */
import { Component, Inject } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Constants, Icons } from '@asoftwareworld/form-builder-pro/common';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/material/dialog";
import * as i3 from "@angular/common";
import * as i4 from "@angular/material/button";
import * as i5 from "@angular/material/divider";
import * as i6 from "@angular/material/form-field";
import * as i7 from "@asoftwareworld/form-builder-pro/editor";
import * as i8 from "@asoftwareworld/form-builder-pro/common";
import * as i9 from "@asoftwareworld/form-builder-pro/core";
export class AswParagraphDialog {
    formBuilder;
    dialogRef;
    control;
    constants = Constants;
    icons = Icons;
    aswParagraphForm;
    status;
    constructor(formBuilder, dialogRef, control) {
        this.formBuilder = formBuilder;
        this.dialogRef = dialogRef;
        this.control = control;
    }
    ngOnInit() {
        this.validateFormBuilder();
        this.editProperty(this.control);
    }
    validateFormBuilder() {
        this.aswParagraphForm = this.formBuilder.group({
            label: ['', [Validators.required, Validators.minLength(2)]]
        });
    }
    editProperty(control) {
        this.aswParagraphForm.setValue({
            label: control.label
        });
    }
    onNoClick() {
        this.dialogRef.close();
    }
    onSubmit() {
        if (this.aswParagraphForm.invalid) {
            return;
        }
        this.aswParagraphForm.value.controlType = this.control.controlType;
        this.aswParagraphForm.value.id = this.control.id;
        this.aswParagraphForm.value.guid = this.control.guid;
        this.dialogRef.close(this.aswParagraphForm.value);
    }
    onChange(event) {
        if (event.checked) {
            this.status = true;
        }
        else {
            this.status = false;
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: AswParagraphDialog, deps: [{ token: i1.FormBuilder }, { token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: AswParagraphDialog, selector: "asw-paragraph-dialog", ngImport: i0, template: "<div class=\"asw-dialog-header\">\r\n    <div class=\"asw-edit-row-dialog\">\r\n        <div class=\"asw-dialog-header clearfix\">\r\n            <div class=\"asw-dialog-about\">\r\n                <h1 mat-dialog-title class=\"asw-m-0\">{{'FormControl.EditParagraph' | aswTranslate}}</h1>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <button mat-icon-button (click)=\"onNoClick()\" aria-label=\"Close dialog\" class=\"asw-mt-2 asw-me-2\">\r\n        <div [innerHTML]=\"icons.close | aswSafeHtml\"></div>\r\n    </button>\r\n</div>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswParagraphForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-row\">\r\n            <div class=\"asw-col-md-12\">\r\n                <asw-editor autofocus=\"true\" id=\"asw-editor\" formControlName=\"label\" [config]=\"constants.aswEditorConfig\"></asw-editor>\r\n                <ng-container *ngFor=\"let validation of constants.accountValidationMessages.label\">\r\n                    <mat-error *ngIf=\"aswParagraphForm.get('label')?.hasError(validation.type) && (aswParagraphForm.get('label')?.dirty || aswParagraphForm.get('label')?.touched)\">\r\n                        {{validation.message | aswTranslate}}\r\n                    </mat-error>\r\n                </ng-container>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-divider></mat-divider>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"asw-button asw-button-danger asw-me-2 asw-mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            {{'FormControl.No' | aswTranslate}}\r\n        </button>\r\n        <button type=\"submit\"\r\n                class=\"asw-button asw-button-primary asw-mb-1\"\r\n                cdkFocusInitial>\r\n            {{'FormControl.Yes' | aswTranslate}}\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>\r\n\r\n", dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: i5.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: i6.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "component", type: i7.AswEditor, selector: "asw-editor", inputs: ["id", "config", "placeholder", "tabIndex"], outputs: ["html", "viewMode", "blur", "focus"] }, { kind: "pipe", type: i8.AswSafeHtmlPipe, name: "aswSafeHtml" }, { kind: "pipe", type: i9.AswTranslatePipe, name: "aswTranslate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: AswParagraphDialog, decorators: [{
            type: Component,
            args: [{ selector: 'asw-paragraph-dialog', template: "<div class=\"asw-dialog-header\">\r\n    <div class=\"asw-edit-row-dialog\">\r\n        <div class=\"asw-dialog-header clearfix\">\r\n            <div class=\"asw-dialog-about\">\r\n                <h1 mat-dialog-title class=\"asw-m-0\">{{'FormControl.EditParagraph' | aswTranslate}}</h1>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <button mat-icon-button (click)=\"onNoClick()\" aria-label=\"Close dialog\" class=\"asw-mt-2 asw-me-2\">\r\n        <div [innerHTML]=\"icons.close | aswSafeHtml\"></div>\r\n    </button>\r\n</div>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswParagraphForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-row\">\r\n            <div class=\"asw-col-md-12\">\r\n                <asw-editor autofocus=\"true\" id=\"asw-editor\" formControlName=\"label\" [config]=\"constants.aswEditorConfig\"></asw-editor>\r\n                <ng-container *ngFor=\"let validation of constants.accountValidationMessages.label\">\r\n                    <mat-error *ngIf=\"aswParagraphForm.get('label')?.hasError(validation.type) && (aswParagraphForm.get('label')?.dirty || aswParagraphForm.get('label')?.touched)\">\r\n                        {{validation.message | aswTranslate}}\r\n                    </mat-error>\r\n                </ng-container>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-divider></mat-divider>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"asw-button asw-button-danger asw-me-2 asw-mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            {{'FormControl.No' | aswTranslate}}\r\n        </button>\r\n        <button type=\"submit\"\r\n                class=\"asw-button asw-button-primary asw-mb-1\"\r\n                cdkFocusInitial>\r\n            {{'FormControl.Yes' | aswTranslate}}\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>\r\n\r\n" }]
        }], ctorParameters: function () { return [{ type: i1.FormBuilder }, { type: i2.MatDialogRef }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }]; } });
//# sourceMappingURL=data:application/json;base64, 