import { useFieldSchema } from "@tachybase/schema";
import { useTranslation } from "react-i18next";
import { SchemaSettings } from "../../../../application/schema-settings/SchemaSettings.mjs";
import { useCollection } from "../../../../data-source/index.mjs";
import { FilterBlockType } from "../../../../filter-provider/index.mjs";
import { SchemaSettingsBlockTitleItem, SchemaSettingsConnectDataBlocks, SchemaSettingsFormItemTemplate, SchemaSettingsLinkageRules } from "../../../../schema-settings/index.mjs";
const filterTreeBlockSettings = new SchemaSettings({
    name: 'blockSettings:filterTree',
    items: [
        {
            name: 'title',
            Component: SchemaSettingsBlockTitleItem
        },
        {
            name: 'formItemTemplate',
            Component: SchemaSettingsFormItemTemplate,
            useComponentProps () {
                var _fieldSchema_xdecoratorprops, _fieldSchema_xdecoratorprops1;
                const { name } = useCollection();
                const fieldSchema = useFieldSchema();
                const defaultResource = (null == fieldSchema ? void 0 : null == (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) ? void 0 : _fieldSchema_xdecoratorprops.resource) || (null == fieldSchema ? void 0 : null == (_fieldSchema_xdecoratorprops1 = fieldSchema['x-decorator-props']) ? void 0 : _fieldSchema_xdecoratorprops1.association);
                return {
                    componentName: 'FilterFormItem',
                    collectionName: name,
                    resourceName: defaultResource
                };
            }
        },
        {
            name: 'linkageRules',
            Component: SchemaSettingsLinkageRules,
            useComponentProps () {
                const { name } = useCollection();
                return {
                    collectionName: name
                };
            }
        },
        {
            name: 'connectDataBlocks',
            Component: SchemaSettingsConnectDataBlocks,
            useComponentProps () {
                const { t } = useTranslation();
                return {
                    type: FilterBlockType.TREE,
                    emptyDescription: t('No blocks to connect')
                };
            }
        },
        {
            name: 'divider',
            type: 'divider'
        },
        {
            name: 'remove',
            type: 'remove',
            componentProps: {
                removeParentsIfNoChildren: true,
                breakRemoveOn: {
                    'x-component': 'Grid'
                }
            }
        }
    ]
});
export { filterTreeBlockSettings };
