import { p as readStringValue } from "./string-coerce-DKw2K5wM.js";
import { a as parseNodmixManifestInstallBase, c as resolveNodmixManifestOs, i as parseFrontmatterBool, l as resolveNodmixManifestRequires, n as getFrontmatterString, o as resolveNodmixManifestBlock, r as normalizeStringList, s as resolveNodmixManifestInstall, t as applyNodmixManifestInstallCommonFields, u as parseFrontmatterBlock } from "./frontmatter-CeGNcmGX.js";
//#region src/hooks/frontmatter.ts
function parseFrontmatter(content) {
	return parseFrontmatterBlock(content);
}
function parseInstallSpec(input) {
	const parsed = parseNodmixManifestInstallBase(input, [
		"bundled",
		"npm",
		"git"
	]);
	if (!parsed) return;
	const { raw } = parsed;
	const spec = applyNodmixManifestInstallCommonFields({ kind: parsed.kind }, parsed);
	if (typeof raw.package === "string") spec.package = raw.package;
	if (typeof raw.repository === "string") spec.repository = raw.repository;
	return spec;
}
function resolveNodmixMetadata(frontmatter) {
	const metadataObj = resolveNodmixManifestBlock({ frontmatter });
	if (!metadataObj) return;
	const requires = resolveNodmixManifestRequires(metadataObj);
	const install = resolveNodmixManifestInstall(metadataObj, parseInstallSpec);
	const osRaw = resolveNodmixManifestOs(metadataObj);
	const eventsRaw = normalizeStringList(metadataObj.events);
	return {
		always: typeof metadataObj.always === "boolean" ? metadataObj.always : void 0,
		emoji: readStringValue(metadataObj.emoji),
		homepage: readStringValue(metadataObj.homepage),
		hookKey: readStringValue(metadataObj.hookKey),
		export: readStringValue(metadataObj.export),
		os: osRaw.length > 0 ? osRaw : void 0,
		events: eventsRaw.length > 0 ? eventsRaw : [],
		requires,
		install: install.length > 0 ? install : void 0
	};
}
function resolveHookInvocationPolicy(frontmatter) {
	return { enabled: parseFrontmatterBool(getFrontmatterString(frontmatter, "enabled"), true) };
}
function resolveHookKey(hookName, entry) {
	return entry?.metadata?.hookKey ?? hookName;
}
//#endregion
export { resolveNodmixMetadata as i, resolveHookInvocationPolicy as n, resolveHookKey as r, parseFrontmatter as t };
