"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    getAppBaseUrl: function() {
        return getAppBaseUrl;
    },
    getClient: function() {
        return getClient;
    }
});
const _env = require("@llamaindex/env");
const _types = require("./types.js");
function getBaseUrl(baseUrl) {
    return baseUrl ?? (0, _env.getEnv)("LLAMA_CLOUD_BASE_URL") ?? _types.DEFAULT_BASE_URL;
}
function getAppBaseUrl(baseUrl) {
    return getBaseUrl(baseUrl).replace(/api\./, "");
}
async function getClient({ apiKey, baseUrl } = {}) {
    // Get the environment variables or use defaults
    baseUrl = getBaseUrl(baseUrl);
    apiKey = apiKey ?? (0, _env.getEnv)("LLAMA_CLOUD_API_KEY");
    const { PlatformApiClient } = await import("@llamaindex/cloud");
    return new PlatformApiClient({
        token: apiKey,
        environment: baseUrl
    });
}
