import { jsx } from "react/jsx-runtime";
import { useMemo } from "react";
import { useComponent, useDesignable } from "../../../schema-component/index.mjs";
import { SchemaToolbar } from "../../../schema-settings/GeneralSchemaDesigner.mjs";
const useSchemaToolbarRender = (fieldSchema)=>{
    const { designable } = useDesignable();
    const toolbar = useMemo(()=>{
        if (fieldSchema['x-toolbar'] || fieldSchema['x-designer']) return fieldSchema['x-toolbar'] || fieldSchema['x-designer'];
        if (fieldSchema['x-settings']) return SchemaToolbar;
    }, [
        fieldSchema
    ]);
    const C = useComponent(toolbar);
    return {
        render (props) {
            if (!designable || !C) return null;
            return /*#__PURE__*/ jsx(C, {
                ...fieldSchema['x-toolbar-props'],
                ...props
            });
        },
        exists: !!C
    };
};
export { useSchemaToolbarRender };
