import { ServerObjectConverterNode } from "../../3.1/paths/ServerObjectConverter.node";
export function coalesceServers(existingServers, serversToAdd, context, accessPath) {
    const existing = existingServers ?? [];
    const existingUrls = new Set(existing.map((server) => server.url));
    const newServers = (serversToAdd ?? [])
        .filter((server) => !existingUrls.has(server.url))
        .map((server, index) => new ServerObjectConverterNode({
        input: server,
        context,
        accessPath,
        pathId: ["servers", `${index}`],
    }));
    return [...existing, ...newServers];
}
