import { UMB_LANGUAGE_ENTITY_TYPE } from '../../entity.js';
import { UmbManagementApiLanguageItemDataRequestManager } from './language-item.server.request-manager.js';
import { UmbItemServerDataSourceBase } from '../../../core/repository/index.js';
/**
 * A server data source for Language items
 * @class UmbLanguageItemServerDataSource
 * @implements {DocumentTreeDataSource}
 */
export class UmbLanguageItemServerDataSource extends UmbItemServerDataSourceBase {
    #itemRequestManager = new UmbManagementApiLanguageItemDataRequestManager(this);
    /**
     * Creates an instance of UmbLanguageItemServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbLanguageItemServerDataSource
     */
    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.isoCode,
        name: item.name,
        entityType: UMB_LANGUAGE_ENTITY_TYPE,
    };
};
