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 { CaseView, CaseField, Draft } from '../../domain';
var CaseHeaderComponent = /** @class */ (function () {
    function CaseHeaderComponent() {
    }
    CaseHeaderComponent.prototype.ngOnInit = function () {
        this.caseTitle = new CaseField();
        if (!this.isDraft() && this.caseDetails.state.title_display) {
            this.caseTitle.label = this.caseDetails.state.title_display;
            this.caseFields = this.getCaseFields();
        }
    };
    CaseHeaderComponent.prototype.isDraft = function () {
        return Draft.isDraft(this.caseDetails.case_id);
    };
    CaseHeaderComponent.prototype.showCaseReference = function () {
        return !this.caseTitle.label;
    };
    CaseHeaderComponent.prototype.getCaseFields = function () {
        var caseDataFields = this.caseDetails.tabs.reduce(function (acc, tab) {
            return acc.concat(tab.fields);
        }, []);
        return caseDataFields.concat(this.caseDetails.metadataFields);
    };
    __decorate([
        Input(),
        __metadata("design:type", CaseView)
    ], CaseHeaderComponent.prototype, "caseDetails", void 0);
    CaseHeaderComponent = __decorate([
        Component({
            selector: 'ccd-case-header',
            template: "\n    <h1 *ngIf=\"showCaseReference(); else custom_case_title\" class=\"heading-h1\">\n      #{{ caseDetails.case_id | ccdCaseReference}}\n    </h1>\n\n    <ng-template #custom_case_title>\n      <div class=\"case-title\">\n        <ccd-label-field [caseField]=\"caseTitle\" [caseFields]=\"caseFields\"></ccd-label-field>\n      </div>\n    </ng-template>\n  ",
            styles: ["\n    .case-title{margin-top:47px;margin-bottom:10px}.heading-h1{margin-top:40px}\n  "]
        })
    ], CaseHeaderComponent);
    return CaseHeaderComponent;
}());
export { CaseHeaderComponent };
//# sourceMappingURL=case-header.component.js.map