import { Component, Input } from '@angular/core';
import { of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { OrganisationConverter } from '../../../domain/organisation/organisation-converter';
import { OrganisationService } from '../../../services/organisation/organisation.service';
import { AbstractFieldReadComponent } from '../base-field/abstract-field-read.component';
import * as i0 from "@angular/core";
import * as i1 from "../../../services/organisation/organisation.service";
import * as i2 from "../../../domain/organisation/organisation-converter";
import * as i3 from "@angular/common";
import * as i4 from "../markdown/markdown.component";
import * as i5 from "rpx-xui-translation";
function ReadOrganisationFieldRawComponent_table_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "table", 1)(1, "tr", 4);
    i0.ɵɵelement(2, "th", 2);
    i0.ɵɵelementStart(3, "td", 5)(4, "span", 6);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "td")(7, "span", 6);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd()()();
    i0.ɵɵelementStart(9, "tr", 4);
    i0.ɵɵelement(10, "th", 2);
    i0.ɵɵelementStart(11, "td", 5)(12, "span", 6);
    i0.ɵɵtext(13);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "td");
    i0.ɵɵelement(15, "ccd-markdown", 7);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const selectedOrg_r1 = ctx.ngIf;
    i0.ɵɵattribute("aria-describedby", "selected organisation field table");
    i0.ɵɵadvance(5);
    i0.ɵɵtextInterpolate("Name:");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(selectedOrg_r1.name);
    i0.ɵɵadvance(5);
    i0.ɵɵtextInterpolate("Address:");
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("content", selectedOrg_r1.address);
} }
export class ReadOrganisationFieldRawComponent extends AbstractFieldReadComponent {
    organisationService;
    organisationConverter;
    caseFields = [];
    organisations$;
    selectedOrg$;
    constructor(organisationService, organisationConverter) {
        super();
        this.organisationService = organisationService;
        this.organisationConverter = organisationConverter;
    }
    ngOnInit() {
        super.ngOnInit();
        if (this.caseField.value && this.caseField.value.OrganisationID) {
            this.organisations$ = this.organisationService.getActiveOrganisations();
            this.selectedOrg$ = this.organisations$.pipe(switchMap((organisations) => of(this.organisationConverter.toSimpleOrganisationModel(organisations.find(findOrg => findOrg.organisationIdentifier === this.caseField.value.OrganisationID)))));
        }
    }
    static ɵfac = function ReadOrganisationFieldRawComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReadOrganisationFieldRawComponent)(i0.ɵɵdirectiveInject(i1.OrganisationService), i0.ɵɵdirectiveInject(i2.OrganisationConverter)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ReadOrganisationFieldRawComponent, selectors: [["ccd-read-organisation-field-raw"]], inputs: { caseFields: "caseFields" }, features: [i0.ɵɵInheritDefinitionFeature], decls: 9, vars: 6, consts: [[1, "complex-panel"], [1, "complex-field-table"], [2, "display", "none"], ["class", "complex-field-table", 4, "ngIf"], [1, "complex-panel-compound-field"], [1, "label-width-small"], [1, "text-16"], [3, "content"]], template: function ReadOrganisationFieldRawComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "table", 1);
            i0.ɵɵpipe(2, "rpxTranslate");
            i0.ɵɵelementStart(3, "tbody")(4, "tr");
            i0.ɵɵelement(5, "th", 2);
            i0.ɵɵelementStart(6, "td");
            i0.ɵɵtemplate(7, ReadOrganisationFieldRawComponent_table_7_Template, 16, 5, "table", 3);
            i0.ɵɵpipe(8, "async");
            i0.ɵɵelementEnd()()()()();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵattribute("aria-describedby", i0.ɵɵpipeBind1(2, 2, "complex organisation field table"));
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(8, 4, ctx.selectedOrg$));
        } }, dependencies: [i3.NgIf, i4.MarkdownComponent, i3.AsyncPipe, i5.RpxTranslatePipe], styles: [".hmcts-banner[_ngcontent-%COMP%]{border:0 solid;margin-bottom:10px;color:#000}.hmcts-banner[_ngcontent-%COMP%]   .warning-message[_ngcontent-%COMP%]{font-weight:700}.govuk-hint[_ngcontent-%COMP%]{font-size:1.1rem}.name-header[_ngcontent-%COMP%]{font-weight:700;margin-top:10px;font-size:18px}.td-address[_ngcontent-%COMP%]{width:90%;padding-top:2px}.td-select[_ngcontent-%COMP%]{width:10%}.warning-panel[_ngcontent-%COMP%]{background-color:#e7ebef;height:40px;margin-bottom:0;align-items:center;display:flex}.warning-panel[_ngcontent-%COMP%]   .warning-message[_ngcontent-%COMP%]{padding-left:15px}.complex-field-table[_ngcontent-%COMP%] > tbody[_ngcontent-%COMP%] > tr[_ngcontent-%COMP%] > th[_ngcontent-%COMP%]{border:none}.complex-field-table[_ngcontent-%COMP%] > tbody[_ngcontent-%COMP%] > tr[_ngcontent-%COMP%]:last-child > th[_ngcontent-%COMP%], .complex-field-table[_ngcontent-%COMP%] > tbody[_ngcontent-%COMP%] > tr[_ngcontent-%COMP%]:last-child > td[_ngcontent-%COMP%]{border-bottom:none}.complex-field-title[_ngcontent-%COMP%]{width:300px}.label-width-small[_ngcontent-%COMP%]{width:100px}.label-width-medium[_ngcontent-%COMP%]{width:150px}.scroll-container[_ngcontent-%COMP%]{height:600px;overflow-y:scroll}.no-result-message[_ngcontent-%COMP%]{margin-top:15px}"] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReadOrganisationFieldRawComponent, [{
        type: Component,
        args: [{ selector: 'ccd-read-organisation-field-raw', template: "<div class=\"complex-panel\">\n  <table class=\"complex-field-table\" [attr.aria-describedby]=\"'complex organisation field table' | rpxTranslate\">\n    <tbody>\n      <tr>\n        <th style=\"display: none;\"></th>\n        <td>\n          <table class=\"complex-field-table\" *ngIf=\"(selectedOrg$ | async) as selectedOrg\"\n                 [attr.aria-describedby]=\"'selected organisation field table'\">\n            <tr class=\"complex-panel-compound-field\">\n              <th style=\"display: none;\"></th>\n              <td class=\"label-width-small\"><span class=\"text-16\">{{'Name:'}}</span></td>\n              <td><span class=\"text-16\">{{selectedOrg.name}}</span></td>\n            </tr>\n            <tr class=\"complex-panel-compound-field\">\n              <th style=\"display: none;\"></th>\n              <td class=\"label-width-small\"><span class=\"text-16\">{{'Address:'}}</span></td>\n              <td>\n                <ccd-markdown [content]=\"selectedOrg.address\"></ccd-markdown>\n              </td>\n            </tr>\n          </table>\n        </td>\n      </tr>\n    </tbody>\n  </table>\n</div>\n", styles: [".hmcts-banner{border:0 solid;margin-bottom:10px;color:#000}.hmcts-banner .warning-message{font-weight:700}.govuk-hint{font-size:1.1rem}.name-header{font-weight:700;margin-top:10px;font-size:18px}.td-address{width:90%;padding-top:2px}.td-select{width:10%}.warning-panel{background-color:#e7ebef;height:40px;margin-bottom:0;align-items:center;display:flex}.warning-panel .warning-message{padding-left:15px}.complex-field-table>tbody>tr>th{border:none}.complex-field-table>tbody>tr:last-child>th,.complex-field-table>tbody>tr:last-child>td{border-bottom:none}.complex-field-title{width:300px}.label-width-small{width:100px}.label-width-medium{width:150px}.scroll-container{height:600px;overflow-y:scroll}.no-result-message{margin-top:15px}\n"] }]
    }], () => [{ type: i1.OrganisationService }, { type: i2.OrganisationConverter }], { caseFields: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ReadOrganisationFieldRawComponent, { className: "ReadOrganisationFieldRawComponent", filePath: "lib/shared/components/palette/organisation/read-organisation-field-raw.component.ts", lineNumber: 15 }); })();
//# sourceMappingURL=data:application/json;base64, 