import { BaseOpenApiV3_1ConverterNode, } from "../../../BaseOpenApiV3_1Converter.node";
import { extendType } from "../../../utils/extendType";
import { isValidJsonPath } from "../../../utils/isValidJsonPath";
import { X_FERN_ACCESS_TOKEN_LOCATOR } from "../fernExtension.consts";
export class XFernAccessTokenLocatorConverterNode extends BaseOpenApiV3_1ConverterNode {
    accessTokenLocator;
    constructor(args) {
        super(args);
        this.safeParse();
    }
    parse() {
        this.accessTokenLocator =
            extendType(this.input)[X_FERN_ACCESS_TOKEN_LOCATOR];
        if (this.accessTokenLocator != null) {
            if (!isValidJsonPath(this.accessTokenLocator)) {
                this.context.errors.error({
                    message: "Invalid access token locator, must be a valid jq path",
                    path: this.accessPath,
                });
                this.accessTokenLocator = undefined;
            }
        }
    }
    convert() {
        return this.accessTokenLocator;
    }
}
