import { BaseInputElement, OptionElement } from "./index";
import { ElementType } from "../../../constants/UIKitConstants";
/**
 * Represents a radio button input element.
 */
export class RadioButtonElement extends BaseInputElement {
    /** The label of the input element. */
    label;
    /** The default value of the input element. */
    defaultValue;
    /** The options available for the radio input element. */
    options;
    /**
     * Creates a new instance of the RadioButtonElement class.
     * @param elementId The ID of the radio button element.
     * @param label The label of the radio button element.
     * @param options The options available for the radio button element.
     */
    constructor(elementId, label, options = []) {
        super(elementId, ElementType.radio);
        this.label = label || "";
        this.options = options.map((option) => {
            if (option instanceof OptionElement) {
                return option;
            }
            else {
                return OptionElement.fromJSON(option);
            }
        });
    }
    /**
     * Gets the label of the input element.
     * @returns The label of the input element.
     */
    getLabel() {
        return this.label;
    }
    /**
     * Gets the default value of the input element.
     * @returns The default value of the input element.
     */
    getDefaultValue() {
        return this.defaultValue;
    }
    /**
     * Sets the default value of the input element.
     * @param defaultValue The default value of the input element.
     */
    setDefaultValue(defaultValue) {
        this.defaultValue = defaultValue;
    }
    /**
     * Gets the options available for the radio input element.
     * @returns The options available for the radio input element.
     */
    getOptions() {
        return this.options;
    }
    static fromJSON(json) {
        const options = (json?.options || []).map((option) => {
            return OptionElement.fromJSON(option);
        });
        const radioButtonElement = new RadioButtonElement(json.elementId, json.label, options);
        if (json.defaultValue)
            radioButtonElement.setDefaultValue(json.defaultValue);
        return radioButtonElement;
    }
}
//# sourceMappingURL=RadioButtonElement.js.map