import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_FormItem_Settings_mjs__ from "../schema-component/antd/form-item/FormItem.Settings.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_table_v2_Table_Column_Decorator_mjs__ from "../schema-component/antd/table-v2/Table.Column.Decorator.mjs";
function useFieldComponentName() {
    var _fieldSchema_xcomponentprops, _field_componentProps, _collectionField_uiSchema, _fieldSchema_xcomponentprops1;
    const { fieldSchema: tableColumnSchema, collectionField: tableColumnField } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
    const isFileField = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_FormItem_Settings_mjs__.useIsFileField)();
    const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const targetCollectionField = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionField)();
    const targetCollection = cm.getCollection(null == targetCollectionField ? void 0 : targetCollectionField.target);
    const isTreeCollection = (null == targetCollection ? void 0 : targetCollection.template) === 'tree';
    const fieldSchema = tableColumnSchema || schema;
    const collectionField = tableColumnField || targetCollectionField;
    const map = {
        AssociationField: isTreeCollection ? 'Cascader' : 'Select'
    };
    const fieldComponentName = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['mode']) || (null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps['mode']) || (isFileField ? 'FileManager' : '') || (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema['x-component']);
    return map[fieldComponentName] || fieldComponentName || (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['component']);
}
export { useFieldComponentName };
