import { useMemo } from "react";
import { useSchemaToolbar } from "../../../application/index.mjs";
import { SchemaSettings } from "../../../application/schema-settings/SchemaSettings.mjs";
import { useCollectionManager_deprecated, useCollection_deprecated } from "../../../collection-manager/index.mjs";
import { ButtonEditor, RemoveButton } from "../../../schema-component/antd/action/Action.Designer.mjs";
import { SchemaSettingOpenModeSchemaItems } from "../../../schema-items/index.mjs";
import { SchemaSettingsEnableChildCollections } from "../../../schema-settings/SchemaSettings.mjs";
const associateActionSettings = new SchemaSettings({
    name: 'actionSettings:associate',
    items: [
        {
            name: 'editButton',
            Component: ButtonEditor,
            useComponentProps () {
                const { buttonEditorProps } = useSchemaToolbar();
                return buttonEditorProps;
            }
        },
        {
            name: 'openMode',
            Component: SchemaSettingOpenModeSchemaItems,
            componentProps: {
                openMode: true,
                openSize: true
            }
        },
        {
            name: 'enableChildCollections',
            Component: SchemaSettingsEnableChildCollections,
            useComponentProps () {
                const { name } = useCollection_deprecated();
                return {
                    collectionName: name
                };
            },
            useVisible () {
                const { name } = useCollection_deprecated();
                const { getChildrenCollections } = useCollectionManager_deprecated();
                const isChildCollectionAction = useMemo(()=>getChildrenCollections(name).length > 0, [
                    getChildrenCollections,
                    name
                ]);
                return isChildCollectionAction;
            }
        },
        {
            name: 'delete',
            sort: 100,
            Component: RemoveButton,
            useComponentProps () {
                const { removeButtonProps } = useSchemaToolbar();
                return removeButtonProps;
            }
        }
    ]
});
export { associateActionSettings };
