'use strict';

var index = require('./index-p7cvUYAE.js');
var parts = require('./parts-BXshb_S-.js');

const FormControlRadio = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.formControlInput = index.createEvent(this, "formControlInput", 7);
        this.formControlBlur = index.createEvent(this, "formControlBlur", 7);
        this.isFocused = false;
        this.inputHandler = () => { };
        this.disabled = false;
        this.errorText = '';
        this.handleFormControlInput = (event) => {
            const target = event.target;
            const name = target.getAttribute('name');
            this.inputHandler(name, this.value);
            this.formControlInput.emit({ name, value: this.value });
        };
    }
    get part() {
        if (this.errorText) {
            return parts.inputRadioInvalid;
        }
        if (this.isFocused && this.checked) {
            return parts.inputRadioCheckedFocused;
        }
        if (this.checked) {
            return parts.inputRadioChecked;
        }
        if (this.isFocused) {
            return parts.inputRadioFocused;
        }
        return parts.inputRadio;
    }
    render() {
        return (index.h(index.Host, { key: '0c6362e375e04d23c7e31a6be9ea6a43fbfdaac2', class: 'form-group d-flex flex-column' }, index.h("div", { key: '81b22f74d5b872318e121a2be0cbd8108c3f32ec', class: "form-check" }, index.h("input", { key: '903e8b0ad9cb30241d175da091de758bf4ac2471', ref: el => (this.radioElement = el), type: "radio", id: `${this.name}-${this.value}`, name: this.name, onFocus: () => this.isFocused = true, onBlur: () => {
                this.isFocused = false;
                this.formControlBlur.emit();
            }, onChange: this.handleFormControlInput, part: this.part, class: this.errorText ? 'form-check-input is-invalid' : 'form-check-input', disabled: this.disabled, value: this.value, checked: this.checked }), index.h("label", { key: 'df1402687b5965cbbd41ab65dc3de46a2e6e86b8', class: "form-check-label", htmlFor: `${this.name}-${this.value}`, part: parts.label }, this.label)), index.h("form-control-help-text", { key: 'cf5498002674765b9cc5a0a09be1851be4221e9f', helpText: this.helpText, name: this.name }), index.h("form-control-error-text", { key: 'c5b50668f0451d1d5cbf94c1399057758ac93a5e', errorText: this.errorText, name: this.name })));
    }
};

exports.form_control_radio = FormControlRadio;
