import { f as readStringValue } from "./string-coerce-DyL154ka.js";
import { a as parseFrontmatterBool, c as resolveDaoCoreManifestOs, i as parseDaoCoreManifestInstallBase, l as resolveDaoCoreManifestRequires, n as getFrontmatterString, o as resolveDaoCoreManifestBlock, r as normalizeStringList, s as resolveDaoCoreManifestInstall, t as applyDaoCoreManifestInstallCommonFields, u as parseFrontmatterBlock } from "./frontmatter-CpLlMj9v.js";
//#region src/hooks/frontmatter.ts
function parseFrontmatter(content) {
	return parseFrontmatterBlock(content);
}
function parseInstallSpec(input) {
	const parsed = parseDaoCoreManifestInstallBase(input, [
		"bundled",
		"npm",
		"git"
	]);
	if (!parsed) return;
	const { raw } = parsed;
	const spec = applyDaoCoreManifestInstallCommonFields({ 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 resolveDaoCoreMetadata(frontmatter) {
	const metadataObj = resolveDaoCoreManifestBlock({ frontmatter });
	if (!metadataObj) return;
	const requires = resolveDaoCoreManifestRequires(metadataObj);
	const install = resolveDaoCoreManifestInstall(metadataObj, parseInstallSpec);
	const osRaw = resolveDaoCoreManifestOs(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 { resolveHookKey as i, resolveDaoCoreMetadata as n, resolveHookInvocationPolicy as r, parseFrontmatter as t };
