import { createContext, useContext } from "react";
const FieldSetContext = createContext(undefined);
const FieldSetContextProvider = FieldSetContext.Provider;
export function useFieldSet() {
    const ctx = useContext(FieldSetContext);
    if (!ctx) {
        throw new Error('useFieldSet must be used within a Form or FieldSet element');
    }
    return ctx;
}
export class FormContext {
    object;
    components;
    disabled;
    constructor(object, components = {}, disabled = false) {
        this.object = object;
        this.components = components;
        this.disabled = disabled;
    }
}
const _FormContext = createContext(undefined);
export function useForm() {
    const ctx = useContext(_FormContext);
    if (!ctx) {
        throw new Error('useForm must be used within a Form element');
    }
    return ctx;
}
const FormContextProvider = _FormContext.Provider;
export { FieldSetContextProvider, FormContextProvider };
//# sourceMappingURL=FormContext.js.map