import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { AbstractFieldWriteComponent } from '../base-field/abstract-field-write.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "../utils/field-label.pipe";
import * as i4 from "../utils/first-error.pipe";
import * as i5 from "rpx-xui-translation";
const _c0 = a0 => ({ "form-group-error": a0 });
const _c1 = a0 => ({ "govuk-input--error": a0 });
function WriteNumberFieldComponent_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 6);
    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 WriteNumberFieldComponent_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 7);
    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 WriteNumberFieldComponent_span_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 8);
    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.numberControl.errors, ctx_r0.caseField.label), " ");
} }
export class WriteNumberFieldComponent extends AbstractFieldWriteComponent {
    numberControl;
    ngOnInit() {
        this.numberControl = this.registerControl(new FormControl(this.caseField.value));
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵWriteNumberFieldComponent_BaseFactory; return function WriteNumberFieldComponent_Factory(__ngFactoryType__) { return (ɵWriteNumberFieldComponent_BaseFactory || (ɵWriteNumberFieldComponent_BaseFactory = i0.ɵɵgetInheritedFactory(WriteNumberFieldComponent)))(__ngFactoryType__ || WriteNumberFieldComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: WriteNumberFieldComponent, selectors: [["ccd-write-number-field"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 6, vars: 12, consts: [[1, "form-group", 3, "ngClass"], [3, "for"], ["class", "form-label", 4, "ngIf"], ["class", "form-hint", 4, "ngIf"], ["class", "error-message", 4, "ngIf"], ["type", "text", "inputmode", "decimal", "pattern", "^[-+]?[0-9]+(?:\\.?[0-9]+)?$", 1, "form-control", "bottom-30", 3, "ngClass", "id", "formControl"], [1, "form-label"], [1, "form-hint"], [1, "error-message"]], template: function WriteNumberFieldComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "label", 1);
            i0.ɵɵtemplate(2, WriteNumberFieldComponent_span_2_Template, 3, 3, "span", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(3, WriteNumberFieldComponent_span_3_Template, 3, 3, "span", 3)(4, WriteNumberFieldComponent_span_4_Template, 3, 4, "span", 4);
            i0.ɵɵelement(5, "input", 5);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(8, _c0, !ctx.numberControl.valid && ctx.numberControl.dirty));
            i0.ɵɵadvance();
            i0.ɵɵproperty("for", ctx.id());
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.label);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseField.hint_text);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.numberControl.errors && ctx.numberControl.dirty);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(10, _c1, ctx.numberControl.errors && ctx.numberControl.dirty))("id", ctx.id())("formControl", ctx.numberControl);
        } }, dependencies: [i1.NgClass, i1.NgIf, i2.DefaultValueAccessor, i2.NgControlStatus, i2.PatternValidator, i2.FormControlDirective, i3.FieldLabelPipe, i4.FirstErrorPipe, i5.RpxTranslatePipe], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(WriteNumberFieldComponent, [{
        type: Component,
        args: [{ selector: 'ccd-write-number-field', template: "<div class=\"form-group\" [ngClass]=\"{'form-group-error': !numberControl.valid && numberControl.dirty}\">\n  <label [for]=\"id()\">\n    <span class=\"form-label\" *ngIf=\"caseField.label\">{{caseField | ccdFieldLabel}}</span>\n  </label>\n  <span class=\"form-hint\" *ngIf=\"caseField.hint_text\">{{caseField.hint_text | rpxTranslate}}</span>\n  <span class=\"error-message\" *ngIf=\"numberControl.errors && numberControl.dirty\">\n    {{numberControl.errors | ccdFirstError:caseField.label}}\n  </span>\n\n  <input class=\"form-control bottom-30\" [ngClass]=\"{'govuk-input--error': numberControl.errors && numberControl.dirty}\"\n   [id]=\"id()\" type=\"text\" inputmode=\"decimal\" pattern=\"^[-+]?[0-9]+(?:\\.?[0-9]+)?$\" [formControl]=\"numberControl\">\n</div>\n" }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(WriteNumberFieldComponent, { className: "WriteNumberFieldComponent", filePath: "lib/shared/components/palette/number/write-number-field.component.ts", lineNumber: 9 }); })();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid3JpdGUtbnVtYmVyLWZpZWxkLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2NjZC1jYXNlLXVpLXRvb2xraXQvc3JjL2xpYi9zaGFyZWQvY29tcG9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