import { UserService } from '../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../core/resources/index.js';
/**
 * A data source for Data Type items that fetches data from the server
 * @class UmbUserSetGroupsServerDataSource
 */
export class UmbUserSetGroupsServerDataSource {
    #host;
    /**
     * Creates an instance of UmbUserSetGroupsServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbUserSetGroupsServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Set groups for users
     * @param {Array<string>} id
     * @param userIds
     * @param userGroupIds
     * @returns {*}
     * @memberof UmbUserSetGroupsServerDataSource
     */
    async setGroups(userIds, userGroupIds) {
        if (!userIds)
            throw new Error('User ids are missing');
        if (!userGroupIds)
            throw new Error('User group ids are missing');
        return tryExecute(this.#host, UserService.postUserSetUserGroups({
            body: {
                userIds: userIds.map((id) => ({ id })),
                userGroupIds: userGroupIds.map((id) => ({ id })),
            },
        }));
    }
}
