import { A as getRegisteredEmbeddingProvider, j as listRegisteredEmbeddingProviders } from "./registry-BfllMzet.js";
import { i as resolveRuntimeEmbeddingProviderLookupIds, n as listRuntimeEmbeddingProviderAdapters, r as readConfiguredProviderApiId, t as getRuntimeEmbeddingProviderAdapter } from "./embedding-provider-runtime-shared-CtvsyOME.js";
//#region src/plugins/embedding-provider-runtime.ts
const OPENAI_COMPATIBLE_EMBEDDING_PROVIDER_ID = "openai-compatible";
const OPENAI_COMPATIBLE_MODEL_APIS = new Set(["openai-completions", "openai-responses"]);
function listRegisteredEmbeddingProviderAdapters() {
	return listRegisteredEmbeddingProviders().map((entry) => entry.adapter);
}
function listEmbeddingProviders(cfg) {
	return listRuntimeEmbeddingProviderAdapters({
		key: "embeddingProviders",
		cfg,
		registered: listRegisteredEmbeddingProviderAdapters()
	});
}
function resolveConfiguredEmbeddingProviderId(providerId, cfg) {
	return readConfiguredProviderApiId({
		providerId,
		cfg,
		resolveApiProviderId: (normalizedApiId) => OPENAI_COMPATIBLE_MODEL_APIS.has(normalizedApiId) ? OPENAI_COMPATIBLE_EMBEDDING_PROVIDER_ID : normalizedApiId,
		resolveMissingApiProviderId: (providerConfig) => providerConfig.baseUrl?.trim() ? OPENAI_COMPATIBLE_EMBEDDING_PROVIDER_ID : void 0
	});
}
function resolveEmbeddingProviderLookupIds(id, cfg) {
	return resolveRuntimeEmbeddingProviderLookupIds({
		id,
		cfg,
		resolveConfiguredProviderId: resolveConfiguredEmbeddingProviderId
	});
}
function getEmbeddingProvider(id, cfg) {
	return getRuntimeEmbeddingProviderAdapter({
		key: "embeddingProviders",
		cfg,
		lookupIds: resolveEmbeddingProviderLookupIds(id, cfg),
		getRegisteredProvider: getRegisteredEmbeddingProvider
	});
}
//#endregion
export { listEmbeddingProviders as n, getEmbeddingProvider as t };
