"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__, {
    CollectionFieldsToFormInitializerItems: ()=>CollectionFieldsToFormInitializerItems,
    findKanbanFormItem: ()=>findKanbanFormItem
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const utils_js_namespaceObject = require("../../schema-initializer/utils.js");
const external_CollectionFieldsToInitializerItems_js_namespaceObject = require("./CollectionFieldsToInitializerItems.js");
const findKanbanFormItem = (schema, key, action)=>{
    const s = (0, utils_js_namespaceObject.findSchema)(schema, 'x-component', 'Kanban');
    return (0, utils_js_namespaceObject.findSchema)(s, key, action);
};
const CollectionFieldsToFormInitializerItems = (props)=>{
    const block = (null == props ? void 0 : props.block) || 'Form';
    const fieldItemSchema = {
        'x-toolbar': 'FormItemSchemaToolbar',
        'x-settings': 'fieldSettings:FormItem',
        'x-decorator': 'FormItem'
    };
    const initializerItem = {
        remove: utils_js_namespaceObject.removeGridFormItem
    };
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CollectionFieldsToInitializerItems_js_namespaceObject.CollectionFieldsToInitializerItems, {
        block: block,
        selfField: {
            filter: (field)=>!field.treeChildren,
            getSchema: (field, param)=>{
                let { targetCollection } = param;
                var _field_uiSchema_xcomponentprops, _field_uiSchema;
                const isFileCollection = (null == targetCollection ? void 0 : targetCollection.template) === 'file';
                const isAssociationField = targetCollection;
                const fieldNames = null == field ? void 0 : null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : null === (_field_uiSchema_xcomponentprops = _field_uiSchema['x-component-props']) || void 0 === _field_uiSchema_xcomponentprops ? void 0 : _field_uiSchema_xcomponentprops['fieldNames'];
                return {
                    ...fieldItemSchema,
                    'x-component-props': isFileCollection ? {
                        fieldNames: {
                            label: 'preview',
                            value: 'id'
                        }
                    } : isAssociationField && fieldNames ? {
                        fieldNames: {
                            ...fieldNames,
                            label: (null == targetCollection ? void 0 : targetCollection.titleField) || fieldNames.label
                        }
                    } : {}
                };
            },
            getInitializerItem: ()=>({
                    ...initializerItem,
                    find: (null == props ? void 0 : props.block) === 'Kanban' ? findKanbanFormItem : void 0
                })
        },
        parentField: {
            getSchema: ()=>fieldItemSchema,
            getInitializerItem: ()=>initializerItem
        },
        associationField: {
            filterSelfField: (field)=>{
                if ('Form' !== block) return true;
                return (null == field ? void 0 : field.interface) === 'm2o';
            },
            filterAssociationField (collectionField) {
                return (null == collectionField ? void 0 : collectionField.interface) && ![
                    'subTable'
                ].includes(null == collectionField ? void 0 : collectionField.interface) && !collectionField.treeChildren;
            },
            getSchema: ()=>fieldItemSchema,
            getInitializerItem: ()=>initializerItem
        }
    });
};
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
});
