/**
 * @license
 * Copyright ASW (A Software World) All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Constants, ObjectUtils } from '@asoftwareworld/form-builder/form-control/core';
import * as i0 from "@angular/core";
import * as i1 from "@asoftwareworld/form-builder/form-control/core";
import * as i2 from "@asoftwareworld/form-builder/form-control/autocomplete";
import * as i3 from "@asoftwareworld/form-builder/form-control/header";
import * as i4 from "@asoftwareworld/form-builder/form-control/qrcode";
import * as i5 from "@asoftwareworld/form-builder/form-control/image";
import * as i6 from "@asoftwareworld/form-builder/form-control/textfield";
import * as i7 from "@asoftwareworld/form-builder/form-control/textarea";
import * as i8 from "@asoftwareworld/form-builder/form-control/number";
import * as i9 from "@asoftwareworld/form-builder/form-control/calculation";
import * as i10 from "@asoftwareworld/form-builder/form-control/select";
import * as i11 from "@asoftwareworld/form-builder/form-control/multi-select";
import * as i12 from "@asoftwareworld/form-builder/form-control/radio-button";
import * as i13 from "@asoftwareworld/form-builder/form-control/checkbox";
import * as i14 from "@asoftwareworld/form-builder/form-control/datepicker";
import * as i15 from "@asoftwareworld/form-builder/form-control/button";
import * as i16 from "@asoftwareworld/form-builder/form-control/paragraph";
import * as i17 from "@asoftwareworld/form-builder/form-control/divider";
import * as i18 from "@asoftwareworld/form-builder/form-control/slide-toggle";
import * as i19 from "@asoftwareworld/form-builder/form-control/gps";
import * as i20 from "@asoftwareworld/form-builder/form-control/signature";
import * as i21 from "@asoftwareworld/form-builder/form-control/drawing";
import * as i22 from "@angular/common";
export class AswPreviewTemplate {
    constructor(notificationService) {
        this.notificationService = notificationService;
        this.constants = Constants;
        this.formContainer = [];
        this.buttonClick = new EventEmitter();
        this.aswModelChange = new EventEmitter();
    }
    updatedControl(data) {
        this.formContainer.splice(data.index, 1, data.control);
    }
    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);
    }
}
AswPreviewTemplate.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswPreviewTemplate, deps: [{ token: i1.NotificationService }], target: i0.ɵɵFactoryTarget.Component });
AswPreviewTemplate.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.4", type: AswPreviewTemplate, selector: "asw-preview-template", inputs: { formContainer: "formContainer" }, outputs: { buttonClick: "buttonClick", aswModelChange: "aswModelChange" }, ngImport: i0, template: "<div class=\"row\">\r\n    <div class=\"col-md-12 text-right\">\r\n        <button mat-raised-button \r\n                type=\"button\"\r\n                class=\"btn btn-secondary btn-sm float-end mb-2\">Download Pdf\r\n        </button>                \r\n    </div>\r\n</div>\r\n<div class=\"row\">            \r\n    <div class=\"col-md-12\">\r\n        <div class=\"card\">\r\n            <div class=\"card-body\">\r\n                <div class=\"row\">\r\n                    <ng-container *ngFor=\"let control of formContainer; let i = index\">\r\n                        <ng-container [ngSwitch]=\"control.controlType\" class=\"asw-full-width\">\r\n                            <div [ngClass]=\"control.column\">\r\n                                <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n                                    <asw-autocomplete [control]=\"control\"\r\n                                                      [controlIndex]=\"i\"\r\n                                                      (selectionChange)=\"onSelectionChange($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                                    </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                                    </asw-qrcode>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'image'\">\r\n                                    <asw-image [control]=\"control\"\r\n                                               [controlIndex]=\"i\"\r\n                                               (imageUpdateEvent)=\"updatedControl($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                                                (aswModelChange)=\"onSelectionChange($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                                                    (aswModelChange)=\"onSelectionChange($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                                                [formControls]=\"formContainer\"\r\n                                                (aswModelChange)=\"onSelectionChange($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                                                (aswModelChange)=\"onSelectionChange($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                                                (selectionChange)=\"onSelectionChange($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                                                        (selectionChange)=\"onSelectionChange($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                                                        (selectionChange)=\"onSelectionChange($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                                                    (selectionChange)=\"onSelectionChange($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                                                    (dateChange)=\"onSelectionChange($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                                                (buttonClickEvent)=\"buttonClicked($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                                    </asw-paragraph>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'divider'\">\r\n                                    <asw-divider [control]=\"control\"\r\n                                                [controlIndex]=\"i\">\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                                                        (selectionChange)=\"onSelectionChange($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                                                (gpsAddressChange)=\"onSelectionChange($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                                    </asw-signature>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'drawing'\">\r\n                                    <asw-drawing [control]=\"control\"\r\n                                                    [controlIndex]=\"i\">\r\n                                    </asw-drawing>\r\n                                </ng-container>\r\n                            </div>\r\n                        </ng-container>\r\n                    </ng-container>\r\n                </div>                        \r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>", components: [{ type: i2.AswAutocomplete, selector: "asw-autocomplete", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["autocompleteUpdateEvent", "autocompleteDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i3.AswHeader, selector: "asw-header", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["headerUpdateEvent", "headerDeleteEvent", "duplicateControl"] }, { type: i4.AswQrCode, selector: "asw-qrcode", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["qrCodeUpdateEvent", "qrCodeDeleteEvent", "duplicateControl"] }, { type: i5.AswImage, selector: "asw-image", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["imageUpdateEvent", "imageDeleteEvent", "duplicateControl"] }, { type: i6.AswTextField, selector: "asw-textfield", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["textFieldUpdateEvent", "textFieldDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i7.AswTextarea, selector: "asw-textarea", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["textAreaUpdateEvent", "textAreaDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i8.AswNumber, selector: "asw-number", inputs: ["control", "formControls", "controlIndex", "isPreviewTemplate"], outputs: ["numberUpdateEvent", "numberDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i9.AswCalculation, selector: "asw-calculation", inputs: ["control", "formControls", "controlIndex", "isPreviewTemplate"], outputs: ["calculationUpdateEvent", "calculationDeleteEvent", "aswModelChange", "duplicateControl"] }, { type: i10.AswSelect, selector: "asw-select", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["selectUpdateEvent", "selectDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i11.AswMultiSelect, selector: "asw-multi-select", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["multiSelectUpdateEvent", "multiSelectDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i12.AswRadioButton, selector: "asw-radio-button", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["radioButtonUpdateEvent", "radioButtonDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i13.AswCheckbox, selector: "asw-checkbox", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["checkboxUpdateEvent", "checkboxDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i14.AswDatepicker, selector: "asw-datepicker", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["datepickerUpdateEvent", "datepickerDeleteEvent", "dateChange", "duplicateControl"] }, { type: i15.AswButton, selector: "asw-button", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["buttonClickEvent", "buttonUpdateEvent", "buttonDeleteEvent", "duplicateControl"] }, { type: i16.AswParagraph, selector: "asw-paragraph", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["paragraphUpdateEvent", "paragraphDeleteEvent", "duplicateControl"] }, { type: i17.AswDivider, selector: "asw-divider", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["dividerDeleteEvent", "duplicateControl"] }, { type: i18.AswSlideToggle, selector: "asw-slide-toggle", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["slidetoggleUpdateEvent", "slidetoggleDeleteEvent", "selectionChange", "duplicateControl"] }, { type: i19.AswGps, selector: "asw-gps", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["gpsUpdateEvent", "gpsDeleteEvent", "gpsAddressChange", "duplicateControl"] }, { type: i20.AswSignature, selector: "asw-signature", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["signatureUpdateEvent", "signatureDeleteEvent", "duplicateControl"] }, { type: i21.AswDrawing, selector: "asw-drawing", inputs: ["control", "controlIndex", "isPreviewTemplate"], outputs: ["drawingUpdateEvent", "drawingDeleteEvent", "duplicateControl"] }], directives: [{ type: i22.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i22.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i22.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i22.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.4", ngImport: i0, type: AswPreviewTemplate, decorators: [{
            type: Component,
            args: [{ selector: 'asw-preview-template', template: "<div class=\"row\">\r\n    <div class=\"col-md-12 text-right\">\r\n        <button mat-raised-button \r\n                type=\"button\"\r\n                class=\"btn btn-secondary btn-sm float-end mb-2\">Download Pdf\r\n        </button>                \r\n    </div>\r\n</div>\r\n<div class=\"row\">            \r\n    <div class=\"col-md-12\">\r\n        <div class=\"card\">\r\n            <div class=\"card-body\">\r\n                <div class=\"row\">\r\n                    <ng-container *ngFor=\"let control of formContainer; let i = index\">\r\n                        <ng-container [ngSwitch]=\"control.controlType\" class=\"asw-full-width\">\r\n                            <div [ngClass]=\"control.column\">\r\n                                <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n                                    <asw-autocomplete [control]=\"control\"\r\n                                                      [controlIndex]=\"i\"\r\n                                                      (selectionChange)=\"onSelectionChange($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                                    </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                                    </asw-qrcode>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'image'\">\r\n                                    <asw-image [control]=\"control\"\r\n                                               [controlIndex]=\"i\"\r\n                                               (imageUpdateEvent)=\"updatedControl($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                                                (aswModelChange)=\"onSelectionChange($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                                                    (aswModelChange)=\"onSelectionChange($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                                                [formControls]=\"formContainer\"\r\n                                                (aswModelChange)=\"onSelectionChange($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                                                (aswModelChange)=\"onSelectionChange($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                                                (selectionChange)=\"onSelectionChange($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                                                        (selectionChange)=\"onSelectionChange($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                                                        (selectionChange)=\"onSelectionChange($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                                                    (selectionChange)=\"onSelectionChange($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                                                    (dateChange)=\"onSelectionChange($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                                                (buttonClickEvent)=\"buttonClicked($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                                    </asw-paragraph>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'divider'\">\r\n                                    <asw-divider [control]=\"control\"\r\n                                                [controlIndex]=\"i\">\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                                                        (selectionChange)=\"onSelectionChange($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                                                (gpsAddressChange)=\"onSelectionChange($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                                    </asw-signature>\r\n                                </ng-container>\r\n                                <ng-container *ngSwitchCase=\"'drawing'\">\r\n                                    <asw-drawing [control]=\"control\"\r\n                                                    [controlIndex]=\"i\">\r\n                                    </asw-drawing>\r\n                                </ng-container>\r\n                            </div>\r\n                        </ng-container>\r\n                    </ng-container>\r\n                </div>                        \r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>" }]
        }], ctorParameters: function () { return [{ type: i1.NotificationService }]; }, propDecorators: { formContainer: [{
                type: Input
            }], buttonClick: [{
                type: Output
            }], aswModelChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 