import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import { DATE_TIME_FORMAT, K8sUtilService, } from '../../../../../core/public-api';
import { MESSAGE_TYPE_MAP, dateValueOf, } from '../../utils';
import * as i0 from "@angular/core";
import * as i1 from "../../../../../core/public-api";
function NotificationListComponent_ng_container_0_aui_tag_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "aui-tag", 10);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const tagOption_r3 = ctx.ngIf;
    i0.ɵɵproperty("color", (tagOption_r3 == null ? null : tagOption_r3.color) || "")("type", tagOption_r3 == null ? null : tagOption_r3.type);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 3, tagOption_r3 == null ? null : tagOption_r3.title), " ");
} }
function NotificationListComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "aui-accordion", 1)(2, "aui-accordion-item", 2);
    i0.ɵɵlistener("expandedChange", function NotificationListComponent_ng_container_0_Template_aui_accordion_item_expandedChange_2_listener($event) { const restoredCtx = i0.ɵɵrestoreView(_r5); const item_r1 = restoredCtx.$implicit; const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.expandedChange($event, item_r1)); });
    i0.ɵɵelementStart(3, "div", 3)(4, "div", 4)(5, "div", 5);
    i0.ɵɵtemplate(6, NotificationListComponent_ng_container_0_aui_tag_6_Template, 3, 5, "aui-tag", 6);
    i0.ɵɵpipe(7, "pure");
    i0.ɵɵelementStart(8, "span", 7);
    i0.ɵɵtext(9);
    i0.ɵɵpipe(10, "aclRelativeTime");
    i0.ɵɵpipe(11, "aclCreationTimestamp");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(12, "span", 8);
    i0.ɵɵtext(13);
    i0.ɵɵpipe(14, "aclFieldNotAvailable");
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(15, "div", 9);
    i0.ɵɵtext(16);
    i0.ɵɵpipe(17, "aclFieldNotAvailable");
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r1 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("background", false);
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("expand", item_r1.expanded);
    i0.ɵɵproperty("background", false);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind2(7, 8, item_r1, ctx_r0.getTagOption));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(10, 11, i0.ɵɵpipeBind1(11, 13, item_r1)));
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(14, 15, item_r1.spec.subject), " ");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(17, 17, item_r1.spec.content), " ");
} }
dayjs.extend(utc);
export class NotificationListComponent {
    constructor(k8sUtil) {
        this.k8sUtil = k8sUtil;
        this.getTagOption = (value) => {
            const key = this.k8sUtil.getLabel(value, 'type');
            return MESSAGE_TYPE_MAP[key];
        };
    }
    trackBy(_index, res) {
        return res.metadata.uid;
    }
    expandedChange(expanded, item) {
        item.expanded = expanded;
    }
    expired(item) {
        if (!item.spec.expiredTimestamp) {
            return true;
        }
        return dateValueOf(item.spec.expiredTimestamp) < Date.now();
    }
    formatUtcStr(utcStr) {
        return dayjs.utc(utcStr).local().format(DATE_TIME_FORMAT);
    }
}
NotificationListComponent.ɵfac = function NotificationListComponent_Factory(t) { return new (t || NotificationListComponent)(i0.ɵɵdirectiveInject(i1.K8sUtilService)); };
NotificationListComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NotificationListComponent, selectors: [["acl-notification-list"]], inputs: { list: "list" }, decls: 1, vars: 1, consts: [[4, "ngFor", "ngForOf"], [1, "notify", 3, "background"], [3, "background", "expandedChange"], ["auiAccordionItemHeader", ""], [1, "notify_header"], [1, "notify_header_title"], ["size", "small", 3, "color", "type", 4, "ngIf"], [1, "notify_header_text"], [1, "notify_name"], [1, "notify_content"], ["size", "small", 3, "color", "type"]], template: function NotificationListComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, NotificationListComponent_ng_container_0_Template, 18, 19, "ng-container", 0);
    } if (rf & 2) {
        i0.ɵɵproperty("ngForOf", ctx.list);
    } }, styles: [".notify_header[_ngcontent-%COMP%]{display:flex;flex-direction:column}.notify_header_title[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;padding-left:6px}.notify_header_text[_ngcontent-%COMP%]{color:#acacac;font-size:12px}.notify_name[_ngcontent-%COMP%]{padding:9px 8px 0;color:rgb(var(--aui-color-main-text));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.notify_content[_ngcontent-%COMP%]{background-color:rgb(var(--aui-color-n-9));padding:0 24px;color:rgb(var(--aui-color-secondary-text))}.nodata[_ngcontent-%COMP%]{width:100%;height:200px;display:flex;align-items:center;justify-content:center;color:rgb(var(--aui-color-help-text))}[_nghost-%COMP%]     .aui-tag{align-items:center}[_nghost-%COMP%]     .aui-accordion-item__expand-button{margin-top:5px}[_nghost-%COMP%]     .aui-accordion-item__expand-button:first-child{margin-right:0}[_nghost-%COMP%]     .aui-accordion-item{border:none;padding:0 0 20px}[_nghost-%COMP%]     aui-accordion{display:block;border-bottom:1px solid rgb(var(--aui-color-n-8))}[_nghost-%COMP%]     .aui-accordion-item__header{align-items:flex-start}[_nghost-%COMP%]     .aui-accordion-item__header-content{flex:1}"], changeDetection: 0 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationListComponent, [{
        type: Component,
        args: [{ selector: 'acl-notification-list', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngFor=\"let item of list\">\n  <aui-accordion\n    class=\"notify\"\n    [background]=\"false\"\n  >\n    <aui-accordion-item\n      [background]=\"false\"\n      [class.expand]=\"item.expanded\"\n      (expandedChange)=\"expandedChange($event, item)\"\n    >\n      <div auiAccordionItemHeader>\n        <div class=\"notify_header\">\n          <div class=\"notify_header_title\">\n            <aui-tag\n              size=\"small\"\n              *ngIf=\"item | pure: getTagOption as tagOption\"\n              [color]=\"tagOption?.color || ''\"\n              [type]=\"tagOption?.type\"\n            >\n              {{ tagOption?.title | translate }}\n            </aui-tag>\n            <span class=\"notify_header_text\">{{\n              item | aclCreationTimestamp | aclRelativeTime\n            }}</span>\n          </div>\n          <span class=\"notify_name\">\n            {{ item.spec.subject | aclFieldNotAvailable }}\n          </span>\n        </div>\n      </div>\n      <div class=\"notify_content\">\n        {{ item.spec.content | aclFieldNotAvailable }}\n      </div>\n    </aui-accordion-item>\n  </aui-accordion>\n</ng-container>\n", styles: [".notify_header{display:flex;flex-direction:column}.notify_header_title{display:flex;justify-content:space-between;align-items:center;padding-left:6px}.notify_header_text{color:#acacac;font-size:12px}.notify_name{padding:9px 8px 0;color:rgb(var(--aui-color-main-text));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.notify_content{background-color:rgb(var(--aui-color-n-9));padding:0 24px;color:rgb(var(--aui-color-secondary-text))}.nodata{width:100%;height:200px;display:flex;align-items:center;justify-content:center;color:rgb(var(--aui-color-help-text))}:host ::ng-deep .aui-tag{align-items:center}:host ::ng-deep .aui-accordion-item__expand-button{margin-top:5px}:host ::ng-deep .aui-accordion-item__expand-button:first-child{margin-right:0}:host ::ng-deep .aui-accordion-item{border:none;padding:0 0 20px}:host ::ng-deep aui-accordion{display:block;border-bottom:1px solid rgb(var(--aui-color-n-8))}:host ::ng-deep .aui-accordion-item__header{align-items:flex-start}:host ::ng-deep .aui-accordion-item__header-content{flex:1}\n"] }]
    }], function () { return [{ type: i1.K8sUtilService }]; }, { list: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 