import { UMB_MEMBER_GROUP_ENTITY_TYPE } from '../../entity.js';
import { UmbManagementApiMemberGroupItemDataRequestManager } from './member-group-item.server.request-manager.js';
import { UmbItemServerDataSourceBase } from '../../../../core/repository/index.js';
/**
 * A server data source for Member Group items
 * @class UmbMemberGroupItemServerDataSource
 * @implements {DocumentTreeDataSource}
 */
export class UmbMemberGroupItemServerDataSource extends UmbItemServerDataSourceBase {
    #itemRequestManager = new UmbManagementApiMemberGroupItemDataRequestManager(this);
    /**
     * Creates an instance of UmbMemberGroupItemServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbMemberGroupItemServerDataSource
     */
    constructor(host) {
        super(host, {
            mapper,
        });
    }
    async getItems(uniques) {
        if (!uniques)
            throw new Error('Uniques are missing');
        const { data, error } = await this.#itemRequestManager.getItems(uniques);
        return { data: this._getMappedItems(data), error };
    }
}
const mapper = (item) => {
    return {
        unique: item.id,
        name: item.name,
        entityType: UMB_MEMBER_GROUP_ENTITY_TYPE,
    };
};
