"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    CollectionDeletedPlaceholder: ()=>CollectionDeletedPlaceholder
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const DataSourceManager_js_namespaceObject = require("../data-source/DataSourceManager.js");
const index_js_namespaceObject = require("../../schema-component/index.js");
const external_collection_index_js_namespaceObject = require("../collection/index.js");
const external_data_source_index_js_namespaceObject = require("../data-source/index.js");
const DataSourceProvider_js_namespaceObject = require("../data-source/DataSourceProvider.js");
const { Text } = external_antd_namespaceObject.Typography;
const CollectionDeletedPlaceholder = (param)=>{
    let { type, name, message } = param;
    const { designable, dn } = (0, index_js_namespaceObject.useDesignable)();
    const { modal } = external_antd_namespaceObject.App.useApp();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const dataSource = (0, DataSourceProvider_js_namespaceObject.useDataSource)();
    const compile = (0, index_js_namespaceObject.useCompile)();
    const collection = (0, external_collection_index_js_namespaceObject.useCollection)();
    const dataSourceManager = (0, external_data_source_index_js_namespaceObject.useDataSourceManager)();
    const nameValue = (0, external_react_namespaceObject.useMemo)(()=>{
        if ('DataSource' === type) return name;
        const dataSourcePrefix = (null == dataSourceManager ? void 0 : dataSourceManager.getDataSources().length) >= 1 && dataSource && dataSource.key !== DataSourceManager_js_namespaceObject.DEFAULT_DATA_SOURCE_KEY ? "".concat(compile(dataSource.displayName || dataSource.key), " > ") : '';
        if ('Collection' === type) return "".concat(dataSourcePrefix).concat(name);
        const collectionPrefix = collection ? "".concat(compile(collection.title) || collection.name || collection.tableName, " > ") : '';
        return "".concat(dataSourcePrefix).concat(collectionPrefix).concat(name);
    }, []);
    const blockType = (0, external_react_namespaceObject.useMemo)(()=>{
        if ('Field' === type) return 'Field';
        return 'Block';
    }, [
        type
    ]);
    const messageValue = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!name) return "".concat(t(type), " ", 'name is required');
        if (message) return "".concat(t(type), ' "').concat(nameValue, '" ').concat(message);
        return t('The {{type}} "{{name}}" may have been deleted. Please remove this {{blockType}}.', {
            type: t(type).toLocaleLowerCase(),
            name: nameValue,
            blockType: t(blockType)
        }).replaceAll('&gt;', '>');
    }, [
        message,
        nameValue,
        type,
        t,
        blockType
    ]);
    if (designable) {
        if ('Field' === type) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.EllipsisWithTooltip, {
            ellipsis: true,
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Text, {
                type: "secondary",
                children: messageValue
            })
        });
        return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.CardItem, {
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Result, {
                status: "404",
                subTitle: messageValue,
                extra: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
                    onClick: ()=>modal.confirm({
                            title: t('Delete block'),
                            content: t('Are you sure you want to delete it?'),
                            ...confirm,
                            onOk () {
                                dn.remove(null, {
                                    removeParentsIfNoChildren: true,
                                    breakRemoveOn: {
                                        'x-component': 'Grid'
                                    }
                                });
                            }
                        }),
                    children: t('Delete')
                }, "Delete")
            })
        });
    }
    return null;
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
