import { camelCase } from "es-toolkit";
import { FernRegistry } from "../client/generated";
export function computeSubpackages({ endpoints, webhookEndpoints, }) {
    const subpackages = {};
    if (endpoints != null) {
        Object.values(endpoints).forEach((endpoint) => endpoint.namespace?.forEach((subpackage) => {
            const qualifiedPath = [];
            subpackages[FernRegistry.api.v1.SubpackageId(camelCase(subpackage))] = {
                id: FernRegistry.api.v1.SubpackageId(camelCase(subpackage)),
                name: [...qualifiedPath, subpackage].join("/"),
                displayName: subpackage,
            };
            qualifiedPath.push(subpackage);
        }));
    }
    if (webhookEndpoints != null) {
        Object.values(webhookEndpoints).forEach((webhook) => webhook.namespace?.forEach((subpackage) => {
            const qualifiedPath = [];
            subpackages[FernRegistry.api.v1.SubpackageId(camelCase(subpackage))] = {
                id: FernRegistry.api.v1.SubpackageId(camelCase(subpackage)),
                name: [...qualifiedPath, subpackage].join("/"),
                displayName: subpackage,
            };
            qualifiedPath.push(subpackage);
        }));
    }
    return subpackages;
}
