import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
const useFormItemInitializerFields = ()=>[
        {
            name: 'name',
            title: 'Name',
            Component: 'CollectionFieldInitializer',
            schema: {
                type: 'string',
                title: 'Name',
                name: 'name',
                'x-component': 'Input',
                'x-decorator': 'FormItem',
                'x-collection-field': 'posts.name'
            }
        },
        {
            name: 'title',
            title: 'Title',
            Component: 'CollectionFieldInitializer',
            schema: {
                type: 'string',
                title: 'Title',
                name: 'title',
                'x-component': 'Input',
                'x-decorator': 'FormItem',
                'x-collection-field': 'posts.title'
            }
        }
    ];
const TextInitializer = ()=>{
    const { insert } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializer)();
    const itemConfig = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializerItem)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaInitializerItem, {
        onClick: ()=>{
            insert({
                type: 'void',
                'x-component': 'Markdown.Void',
                'x-decorator': 'FormItem'
            });
        },
        ...itemConfig
    });
};
const addFormItemInitializer = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaInitializer({
    name: 'addFormItem',
    title: 'Configure actions',
    insertPosition: 'beforeEnd',
    items: [
        {
            name: 'displayFields',
            type: 'itemGroup',
            title: 'Display fields',
            useChildren: useFormItemInitializerFields
        },
        {
            name: 'divider',
            type: 'divider'
        },
        {
            name: 'addText',
            title: 'Add text',
            Component: TextInitializer
        }
    ]
});
const Page = (props)=>{
    const { render } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializerRender)('addFormItem');
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        children: [
            props.children,
            render()
        ]
    });
};
const Root = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponentProvider, {
            designable: true,
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                components: {
                    TextInitializer,
                    Page,
                    Form: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Form,
                    Input: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Input,
                    FormItem: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.FormItem,
                    Markdown: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Markdown,
                    CollectionFieldInitializer: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.CollectionFieldInitializer
                },
                schema: {
                    type: 'void',
                    name: 'page',
                    'x-decorator': 'Form',
                    'x-component': 'Page',
                    properties: {
                        title: {
                            type: 'string',
                            title: 'Title',
                            'x-component': 'Input',
                            'x-decorator': 'FormItem',
                            'x-collection-field': 'posts.title'
                        },
                        name: {
                            type: 'string',
                            title: 'Name',
                            'x-component': 'Input',
                            'x-decorator': 'FormItem',
                            'x-collection-field': 'posts.name'
                        }
                    }
                }
            })
        })
    });
class MyPlugin extends __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Plugin {
    async load() {
        this.app.schemaInitializerManager.add(addFormItemInitializer);
        this.app.router.add('root', {
            path: '/',
            Component: Root
        });
    }
}
const app = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Application({
    router: {
        type: 'memory',
        initialEntries: [
            '/'
        ]
    },
    plugins: [
        MyPlugin
    ]
});
const insert_schema_form_item_rslib_entry_ = app.getRootComponent();
export { insert_schema_form_item_rslib_entry_ as default };
