"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const network_1 = __importDefault(require("@ledgerhq/live-network/network"));
const qs_1 = __importDefault(require("qs"));
const live_env_1 = require("@ledgerhq/live-env");
const mock_json_1 = __importDefault(require("./mock.json"));
const api = {
    fetchLiveAppManifests: async (url, params) => {
        if ((0, live_env_1.getEnv)("MOCK")) {
            if ((0, live_env_1.getEnv)("MOCK_REMOTE_LIVE_MANIFEST")) {
                return [
                    ...mock_json_1.default,
                    ...JSON.parse((0, live_env_1.getEnv)("MOCK_REMOTE_LIVE_MANIFEST")),
                ];
            }
            return mock_json_1.default;
        }
        try {
            const { data } = await (0, network_1.default)({
                method: "GET",
                params,
                paramsSerializer: params => {
                    return qs_1.default.stringify(params, { arrayFormat: "repeat" });
                },
                url,
            });
            if (!Array.isArray(data))
                throw new Error("Response is not an Array");
            return data;
        }
        catch (e) {
            console.error(e);
            return [];
        }
    },
};
exports.default = api;
//# sourceMappingURL=index.js.map