import { succeeded } from '../../../../modules/setup-wizard/entities/stepOutcome/stepOutcome.js';
import { NextActionsPresenter } from '../../../../modules/setup-wizard/interface-adapters/presenters/nextActions.presenter.js';
import { isValidSecret } from '../../../../shared/services/secretGenerator.js';
const DEFAULT_HOST = 'YOUR_HOST';
const DEFAULT_PORT = 3847;
function pickPlatformOrDefault(platform) {
    if (platform === 'github' || platform === 'gitlab')
        return platform;
    return 'github';
}
export class DisplayNextActionsStep {
    id = 'next-actions';
    title = 'Prochaines actions';
    async detect(_context) {
        return null;
    }
    async execute(context) {
        const presenter = new NextActionsPresenter();
        const platform = pickPlatformOrDefault(context.project.platform);
        const projectPath = context.project.localPath ?? '/unknown';
        const envContents = context.gateways.envFile.read(projectPath);
        const candidateSecret = platform === 'github' ? envContents.githubSecret : envContents.gitlabSecret;
        const webhookSecret = candidateSecret && isValidSecret(candidateSecret) ? candidateSecret : '';
        const viewModel = presenter.present({
            platform,
            host: DEFAULT_HOST,
            port: DEFAULT_PORT,
            webhookSecret,
            projectPath,
            showSecrets: context.flags.showSecrets,
        });
        context.emitter.emitInstructions(viewModel.lines);
        return succeeded('Prochaines actions affichées', {
            webhookUrl: viewModel.webhookUrl,
            eventType: viewModel.eventType,
            maskedSecret: viewModel.maskedSecret,
            fullSecret: viewModel.fullSecret,
            lines: viewModel.lines,
        });
    }
}
//# sourceMappingURL=displayNextActions.step.js.map