var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CaseViewEvent } from '../../../../domain';
var EventLogTableComponent = /** @class */ (function () {
    function EventLogTableComponent() {
        this.DRAFT_STATE_ID = '[DRAFT]';
        this.onSelect = new EventEmitter();
        this.onCaseHistory = new EventEmitter();
        this.isPartOfCaseTimeline = false;
    }
    EventLogTableComponent.prototype.ngOnInit = function () {
        this.isPartOfCaseTimeline = this.onCaseHistory.observers.length > 0;
    };
    EventLogTableComponent.prototype.select = function (event) {
        this.selected = event;
        this.onSelect.emit(event);
    };
    EventLogTableComponent.prototype.significantItemExist = function (event) {
        return (event.significant_item &&
            event.significant_item.type === 'DOCUMENT' &&
            event.significant_item.url !== undefined &&
            event.significant_item.description !== undefined);
    };
    EventLogTableComponent.prototype.getSignificantItemUrl = function (event) {
        if (event.significant_item) {
            return event.significant_item.url;
        }
    };
    EventLogTableComponent.prototype.getSignificantItemDesc = function (event) {
        if (event.significant_item) {
            return event.significant_item.description;
        }
    };
    EventLogTableComponent.prototype.caseHistoryClicked = function (eventId) {
        this.onCaseHistory.emit(eventId);
    };
    __decorate([
        Input(),
        __metadata("design:type", Array)
    ], EventLogTableComponent.prototype, "events", void 0);
    __decorate([
        Input(),
        __metadata("design:type", CaseViewEvent)
    ], EventLogTableComponent.prototype, "selected", void 0);
    __decorate([
        Output(),
        __metadata("design:type", Object)
    ], EventLogTableComponent.prototype, "onSelect", void 0);
    __decorate([
        Output(),
        __metadata("design:type", Object)
    ], EventLogTableComponent.prototype, "onCaseHistory", void 0);
    EventLogTableComponent = __decorate([
        Component({
            selector: 'ccd-event-log-table',
            template: "\n    <table class=\"EventLogTable\">\n      <caption><h2 class=\"heading-h2\">History</h2></caption>\n      <thead>\n      <tr>\n        <th><span class=\"text-16\">Event</span></th>\n        <th><span class=\"text-16\">Date</span></th>\n        <th><span class=\"text-16\">Author</span></th>\n      </tr>\n      </thead>\n      <tbody>\n      <tr *ngFor=\"let event of events\" (click)=\"select(event)\" [ngClass]=\"{'EventLogTable-Selected': selected === event}\">\n        <td>\n          <ng-container [ngSwitch]=\"isPartOfCaseTimeline\">\n            <div id=\"case-timeline\" *ngSwitchCase=\"true\">\n              <a (click)=\"caseHistoryClicked(event.id)\"\n                *ngIf=\"event.state_id !== DRAFT_STATE_ID\" class=\"text-16 event-link\">{{event.event_name}}</a>\n            </div>\n            <div *ngSwitchCase=\"false\">\n              <a [routerLink]=\"['./', 'event', event.id, 'history']\"\n                  [target]=\"'_blank'\"\n                  *ngIf=\"event.state_id !== DRAFT_STATE_ID\" class=\"text-16 event-link\">{{event.event_name}}</a>\n            </div>\n          </ng-container>\n          <span *ngIf=\"event.state_id === DRAFT_STATE_ID\">{{event.event_name}}</span>\n          <div class=\"tooltip\" *ngIf=\"significantItemExist(event)\">\n            <a href=\"{{getSignificantItemUrl(event)}}\" target=\"_blank\">\n              <img class=\"doc-img\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABoCAYAAABmOHdtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4yMfEgaZUAAAkoSURBVHhe7d33c5RFHAZw/wCKiF0s2LAwiigq9l5G/UV/UUeFkEAoQqiWoKKI1Dg6YxQQbGmkXQoJIQQiaSShhiQMkgIphCSXkN4buPtcnnDG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GDz8Kdiyie0d3ZBgpjGSc+K6Z2kaqMRHaDVA3xMfDiJW3W5NfeRz7YBP3h45nHoEKWJtK/QDiy0n1udAPx5S3sX3Lt0KzDo59fsAAbIQnri0mhQtdGIDtDqAbJ8mLIhBbi5nFs6eKE0p2B8LAnaCzfNDwdukOQF2OzK3MrB91sXmwMn7A3ARQXLDiI6QMUPzwfLDE76+XMW0ryEn4PDT0l5wNOeDJqDREh6IfAPwdOaz68WXVjglJCD1kTRzSXnNrlCBzhYAvwrnIIliBJG4pI+bzLBJX8+n4MO/yA8ngFy0OKUMPVYBXDp3/m9XaEDHOwBcirHDZWcyn0spmcSp3CqY50xUF4yxsHjVE0z8JYDqmON6AAHe4C8gIYX1jBAn225wPJFdawzBsibVHARgUFyEFIda0QHONgDpK/jcoHlB28e4WoBfKmY7kncUtzVLW/S091XHvHiRtWxRnSAgz7A3ptBcNmLS/a8+VjU/iLg7U5YtvB4bioatzAceHkrb27Bk0osf/7w3i7QAQ76AHtxAyVPlPNWTly6z8ivhDd8d8NLPjvBY1Mq8CZlvClZQXkd8OJDHaAO0DWTvG3gtTkRePqSgwJPmPMSLm5zO3PmDBRW1IPHehGucNuicFC9lyt0gEMtQLr7gyjg1g0uCrCrcoq2t8AOyb9VABcTbl9sA9VrD4QOUPHaA2HZAIk3Fxsx1Q/u8Y4GBsugeVKJ2+FUr3U+dIAmWT7A/5sO0CQdoEk6QJN0gCbpAE0yHSBfYKgaMcMG/YMjHeDfMB2g6iDtHB2gSTpAk3SAJukATdIBmvSvBcj/UUnfGwxWitCcKcNxhQ7QQRmOK1iIql50KFGG4wodoIMyHFfoAB2U4bhCB+igDMcVOkAHZTiu0AFK/md/Bw8XevIIyEqZAAAAAElFTkSuQmCC\"/>\n            </a>\n            <span class=\"tooltiptext doc-tooltip\">{{getSignificantItemDesc(event)}}</span>\n          </div>\n        </td>\n        <td><div class=\"tooltip text-16\">{{event.timestamp | ccdDate : 'local'}}\n          <span class=\"tooltiptext\">UTC: {{event.timestamp | ccdDate : 'utc'}}</span>\n        </div></td>\n        <td><span class=\"text-16\">{{event.user_first_name | titlecase}} {{event.user_last_name | uppercase}}</span></td>\n      </tr>\n      </tbody>\n    </table>\n  ",
            styles: ["\n    #case-timeline a{cursor:pointer;text-decoration:underline;color:#005ea5}#case-timeline a:hover{color:#2b8cc4}#case-timeline a:visited{color:#4c2c92}.EventLogTable tbody>tr td:first-child{padding-left:10px}.EventLogTable tbody>tr.EventLogTable-Selected{border-left:8px solid #005ea5;background-color:rgba(0,94,165,0.2)}.EventLogTable tbody>tr.EventLogTable-Selected td:first-child{padding-left:6px}.EventLogTable tbody>tr:not(.EventLogTable-Selected):hover{border-left:8px solid #2b8cc4;background-color:#f8f8f8;cursor:pointer;cursor:hand}.EventLogTable tbody>tr:not(.EventLogTable-Selected):hover td:first-child{padding-left:6px}.EventLogTable tbody>tr .event-link{float:left;padding-right:8px}.EventLogTable tbody>tr .doc-img{width:16px;float:left}.EventLogTable tbody>tr .doc-tooltip{left:35%;bottom:7px}.EventLogTable tbody>tr .doc-tooltip::after{border-color:transparent}\n  "]
        })
    ], EventLogTableComponent);
    return EventLogTableComponent;
}());
export { EventLogTableComponent };
//# sourceMappingURL=event-log-table.component.js.map