import { UMB_ENTITY_DATA_PICKER_DATA_SOURCE_API_CONTEXT } from '../input/entity-data-picker-data-source.context.token.js';
import { UmbRepositoryBase } from '../../../core/repository/index.js';
export class UmbEntityDataPickerItemRepository extends UmbRepositoryBase {
    #init;
    #pickerDataSourceContext;
    constructor(host) {
        super(host);
        this.#init = Promise.all([
            this.consumeContext(UMB_ENTITY_DATA_PICKER_DATA_SOURCE_API_CONTEXT, (context) => {
                this.#pickerDataSourceContext = context;
            }).asPromise(),
        ]);
    }
    async requestItems(uniques) {
        await this.#init;
        const api = await this.#getApi();
        return api.requestItems(uniques);
    }
    async #getApi() {
        const api = await this.observe(this.#pickerDataSourceContext?.dataSourceApi)?.asPromise();
        if (!api)
            throw new Error('No data source API set');
        return api;
    }
}
export { UmbEntityDataPickerItemRepository as api };
