import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
const demo4_rslib_entry_options = [
    {
        name: 'name',
        title: 'Name',
        operators: [
            {
                label: 'eq',
                value: '$eq'
            },
            {
                label: 'ne',
                value: '$ne'
            }
        ],
        schema: {
            type: 'string',
            title: 'Name',
            'x-component': 'Input'
        }
    },
    {
        name: 'age',
        title: 'Age',
        operators: [
            {
                label: 'in',
                value: '$in'
            },
            {
                label: 'not',
                value: '$not'
            }
        ],
        schema: {
            type: 'string',
            title: 'Age',
            'x-component': 'InputNumber'
        }
    },
    {
        name: 'tags',
        title: 'Tags',
        schema: {
            title: 'Tags'
        },
        children: [
            {
                name: 'slug',
                title: 'Slug',
                operators: [
                    {
                        label: 'in',
                        value: '$in'
                    },
                    {
                        label: 'not',
                        value: '$not'
                    }
                ],
                schema: {
                    title: 'Slug',
                    type: 'string',
                    'x-component': 'Input'
                }
            },
            {
                name: 'title',
                title: 'Title',
                operators: [
                    {
                        label: 'eq',
                        value: '$eq'
                    },
                    {
                        label: 'ne',
                        value: '$ne'
                    }
                ],
                schema: {
                    title: 'Title',
                    type: 'string',
                    'x-component': 'Input'
                }
            }
        ]
    }
];
const defaultValue = {
    $or: [
        {
            name: {
                $ne: 'aaa'
            }
        },
        {
            'tags.title': {
                $eq: 'bbb'
            }
        }
    ]
};
const schema = {
    type: 'void',
    properties: {
        demo: {
            name: 'filter',
            type: 'object',
            enum: demo4_rslib_entry_options,
            default: defaultValue,
            'x-component': 'Filter',
            'x-component-props': {
                dynamicComponent: 'CustomDynamicComponent'
            }
        }
    }
};
const ExpRE = /^\s*\{\{([\s\S]*)\}\}\s*$/;
const CustomDynamicComponent = (props)=>{
    const { value, onChange, renderSchemaComponent } = props;
    let matched = null;
    if ('string' == typeof value) matched = ExpRE.exec(value);
    const [source, setSource] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(matched ? 'node1' : 'default');
    const options = [
        {
            label: '字段1',
            value: "{{".concat(source, ".field1}}")
        },
        {
            label: '字段2',
            value: "{{".concat(source, ".field2}}")
        }
    ];
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Space, {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.Select, {
                style: {
                    minWidth: 120
                },
                value: source,
                onChange: (value)=>{
                    setSource(value);
                    onChange(null);
                },
                options: [
                    {
                        label: '默认',
                        value: 'default'
                    },
                    {
                        label: '节点1',
                        value: 'node1'
                    }
                ]
            }),
            'default' === source ? renderSchemaComponent() : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.Select, {
                style: {
                    minWidth: 120
                },
                onChange: (value)=>{
                    onChange(value);
                },
                value: value,
                options: options
            })
        ]
    });
};
const demo4_rslib_entry_ = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponentProvider, {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.AntdSchemaComponentProvider, {
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                components: {
                    Input: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Input,
                    Filter: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Filter,
                    CustomDynamicComponent
                },
                schema: schema
            })
        })
    });
export { demo4_rslib_entry_ as default };
