import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionProvider_mjs__ from "../../data-source/collection/CollectionProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_GeneralSchemaDesigner_mjs__ from "../../schema-settings/GeneralSchemaDesigner.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_templates_index_mjs__ from "../../schema-templates/index.mjs";
const BlockSchemaToolbar = (props)=>{
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
    const collecttion = (0, __WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionProvider_mjs__.useCollection)();
    let { name: currentCollectionName, title: currentCollectionTitle } = collecttion || {};
    const template = (0, __WEBPACK_EXTERNAL_MODULE__schema_templates_index_mjs__.useSchemaTemplate)();
    const { association } = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useDataBlockProps)() || {};
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
    if (association) {
        const [collectionName] = association.split('.');
        const { name, title } = cm.getCollection(collectionName);
        currentCollectionName = name;
        currentCollectionTitle = title;
    }
    const associationField = cm.getCollectionField(association);
    const templateName = [
        'FormItem',
        'ReadPrettyFormItem'
    ].includes(null == template ? void 0 : template.componentName) ? "".concat(null == template ? void 0 : template.name, " ").concat(t('(Fields only)')) : null == template ? void 0 : template.name;
    const toolbarTitle = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
            getCollectionTitle({
                collectionTitle: currentCollectionTitle,
                collectionName: currentCollectionName,
                associationField,
                compile
            }),
            templateName
        ].filter(Boolean), [
        compile,
        currentCollectionTitle,
        currentCollectionName,
        associationField,
        templateName
    ]);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_GeneralSchemaDesigner_mjs__.SchemaToolbar, {
        title: toolbarTitle,
        ...props
    });
};
function getCollectionTitle(props) {
    const { collectionTitle, collectionName, associationField, compile } = props;
    if (associationField) {
        var _associationField_uiSchema;
        return "".concat(compile(collectionTitle || collectionName), " > ").concat(compile((null === (_associationField_uiSchema = associationField.uiSchema) || void 0 === _associationField_uiSchema ? void 0 : _associationField_uiSchema.title) || associationField.name));
    }
    return collectionTitle || collectionName;
}
export { BlockSchemaToolbar };
