import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, inject, Input, Output } from '@angular/core';
import { ControlContainer, ReactiveFormsModule } from '@angular/forms';
import { CoreModule, gettext } from '@c8y/ngx-components';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components";
import * as i2 from "@angular/common";
import * as i3 from "@angular/forms";
export class DateRangePickerComponent {
    constructor() {
        /**
         * If set to true, the component will be reactive and will emit the updatedDate on every change.
         * Otherwise, the component will use a non emitting variant of a template.
         */
        this.isEmittingDateChange = false;
        /**
         * Determines the display of from and to date picker labels.
         */
        this.showLabel = true;
        this.updatedDate = new EventEmitter();
        this.DATE_FROM = 'dateFrom';
        this.DATE_TO = 'dateTo';
        this.FROM_DATE = gettext('From`date`');
        this.HAS_ERROR = 'has-error';
        this.INVALID_DATE_TIME = 'invalidDateTime';
        this.THIS_DATE_IS_INVALID = gettext('This date is invalid.');
        this.THIS_DATE_IS_AFTER_THE_LAST_ALLOWED_DATE = gettext('This date is after the latest allowed date.');
        this.THIS_DATE_IS_BEFORE_THE_EARLIEST_ALLOWED_DATE = gettext('This date is before the earliest allowed date.');
        this.TO_DATE = gettext('To`date`');
        this.parentContainer = inject(ControlContainer);
    }
    onDateFromChange(dateFrom) {
        this.updatedDate.emit({
            dateFrom
        });
    }
    onDateToChange(dateTo) {
        this.updatedDate.emit({
            dateTo
        });
    }
    get parentFormGroup() {
        return this.parentContainer.control;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DateRangePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: DateRangePickerComponent, isStandalone: true, selector: "c8y-date-range-picker", inputs: { isEmittingDateChange: "isEmittingDateChange", showLabel: "showLabel" }, outputs: { updatedDate: "updatedDate" }, ngImport: i0, template: "<div class=\"d-flex gap-8 a-i-center flex-wrap\">\n  <c8y-form-group\n    [ngClass]=\"[\n      parentFormGroup?.controls.dateFrom.errors ? HAS_ERROR : '',\n      isEmittingDateChange ? 'd-flex a-i-center gap-4 m-b-0' : ''\n    ]\"\n  >\n    <ng-container *ngIf=\"showLabel\">\n      <label\n        [title]=\"FROM_DATE | translate\"\n        [for]=\"DATE_FROM\"\n      >\n        {{ FROM_DATE | translate }}\n      </label>\n    </ng-container>\n    <c8y-date-time-picker\n      id=\"DATE_FROM\"\n      [maxDate]=\"parentFormGroup?.value.dateTo\"\n      [placeholder]=\"FROM_DATE | translate\"\n      [formControl]=\"parentFormGroup?.controls.dateFrom\"\n      [ngClass]=\"parentFormGroup?.controls.dateFrom.errors ? HAS_ERROR : ''\"\n      (ngModelChange)=\"onDateFromChange($event)\"\n    ></c8y-date-time-picker>\n    <c8y-messages\n      class=\"text-nowrap\"\n      [show]=\"parentFormGroup?.controls.dateFrom.errors\"\n    >\n      <c8y-message\n        name=\"dateAfterRangeMax\"\n        [text]=\"THIS_DATE_IS_AFTER_THE_LAST_ALLOWED_DATE | translate\"\n      ></c8y-message>\n      <c8y-message\n        name=\"INVALID_DATE_TIME\"\n        [text]=\"THIS_DATE_IS_INVALID | translate\"\n      ></c8y-message>\n    </c8y-messages>\n  </c8y-form-group>\n  <c8y-form-group\n    [ngClass]=\"[\n      parentFormGroup?.controls.dateTo.errors ? HAS_ERROR : '',\n      isEmittingDateChange ? 'd-flex a-i-center gap-4 m-b-0' : ''\n    ]\"\n  >\n    <ng-container *ngIf=\"showLabel\">\n      <label\n        [title]=\"TO_DATE | translate\"\n        [for]=\"DATE_TO\"\n      >\n        {{ TO_DATE | translate }}\n      </label>\n    </ng-container>\n    <c8y-date-time-picker\n      id=\"DATE_TO\"\n      [minDate]=\"parentFormGroup?.value.dateFrom\"\n      [placeholder]=\"TO_DATE | translate\"\n      [formControl]=\"parentFormGroup?.controls.dateTo\"\n      [ngClass]=\"parentFormGroup?.controls.dateTo.errors ? HAS_ERROR : ''\"\n      (ngModelChange)=\"onDateToChange($event)\"\n    ></c8y-date-time-picker>\n    <c8y-messages [show]=\"parentFormGroup?.controls.dateTo.errors\">\n      <c8y-message\n        name=\"dateBeforeRangeMin\"\n        [text]=\"THIS_DATE_IS_BEFORE_THE_EARLIEST_ALLOWED_DATE | translate\"\n      ></c8y-message>\n      <c8y-message\n        name=\"INVALID_DATE_TIME\"\n        [text]=\"THIS_DATE_IS_INVALID | translate\"\n      ></c8y-message>\n    </c8y-messages>\n  </c8y-form-group>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "component", type: i1.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i1.MessageDirective, selector: "c8y-message", inputs: ["name", "text"] }, { kind: "component", type: i1.MessagesComponent, selector: "c8y-messages", inputs: ["show", "defaults", "helpMessage"] }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: i1.DateTimePickerComponent, selector: "c8y-date-time-picker", inputs: ["minDate", "maxDate", "placeholder", "dateInputFormat", "adaptivePosition", "size", "dateType", "config"], outputs: ["onDateSelected"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }], viewProviders: [
            {
                provide: ControlContainer,
                useFactory: () => inject(ControlContainer, { skipSelf: true })
            }
        ], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DateRangePickerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-date-range-picker', standalone: true, imports: [CoreModule, CommonModule, ReactiveFormsModule], changeDetection: ChangeDetectionStrategy.OnPush, viewProviders: [
                        {
                            provide: ControlContainer,
                            useFactory: () => inject(ControlContainer, { skipSelf: true })
                        }
                    ], template: "<div class=\"d-flex gap-8 a-i-center flex-wrap\">\n  <c8y-form-group\n    [ngClass]=\"[\n      parentFormGroup?.controls.dateFrom.errors ? HAS_ERROR : '',\n      isEmittingDateChange ? 'd-flex a-i-center gap-4 m-b-0' : ''\n    ]\"\n  >\n    <ng-container *ngIf=\"showLabel\">\n      <label\n        [title]=\"FROM_DATE | translate\"\n        [for]=\"DATE_FROM\"\n      >\n        {{ FROM_DATE | translate }}\n      </label>\n    </ng-container>\n    <c8y-date-time-picker\n      id=\"DATE_FROM\"\n      [maxDate]=\"parentFormGroup?.value.dateTo\"\n      [placeholder]=\"FROM_DATE | translate\"\n      [formControl]=\"parentFormGroup?.controls.dateFrom\"\n      [ngClass]=\"parentFormGroup?.controls.dateFrom.errors ? HAS_ERROR : ''\"\n      (ngModelChange)=\"onDateFromChange($event)\"\n    ></c8y-date-time-picker>\n    <c8y-messages\n      class=\"text-nowrap\"\n      [show]=\"parentFormGroup?.controls.dateFrom.errors\"\n    >\n      <c8y-message\n        name=\"dateAfterRangeMax\"\n        [text]=\"THIS_DATE_IS_AFTER_THE_LAST_ALLOWED_DATE | translate\"\n      ></c8y-message>\n      <c8y-message\n        name=\"INVALID_DATE_TIME\"\n        [text]=\"THIS_DATE_IS_INVALID | translate\"\n      ></c8y-message>\n    </c8y-messages>\n  </c8y-form-group>\n  <c8y-form-group\n    [ngClass]=\"[\n      parentFormGroup?.controls.dateTo.errors ? HAS_ERROR : '',\n      isEmittingDateChange ? 'd-flex a-i-center gap-4 m-b-0' : ''\n    ]\"\n  >\n    <ng-container *ngIf=\"showLabel\">\n      <label\n        [title]=\"TO_DATE | translate\"\n        [for]=\"DATE_TO\"\n      >\n        {{ TO_DATE | translate }}\n      </label>\n    </ng-container>\n    <c8y-date-time-picker\n      id=\"DATE_TO\"\n      [minDate]=\"parentFormGroup?.value.dateFrom\"\n      [placeholder]=\"TO_DATE | translate\"\n      [formControl]=\"parentFormGroup?.controls.dateTo\"\n      [ngClass]=\"parentFormGroup?.controls.dateTo.errors ? HAS_ERROR : ''\"\n      (ngModelChange)=\"onDateToChange($event)\"\n    ></c8y-date-time-picker>\n    <c8y-messages [show]=\"parentFormGroup?.controls.dateTo.errors\">\n      <c8y-message\n        name=\"dateBeforeRangeMin\"\n        [text]=\"THIS_DATE_IS_BEFORE_THE_EARLIEST_ALLOWED_DATE | translate\"\n      ></c8y-message>\n      <c8y-message\n        name=\"INVALID_DATE_TIME\"\n        [text]=\"THIS_DATE_IS_INVALID | translate\"\n      ></c8y-message>\n    </c8y-messages>\n  </c8y-form-group>\n</div>\n" }]
        }], propDecorators: { isEmittingDateChange: [{
                type: Input
            }], showLabel: [{
                type: Input
            }], updatedDate: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 