import cloneDeep from 'lodash-es/cloneDeep';
import { Component, EventEmitter, Input, Output, ViewChild, } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "./../../../ui-kit/snack-bar/snack-bar.service";
import * as i2 from "../checkpoints-policy-questions/checkpoints-policy-questions.component";
import * as i3 from "../../checkpoint-floating-bar/checkpoint-floating-bar.component";
export class CheckpointsPolicyContainerComponent {
    constructor(snackbarService) {
        this.snackbarService = snackbarService;
        this.animation = true;
        this.closeCheckPoint = new EventEmitter();
        this.saveCheckPoint = new EventEmitter();
        this.requiredPoint = 0;
        this.checkpointData = [];
    }
    ngOnInit() {
        this.checkpointData = cloneDeep(this.checkpointData);
        if (this.checkpointData.length === 0) {
            this.checkpointData = [
                {
                    ranswer: '',
                    question: '',
                    answers: ['', ''],
                },
            ];
        }
        setTimeout(() => {
            this.animation = false;
        }, 500);
        if (this.requiredPoint === 0) {
            this.requiredPoint = 1;
        }
    }
    next() {
        this.CheckpointsPolicyQuestionsComponent.saveCheckPoint();
    }
    saveQuestions(event) {
        this.checkpointData = event;
        this.checkpointData.forEach((element) => {
            if (element?._id) {
                delete element._id;
            }
        });
        if (this.requiredPoint > this.checkpointData.length) {
            this.snackbarService.show(`The points required to attest this policy cannot exceed ${this.checkpointData.length}.`);
        }
        else {
            if (this.requiredPoint < 1) {
                this.snackbarService.show(`The points required to attest this policy cannot be 0`);
            }
            else {
                this.saveCheckPoint.emit({
                    requiredPoint: this.requiredPoint,
                    checkpointDetails: this.checkpointData,
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckpointsPolicyContainerComponent, deps: [{ token: i1.SnackBarService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CheckpointsPolicyContainerComponent, selector: "app-checkpoints-policy-container", inputs: { requiredPoint: "requiredPoint", checkpointData: "checkpointData" }, outputs: { closeCheckPoint: "closeCheckPoint", saveCheckPoint: "saveCheckPoint" }, viewQueries: [{ propertyName: "CheckpointsPolicyQuestionsComponent", first: true, predicate: ["checkpoint"], descendants: true }], ngImport: i0, template: "<!-- <p>checkpoints works!</p> -->\n<div class=\"checkpoints\" [class.animate]=\"animation\">\n  <div\n    class=\"checkpoints-head vx-d-flex vx-align-center vx-justify-between vx-pl-4 vx-pr-4\"\n  >\n    <div class=\"vx-fs-14 vx-fw-500 vx-label-txt\">Add Questions</div>\n  </div>\n  <div class=\"checkpoints-body\">\n    <div class=\"checkpoints-body-inner vx-mb-4\">\n      <div class=\"checkpoints-body-inside\">\n        <!-- <app-checkpoints-list></app-checkpoints-list> -->\n        <app-checkpoints-policy-questions\n          [(requiredPoint)]=\"requiredPoint\"\n          (changeMax)=\"requiredPoint = $event\"\n          #checkpoint\n          [checkpointDetails]=\"checkpointData\"\n          (saveValidQuestions)=\"saveQuestions($event)\"\n        ></app-checkpoints-policy-questions>\n      </div>\n    </div>\n\n    <div class=\"checkpoints-footer\">\n      <app-checkpoint-floating-bar\n        [isPolicyCheckpoint]=\"true\"\n        (closeList)=\"closeCheckPoint.emit()\"\n        [pluralText]=\"'Questions selected'\"\n        [singularText]=\"'Question selected'\"\n        (saveList)=\"next()\"\n        [(requiredPoint)]=\"requiredPoint\"\n        [count]=\"checkpointData?.length\"\n      ></app-checkpoint-floating-bar>\n    </div>\n  </div>\n</div>\n", styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";@import\"https://cdn.v-comply.com/design-system/css/display/display.css\";@import\"https://cdn.v-comply.com/design-system/css/alignment/alignment.css\";@import\"https://cdn.v-comply.com/design-system/css/text/text.css\";@import\"https://cdn.v-comply.com/design-system/css/color/color.css\";@import\"https://cdn.v-comply.com/design-system/css/width/width.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-top.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-bottom.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-left.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-right.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-top.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-bottom.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-left.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-right.css\";.checkpoints{background:#fff;position:fixed;inset:0 500px 0 0}.checkpoints:before{background:#1e5dd3;content:\"\";position:absolute;top:0;left:0;right:0;width:100%;height:3px}.checkpoints.animate{animation:animate-right .2s cubic-bezier(.25,.46,.45,.94) both;z-index:-1}.checkpoints-head{background:#fbfbfb;height:2.75rem;border:1px solid #f1f1f1;border-right:none}.checkpoints-body{padding:60px 156px;padding:2rem;height:calc(100vh - 2.75rem)}.checkpoints-body-inner{height:calc(100vh - 10.875rem);overflow:hidden;overflow-y:auto}.checkpoints-body-inner::-webkit-scrollbar-track{background-color:transparent;position:absolute}.checkpoints-body-inner::-webkit-scrollbar{width:3px;height:3px;background-color:transparent;position:absolute}.checkpoints-body-inner::-webkit-scrollbar-thumb{border-radius:3px;background-color:#dbdbdb;position:absolute}.checkpoints-body-inside{width:40rem;margin:0 auto}.checkpoints-footer{display:block}@keyframes animate-right{0%{transform:translate(100%)}to{transform:translate(0)}}\n"], dependencies: [{ kind: "component", type: i2.CheckpointsPolicyQuestionsComponent, selector: "app-checkpoints-policy-questions", inputs: ["requiredPoint", "checkpointDetails"], outputs: ["changeMax", "requiredPointChange", "saveValidQuestions"] }, { kind: "component", type: i3.CheckpointFloatingBarComponent, selector: "app-checkpoint-floating-bar", inputs: ["count", "pluralText", "singularText", "requiredPoint", "isPolicyCheckpoint"], outputs: ["closeList", "saveList", "requiredPointChange"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CheckpointsPolicyContainerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-checkpoints-policy-container', template: "<!-- <p>checkpoints works!</p> -->\n<div class=\"checkpoints\" [class.animate]=\"animation\">\n  <div\n    class=\"checkpoints-head vx-d-flex vx-align-center vx-justify-between vx-pl-4 vx-pr-4\"\n  >\n    <div class=\"vx-fs-14 vx-fw-500 vx-label-txt\">Add Questions</div>\n  </div>\n  <div class=\"checkpoints-body\">\n    <div class=\"checkpoints-body-inner vx-mb-4\">\n      <div class=\"checkpoints-body-inside\">\n        <!-- <app-checkpoints-list></app-checkpoints-list> -->\n        <app-checkpoints-policy-questions\n          [(requiredPoint)]=\"requiredPoint\"\n          (changeMax)=\"requiredPoint = $event\"\n          #checkpoint\n          [checkpointDetails]=\"checkpointData\"\n          (saveValidQuestions)=\"saveQuestions($event)\"\n        ></app-checkpoints-policy-questions>\n      </div>\n    </div>\n\n    <div class=\"checkpoints-footer\">\n      <app-checkpoint-floating-bar\n        [isPolicyCheckpoint]=\"true\"\n        (closeList)=\"closeCheckPoint.emit()\"\n        [pluralText]=\"'Questions selected'\"\n        [singularText]=\"'Question selected'\"\n        (saveList)=\"next()\"\n        [(requiredPoint)]=\"requiredPoint\"\n        [count]=\"checkpointData?.length\"\n      ></app-checkpoint-floating-bar>\n    </div>\n  </div>\n</div>\n", styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";@import\"https://cdn.v-comply.com/design-system/css/display/display.css\";@import\"https://cdn.v-comply.com/design-system/css/alignment/alignment.css\";@import\"https://cdn.v-comply.com/design-system/css/text/text.css\";@import\"https://cdn.v-comply.com/design-system/css/color/color.css\";@import\"https://cdn.v-comply.com/design-system/css/width/width.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-top.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-bottom.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-left.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin-right.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-top.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-bottom.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-left.css\";@import\"https://cdn.v-comply.com/design-system/css/padding/padding-right.css\";.checkpoints{background:#fff;position:fixed;inset:0 500px 0 0}.checkpoints:before{background:#1e5dd3;content:\"\";position:absolute;top:0;left:0;right:0;width:100%;height:3px}.checkpoints.animate{animation:animate-right .2s cubic-bezier(.25,.46,.45,.94) both;z-index:-1}.checkpoints-head{background:#fbfbfb;height:2.75rem;border:1px solid #f1f1f1;border-right:none}.checkpoints-body{padding:60px 156px;padding:2rem;height:calc(100vh - 2.75rem)}.checkpoints-body-inner{height:calc(100vh - 10.875rem);overflow:hidden;overflow-y:auto}.checkpoints-body-inner::-webkit-scrollbar-track{background-color:transparent;position:absolute}.checkpoints-body-inner::-webkit-scrollbar{width:3px;height:3px;background-color:transparent;position:absolute}.checkpoints-body-inner::-webkit-scrollbar-thumb{border-radius:3px;background-color:#dbdbdb;position:absolute}.checkpoints-body-inside{width:40rem;margin:0 auto}.checkpoints-footer{display:block}@keyframes animate-right{0%{transform:translate(100%)}to{transform:translate(0)}}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.SnackBarService }]; }, propDecorators: { closeCheckPoint: [{
                type: Output
            }], saveCheckPoint: [{
                type: Output
            }], CheckpointsPolicyQuestionsComponent: [{
                type: ViewChild,
                args: ['checkpoint', { static: false }]
            }], requiredPoint: [{
                type: Input
            }], checkpointData: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 