import * as i0 from '@angular/core';
import { Component, Inject, EventEmitter, Input, Output, NgModule } from '@angular/core';
import { AswConfirmDialog, AswConfirmDialogModule } from '@asoftwareworld/form-builder/form-control/confirm-dialog';
import { Constants } from '@asoftwareworld/form-builder/form-control/core';
import * as i1 from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import * as i2 from '@angular/material/divider';
import { MatDividerModule } from '@angular/material/divider';
import * as i3 from '@asoftwareworld/form-builder/image-drawing';
import { AswImageDrawingModule } from '@asoftwareworld/form-builder/image-drawing';
import * as i4 from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as i2$1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3$1 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';

/**
 * @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
 */
class AswSignatureDialog {
    constructor(dialogRef, control) {
        this.dialogRef = dialogRef;
        this.control = control;
        this.width = 600;
        this.height = 250;
    }
    onNoClick() {
        this.dialogRef.close();
    }
    onSubmit(aswEditPropertyForm) {
        if (aswEditPropertyForm.invalid) {
            return;
        }
        // this.model.displayName = this.control.displayName;
        // this.model.controlType = this.control.controlType;
        // this.model.name = this.name;
        // this.model.label = this.label;
        // this.model.tooltip = this.tooltip;
        // if (this.control.controlType !== 'radio' || this.control.controlType !== 'checkbox') {
        //     this.model.style = this.style;
        // }
        // this.model.isRequired = this.isRequired;
        // this.model.options = this.options;
        // this.dialogRef.close(this.model);
    }
}
AswSignatureDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureDialog, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
AswSignatureDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: AswSignatureDialog, selector: "asw-signature-dialog", ngImport: i0, template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form #aswEditPropertyForm=\"ngForm\" (ngSubmit)=\"onSubmit(aswEditPropertyForm)\" novalidate>\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <asw-image-drawing [width]=\"width\" [height]=\"height\"\r\n                       borderCss=\"1px solid black\"\r\n                       [showCancelButton]=\"false\"\r\n                       outputMimeType=\"'image/jpeg'\"            \r\n                       [drawingSizes]=\"{ small: 3, medium: 10, large: 25, extra: 50 }\">\r\n        </asw-image-drawing>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button mat-raised-button\r\n                type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <button mat-raised-button type=\"submit\"\r\n                class=\"btn btn-primary mb-1\"\r\n                cdkFocusInitial>\r\n            Yes\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>", components: [{ type: i2.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i3.AswImageDrawingComponent, selector: "asw-image-drawing", inputs: ["src", "width", "height", "forceSizeCanvas", "forceSizeExport", "enableRemoveImage", "enableLoadAnotherImage", "enableTooltip", "showCancelButton", "saveBtnText", "cancelBtnText", "loadingText", "loadingTemplate", "errorTemplate", "outputMimeType", "outputQuality", "drawingSizes", "colors"], outputs: ["save", "cancel"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i4.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i4.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureDialog, decorators: [{
            type: Component,
            args: [{ selector: 'asw-signature-dialog', template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form #aswEditPropertyForm=\"ngForm\" (ngSubmit)=\"onSubmit(aswEditPropertyForm)\" novalidate>\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <asw-image-drawing [width]=\"width\" [height]=\"height\"\r\n                       borderCss=\"1px solid black\"\r\n                       [showCancelButton]=\"false\"\r\n                       outputMimeType=\"'image/jpeg'\"            \r\n                       [drawingSizes]=\"{ small: 3, medium: 10, large: 25, extra: 50 }\">\r\n        </asw-image-drawing>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button mat-raised-button\r\n                type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <button mat-raised-button type=\"submit\"\r\n                class=\"btn btn-primary mb-1\"\r\n                cdkFocusInitial>\r\n            Yes\r\n        </button>\r\n    </mat-dialog-actions>\r\n</form>" }]
        }], ctorParameters: function () { return [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }]; } });

/**
 * @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
 */
class AswSignature {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        this.isPreviewTemplate = false;
        this.signatureUpdateEvent = new EventEmitter();
        this.signatureDeleteEvent = new EventEmitter();
        this.imageUrl = 'https://i.pinimg.com/236x/d6/27/d9/d627d9cda385317de4812a4f7bd922e9--man--iron-man.jpg';
    }
    deleteSignatureDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswConfirmDialog, {
            width: '350px',
            data: { name: control.label, message: this.constants.messages.waringMessage }
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.signatureDeleteEvent.emit(controlIndex);
            }
        });
    }
    editSignatureDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswSignatureDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result !== undefined) {
                this.signatureUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
}
AswSignature.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignature, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswSignature.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.2", type: AswSignature, selector: "asw-signature", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { signatureUpdateEvent: "signatureUpdateEvent", signatureDeleteEvent: "signatureDeleteEvent" }, ngImport: i0, template: "<div class=\"avatar-upload\">\r\n    <div class=\"avatar-preview\">\r\n        <div id=\"imagePreview\" [style.backgroundImage]=\"'url('+ control.imageUrl +')'\"></div>\r\n    </div>\r\n</div>\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">\r\n        <button mat-raised-button type=\"button\" matTooltip=\"Edit signature control\" [matTooltipPosition]=\"'above'\"\r\n            (click)=\"editSignatureDialog(control, controlIndex)\" class=\"btn btn-just-icon btn-sm btn-outline-success mr-2 mb-1\">\r\n            <i class=\"material-icons\">edit</i>\r\n        </button>\r\n        <button mat-raised-button type=\"button\" matTooltip=\"Remove signature control\" [matTooltipPosition]=\"'above'\"\r\n            (click)=\"deleteSignatureDialog(control, controlIndex)\" class=\"btn btn-just-icon btn-sm btn-outline-danger mb-1\">\r\n            <i class=\"material-icons\">close</i>\r\n        </button>\r\n    </div>\r\n</div>", directives: [{ type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignature, decorators: [{
            type: Component,
            args: [{ selector: 'asw-signature', template: "<div class=\"avatar-upload\">\r\n    <div class=\"avatar-preview\">\r\n        <div id=\"imagePreview\" [style.backgroundImage]=\"'url('+ control.imageUrl +')'\"></div>\r\n    </div>\r\n</div>\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">\r\n        <button mat-raised-button type=\"button\" matTooltip=\"Edit signature control\" [matTooltipPosition]=\"'above'\"\r\n            (click)=\"editSignatureDialog(control, controlIndex)\" class=\"btn btn-just-icon btn-sm btn-outline-success mr-2 mb-1\">\r\n            <i class=\"material-icons\">edit</i>\r\n        </button>\r\n        <button mat-raised-button type=\"button\" matTooltip=\"Remove signature control\" [matTooltipPosition]=\"'above'\"\r\n            (click)=\"deleteSignatureDialog(control, controlIndex)\" class=\"btn btn-just-icon btn-sm btn-outline-danger mb-1\">\r\n            <i class=\"material-icons\">close</i>\r\n        </button>\r\n    </div>\r\n</div>" }]
        }], ctorParameters: function () { return [{ type: i1.MatDialog }]; }, propDecorators: { control: [{
                type: Input
            }], controlIndex: [{
                type: Input
            }], isPreviewTemplate: [{
                type: Input
            }], signatureUpdateEvent: [{
                type: Output
            }], signatureDeleteEvent: [{
                type: Output
            }] } });

/**
 * @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
 */
class AswSignatureModule {
}
AswSignatureModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
AswSignatureModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureModule, declarations: [AswSignature,
        AswSignatureDialog], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        MatInputModule,
        MatSelectModule,
        MatDialogModule,
        MatSlideToggleModule,
        MatDividerModule,
        MatIconModule,
        MatTooltipModule,
        AswImageDrawingModule,
        AswConfirmDialogModule], exports: [AswSignature,
        AswSignatureDialog] });
AswSignatureModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureModule, imports: [[
            CommonModule,
            FormsModule,
            ReactiveFormsModule,
            MatInputModule,
            MatSelectModule,
            MatDialogModule,
            MatSlideToggleModule,
            MatDividerModule,
            MatIconModule,
            MatTooltipModule,
            AswImageDrawingModule,
            AswConfirmDialogModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: AswSignatureModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatInputModule,
                        MatSelectModule,
                        MatDialogModule,
                        MatSlideToggleModule,
                        MatDividerModule,
                        MatIconModule,
                        MatTooltipModule,
                        AswImageDrawingModule,
                        AswConfirmDialogModule
                    ],
                    declarations: [
                        AswSignature,
                        AswSignatureDialog
                    ],
                    exports: [
                        AswSignature,
                        AswSignatureDialog
                    ]
                }]
        }] });

/**
 * @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
 */

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

export { AswSignature, AswSignatureDialog, AswSignatureModule };
//# sourceMappingURL=asoftwareworld-form-builder-form-control-signature.mjs.map
