import { S as Sizes } from './sizes-BcQO4NH2.js';
import { p as pick } from './utils-CQvUntGY.js';
import { F as FormMessageClass } from './constants-BegH8u6i.js';
import { F as FormAutocompleteClass } from './constants-aqe7GX2n.js';
import { F as FormLabelClass } from './constants-CysDgoMA.js';

const FormCheckboxSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormCheckboxClass = {
    root: 'gov-form-checkbox',
    check: 'gov-form-checkbox__check',
    indeterminate: 'gov-form-checkbox__indeterminate',
    label: 'gov-form-checkbox__label',
};

pick(Sizes, ['_M', '_L', '_XL']);
const FormControlClass = {
    root: 'gov-form-control',
    holder: 'gov-form-control__holder',
    bottom: 'gov-form-control__bottom',
};

const FormInputSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
var InputTypes;
(function (InputTypes) {
    InputTypes["COLOR"] = "color";
    InputTypes["DATE"] = "date";
    InputTypes["DATETIME_LOCAL"] = "datetime-local";
    InputTypes["EMAIL"] = "email";
    InputTypes["MONTH"] = "month";
    InputTypes["NUMBER"] = "number";
    InputTypes["PASSWORD"] = "password";
    InputTypes["SEARCH"] = "search";
    InputTypes["TEL"] = "tel";
    InputTypes["TEXT"] = "text";
    InputTypes["TIME"] = "time";
    InputTypes["URL"] = "url";
    InputTypes["WEEK"] = "week";
})(InputTypes || (InputTypes = {}));
var Type;
(function (Type) {
    Type["RESET"] = "reset";
})(Type || (Type = {}));
const FormInputClass = {
    root: 'gov-form-input',
    icons: 'gov-form-input__icons',
};

const FormSelectSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormSelectClass = {
    root: 'gov-form-select'};

const FormMultiselectSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormMultiSelectClass = {
    root: 'gov-form-multi-select',
    wrap: 'gov-form-multi-select__wrap',
    list: 'gov-form-multi-select__list',
    item: 'gov-form-multi-select__item',
};

const FormSwitchSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormSwitchClass = {
    root: 'gov-form-switch',
    input: 'gov-form-switch__input',
    indicator: 'gov-form-switch__indicator',
    label: 'gov-form-switch__label',
    noLabel: 'gov-form-switch__no-label',
};

const FormRadioSizes = pick(Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormRadioClass = {
    root: 'gov-form-radio',
    input: 'gov-form-radio__input',
    label: 'gov-form-radio__label',
};

const govForm = (govHost) => {
    return {
        get govHost() {
            return govHost;
        },
        passAttrToControl(name, value) {
            if (this.control) {
                this.control.setAttribute(name, value);
            }
        },
        passAttrToLabel(name, value) {
            if (this.label) {
                this.label.setAttribute(name, value);
            }
        },
        get hasGroupChildren() {
            if (this.control) {
                return this.control.querySelectorAll('gov-form-group > *, gov-form-radio-group > *, gov-form-checkbox-group > *').length > 1;
            }
            return false;
        },
        get control() {
            if (this.govHost.name === FormControlClass.root) {
                return this.govHost.hostElement;
            }
            return this.govHost.getParent(FormControlClass.root);
        },
        get label() {
            const innerLabel = this.govHost.hostElement.querySelector(`.${FormLabelClass.root}`);
            if (innerLabel) {
                return innerLabel;
            }
            if (this.control) {
                return this.control.querySelector(`.${FormLabelClass.root}`);
            }
            return null;
        },
        get mainElementsInControl() {
            const formElements = [
                FormSelectClass.root,
                FormInputClass.root,
                FormSwitchClass.root,
                FormCheckboxClass.root,
                FormRadioClass.root,
                FormMultiSelectClass.root,
                FormAutocompleteClass.root,
            ];
            if (this.control) {
                const elements = formElements.map(el => `${el}:first-of-type`).join(', ');
                return Array.from(this.control.querySelectorAll(elements));
            }
            return [];
        },
        get messageElements() {
            if (this.control) {
                return Array.from(this.control.querySelectorAll(FormMessageClass.root));
            }
            return [];
        },
    };
};

export { FormCheckboxClass as F, FormCheckboxSizes as a, FormControlClass as b, FormMultiSelectClass as c, FormMultiselectSizes as d, FormRadioClass as e, FormRadioSizes as f, govForm as g, FormSwitchClass as h, FormSwitchSizes as i, FormSelectClass as j, FormSelectSizes as k, FormInputClass as l, FormInputSizes as m };
//# sourceMappingURL=form-DvhJiKwA.js.map

//# sourceMappingURL=form-DvhJiKwA.js.map