"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (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__, {
    SchemaInitializerOpenModeSchemaItems: ()=>SchemaInitializerOpenModeSchemaItems,
    SchemaSettingOpenModeSchemaItems: ()=>SchemaSettingOpenModeSchemaItems
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = 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_block_provider_index_js_namespaceObject = require("../block-provider/index.js");
const PageStyle_provider_js_namespaceObject = require("../built-in/page-style/PageStyle.provider.js");
const usePageStyle_js_namespaceObject = require("../built-in/page-style/usePageStyle.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 isMobile = (0, external_block_provider_index_js_namespaceObject.useIsMobile)();
    const pageStyle = (0, usePageStyle_js_namespaceObject.usePageStyle)();
    const defaultOpenMode = (0, external_react_namespaceObject.useMemo)(()=>{
        if (isMobile || pageStyle === PageStyle_provider_js_namespaceObject.PageStyle.TAB_STYLE) return external_schema_component_index_js_namespaceObject.OpenMode.PAGE;
        return external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE;
    }, [
        isMobile,
        pageStyle
    ]);
    const openModeValue = (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openMode']) || defaultOpenMode;
    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: external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE
                    },
                    {
                        label: t('Dialog'),
                        value: external_schema_component_index_js_namespaceObject.OpenMode.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 && [
                external_schema_component_index_js_namespaceObject.OpenMode.MODAL,
                external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE
            ].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['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops2['openMode']) === external_schema_component_index_js_namespaceObject.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 pageStyle = (0, usePageStyle_js_namespaceObject.usePageStyle)();
    const isMobile = (0, external_block_provider_index_js_namespaceObject.useIsMobile)();
    const defaultOpenMode = (0, external_react_namespaceObject.useMemo)(()=>{
        if (isMobile || pageStyle === PageStyle_provider_js_namespaceObject.PageStyle.TAB_STYLE) return external_schema_component_index_js_namespaceObject.OpenMode.PAGE;
        return external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE;
    }, [
        isMobile,
        pageStyle
    ]);
    const openModeValue = (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops['openMode']) || defaultOpenMode;
    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: external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE
                    },
                    {
                        label: t('Dialog'),
                        value: external_schema_component_index_js_namespaceObject.OpenMode.MODAL
                    },
                    {
                        label: t('Sheet'),
                        value: external_schema_component_index_js_namespaceObject.OpenMode.SHEET
                    },
                    {
                        label: t('Page'),
                        value: external_schema_component_index_js_namespaceObject.OpenMode.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 && [
                external_schema_component_index_js_namespaceObject.OpenMode.MODAL,
                external_schema_component_index_js_namespaceObject.OpenMode.DRAWER_MODE
            ].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['openSize']) ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null == (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) ? void 0 : _fieldSchema_xcomponentprops2['openMode']) === external_schema_component_index_js_namespaceObject.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
        ]
    });
};
exports.SchemaInitializerOpenModeSchemaItems = __webpack_exports__.SchemaInitializerOpenModeSchemaItems;
exports.SchemaSettingOpenModeSchemaItems = __webpack_exports__.SchemaSettingOpenModeSchemaItems;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
    "SchemaInitializerOpenModeSchemaItems",
    "SchemaSettingOpenModeSchemaItems"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
    value: true
});
