import { resolveReadableHomeGraphSpace } from './space-selection.js';
import { readHomeGraphState } from './state.js';
export async function listHomeGraphSources(input) {
    await input.store.init();
    const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
    return { ok: true, spaceId, sources: readHomeGraphState(input.store, spaceId).sources.slice(0, Math.max(1, input.limit ?? 100)) };
}
export async function browseHomeGraph(input) {
    await input.store.init();
    const { spaceId } = resolveReadableHomeGraphSpace(input.store, input);
    const limit = Math.max(1, input.limit ?? 250);
    const state = readHomeGraphState(input.store, spaceId);
    return {
        ok: true,
        spaceId,
        nodes: state.nodes.slice(0, limit),
        edges: state.edges.slice(0, limit),
        sources: state.sources.slice(0, limit),
        issues: state.issues.slice(0, limit),
    };
}
