import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { s as scrollToFirstInvalidField } from './form.js';
import { e as waitAfterIdleCallback, b as waitAfterFramePaint } from './helpers.js';

const balFormCss = ".bal-form{display:block;position:static}";

const Form = /*@__PURE__*/ proxyCustomElement(class Form extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        /**
         * If `true` a native form element is added as a wrapper of the slot.
         */
        this.native = false;
        /**
         * If `true` it adds the novalidate attribute to the native form element.
         */
        this.novalidate = false;
        /**
         * The css class for the inner form element
         */
        this.formClass = '';
    }
    /**
     * Scrolls to the first invalid field inside this form component.
     */
    async scrollToFirstInvalidField() {
        await waitAfterIdleCallback();
        await waitAfterFramePaint();
        scrollToFirstInvalidField({ formEl: this.el });
    }
    render() {
        const NativeEl = this.native ? 'form' : 'div';
        let attrs = {};
        if (this.native) {
            attrs = {
                novalidate: this.novalidate,
            };
        }
        return (h(Host, { key: '8b3d28034718b1594fef9900e776ff718e16441d' }, h(NativeEl, Object.assign({ key: '4a21539e4b24d63f95813654d92ac8aa2c0f948b' }, attrs, { class: this.formClass }), h("slot", { key: '9b2a367a300b2803a4868c057e54d14952a557ca' }))));
    }
    get el() { return this; }
    static get style() { return balFormCss; }
}, [260, "bal-form", {
        "native": [4],
        "novalidate": [4],
        "formClass": [1, "form-class"],
        "scrollToFirstInvalidField": [64]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["bal-form"];
    components.forEach(tagName => { switch (tagName) {
        case "bal-form":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Form);
            }
            break;
    } });
}

const BalForm = Form;
const defineCustomElement = defineCustomElement$1;

export { BalForm, defineCustomElement };
