import { setupTelegramOnboard } from "../../../../../extensions/telegram/src/adapters/onboard-cli.js";
import { getChannelConfigurators } from "./registry.js";
import { select } from "@inquirer/prompts";
//#region src/cli/commands/onboard/channels/index.ts
/**
* Channels configuration for onboarding — multi-channel loop with registry-driven configurators.
*/
function getChannelStatuses(config, configurators) {
	return configurators.map((cfg) => ({
		id: cfg.id,
		name: cfg.name,
		description: cfg.description,
		configured: cfg.isConfigured(config)
	}));
}
async function promptChannelSelection(statuses) {
	const choices = statuses.map((status) => ({
		value: status.id,
		name: `${status.name.padEnd(14)} ${status.configured ? "[configured]" : "[not configured]"}`,
		description: status.description
	}));
	choices.push({
		value: "done",
		name: "[Done]",
		description: "Save and exit channel setup"
	});
	const selected = await select({
		message: "Select a channel to configure:",
		choices
	});
	return selected === "done" ? null : selected;
}
async function configureChannel(config, channelId, configurators) {
	const configurator = configurators.find((c) => c.id === channelId);
	if (!configurator) {
		console.log(`⚠️  Unknown channel: ${channelId}`);
		return config;
	}
	return configurator.configure(config);
}
/**
* Interactive multi-channel onboarding entry point.
*/
async function setupChannels(config) {
	console.log("\n💬 Channel setup\n");
	console.log("═".repeat(50));
	let currentConfig = config;
	const configurators = getChannelConfigurators();
	while (true) {
		const selected = await promptChannelSelection(getChannelStatuses(currentConfig, configurators));
		if (selected === null) break;
		currentConfig = await configureChannel(currentConfig, selected, configurators);
		console.log("\n" + "─".repeat(50) + "\n");
	}
	console.log("\n✅ Channel setup complete\n");
	return currentConfig;
}
//#endregion
export { getChannelConfigurators, setupChannels, setupTelegramOnboard };

//# sourceMappingURL=index.js.map