import { c as normalizeOptionalString } from "./string-coerce-mnp54Vah.js";
import { t as getActivePluginChannelRegistryFromState } from "./runtime-channel-state-CQNj7c3E.js";
//#region src/channels/plugins/registry-loaded-read.ts
/**
* Minimal loaded-plugin reader for hot outbound/read paths.
*/
function coerceLoadedChannelPlugin(plugin) {
	const id = normalizeOptionalString(plugin?.id) ?? "";
	if (!plugin || !id) return;
	if (!plugin.meta || typeof plugin.meta !== "object") plugin.meta = {};
	return plugin;
}
/**
* Reads one loaded channel plugin directly from active runtime state.
*/
function getLoadedChannelPluginForRead(id) {
	const resolvedId = normalizeOptionalString(id) ?? "";
	if (!resolvedId) return;
	const registry = getActivePluginChannelRegistryFromState();
	if (!registry || !Array.isArray(registry.channels)) return;
	for (const entry of registry.channels) {
		const plugin = coerceLoadedChannelPlugin(entry?.plugin);
		if (plugin && plugin.id === resolvedId) return plugin;
	}
}
//#endregion
export { getLoadedChannelPluginForRead as t };
