/**
 * Create id for messaging
 */
const messageId = (id, messageType) => {
    return `${id}__${messageType}-message`;
};
/**
 * Assign aria-description id to relate messages with form element
 */
const assignDescription = (id, invalid, helperMessage) => {
    if (!helperMessage)
        return;
    let relatedId = messageId(id, 'helper');
    if (invalid)
        relatedId = messageId(id, 'error');
    return relatedId;
};
/**
 * Updates the `invalid` prop of a form element based on it's values validity
 */
const isRequired = (target, component) => {
    if (!target || !component)
        return;
    if (component.required === true) {
        (target.checkValidity() === false) ? component.invalid = true : component.invalid = false;
    }
};
/**
 * Exposes a readonly type property on a custom form element to match native form element behavior.
 * This makes the type property enumerable and accessible via element.type, matching native HTML elements.
 * The property is non-configurable, preventing it from being redefined or deleted at runtime.
 *
 * @param element - The custom element to add the type property to
 * @param type - The type value (string literal) or a getter function that returns the type
 */
function exposeTypeProperty(element, type) {
    if (Object.getOwnPropertyDescriptor(element, 'type'))
        return;
    Object.defineProperty(element, 'type', {
        get: typeof type === 'function' ? type : () => type,
        enumerable: true,
        configurable: false
    });
}
/**
 * Determines if code is running in Stencil's spec test environment.
 * Stencil's mock-doc logs console.error on any ElementInternals
 * property access during spec tests. Use this guard to skip
 * ElementInternals calls in the mock environment.
 *
 * Uses __STENCIL_SPEC_TESTS__ (the same env var Stencil's mock-doc checks)
 * to avoid false positives in downstream consumer test suites.
 */
const isSpecTest = () => {
    var _a;
    return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.__STENCIL_SPEC_TESTS__) === 'true';
};

export { assignDescription as a, isRequired as b, exposeTypeProperty as e, isSpecTest as i, messageId as m };
//# sourceMappingURL=form-C3xDZBme.js.map

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