function _check_private_redeclaration(obj, privateCollection) {
    if (privateCollection.has(obj)) {
        throw new TypeError("Cannot initialize the same private elements twice on an object");
    }
}
function _class_apply_descriptor_get(receiver, descriptor) {
    if (descriptor.get) {
        return descriptor.get.call(receiver);
    }
    return descriptor.value;
}
function _class_apply_descriptor_set(receiver, descriptor, value) {
    if (descriptor.set) {
        descriptor.set.call(receiver, value);
    } else {
        if (!descriptor.writable) {
            throw new TypeError("attempted to set read only private field");
        }
        descriptor.value = value;
    }
}
function _class_extract_field_descriptor(receiver, privateMap, action) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to " + action + " private field on non-instance");
    }
    return privateMap.get(receiver);
}
function _class_private_field_get(receiver, privateMap) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
    return _class_apply_descriptor_get(receiver, descriptor);
}
function _class_private_field_init(obj, privateMap, value) {
    _check_private_redeclaration(obj, privateMap);
    privateMap.set(obj, value);
}
function _class_private_field_set(receiver, privateMap, value) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
    _class_apply_descriptor_set(receiver, descriptor, value);
    return value;
}
import { clone, extend } from '../../../helpers/object.mjs';
import { BaseUI } from './_base.mjs';
var /**
   * The reference to the input element.
   *
   * @type {HTMLInputElement}
   */ _input = /*#__PURE__*/ new WeakMap(), /**
   * The reference to the label element.
   *
   * @type {HTMLLabelElement}
   */ _label = /*#__PURE__*/ new WeakMap();
/**
 * @private
 * @class RadioInputUI
 */ export class RadioInputUI extends BaseUI {
    static get DEFAULTS() {
        return clone({
            type: 'radio',
            tagName: 'input',
            className: 'htUIRadio',
            label: {}
        });
    }
    /**
   * Build DOM structure.
   */ build() {
        super.build();
        const label = this.hot.rootDocument.createElement('label');
        label.textContent = this.translateIfPossible(this.options.label.textContent);
        label.htmlFor = this.translateIfPossible(this.options.label.htmlFor);
        _class_private_field_set(this, _label, label);
        _class_private_field_set(this, _input, this._element.firstChild);
        _class_private_field_get(this, _input).checked = this.options.checked;
        this._element.appendChild(label);
        this.update();
    }
    /**
   * Update element.
   */ update() {
        if (!this.isBuilt()) {
            return;
        }
        _class_private_field_get(this, _label).textContent = this.translateIfPossible(this.options.label.textContent);
    }
    /**
   * Check if radio button is checked.
   *
   * @returns {boolean}
   */ isChecked() {
        return this.isBuilt() ? _class_private_field_get(this, _input).checked : false;
    }
    /**
   * Set input checked attribute.
   *
   * @param {boolean} value Set the component state.
   */ setChecked(value = true) {
        if (this.isBuilt()) {
            _class_private_field_get(this, _input).checked = value;
        }
    }
    /**
   * Focus element.
   */ focus() {
        if (this.isBuilt()) {
            _class_private_field_get(this, _input).focus();
        }
    }
    constructor(hotInstance, options){
        super(hotInstance, extend(RadioInputUI.DEFAULTS, options)), _class_private_field_init(this, _input, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _label, {
            writable: true,
            value: void 0
        });
    }
}
