"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeConfigs = exports.getInitConfig = exports.getDefaultConfig = exports.tryGetJsPackageName = exports.tryGetPythonPackageName = exports.FileTag = exports.QPC_CONFIG_FILENAME = exports.QPC_DIR = exports.osFromTarget = exports.archFromTarget = exports.TARGETS = void 0;
const object_hash_1 = require("object-hash");
exports.TARGETS = [
    "python-x86_64-linux",
    "python-x86_64-windows",
    "python-x86_64-macos",
    "python-arm64-macos",
    "python-arm64-linux",
    // "python-universal",
    //
    "node-x86_64-linux",
    "node-x86_64-windows",
    "node-x86_64-macos",
    "node-arm64-macos",
    "node-arm64-linux",
    "node-universal", // all platforms
    //
    "js-universal", // WASM + Node.js all platforms
    //
    "wasm-unknown-unknown",
];
const archFromTarget = (target) => {
    if (target.includes("x86_64")) {
        return "x86_64";
    }
    else if (target.includes("arm64")) {
        return "arm64";
    }
    return "unknown";
};
exports.archFromTarget = archFromTarget;
const osFromTarget = (target) => {
    if (target.includes("linux")) {
        return "linux";
    }
    else if (target.includes("windows")) {
        return "windows";
    }
    else if (target.includes("macos")) {
        return "macos";
    }
    return "unknown";
};
exports.osFromTarget = osFromTarget;
exports.QPC_DIR = ".qpace";
exports.QPC_CONFIG_FILENAME = ".qpace.json";
var FileTag;
(function (FileTag) {
    FileTag["QPC_PYTHON_WHEEL"] = "qpc_python_wheel";
})(FileTag || (exports.FileTag = FileTag = {}));
const tryGetPythonPackageName = (config) => {
    if (typeof config?.package === "string") {
        return config.package;
    }
    if (typeof config?.package === "object" && config?.package.name) {
        return config.package.name;
    }
    return;
};
exports.tryGetPythonPackageName = tryGetPythonPackageName;
const tryGetJsPackageName = (config) => {
    if (typeof config?.package === "string") {
        return config.package;
    }
    if (typeof config?.package === "object" && config?.package.name) {
        return config.package.name;
    }
    return;
};
exports.tryGetJsPackageName = tryGetJsPackageName;
const getDefaultConfig = () => {
    return {
        noDeadCode: true,
        rust: {
            qpaceCoreCrate: "qpace_core",
        },
        py: {
            package: "qpace_artifact",
            qpacePackage: "qpace",
        },
        js: {
            package: "qpace_artifact",
            qpacePackage: "qpace",
        },
        node: {},
        web: {},
        emit: false,
        out: "build",
        include: ["**/*.pine"],
        exclude: [
            "node_modules",
            "build",
            "dist",
            "target",
            "__pycache__",
            exports.QPC_DIR,
        ],
    };
};
exports.getDefaultConfig = getDefaultConfig;
const getInitConfig = () => {
    const pckgName = `qpace_script_${(0, object_hash_1.MD5)(Date.now()).slice(0, 6)}`;
    return {
        install: true,
        test: true,
        py: {
            package: pckgName,
        },
        js: {
            package: pckgName,
            packageManager: "auto",
        },
        outDir: "build",
        include: ["README.md", "**/*.pine"],
    };
};
exports.getInitConfig = getInitConfig;
const mergeConfigs = (config, newConfig) => {
    return {
        ...config,
        ...newConfig,
        rust: {
            ...config.rust,
            ...newConfig.rust,
        },
        py: {
            ...config.py,
            ...newConfig.py,
        },
        js: {
            ...config.js,
            ...newConfig.js,
        },
        node: {
            ...config.node,
            ...newConfig.node,
        },
        web: {
            ...config.web,
            ...newConfig.web,
        },
    };
};
exports.mergeConfigs = mergeConfigs;
//# sourceMappingURL=config.js.map