import { jsx } from "react/jsx-runtime";
import { createContext, useContext } from "react";
import { Spin } from "antd";
import { useRequest } from "../../../api-client/index.mjs";
import { SchemaComponent, SchemaComponentContext } from "../../../schema-component/index.mjs";
import { MenuItemsProvider } from "./MenuItemsProvider.mjs";
import { PermissionProvider, SettingCenterPermissionProvider } from "./PermisionProvider.mjs";
import { roleSchema } from "./schemas/roles.mjs";
const AvailableActionsContext = /*#__PURE__*/ createContext([]);
AvailableActionsContext.displayName = 'AvailableActionsContext';
const AvailableActionsProver = (props)=>{
    const { data, loading } = useRequest({
        resource: 'availableActions',
        action: 'list'
    });
    if (loading) return /*#__PURE__*/ jsx(Spin, {});
    return /*#__PURE__*/ jsx(AvailableActionsContext.Provider, {
        value: null == data ? void 0 : data.data,
        children: props.children
    });
};
const useAvailableActions = ()=>useContext(AvailableActionsContext);
const RoleTable = ()=>/*#__PURE__*/ jsx("div", {
        children: /*#__PURE__*/ jsx(SchemaComponentContext.Provider, {
            value: {
                designable: false
            },
            children: /*#__PURE__*/ jsx(AvailableActionsProver, {
                children: /*#__PURE__*/ jsx(SchemaComponent, {
                    schema: roleSchema,
                    components: {
                        MenuItemsProvider: MenuItemsProvider,
                        SettingCenterPermissionProvider: SettingCenterPermissionProvider,
                        PermissionProvider: PermissionProvider
                    }
                })
            })
        })
    });
export { RoleTable, useAvailableActions };
