import { bundledChannelPlugins } from "../../../../generated/bundled-channel-plugins.js";
import { listChannelPlugins, syncChannelPluginsFromManager } from "../../../../channels/plugins/registry.js";
import { channelSetupWizardToConfigurator } from "./wizard-to-configurator.js";
import { channelOnboardToConfigurator } from "./onboard-to-configurator.js";
//#region src/cli/commands/onboard/channels/registry.ts
function ensureChannelRegistrySeeded() {
	if (listChannelPlugins().length === 0) syncChannelPluginsFromManager(bundledChannelPlugins);
}
function sortByMetaOrder(plugins) {
	return [...plugins].sort((a, b) => {
		const oa = a.meta.order ?? 999;
		const ob = b.meta.order ?? 999;
		if (oa !== ob) return oa - ob;
		return a.id.localeCompare(b.id);
	});
}
function getChannelConfigurators() {
	ensureChannelRegistrySeeded();
	const out = [];
	for (const plugin of sortByMetaOrder([...listChannelPlugins()])) if (plugin.onboard) out.push(channelOnboardToConfigurator(plugin));
	else if (plugin.setupWizard) out.push(channelSetupWizardToConfigurator(plugin.setupWizard, {
		name: plugin.meta.label,
		description: plugin.meta.blurb
	}));
	return out;
}
//#endregion
export { getChannelConfigurators };

//# sourceMappingURL=registry.js.map