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, Input } from '@angular/core';
import { CasesService, CaseService } from '../case-editor';
import { AlertService } from '../../services';
import { map } from 'rxjs/operators';
import { throwError } from 'rxjs';
var CaseTimelineComponent = /** @class */ (function () {
    function CaseTimelineComponent(caseService, casesService, alertService) {
        this.caseService = caseService;
        this.casesService = casesService;
        this.alertService = alertService;
        this.dspMode = CaseTimelineDisplayMode;
        this.displayMode = CaseTimelineDisplayMode.TIMELINE;
    }
    CaseTimelineComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.casesService
            .getCaseView(this.case)
            .pipe(map(function (caseView) {
            _this.events = caseView.events;
            _this.caseService.announceCase(caseView);
        }))
            .toPromise()
            .catch(function (error) {
            _this.alertService.error(error.message);
            return throwError(error);
        });
    };
    CaseTimelineComponent.prototype.isDataLoaded = function () {
        return this.events ? true : false;
    };
    CaseTimelineComponent.prototype.caseHistoryClicked = function (eventId) {
        this.displayMode = CaseTimelineDisplayMode.DETAILS;
        this.selectedEventId = eventId;
    };
    CaseTimelineComponent.prototype.goToCaseTimeline = function () {
        this.displayMode = CaseTimelineDisplayMode.TIMELINE;
    };
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], CaseTimelineComponent.prototype, "case", void 0);
    CaseTimelineComponent = __decorate([
        Component({
            selector: 'ccd-case-timeline',
            template: "\n    <div *ngIf=\"isDataLoaded()\">\n        <ng-container [ngSwitch]=\"displayMode\">\n            <ng-container *ngSwitchCase=\"dspMode.TIMELINE\">\n                <ccd-event-log [events]=\"events\" (onCaseHistory)=\"caseHistoryClicked($event)\" *ngIf=\"displayMode === dspMode.TIMELINE\"></ccd-event-log>\n            </ng-container>\n            <ng-container *ngSwitchCase=\"dspMode.DETAILS\">\n                <div class=\"govuk-breadcrumbs\">\n                    <ol class=\"govuk-breadcrumbs__list\">\n                        <li class=\"govuk-breadcrumbs__list-item\">\n                            <a href=\"javascript:void(0)\" (click)=\"goToCaseTimeline()\" class=\"govuk-back-link\">Back to case timeline</a>\n                        </li>\n                    </ol>\n                </div>\n                <ccd-case-history [event]=\"selectedEventId\"></ccd-case-history>\n            </ng-container>\n        </ng-container>\n    </div>\n  "
        }),
        __metadata("design:paramtypes", [CaseService,
            CasesService,
            AlertService])
    ], CaseTimelineComponent);
    return CaseTimelineComponent;
}());
export { CaseTimelineComponent };
export var CaseTimelineDisplayMode;
(function (CaseTimelineDisplayMode) {
    CaseTimelineDisplayMode[CaseTimelineDisplayMode["TIMELINE"] = 0] = "TIMELINE";
    CaseTimelineDisplayMode[CaseTimelineDisplayMode["DETAILS"] = 1] = "DETAILS";
})(CaseTimelineDisplayMode || (CaseTimelineDisplayMode = {}));
//# sourceMappingURL=case-timeline.component.js.map