import { c as parseProviderSource } from "./manifest-CslkSMd8.mjs";
import { o as normalizeGitRemoteUrl } from "./src-DDJn_-JW.mjs";
//#region src/lib/git-source.ts
function parseGitProviderSource(source) {
	const parsed = parseProviderSource(source);
	if (parsed.type !== "git") return null;
	return parseGitProviderValue(parsed);
}
function normalizeGithubUpstreamSource(upstream) {
	return {
		ref: upstream.ref,
		url: normalizeGitRemoteUrl(`https://github.com/${upstream.repo}`)
	};
}
function parseGitProviderValue(parsed) {
	const separatorIndex = parsed.value.lastIndexOf("@");
	const hasRef = separatorIndex > parsed.value.indexOf("/");
	const repoValue = hasRef ? parsed.value.slice(0, separatorIndex) : parsed.value;
	const ref = hasRef ? parsed.value.slice(separatorIndex + 1) : void 0;
	if (repoValue.startsWith("http://") || repoValue.startsWith("https://") || repoValue.startsWith("git@")) return {
		ref,
		url: normalizeGitRemoteUrl(repoValue)
	};
	return {
		ref,
		url: normalizeGitRemoteUrl(`https://github.com/${repoValue}`)
	};
}
//#endregion
export { parseGitProviderSource as n, normalizeGithubUpstreamSource as t };

//# sourceMappingURL=git-source-CDrBBD6o.mjs.map