import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { AbstractFieldWriteComponent } from '../base-field/abstract-field-write.component';
import { YesNoService } from './yes-no.service';
import * as i0 from "@angular/core";
import * as i1 from "./yes-no.service";
import * as i2 from "@angular/common";
import * as i3 from "@angular/forms";
import * as i4 from "../utils/field-label.pipe";
import * as i5 from "../utils/first-error.pipe";
import * as i6 from "rpx-xui-translation";
const _c0 = a0 => ({ "form-group-error": a0 });
const _c1 = a0 => ({ selected: a0 });
function WriteYesNoFieldComponent_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 7);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "ccdFieldLabel");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r0.caseField));
} }
function WriteYesNoFieldComponent_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, ctx_r0.caseField.hint_text));
} }
function WriteYesNoFieldComponent_span_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 9);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "ccdFirstError");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind2(2, 1, ctx_r0.yesNoControl.errors, ctx_r0.caseField.label), " ");
} }
function WriteYesNoFieldComponent_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵelement(1, "input", 11);
    i0.ɵɵelementStart(2, "label", 12);
    i0.ɵɵtext(3);
    i0.ɵɵpipe(4, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const value_r2 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(12, _c1, ctx_r0.yesNoControl.value === value_r2));
    i0.ɵɵadvance();
    i0.ɵɵproperty("id", ctx_r0.createElementId(value_r2))("name", ctx_r0.id())("formControl", ctx_r0.yesNoControl)("value", value_r2);
    i0.ɵɵattribute("name", ctx_r0.id());
    i0.ɵɵadvance();
    i0.ɵɵproperty("for", ctx_r0.createElementId(value_r2));
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.caseField.label ? i0.ɵɵpipeBind3(4, 8, ctx_r0.caseField.originalLabel || ctx_r0.caseField.label, null, value_r2) : value_r2);
} }
export class WriteYesNoFieldComponent extends AbstractFieldWriteComponent {
    yesNoService;
    yesNoValues = ['Yes', 'No'];
    yesNoControl;
    constructor(yesNoService) {
        super();
        this.yesNoService = yesNoService;
    }
    ngOnInit() {
        this.yesNoControl = this.registerControl(new FormControl(this.yesNoService.format(this.caseField.value)));
    }
    static ɵfac = function WriteYesNoFieldComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || WriteYesNoFieldComponent)(i0.ɵɵdirectiveInject(i1.YesNoService)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteYesNoFieldComponent, selectors: [["ccd-write-yes-no-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 8, vars: 9, consts: [[1, "form-group", "bottom-30", 3, "id", "ngClass"], [1, "inline"], ["class", "form-label", 4, "ngIf"], ["class", "form-hint", 4, "ngIf"], ["class", "error-message", 4, "ngIf"], [3, "id"], ["class", "multiple-choice", 3, "ngClass", 4, "ngFor", "ngForOf"], [1, "form-label"], [1, "form-hint"], [1, "error-message"], [1, "multiple-choice", 3, "ngClass"], ["type", "radio", 1, "form-control", 3, "id", "name", "formControl", "value"], [1, "form-label", 3, "for"]], template: function WriteYesNoFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "fieldset", 1)(2, "legend");
            i0.ɵɵtemplate(3, WriteYesNoFieldComponent_span_3_Template, 3, 3, "span", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(4, WriteYesNoFieldComponent_span_4_Template, 3, 3, "span", 3)(5, WriteYesNoFieldComponent_span_5_Template, 3, 4, "span", 4);
            i0.ɵɵelementStart(6, "div", 5);
            i0.ɵɵtemplate(7, WriteYesNoFieldComponent_div_7_Template, 5, 14, "div", 6);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵproperty("id", ctx.id())("ngClass", i0.ɵɵpureFunction1(7, _c0, !ctx.yesNoControl.valid && (ctx.yesNoControl.dirty || ctx.yesNoControl.touched)));
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.caseField.label);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.hint_text);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.yesNoControl.errors && (ctx.yesNoControl.dirty || ctx.yesNoControl.touched));
            i0.ɵɵadvance();
            i0.ɵɵproperty("id", ctx.createElementId("radio"));
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngForOf", ctx.yesNoValues);
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i3.DefaultValueAccessor, i3.RadioControlValueAccessor, i3.NgControlStatus, i3.FormControlDirective, i4.FieldLabelPipe, i5.FirstErrorPipe, i6.RpxTranslatePipe], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteYesNoFieldComponent, [{
        type: Component,
        args: [{ selector: 'ccd-write-yes-no-field', template: "<div [id]=\"id()\" class=\"form-group bottom-30\" [ngClass]=\"{'form-group-error': !yesNoControl.valid && (yesNoControl.dirty || yesNoControl.touched)}\">\n\t<fieldset class=\"inline\">\n    <legend>\n      <span class=\"form-label\" *ngIf=\"caseField.label\">{{caseField | ccdFieldLabel}}</span>\n    </legend>\n    <span class=\"form-hint\" *ngIf=\"caseField.hint_text\">{{caseField.hint_text | rpxTranslate}}</span>\n    <span class=\"error-message\" *ngIf=\"yesNoControl.errors && (yesNoControl.dirty || yesNoControl.touched)\">\n      {{yesNoControl.errors | ccdFirstError:caseField.label}}\n    </span>\n\n    <div [id]=\"createElementId('radio')\">\n  \t  <div class=\"multiple-choice\" *ngFor=\"let value of yesNoValues\" [ngClass]=\"{selected: yesNoControl.value === value}\">\n  \t    <input class=\"form-control\" [id]=\"createElementId(value)\" [attr.name]=\"id()\" [name]=\"id()\" type=\"radio\" [formControl]=\"yesNoControl\" [value]=\"value\">\n        <label class=\"form-label\" [for]=\"createElementId(value)\">{{caseField.label ? ((caseField.originalLabel || caseField.label) | rpxTranslate:null:value) : value}}</label>\n  \t  </div>\n    </div>\n\t</fieldset>\n</div>\n" }]
    }], () => [{ type: i1.YesNoService }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteYesNoFieldComponent, { className: "WriteYesNoFieldComponent", filePath: "lib/shared/components/palette/yes-no/write-yes-no-field.component.ts", lineNumber: 10 }); })();
//# sourceMappingURL=data:application/json;base64, 