import { useCallback } from 'react';
import '../../../../../_virtual/index2.mjs';
import { useSWRConfig } from '../../../../../node_modules/swr/_internal/dist/index.mjs';
import { useMutateWithToast } from './useMutateWithToast.mjs';
import { scimGetConnectionKey } from './useScimConnection.mjs';
import { useStytchClient } from './useStytchClient.mjs';

const useMutateScimConnectionRoleAssignments = ()=>{
    const { mutate: mutateSWR } = useSWRConfig();
    const client = useStytchClient();
    const org = client.organization.getSync();
    const connectionId = org?.scim_active_connection?.connection_id;
    return useMutateWithToast(useCallback(async (properties)=>{
        await mutateSWR(scimGetConnectionKey(connectionId), async ()=>{
            const resp = await client.scim.updateConnection({
                connection_id: properties.connection_id,
                scim_group_implicit_role_assignments: properties.scim_group_implicit_role_assignments
            });
            return resp.connection;
        }, {
            rollbackOnError: true,
            populateCache: true,
            revalidate: false
        });
    }, [
        client.scim,
        connectionId,
        mutateSWR
    ]));
};

export { useMutateScimConnectionRoleAssignments };
//# sourceMappingURL=useMutateScimConnection.mjs.map
