import { isNonNullish } from "@fern-api/ui-core-utils";
import { BaseOpenApiV3_1ConverterNode, } from "../../BaseOpenApiV3_1Converter.node";
import { resolveWebhookReference } from "../../utils/3.1/resolveWebhookReference";
import { PathItemObjectConverterNode } from "./PathItemObjectConverter.node";
export class WebhooksObjectConverterNode extends BaseOpenApiV3_1ConverterNode {
    basePath;
    servers;
    globalAuth;
    webhooks;
    constructor(args, basePath, servers, globalAuth) {
        super(args);
        this.basePath = basePath;
        this.servers = servers;
        this.globalAuth = globalAuth;
        this.safeParse();
    }
    parse() {
        this.webhooks = Object.fromEntries(Object.entries(this.input ?? {})
            .map(([operation, operationItem]) => {
            const resolvedOperationItem = resolveWebhookReference(operationItem, this.context.document);
            if (resolvedOperationItem == null) {
                return undefined;
            }
            return [
                operation,
                new PathItemObjectConverterNode({
                    input: resolvedOperationItem,
                    context: this.context,
                    accessPath: this.accessPath,
                    pathId: operation,
                }, this.servers, this.globalAuth, this.basePath, true),
            ];
        })
            .filter(isNonNullish));
    }
    convert() {
        return {};
    }
}
