"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__, {
    generalSettingsItems: ()=>generalSettingsItems
});
const schema_namespaceObject = require("@tachybase/schema");
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../application/schema-toolbar/index.js");
const external_collection_manager_index_js_namespaceObject = require("../collection-manager/index.js");
const external_schema_component_index_js_namespaceObject = require("../schema-component/index.js");
const SchemaSettingsDefaultValue_js_namespaceObject = require("../schema-settings/SchemaSettingsDefaultValue.js");
const generalSettingsItems = [
    {
        name: 'editFieldTitle',
        type: 'modal',
        useComponentProps () {
            var _collectionField_uiSchema;
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
            const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
            const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
            return {
                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();
                }
            };
        },
        useVisible () {
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            const { getCollectionJoinField } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
            const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
            const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
            return !!collectionField;
        }
    },
    {
        name: 'displayTitle',
        type: 'switch',
        useComponentProps () {
            var _fieldSchema_xdecoratorprops;
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            var _fieldSchema_xdecoratorprops_showTitle;
            return {
                title: t('Display title'),
                checked: null === (_fieldSchema_xdecoratorprops_showTitle = null === (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) || void 0 === _fieldSchema_xdecoratorprops ? void 0 : _fieldSchema_xdecoratorprops['showTitle']) || void 0 === _fieldSchema_xdecoratorprops_showTitle || _fieldSchema_xdecoratorprops_showTitle,
                onChange (checked) {
                    fieldSchema['x-decorator-props'] = fieldSchema['x-decorator-props'] || {};
                    fieldSchema['x-decorator-props']['showTitle'] = checked;
                    field.decoratorProps.showTitle = checked;
                    dn.emit('patch', {
                        schema: {
                            'x-uid': fieldSchema['x-uid'],
                            'x-decorator-props': {
                                ...fieldSchema['x-decorator-props'],
                                showTitle: checked
                            }
                        }
                    });
                    dn.refresh();
                }
            };
        }
    },
    {
        name: 'editDescription',
        type: 'modal',
        useComponentProps () {
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            return {
                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();
                }
            };
        },
        useVisible () {
            const field = (0, schema_namespaceObject.useField)();
            return !field.readPretty;
        }
    },
    {
        name: 'editTooltip',
        type: 'modal',
        useComponentProps () {
            var _fieldSchema_xdecoratorprops;
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            return {
                title: t('Edit tooltip'),
                schema: {
                    type: 'object',
                    title: t('Edit tooltip'),
                    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();
                }
            };
        },
        useVisible () {
            const field = (0, schema_namespaceObject.useField)();
            return field.readPretty;
        }
    },
    {
        name: 'required',
        type: 'switch',
        useComponentProps () {
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            const { dn, refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
            return {
                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();
                }
            };
        },
        useVisible () {
            const field = (0, schema_namespaceObject.useField)();
            const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
            const { required = true } = (0, index_js_namespaceObject.useSchemaToolbar)();
            return !field.readPretty && 'FormField' !== fieldSchema['x-component'] && required;
        }
    },
    {
        name: 'editDefaultValue',
        Component: SchemaSettingsDefaultValue_js_namespaceObject.SchemaSettingsDefaultValue
    }
];
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
});
