import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DEFAULT_TIME } from '../../../constants/time.constants';
import * as i0 from "@angular/core";
import * as i1 from "../frequency.service";
import * as i2 from "@angular/common";
import * as i3 from "../../../formgroup/cs-radio/cs-radio.component";
export class FrequencyOngoingComponent {
    constructor(frequencyService) {
        this.frequencyService = frequencyService;
        this.selectedType = 0; // selected type
        this.selectedOngoingType = 2; // default month selected;
        this.ongoingType = ['Week', 'Month', 'Quarter', 'Every 6 months', 'Annual'];
        this.startDate = Math.floor(Date.now() / 1000);
        this.lifecycleDetails = '0000-00-00~~0';
        this.frequencyDetails = new EventEmitter();
    }
    ngOnInit() {
        this.frequencyInfo = Object.assign(this.frequencyService.frequencyInfo);
        if (this.frequencyData.pattern != '' &&
            parseInt(this.frequencyData.pattern.split('~')[0]) === 10) {
            this.populateFrequency();
        }
        this.getOngoingFrequency();
    }
    populateFrequency() {
        const frequencySelected = this.frequencyData.pattern.split('~');
        this.selectedType = parseInt(frequencySelected[1]);
        this.selectedOngoingType =
            parseInt(frequencySelected[2]) === 0 ? 2 : parseInt(frequencySelected[2]);
    }
    onSelected(event) {
        this.selectedType = Number(event.target.value);
        this.getOngoingFrequency();
    }
    onSelectedOnGoingType(event) {
        this.selectedOngoingType = Number(event.target.value);
        this.getOngoingFrequency();
    }
    getOngoingFrequency() {
        this.frequencyInfo.placeholder = 'You have selected an ongoing frequency.';
        this.frequencyInfo.pattern =
            10 +
                '~' +
                this.selectedType +
                '~' +
                (this.selectedType ? this.selectedOngoingType : 0) +
                '~0';
        this.frequencyInfo.case = 'onGoing';
        this.frequencyInfo.failedAfter = 0;
        this.frequencyInfo.window = 0;
        this.frequencyInfo.timeIn12hr = DEFAULT_TIME;
        this.frequencyInfo.timeIn24Hr =
            this.frequencyService.timeFrom12hTo24h(DEFAULT_TIME);
        this.frequencyInfo.failed_time_utc = 0;
        this.frequencyInfo.reportId = 0;
        this.frequencyDetails.emit(this.frequencyInfo);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FrequencyOngoingComponent, deps: [{ token: i1.FrequencyService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: FrequencyOngoingComponent, selector: "app-frequency-ongoing", inputs: { selectedType: "selectedType", selectedOngoingType: "selectedOngoingType", frequencyData: "frequencyData", startDate: "startDate" }, outputs: { frequencyDetails: "frequencyDetails" }, ngImport: i0, template: "<div class=\"frequency-ongoing\">\n    <div class=\"vx-fs-11 vx-fw-500 vx-label-txt vx-tt-uppercase vx-mb-1\">DUE DATE FREQUENCY:</div>\n    <div class=\"frequency-ongoing-item first vx-p-3 vx-d-flex vx-align-center\">\n        <app-cs-radio \n        id=\"ongoing-1\" \n        [value]=\"0\" \n        [checked]=\"selectedType === 0\" \n        (checkedEvent)=\"onSelected($event)\"\n        >\n            <div class=\"vx-fs-12 vx-label-txt\">Do not send reminders</div>\n        </app-cs-radio>\n    </div>\n    <div class=\"frequency-ongoing-item last vx-p-3 vx-d-flex vx-align-center\">\n        <div class=\"vx-d-block\">\n            <app-cs-radio \n                id=\"ongoing-2\" \n                [value]=\"1\" \n                [checked]=\"selectedType === 1\" \n                (checkedEvent)=\"onSelected($event)\">\n                <div class=\"vx-fs-12 vx-label-txt\">Remind the assignee at the start of{{selectedType=== 1 ? ':' :''}}</div>\n            </app-cs-radio>\n\n            <div class=\"sub-radio vx-d-flex vx-mt-4 vx-mb-2\" *ngIf=\"selectedType === 1\">\n                <app-cs-radio \n                    *ngFor=\"let data of ongoingType; let i = index\" \n                    [value]=\"i + 1\" \n                    [checked]=\"selectedOngoingType == i + 1\" \n                    [name]=\"'remind'\"\n                    (checkedEvent)=\"onSelectedOnGoingType($event)\"\n                    >\n                    <div class=\"vx-fs-12 vx-label-txt\">{{data}}</div>\n                </app-cs-radio>\n                <!-- <app-cs-radio>\n                    <div class=\"vx-fs-12 vx-label-txt\">Every 6 month</div>\n                </app-cs-radio>\n                <app-cs-radio>\n                    <div class=\"vx-fs-12 vx-label-txt\">Year</div>\n                </app-cs-radio> -->\n            </div>\n        </div>\n    </div>\n</div>", styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";@import\"https://cdn.v-comply.com/design-system/css/mixin/mixin.css\";@import\"https://cdn.v-comply.com/design-system/css/header/header.css\";@import\"https://cdn.v-comply.com/design-system/css/display/display.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin.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-top.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/alignment/alignment.css\";@import\"https://cdn.v-comply.com/design-system/css/text/text.css\";@import\"https://cdn.v-comply.com/design-system/css/button/button.css\";@import\"https://cdn.v-comply.com/design-system/css/color/color.css\";@import\"https://cdn.v-comply.com/design-system/css/popover/popover.css\";@import\"https://cdn.v-comply.com/design-system/css/width/width.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\";::ng-deep .frequency-ongoing{position:relative}::ng-deep .frequency-ongoing-item{border:1px solid #f1f1f1}::ng-deep .frequency-ongoing-item.first{border-radius:.25rem .25rem 0 0}::ng-deep .frequency-ongoing-item.last{border-radius:0 0 .25rem .25rem;border-top:none}::ng-deep .frequency-ongoing-item app-cs-radio{display:flex}::ng-deep .frequency-ongoing-item .sub-radio{padding-left:1.625rem}::ng-deep .frequency-ongoing-item .sub-radio app-cs-radio{display:flex;margin-right:1.75rem}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.CsRadioComponent, selector: "app-cs-radio", inputs: ["disabled", "readonly", "name", "checked", "value", "oneLine"], outputs: ["checkedEvent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FrequencyOngoingComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-frequency-ongoing', template: "<div class=\"frequency-ongoing\">\n    <div class=\"vx-fs-11 vx-fw-500 vx-label-txt vx-tt-uppercase vx-mb-1\">DUE DATE FREQUENCY:</div>\n    <div class=\"frequency-ongoing-item first vx-p-3 vx-d-flex vx-align-center\">\n        <app-cs-radio \n        id=\"ongoing-1\" \n        [value]=\"0\" \n        [checked]=\"selectedType === 0\" \n        (checkedEvent)=\"onSelected($event)\"\n        >\n            <div class=\"vx-fs-12 vx-label-txt\">Do not send reminders</div>\n        </app-cs-radio>\n    </div>\n    <div class=\"frequency-ongoing-item last vx-p-3 vx-d-flex vx-align-center\">\n        <div class=\"vx-d-block\">\n            <app-cs-radio \n                id=\"ongoing-2\" \n                [value]=\"1\" \n                [checked]=\"selectedType === 1\" \n                (checkedEvent)=\"onSelected($event)\">\n                <div class=\"vx-fs-12 vx-label-txt\">Remind the assignee at the start of{{selectedType=== 1 ? ':' :''}}</div>\n            </app-cs-radio>\n\n            <div class=\"sub-radio vx-d-flex vx-mt-4 vx-mb-2\" *ngIf=\"selectedType === 1\">\n                <app-cs-radio \n                    *ngFor=\"let data of ongoingType; let i = index\" \n                    [value]=\"i + 1\" \n                    [checked]=\"selectedOngoingType == i + 1\" \n                    [name]=\"'remind'\"\n                    (checkedEvent)=\"onSelectedOnGoingType($event)\"\n                    >\n                    <div class=\"vx-fs-12 vx-label-txt\">{{data}}</div>\n                </app-cs-radio>\n                <!-- <app-cs-radio>\n                    <div class=\"vx-fs-12 vx-label-txt\">Every 6 month</div>\n                </app-cs-radio>\n                <app-cs-radio>\n                    <div class=\"vx-fs-12 vx-label-txt\">Year</div>\n                </app-cs-radio> -->\n            </div>\n        </div>\n    </div>\n</div>", styles: ["@import\"https://cdn.v-comply.com/design-system/css/icons/icons.css\";@import\"https://cdn.v-comply.com/design-system/css/mixin/mixin.css\";@import\"https://cdn.v-comply.com/design-system/css/header/header.css\";@import\"https://cdn.v-comply.com/design-system/css/display/display.css\";@import\"https://cdn.v-comply.com/design-system/css/margin/margin.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-top.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/alignment/alignment.css\";@import\"https://cdn.v-comply.com/design-system/css/text/text.css\";@import\"https://cdn.v-comply.com/design-system/css/button/button.css\";@import\"https://cdn.v-comply.com/design-system/css/color/color.css\";@import\"https://cdn.v-comply.com/design-system/css/popover/popover.css\";@import\"https://cdn.v-comply.com/design-system/css/width/width.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\";::ng-deep .frequency-ongoing{position:relative}::ng-deep .frequency-ongoing-item{border:1px solid #f1f1f1}::ng-deep .frequency-ongoing-item.first{border-radius:.25rem .25rem 0 0}::ng-deep .frequency-ongoing-item.last{border-radius:0 0 .25rem .25rem;border-top:none}::ng-deep .frequency-ongoing-item app-cs-radio{display:flex}::ng-deep .frequency-ongoing-item .sub-radio{padding-left:1.625rem}::ng-deep .frequency-ongoing-item .sub-radio app-cs-radio{display:flex;margin-right:1.75rem}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.FrequencyService }]; }, propDecorators: { selectedType: [{
                type: Input
            }], selectedOngoingType: [{
                type: Input
            }], frequencyData: [{
                type: Input
            }], startDate: [{
                type: Input
            }], frequencyDetails: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 