import { isOperationName, JsonPointer } from '../utils/index.js';
import { getOperation } from './operation.js';
import { joinWithSeparator } from '../services/index.js';
export function getCallback(parser, name, infoOrRef, parentPointer, options, href, parent, userClaims) {
    const { resolved: paths } = parser.deref(infoOrRef);
    const operations = [];
    for (const pathName of Object.keys(paths)) {
        const path = paths[pathName];
        const operationNames = Object.keys(path).filter(isOperationName);
        for (const operationName of operationNames) {
            const operationInfo = path[operationName];
            const operation = getOperation(parser, {
                ...operationInfo,
                pathName,
                pointer: JsonPointer.join(parentPointer, ['callbacks', name, operationName]),
                httpVerb: operationName,
                pathParameters: path.parameters || [],
                pathServers: path.servers,
            }, parent, options, href, {
                isCallback: true,
                id: joinWithSeparator(name, operationName),
            }, userClaims);
            operations.push(operation);
        }
    }
    return { name, operations };
}
//# sourceMappingURL=callback.js.map