import { jsx } from "react/jsx-runtime";
import "react";
import { merge } from "@tachybase/schema";
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from "../../application/index.mjs";
const BlockInitializer = (props)=>{
    const { item, schema, ...others } = props;
    const { insert } = useSchemaInitializer();
    return /*#__PURE__*/ jsx(SchemaInitializerItem, {
        ...others,
        onClick: ()=>{
            var _item_schemaInitialize, _props_onClick;
            const s = merge(schema || {}, item.schema || {});
            null == item || null == (_item_schemaInitialize = item.schemaInitialize) || _item_schemaInitialize.call(item, s);
            insert(s);
            null == (_props_onClick = props.onClick) || _props_onClick.call(props, s);
        }
    });
};
const BlockItemInitializer = ()=>{
    const itemConfig = useSchemaInitializerItem();
    const { schema, ...others } = itemConfig;
    return /*#__PURE__*/ jsx(BlockInitializer, {
        ...others,
        item: itemConfig
    });
};
export { BlockInitializer, BlockItemInitializer };
