import { iterableSome } from "collection-utils";
import { BooleanOption, EnumOption, getOptionValues, } from "../../RendererOptions/index.js";
import { TargetLanguage } from "../../TargetLanguage.js";
import { UnionType, } from "../../Type/index.js";
import { JSONPythonRenderer } from "./JSONPythonRenderer.js";
import { PythonRenderer } from "./PythonRenderer.js";
export const pythonOptions = {
    features: new EnumOption("python-version", "Python version", {
        "3.5": { typeHints: false, dataClasses: false },
        "3.6": { typeHints: true, dataClasses: false },
        "3.7": { typeHints: true, dataClasses: true },
    }, "3.6"),
    justTypes: new BooleanOption("just-types", "Classes only", false),
    nicePropertyNames: new BooleanOption("nice-property-names", "Transform property names to be Pythonic", true),
    pydanticBaseModel: new BooleanOption("pydantic-base-model", "Uses pydantic BaseModel", false),
};
export const pythonLanguageConfig = {
    displayName: "Python",
    names: ["python", "py"],
    extension: "py",
};
export class PythonTargetLanguage extends TargetLanguage {
    constructor() {
        super(pythonLanguageConfig);
    }
    getOptions() {
        return pythonOptions;
    }
    get stringTypeMapping() {
        const mapping = new Map();
        const dateTimeType = "date-time";
        mapping.set("date", dateTimeType);
        mapping.set("time", dateTimeType);
        mapping.set("date-time", dateTimeType);
        mapping.set("uuid", "uuid");
        mapping.set("integer-string", "integer-string");
        mapping.set("bool-string", "bool-string");
        return mapping;
    }
    get supportsUnionsWithBothNumberTypes() {
        return true;
    }
    get supportsOptionalClassProperties() {
        return false;
    }
    needsTransformerForType(t) {
        if (t instanceof UnionType) {
            return iterableSome(t.members, (m) => this.needsTransformerForType(m));
        }
        return t.kind === "integer-string" || t.kind === "bool-string";
    }
    makeRenderer(renderContext, untypedOptionValues) {
        const options = getOptionValues(pythonOptions, untypedOptionValues);
        if (options.justTypes) {
            return new PythonRenderer(this, renderContext, options);
        }
        return new JSONPythonRenderer(this, renderContext, options);
    }
}
