"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__, {
    SchemaSettingOpenModeSchemaItems: ()=>SchemaSettingOpenModeSchemaItems,
    SchemaInitializerOpenModeSchemaItems: ()=>SchemaInitializerOpenModeSchemaItems
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../application/index.js");
const external_schema_component_index_js_namespaceObject = require("../schema-component/index.js");
const external_schema_settings_index_js_namespaceObject = require("../schema-settings/index.js");
const SchemaInitializerOpenModeSchemaItems = (options)=>{
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2;
    const { openMode = true, openSize = true } = options;
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const field = (0, schema_namespaceObject.useField)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
    const openModeValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['openMode']) || 'drawer';
    var _fieldSchema_xcomponentprops_openSize;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            openMode ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.SchemaInitializerSelect, {
                title: t('Open mode'),
                options: [
                    {
                        label: t('Drawer'),
                        value: 'drawer'
                    },
                    {
                        label: t('Dialog'),
                        value: 'modal'
                    }
                ],
                value: openModeValue,
                onChange: (value)=>{
                    field.componentProps.openMode = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openMode = value;
                    fieldSchema['x-component-props'].openMode = value;
                    Reflect.deleteProperty(fieldSchema['x-component-props'], 'openSize');
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : null,
            openSize && [
                'modal',
                'drawer'
            ].includes(openModeValue) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.SchemaInitializerItem, {
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                    style: {
                        alignItems: 'center',
                        display: 'flex',
                        justifyContent: 'space-between'
                    },
                    children: [
                        t('Popup size'),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Select, {
                            "data-testid": "antd-select",
                            bordered: false,
                            options: [
                                {
                                    label: t('Small'),
                                    value: 'small'
                                },
                                {
                                    label: t('Middle'),
                                    value: 'middle'
                                },
                                {
                                    label: t('Large'),
                                    value: 'large'
                                }
                            ],
                            value: null !== (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['openSize']) && void 0 !== _fieldSchema_xcomponentprops_openSize ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2['openMode']) == 'modal' ? 'large' : 'middle',
                            onChange: (value)=>{
                                field.componentProps.openSize = value;
                                const schema = {
                                    'x-uid': fieldSchema['x-uid']
                                };
                                schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                                schema['x-component-props'].openSize = value;
                                fieldSchema['x-component-props'].openSize = value;
                                dn.emit('patch', {
                                    schema: schema
                                });
                                dn.refresh();
                            },
                            style: {
                                textAlign: 'right',
                                minWidth: 100
                            }
                        })
                    ]
                })
            }) : null
        ]
    });
};
const SchemaSettingOpenModeSchemaItems = (options)=>{
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2;
    const { openMode = true, openSize = true } = options;
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const field = (0, schema_namespaceObject.useField)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
    const openModeValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['openMode']) || 'drawer';
    var _fieldSchema_xcomponentprops_openSize;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            openMode ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
                title: t('Open mode'),
                options: [
                    {
                        label: t('Drawer'),
                        value: 'drawer'
                    },
                    {
                        label: t('Dialog'),
                        value: 'modal'
                    },
                    {
                        label: t('Sheet'),
                        value: 'sheet'
                    },
                    {
                        label: t('Page'),
                        value: 'page'
                    }
                ],
                value: openModeValue,
                onChange: (value)=>{
                    field.componentProps.openMode = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openMode = value;
                    fieldSchema['x-component-props'].openMode = value;
                    Reflect.deleteProperty(fieldSchema['x-component-props'], 'openSize');
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : null,
            openSize && [
                'modal',
                'drawer'
            ].includes(openModeValue) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.SchemaSettingsSelectItem, {
                title: t('Popup size'),
                options: [
                    {
                        label: t('Small'),
                        value: 'small'
                    },
                    {
                        label: t('Middle'),
                        value: 'middle'
                    },
                    {
                        label: t('Large'),
                        value: 'large'
                    }
                ],
                value: null !== (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['openSize']) && void 0 !== _fieldSchema_xcomponentprops_openSize ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2['openMode']) == 'modal' ? 'large' : 'middle',
                onChange: (value)=>{
                    field.componentProps.openSize = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openSize = value;
                    fieldSchema['x-component-props'].openSize = value;
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : 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
});
