import { BaseOpenApiV3_1ConverterNodeWithExample, } from "../../BaseOpenApiV3_1Converter.node";
import { AvailabilityConverterNode } from "../extensions/AvailabilityConverter.node";
export class ConstConverterNode extends BaseOpenApiV3_1ConverterNodeWithExample {
    constValue;
    description;
    availability;
    constructor(args) {
        super(args);
        this.safeParse();
    }
    parse() {
        // TODO: this can be any primitive type, so Enum Value should be an FDR primitive
        if (this.input.const != null &&
            (typeof this.input.const === "string" ||
                typeof this.input.const === "number" ||
                typeof this.input.const === "boolean")) {
            this.constValue = this.input.const.toString();
        }
        else {
            this.context.errors.warning({
                message: `Unsupported const type: ${typeof this.input}`,
                path: this.accessPath,
            });
        }
        this.description = this.input.description;
        this.availability = new AvailabilityConverterNode({
            input: this.input,
            context: this.context,
            accessPath: this.accessPath,
            pathId: "x-fern-availability",
        });
    }
    convert() {
        if (this.constValue == null) {
            return undefined;
        }
        return {
            type: "enum",
            default: this.constValue,
            values: [
                {
                    value: this.constValue,
                    description: this.description,
                    availability: this.availability?.convert(),
                },
            ],
        };
    }
    example() {
        return this.input.example ?? this.input.examples?.[0] ?? this.constValue;
    }
}
