import { aggregateAcrossTeams, formatAggregationResult, loopGet, } from "../lib/loop-api.js";
export async function peopleList(params) {
    const { accountId, search, teamName, limit } = params;
    const result = await aggregateAcrossTeams(accountId, "people", "loop-people-list", async (apiKey, team) => {
        const searchParam = search ? `?search=${encodeURIComponent(search)}` : "";
        const data = await loopGet(apiKey, `/people${searchParam}`, "loop-people-list", team);
        return Array.isArray(data) ? data : [];
    }, { teamName, limitPerTeam: limit ?? 50, limitTotal: limit ?? 200 });
    return formatAggregationResult(result, (p) => {
        const name = [p.firstName, p.lastName].filter(Boolean).join(" ") || "Unknown";
        const contact = p.email ?? p.phone ?? "";
        const type = p.type ? ` (${p.type})` : "";
        return `- ${name}${contact ? ` <${contact}>` : ""}${type}`;
    }, "people");
}
//# sourceMappingURL=people-list.js.map