globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { d as renderTemplate, f as maybeRenderHead, i as renderComponent, m as addAttribute, w as createAstro, x as unescapeHTML } from "./server_DAChoow1.mjs";
import { t as createComponent } from "./compiler_CLrjY88v.mjs";
import { j as getBySlug } from "./crypto_CY2zBtG3.mjs";
import { t as getDb } from "./db_DCN9iNkm.mjs";
import { t as $$Base } from "./Base_CShmIjgp.mjs";
import { t as sanitizeContentBody } from "./sanitize_CLHlWQbC.mjs";
import { a as layers, i as getModule, n as depClosure, t as MOD_CMS_MODULES } from "./catalogue_C7Gcv984.mjs";
import { env } from "cloudflare:workers";
//#region src/components/ModuleGraph.astro
createAstro("https://astro.build");
var $$ModuleGraph = createComponent(($$result, $$props, $$slots) => {
	const Astro = $$result.createAstro($$props, $$slots);
	Astro.self = $$ModuleGraph;
	const { moduleId } = Astro.props;
	const nodeIds = depClosure(moduleId);
	const nodeSet = new Set(nodeIds);
	const nodeModules = nodeIds.map((id) => getModule(id)).filter((m) => !!m);
	const presentLayers = [
		"L3",
		"L2",
		"L1",
		"L0",
		"UI"
	].filter((lid) => nodeModules.some((m) => m.layer === lid));
	const LC = {
		L0: "var(--l0)",
		L1: "var(--l1)",
		L2: "var(--l2)",
		L3: "var(--l3)",
		UI: "var(--lUI)"
	};
	const ZONE = {
		L0: "var(--graph-zone0)",
		L1: "var(--graph-zone1)",
		L2: "var(--graph-zone2)",
		L3: "var(--graph-zone3)",
		UI: "var(--graph-zoneUI)"
	};
	const TC = {
		available: "#1f9d6b",
		design: "#c5871d",
		roadmap: "#9095a1"
	};
	const W = 820;
	const padX = 70;
	const bandH = 110;
	const top = 24;
	const H = top + presentLayers.length * bandH + 20;
	const pos = {};
	presentLayers.forEach((lid, i) => {
		const inLayer = nodeModules.filter((m) => m.layer === lid);
		const y = top + i * bandH + bandH / 2;
		const avail = 700;
		inLayer.forEach((m, j) => {
			const x = inLayer.length === 1 ? 420 : padX + avail * j / (inLayer.length - 1);
			pos[m.id] = {
				x,
				y
			};
		});
	});
	const edges = [];
	for (const m of nodeModules) for (const dep of m.deps) if (nodeSet.has(dep) && pos[m.id] && pos[dep]) edges.push({
		from: m.id,
		to: dep
	});
	function trackPath(a, b) {
		const my = (a.y + b.y) / 2;
		return `M${a.x},${a.y} C${a.x},${my} ${b.x},${my} ${b.x},${b.y}`;
	}
	const layerMeta = new Map(layers.map((l) => [l.id, l]));
	return renderTemplate`${maybeRenderHead($$result)}<div class="graph-wrap" role="img"${addAttribute(`Dependency graph for ${moduleId} module`, "aria-label")}><svg class="module-graph"${addAttribute(`0 0 ${W} ${H}`, "viewBox")}${addAttribute(W, "width")}${addAttribute(H, "height")} xmlns="http://www.w3.org/2000/svg">${presentLayers.map((lid, i) => {
		const y = top + i * bandH;
		const meta = layerMeta.get(lid);
		return renderTemplate`<g class="zoneband"><rect x="0"${addAttribute(y, "y")}${addAttribute(W, "width")}${addAttribute(100, "height")} rx="12"${addAttribute(ZONE[lid], "fill")}></rect><text x="14"${addAttribute(y + 26, "y")}${addAttribute(LC[lid], "fill")} font-size="13" font-weight="800">${lid} · ${meta?.name ?? lid}</text><text x="14"${addAttribute(y + 44, "y")} fill="var(--graph-ink-faint)" font-size="11">${meta?.blurb ?? ""}</text></g>`;
	})}<g class="tracks">${edges.map((e) => {
		const a = pos[e.from];
		const b = pos[e.to];
		if (!a || !b) return null;
		return renderTemplate`<path${addAttribute(trackPath(a, b), "d")} fill="none" stroke="var(--graph-line)" stroke-width="2" stroke-linecap="round"></path>`;
	})}</g><g class="stations">${nodeModules.map((m) => {
		const p = pos[m.id];
		if (!p) return null;
		const caps = (m.capabilities?.length ?? 0) + (m.providers?.length ?? 0);
		const isFocus = m.id === moduleId;
		const r = isFocus ? 14 : Math.max(8, Math.min(12, 8 + caps * .25));
		const stroke = isFocus ? LC[m.layer] ?? "var(--mod-color-accent)" : TC[m.status] ?? "#9095a1";
		const strokeWidth = isFocus ? 4 : 3;
		const dash = m.status !== "available" ? "3 3" : void 0;
		return renderTemplate`<g${addAttribute(["station", isFocus && "station--focus"], "class:list")}${addAttribute(m.id, "data-module")}><circle${addAttribute(p.x, "cx")}${addAttribute(p.y, "cy")}${addAttribute(r + 10, "r")} fill="transparent"></circle><circle${addAttribute(p.x, "cx")}${addAttribute(p.y, "cy")}${addAttribute(r, "r")} fill="var(--mod-color-surface-raised)"${addAttribute(stroke, "stroke")}${addAttribute(strokeWidth, "stroke-width")}${addAttribute(dash, "stroke-dasharray")}></circle>${isFocus && renderTemplate`<circle${addAttribute(p.x, "cx")}${addAttribute(p.y, "cy")}${addAttribute(r + 5, "r")} fill="none"${addAttribute(stroke, "stroke")} stroke-width="2" opacity="0.45"></circle>`}<text${addAttribute(p.x, "x")}${addAttribute(p.y - r - 8, "y")} text-anchor="middle" fill="var(--graph-ink)" font-size="12" font-weight="600">${m.name}</text><text${addAttribute(p.x, "x")}${addAttribute(p.y + r + 14, "y")} text-anchor="middle" fill="var(--graph-ink-faint)" font-size="10">${m.pkg.replace("@platform-modules/", "")}</text></g>`;
	})}</g></svg></div>`;
}, "/home/user/runs/content-model-t15-final-build/repo/apps/mod-cms/src/components/ModuleGraph.astro", void 0);
//#endregion
//#region src/pages/module/[slug].astro
var _slug__exports = /* @__PURE__ */ __exportAll({
	default: () => $$Slug,
	file: () => $$file,
	prerender: () => false,
	url: () => $$url
});
createAstro("https://astro.build");
var $$Slug = createComponent(async ($$result, $$props, $$slots) => {
	const Astro = $$result.createAstro($$props, $$slots);
	Astro.self = $$Slug;
	const slug = Astro.params.slug;
	const allowed = new Set(MOD_CMS_MODULES);
	if (!slug || !allowed.has(slug)) return new Response(null, { status: 404 });
	const moduleId = slug;
	const mod = getModule(moduleId);
	if (!mod) return new Response(null, { status: 404 });
	let bodyHtml = null;
	try {
		const { db } = getDb(env);
		const entry = await getBySlug(db, "module", slug);
		if (entry?.status === "published" && entry.body) bodyHtml = entry.body;
	} catch {}
	return renderTemplate`${renderComponent($$result, "Base", $$Base, {
		"title": `${mod.name} · mod-cms`,
		"description": mod.tagline
	}, { "default": ($$result) => renderTemplate`${maybeRenderHead($$result)}<p class="page-meta"><a href="/">← Home</a></p><p class="hero__eyebrow">${mod.layer} · ${mod.pkg}</p><h1>${mod.name}</h1><p>${mod.tagline}</p>${renderComponent($$result, "ModuleGraph", $$ModuleGraph, { "moduleId": moduleId })}${bodyHtml ? renderTemplate`<div class="cms-body">${unescapeHTML(sanitizeContentBody(bodyHtml))}</div>` : renderTemplate`<p>${mod.tagline}</p>`}<section class="section"><h2>Capabilities</h2><ul class="cap-list">${mod.capabilities.map((cap) => renderTemplate`<li><strong>${cap.name}</strong><span>${cap.desc}</span></li>`)}</ul></section>` })}`;
}, "/home/user/runs/content-model-t15-final-build/repo/apps/mod-cms/src/pages/module/[slug].astro", void 0);
var $$file = "/home/user/runs/content-model-t15-final-build/repo/apps/mod-cms/src/pages/module/[slug].astro";
var $$url = "/module/[slug]";
//#endregion
//#region \0virtual:astro:page:src/pages/module/[slug]@_@astro
var page = () => _slug__exports;
//#endregion
export { page };
