import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
import { logger } from "../../../logger/index.js";
import { parseUrl } from "../../../util/url.js";
import { ExternalHostError } from "../../../types/errors/external-host-error.js";
import { memCacheProvider } from "../../../util/http/cache/memory-http-cache-provider.js";
import { Http } from "../../../util/http/index.js";
import { PRESET_DEP_NOT_FOUND, parsePreset } from "../util.js";
//#region lib/config/presets/http/index.ts
var http_exports = /* @__PURE__ */ __exportAll({ getPreset: () => getPreset });
const http = new Http("preset");
async function getPreset({ repo: url }) {
	const parsedUrl = parseUrl(url);
	let response;
	if (!parsedUrl) {
		logger.debug(`Preset URL ${url} is malformed`);
		throw new Error(PRESET_DEP_NOT_FOUND);
	}
	try {
		response = await http.getText(url, { cacheProvider: memCacheProvider });
	} catch (err) {
		if (err instanceof ExternalHostError) throw err;
		logger.debug(`Preset file ${url} not found: ${err.message}`);
		throw new Error(PRESET_DEP_NOT_FOUND);
	}
	return parsePreset(response.body, parsedUrl.pathname);
}
//#endregion
export { http_exports };

//# sourceMappingURL=index.js.map