import { Component } from "@angular/core";
import { UntypedFormControl, UntypedFormGroup, Validators } from "@angular/forms";
import { takeUntil } from "rxjs/operators";
import { QMSCKEditorBaseComponent } from "../../../qms-ckeditor-base.component";
import * as i0 from "@angular/core";
import * as i1 from "../../../../services/translation-registry.service";
import * as i2 from "@angular/material/dialog";
import * as i3 from "@angular/common";
import * as i4 from "@angular/material/icon";
import * as i5 from "@angular/material/input";
import * as i6 from "@angular/material/form-field";
import * as i7 from "@angular/forms";
import * as i8 from "@angular/material/button";
export class SaveTemplateComponent extends QMSCKEditorBaseComponent {
    constructor(translate, dialogRef) {
        super();
        this.translate = translate;
        this.dialogRef = dialogRef;
        this.saveFormGroup = new UntypedFormGroup({
            templateName: new UntypedFormControl('', [Validators.required])
        });
        this.templateName = '';
    }
    ngOnInit() {
        this.translate.getLanguageSubject$.pipe(takeUntil(this.ngUnsubcribe)).subscribe((res) => {
            if (res) {
                this.LANG = this.translate.getObjectLang(res);
            }
        });
    }
    saveTemplate() {
        this.dialogRef.close(this.templateName);
        // if (this.templateType === CKEditorEventConst.QMSCK_BPMN) {
        //     this.bpmn.templateName = this.templateName;
        //     this.bpmnApiService
        //         .bpmnModifying(this.bpmn)
        //         .pipe(takeUntil(this.ngUnsubcribe))
        //         .subscribe((result) => {
        //             if (result) {
        //                 this.bmpnService.addItemTemplate(result, this.bpmn);
        //                 QMSCKEditorToastService.success(this.LANG.QMSCKEDITOR.SAVED);
        //                 this.onCloseDialog();
        //             } else {
        //                 QMSCKEditorToastService.error(this.LANG.QMSCKEDITOR.SAVE_FAILED);
        //             }
        //         });
        // }
        // else if (this.templateType === CKEditorEventConst.QMSCK_FLOWCHART) {
        //     this.flowchart.templateName = this.templateName;
        //     this.flowchartService
        //         .flowchartModifying(this.flowchart)
        //         .pipe(takeUntil(this.ngUnsubcribe))
        //         .subscribe((result) => {
        //             if (result) {
        //                 QMSCKEditorToastService.success(this.LANG.QMSCKEDITOR.SAVED);
        //                 this.flowchart.id = result;
        //                 const scrollTop = this.commonService.getScrollTopCkeditor(this.ckEditor);
        //                 this.dialogRef.close(this.flowchart);
        //                 this.commonService.setScrollTopEditorContainer(this.ckEditor, scrollTop);
        //             } else {
        //                 QMSCKEditorToastService.error(this.LANG.QMSCKEDITOR.SAVE_FAILED);
        //             }
        //         });
        // }
    }
    onCloseDialog() {
        this.dialogRef.close();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SaveTemplateComponent, deps: [{ token: i1.TranslateLibraryService }, { token: i2.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: SaveTemplateComponent, selector: "save-template", usesInheritance: true, ngImport: i0, template: "<div id=\"qmsckeditor-bpmn\" class=\"qmsckeditor qmsckeditor__savetemplate__container\">\n  <div id=\"qmsckeditor-load-template-header\">\n    <span id=\"qmsckeditor-bpmn-header_001\" mat-icon-button class=\"qmsckeditor button__close\" (click)=\"onCloseDialog()\">\n      <mat-icon>close</mat-icon>\n    </span>\n    <div id=\"qmsckeditor-load-template-header_002\" mat-dialog-content>\n      <h2 id=\"qmsckeditor-template_002_001\">Save as template</h2>\n    </div>\n\n    <form [formGroup]=\"saveFormGroup\">\n      <div id=\"qmsckeditor-save-as-content\" class=\"qmsckeditor save__as__template height\">\n        <div id=\"qmsckeditor-save-as-content_001\" class=\"col-12 mt-1 pl-2 pr-2 ps-2 pe-2\">\n          <div id=\"qmsckeditor-save-as-panel_001\">\n            <div id=\"qmsckeditor-save-as-panel_001_001\">\n              <mat-form-field class=\"col-12 pl-0 pr-0 ps-0 pe-0\" appearance=\"fill\">\n                <mat-label>{{ LANG.BPMN.TEMPLATE_NAME }}</mat-label>\n                <input matInput formControlName=\"templateName\" [(ngModel)]=\"templateName\" />\n                <mat-error *ngIf=\"saveFormGroup.get('templateName').hasError('required')\" class=\"mt5\">\n                </mat-error>\n              </mat-form-field>\n            </div>\n            <div id=\"qmsckeditor-save-as-panel_001_003\" class=\"qmsckeditor button__groups row mr-0 ml-0 ms-0 me-0\">\n              <div class=\"col-6\">\n                <button class=\"save\" mat-flat-button (click)=\"saveTemplate()\" [disabled]=\"saveFormGroup.invalid\">\n                  {{ LANG.QMSCKEDITOR.SAVE }}\n                </button>\n              </div>\n              <div class=\"col-6\">\n                <button class=\"cancel\" (click)=\"onCloseDialog()\">\n                  {{ LANG.QMSCKEDITOR.CANCEL }}\n                </button>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n    </form>\n  </div>\n</div>", styles: [""], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: i4.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i5.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"] }, { kind: "component", type: i6.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i6.MatLabel, selector: "mat-label" }, { kind: "directive", type: i6.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i7.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i7.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i7.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i8.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SaveTemplateComponent, decorators: [{
            type: Component,
            args: [{ selector: 'save-template', template: "<div id=\"qmsckeditor-bpmn\" class=\"qmsckeditor qmsckeditor__savetemplate__container\">\n  <div id=\"qmsckeditor-load-template-header\">\n    <span id=\"qmsckeditor-bpmn-header_001\" mat-icon-button class=\"qmsckeditor button__close\" (click)=\"onCloseDialog()\">\n      <mat-icon>close</mat-icon>\n    </span>\n    <div id=\"qmsckeditor-load-template-header_002\" mat-dialog-content>\n      <h2 id=\"qmsckeditor-template_002_001\">Save as template</h2>\n    </div>\n\n    <form [formGroup]=\"saveFormGroup\">\n      <div id=\"qmsckeditor-save-as-content\" class=\"qmsckeditor save__as__template height\">\n        <div id=\"qmsckeditor-save-as-content_001\" class=\"col-12 mt-1 pl-2 pr-2 ps-2 pe-2\">\n          <div id=\"qmsckeditor-save-as-panel_001\">\n            <div id=\"qmsckeditor-save-as-panel_001_001\">\n              <mat-form-field class=\"col-12 pl-0 pr-0 ps-0 pe-0\" appearance=\"fill\">\n                <mat-label>{{ LANG.BPMN.TEMPLATE_NAME }}</mat-label>\n                <input matInput formControlName=\"templateName\" [(ngModel)]=\"templateName\" />\n                <mat-error *ngIf=\"saveFormGroup.get('templateName').hasError('required')\" class=\"mt5\">\n                </mat-error>\n              </mat-form-field>\n            </div>\n            <div id=\"qmsckeditor-save-as-panel_001_003\" class=\"qmsckeditor button__groups row mr-0 ml-0 ms-0 me-0\">\n              <div class=\"col-6\">\n                <button class=\"save\" mat-flat-button (click)=\"saveTemplate()\" [disabled]=\"saveFormGroup.invalid\">\n                  {{ LANG.QMSCKEDITOR.SAVE }}\n                </button>\n              </div>\n              <div class=\"col-6\">\n                <button class=\"cancel\" (click)=\"onCloseDialog()\">\n                  {{ LANG.QMSCKEDITOR.CANCEL }}\n                </button>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n    </form>\n  </div>\n</div>" }]
        }], ctorParameters: () => [{ type: i1.TranslateLibraryService }, { type: i2.MatDialogRef }] });
//# sourceMappingURL=data:application/json;base64, 