"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __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__, {
    EditRequired: ()=>EditRequired,
    EditDescription: ()=>EditDescription,
    EditValidationRules: ()=>EditValidationRules,
    EditComponent: ()=>EditComponent,
    findFilterOperators: ()=>findFilterOperators,
    EditTooltip: ()=>EditTooltip,
    useEnsureOperatorsValid: ()=>useEnsureOperatorsValid,
    EditTitleField: ()=>EditTitleField,
    EditPattern: ()=>EditPattern,
    EditTitle: ()=>EditTitle,
    EditOperator: ()=>EditOperator,
    EditDefaultValue: ()=>EditDefaultValue
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const components_namespaceObject = require("@tachybase/components");
const schema_namespaceObject = require("@tachybase/schema");
const external_lodash_namespaceObject = require("lodash");
var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../../block-provider/index.js");
const external_collection_manager_index_js_namespaceObject = require("../../../collection-manager/index.js");
const external_schema_settings_index_js_namespaceObject = require("../../../schema-settings/index.js");
const isPatternDisabled_js_namespaceObject = require("../../../schema-settings/isPatternDisabled.js");
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
const useOperators_js_namespaceObject = require("../filter/useOperators.js");
const external_FormItem_js_namespaceObject = require("./FormItem.js");
const findFilterOperators = (schema)=>{
    while(schema){
        if (schema['x-filter-operators']) return {
            operators: schema['x-filter-operators'],
            uid: schema['x-uid']
        };
        schema = schema.parent;
    }
    return {};
};
const EditTitle = ()=>{
    var _collectionField_uiSchema;
    const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    return collectionField ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Edit field title'),
        schema: {
            type: 'object',
            title: t('Edit field title'),
            properties: {
                title: {
                    title: t('Field title'),
                    default: null == field ? void 0 : field.title,
                    description: "".concat(t('Original field title: ')).concat(null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.title),
                    'x-decorator': 'FormItem',
                    'x-component': 'Input',
                    'x-component-props': {}
                }
            }
        },
        onSubmit: (param)=>{
            let { title } = param;
            if (title) {
                field.title = title;
                fieldSchema.title = title;
                dn.emit('patch', {
                    schema: {
                        'x-uid': fieldSchema['x-uid'],
                        title: fieldSchema.title
                    }
                });
            }
            dn.refresh();
        }
    }, "edit-field-title") : null;
};
const EditDescription = ()=>{
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    return field.readPretty ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Edit description'),
        schema: {
            type: 'object',
            title: t('Edit description'),
            properties: {
                description: {
                    default: null == field ? void 0 : field.description,
                    'x-decorator': 'FormItem',
                    'x-component': 'Input.TextArea',
                    'x-component-props': {}
                }
            }
        },
        onSubmit: (param)=>{
            let { description } = param;
            field.description = description;
            fieldSchema.description = description;
            dn.emit('patch', {
                schema: {
                    'x-uid': fieldSchema['x-uid'],
                    description: fieldSchema.description
                }
            });
            dn.refresh();
        }
    }, "edit-description");
};
const EditTooltip = ()=>{
    var _fieldSchema_xdecoratorprops;
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    return field.readPretty ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Edit tooltip'),
        schema: {
            type: 'object',
            title: t('Edit description'),
            properties: {
                tooltip: {
                    default: null == fieldSchema ? void 0 : null === (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) || void 0 === _fieldSchema_xdecoratorprops ? void 0 : _fieldSchema_xdecoratorprops.tooltip,
                    'x-decorator': 'FormItem',
                    'x-component': 'Input.TextArea',
                    'x-component-props': {}
                }
            }
        },
        onSubmit: (param)=>{
            let { tooltip } = param;
            field.decoratorProps.tooltip = tooltip;
            fieldSchema['x-decorator-props'] = fieldSchema['x-decorator-props'] || {};
            fieldSchema['x-decorator-props']['tooltip'] = tooltip;
            dn.emit('patch', {
                schema: {
                    'x-uid': fieldSchema['x-uid'],
                    'x-decorator-props': fieldSchema['x-decorator-props']
                }
            });
            dn.refresh();
        }
    }, "edit-tooltip") : null;
};
const EditRequired = ()=>{
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn, refresh } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    return field.readPretty || 'FormField' === fieldSchema['x-component'] ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSwitchItem, {
        title: t('Required'),
        checked: fieldSchema.required,
        onChange: (required)=>{
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            field.required = required;
            fieldSchema['required'] = required;
            schema['required'] = required;
            dn.emit('patch', {
                schema
            });
            refresh();
        }
    }, "required");
};
const EditValidationRules = ()=>{
    var _interfaceConfig_validateSchema;
    const { getInterface, getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const { form } = (0, index_js_namespaceObject.useFormBlockContext)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn, refresh } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    const interfaceConfig = getInterface(null == collectionField ? void 0 : collectionField.interface);
    const validateSchema = null == interfaceConfig ? void 0 : null === (_interfaceConfig_validateSchema = interfaceConfig['validateSchema']) || void 0 === _interfaceConfig_validateSchema ? void 0 : _interfaceConfig_validateSchema.call(interfaceConfig, fieldSchema);
    return form && !(null == form ? void 0 : form.readPretty) && validateSchema ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Set validation rules'),
        components: {
            ArrayCollapse: components_namespaceObject.ArrayCollapse,
            FormLayout: components_namespaceObject.FormLayout
        },
        schema: {
            type: 'object',
            title: t('Set validation rules'),
            properties: {
                rules: {
                    type: 'array',
                    default: null == fieldSchema ? void 0 : fieldSchema['x-validator'],
                    'x-component': 'ArrayCollapse',
                    'x-decorator': 'FormItem',
                    'x-component-props': {
                        accordion: true
                    },
                    maxItems: 3,
                    items: {
                        type: 'object',
                        'x-component': 'ArrayCollapse.CollapsePanel',
                        'x-component-props': {
                            header: '{{ t("Validation rule") }}'
                        },
                        properties: {
                            index: {
                                type: 'void',
                                'x-component': 'ArrayCollapse.Index'
                            },
                            layout: {
                                type: 'void',
                                'x-component': 'FormLayout',
                                'x-component-props': {
                                    labelStyle: {
                                        marginTop: '6px'
                                    },
                                    labelCol: 8,
                                    wrapperCol: 16
                                },
                                properties: {
                                    ...validateSchema,
                                    message: {
                                        type: 'string',
                                        title: '{{ t("Error message") }}',
                                        'x-decorator': 'FormItem',
                                        'x-component': 'Input.TextArea',
                                        'x-component-props': {
                                            autoSize: {
                                                minRows: 2,
                                                maxRows: 2
                                            }
                                        }
                                    }
                                }
                            },
                            remove: {
                                type: 'void',
                                'x-component': 'ArrayCollapse.Remove'
                            },
                            moveUp: {
                                type: 'void',
                                'x-component': 'ArrayCollapse.MoveUp'
                            },
                            moveDown: {
                                type: 'void',
                                'x-component': 'ArrayCollapse.MoveDown'
                            }
                        }
                    },
                    properties: {
                        add: {
                            type: 'void',
                            title: '{{ t("Add validation rule") }}',
                            'x-component': 'ArrayCollapse.Addition',
                            'x-reactions': {
                                dependencies: [
                                    'rules'
                                ],
                                fulfill: {
                                    state: {
                                        disabled: '{{$deps[0].length >= 3}}'
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        onSubmit: (v)=>{
            var _collectionField_uiSchema;
            const rules = [];
            for (const rule of v.rules)rules.push(external_lodash_default().pickBy(rule, external_lodash_default().identity));
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            if ([
                'percent'
            ].includes(null == collectionField ? void 0 : collectionField.interface)) for (const rule of rules){
                if (!!rule.maxValue || !!rule.minValue) rule['percentMode'] = true;
                if (rule.percentFormat) rule['percentFormats'] = true;
            }
            const concatValidator = external_lodash_default().concat([], (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema['x-validator']) || [], rules);
            field.validator = concatValidator;
            fieldSchema['x-validator'] = rules;
            schema['x-validator'] = rules;
            dn.emit('patch', {
                schema
            });
            refresh();
        }
    }) : null;
};
const EditDefaultValue = ()=>{
    var _collectionField_uiSchema;
    const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const { form } = (0, index_js_namespaceObject.useFormBlockContext)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn, refresh } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    return form && !(null == form ? void 0 : form.readPretty) && (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema.type) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Set default value'),
        components: {
            ArrayCollapse: components_namespaceObject.ArrayCollapse,
            FormLayout: components_namespaceObject.FormLayout
        },
        schema: {
            type: 'object',
            title: t('Set default value'),
            properties: {
                default: {
                    ...null == collectionField ? void 0 : collectionField.uiSchema,
                    name: 'default',
                    title: t('Default value'),
                    'x-decorator': 'FormItem',
                    default: fieldSchema.default || (null == collectionField ? void 0 : collectionField.defaultValue)
                }
            }
        },
        onSubmit: (v)=>{
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            if (field.value !== v.default) field.value = v.default;
            fieldSchema.default = v.default;
            schema.default = v.default;
            dn.emit('patch', {
                schema
            });
            refresh();
        }
    }) : null;
};
const EditComponent = ()=>{
    var _field_componentProps;
    const { getCollectionJoinField, getCollection } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    const fieldModeOptions = (0, external_hooks_index_js_namespaceObject.useFieldModeOptions)();
    const isAssociationField = [
        'belongsTo',
        'hasOne',
        'hasMany',
        'belongsToMany'
    ].includes(null == collectionField ? void 0 : collectionField.type);
    const targetCollection = getCollection(null == collectionField ? void 0 : collectionField.target);
    const isFileField = (0, external_FormItem_js_namespaceObject.isFileCollection)(targetCollection);
    return isAssociationField && fieldModeOptions ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
        title: t('Field component'),
        options: fieldModeOptions,
        value: (null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps['mode']) || (isFileField ? 'FileManager' : 'Select'),
        onChange: (mode)=>{
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
            fieldSchema['x-component-props']['mode'] = mode;
            schema['x-component-props'] = fieldSchema['x-component-props'];
            field.componentProps = field.componentProps || {};
            field.componentProps.mode = mode;
            dn.emit('patch', {
                schema
            });
            dn.refresh();
        }
    }, "field-mode") : null;
};
const EditPattern = ()=>{
    const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const { form } = (0, index_js_namespaceObject.useFormBlockContext)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    let readOnlyMode = 'editable';
    if (true === fieldSchema['x-disabled']) readOnlyMode = 'readonly';
    if (true === fieldSchema['x-read-pretty']) readOnlyMode = 'read-pretty';
    return !form || (null == form ? void 0 : form.readPretty) || (null == collectionField ? void 0 : collectionField.interface) === 'o2m' || (0, isPatternDisabled_js_namespaceObject.isPatternDisabled)(fieldSchema) ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
        title: t('Pattern'),
        options: [
            {
                label: t('Editable'),
                value: 'editable'
            },
            {
                label: t('Readonly'),
                value: 'readonly'
            },
            {
                label: t('Easy-reading'),
                value: 'read-pretty'
            }
        ],
        value: readOnlyMode,
        onChange: (v)=>{
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            switch(v){
                case 'readonly':
                    fieldSchema['x-read-pretty'] = false;
                    fieldSchema['x-disabled'] = true;
                    schema['x-read-pretty'] = false;
                    schema['x-disabled'] = true;
                    field.readPretty = false;
                    field.disabled = true;
                    break;
                case 'read-pretty':
                    fieldSchema['x-read-pretty'] = true;
                    fieldSchema['x-disabled'] = false;
                    schema['x-read-pretty'] = true;
                    schema['x-disabled'] = false;
                    field.readPretty = true;
                    break;
                default:
                    fieldSchema['x-read-pretty'] = false;
                    fieldSchema['x-disabled'] = false;
                    schema['x-read-pretty'] = false;
                    schema['x-disabled'] = false;
                    field.readPretty = false;
                    field.disabled = false;
                    break;
            }
            dn.emit('patch', {
                schema
            });
            dn.refresh();
        }
    }, "pattern");
};
const useEnsureOperatorsValid = ()=>{
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const operatorList = (0, useOperators_js_namespaceObject.useOperatorList)();
    const { operators: storedOperators } = findFilterOperators(fieldSchema);
    if (storedOperators && operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList[0].value;
};
const EditOperator = ()=>{
    const compile = (0, external_hooks_index_js_namespaceObject.useCompile)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const field = (0, schema_namespaceObject.useField)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const operatorList = (0, useOperators_js_namespaceObject.useOperatorList)();
    const { operators: storedOperators = {}, uid } = findFilterOperators(fieldSchema);
    if (operatorList.length && !storedOperators[fieldSchema.name]) storedOperators[fieldSchema.name] = operatorList[0].value;
    return operatorList.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
        title: t('Operator'),
        value: storedOperators[fieldSchema.name],
        options: compile(operatorList),
        onChange: (v)=>{
            var _operator_schema, _fieldSchema_xcomponentprops;
            storedOperators[fieldSchema.name] = v;
            const operator = operatorList.find((item)=>item.value === v);
            const schema = {
                ['x-uid']: uid,
                ['x-filter-operators']: storedOperators
            };
            let componentProps = {
                ...fieldSchema['x-component-props']
            };
            const isCustom = fieldSchema.name.includes('__custom');
            if (null == operator ? void 0 : null === (_operator_schema = operator.schema) || void 0 === _operator_schema ? void 0 : _operator_schema['x-component']) {
                var _operator_schema1;
                external_lodash_default().set(fieldSchema, isCustom ? 'x-component' : 'x-component-props.component', operator.schema['x-component']);
                external_lodash_default().set(field, isCustom ? 'component' : 'componentProps.component', operator.schema['x-component']);
                field.reset();
                componentProps = {
                    component: operator.schema['x-component'],
                    ...fieldSchema['x-component-props'],
                    ...null === (_operator_schema1 = operator.schema) || void 0 === _operator_schema1 ? void 0 : _operator_schema1['x-component-props']
                };
                const dnSchema = {
                    schema: {
                        ['x-uid']: fieldSchema['x-uid'],
                        ['x-component-props']: componentProps
                    }
                };
                if (isCustom) {
                    var _operator_schema2;
                    dnSchema.schema['x-component'] = null === (_operator_schema2 = operator.schema) || void 0 === _operator_schema2 ? void 0 : _operator_schema2['x-component'];
                    dnSchema.schema['x-component-props']['component'] = fieldSchema['x-component-props']['component'];
                }
                dn.emit('patch', dnSchema);
            } else if (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.component) {
                var _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2, _fieldSchema_xcomponentprops3, _operator_schema3;
                external_lodash_default().set(fieldSchema, isCustom ? 'x-component' : 'x-component-props.component', isCustom ? null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.component : null);
                external_lodash_default().set(field, isCustom ? 'component' : 'componentProps.component', isCustom ? null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2.component : null);
                field.reset();
                componentProps = {
                    component: isCustom ? null === (_fieldSchema_xcomponentprops3 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops3 ? void 0 : _fieldSchema_xcomponentprops3.component : null,
                    ...fieldSchema['x-component-props'],
                    ...null === (_operator_schema3 = operator.schema) || void 0 === _operator_schema3 ? void 0 : _operator_schema3['x-component-props']
                };
                const dnSchema = {
                    schema: {
                        ['x-uid']: fieldSchema['x-uid'],
                        ['x-component-props']: componentProps
                    }
                };
                if (isCustom) {
                    var _fieldSchema_xcomponentprops4;
                    dnSchema.schema['x-component'] = null === (_fieldSchema_xcomponentprops4 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops4 ? void 0 : _fieldSchema_xcomponentprops4.component;
                }
                dn.emit('patch', dnSchema);
            }
            field.componentProps = componentProps;
            dn.emit('patch', {
                schema
            });
            dn.refresh();
        }
    }, "operator") : null;
};
const EditTitleField = ()=>{
    var _fieldSchema_xcomponentprops_fieldNames, _fieldSchema_xcomponentprops;
    const { getCollectionFields, getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_hooks_index_js_namespaceObject.useDesignable)();
    const compile = (0, external_hooks_index_js_namespaceObject.useCompile)();
    const collectionManage = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    var _fieldSchema_name;
    const isCustomFilterItem = (null !== (_fieldSchema_name = null == fieldSchema ? void 0 : fieldSchema.name) && void 0 !== _fieldSchema_name ? _fieldSchema_name : '').startsWith('__custom.');
    const collectionManageField = isCustomFilterItem ? collectionManage.collections.filter((value)=>value.name === fieldSchema['x-decorator-props'])[0] : {};
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    let targetFields = [];
    if (collectionField) {
        var _getCollectionFields;
        targetFields = (null == collectionField ? void 0 : collectionField.target) ? getCollectionFields(null == collectionField ? void 0 : collectionField.target) : null !== (_getCollectionFields = getCollectionFields(null == collectionField ? void 0 : collectionField.targetCollection)) && void 0 !== _getCollectionFields ? _getCollectionFields : [];
    } else if (collectionManageField) targetFields = collectionManageField['fields'];
    const options = targetFields.filter((field)=>!(null == field ? void 0 : field.target) && 'boolean' !== field.type).map((field)=>{
        var _field_uiSchema;
        return {
            value: null == field ? void 0 : field.name,
            label: compile(null == field ? void 0 : null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : _field_uiSchema.title) || (null == field ? void 0 : field.name)
        };
    });
    return options.length > 0 && ('CollectionField' === fieldSchema['x-component'] || isCustomFilterItem) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
        title: t('Title field'),
        options: options,
        value: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : null === (_fieldSchema_xcomponentprops_fieldNames = _fieldSchema_xcomponentprops['fieldNames']) || void 0 === _fieldSchema_xcomponentprops_fieldNames ? void 0 : _fieldSchema_xcomponentprops_fieldNames.label) || 'id',
        onChange: (label)=>{
            var _collectionField_uiSchema_xcomponentprops, _collectionField_uiSchema;
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            const fieldNames = {
                ...null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : null === (_collectionField_uiSchema_xcomponentprops = _collectionField_uiSchema['x-component-props']) || void 0 === _collectionField_uiSchema_xcomponentprops ? void 0 : _collectionField_uiSchema_xcomponentprops['fieldNames'],
                ...field.componentProps.fieldNames,
                label
            };
            if (isCustomFilterItem) fieldNames['value'] = label;
            fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
            fieldSchema['x-component-props']['fieldNames'] = fieldNames;
            schema['x-component-props'] = fieldSchema['x-component-props'];
            field.componentProps = fieldSchema['x-component-props'];
            dn.emit('patch', {
                schema
            });
            dn.refresh();
        }
    }, "title-field") : 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
});
