import { BaseInputElement, OptionElement } from "./index";
import { ElementType } from "../../../constants/UIKitConstants";
/**
 * Represents a checkbox input element.
 */
export class CheckboxElement extends BaseInputElement {
    /** The label of the input element. */
    label;
    /** The default values to be selected in the checkbox. */
    defaultValue;
    /** The options available for the checkbox input element. */
    options;
    /**
     * Creates a new instance of the CheckboxInput class.
     * @param elementId The ID of the input element.
     * @param label The label of the input element.
     * @param options The options available for the checkbox input element.
     */
    constructor(elementId, label, options = []) {
        super(elementId, ElementType.checkbox);
        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;
    }
    /**
     * Sets the default values to be selected in the checkbox.
     * @param defaultValue The default values to be selected in the checkbox.
     */
    setDefaultValue(defaultValue) {
        this.defaultValue = defaultValue;
    }
    /**
     * Gets the default values to be selected in the checkbox.
     * @returns The default values to be selected in the checkbox.
     * */
    getDefaultValue() {
        return this.defaultValue;
    }
    /**
     * Gets the options available for the checkbox input element.
     * @returns The options available for the checkbox input element.
     */
    getOptions() {
        return this.options;
    }
    static fromJSON(json) {
        const options = (json?.options || []).map((option) => {
            return OptionElement.fromJSON(option);
        });
        const checkboxElement = new CheckboxElement(json.elementId, json.label, options);
        if (json.defaultValue)
            checkboxElement.setDefaultValue(json.defaultValue);
        return checkboxElement;
    }
}
//# sourceMappingURL=CheckboxElement.js.map