import { Component, Input } from '@angular/core';
import { plainToClassFromExist } from 'class-transformer';
import { CaseField } from '../../../domain/definition/case-field.model';
import { AbstractFieldReadComponent } from './abstract-field-read.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "rpx-xui-translation";
const _c0 = ["*"];
function FieldReadLabelComponent_dl_1_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function FieldReadLabelComponent_dl_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "dl", 3)(1, "dt", 4);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 5);
    i0.ɵɵtemplate(5, FieldReadLabelComponent_dl_1_ng_container_5_Template, 1, 0, "ng-container", 6);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    const caseFieldValue_r2 = i0.ɵɵreference(3);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, ctx_r0.caseField.label));
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngTemplateOutlet", caseFieldValue_r2);
} }
function FieldReadLabelComponent_ng_template_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0);
} }
export class FieldReadLabelComponent extends AbstractFieldReadComponent {
    // EUI-3267. Flag for whether or not this can have a grey bar.
    canHaveGreyBar = false;
    withLabel;
    isLabel() {
        return this.caseField.field_type && this.caseField.field_type.type === 'Label';
    }
    isComplex() {
        return this.caseField.isComplex();
    }
    isCaseLink() {
        return this.caseField.isCaseLink();
    }
    ngOnChanges(changes) {
        const change = changes['caseField'];
        if (change) {
            const cfNew = change.currentValue;
            if (!(cfNew instanceof CaseField)) {
                this.fixCaseField();
            }
            // EUI-3267.
            // Set up the flag for whether this can have a grey bar.
            this.canHaveGreyBar = !!this.caseField.show_condition;
        }
    }
    fixCaseField() {
        if (this.caseField && !(this.caseField instanceof CaseField)) {
            this.caseField = plainToClassFromExist(new CaseField(), this.caseField);
        }
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵFieldReadLabelComponent_BaseFactory; return function FieldReadLabelComponent_Factory(__ngFactoryType__) { return (ɵFieldReadLabelComponent_BaseFactory || (ɵFieldReadLabelComponent_BaseFactory = i0.ɵɵgetInheritedFactory(FieldReadLabelComponent)))(__ngFactoryType__ || FieldReadLabelComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FieldReadLabelComponent, selectors: [["ccd-field-read-label"]], inputs: { withLabel: "withLabel" }, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c0, decls: 4, vars: 5, consts: [["caseFieldValue", ""], [3, "hidden"], ["class", "case-field", 4, "ngIf", "ngIfElse"], [1, "case-field"], [1, "case-field__label"], [1, "case-field__value"], [4, "ngTemplateOutlet"]], template: function FieldReadLabelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "div", 1);
            i0.ɵɵtemplate(1, FieldReadLabelComponent_dl_1_Template, 6, 4, "dl", 2)(2, FieldReadLabelComponent_ng_template_2_Template, 1, 0, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            const caseFieldValue_r2 = i0.ɵɵreference(3);
            i0.ɵɵclassProp("grey-bar", ctx.canHaveGreyBar && !ctx.caseField.hiddenCannotChange);
            i0.ɵɵproperty("hidden", ctx.caseField.hidden);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.withLabel && !ctx.isLabel() && (!ctx.isComplex() || ctx.isCaseLink()))("ngIfElse", caseFieldValue_r2);
        } }, dependencies: [i1.NgIf, i1.NgTemplateOutlet, i2.RpxTranslatePipe], styles: [".case-field[_ngcontent-%COMP%]:after{content:\"\";display:block;clear:both}.case-field[_ngcontent-%COMP%]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:15px}@media (min-width: 641px){.case-field[_ngcontent-%COMP%]{margin-bottom:30px}}.case-field[_ngcontent-%COMP%]   .case-field__label[_ngcontent-%COMP%]{display:block;color:#0b0c0c;padding-bottom:2px;font-family:nta,Arial,sans-serif;font-weight:700;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.case-field[_ngcontent-%COMP%]   .case-field__label[_ngcontent-%COMP%]{font-size:19px;line-height:1.3157894737}}.case-field[_ngcontent-%COMP%]   .case-field__value[_ngcontent-%COMP%]{font-family:nta,Arial,sans-serif;font-weight:400;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.case-field[_ngcontent-%COMP%]   .case-field__value[_ngcontent-%COMP%]{font-size:19px;line-height:1.3157894737}}.form   [_nghost-%COMP%]  .grey-bar>*>.form-group, .form   [_nghost-%COMP%]  .grey-bar>*>*>.form-group, .form   [_nghost-%COMP%]  .grey-bar>*>dl.case-field{margin-left:15px;padding-left:15px}.form   [_nghost-%COMP%]  .grey-bar>*>.form-group:not(.form-group-error), .form   [_nghost-%COMP%]  .grey-bar>*>*>.form-group:not(.form-group-error), .form   [_nghost-%COMP%]  .grey-bar>*>dl.case-field:not(.form-group-error){border-left:solid 5px #b1b4b6}.form   [_nghost-%COMP%]  .grey-bar>*>.form-group input:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>.form-group select:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>.form-group textarea:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>*>.form-group input:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>*>.form-group select:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>*>.form-group textarea:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>dl.case-field input:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>dl.case-field select:not(.inline-block), .form   [_nghost-%COMP%]  .grey-bar>*>dl.case-field textarea:not(.inline-block){display:block}"] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FieldReadLabelComponent, [{
        type: Component,
        args: [{ selector: 'ccd-field-read-label', template: "<div [hidden]=\"caseField.hidden\" [class.grey-bar]=\"canHaveGreyBar && !caseField.hiddenCannotChange\">\n  <dl class=\"case-field\" *ngIf=\"withLabel && !isLabel() && (!isComplex() || isCaseLink()); else caseFieldValue\">\n    <dt class=\"case-field__label\">{{caseField.label | rpxTranslate}}</dt>\n    <dd class=\"case-field__value\">\n      <ng-container *ngTemplateOutlet=\"caseFieldValue\"></ng-container>\n    </dd>\n  </dl>\n  <ng-template #caseFieldValue>\n    <ng-content></ng-content>\n  </ng-template>\n</div>\n", styles: [".case-field:after{content:\"\";display:block;clear:both}.case-field{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:15px}@media (min-width: 641px){.case-field{margin-bottom:30px}}.case-field .case-field__label{display:block;color:#0b0c0c;padding-bottom:2px;font-family:nta,Arial,sans-serif;font-weight:700;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.case-field .case-field__label{font-size:19px;line-height:1.3157894737}}.case-field .case-field__value{font-family:nta,Arial,sans-serif;font-weight:400;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.case-field .case-field__value{font-size:19px;line-height:1.3157894737}}.form :host::ng-deep .grey-bar>*>.form-group,.form :host::ng-deep .grey-bar>*>*>.form-group,.form :host::ng-deep .grey-bar>*>dl.case-field{margin-left:15px;padding-left:15px}.form :host::ng-deep .grey-bar>*>.form-group:not(.form-group-error),.form :host::ng-deep .grey-bar>*>*>.form-group:not(.form-group-error),.form :host::ng-deep .grey-bar>*>dl.case-field:not(.form-group-error){border-left:solid 5px #b1b4b6}.form :host::ng-deep .grey-bar>*>.form-group input:not(.inline-block),.form :host::ng-deep .grey-bar>*>.form-group select:not(.inline-block),.form :host::ng-deep .grey-bar>*>.form-group textarea:not(.inline-block),.form :host::ng-deep .grey-bar>*>*>.form-group input:not(.inline-block),.form :host::ng-deep .grey-bar>*>*>.form-group select:not(.inline-block),.form :host::ng-deep .grey-bar>*>*>.form-group textarea:not(.inline-block),.form :host::ng-deep .grey-bar>*>dl.case-field input:not(.inline-block),.form :host::ng-deep .grey-bar>*>dl.case-field select:not(.inline-block),.form :host::ng-deep .grey-bar>*>dl.case-field textarea:not(.inline-block){display:block}\n"] }]
    }], null, { withLabel: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(FieldReadLabelComponent, { className: "FieldReadLabelComponent", filePath: "lib/shared/components/palette/base-field/field-read-label.component.ts", lineNumber: 14 }); })();
//# sourceMappingURL=data:application/json;base64, 