function getInitializerItemsByFields(props, fields, context) {
    var _actionContext_fieldSchema;
    const { block, isReadPretty = (param)=>{
        let { form } = param;
        return form.readPretty;
    }, filter = ()=>true, getInitializerItem = ()=>({}), getSchema = ()=>({}) } = props;
    const { collectionManager, collection, dataSourceManager, actionContext } = context;
    const action = null === (_actionContext_fieldSchema = actionContext.fieldSchema) || void 0 === _actionContext_fieldSchema ? void 0 : _actionContext_fieldSchema['x-action'];
    if (!collection) return [];
    return fields.map((collectionField)=>{
        const targetCollection = collectionManager.getCollection(collectionField.target);
        const collectionFieldInterface = dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(collectionField.interface);
        return {
            collectionField,
            context: {
                ...context,
                targetCollection,
                collectionFieldInterface
            }
        };
    }).filter((param)=>{
        let { collectionField } = param;
        return collectionField.interface;
    }).filter((param)=>{
        let { collectionField, context } = param;
        return filter(collectionField, context);
    }).map((param)=>{
        let { collectionField, context } = param;
        var _collectionField_uiSchema, _collectionField_uiSchema1;
        const defaultSchema = {
            type: 'string',
            title: (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.title) || collectionField.name,
            name: collectionField.name,
            'x-component': 'CollectionField',
            'x-collection-field': "".concat(collection.name, ".").concat(collectionField.name),
            'x-read-pretty': null == collectionField ? void 0 : null === (_collectionField_uiSchema1 = collectionField.uiSchema) || void 0 === _collectionField_uiSchema1 ? void 0 : _collectionField_uiSchema1['x-read-pretty']
        };
        const customSchema = getSchema(collectionField, {
            ...context,
            defaultSchema: defaultSchema
        });
        const schema = {
            ...defaultSchema,
            ...customSchema || {}
        };
        return {
            collectionField,
            schema,
            context: {
                ...context,
                schema
            }
        };
    }).map((param)=>{
        let { collectionField, context } = param;
        var _collectionField_uiSchema;
        const defaultInitializerItem = {
            type: 'item',
            name: collectionField.name,
            title: (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.title) || collectionField.name,
            Component: 'CollectionFieldInitializer',
            schemaInitialize: (s)=>{
                var _context_collectionFieldInterface_schemaInitialize, _context_collectionFieldInterface;
                null === (_context_collectionFieldInterface = context.collectionFieldInterface) || void 0 === _context_collectionFieldInterface || null === (_context_collectionFieldInterface_schemaInitialize = _context_collectionFieldInterface.schemaInitialize) || void 0 === _context_collectionFieldInterface_schemaInitialize || _context_collectionFieldInterface_schemaInitialize.call(_context_collectionFieldInterface, s, {
                    field: collectionField,
                    block,
                    readPretty: null == isReadPretty ? void 0 : isReadPretty(context),
                    action,
                    targetCollection: context.targetCollection
                });
            },
            schema: context.schema
        };
        return {
            collectionField,
            context,
            defaultInitializerItem
        };
    }).map((param)=>{
        let { collectionField, defaultInitializerItem, context } = param;
        const customInitializerItem = getInitializerItem(collectionField, {
            ...context,
            defaultInitializerItem
        });
        return {
            ...defaultInitializerItem,
            ...customInitializerItem || {}
        };
    });
}
export { getInitializerItemsByFields };
