"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__, {
    createModalSettingsItem: ()=>createModalSettingsItem
});
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("../../schema-component/index.js");
const external_util_js_namespaceObject = require("./util.js");
function createModalSettingsItem(options) {
    const { name, parentSchemaKey, valueKeys, schema, title, useSubmit = external_util_js_namespaceObject.useHookDefault, useVisible, defaultValue: propsDefaultValue, useDefaultValue = external_util_js_namespaceObject.useHookDefault, width, type = 'common' } = options;
    return {
        name,
        type: 'actionModal',
        useVisible,
        useComponentProps () {
            const fieldSchema = (0, external_util_js_namespaceObject.useSchemaByType)(type);
            const { dn } = (0, index_js_namespaceObject.useDesignable)();
            const defaultValue = useDefaultValue(propsDefaultValue);
            const values = parentSchemaKey ? external_lodash_default().get(fieldSchema, parentSchemaKey) : void 0;
            const compile = (0, index_js_namespaceObject.useCompile)();
            const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
            const onSubmit = useSubmit();
            const { fieldSchema: tableColumnSchema } = (0, index_js_namespaceObject.useColumnSchema)() || {};
            return {
                title: 'function' == typeof title ? title(t) : compile(title),
                width,
                schema: schema({
                    ...defaultValue,
                    ...values
                }),
                onSubmit (values) {
                    const newSchema = (0, external_util_js_namespaceObject.getNewSchema)({
                        fieldSchema,
                        parentSchemaKey: parentSchemaKey,
                        value: values,
                        valueKeys
                    });
                    if (tableColumnSchema) {
                        dn.emit('patch', {
                            schema: newSchema
                        });
                        dn.refresh();
                    } else dn.deepMerge(newSchema);
                    return null == onSubmit ? void 0 : onSubmit(values);
                }
            };
        }
    };
}
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
});
