import { jsx } from "react/jsx-runtime";
import { SchemaInitializerChildren } from "../../../application/schema-initializer/index.mjs";
import { getInitializerItemsByFields, useCollectionFieldContext } from "../utils/index.mjs";
const ParentCollectionFields = (props)=>{
    const context = useCollectionFieldContext();
    const { collection, t, collectionManager } = context;
    const parentCollectionNames = collection.getParentCollectionsName();
    if (!parentCollectionNames.length) return null;
    const children = parentCollectionNames.map((parentCollectionName)=>{
        const parentCollectionFields = collection.getParentCollectionFields(parentCollectionName);
        if (0 === parentCollectionFields.length) return null;
        const parentCollection = collectionManager.getCollection(parentCollectionName);
        return {
            parentCollection,
            parentCollectionFields
        };
    }).filter(Boolean).map((options)=>{
        const { parentCollection, parentCollectionFields } = options;
        const newContext = {
            ...context,
            collection: parentCollection
        };
        return {
            type: 'itemGroup',
            divider: true,
            title: t("Parent collection fields") + '(' + context.compile(parentCollection.title) + ')',
            children: getInitializerItemsByFields(props, parentCollectionFields, newContext)
        };
    });
    return /*#__PURE__*/ jsx(SchemaInitializerChildren, {
        children: children
    });
};
export { ParentCollectionFields };
