import { get, post } from "./serviceHelper";
export async function getCombinedIndexStatus() {
    const result = await get("/parhelia/index/combinedstatus");
    return result.data;
}
export async function rebuildIndex(forceRegenerate = false) {
    const result = await post(`/parhelia/index/rebuild?forceRegenerate=${forceRegenerate}`, {});
    return result.data;
}
export async function cleanupBatches() {
    await post("/parhelia/index/cleanup", {});
}
export async function populateCentroids(k) {
    await post(`/parhelia/index/populatecentroids?k=${encodeURIComponent(k)}`, {});
}
export async function processCompletedBatches() {
    await post("/parhelia/index/processcompletedbatches", {});
}
// Provider-agnostic methods
export async function getProviderInfo() {
    const result = await get("/parhelia/index/providerinfo");
    return result.data;
}
export async function generateEmbeddings(mode = "auto") {
    await post(`/parhelia/index/generateembeddings?mode=${encodeURIComponent(mode)}`, {});
}
export async function getQueueStatus() {
    const result = await get("/parhelia/index/queuestatus");
    return result.data;
}
export async function getStagingStats() {
    const result = await get("/parhelia/index/stagingstats");
    return result.data;
}
export async function retryFailedEmbeddingRequests(rebuildId, limit) {
    const query = new URLSearchParams();
    if (rebuildId)
        query.set("rebuildId", rebuildId);
    if (limit != null)
        query.set("limit", String(limit));
    const qs = query.toString();
    const result = await post(`/parhelia/index/retryfailedrequests${qs ? `?${qs}` : ""}`, {});
    if (result.type !== "success") {
        throw new Error(result.details || result.summary || "Retry failed");
    }
    const data = result.data;
    const retried = (data?.retried ?? 0);
    return { retried };
}
export async function stopEmbeddingGeneration() {
    const result = await post("/parhelia/index/stopgeneration", {});
    if (result.type !== "success") {
        throw new Error(result.details || result.summary || "Stop failed");
    }
}
export async function cancelCollection() {
    const result = await post("/parhelia/index/cancelcollection", {});
    if (result.type !== "success") {
        throw new Error(result.details || result.summary || "Cancel failed");
    }
}
//# sourceMappingURL=indexService.js.map