"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__, {
    scopesSchema: ()=>scopesSchema,
    rolesResourcesScopesCollection: ()=>rolesResourcesScopesCollection
});
const external_react_namespaceObject = require("react");
const index_js_namespaceObject = require("../../../../block-provider/index.js");
const external_schema_component_index_js_namespaceObject = require("../../../../schema-component/index.js");
const VariableInput_js_namespaceObject = require("../../../../schema-settings/VariableInput/VariableInput.js");
const external_RolesResourcesActions_js_namespaceObject = require("../RolesResourcesActions.js");
const rolesResourcesScopesCollection = {
    name: 'rolesResourcesScopes',
    fields: [
        {
            type: 'string',
            name: 'name',
            interface: 'input',
            uiSchema: {
                title: '{{t("Scope name")}}',
                type: 'string',
                'x-component': 'Input',
                required: true
            }
        }
    ]
};
const useFormBlockProps = ()=>{
    const { name } = (0, external_react_namespaceObject.useContext)(external_RolesResourcesActions_js_namespaceObject.RoleResourceCollectionContext);
    const ctx = (0, index_js_namespaceObject.useFormBlockContext)();
    (0, external_react_namespaceObject.useEffect)(()=>{
        ctx.form.setInitialValues({
            resourceName: name
        });
    }, [
        name
    ]);
    return {
        form: ctx.form
    };
};
const scopesSchema = {
    type: 'object',
    properties: {
        scope: {
            'x-component': 'RecordPicker',
            'x-component-props': {
                size: 'small',
                fieldNames: {
                    label: 'name',
                    value: 'id'
                },
                multiple: false,
                association: {
                    target: 'rolesResourcesScopes'
                },
                onChange: '{{ onChange }}'
            },
            properties: {
                selector: {
                    type: 'void',
                    title: '{{ t("Select record") }}',
                    'x-component': 'RecordPicker.Selector',
                    'x-component-props': {
                        className: 'tb-record-picker-selector'
                    },
                    properties: {
                        tableBlock: {
                            type: 'void',
                            'x-decorator': 'TableSelectorProvider',
                            'x-decorator-props': {
                                collection: rolesResourcesScopesCollection,
                                resource: 'rolesResourcesScopes',
                                action: 'list',
                                params: {
                                    pageSize: 20
                                },
                                useParams () {
                                    const ctx = (0, external_react_namespaceObject.useContext)(external_RolesResourcesActions_js_namespaceObject.RoleResourceCollectionContext);
                                    return {
                                        filter: {
                                            $or: [
                                                {
                                                    resourceName: ctx.name
                                                },
                                                {
                                                    resourceName: null
                                                }
                                            ]
                                        }
                                    };
                                },
                                rowKey: 'id'
                            },
                            'x-component': 'BlockItem',
                            properties: {
                                actions: {
                                    type: 'void',
                                    'x-component': 'ActionBar',
                                    'x-component-props': {
                                        style: {
                                            marginBottom: 16
                                        }
                                    },
                                    properties: {
                                        create: {
                                            type: 'void',
                                            title: '{{ t("Add new") }}',
                                            'x-action': 'create',
                                            'x-component': 'Action',
                                            'x-component-props': {
                                                icon: 'PlusOutlined',
                                                openMode: 'drawer',
                                                type: 'primary'
                                            },
                                            properties: {
                                                drawer: {
                                                    type: 'void',
                                                    title: '{{ t("Add record") }}',
                                                    'x-component': 'Action.Container',
                                                    'x-component-props': {
                                                        className: 'tb-action-popup'
                                                    },
                                                    properties: {
                                                        formBlock: {
                                                            type: 'void',
                                                            'x-decorator': 'FormBlockProvider',
                                                            'x-decorator-props': {
                                                                resource: 'rolesResourcesScopes',
                                                                collection: rolesResourcesScopesCollection
                                                            },
                                                            'x-component': 'CardItem',
                                                            properties: {
                                                                form: {
                                                                    type: 'void',
                                                                    'x-component': 'FormV2',
                                                                    'x-use-component-props': useFormBlockProps,
                                                                    properties: {
                                                                        name: {
                                                                            type: 'string',
                                                                            'x-component': 'CollectionField',
                                                                            'x-decorator': 'FormItem'
                                                                        },
                                                                        scope: {
                                                                            type: 'object',
                                                                            title: '{{t("Data scope")}}',
                                                                            name: 'filter',
                                                                            'x-decorator': 'FormItem',
                                                                            'x-component': 'Filter',
                                                                            'x-use-component-props': ()=>{
                                                                                const ctx = (0, external_react_namespaceObject.useContext)(external_RolesResourcesActions_js_namespaceObject.RoleResourceCollectionContext);
                                                                                const options = (0, external_schema_component_index_js_namespaceObject.useFilterOptions)(ctx.name);
                                                                                return {
                                                                                    options
                                                                                };
                                                                            },
                                                                            'x-component-props': {
                                                                                dynamicComponent: VariableInput_js_namespaceObject.VariableInput
                                                                            }
                                                                        },
                                                                        actions: {
                                                                            type: 'void',
                                                                            'x-component': 'ActionBar',
                                                                            'x-component-props': {
                                                                                layout: 'one-column',
                                                                                style: {
                                                                                    marginTop: 24
                                                                                }
                                                                            },
                                                                            properties: {
                                                                                create: {
                                                                                    title: '{{ t("Submit") }}',
                                                                                    'x-action': 'submit',
                                                                                    'x-component': 'Action',
                                                                                    'x-use-component-props': 'useCreateActionProps',
                                                                                    'x-component-props': {
                                                                                        type: 'primary',
                                                                                        htmlType: 'submit'
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                },
                                value: {
                                    type: 'array',
                                    'x-component': 'TableV2.Selector',
                                    'x-use-component-props': 'useTableSelectorProps',
                                    'x-component-props': {
                                        rowKey: 'id',
                                        rowSelection: {
                                            type: 'checkbox'
                                        }
                                    },
                                    properties: {
                                        column1: {
                                            type: 'void',
                                            'x-decorator': 'TableV2.Column.Decorator',
                                            'x-component': 'TableV2.Column',
                                            properties: {
                                                name: {
                                                    type: 'string',
                                                    'x-component': 'CollectionField',
                                                    'x-read-pretty': true
                                                }
                                            }
                                        },
                                        actions: {
                                            type: 'void',
                                            title: '{{ t("Actions") }}',
                                            'x-action-column': '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-decorator': 'ACLActionProvider',
                                                            '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: {
                                                                        formBlock: {
                                                                            type: 'void',
                                                                            'x-decorator': 'FormBlockProvider',
                                                                            'x-decorator-props': {
                                                                                resource: 'rolesResourcesScopes',
                                                                                collection: rolesResourcesScopesCollection,
                                                                                action: 'get',
                                                                                useParams: '{{ useParamsFromRecord }}'
                                                                            },
                                                                            'x-component': 'CardItem',
                                                                            properties: {
                                                                                form: {
                                                                                    type: 'void',
                                                                                    'x-component': 'FormV2',
                                                                                    'x-use-component-props': 'useFormBlockProps',
                                                                                    properties: {
                                                                                        name: {
                                                                                            type: 'string',
                                                                                            'x-component': 'CollectionField',
                                                                                            'x-decorator': 'FormItem'
                                                                                        },
                                                                                        scope: {
                                                                                            type: 'object',
                                                                                            title: '{{t("Data scope")}}',
                                                                                            name: 'filter',
                                                                                            'x-decorator': 'FormItem',
                                                                                            'x-component': 'Filter',
                                                                                            'x-use-component-props': ()=>{
                                                                                                const ctx = (0, external_react_namespaceObject.useContext)(external_RolesResourcesActions_js_namespaceObject.RoleResourceCollectionContext);
                                                                                                const options = (0, external_schema_component_index_js_namespaceObject.useFilterOptions)(ctx.name);
                                                                                                return {
                                                                                                    options
                                                                                                };
                                                                                            },
                                                                                            'x-component-props': {
                                                                                                dynamicComponent: VariableInput_js_namespaceObject.VariableInput
                                                                                            }
                                                                                        },
                                                                                        actions: {
                                                                                            type: 'void',
                                                                                            'x-component': 'ActionBar',
                                                                                            'x-component-props': {
                                                                                                layout: 'one-column',
                                                                                                style: {
                                                                                                    marginTop: 24
                                                                                                }
                                                                                            },
                                                                                            properties: {
                                                                                                update: {
                                                                                                    title: '{{ t("Submit") }}',
                                                                                                    'x-action': 'submit',
                                                                                                    'x-component': 'Action',
                                                                                                    'x-use-component-props': 'useUpdateActionProps',
                                                                                                    'x-component-props': {
                                                                                                        type: 'primary',
                                                                                                        htmlType: 'submit'
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        destroy: {
                                                            title: '{{ t("Delete") }}',
                                                            'x-action': 'destroy',
                                                            'x-decorator': 'ACLActionProvider',
                                                            'x-component': 'Action.Link',
                                                            'x-use-component-props': 'useDestroyActionProps',
                                                            'x-component-props': {
                                                                icon: 'DeleteOutlined',
                                                                confirm: {
                                                                    title: "{{t('Delete record')}}",
                                                                    content: "{{t('Are you sure you want to delete it?')}}"
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        footer: {
                            'x-component': 'Action.Container.Footer',
                            'x-component-props': {},
                            properties: {
                                actions: {
                                    type: 'void',
                                    'x-component': 'ActionBar',
                                    'x-component-props': {},
                                    properties: {
                                        submit: {
                                            title: '{{ t("Submit") }}',
                                            'x-action': 'submit',
                                            'x-component': 'Action',
                                            'x-use-component-props': 'usePickActionProps',
                                            'x-component-props': {
                                                type: 'primary',
                                                htmlType: 'submit'
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
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
});
