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_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schemas_scopes_mjs__ from "./schemas/scopes.mjs";
const RolesResourcesScopesSelectedRowKeysContext = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(null);
RolesResourcesScopesSelectedRowKeysContext.displayName = 'RolesResourcesScopesSelectedRowKeysContext';
const RolesResourcesScopesSelectedRowKeysProvider = (props)=>{
    const [keys, setKeys] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RolesResourcesScopesSelectedRowKeysContext.Provider, {
        value: [
            keys,
            setKeys
        ],
        children: props.children
    });
};
const useRolesResourcesScopesSelectedRowKeys = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(RolesResourcesScopesSelectedRowKeysContext);
const ScopeSelect = (props)=>{
    const form = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.createForm)({
            values: {
                scope: props.value
            }
        }), []);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.FormProvider, {
        form: form,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.SchemaComponent, {
            components: {
                RolesResourcesScopesSelectedRowKeysProvider
            },
            scope: {
                onChange (value) {
                    var _props_onChange;
                    null == props || null === (_props_onChange = props.onChange) || void 0 === _props_onChange || _props_onChange.call(props, value);
                }
            },
            schema: __WEBPACK_EXTERNAL_MODULE__schemas_scopes_mjs__.scopesSchema
        })
    });
};
export { ScopeSelect, useRolesResourcesScopesSelectedRowKeys };
