import { UMB_DOCUMENT_TYPE_ENTITY_TYPE } from '../../entity.js';
import { UmbManagementApiDocumentTypeItemDataRequestManager } from './document-type-item.server.request-manager.js';
import { UmbItemServerDataSourceBase } from '../../../../core/repository/index.js';
/**
 * A data source for Document Type items that fetches data from the server
 * @class UmbDocumentTypeItemServerDataSource
 * @augments {UmbItemServerDataSourceBase<DocumentTypeItemResponseModel, UmbDocumentTypeItemModel>}
 */
export class UmbDocumentTypeItemServerDataSource extends UmbItemServerDataSourceBase {
    #itemRequestManager = new UmbManagementApiDocumentTypeItemDataRequestManager(this);
    /**
     * Creates an instance of UmbDocumentTypeItemServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbDocumentTypeItemServerDataSource
     */
    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 {
        entityType: UMB_DOCUMENT_TYPE_ENTITY_TYPE,
        isElement: item.isElement,
        icon: item.icon ?? undefined,
        unique: item.id,
        name: item.name,
        description: item.description ?? undefined,
    };
};
