'use strict';

var sizes = require('./sizes-D5zsw2g5.js');
var utils = require('./utils-NnC78QR3.js');
var constants = require('./constants-DcKnOyW4.js');
var constants$1 = require('./constants-CFAhiwqu.js');
var constants$2 = require('./constants-357ehBFU.js');

const FormCheckboxSizes = utils.pick(sizes.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',
};

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

const FormInputSizes = utils.pick(sizes.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 = utils.pick(sizes.Sizes, ['_XS', '_S', '_M', '_L', '_XL']);
const FormSelectClass = {
    root: 'gov-form-select'};

const FormMultiselectSizes = utils.pick(sizes.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 = utils.pick(sizes.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 = utils.pick(sizes.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(`.${constants$2.FormLabelClass.root}`);
            if (innerLabel) {
                return innerLabel;
            }
            if (this.control) {
                return this.control.querySelector(`.${constants$2.FormLabelClass.root}`);
            }
            return null;
        },
        get mainElementsInControl() {
            const formElements = [
                FormSelectClass.root,
                FormInputClass.root,
                FormSwitchClass.root,
                FormCheckboxClass.root,
                FormRadioClass.root,
                FormMultiSelectClass.root,
                constants$1.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(constants.FormMessageClass.root));
            }
            return [];
        },
    };
};

exports.FormCheckboxClass = FormCheckboxClass;
exports.FormCheckboxSizes = FormCheckboxSizes;
exports.FormControlClass = FormControlClass;
exports.FormInputClass = FormInputClass;
exports.FormInputSizes = FormInputSizes;
exports.FormMultiSelectClass = FormMultiSelectClass;
exports.FormMultiselectSizes = FormMultiselectSizes;
exports.FormRadioClass = FormRadioClass;
exports.FormRadioSizes = FormRadioSizes;
exports.FormSelectClass = FormSelectClass;
exports.FormSelectSizes = FormSelectSizes;
exports.FormSwitchClass = FormSwitchClass;
exports.FormSwitchSizes = FormSwitchSizes;
exports.govForm = govForm;
//# sourceMappingURL=form-GgXzZZ-E.js.map

//# sourceMappingURL=form-GgXzZZ-E.js.map