import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_index_mjs__ from "../../block-provider/hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collections_uiSchemaTemplates_mjs__ from "../collections/uiSchemaTemplates.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__useSchemaTemplateManager_mjs__ from "../useSchemaTemplateManager.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__CollectionTitle_mjs__ from "./CollectionTitle.mjs";
const useUpdateSchemaTemplateActionProps = ()=>{
    const props = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_index_mjs__.useUpdateActionProps)();
    const { refresh } = (0, __WEBPACK_EXTERNAL_MODULE__useSchemaTemplateManager_mjs__.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const useBulkDestroyTemplateProps = ()=>{
    const props = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_index_mjs__.useBulkDestroyActionProps)();
    const { refresh } = (0, __WEBPACK_EXTERNAL_MODULE__useSchemaTemplateManager_mjs__.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const useDestroyTemplateProps = ()=>{
    const props = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_hooks_index_mjs__.useDestroyActionProps)();
    const { refresh } = (0, __WEBPACK_EXTERNAL_MODULE__useSchemaTemplateManager_mjs__.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const uiSchemaTemplatesSchema = {
    type: 'object',
    properties: {
        [(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.uid)()]: {
            type: 'void',
            'x-decorator': 'TableBlockProvider',
            'x-decorator-props': {
                collection: __WEBPACK_EXTERNAL_MODULE__collections_uiSchemaTemplates_mjs__.uiSchemaTemplatesCollection,
                resource: 'uiSchemaTemplates',
                action: 'list',
                params: {
                    pageSize: 20,
                    sort: [
                        '-createdAt'
                    ]
                },
                rowKey: 'key',
                showIndex: true,
                dragSort: false
            },
            'x-component': 'CardItem',
            properties: {
                actions: {
                    type: 'void',
                    'x-component': 'ActionBar',
                    'x-component-props': {
                        style: {
                            marginBottom: 16
                        }
                    },
                    properties: {
                        destroy: {
                            title: '{{ t("Delete") }}',
                            'x-action': 'destroy',
                            'x-component': 'Action',
                            'x-use-component-props': useBulkDestroyTemplateProps,
                            'x-component-props': {
                                icon: 'DeleteOutlined',
                                confirm: {
                                    title: "{{t('Delete record')}}",
                                    content: "{{t('Are you sure you want to delete it?')}}"
                                }
                            }
                        }
                    }
                },
                [(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.uid)()]: {
                    type: 'array',
                    'x-component': 'TableV2',
                    'x-use-component-props': 'useTableBlockProps',
                    'x-component-props': {
                        rowSelection: {
                            type: 'checkbox'
                        }
                    },
                    properties: {
                        actions: {
                            type: 'void',
                            title: '{{ t("Actions") }}',
                            'x-component': 'TableV2.Column',
                            properties: {
                                actions: {
                                    type: 'void',
                                    'x-decorator': 'DndContext',
                                    'x-component': 'Space',
                                    'x-component-props': {
                                        split: '|'
                                    },
                                    properties: {
                                        edit: {
                                            type: 'void',
                                            title: '{{ t("Edit") }}',
                                            'x-action': 'update',
                                            'x-component': 'Action.Link',
                                            'x-component-props': {
                                                openMode: 'drawer',
                                                icon: 'EditOutlined'
                                            },
                                            properties: {
                                                drawer: {
                                                    type: 'void',
                                                    title: '{{ t("Edit record") }}',
                                                    'x-component': 'Action.Container',
                                                    'x-component-props': {
                                                        className: 'tb-action-popup'
                                                    },
                                                    properties: {
                                                        form: {
                                                            type: 'void',
                                                            'x-decorator': 'FormBlockProvider',
                                                            'x-decorator-props': {
                                                                resource: 'uiSchemaTemplates',
                                                                collection: __WEBPACK_EXTERNAL_MODULE__collections_uiSchemaTemplates_mjs__.uiSchemaTemplatesCollection,
                                                                action: 'get',
                                                                useParams: '{{ useParamsFromRecord }}'
                                                            },
                                                            'x-component': 'CardItem',
                                                            properties: {
                                                                [(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.uid)()]: {
                                                                    type: 'void',
                                                                    'x-component': 'FormV2',
                                                                    'x-use-component-props': 'useFormBlockProps',
                                                                    properties: {
                                                                        name: {
                                                                            type: 'string',
                                                                            'x-component': 'CollectionField',
                                                                            'x-decorator': 'FormItem',
                                                                            'x-collection-field': 'uiSchemaTemplates.name',
                                                                            required: true
                                                                        },
                                                                        actions: {
                                                                            type: 'void',
                                                                            'x-component': 'ActionBar',
                                                                            'x-component-props': {
                                                                                layout: 'one-column',
                                                                                style: {
                                                                                    marginTop: 24
                                                                                }
                                                                            },
                                                                            properties: {
                                                                                submit: {
                                                                                    title: '{{t("Submit")}}',
                                                                                    'x-action': 'submit',
                                                                                    'x-component': 'Action',
                                                                                    'x-use-component-props': useUpdateSchemaTemplateActionProps,
                                                                                    'x-component-props': {
                                                                                        type: 'primary',
                                                                                        htmlType: 'submit'
                                                                                    },
                                                                                    type: 'void'
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        destroy: {
                                            title: '{{ t("Delete") }}',
                                            'x-action': 'destroy',
                                            'x-component': 'Action.Link',
                                            'x-use-component-props': useDestroyTemplateProps,
                                            'x-component-props': {
                                                icon: 'DeleteOutlined',
                                                confirm: {
                                                    title: "{{t('Delete record')}}",
                                                    content: "{{t('Are you sure you want to delete it?')}}"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        column1: {
                            type: 'void',
                            'x-decorator': 'TableV2.Column.Decorator',
                            'x-component': 'TableV2.Column',
                            properties: {
                                name: {
                                    type: 'string',
                                    'x-collection-field': 'uiSchemaTemplates.name',
                                    'x-component': 'CollectionField',
                                    'x-read-pretty': true,
                                    'x-component-props': {
                                        ellipsis: true
                                    }
                                }
                            }
                        },
                        column2: {
                            type: 'void',
                            title: '{{t("Collection display name")}}',
                            'x-component': 'TableV2.Column',
                            properties: {
                                'collection.title': {
                                    type: 'string',
                                    'x-component': __WEBPACK_EXTERNAL_MODULE__CollectionTitle_mjs__.CollectionTitle,
                                    'x-read-pretty': true,
                                    'x-component-props': {
                                        ellipsis: true
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
export { uiSchemaTemplatesSchema };
