import { bundledChannelPlugins } from "../generated/bundled-channel-plugins.js";
//#region src/config/validate-channel-configs.ts
/**
* Run each registered channel plugin's optional `configSchema.validate` on the matching subtree.
*/
function validateChannelPluginConfigs(config) {
	const errors = [];
	const channelsCfg = config.channels ?? {};
	for (const [channelId, raw] of Object.entries(channelsCfg)) {
		const validate = bundledChannelPlugins.find((p) => p.id === channelId)?.configSchema?.validate;
		if (typeof validate !== "function") continue;
		const result = validate(raw);
		if (!result.ok) for (const e of result.errors ?? ["Invalid configuration"]) errors.push(`channels.${channelId}: ${e}`);
	}
	return errors;
}
function assertChannelPluginConfigs(config) {
	const errs = validateChannelPluginConfigs(config);
	if (errs.length === 0) return;
	throw new Error(`Channel configuration failed validation:\n${errs.join("\n")}`);
}
//#endregion
export { assertChannelPluginConfigs, validateChannelPluginConfigs };

//# sourceMappingURL=validate-channel-configs.js.map