import { Component, Inject } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { forkJoin } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
import QMSCKEditorTreeFunctions from '../../common/functions/tree.function';
import { QMSCKEditorBaseComponent } from '../../qms-ckeditor-base.component';
import { DataType } from '../../../common/enum/data-type.enum';
import * as i0 from "@angular/core";
import * as i1 from "../../services/qms-ckeditor-tree.service";
import * as i2 from "../../../services/translation-registry.service";
import * as i3 from "@angular/material/dialog";
import * as i4 from "@angular/common";
import * as i5 from "@angular/material/icon";
import * as i6 from "@angular/material/input";
import * as i7 from "@angular/forms";
import * as i8 from "@angular/material/core";
import * as i9 from "@angular/material/button";
import * as i10 from "@angular/material/autocomplete";
import * as i11 from "@angular/cdk/scrolling";
import * as i12 from "../../common/module/tree/qms-ckeditor-tree.component";
import * as i13 from "../../common/models/qms-ckeditor-relation.model";
export class QMSCKEditorRelatedComponent extends QMSCKEditorBaseComponent {
    constructor(treeService, translate, dialogRef, data) {
        super();
        this.treeService = treeService;
        this.translate = translate;
        this.dialogRef = dialogRef;
        this.data = data;
        this.processNumber = -1;
        this.listParentProcessId = {};
        this.listParentDocumentId = {};
        this.myControl = new UntypedFormControl();
        this.filteredOptions = [];
        this.isInputValue = false;
        this.isOnlyDocument = false;
        this.isEnableFolder = false;
        this.isOnlyDocument = data.isOnlyDocument;
        this.isEnableFolder = data.isEnableFolder;
    }
    ngOnInit() {
        this.translate.getLanguageSubject$.pipe(takeUntil(this.ngUnsubcribe)).subscribe((res) => {
            if (res) {
                this.LANG = this.translate.getObjectLang(res);
            }
        });
        this.selectedNode = { id: '', type: 0 };
        this.getProcessAndDocumentData();
        this.myControl.valueChanges.pipe(debounceTime(1000)).subscribe((val) => {
            this.isInputValue = true;
            this.filteredOptions = this.onSearchRelated(val);
        });
    }
    getProcessAndDocumentData() {
        forkJoin([this.getProcessData(), this.getDocumentData()])
            .pipe(takeUntil(this.ngUnsubcribe))
            .subscribe(([p, d]) => {
            this.mappingData(p, 2);
            this.mappingData(d, 1);
            // for  process
            this.filterData = this.processData.filter((x) => {
                return x.parentId === '';
            });
            this.treeDataFile = QMSCKEditorTreeFunctions.buildObjectTree(this.filterData);
            this.treeProcessData = QMSCKEditorTreeFunctions.buildArrayTree(this.treeDataFile, 0);
            // for document
            this.filterData = this.documentData.filter((x) => {
                return x.parentId === '';
            });
            this.treeDataFile = QMSCKEditorTreeFunctions.buildObjectTree(this.filterData);
            this.treeDocumentData = QMSCKEditorTreeFunctions.buildArrayTree(this.treeDataFile, 0);
        });
    }
    getProcessData() {
        return this.treeService.getProcessList().pipe(takeUntil(this.ngUnsubcribe));
    }
    getDocumentData() {
        return this.treeService.getDocumentList().pipe(takeUntil(this.ngUnsubcribe));
    }
    mappingData(array, dataType) {
        if (array) {
            if (dataType === 1) {
                this.documentData = array.map((item) => {
                    if (!!item.parentId && item.parentId.length > 0) {
                        this.listParentDocumentId[item.parentId] = 1;
                    }
                    if (!!item.childId && item.childId.length > 0) {
                        this.listParentDocumentId[item.rootId] = 1;
                    }
                    return {
                        rootId: item.rootId,
                        parentId: item.parentId,
                        rootName: item.rootName,
                        subName: item.subName,
                        childId: item.childId,
                        childName: item.childName,
                        statusId: item.statusId,
                        displayId: item.displayId
                    };
                });
            }
            else if (dataType === 2) {
                this.processData = array.filter((item) => {
                    if (!!item.parentId && item.parentId.length > 0) {
                        this.listParentProcessId[item.parentId] = 1;
                    }
                    if (item.childId && item.childId.length > 0) {
                        this.listParentProcessId[item.rootId] = 1;
                    }
                    if (Number(item.displayId) === this.processNumber) {
                        item.childId = '';
                        item.childName = '';
                        this.areaOfCurrentProcess = item.rootId;
                    }
                    return {
                        rootId: item.rootId,
                        parentId: item.parentId,
                        rootName: item.rootName,
                        subName: item.subName,
                        childId: item.childId,
                        childName: item.childName,
                        statusId: item.statusId,
                        displayId: item.displayId
                    };
                });
            }
        }
    }
    onCloseClick() {
        this.dialogRef.close();
    }
    onAddDocumentProcess() {
        let data;
        this.linkUrl = { id: '', url: '', title: '' };
        switch (this.selectedNode.type) {
            case DataType.document:
                data = this.documentData.find((e) => {
                    return e.childId === this.selectedNode.id;
                });
                if (data) {
                    this.linkUrl.id = this.selectedNode.id;
                    this.linkUrl.url = `/document/${data.childId}`;
                    this.linkUrl.title = data.childName;
                }
                break;
            case DataType.process:
                data = this.processData.find((e) => {
                    return e.childId === this.selectedNode.id;
                });
                if (data) {
                    this.linkUrl.id = this.selectedNode.id;
                    this.linkUrl.url = `/process-detail/${data.displayId}`;
                    this.linkUrl.title = data.childName;
                }
                break;
            case DataType.area:
                data = this.processData.find((e) => {
                    return e.rootId === this.selectedNode.id;
                });
                if (data) {
                    this.linkUrl.id = this.selectedNode.id;
                    this.linkUrl.url = `/area/detail/${data.rootId}`;
                    this.linkUrl.title = data.rootName;
                }
                break;
            case DataType.folder:
                data = this.documentData.find((e) => {
                    return e.rootId === this.selectedNode.id;
                });
                if (data) {
                    this.linkUrl.id = this.selectedNode.id;
                    this.linkUrl.url = `/folder/${data.rootId}`;
                    this.linkUrl.title = data.rootName;
                }
                break;
            default:
                break;
        }
        this.dialogRef.close(this.linkUrl);
    }
    selectAreaNode(id) {
        this.selectedNode.id = id;
        this.selectedNode.type = DataType.area;
    }
    selectProcessNode(id) {
        this.selectedNode.id = id;
        this.selectedNode.type = DataType.process;
    }
    selectDocumentNode(id) {
        this.selectedNode.id = id;
        this.selectedNode.type = DataType.document;
    }
    selectHandbookNode(id) {
        this.selectedNode.id = id;
        this.selectedNode.type = DataType.folder;
    }
    onSearchRelated(_val) {
        const arr = [];
        let data = [];
        if (typeof _val !== 'string' || !_val?.trim().length) {
            return arr;
        }
        let val = _val.trim().toLowerCase();
        if (!this.isOnlyDocument) {
            this.createSearchItem(arr, this.processData, DataType.process, val);
        }
        this.createSearchItem(arr, this.documentData, DataType.document, val);
        this.setResultHeight(arr);
        return arr;
    }
    displayRelated(related) {
        return related ? related.name : undefined;
    }
    selectRelated(id, type) {
        this.selectedNode = { id, type };
        this.onAddDocumentProcess();
    }
    setResultHeight(arr) {
        const viewreports = document.getElementsByClassName('related-viewport');
        if (viewreports) {
            let iHeight = 0;
            const view = viewreports[0];
            if (arr.length * 5 > 50) {
                iHeight = 51;
            }
            else {
                iHeight = arr.length * 5 + 1;
                if (iHeight > 0) {
                    // window[ProcessRelatedConst.IS_DISPLAY_SEARCH_RESULT] = true;
                }
            }
            view.style.height = `${iHeight}vh`;
            view.style.display = 'block';
        }
    }
    hideSearchResult() {
        if (this.filteredOptions && this.filteredOptions.length > 0) {
            const viewreports = document.getElementsByClassName('related-viewport');
            if (viewreports && viewreports.length) {
                const view = viewreports[0];
                view.style.display = 'none';
                // window[ProcessRelatedConst.IS_DISPLAY_SEARCH_RESULT] = false;
            }
        }
    }
    showSearchResult() {
        if (this.filteredOptions && this.filteredOptions.length) {
            const viewreports = document.getElementsByClassName('related-viewport');
            if (viewreports && viewreports.length) {
                const view = viewreports[0];
                if (view.style.display === 'none') {
                    view.style.display = 'block';
                    // window[ProcessRelatedConst.IS_DISPLAY_SEARCH_RESULT] = true;
                }
            }
        }
    }
    createSearchItem(result, data, documentType, searchKey) {
        data.forEach((item) => {
            if (item.childName.toLowerCase().includes(searchKey) || item.displayId.toString().includes(searchKey)) {
                result.push({
                    id: item.childId,
                    name: item.childName,
                    type: documentType
                });
            }
            ;
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: QMSCKEditorRelatedComponent, deps: [{ token: i1.QMSCKEditorTreeService }, { token: i2.TranslateLibraryService }, { token: i3.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: QMSCKEditorRelatedComponent, selector: "app-dialog", usesInheritance: true, ngImport: i0, template: "<div id=\"qmsckeditor_tree\" class=\"qmsckeditor qmsckeditor__tree__containter\">\n  <span\n    mat-icon-button\n    class=\"qmsckeditor button__close\"\n    (click)=\"onCloseClick()\"\n  >\n    <mat-icon>close</mat-icon>\n  </span>\n  <div id=\"qmsckeditor_tree_001\" mat-dialog-content>\n    <h2 *ngIf=\"!isOnlyDocument\">\n      {{ LANG.QMSCKEDITOR.ADD_DOCUMENT_PROCESS }}\n    </h2>\n    <h2 *ngIf=\"isOnlyDocument\">{{ LANG.QMSCKEDITOR.ADD_DOCUMENT }}</h2>\n  </div>\n  <div\n    id=\"qmsckeditor_tree_002\"\n    class=\"input__field\"\n    (click)=\"showSearchResult()\"\n  >\n    <input\n      #name\n      type=\"text\"\n      placeholder=\"{{ LANG.QMSCKEDITOR.SEARCH }}\"\n      matInput\n      [formControl]=\"myControl\"\n      [matAutocomplete]=\"auto\"\n    />\n    <mat-icon>search</mat-icon>\n  </div>\n  <mat-autocomplete\n    #auto=\"matAutocomplete\"\n    [displayWith]=\"displayRelated\"\n    style=\"height: 50vh\"\n  >\n    <cdk-virtual-scroll-viewport\n      itemSize=\"10\"\n      class=\"related-viewport\"\n      style=\"height: 50vh\"\n    >\n      <mat-option\n        *cdkVirtualFor=\"let option of filteredOptions\"\n        [value]=\"option\"\n      >\n        <div\n          *ngIf=\"option.type == 1\"\n          class=\"col-12\"\n          (click)=\"selectRelated(option.id, option.type)\"\n        >\n          <span\n            ><img\n              class=\"mat-icon\"\n              src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAiElEQVR4AezOAQaAABQE0dDBuk2AjvCPGDrQb0GQ2NCqzDAAvOFP0ahLb7pvvjwBmn1ABrXqfhOqj/3KR+VBPioMOqPyIB+VB/moPMhH5UGdAk26rs6B/AABAgQIECBAgL4E2vcZpJFG+DA5DppPQweFk+MgHiAuB+L7VHTIeyDuBg9kDBcwCgBx1CcsdvijVwAAAABJRU5ErkJggg==\"\n          /></span>\n          <span>{{ option.name }}</span>\n        </div>\n        <div\n          *ngIf=\"option.type == 2\"\n          class=\"col-12\"\n          (click)=\"selectRelated(option.id, option.type)\"\n        >\n          <span\n            ><img\n              class=\"mat-icon\"\n              src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYAQMAAADaua+7AAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAZQTFRFAAAAbHV9mFYLuQAAAAJ0Uk5TAP9bkSK1AAAAKUlEQVR4nGNgQALyjT/AWPL/DDCG8dmAclgx4w8wZgeqBWEGIBuMEQAAaJkRERdvY48AAAAASUVORK5CYII=\"\n          /></span>\n          <span>{{ option.name }}</span>\n        </div>\n      </mat-option>\n    </cdk-virtual-scroll-viewport>\n  </mat-autocomplete>\n  <div id=\"qmsckeditor_tree_003\" class=\"row ml-0 mr-0 mt20 ms-0 me-0\">\n    <div id=\"qmsckeditor_tree_003_001\" class=\"content-box\">\n      <strong *ngIf=\"!isOnlyDocument\">{{ LANG.QMSCKEDITOR.PROCESSES }}</strong>\n      <qms-ckeditor-tree\n        *ngIf=\"!isOnlyDocument\"\n        [areaOfCurrentProcess]=\"areaOfCurrentProcess\"\n        [listParentObj]=\"listParentProcessId\"\n        [treeData]=\"treeProcessData\"\n        [rawData]=\"processData\"\n        [docType]=\"2\"\n        [useExpandFeature]=\"true\"\n        [allowSelectFolder]=\"isEnableFolder\"\n        (selectNodeEvent)=\"selectProcessNode($event)\"\n        (selectFolderEvent)=\"selectAreaNode($event)\"\n      ></qms-ckeditor-tree>\n      <div *ngIf=\"!isOnlyDocument\" class=\"line-divider\"></div>\n      <strong>{{ LANG.QMSCKEDITOR.DOCUMENTS }}</strong>\n      <qms-ckeditor-tree\n        [areaOfCurrentProcess]=\"areaOfCurrentProcess\"\n        [listParentObj]=\"listParentDocumentId\"\n        [treeData]=\"treeDocumentData\"\n        [rawData]=\"documentData\"\n        [useExpandFeature]=\"true\"\n        [docType]=\"1\"\n        [allowSelectFolder]=\"isEnableFolder\"\n        (selectNodeEvent)=\"selectDocumentNode($event)\"\n        (selectFolderEvent)=\"selectHandbookNode($event)\"\n      ></qms-ckeditor-tree>\n    </div>\n  </div>\n  <div\n    id=\"qmsckeditor_tree_004\"\n    class=\"qmsckeditor button__groups mt20 row ml-0 mr-0 ms-0 me-0\"\n  >\n    <button\n      type=\"button\"\n      class=\"save col-12\"\n      mat-flat-button\n      (click)=\"onAddDocumentProcess()\"\n    >\n      {{ LANG.QMSCKEDITOR.ADD }}\n    </button>\n  </div>\n</div>\n", styles: [".mt5{margin-top:5px!important}.mt10{margin-top:10px!important}.mt7{margin-top:7px!important}.mt15{margin-top:15px!important}.mt20{margin-top:20px!important}.mt30{margin-top:30px!important}.mt40{margin-top:40px!important}.ml2{margin-left:2px!important}.ml3{margin-left:3px!important}.ml5{margin-left:5px!important}.ml15{margin-left:15px!important}.ml10{margin-left:10px!important}.ml12{margin-left:12px!important}.ml16{margin-left:16px!important}.ml-auto{margin-left:auto!important}.ml-25{margin-left:-25px!important}.mr5{margin-right:5px!important}.mr12{margin-right:12px!important}.mr15{margin-right:15px!important}.mb5{margin-bottom:5px!important}.mb10{margin-bottom:10px!important}.mb15{margin-bottom:15px!important}.pt8{padding-top:8px!important}.pt10{padding-top:10px!important}.pt15{padding-top:15px!important}.pt16{padding-top:16px!important}.pl15{padding-left:15px!important}.pl0{padding-left:0!important}.pr0{padding-right:0!important}.pr15{padding-right:15px!important}.fs12{font-size:12px}.fs14{font-size:14px!important}.fs16{font-size:16px!important}.fs22{font-size:22px!important}.fw500{font-weight:500!important}.italic-text{font-style:italic}.display-flex{display:flex}.qmsckeditor{font-family:Roboto,Helvetica Neue,sans-serif;font-size:14px;font-weight:400}.qmsckeditor h2{font-size:20px;font-weight:400}.qmsckeditor .mat-icon{color:#909497}.qmsckeditor__fullscreen{position:fixed;inset:0;background:#fff;overflow-y:auto;max-height:100vh;overflow-x:hidden}.qmsckeditor__cursor{cursor:pointer}.qmsckeditor__notallowed{cursor:not-allowed}.qmsckeditor.button__close{float:right;top:-24px;right:-24px;cursor:pointer}.qmsckeditor.button__done{float:right;top:-24px;right:-24px;cursor:pointer;margin-right:20px}.qmsckeditor.button__done .mat-icon{color:#28a745;font-weight:700}.qmsckeditor.button__groups button{min-height:40px;width:100%;border-radius:4px;border:1px solid #c5c5c5;font-family:Open Sans;font-weight:600;font-size:14px;letter-spacing:1px;line-height:16px}.qmsckeditor.button__groups .save{background:#f8f9f9}.qmsckeditor.button__groups .save:hover{background:#e5e7e9}.qmsckeditor.button__groups .save:disabled{cursor:not-allowed}.qmsckeditor.button__groups .cancel{background:#f8f9f9}.qmsckeditor.button__groups .cancel:hover{background:#e5e7e9}.qmsckeditor.button__groups .cancel:disabled{cursor:not-allowed}.qmsckeditor.button__groups .delete{background:#f8f9f9}.qmsckeditor.button__groups .delete:hover{background:#e5e7e9}.qmsckeditor.button__groups .delete:disabled{cursor:not-allowed}.qmsckeditor.confirm__button__groups button{min-height:36px;border-radius:4px;width:auto;border:1px solid #c5c5c5;font-family:Open Sans;font-weight:600;font-size:14px;letter-spacing:1px;line-height:16px;padding-left:15px;padding-right:15px}.qmsckeditor.confirm__button__groups .confirm{background:#f8f9f9}.qmsckeditor.confirm__button__groups .confirm:hover{background:#e5e7e9}.qmsckeditor.confirm__button__groups .cancel{background:#f8f9f9}.qmsckeditor.confirm__button__groups .cancel:hover{background:#e5e7e9}.qmsckeditor.template-content.height{min-height:420px;max-height:520px;overflow:auto}.qmsckeditor.template-content.title{margin-left:-9px}.qmsckeditor.link__content.height{min-height:400px;max-height:520px}.qmsckeditor.card{margin-bottom:10px;min-height:60px;box-shadow:none;border:1px solid #e5e5e5}.qmsckeditor.card .title{font-weight:700}.qmsckeditor.card .content{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.qmsckeditor.card .material-icons{font-size:20px}.qmsckeditor.tooltip-content.height{min-height:400px;max-height:472px;overflow:auto}.qmsckeditor.save__as__template.height{height:125px}.ck-content .page-break,.ck-content .ck-horizontal-line{width:100%}.ck-content hr{background:#ccc}.ck-font-size-dropdown .ck-dropdown__panel ul{max-height:320px;overflow-y:auto}.ck-font-size-dropdown .ck-dropdown__panel ul li .ck-fontsize-option .ck-button__label{line-height:50px}::ng-deep .qmsckeditor__tree__containter .input__field input{width:97%;padding:10px;outline:none;border:none;background:#eee}::ng-deep .qmsckeditor__tree__containter .input__field .mat-icon{margin-left:-35px;cursor:pointer;vertical-align:middle}::ng-deep .qmsckeditor__tree__containter .mat-tree{background:#00283a}::ng-deep .qmsckeditor__tree__containter .mat-tree-node{color:#fff;min-height:40px}::ng-deep .qmsckeditor__tree__containter .folder-icon{color:#a4b0de}::ng-deep .qmsckeditor__tree__containter .mat-icon{margin-bottom:5px}::ng-deep .qmsckeditor__tree__containter .content-box{min-width:375px;width:100%;height:435px;overflow-y:auto;background:#00283a;color:#fff}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item{width:100%;height:56px;border:1px solid #d4d5d6;padding:15px}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item:hover{background:#d8ddf0;cursor:pointer}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item .content-box-text{float:left;width:90%;height:26px;overflow:hidden}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item .content-box-icon{float:right}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item:not(:last-child){border-bottom:none}::ng-deep .qmsckeditor__tree__containter .content-box strong{text-transform:uppercase;margin:10px 0 0 2px}::ng-deep .qmsckeditor__tree__containter .line-divider{border-bottom:1px solid #ccc;height:1px;margin-top:10px}::ng-deep .qmsckeditor__tree__containter .loading ::ng-deep .mat-mdc-progress-spinner{width:21px;height:21px;margin:0 auto;top:32px}::ng-deep .mat-autocomplete-panel.mat-autocomplete-visible{overflow:hidden;max-height:none}::ng-deep .mat-autocomplete-panel.mat-autocomplete-hidden{visibility:hidden;display:none}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i6.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: "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.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i8.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i9.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i10.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i10.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: i11.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i11.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i11.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: i12.QMSCKEditorTreeComponent, selector: "qms-ckeditor-tree", inputs: ["rawData", "treeData", "useExpandFeature", "docType", "allowSelectFolder", "listParentObj", "areaOfCurrentProcess"], outputs: ["selectNodeEvent", "selectFolderEvent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: QMSCKEditorRelatedComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-dialog', template: "<div id=\"qmsckeditor_tree\" class=\"qmsckeditor qmsckeditor__tree__containter\">\n  <span\n    mat-icon-button\n    class=\"qmsckeditor button__close\"\n    (click)=\"onCloseClick()\"\n  >\n    <mat-icon>close</mat-icon>\n  </span>\n  <div id=\"qmsckeditor_tree_001\" mat-dialog-content>\n    <h2 *ngIf=\"!isOnlyDocument\">\n      {{ LANG.QMSCKEDITOR.ADD_DOCUMENT_PROCESS }}\n    </h2>\n    <h2 *ngIf=\"isOnlyDocument\">{{ LANG.QMSCKEDITOR.ADD_DOCUMENT }}</h2>\n  </div>\n  <div\n    id=\"qmsckeditor_tree_002\"\n    class=\"input__field\"\n    (click)=\"showSearchResult()\"\n  >\n    <input\n      #name\n      type=\"text\"\n      placeholder=\"{{ LANG.QMSCKEDITOR.SEARCH }}\"\n      matInput\n      [formControl]=\"myControl\"\n      [matAutocomplete]=\"auto\"\n    />\n    <mat-icon>search</mat-icon>\n  </div>\n  <mat-autocomplete\n    #auto=\"matAutocomplete\"\n    [displayWith]=\"displayRelated\"\n    style=\"height: 50vh\"\n  >\n    <cdk-virtual-scroll-viewport\n      itemSize=\"10\"\n      class=\"related-viewport\"\n      style=\"height: 50vh\"\n    >\n      <mat-option\n        *cdkVirtualFor=\"let option of filteredOptions\"\n        [value]=\"option\"\n      >\n        <div\n          *ngIf=\"option.type == 1\"\n          class=\"col-12\"\n          (click)=\"selectRelated(option.id, option.type)\"\n        >\n          <span\n            ><img\n              class=\"mat-icon\"\n              src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAiElEQVR4AezOAQaAABQE0dDBuk2AjvCPGDrQb0GQ2NCqzDAAvOFP0ahLb7pvvjwBmn1ABrXqfhOqj/3KR+VBPioMOqPyIB+VB/moPMhH5UGdAk26rs6B/AABAgQIECBAgL4E2vcZpJFG+DA5DppPQweFk+MgHiAuB+L7VHTIeyDuBg9kDBcwCgBx1CcsdvijVwAAAABJRU5ErkJggg==\"\n          /></span>\n          <span>{{ option.name }}</span>\n        </div>\n        <div\n          *ngIf=\"option.type == 2\"\n          class=\"col-12\"\n          (click)=\"selectRelated(option.id, option.type)\"\n        >\n          <span\n            ><img\n              class=\"mat-icon\"\n              src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYAQMAAADaua+7AAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAZQTFRFAAAAbHV9mFYLuQAAAAJ0Uk5TAP9bkSK1AAAAKUlEQVR4nGNgQALyjT/AWPL/DDCG8dmAclgx4w8wZgeqBWEGIBuMEQAAaJkRERdvY48AAAAASUVORK5CYII=\"\n          /></span>\n          <span>{{ option.name }}</span>\n        </div>\n      </mat-option>\n    </cdk-virtual-scroll-viewport>\n  </mat-autocomplete>\n  <div id=\"qmsckeditor_tree_003\" class=\"row ml-0 mr-0 mt20 ms-0 me-0\">\n    <div id=\"qmsckeditor_tree_003_001\" class=\"content-box\">\n      <strong *ngIf=\"!isOnlyDocument\">{{ LANG.QMSCKEDITOR.PROCESSES }}</strong>\n      <qms-ckeditor-tree\n        *ngIf=\"!isOnlyDocument\"\n        [areaOfCurrentProcess]=\"areaOfCurrentProcess\"\n        [listParentObj]=\"listParentProcessId\"\n        [treeData]=\"treeProcessData\"\n        [rawData]=\"processData\"\n        [docType]=\"2\"\n        [useExpandFeature]=\"true\"\n        [allowSelectFolder]=\"isEnableFolder\"\n        (selectNodeEvent)=\"selectProcessNode($event)\"\n        (selectFolderEvent)=\"selectAreaNode($event)\"\n      ></qms-ckeditor-tree>\n      <div *ngIf=\"!isOnlyDocument\" class=\"line-divider\"></div>\n      <strong>{{ LANG.QMSCKEDITOR.DOCUMENTS }}</strong>\n      <qms-ckeditor-tree\n        [areaOfCurrentProcess]=\"areaOfCurrentProcess\"\n        [listParentObj]=\"listParentDocumentId\"\n        [treeData]=\"treeDocumentData\"\n        [rawData]=\"documentData\"\n        [useExpandFeature]=\"true\"\n        [docType]=\"1\"\n        [allowSelectFolder]=\"isEnableFolder\"\n        (selectNodeEvent)=\"selectDocumentNode($event)\"\n        (selectFolderEvent)=\"selectHandbookNode($event)\"\n      ></qms-ckeditor-tree>\n    </div>\n  </div>\n  <div\n    id=\"qmsckeditor_tree_004\"\n    class=\"qmsckeditor button__groups mt20 row ml-0 mr-0 ms-0 me-0\"\n  >\n    <button\n      type=\"button\"\n      class=\"save col-12\"\n      mat-flat-button\n      (click)=\"onAddDocumentProcess()\"\n    >\n      {{ LANG.QMSCKEDITOR.ADD }}\n    </button>\n  </div>\n</div>\n", styles: [".mt5{margin-top:5px!important}.mt10{margin-top:10px!important}.mt7{margin-top:7px!important}.mt15{margin-top:15px!important}.mt20{margin-top:20px!important}.mt30{margin-top:30px!important}.mt40{margin-top:40px!important}.ml2{margin-left:2px!important}.ml3{margin-left:3px!important}.ml5{margin-left:5px!important}.ml15{margin-left:15px!important}.ml10{margin-left:10px!important}.ml12{margin-left:12px!important}.ml16{margin-left:16px!important}.ml-auto{margin-left:auto!important}.ml-25{margin-left:-25px!important}.mr5{margin-right:5px!important}.mr12{margin-right:12px!important}.mr15{margin-right:15px!important}.mb5{margin-bottom:5px!important}.mb10{margin-bottom:10px!important}.mb15{margin-bottom:15px!important}.pt8{padding-top:8px!important}.pt10{padding-top:10px!important}.pt15{padding-top:15px!important}.pt16{padding-top:16px!important}.pl15{padding-left:15px!important}.pl0{padding-left:0!important}.pr0{padding-right:0!important}.pr15{padding-right:15px!important}.fs12{font-size:12px}.fs14{font-size:14px!important}.fs16{font-size:16px!important}.fs22{font-size:22px!important}.fw500{font-weight:500!important}.italic-text{font-style:italic}.display-flex{display:flex}.qmsckeditor{font-family:Roboto,Helvetica Neue,sans-serif;font-size:14px;font-weight:400}.qmsckeditor h2{font-size:20px;font-weight:400}.qmsckeditor .mat-icon{color:#909497}.qmsckeditor__fullscreen{position:fixed;inset:0;background:#fff;overflow-y:auto;max-height:100vh;overflow-x:hidden}.qmsckeditor__cursor{cursor:pointer}.qmsckeditor__notallowed{cursor:not-allowed}.qmsckeditor.button__close{float:right;top:-24px;right:-24px;cursor:pointer}.qmsckeditor.button__done{float:right;top:-24px;right:-24px;cursor:pointer;margin-right:20px}.qmsckeditor.button__done .mat-icon{color:#28a745;font-weight:700}.qmsckeditor.button__groups button{min-height:40px;width:100%;border-radius:4px;border:1px solid #c5c5c5;font-family:Open Sans;font-weight:600;font-size:14px;letter-spacing:1px;line-height:16px}.qmsckeditor.button__groups .save{background:#f8f9f9}.qmsckeditor.button__groups .save:hover{background:#e5e7e9}.qmsckeditor.button__groups .save:disabled{cursor:not-allowed}.qmsckeditor.button__groups .cancel{background:#f8f9f9}.qmsckeditor.button__groups .cancel:hover{background:#e5e7e9}.qmsckeditor.button__groups .cancel:disabled{cursor:not-allowed}.qmsckeditor.button__groups .delete{background:#f8f9f9}.qmsckeditor.button__groups .delete:hover{background:#e5e7e9}.qmsckeditor.button__groups .delete:disabled{cursor:not-allowed}.qmsckeditor.confirm__button__groups button{min-height:36px;border-radius:4px;width:auto;border:1px solid #c5c5c5;font-family:Open Sans;font-weight:600;font-size:14px;letter-spacing:1px;line-height:16px;padding-left:15px;padding-right:15px}.qmsckeditor.confirm__button__groups .confirm{background:#f8f9f9}.qmsckeditor.confirm__button__groups .confirm:hover{background:#e5e7e9}.qmsckeditor.confirm__button__groups .cancel{background:#f8f9f9}.qmsckeditor.confirm__button__groups .cancel:hover{background:#e5e7e9}.qmsckeditor.template-content.height{min-height:420px;max-height:520px;overflow:auto}.qmsckeditor.template-content.title{margin-left:-9px}.qmsckeditor.link__content.height{min-height:400px;max-height:520px}.qmsckeditor.card{margin-bottom:10px;min-height:60px;box-shadow:none;border:1px solid #e5e5e5}.qmsckeditor.card .title{font-weight:700}.qmsckeditor.card .content{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.qmsckeditor.card .material-icons{font-size:20px}.qmsckeditor.tooltip-content.height{min-height:400px;max-height:472px;overflow:auto}.qmsckeditor.save__as__template.height{height:125px}.ck-content .page-break,.ck-content .ck-horizontal-line{width:100%}.ck-content hr{background:#ccc}.ck-font-size-dropdown .ck-dropdown__panel ul{max-height:320px;overflow-y:auto}.ck-font-size-dropdown .ck-dropdown__panel ul li .ck-fontsize-option .ck-button__label{line-height:50px}::ng-deep .qmsckeditor__tree__containter .input__field input{width:97%;padding:10px;outline:none;border:none;background:#eee}::ng-deep .qmsckeditor__tree__containter .input__field .mat-icon{margin-left:-35px;cursor:pointer;vertical-align:middle}::ng-deep .qmsckeditor__tree__containter .mat-tree{background:#00283a}::ng-deep .qmsckeditor__tree__containter .mat-tree-node{color:#fff;min-height:40px}::ng-deep .qmsckeditor__tree__containter .folder-icon{color:#a4b0de}::ng-deep .qmsckeditor__tree__containter .mat-icon{margin-bottom:5px}::ng-deep .qmsckeditor__tree__containter .content-box{min-width:375px;width:100%;height:435px;overflow-y:auto;background:#00283a;color:#fff}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item{width:100%;height:56px;border:1px solid #d4d5d6;padding:15px}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item:hover{background:#d8ddf0;cursor:pointer}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item .content-box-text{float:left;width:90%;height:26px;overflow:hidden}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item .content-box-icon{float:right}::ng-deep .qmsckeditor__tree__containter .content-box .content-box-item:not(:last-child){border-bottom:none}::ng-deep .qmsckeditor__tree__containter .content-box strong{text-transform:uppercase;margin:10px 0 0 2px}::ng-deep .qmsckeditor__tree__containter .line-divider{border-bottom:1px solid #ccc;height:1px;margin-top:10px}::ng-deep .qmsckeditor__tree__containter .loading ::ng-deep .mat-mdc-progress-spinner{width:21px;height:21px;margin:0 auto;top:32px}::ng-deep .mat-autocomplete-panel.mat-autocomplete-visible{overflow:hidden;max-height:none}::ng-deep .mat-autocomplete-panel.mat-autocomplete-hidden{visibility:hidden;display:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.QMSCKEditorTreeService }, { type: i2.TranslateLibraryService }, { type: i3.MatDialogRef }, { type: i13.QMSCKEditorRelation, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }] });
//# sourceMappingURL=data:application/json;base64, 