/**
 * @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 { moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Constants, ObjectUtils } from '@asoftwareworld/form-builder/form-control/core';
import { AswJsonPreviewDialog } from '@asoftwareworld/form-builder/form-control/json-preview-dialog';
import { CONTROLS } from './default-controls';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "@asoftwareworld/form-builder/form-control/core";
import * as i3 from "@angular/material/icon";
import * as i4 from "@asoftwareworld/form-builder/form-control/autocomplete";
import * as i5 from "@asoftwareworld/form-builder/form-control/header";
import * as i6 from "@asoftwareworld/form-builder/form-control/qrcode";
import * as i7 from "@asoftwareworld/form-builder/form-control/image";
import * as i8 from "@asoftwareworld/form-builder/form-control/textfield";
import * as i9 from "@asoftwareworld/form-builder/form-control/textarea";
import * as i10 from "@asoftwareworld/form-builder/form-control/number";
import * as i11 from "@asoftwareworld/form-builder/form-control/calculation";
import * as i12 from "@asoftwareworld/form-builder/form-control/select";
import * as i13 from "@asoftwareworld/form-builder/form-control/multi-select";
import * as i14 from "@asoftwareworld/form-builder/form-control/radio-button";
import * as i15 from "@asoftwareworld/form-builder/form-control/checkbox";
import * as i16 from "@asoftwareworld/form-builder/form-control/datepicker";
import * as i17 from "@asoftwareworld/form-builder/form-control/button";
import * as i18 from "@asoftwareworld/form-builder/form-control/paragraph";
import * as i19 from "@asoftwareworld/form-builder/form-control/divider";
import * as i20 from "@asoftwareworld/form-builder/form-control/slide-toggle";
import * as i21 from "@asoftwareworld/form-builder/form-control/gps";
import * as i22 from "@asoftwareworld/form-builder/form-control/signature";
import * as i23 from "@asoftwareworld/form-builder/form-control/drawing";
import * as i24 from "@angular/common";
import * as i25 from "@angular/cdk/drag-drop";
export class AswFormBuilder {
    constructor(dialog, notificationService) {
        this.dialog = dialog;
        this.notificationService = notificationService;
        this.constants = Constants;
        this.availableControls = [];
        this.formContainer = [];
        this.viewInitialized = false;
        this.uploadData = [];
        this.isShowPreviewButton = true;
        this.isShowJsonDataButton = true;
        this.isShowPublishButton = true;
        this.previewClick = new EventEmitter();
        this.publishClick = new EventEmitter();
        this.buttonClick = new EventEmitter();
        this.aswModelChange = new EventEmitter();
    }
    ngOnInit() {
        this.availableControls = CONTROLS;
    }
    ngOnChanges() {
        if (this.uploadData.length) {
            this.formContainer = this.uploadData;
        }
    }
    drop(event) {
        if (event.previousContainer === event.container) {
            moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
        }
        else {
            transferArrayItem(JSON.parse(JSON.stringify(event.previousContainer.data)), event.container.data, event.previousIndex, event.currentIndex);
        }
    }
    updatedControl(data) {
        this.formContainer.splice(data.index, 1, data.control);
    }
    deleteControl(index) {
        this.formContainer.splice(index, 1);
    }
    previewTemplate() {
        this.previewClick.emit(this.formContainer);
    }
    previewJsonData() {
        const dialogRef = this.dialog.open(AswJsonPreviewDialog, {
            disableClose: true,
            width: '744px',
            data: this.formContainer
        });
        dialogRef.afterClosed();
    }
    publishTemplate() {
        this.publishClick.emit(this.formContainer);
    }
    buttonClicked(type) {
        if (type === 'reset') {
            this.formContainer = ObjectUtils.resetForm(this.formContainer);
        }
        else {
            const data = ObjectUtils.validateForm(this.formContainer);
            if (!data.isFormValid) {
                this.notificationService.openNotification('Please fill in the following required fields.'
                    + ' \n \n' + data.labels.toString(), 'Close');
            }
            else {
                this.buttonClick.emit(this.formContainer);
            }
        }
    }
    onSelectionChange(control) {
        this.aswModelChange.emit(control);
    }
    duplicateControl(control) {
        this.formContainer.push(JSON.parse(JSON.stringify(control)));
    }
}
AswFormBuilder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswFormBuilder, deps: [{ token: i1.MatDialog }, { token: i2.NotificationService }], target: i0.ɵɵFactoryTarget.Component });
AswFormBuilder.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswFormBuilder, selector: "asw-form-builder", inputs: { uploadData: "uploadData", isShowPreviewButton: "isShowPreviewButton", isShowJsonDataButton: "isShowJsonDataButton", isShowPublishButton: "isShowPublishButton" }, outputs: { previewClick: "previewClick", publishClick: "publishClick", buttonClick: "buttonClick", aswModelChange: "aswModelChange" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"row\">\r\n    <div class=\"col-md-12 text-right float-right text-end\">\r\n        <button type=\"button\" *ngIf=\"isShowPreviewButton\"\r\n                class=\"btn btn-primary btn-sm mr-1 mb-2 me-1\"\r\n                (click)=\"previewTemplate()\">Preview</button>\r\n        <button type=\"button\" *ngIf=\"isShowJsonDataButton\"\r\n                class=\"btn btn-secondary btn-sm mr-1 mb-2 me-1\"\r\n                (click)=\"previewJsonData()\">Json Data</button>\r\n        <button class=\"btn btn-success btn-sm mb-2 me-1\"\r\n                type=\"button\" *ngIf=\"isShowPublishButton\"\r\n                (click)=\"publishTemplate()\">Publish</button>\r\n    </div>\r\n</div>\r\n<div class=\"row\" cdkDropListGroup>\r\n    <div class=\"col-md-3\">\r\n        <div class=\"card\">\r\n            <h2 class=\"asw-card-header\">\r\n                Controls\r\n            </h2>\r\n            <div class=\"card-body\">\r\n                <div cdkDropList\r\n                    [cdkDropListData]=\"availableControls\"\r\n                    class=\"asw-list\">\r\n                    <div class=\"row\">\r\n                        <ng-container *ngFor=\"let item of availableControls\">\r\n                            <div class=\"col-md-12\">\r\n                                <div class=\"alert alert-primary d-flex asw-alert-primary align-items-center\" cdkDrag>\r\n                                    <mat-icon class=\"asw-icon mr-1 me-1\">{{item.icon}}</mat-icon>\r\n                                    {{item.displayName}}\r\n                                </div>\r\n                            </div>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div class=\"col-md-9\">\r\n        <div class=\"card\">\r\n            <h2 class=\"asw-card-header text-center alert-info asw-alert-info\">Drag and Drop a form component</h2>\r\n            <div class=\"card-body\">                \r\n                <div cdkDropList\r\n                    [cdkDropListData]=\"formContainer\"\r\n                    class=\"asw-list\"\r\n                    (cdkDropListDropped)=\"drop($event)\">\r\n                    <div class=\"row\">\r\n                        <ng-container *ngFor=\"let control of formContainer; let i = index\">\r\n                            <div class=\"asw-box\" [ngClass]=\"control.column\" cdkDrag>\r\n                                <ng-container [ngSwitch]=\"control.controlType\" class=\"asw-full-width\">\r\n                                    <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n                                        <asw-autocomplete [control]=\"control\"\r\n                                                          [controlIndex]=\"i\"\r\n                                                          [isPreviewTemplate]=\"true\"\r\n                                                          (autocompleteUpdateEvent)=\"updatedControl($event)\"\r\n                                                          (autocompleteDeleteEvent)=\"deleteControl($event)\"\r\n                                                          (selectionChange)=\"onSelectionChange($event)\"\r\n                                                          (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-autocomplete>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'header'\">\r\n                                        <asw-header [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (headerUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (headerDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-header>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'qr-code'\">\r\n                                        <asw-qrcode [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (qrCodeUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (qrCodeDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-qrcode>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'image'\">\r\n                                        <asw-image [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (imageUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (imageDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-image>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'textfield'\">\r\n                                        <asw-textfield [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (textFieldUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (textFieldDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-textfield>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'textarea'\">\r\n                                        <asw-textarea [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (textAreaUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (textAreaDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-textarea>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'number'\">\r\n                                        <asw-number [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    [formControls]=\"formContainer\"\r\n                                                    (numberUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (numberDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-number>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'calculation'\">\r\n                                        <asw-calculation [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [formControls]=\"formContainer\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (calculationUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (calculationDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-calculation>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'select'\">\r\n                                        <asw-select [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (selectUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (selectDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (selectionChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-select>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'multi-select'\">\r\n                                        <asw-multi-select [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (multiSelectUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (multiSelectDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-multi-select>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'radio'\">\r\n                                        <asw-radio-button [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (radioButtonUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (radioButtonDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-radio-button>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'checkbox'\">\r\n                                        <asw-checkbox [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (checkboxUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (checkboxDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (selectionChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-checkbox>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'datepicker'\">\r\n                                        <asw-datepicker [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (datepickerUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (datepickerDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (dateChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-datepicker>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'button'\">\r\n                                        <asw-button [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (buttonUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (buttonDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (buttonClickEvent)=\"buttonClicked($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-button>                                       \r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'paragraph'\">\r\n                                        <asw-paragraph [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (paragraphUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (paragraphDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-paragraph>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'divider'\">\r\n                                        <asw-divider [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (dividerDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-divider>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'slide-toggle'\">\r\n                                        <asw-slide-toggle [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (slidetoggleUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (slidetoggleDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-slide-toggle>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'gps'\">\r\n                                        <asw-gps [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (gpsUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (gpsDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (gpsAddressChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-gps>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'signature'\">\r\n                                        <asw-signature [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (signatureUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (signatureDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-signature>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'drawing'\">\r\n                                        <asw-drawing [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (drawingUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (drawingDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-drawing>\r\n                                    </ng-container>\r\n                                </ng-container>\r\n                            </div>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>", styles: ["h2{margin:0}.asw-list{min-height:595px;border-radius:4px;display:block}.asw-box{padding:7px;border-bottom:solid 1px #ccc;color:#000000de;flex-direction:row;align-items:center;justify-content:space-between;box-sizing:border-box;cursor:move;background:white;font-size:14px}.alert{padding:.4rem!important;margin-bottom:.4rem!important}.asw-alert-primary{color:#fff!important;background-color:#2780e3!important;border-color:#2780e3!important;cursor:move}.asw-card-header{padding:.5rem 1rem;margin-bottom:0;background-color:#00000008;border-bottom:1px solid rgba(0,0,0,.125)}.asw-alert-info{color:#502c61!important;background-color:#ebddf1!important;border-color:#e2cfec!important}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.asw-list.cdk-drop-list-dragging .asw-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}\n"], components: [{ type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.AswAutocomplete, selector: "asw-autocomplete", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["autocompleteUpdateEvent", "autocompleteDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i5.AswHeader, selector: "asw-header", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["headerUpdateEvent", "headerDeleteEvent", "duplicateControl"] }, { type: i6.AswQrCode, selector: "asw-qrcode", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["qrCodeUpdateEvent", "qrCodeDeleteEvent", "duplicateControl"] }, { type: i7.AswImage, selector: "asw-image", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["imageUpdateEvent", "imageDeleteEvent", "duplicateControl"] }, { type: i8.AswTextField, selector: "asw-textfield", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["textFieldUpdateEvent", "textFieldDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i9.AswTextarea, selector: "asw-textarea", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["textAreaUpdateEvent", "textAreaDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i10.AswNumber, selector: "asw-number", inputs: ["control", "formControls", "controlIndex", "isPreviewTemplate"], outputs: ["numberUpdateEvent", "numberDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i11.AswCalculation, selector: "asw-calculation", inputs: ["control", "formControls", "controlIndex", "isPreviewTemplate"], outputs: ["calculationUpdateEvent", "calculationDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i12.AswSelect, selector: "asw-select", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["selectUpdateEvent", "selectDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i13.AswMultiSelect, selector: "asw-multi-select", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["multiSelectUpdateEvent", "multiSelectDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i14.AswRadioButton, selector: "asw-radio-button", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["radioButtonUpdateEvent", "radioButtonDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i15.AswCheckbox, selector: "asw-checkbox", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["checkboxUpdateEvent", "checkboxDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i16.AswDatepicker, selector: "asw-datepicker", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["datepickerUpdateEvent", "datepickerDeleteEvent", "dateChange", "duplicateControl"] }, { type: i17.AswButton, selector: "asw-button", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["buttonClickEvent", "buttonUpdateEvent", "buttonDeleteEvent", "duplicateControl"] }, { type: i18.AswParagraph, selector: "asw-paragraph", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["paragraphUpdateEvent", "paragraphDeleteEvent", "duplicateControl"] }, { type: i19.AswDivider, selector: "asw-divider", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["dividerDeleteEvent", "duplicateControl"] }, { type: i20.AswSlideToggle, selector: "asw-slide-toggle", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["slidetoggleUpdateEvent", "slidetoggleDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i21.AswGps, selector: "asw-gps", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["gpsUpdateEvent", "gpsDeleteEvent", "gpsAddressChange", "duplicateControl"] }, { type: i22.AswSignature, selector: "asw-signature", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["signatureUpdateEvent", "signatureDeleteEvent", "duplicateControl"] }, { type: i23.AswDrawing, selector: "asw-drawing", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["drawingUpdateEvent", "drawingDeleteEvent", "duplicateControl"] }], directives: [{ type: i24.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i25.CdkDropListGroup, selector: "[cdkDropListGroup]", inputs: ["cdkDropListGroupDisabled"], exportAs: ["cdkDropListGroup"] }, { type: i25.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { type: i24.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i25.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i24.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i24.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i24.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswFormBuilder, decorators: [{
            type: Component,
            args: [{ selector: 'asw-form-builder', template: "<div class=\"row\">\r\n    <div class=\"col-md-12 text-right float-right text-end\">\r\n        <button type=\"button\" *ngIf=\"isShowPreviewButton\"\r\n                class=\"btn btn-primary btn-sm mr-1 mb-2 me-1\"\r\n                (click)=\"previewTemplate()\">Preview</button>\r\n        <button type=\"button\" *ngIf=\"isShowJsonDataButton\"\r\n                class=\"btn btn-secondary btn-sm mr-1 mb-2 me-1\"\r\n                (click)=\"previewJsonData()\">Json Data</button>\r\n        <button class=\"btn btn-success btn-sm mb-2 me-1\"\r\n                type=\"button\" *ngIf=\"isShowPublishButton\"\r\n                (click)=\"publishTemplate()\">Publish</button>\r\n    </div>\r\n</div>\r\n<div class=\"row\" cdkDropListGroup>\r\n    <div class=\"col-md-3\">\r\n        <div class=\"card\">\r\n            <h2 class=\"asw-card-header\">\r\n                Controls\r\n            </h2>\r\n            <div class=\"card-body\">\r\n                <div cdkDropList\r\n                    [cdkDropListData]=\"availableControls\"\r\n                    class=\"asw-list\">\r\n                    <div class=\"row\">\r\n                        <ng-container *ngFor=\"let item of availableControls\">\r\n                            <div class=\"col-md-12\">\r\n                                <div class=\"alert alert-primary d-flex asw-alert-primary align-items-center\" cdkDrag>\r\n                                    <mat-icon class=\"asw-icon mr-1 me-1\">{{item.icon}}</mat-icon>\r\n                                    {{item.displayName}}\r\n                                </div>\r\n                            </div>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div class=\"col-md-9\">\r\n        <div class=\"card\">\r\n            <h2 class=\"asw-card-header text-center alert-info asw-alert-info\">Drag and Drop a form component</h2>\r\n            <div class=\"card-body\">                \r\n                <div cdkDropList\r\n                    [cdkDropListData]=\"formContainer\"\r\n                    class=\"asw-list\"\r\n                    (cdkDropListDropped)=\"drop($event)\">\r\n                    <div class=\"row\">\r\n                        <ng-container *ngFor=\"let control of formContainer; let i = index\">\r\n                            <div class=\"asw-box\" [ngClass]=\"control.column\" cdkDrag>\r\n                                <ng-container [ngSwitch]=\"control.controlType\" class=\"asw-full-width\">\r\n                                    <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n                                        <asw-autocomplete [control]=\"control\"\r\n                                                          [controlIndex]=\"i\"\r\n                                                          [isPreviewTemplate]=\"true\"\r\n                                                          (autocompleteUpdateEvent)=\"updatedControl($event)\"\r\n                                                          (autocompleteDeleteEvent)=\"deleteControl($event)\"\r\n                                                          (selectionChange)=\"onSelectionChange($event)\"\r\n                                                          (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-autocomplete>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'header'\">\r\n                                        <asw-header [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (headerUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (headerDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-header>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'qr-code'\">\r\n                                        <asw-qrcode [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (qrCodeUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (qrCodeDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-qrcode>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'image'\">\r\n                                        <asw-image [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (imageUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (imageDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-image>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'textfield'\">\r\n                                        <asw-textfield [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (textFieldUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (textFieldDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-textfield>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'textarea'\">\r\n                                        <asw-textarea [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (textAreaUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (textAreaDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-textarea>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'number'\">\r\n                                        <asw-number [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    [formControls]=\"formContainer\"\r\n                                                    (numberUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (numberDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-number>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'calculation'\">\r\n                                        <asw-calculation [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [formControls]=\"formContainer\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (calculationUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (calculationDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (aswModelChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-calculation>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'select'\">\r\n                                        <asw-select [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (selectUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (selectDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (selectionChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-select>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'multi-select'\">\r\n                                        <asw-multi-select [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (multiSelectUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (multiSelectDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-multi-select>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'radio'\">\r\n                                        <asw-radio-button [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (radioButtonUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (radioButtonDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-radio-button>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'checkbox'\">\r\n                                        <asw-checkbox [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (checkboxUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (checkboxDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (selectionChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-checkbox>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'datepicker'\">\r\n                                        <asw-datepicker [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (datepickerUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (datepickerDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (dateChange)=\"onSelectionChange($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-datepicker>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'button'\">\r\n                                        <asw-button [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (buttonUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (buttonDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (buttonClickEvent)=\"buttonClicked($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-button>                                       \r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'paragraph'\">\r\n                                        <asw-paragraph [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (paragraphUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (paragraphDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-paragraph>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'divider'\">\r\n                                        <asw-divider [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (dividerDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-divider>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'slide-toggle'\">\r\n                                        <asw-slide-toggle [control]=\"control\"\r\n                                                            [controlIndex]=\"i\"\r\n                                                            [isPreviewTemplate]=\"true\"\r\n                                                            (slidetoggleUpdateEvent)=\"updatedControl($event)\"\r\n                                                            (slidetoggleDeleteEvent)=\"deleteControl($event)\"\r\n                                                            (selectionChange)=\"onSelectionChange($event)\"\r\n                                                            (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-slide-toggle>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'gps'\">\r\n                                        <asw-gps [control]=\"control\"\r\n                                                    [controlIndex]=\"i\"\r\n                                                    [isPreviewTemplate]=\"true\"\r\n                                                    (gpsUpdateEvent)=\"updatedControl($event)\"\r\n                                                    (gpsDeleteEvent)=\"deleteControl($event)\"\r\n                                                    (gpsAddressChange)=\"onSelectionChange($event)\"\r\n                                                    (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-gps>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'signature'\">\r\n                                        <asw-signature [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (signatureUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (signatureDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-signature>\r\n                                    </ng-container>\r\n                                    <ng-container *ngSwitchCase=\"'drawing'\">\r\n                                        <asw-drawing [control]=\"control\"\r\n                                                        [controlIndex]=\"i\"\r\n                                                        [isPreviewTemplate]=\"true\"\r\n                                                        (drawingUpdateEvent)=\"updatedControl($event)\"\r\n                                                        (drawingDeleteEvent)=\"deleteControl($event)\"\r\n                                                        (duplicateControl)=\"duplicateControl($event)\">\r\n                                        </asw-drawing>\r\n                                    </ng-container>\r\n                                </ng-container>\r\n                            </div>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>", styles: ["h2{margin:0}.asw-list{min-height:595px;border-radius:4px;display:block}.asw-box{padding:7px;border-bottom:solid 1px #ccc;color:#000000de;flex-direction:row;align-items:center;justify-content:space-between;box-sizing:border-box;cursor:move;background:white;font-size:14px}.alert{padding:.4rem!important;margin-bottom:.4rem!important}.asw-alert-primary{color:#fff!important;background-color:#2780e3!important;border-color:#2780e3!important;cursor:move}.asw-card-header{padding:.5rem 1rem;margin-bottom:0;background-color:#00000008;border-bottom:1px solid rgba(0,0,0,.125)}.asw-alert-info{color:#502c61!important;background-color:#ebddf1!important;border-color:#e2cfec!important}.cdk-drag-preview{box-sizing:border-box;border-radius:4px;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.asw-list.cdk-drop-list-dragging .asw-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i2.NotificationService }]; }, propDecorators: { uploadData: [{
                type: Input
            }], isShowPreviewButton: [{
                type: Input
            }], isShowJsonDataButton: [{
                type: Input
            }], isShowPublishButton: [{
                type: Input
            }], previewClick: [{
                type: Output
            }], publishClick: [{
                type: Output
            }], buttonClick: [{
                type: Output
            }], aswModelChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 