import { g as getAllSubstrates } from './src-DG3l2-J-.js';
import { json } from '@sveltejs/kit';
import './dual-scope-db-ATrwq0LH.js';
import './paths-2M_UxD_H.js';
import 'node:fs';
import 'node:path';
import 'node:os';
import 'node:events';
import 'node:diagnostics_channel';
import 'fs';
import 'events';
import 'util';
import 'path';
import 'assert';
import 'worker_threads';
import 'module';
import 'node:url';
import 'url';
import 'buffer';
import 'node:module';
import 'node:child_process';
import 'node:crypto';
import 'node:process';
import 'node:async_hooks';
import './indexes-aYlULWG3.js';
import './utils-BvHPJOVk.js';

//#region src/routes/api/brain/substrate/[name]/+server.ts
/**
* Substrate-filtered BRAIN super-graph endpoint.
*
* GET /api/brain/substrate/:name
*   → { nodes: BrainNode[], edges: BrainEdge[], counts, truncated }
*
* `:name` must be one of: brain | nexus | tasks | conduit | signaldock
*
* Query params:
*   limit      — max nodes to return (default 500, max 2000)
*   min_weight — minimum quality/weight threshold 0.0–1.0 (default 0)
*
* Returns 400 for unrecognised substrate names.
* This endpoint is equivalent to GET /api/brain?substrates=<name>
* but provides a cleaner URL and explicit 400 on bad substrate names.
*/
var VALID_SUBSTRATES = new Set([
	"brain",
	"nexus",
	"tasks",
	"conduit",
	"agent-registry"
]);
var GET = ({ locals, params, url }) => {
	const name = params.name;
	if (!VALID_SUBSTRATES.has(name)) return json({ error: `Unknown substrate: "${name}". Valid values: brain, nexus, tasks, conduit, signaldock` }, { status: 400 });
	const limitParam = Number(url.searchParams.get("limit") ?? "500");
	const limit = Math.min(Math.max(1, Number.isNaN(limitParam) ? 500 : limitParam), 2e3);
	const minWeightParam = url.searchParams.get("min_weight");
	const minWeight = minWeightParam !== null ? Math.max(0, parseFloat(minWeightParam)) : 0;
	try {
		return json(getAllSubstrates({
			limit,
			substrates: [name],
			minWeight,
			projectCtx: locals.projectCtx
		}));
	} catch (err) {
		return json({ error: String(err) }, { status: 500 });
	}
};

export { GET };
//# sourceMappingURL=_server.ts-CvR1dmGd.js.map
