import { jsx } from "react/jsx-runtime";
import { memo, useContext, useMemo } from "react";
import { ExpressionScope, SchemaComponentsContext, SchemaOptionsContext } from "@tachybase/schema";
const useSchemaOptionsContext = ()=>{
    const options = useContext(SchemaOptionsContext);
    return options || {};
};
const SchemaComponentOptions = /*#__PURE__*/ memo((props)=>{
    const { children } = props;
    const options = useSchemaOptionsContext();
    const components = useMemo(()=>({
            ...options.components,
            ...props.components
        }), [
        options.components,
        props.components
    ]);
    const scope = useMemo(()=>({
            ...options.scope,
            ...props.scope
        }), [
        options.scope,
        props.scope
    ]);
    const schemaOptionsContextValue = useMemo(()=>({
            scope,
            components
        }), [
        scope,
        components
    ]);
    return /*#__PURE__*/ jsx(SchemaOptionsContext.Provider, {
        value: schemaOptionsContextValue,
        children: /*#__PURE__*/ jsx(SchemaComponentsContext.Provider, {
            value: components,
            children: /*#__PURE__*/ jsx(ExpressionScope, {
                value: scope,
                children: children
            })
        })
    });
});
SchemaComponentOptions.displayName = 'SchemaComponentOptions';
export { SchemaComponentOptions, useSchemaOptionsContext };
