import { r as registerInstance, h, g as getElement } from './index-b13326fc.js';

const BceElementForm = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    async validate(silent = false) {
        const root = this.el.shadowRoot;
        const query = root.querySelectorAll('bce-input');
        const inputs = Array.from(query);
        const errors = await Promise.all(inputs.map(el => el.validate(silent)));
        return [].concat(...errors);
    }
    isSelect(input) {
        return input.type === 'radio';
    }
    renderInput(input) {
        return (h("bce-input", { id: input.id, key: input.id, label: input.label, type: input.type, validation: input.required ? 'required' : undefined }));
    }
    renderSelect(input) {
        return (h("bce-select", { id: input.id, key: input.id, label: input.label, type: input.type, validation: input.required ? 'required' : undefined }, (input.options || []).map((option, i) => (h("bce-option", { key: i, value: option }, option)))));
    }
    render() {
        return this.template.input.map(i => this.isSelect(i) ? this.renderSelect(i) : this.renderInput(i));
    }
    get el() { return getElement(this); }
    static get style() { return ":host{position:relative;display:block}"; }
};

export { BceElementForm as bce_element_form };
