import network from "@ledgerhq/live-network/network";
import qs from "qs";
import { getEnv } from "@ledgerhq/live-env";
import mockData from "./mock.json";
const api = {
    fetchLiveAppManifests: async (url, params) => {
        if (getEnv("MOCK")) {
            if (getEnv("MOCK_REMOTE_LIVE_MANIFEST")) {
                return [
                    ...mockData,
                    ...JSON.parse(getEnv("MOCK_REMOTE_LIVE_MANIFEST")),
                ];
            }
            return mockData;
        }
        try {
            const { data } = await network({
                method: "GET",
                params,
                paramsSerializer: params => {
                    return qs.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 [];
        }
    },
};
export default api;
//# sourceMappingURL=index.js.map