import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__ant_design_icons__ from "@ant-design/icons";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../../collection-manager/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_initializer_items_DataBlockInitializer_mjs__ from "../../../../schema-initializer/items/DataBlockInitializer.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__createGridCardBlockUISchema_mjs__ from "./createGridCardBlockUISchema.mjs";
const GridCardBlockInitializer = (param)=>{
    let { filterCollections, onlyCurrentDataSource, hideSearch, createBlockSchema, componentType = 'FormItem', templateWrap, showAssociationFields } = param;
    const itemConfig = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaInitializerItem)();
    const { createGridCardBlock } = useCreateGridCardBlock();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_initializer_items_DataBlockInitializer_mjs__.DataBlockInitializer, {
        ...itemConfig,
        icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.OrderedListOutlined, {}),
        componentType: 'GridCard',
        onCreateBlockSchema: async (options)=>{
            if (createBlockSchema) return createBlockSchema(options);
            createGridCardBlock(options);
        },
        onlyCurrentDataSource: onlyCurrentDataSource,
        hideSearch: hideSearch,
        filter: filterCollections,
        showAssociationFields: showAssociationFields
    });
};
const useCreateGridCardBlock = ()=>{
    const { insert } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaInitializer)();
    const { getCollection } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const createGridCardBlock = (param)=>{
        let { item } = param;
        const collection = getCollection(item.name, item.dataSource);
        const schema = (0, __WEBPACK_EXTERNAL_MODULE__createGridCardBlockUISchema_mjs__.createGridCardBlockUISchema)({
            collectionName: item.name,
            dataSource: item.dataSource,
            rowKey: collection.filterTargetKey || 'id'
        });
        insert(schema);
    };
    return {
        createGridCardBlock
    };
};
export { GridCardBlockInitializer, useCreateGridCardBlock };
