import { getWalletState } from "../services/walletconnect-service.mjs";
import { getAllToolStatus } from "../services/tool-config-service.mjs";
//#region extensions/crypto/src/commands/setup-command.ts
/**
* /setup — Show tool configuration status and setup instructions.
*
* Groups tools into:
*   - Ready (configured and working)
*   - Needs wallet (requires /connect first)
*   - Needs API keys (with setup instructions)
*
* All output uses tappable slash commands where possible.
*/
const setupCommand = {
	name: "setup",
	description: "Show which tools are configured and what keys are missing",
	acceptsArgs: false,
	requireAuth: true,
	handler: async (_ctx) => {
		const statuses = getAllToolStatus();
		const wallet = getWalletState();
		const ready = [];
		const needsWallet = [];
		const needsKeys = [];
		for (const s of statuses) if (s.configured && !s.walletRequired) ready.push(s);
		else if (s.configured && s.walletRequired && !wallet.connected) needsWallet.push(s);
		else if (s.configured && s.walletRequired && wallet.connected) ready.push(s);
		else if (s.missingKeys.length > 0) needsKeys.push(s);
		else if (s.walletRequired && !wallet.connected) needsWallet.push(s);
		else ready.push(s);
		const lines = ["**OpenClawnch Tool Setup**", ""];
		if (ready.length > 0) {
			lines.push(`**Ready (${ready.length} tools):**`);
			for (const s of ready) lines.push(`  ${s.label} — ${s.description}`);
			lines.push("");
		}
		if (needsWallet.length > 0) {
			lines.push(`**Needs wallet (${needsWallet.length} tools):**`);
			for (const s of needsWallet) lines.push(`  ${s.label} — ${s.description}`);
			lines.push("");
			lines.push("  Connect: /connect");
			lines.push("");
		}
		if (needsKeys.length > 0) {
			lines.push(`**Needs API keys (${needsKeys.length} tools):**`);
			for (const s of needsKeys) {
				const missingStr = s.missingKeys.map((k) => `\`${k}\``).join(", ");
				lines.push(`  **${s.label}** — ${s.description}`);
				lines.push(`    Missing: ${missingStr}`);
				if (s.keySource) lines.push(`    Get keys: ${s.keySource}`);
				if (s.setupHint) lines.push(`    Setup: ${s.setupHint}`);
				lines.push("");
			}
		}
		const total = statuses.length;
		const readyCount = ready.length;
		lines.push(`**${readyCount}/${total} tools ready.**`);
		if (needsKeys.length > 0) {
			lines.push("");
			if (process.env.FLY_APP_NAME) lines.push("Use /flykeys to set API keys, then /flyrestart to apply.");
			else lines.push("Add the missing API keys to your .env file or run `openclawnch init` to reconfigure.");
		}
		return { text: lines.join("\n") };
	}
};
//#endregion
export { setupCommand };

//# sourceMappingURL=setup-command.mjs.map