import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Base } from './export-schedules.interface';
import { CronService } from './cron.service';
import * as i0 from "@angular/core";
import * as i1 from "./cron.service";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@angular/common";
import * as i4 from "@angular/forms";
export class CronComponent {
    constructor(cronService) {
        this.cronService = cronService;
        this.emitter = new EventEmitter();
        this.emittedCron = {
            valid: false,
            cron: ''
        };
        this.base = Base.Initial;
        //
    }
    ngOnInit() {
        this.daysOfWeekPosix = this.cronService.daysOfWeekPosix;
        this.daysOfMonth = this.cronService.daysOfMonth;
        this.months = this.cronService.months;
        this.hours = this.cronService.hours;
        this.minutes = this.cronService.minutes;
        this.intervals = this.cronService.intervals;
        this.cronConfig = this.cronService.generateCronConfig(this.cronIn);
        this.base = this.cronService.getBase(this.cronConfig);
    }
    onChangeSelect() {
        this.cronService.clearNextModels(this.base, this.cronConfig);
        this.emittedCron.valid = this.cronService.validateModels(this.base, this.cronConfig);
        this.emittedCron.cron = this.cronService.generateCron(this.cronConfig);
        this.emitter.emit(this.emittedCron);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CronComponent, deps: [{ token: i1.CronService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: CronComponent, selector: "cron", inputs: { cronIn: "cronIn" }, outputs: { emitter: "emitter" }, ngImport: i0, template: "<div class=\"cron-wrap\">\n  <div class=\"form-group smart-cron-job-every\">\n    <label for=\"smart-cron-job-every\" class=\"control-label\" translate>Interval</label>\n    <div>\n      <div class=\"c8y-select-wrapper\">\n        <select\n          class=\"cron-select form-control\"\n          id=\"smart-cron-job-every\"\n          [(ngModel)]=\"base\"\n          required=\"true\"\n          (change)=\"onChangeSelect()\"\n        >\n          <option *ngIf=\"base === 1\" value=\"1\" translate>Select\u2026</option>\n          <option *ngFor=\"let baseInterval of intervals\" [ngValue]=\"baseInterval.value\">\n            {{ baseInterval.label | translate }}\n          </option>\n        </select>\n        <span></span>\n      </div>\n    </div>\n  </div>\n  <div class=\"row\">\n    <div class=\"form-group smart-cron-job-on col-md-6\" *ngIf=\"base == 4\">\n      <label class=\"control-label\" for=\"smart-cron-job-on\" translate>Day</label>\n\n      <div class=\"c8y-select-wrapper\">\n        <select\n          class=\"cron-select form-control day-value\"\n          id=\"smart-cron-job-on\"\n          [(ngModel)]=\"cronConfig.weekday\"\n          (change)=\"onChangeSelect()\"\n        >\n          <option *ngFor=\"let dayOfWeek of daysOfWeekPosix\" [ngValue]=\"dayOfWeek.value\">\n            {{ dayOfWeek.label | translate }}\n          </option>\n        </select>\n        <span></span>\n      </div>\n    </div>\n\n    <div class=\"form-group smart-cron-job-of col-md-6\" *ngIf=\"base == 6\">\n      <label for=\"smart-cron-job-of\" class=\"control-label\" translate>Month</label>\n      <div>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            id=\"smart-cron-job-of\"\n            class=\"cron-select form-control month-value\"\n            [(ngModel)]=\"cronConfig.month\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let month of months\" [ngValue]=\"month.value\">\n              {{ month.label | translate }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n\n    <div class=\"form-group smart-cron-job-on-the col-md-6\" *ngIf=\"base >= 5\">\n      <label for=\"smart-cron-job-on-the\" class=\"control-label\" translate>Day</label>\n      <div>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            id=\"smart-cron-job-on-the\"\n            class=\"cron-select form-control day-of-month-value\"\n            [(ngModel)]=\"cronConfig.day\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let dayOfMonth of daysOfMonth\" [ngValue]=\"dayOfMonth.value\">\n              {{ dayOfMonth.label | translate }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n  </div>\n\n  <div class=\"form-group smart-cron-job-at\" *ngIf=\"base >= 2\">\n    <label for=\"smart-cron-job-at-hour\" class=\"control-label\">\n      <span *ngIf=\"base >= 3\" translate>Time</span>\n      <span *ngIf=\"base < 3\" translate>Minutes</span>\n    </label>\n    <div>\n      <div class=\"form-inline\">\n        <div class=\"c8y-select-wrapper\" *ngIf=\"base >= 3\">\n          <select\n            id=\"smart-cron-job-at-hour\"\n            class=\"cron-select form-control hour-value\"\n            [(ngModel)]=\"cronConfig.hour\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let hour of hours\" [ngValue]=\"hour.value\">\n              {{ hour.value | number: '2.0-0' }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n        <span *ngIf=\"base >= 3\">:</span>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            class=\"cron-select form-control minute-value\"\n            id=\"smart-cron-job-at-minute\"\n            [(ngModel)]=\"cronConfig.minute\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let minute of minutes\" [ngValue]=\"minute.value\">\n              {{ minute.value | number: '2.0-0' }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n  </div>\n</div>\n", dependencies: [{ kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i3.DecimalPipe, name: "number" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: CronComponent, decorators: [{
            type: Component,
            args: [{ selector: 'cron', template: "<div class=\"cron-wrap\">\n  <div class=\"form-group smart-cron-job-every\">\n    <label for=\"smart-cron-job-every\" class=\"control-label\" translate>Interval</label>\n    <div>\n      <div class=\"c8y-select-wrapper\">\n        <select\n          class=\"cron-select form-control\"\n          id=\"smart-cron-job-every\"\n          [(ngModel)]=\"base\"\n          required=\"true\"\n          (change)=\"onChangeSelect()\"\n        >\n          <option *ngIf=\"base === 1\" value=\"1\" translate>Select\u2026</option>\n          <option *ngFor=\"let baseInterval of intervals\" [ngValue]=\"baseInterval.value\">\n            {{ baseInterval.label | translate }}\n          </option>\n        </select>\n        <span></span>\n      </div>\n    </div>\n  </div>\n  <div class=\"row\">\n    <div class=\"form-group smart-cron-job-on col-md-6\" *ngIf=\"base == 4\">\n      <label class=\"control-label\" for=\"smart-cron-job-on\" translate>Day</label>\n\n      <div class=\"c8y-select-wrapper\">\n        <select\n          class=\"cron-select form-control day-value\"\n          id=\"smart-cron-job-on\"\n          [(ngModel)]=\"cronConfig.weekday\"\n          (change)=\"onChangeSelect()\"\n        >\n          <option *ngFor=\"let dayOfWeek of daysOfWeekPosix\" [ngValue]=\"dayOfWeek.value\">\n            {{ dayOfWeek.label | translate }}\n          </option>\n        </select>\n        <span></span>\n      </div>\n    </div>\n\n    <div class=\"form-group smart-cron-job-of col-md-6\" *ngIf=\"base == 6\">\n      <label for=\"smart-cron-job-of\" class=\"control-label\" translate>Month</label>\n      <div>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            id=\"smart-cron-job-of\"\n            class=\"cron-select form-control month-value\"\n            [(ngModel)]=\"cronConfig.month\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let month of months\" [ngValue]=\"month.value\">\n              {{ month.label | translate }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n\n    <div class=\"form-group smart-cron-job-on-the col-md-6\" *ngIf=\"base >= 5\">\n      <label for=\"smart-cron-job-on-the\" class=\"control-label\" translate>Day</label>\n      <div>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            id=\"smart-cron-job-on-the\"\n            class=\"cron-select form-control day-of-month-value\"\n            [(ngModel)]=\"cronConfig.day\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let dayOfMonth of daysOfMonth\" [ngValue]=\"dayOfMonth.value\">\n              {{ dayOfMonth.label | translate }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n  </div>\n\n  <div class=\"form-group smart-cron-job-at\" *ngIf=\"base >= 2\">\n    <label for=\"smart-cron-job-at-hour\" class=\"control-label\">\n      <span *ngIf=\"base >= 3\" translate>Time</span>\n      <span *ngIf=\"base < 3\" translate>Minutes</span>\n    </label>\n    <div>\n      <div class=\"form-inline\">\n        <div class=\"c8y-select-wrapper\" *ngIf=\"base >= 3\">\n          <select\n            id=\"smart-cron-job-at-hour\"\n            class=\"cron-select form-control hour-value\"\n            [(ngModel)]=\"cronConfig.hour\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let hour of hours\" [ngValue]=\"hour.value\">\n              {{ hour.value | number: '2.0-0' }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n        <span *ngIf=\"base >= 3\">:</span>\n        <div class=\"c8y-select-wrapper\">\n          <select\n            class=\"cron-select form-control minute-value\"\n            id=\"smart-cron-job-at-minute\"\n            [(ngModel)]=\"cronConfig.minute\"\n            (change)=\"onChangeSelect()\"\n          >\n            <option *ngFor=\"let minute of minutes\" [ngValue]=\"minute.value\">\n              {{ minute.value | number: '2.0-0' }}\n            </option>\n          </select>\n          <span></span>\n        </div>\n      </div>\n    </div>\n  </div>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.CronService }], propDecorators: { cronIn: [{
                type: Input
            }], emitter: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 