import { ChangeDetectionStrategy, Component, HostBinding, Input, NgModule, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MomentModule } from 'ngx-moment';
import { TranslateModule } from '@ngx-translate/core';
import { BaseDirective } from '../../../base.directive';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "ngx-moment";
import * as i3 from "@ngx-translate/core";
const _c0 = function (a0) { return { days: a0 }; };
function EuiDateTagComponent_span_0_div_20_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, "eui.XDAYSAGO", i0.ɵɵpureFunction1(4, _c0, ctx_r3.mathAbsDays(ctx_r3.daysLeftValue))));
} }
function EuiDateTagComponent_span_0_div_20_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "eui.ONEDAYAGO"));
} }
function EuiDateTagComponent_span_0_div_20_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "eui.TODAY"));
} }
function EuiDateTagComponent_span_0_div_20_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, "eui.INONEDAY"), "");
} }
function EuiDateTagComponent_span_0_div_20_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r7 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, "eui.INXDAYS", i0.ɵɵpureFunction1(4, _c0, ctx_r7.daysLeftValue)));
} }
function EuiDateTagComponent_span_0_div_20_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵtemplate(1, EuiDateTagComponent_span_0_div_20_ng_container_1_Template, 3, 6, "ng-container", 8);
    i0.ɵɵtemplate(2, EuiDateTagComponent_span_0_div_20_ng_container_2_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(3, EuiDateTagComponent_span_0_div_20_ng_container_3_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(4, EuiDateTagComponent_span_0_div_20_ng_container_4_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(5, EuiDateTagComponent_span_0_div_20_ng_container_5_Template, 3, 6, "ng-container", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.daysLeftValue < -1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.daysLeftValue === -1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.daysLeftValue === 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.daysLeftValue === 1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.daysLeftValue > 1);
} }
function EuiDateTagComponent_span_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 1);
    i0.ɵɵpipe(1, "amDateFormat");
    i0.ɵɵpipe(2, "amLocal");
    i0.ɵɵpipe(3, "amDateFormat");
    i0.ɵɵpipe(4, "amLocal");
    i0.ɵɵpipe(5, "amDateFormat");
    i0.ɵɵpipe(6, "amLocal");
    i0.ɵɵelementStart(7, "div", 2);
    i0.ɵɵelementStart(8, "div", 3);
    i0.ɵɵtext(9);
    i0.ɵɵpipe(10, "amDateFormat");
    i0.ɵɵpipe(11, "amLocal");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "div", 4);
    i0.ɵɵtext(13);
    i0.ɵɵpipe(14, "amDateFormat");
    i0.ɵɵpipe(15, "amLocal");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(16, "div", 5);
    i0.ɵɵtext(17);
    i0.ɵɵpipe(18, "amDateFormat");
    i0.ɵɵpipe(19, "amLocal");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(20, EuiDateTagComponent_span_0_div_20_Template, 6, 5, "div", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵattributeInterpolate4("aria-label", "", i0.ɵɵpipeBind2(1, 10, i0.ɵɵpipeBind1(2, 13, ctx_r0.date), "DD"), " ", i0.ɵɵpipeBind2(3, 15, i0.ɵɵpipeBind1(4, 18, ctx_r0.date), "MMM"), " ", i0.ɵɵpipeBind2(5, 20, i0.ɵɵpipeBind1(6, 23, ctx_r0.date), "YYYY"), " ", ctx_r0.daysLeftValue, "");
    i0.ɵɵproperty("tabindex", ctx_r0.tabindex);
    i0.ɵɵadvance(7);
    i0.ɵɵattribute("data-e2e", ctx_r0.e2eAttr);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(10, 25, i0.ɵɵpipeBind1(11, 28, ctx_r0.date), "DD"));
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(14, 30, i0.ɵɵpipeBind1(15, 33, ctx_r0.date), "MMM"));
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(18, 35, i0.ɵɵpipeBind1(19, 38, ctx_r0.date), "YYYY"));
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r0.isDisplayDaysLeft);
} }
function EuiDateTagComponent_span_1_div_7_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r9 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, "eui.XDAYSAGO", i0.ɵɵpureFunction1(4, _c0, ctx_r9.mathAbsDays(ctx_r9.daysLeftValue))));
} }
function EuiDateTagComponent_span_1_div_7_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "eui.ONEDAYAGO"));
} }
function EuiDateTagComponent_span_1_div_7_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "eui.TODAY"));
} }
function EuiDateTagComponent_span_1_div_7_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 1, "eui.INONEDAY"), "");
} }
function EuiDateTagComponent_span_1_div_7_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r13 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(2, 1, "eui.INXDAYS", i0.ɵɵpureFunction1(4, _c0, ctx_r13.daysLeftValue)));
} }
function EuiDateTagComponent_span_1_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵtemplate(1, EuiDateTagComponent_span_1_div_7_ng_container_1_Template, 3, 6, "ng-container", 8);
    i0.ɵɵtemplate(2, EuiDateTagComponent_span_1_div_7_ng_container_2_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(3, EuiDateTagComponent_span_1_div_7_ng_container_3_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(4, EuiDateTagComponent_span_1_div_7_ng_container_4_Template, 3, 3, "ng-container", 8);
    i0.ɵɵtemplate(5, EuiDateTagComponent_span_1_div_7_ng_container_5_Template, 3, 6, "ng-container", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r8 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.daysLeftValue < -1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.daysLeftValue === -1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.daysLeftValue === 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.daysLeftValue === 1);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r8.daysLeftValue > 1);
} }
function EuiDateTagComponent_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 1);
    i0.ɵɵpipe(1, "amDateFormat");
    i0.ɵɵpipe(2, "amLocal");
    i0.ɵɵelementStart(3, "div", 2);
    i0.ɵɵtext(4);
    i0.ɵɵpipe(5, "amDateFormat");
    i0.ɵɵpipe(6, "amLocal");
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(7, EuiDateTagComponent_span_1_div_7_Template, 6, 5, "div", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵattributeInterpolate2("aria-label", "", i0.ɵɵpipeBind2(1, 6, i0.ɵɵpipeBind1(2, 9, ctx_r1.date), ctx_r1.dateFormat), " ", ctx_r1.daysLeftValue, "");
    i0.ɵɵproperty("tabindex", ctx_r1.tabindex);
    i0.ɵɵadvance(3);
    i0.ɵɵattribute("data-e2e", ctx_r1.e2eAttr);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(5, 11, i0.ɵɵpipeBind1(6, 14, ctx_r1.date), ctx_r1.dateFormat), " ");
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r1.isDisplayDaysLeft);
} }
export class EuiDateTagComponent extends BaseDirective {
    constructor() {
        super();
        this.date = new Date();
        this.dateFormat = 'DD/MM/YYYY';
        this.isVerticalLayout = true;
        this.isHandleOverdue = false;
        this.isDisplayDaysLeft = false;
        this.isMuted = false;
        this.isAgnostic = false;
        this.tabindex = 0;
        this.stateClass = '';
    }
    get cssClasses() {
        return this.getCssClasses();
    }
    getCssClasses() {
        let classes = [
            super.getCssClasses('eui-date-tag'),
        ];
        if (this.isMuted || this.isAgnostic) {
            this.isVerticalLayout = false;
        }
        if (this.isVerticalLayout) {
            classes.push('eui-date-tag--vertical');
            if (this.isHandleOverdue) {
                classes.push('eui-date-tag--vertical--' + this._getOverdueState());
            }
        }
        else {
            if (this.isHandleOverdue) {
                classes.push('eui-date-tag--' + this._getOverdueState());
            }
            if (this.isMuted) {
                classes.push('eui-date-tag--muted');
            }
            if (this.isAgnostic) {
                classes.push('eui-date-tag--agnostic');
            }
        }
        return classes.join(' ').trim();
    }
    mathAbsDays(diffDays) {
        return Math.abs(diffDays).toString();
    }
    get daysLeftValue() {
        return this.diffDays(new Date(), this.date);
    }
    diffDays(dateStart, dateEnd) {
        return Math.round((dateEnd.getTime() - dateStart.getTime()) / 1000 / 60 / 60 / 24);
    }
    _getOverdueState() {
        const now = new Date();
        if (this.date.toDateString() === now.toDateString()) {
            return 'warning';
        }
        else if (now > this.date) {
            return 'danger';
        }
        else {
            return 'primary';
        }
    }
}
/** @nocollapse */ EuiDateTagComponent.ɵfac = function EuiDateTagComponent_Factory(t) { return new (t || EuiDateTagComponent)(); };
/** @nocollapse */ EuiDateTagComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiDateTagComponent, selectors: [["eui-date-tag"]], hostVars: 2, hostBindings: function EuiDateTagComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassMap(ctx.cssClasses);
    } }, inputs: { date: "date", dateFormat: "dateFormat", isVerticalLayout: "isVerticalLayout", isHandleOverdue: "isHandleOverdue", isDisplayDaysLeft: "isDisplayDaysLeft", isMuted: "isMuted", isAgnostic: "isAgnostic", tabindex: "tabindex" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 2, consts: [["class", "eui-date-tag", 3, "tabindex", 4, "ngIf"], [1, "eui-date-tag", 3, "tabindex"], [1, "eui-date-tag__label"], [1, "eui-date-tag__d"], [1, "eui-date-tag__m"], [1, "eui-date-tag__y"], ["class", "eui-date-tag__sub-label", 4, "ngIf"], [1, "eui-date-tag__sub-label"], [4, "ngIf"]], template: function EuiDateTagComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, EuiDateTagComponent_span_0_Template, 21, 40, "span", 0);
        i0.ɵɵtemplate(1, EuiDateTagComponent_span_1_Template, 8, 16, "span", 0);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", ctx.isVerticalLayout);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.isVerticalLayout);
    } }, directives: [i1.NgIf], pipes: [i2.DateFormatPipe, i2.LocalTimePipe, i3.TranslatePipe], styles: [".eui-t-compact .eui-date-tag .eui-date-tag_label{max-width:6rem}.eui-date-tag__label{background-color:var(--eui-color-white);box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);font-style:normal;font-weight:700;justify-content:center;padding:var(--eui-spacing-s);text-align:center;width:7rem}.eui-date-tag__sub-label{font-size:var(--eui-font-size-xs);font-style:italic;margin-top:var(--eui-spacing-xs);text-align:center}.eui-date-tag--vertical{background:var(--eui-color-grey-lighter);border-bottom:var(--eui-spacing-2xs) solid var(--eui-color-accent-dark)}.eui-date-tag--vertical .eui-date-tag__d{font-size:var(--eui-font-size-l);font-weight:400}.eui-date-tag--vertical .eui-date-tag__m{font-size:var(--eui-font-size-s);font-style:normal;font-weight:700;text-transform:uppercase}.eui-date-tag--vertical .eui-date-tag__y{font-size:var(--eui-font-size-s)}.eui-date-tag--tiny{padding:var(--eui-spacing-xs)}.eui-date-tag--big{padding:var(--eui-spacing)}.eui-date-tag--primary{color:var(--eui-color-primary-dark)}.eui-date-tag--info{color:var(--eui-color-info-dark)}.eui-date-tag--success{color:var(--eui-color-success-dark)}.eui-date-tag--warning{color:var(--eui-color-warning-darker)}.eui-date-tag--danger{color:var(--eui-color-danger-dark)}.eui-date-tag--vertical--primary{background:var(--eui-color-primary-dark);border-bottom-color:var(--eui-color-primary-darkester);color:var(--eui-color-white)}.eui-date-tag--vertical--info{background:var(--eui-color-info-dark);border-bottom-color:var(--eui-color-info-darkester);color:var(--eui-color-white)}.eui-date-tag--vertical--success{background:var(--eui-color-success-dark);border-bottom-color:var(--eui-color-success-darkester);color:var(--eui-color-white)}.eui-date-tag--vertical--warning{background:var(--eui-color-warning-dark);border-bottom-color:var(--eui-color-warning-darkester);color:var(--eui-color-white)}.eui-date-tag--vertical--danger{background:var(--eui-color-danger-dark);border-bottom-color:var(--eui-color-danger-darkester);color:var(--eui-color-white)}.eui-date-tag--muted .eui-date-tag__label{box-shadow:none;font-style:normal;font-weight:400;margin-bottom:0}.eui-date-tag--agnostic{background-color:initial!important;box-shadow:none;display:inline-block;font-style:normal;font-weight:400;padding:0;text-align:inherit;white-space:nowrap;width:auto!important}"], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiDateTagComponent, [{
        type: Component,
        args: [{
                selector: 'eui-date-tag',
                templateUrl: './eui-date-tag.component.html',
                styleUrls: ['./styles/_index.scss'],
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
            }]
    }], function () { return []; }, { cssClasses: [{
            type: HostBinding,
            args: ['class']
        }], date: [{
            type: Input
        }], dateFormat: [{
            type: Input
        }], isVerticalLayout: [{
            type: Input
        }], isHandleOverdue: [{
            type: Input
        }], isDisplayDaysLeft: [{
            type: Input
        }], isMuted: [{
            type: Input
        }], isAgnostic: [{
            type: Input
        }], tabindex: [{
            type: Input
        }] }); })();
export class EuiDateTagComponentModule {
}
/** @nocollapse */ EuiDateTagComponentModule.ɵmod = i0.ɵɵdefineNgModule({ type: EuiDateTagComponentModule });
/** @nocollapse */ EuiDateTagComponentModule.ɵinj = i0.ɵɵdefineInjector({ factory: function EuiDateTagComponentModule_Factory(t) { return new (t || EuiDateTagComponentModule)(); }, imports: [[CommonModule, MomentModule, TranslateModule]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EuiDateTagComponentModule, { declarations: [EuiDateTagComponent], imports: [CommonModule, MomentModule, TranslateModule], exports: [EuiDateTagComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiDateTagComponentModule, [{
        type: NgModule,
        args: [{
                imports: [CommonModule, MomentModule, TranslateModule],
                exports: [EuiDateTagComponent],
                declarations: [EuiDateTagComponent]
            }]
    }], null, null); })();
//# sourceMappingURL=data:application/json;base64, 