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/forms';
import { Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as i2 from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import * as i3 from '@angular/material/divider';
import { MatDividerModule } from '@angular/material/divider';
import * as i4 from '@angular/material/form-field';
import { MatFormFieldModule } from '@angular/material/form-field';
import * as i5 from '@angular/material/select';
import { MatSelectModule } from '@angular/material/select';
import * as i6 from '@angular/material/core';
import * as i7 from '@angular/material/button-toggle';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import * as i8 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i9 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i10 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import * as i11 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i5$1 from '@asoftwareworld/form-builder/image-crop';
import { AswImageCropModule } from '@asoftwareworld/form-builder/image-crop';
import * as i2$1 from '@angular/material/button';
import { MatButtonModule } from '@angular/material/button';

/**
 * @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 AswImageDialog {
    constructor(formBuilder, dialogRef, control) {
        this.formBuilder = formBuilder;
        this.dialogRef = dialogRef;
        this.control = control;
        this.constants = Constants;
    }
    ngOnInit() {
        this.validateFormBuilder();
        this.editProperty(this.control);
    }
    validateFormBuilder() {
        this.aswImageForm = this.formBuilder.group({
            label: ['', [Validators.required, Validators.minLength(5)]],
            column: [],
            class: [],
            imageUrl: [],
            imageShape: []
        });
    }
    editProperty(control) {
        this.aswImageForm.setValue({
            label: control.label,
            class: control.class,
            column: control.column,
            imageUrl: control.imageUrl,
            imageShape: control.imageShape
        });
    }
    onNoClick() {
        this.dialogRef.close();
    }
    onSubmit() {
        if (this.aswImageForm.invalid) {
            return;
        }
        this.aswImageForm.value.controlType = this.control.controlType;
        this.dialogRef.close(this.aswImageForm.value);
    }
}
AswImageDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageDialog, deps: [{ token: i1.FormBuilder }, { token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
AswImageDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswImageDialog, selector: "asw-image-dialog", ngImport: i0, template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswImageForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-full-width\"><br>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Label</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"label\"\r\n                                        placeholder=\"Enter label\"\r\n                                        matTooltip=\"Enter label\"\r\n                                        formControlName=\"label\" required>\r\n                        <mat-error class=\"asw-mat-error\" *ngFor=\"let validation of constants.accountValidationMessages.label\">\r\n                            <mat-error class=\"asw-mat-error\" *ngIf=\"aswImageForm.get('label')?.hasError(validation.type) && (aswImageForm.get('label')?.dirty || aswImageForm.get('label')?.touched)\">\r\n                                {{validation.message}}\r\n                            </mat-error>\r\n                        </mat-error>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Image url</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"label\"\r\n                                        placeholder=\"Enter image url\"\r\n                                        matTooltip=\"Enter label\"\r\n                                        formControlName=\"imageUrl\">\r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Column Size</mat-label>\r\n                        <mat-select formControlName=\"column\" matTooltip=\"Select column size\">\r\n                            <mat-option *ngFor=\"let column of constants.columns\" [value]=\"column.value\">\r\n                                {{column.label}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Select image shape</mat-label>\r\n                        <mat-select formControlName=\"imageShape\" matTooltip=\"Select image shape\">\r\n                            <mat-option value=\"asw-avatar-wrapper-circle\">Circle</mat-option>\r\n                            <mat-option value=\"asw-avatar-wrapper\">Square</mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    Text style: \r\n                    <mat-button-toggle-group formControlName=\"class\" name=\"fontStyle\" aria-label=\"Font Style\">\r\n                        <mat-button-toggle value=\"float-left float-start\" aria-label=\"Text align left\">\r\n                            <mat-icon>format_align_left</mat-icon>\r\n                        </mat-button-toggle>\r\n                        <mat-button-toggle value=\"mx-auto\" aria-label=\"Text align center\">\r\n                            <mat-icon>format_align_center</mat-icon>\r\n                        </mat-button-toggle>\r\n                        <mat-button-toggle value=\"float-right float-end\" aria-label=\"Text align right\">\r\n                            <mat-icon>format_align_right</mat-icon>\r\n                        </mat-button-toggle>\r\n                    </mat-button-toggle-group>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1 me-2\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <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>\r\n\r\n", components: [{ type: i3.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i5.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i6.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i7.MatButtonToggle, selector: "mat-button-toggle", inputs: ["disableRipple", "aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "appearance", "checked", "disabled"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i4.MatLabel, selector: "mat-label" }, { type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i4.MatError, selector: "mat-error", inputs: ["id"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageDialog, decorators: [{
            type: Component,
            args: [{ selector: 'asw-image-dialog', template: "<h4 mat-dialog-title>Edit Property</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswImageForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"asw-full-width\"><br>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Label</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"label\"\r\n                                        placeholder=\"Enter label\"\r\n                                        matTooltip=\"Enter label\"\r\n                                        formControlName=\"label\" required>\r\n                        <mat-error class=\"asw-mat-error\" *ngFor=\"let validation of constants.accountValidationMessages.label\">\r\n                            <mat-error class=\"asw-mat-error\" *ngIf=\"aswImageForm.get('label')?.hasError(validation.type) && (aswImageForm.get('label')?.dirty || aswImageForm.get('label')?.touched)\">\r\n                                {{validation.message}}\r\n                            </mat-error>\r\n                        </mat-error>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Image url</mat-label>\r\n                        <input matInput type=\"text\"\r\n                                        name=\"label\"\r\n                                        placeholder=\"Enter image url\"\r\n                                        matTooltip=\"Enter label\"\r\n                                        formControlName=\"imageUrl\">\r\n                    </mat-form-field>\r\n                </div>\r\n                <div class=\"col-md-6\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Column Size</mat-label>\r\n                        <mat-select formControlName=\"column\" matTooltip=\"Select column size\">\r\n                            <mat-option *ngFor=\"let column of constants.columns\" [value]=\"column.value\">\r\n                                {{column.label}}\r\n                            </mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    <mat-form-field appearance=\"outline\" class=\"asw-mat-form-field\">\r\n                        <mat-label>Select image shape</mat-label>\r\n                        <mat-select formControlName=\"imageShape\" matTooltip=\"Select image shape\">\r\n                            <mat-option value=\"asw-avatar-wrapper-circle\">Circle</mat-option>\r\n                            <mat-option value=\"asw-avatar-wrapper\">Square</mat-option>\r\n                        </mat-select>\r\n                    </mat-form-field>\r\n                </div>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div class=\"col-md-12\">\r\n                    Text style: \r\n                    <mat-button-toggle-group formControlName=\"class\" name=\"fontStyle\" aria-label=\"Font Style\">\r\n                        <mat-button-toggle value=\"float-left float-start\" aria-label=\"Text align left\">\r\n                            <mat-icon>format_align_left</mat-icon>\r\n                        </mat-button-toggle>\r\n                        <mat-button-toggle value=\"mx-auto\" aria-label=\"Text align center\">\r\n                            <mat-icon>format_align_center</mat-icon>\r\n                        </mat-button-toggle>\r\n                        <mat-button-toggle value=\"float-right float-end\" aria-label=\"Text align right\">\r\n                            <mat-icon>format_align_right</mat-icon>\r\n                        </mat-button-toggle>\r\n                    </mat-button-toggle-group>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1 me-2\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <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>\r\n\r\n" }]
        }], ctorParameters: function () {
        return [{ type: i1.FormBuilder }, { type: i2.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 AswImageUploadDialog {
    constructor(formBuilder, dialogRef, control) {
        this.formBuilder = formBuilder;
        this.dialogRef = dialogRef;
        this.control = control;
        this.constants = Constants;
        this.imageChangedEvent = '';
        this.croppedImage = '';
        this.canvasRotation = 0;
        this.rotation = 0;
        this.scale = 1;
        this.showCropper = false;
        this.isImageLoaded = false;
        this.containWithinAspectRatio = false;
        this.transform = {};
    }
    ngOnInit() {
        this.validateFormBuilder();
        this.editProperty(this.control);
        this.croppedImage = this.control.imageUrl;
        this.imageChangedEvent = this.control.event;
    }
    fileChangeEvent(event) {
        this.isImageLoaded = true;
        this.imageChangedEvent = event;
    }
    removeImage() {
        this.isImageLoaded = true;
        this.imageChangedEvent = null;
    }
    imageCropped(event) {
        this.croppedImage = event.base64;
    }
    imageLoaded() {
        this.showCropper = true;
    }
    cropperReady(sourceImageDimensions) {
        this.isImageLoaded = false;
    }
    loadImageFailed() {
        console.log('Load failed');
    }
    rotateLeft() {
        this.isImageLoaded = true;
        setTimeout(() => {
            this.canvasRotation--;
            this.flipAfterRotate();
        });
    }
    rotateRight() {
        this.isImageLoaded = true;
        setTimeout(() => {
            this.canvasRotation++;
            this.flipAfterRotate();
        });
    }
    flipAfterRotate() {
        const flippedH = this.transform.flipH;
        const flippedV = this.transform.flipV;
        this.transform = Object.assign(Object.assign({}, this.transform), { flipH: flippedV, flipV: flippedH });
    }
    flipHorizontal() {
        this.transform = Object.assign(Object.assign({}, this.transform), { flipH: !this.transform.flipH });
    }
    flipVertical() {
        this.transform = Object.assign(Object.assign({}, this.transform), { flipV: !this.transform.flipV });
    }
    resetImage() {
        this.scale = 1;
        this.rotation = 0;
        this.canvasRotation = 0;
        this.transform = {};
    }
    zoomOut() {
        this.scale -= .1;
        this.transform = Object.assign(Object.assign({}, this.transform), { scale: this.scale });
    }
    zoomIn() {
        this.scale += .1;
        this.transform = Object.assign(Object.assign({}, this.transform), { scale: this.scale });
    }
    toggleContainWithinAspectRatio() {
        this.containWithinAspectRatio = !this.containWithinAspectRatio;
    }
    updateRotation() {
        this.transform = Object.assign(Object.assign({}, this.transform), { rotate: this.rotation });
    }
    onNoClick() {
        this.dialogRef.close();
    }
    validateFormBuilder() {
        this.aswImageCropForm = this.formBuilder.group({
            file: [null]
        });
    }
    editProperty(control) {
        if (control.event) {
            this.isImageLoaded = false;
        }
        this.aswImageCropForm.setValue({
            file: control.imageUrl
        });
    }
    onSubmit() {
        if (this.aswImageCropForm.invalid) {
            return;
        }
        this.aswImageCropForm.value.displayName = this.control.displayName;
        this.aswImageCropForm.value.controlType = this.control.controlType;
        this.aswImageCropForm.value.label = this.control.label;
        this.aswImageCropForm.value.class = this.control.class;
        this.aswImageCropForm.value.column = this.control.column;
        this.aswImageCropForm.value.imageUrl = this.croppedImage;
        this.aswImageCropForm.value.imageShape = this.control.imageShape;
        this.aswImageCropForm.value.event = this.imageChangedEvent;
        this.dialogRef.close(this.aswImageCropForm.value);
    }
}
AswImageUploadDialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageUploadDialog, deps: [{ token: i1.FormBuilder }, { token: i2.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component });
AswImageUploadDialog.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswImageUploadDialog, selector: "asw-image-upload-dialog", ngImport: i0, template: "<h4 mat-dialog-title>Crop Uploaded Image</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswImageCropForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"row\">\r\n            <div class=\"col-md-2\">\r\n                <div class=\"text-center btn-toolbar mt-2\" role=\"toolbar\" aria-label=\"Image controls toolbar\">\r\n                    <div class=\"btn-group-vertical\" role=\"group\" aria-label=\"toolbar\">\r\n                        <button type=\"button\" \r\n                            class=\"asw-btn btn btn-outline-primary\"\r\n                            (click)=\"fileInput.click()\"\r\n                            matTooltip=\"Load image\" \r\n                            *ngIf=\"isImageLoaded\">\r\n                            <input style=\"display: none\" \r\n                                    type=\"file\" \r\n                                    #fileInput \r\n                                    (change)=\"fileChangeEvent($event)\"\r\n                                    id=\"imageUpload\" \r\n                                    accept=\".png, .jpg, .jpeg\">\r\n                            <mat-icon>attach_file</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Remove image\"\r\n                                matTooltipPosition=\"right\"\r\n                                *ngIf=\"!isImageLoaded\" \r\n                                (click)=\"removeImage()\">\r\n                            <mat-icon>clear</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                matTooltip=\"Left rotate\"\r\n                                matTooltipPosition=\"right\"\r\n                                (click)=\"rotateLeft()\">\r\n                            <mat-icon>rotate_left</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                matTooltip=\"Right rotate\"\r\n                                matTooltipPosition=\"right\"\r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"rotateRight()\">\r\n                            <mat-icon>rotate_right</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Swap horizontal\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"flipHorizontal()\">\r\n                            <mat-icon>swap_horiz</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Swap vertical\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"flipVertical()\">\r\n                            <mat-icon>swap_vert</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                matTooltip=\"{{containWithinAspectRatio?'Fill Aspect Ratio':'Contain Within Aspect Ratio'}}\"\r\n                                matTooltipPosition=\"right\"\r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"toggleContainWithinAspectRatio()\">\r\n                            <mat-icon>\r\n                                {{containWithinAspectRatio?'crop_free':'crop_din'}}\r\n                            </mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                [disabled]=\"isImageLoaded\"\r\n                                matTooltip=\"Reset image\"\r\n                                matTooltipPosition=\"right\" \r\n                                (click)=\"resetImage()\">\r\n                            <mat-icon>refresh</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Zoom out\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"zoomOut()\">\r\n                            <mat-icon>zoom_out</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Zoom in\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"zoomIn()\">\r\n                            <mat-icon>zoom_in</mat-icon>\r\n                        </button>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n            <div class=\"col-md-10\">\r\n                <asw-image-crop\r\n                    [imageChangedEvent]=\"imageChangedEvent\"\r\n                    [maintainAspectRatio]=\"true\"\r\n                    [containWithinAspectRatio]=\"containWithinAspectRatio\"\r\n                    [aspectRatio]=\"1\"\r\n                    [resizeToWidth]=\"256\"\r\n                    [onlyScaleDown]=\"true\" \r\n                    [roundCropper]=\"true\"\r\n                    [canvasRotation]=\"canvasRotation\"\r\n                    [transform]=\"transform\"\r\n                    [alignImage]=\"'center'\"\r\n                    [style.display]=\"showCropper ? null : 'none'\"\r\n                    format=\"png\"\r\n                    (imageCropped)=\"imageCropped($event)\"\r\n                    (imageLoaded)=\"imageLoaded()\"\r\n                    (cropperReady)=\"cropperReady($event)\"\r\n                    (loadImageFailed)=\"loadImageFailed()\">\r\n                </asw-image-crop>\r\n            </div>\r\n        </div>        \r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1 me-2\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <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: i3.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i5$1.AswImageCropComponent, selector: "asw-image-crop", inputs: ["imageChangedEvent", "imageURL", "imageBase64", "imageFile", "format", "transform", "maintainAspectRatio", "aspectRatio", "resizeToWidth", "resizeToHeight", "cropperMinWidth", "cropperMinHeight", "cropperMaxHeight", "cropperMaxWidth", "cropperStaticWidth", "cropperStaticHeight", "canvasRotation", "initialStepSize", "roundCropper", "onlyScaleDown", "imageQuality", "autoCrop", "backgroundColor", "containWithinAspectRatio", "hideResizeSquares", "cropper", "alignImage", "disabled"], outputs: ["imageCropped", "startCropImage", "imageLoaded", "cropperReady", "loadImageFailed"] }], directives: [{ type: i2.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i2.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageUploadDialog, decorators: [{
            type: Component,
            args: [{ selector: 'asw-image-upload-dialog', template: "<h4 mat-dialog-title>Crop Uploaded Image</h4>\r\n<mat-divider></mat-divider>\r\n<form [formGroup]=\"aswImageCropForm\" (ngSubmit)=\"onSubmit()\">\r\n    <mat-dialog-content class=\"mat-typography\">\r\n        <div class=\"row\">\r\n            <div class=\"col-md-2\">\r\n                <div class=\"text-center btn-toolbar mt-2\" role=\"toolbar\" aria-label=\"Image controls toolbar\">\r\n                    <div class=\"btn-group-vertical\" role=\"group\" aria-label=\"toolbar\">\r\n                        <button type=\"button\" \r\n                            class=\"asw-btn btn btn-outline-primary\"\r\n                            (click)=\"fileInput.click()\"\r\n                            matTooltip=\"Load image\" \r\n                            *ngIf=\"isImageLoaded\">\r\n                            <input style=\"display: none\" \r\n                                    type=\"file\" \r\n                                    #fileInput \r\n                                    (change)=\"fileChangeEvent($event)\"\r\n                                    id=\"imageUpload\" \r\n                                    accept=\".png, .jpg, .jpeg\">\r\n                            <mat-icon>attach_file</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Remove image\"\r\n                                matTooltipPosition=\"right\"\r\n                                *ngIf=\"!isImageLoaded\" \r\n                                (click)=\"removeImage()\">\r\n                            <mat-icon>clear</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                matTooltip=\"Left rotate\"\r\n                                matTooltipPosition=\"right\"\r\n                                (click)=\"rotateLeft()\">\r\n                            <mat-icon>rotate_left</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                matTooltip=\"Right rotate\"\r\n                                matTooltipPosition=\"right\"\r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"rotateRight()\">\r\n                            <mat-icon>rotate_right</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Swap horizontal\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"flipHorizontal()\">\r\n                            <mat-icon>swap_horiz</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Swap vertical\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"flipVertical()\">\r\n                            <mat-icon>swap_vert</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                matTooltip=\"{{containWithinAspectRatio?'Fill Aspect Ratio':'Contain Within Aspect Ratio'}}\"\r\n                                matTooltipPosition=\"right\"\r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"toggleContainWithinAspectRatio()\">\r\n                            <mat-icon>\r\n                                {{containWithinAspectRatio?'crop_free':'crop_din'}}\r\n                            </mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\" \r\n                                [disabled]=\"isImageLoaded\"\r\n                                matTooltip=\"Reset image\"\r\n                                matTooltipPosition=\"right\" \r\n                                (click)=\"resetImage()\">\r\n                            <mat-icon>refresh</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Zoom out\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"zoomOut()\">\r\n                            <mat-icon>zoom_out</mat-icon>\r\n                        </button>\r\n                        <button type=\"button\" \r\n                                class=\"asw-btn btn btn-outline-primary\"\r\n                                matTooltip=\"Zoom in\"\r\n                                matTooltipPosition=\"right\" \r\n                                [disabled]=\"isImageLoaded\" \r\n                                (click)=\"zoomIn()\">\r\n                            <mat-icon>zoom_in</mat-icon>\r\n                        </button>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n            <div class=\"col-md-10\">\r\n                <asw-image-crop\r\n                    [imageChangedEvent]=\"imageChangedEvent\"\r\n                    [maintainAspectRatio]=\"true\"\r\n                    [containWithinAspectRatio]=\"containWithinAspectRatio\"\r\n                    [aspectRatio]=\"1\"\r\n                    [resizeToWidth]=\"256\"\r\n                    [onlyScaleDown]=\"true\" \r\n                    [roundCropper]=\"true\"\r\n                    [canvasRotation]=\"canvasRotation\"\r\n                    [transform]=\"transform\"\r\n                    [alignImage]=\"'center'\"\r\n                    [style.display]=\"showCropper ? null : 'none'\"\r\n                    format=\"png\"\r\n                    (imageCropped)=\"imageCropped($event)\"\r\n                    (imageLoaded)=\"imageLoaded()\"\r\n                    (cropperReady)=\"cropperReady($event)\"\r\n                    (loadImageFailed)=\"loadImageFailed()\">\r\n                </asw-image-crop>\r\n            </div>\r\n        </div>        \r\n    </mat-dialog-content>\r\n    <mat-dialog-actions align=\"end\">\r\n        <button type=\"button\"\r\n                class=\"btn btn-danger mr-2 mb-1 me-2\"\r\n                (click)=\"onNoClick()\">\r\n            No\r\n        </button>\r\n        <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.FormBuilder }, { type: i2.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 AswImage {
    constructor(dialog) {
        this.dialog = dialog;
        this.constants = Constants;
        this.isPreviewTemplate = false;
        this.imageUpdateEvent = new EventEmitter();
        this.imageDeleteEvent = new EventEmitter();
        this.duplicateControl = new EventEmitter();
    }
    deleteImageDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswConfirmDialog, {
            width: '350px',
            data: { name: control.controlType, message: this.constants.messages.waringMessage }
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result) {
                this.imageDeleteEvent.emit(controlIndex);
            }
        });
    }
    editImageDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswImageDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result) {
                this.imageUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
    uploadImageDialog(control, controlIndex) {
        const dialogRef = this.dialog.open(AswImageUploadDialog, {
            disableClose: true,
            width: '744px',
            data: control
        });
        dialogRef.afterClosed().subscribe(result => {
            if (result) {
                console.log(result);
                this.imageUpdateEvent.emit({ control: result, index: controlIndex });
            }
        });
    }
    duplicateImageControl(control) {
        this.duplicateControl.emit(control);
    }
}
AswImage.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImage, deps: [{ token: i2.MatDialog }], target: i0.ɵɵFactoryTarget.Component });
AswImage.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswImage, selector: "asw-image", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { imageUpdateEvent: "imageUpdateEvent", imageDeleteEvent: "imageDeleteEvent", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<div class=\"asw-avatar-wrap {{control.class}}\">\r\n    <div class=\"{{control.imageShape}}\">\r\n        <img class=\"asw-profile-pic\" src=\"{{control.imageUrl}}\" />\t\r\n        <span class=\"file-upload\" ></span>\r\n    </div>\r\n    <div class=\"asw-upload-button\">\r\n        <i class=\"fa fa-camera\" aria-hidden=\"true\" (click)=\"uploadImageDialog(control, controlIndex)\"></i>\r\n    </div>\r\n</div>\r\n\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Duplicate\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"duplicateImageControl(control)\">\r\n            <mat-icon>content_copy</mat-icon>\r\n        </button>\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Edit\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"editImageDialog(control, controlIndex)\">\r\n            <mat-icon>edit</mat-icon>\r\n        </button>\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Delete\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"deleteImageDialog(control, controlIndex)\">\r\n            <mat-icon>delete</mat-icon>\r\n        </button>\r\n    </div>\r\n</div>", components: [{ type: i2$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button],             button[mat-fab], button[mat-mini-fab], button[mat-stroked-button],             button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i8.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], directives: [{ type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i10.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImage, decorators: [{
            type: Component,
            args: [{ selector: 'asw-image', template: "<div class=\"asw-avatar-wrap {{control.class}}\">\r\n    <div class=\"{{control.imageShape}}\">\r\n        <img class=\"asw-profile-pic\" src=\"{{control.imageUrl}}\" />\t\r\n        <span class=\"file-upload\" ></span>\r\n    </div>\r\n    <div class=\"asw-upload-button\">\r\n        <i class=\"fa fa-camera\" aria-hidden=\"true\" (click)=\"uploadImageDialog(control, controlIndex)\"></i>\r\n    </div>\r\n</div>\r\n\r\n<div class=\"row\" *ngIf=\"isPreviewTemplate\">\r\n    <div class=\"col-md-12\">\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Duplicate\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"duplicateImageControl(control)\">\r\n            <mat-icon>content_copy</mat-icon>\r\n        </button>\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Edit\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"editImageDialog(control, controlIndex)\">\r\n            <mat-icon>edit</mat-icon>\r\n        </button>\r\n        <button mat-icon-button \r\n                type=\"button\" \r\n                matTooltip=\"Delete\" \r\n                [matTooltipPosition]=\"'below'\" \r\n                (click)=\"deleteImageDialog(control, controlIndex)\">\r\n            <mat-icon>delete</mat-icon>\r\n        </button>\r\n    </div>\r\n</div>" }]
        }], ctorParameters: function () { return [{ type: i2.MatDialog }]; }, propDecorators: { control: [{
                type: Input
            }], controlIndex: [{
                type: Input
            }], isPreviewTemplate: [{
                type: Input
            }], imageUpdateEvent: [{
                type: Output
            }], imageDeleteEvent: [{
                type: Output
            }], duplicateControl: [{
                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 AswImageModule {
}
AswImageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
AswImageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageModule, declarations: [AswImage,
        AswImageDialog,
        AswImageUploadDialog], imports: [CommonModule,
        FormsModule,
        ReactiveFormsModule,
        AswImageCropModule,
        MatDividerModule,
        MatTooltipModule,
        MatDialogModule,
        MatIconModule,
        AswConfirmDialogModule,
        MatSelectModule,
        MatButtonToggleModule,
        MatFormFieldModule,
        MatInputModule,
        MatButtonModule], exports: [AswImage,
        AswImageDialog,
        AswImageUploadDialog] });
AswImageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageModule, imports: [[
            CommonModule,
            FormsModule,
            ReactiveFormsModule,
            AswImageCropModule,
            MatDividerModule,
            MatTooltipModule,
            MatDialogModule,
            MatIconModule,
            AswConfirmDialogModule,
            MatSelectModule,
            MatButtonToggleModule,
            MatFormFieldModule,
            MatInputModule,
            MatButtonModule
        ]] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswImageModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        AswImageCropModule,
                        MatDividerModule,
                        MatTooltipModule,
                        MatDialogModule,
                        MatIconModule,
                        AswConfirmDialogModule,
                        MatSelectModule,
                        MatButtonToggleModule,
                        MatFormFieldModule,
                        MatInputModule,
                        MatButtonModule
                    ],
                    declarations: [
                        AswImage,
                        AswImageDialog,
                        AswImageUploadDialog
                    ],
                    exports: [
                        AswImage,
                        AswImageDialog,
                        AswImageUploadDialog
                    ]
                }]
        }] });

/**
 * @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 { AswImage, AswImageDialog, AswImageModule, AswImageUploadDialog };
//# sourceMappingURL=asoftwareworld-form-builder-form-control-image.mjs.map
