/**
 * Market Research Report Generator
 *
 * Generates markdown reports summarizing vision analysis results.
 */
import fs from 'fs/promises';
import path from 'path';
/**
 * ReportGenerator - Generates market research reports
 *
 * **Usage**:
 * ```typescript
 * await ReportGenerator.generate(insights);
 * // Creates .specweave/reports/market-research.md
 * ```
 */
export class ReportGenerator {
    /**
     * Generate market research report
     *
     * @param insights - Vision insights to include in report
     * @param reportPath - Optional custom report path
     */
    static async generate(insights, reportPath = ReportGenerator.REPORT_PATH) {
        const markdown = ReportGenerator.createMarkdown(insights);
        // Ensure reports directory exists
        const dir = path.dirname(reportPath);
        await fs.mkdir(dir, { recursive: true });
        // Write report
        await fs.writeFile(reportPath, markdown, 'utf-8');
    }
    /**
     * Create markdown content from insights
     *
     * @param insights - Vision insights
     * @returns Markdown string
     */
    static createMarkdown(insights) {
        const now = new Date();
        const date = now.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
        const keywordsList = insights.keywords.map(k => `- ${k}`).join('\n');
        const confidencePercent = ((insights.confidence || 0) * 100).toFixed(0);
        const sections = [
            '# Market Research Report',
            '',
            `**Generated**: ${date}`,
            `**Timestamp**: ${now.toISOString()}`,
            '',
            '---',
            '',
            '## Product Vision',
            '',
            insights.rawVision,
            '',
            '## Keywords & Domain Focus',
            '',
            '**Extracted Keywords**:',
            '',
            keywordsList,
            '',
            '## Market Classification',
            '',
            `**Category**: ${insights.market}`,
            `**Confidence**: ${confidencePercent}%`,
            '',
            '## Opportunity Analysis',
            '',
            `**Opportunity Score**: ${insights.opportunityScore}/10`,
            `**Viral Potential**: ${insights.viralPotential ? 'Yes' : 'No'}`,
            ''
        ];
        // Competitors section
        sections.push('## Competitive Landscape');
        sections.push('');
        if (insights.competitors.length > 0) {
            sections.push('**Similar Products**:');
            sections.push('');
            sections.push('| Product | URL | Similarity | Strengths | Weaknesses |');
            sections.push('|---------|-----|------------|-----------|------------|');
            for (const comp of insights.competitors) {
                const strengths = comp.strengths.join(', ') || 'N/A';
                const weaknesses = comp.weaknesses.join(', ') || 'N/A';
                sections.push(`| ${comp.name} | ${comp.url || 'N/A'} | N/A | ${strengths} | ${weaknesses} |`);
            }
        }
        else {
            sections.push('No similar products identified.');
        }
        sections.push('');
        // Follow-up Questions section
        if (insights.followUpQuestions.length > 0) {
            sections.push('## Recommended Next Steps');
            sections.push('');
            sections.push('To refine your product strategy, consider these questions:');
            sections.push('');
            insights.followUpQuestions.forEach((q, idx) => {
                sections.push(`${idx + 1}. **${q.question}**`);
                sections.push('');
            });
        }
        // Footer
        sections.push('---');
        sections.push('');
        sections.push('*This report was generated by SpecWeave Strategic Init*');
        sections.push('');
        return sections.join('\n');
    }
}
/**
 * Default report path
 */
ReportGenerator.REPORT_PATH = '.specweave/reports/market-research.md';
//# sourceMappingURL=ReportGenerator.js.map