import { error } from '@sveltejs/kit';

//#region src/routes/code/symbol/[name]/+page.server.ts
/**
* /code/symbol/[name] — ego-network page server load.
*
* Wires through `/api/nexus/symbol/[name]` to kill the duplicate SQL
* path flagged by the T990 code audit.  Returns the raw API payload
* + a friendly community label for the breadcrumb.
*
* @task T990
* @wave 1B
*/
var load = async ({ params, fetch }) => {
	const name = decodeURIComponent(params.name);
	const resp = await fetch(`/api/nexus/symbol/${encodeURIComponent(name)}`);
	if (!resp.ok) {
		if (resp.status === 404) error(404, `Symbol "${name}" not found`);
		if (resp.status === 503) error(503, "nexus.db not available");
		error(resp.status, "Failed to load symbol");
	}
	const payload = await resp.json();
	const center = payload.nodes.find((n) => n.id === payload.center) ?? null;
	let communityLabel = null;
	if (center?.communityId) {
		const listResp = await fetch("/api/nexus?only=communities");
		if (listResp.ok) communityLabel = (await listResp.json()).communities.find((c) => c.id === center.communityId)?.rawLabel ?? center.communityId.replace("comm_", "Cluster ");
	}
	return {
		symbolName: name,
		nodes: payload.nodes,
		edges: payload.edges,
		center,
		communityLabel
	};
};

var _page_server_ts = /*#__PURE__*/Object.freeze({
	__proto__: null,
	load: load
});

const index = 18;
let component_cache;
const component = async () => component_cache ??= (await import('./_page.svelte-VtPkM6fK.js')).default;
const server_id = "src/routes/code/symbol/[name]/+page.server.ts";
const imports = ["_app/immutable/nodes/18.QXXMklWH.js","_app/immutable/chunks/CQQRJ2Hr.js","_app/immutable/chunks/DyGQ_VXC.js","_app/immutable/chunks/DrKWWDpL.js","_app/immutable/chunks/DKX-2-1g.js","_app/immutable/chunks/CQCxd1p9.js","_app/immutable/chunks/D8NsLz6i.js","_app/immutable/chunks/o1PZ6Kzq.js","_app/immutable/chunks/RptFUp2P.js","_app/immutable/chunks/CEqOYim7.js","_app/immutable/chunks/CqF5Lomf.js"];
const stylesheets = ["_app/immutable/assets/cluster-label-layer.aRgASjnn.css","_app/immutable/assets/no-face-up.BlswZ73M.css","_app/immutable/assets/nexus-adapter.DuSZKvuH.css","_app/immutable/assets/Tabs.CU9_rsWl.css","_app/immutable/assets/ui.CH-9N9-0.css","_app/immutable/assets/18.d18ttKnU.css"];
const fonts = [];

export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
//# sourceMappingURL=18-C2n16Ctc.js.map
