import React from 'react';
import { Bot, Newspaper, LineChart, Share2, TrendingUp, TrendingDown, ChevronsUp, ChevronsDown, Landmark, Building2, User, ArrowUp, ArrowDown, Minus } from 'lucide-react';
import ReactMarkdown from 'react-markdown';
import HistoricalChart from './HistoricalChart';
const SectionTitle = ({ icon, title, subtitle }) => (
  
    
    {subtitle && (
      
{subtitle}
    )}
  
 
);
const MetricCard = ({ title, value, subtitle, trend }) => {
  const getTrendIcon = () => {
    if (trend > 0) return ;
    if (trend < 0) return ;
    return ;
  };
  const getTrendColor = () => {
    if (trend > 0) return 'text-green-400';
    if (trend < 0) return 'text-red-400';
    return 'text-gray-400';
  };
  return (
    
      
      
        
          {title}
          {trend !== undefined && getTrendIcon()}
        
 
        {value}
        {subtitle && (
          
            {subtitle}
          
        )}
      
 
     
  );
};
const NewsCard = ({ item, index }) => (
  
    
    
      
      
      
        {item.title}
      
      
      
        {item.source}
        Click to read
      
     
  
);
function ResultsDisplay({ result }) {
  if (!result) return null;
  const { 
    company_name, 
    current_price, 
    previous_close, 
    day_high, 
    day_low, 
    fifty_two_week_high, 
    fifty_two_week_low, 
    market_cap, 
    pe_ratio, 
    sector, 
    industry, 
    ceo, 
    intelligence_briefing, 
    llm_analysis 
  } = result;
  const price_change = current_price - previous_close;
  const price_change_percent = ((price_change / previous_close) * 100);
  const advisorReportText = llm_analysis?.llm_report;
  const handleShare = () => {
    if (navigator.share) {
      navigator.share({
        title: `${company_name} Analysis`,
        text: `Check out this comprehensive analysis of ${company_name}`,
        url: window.location.href,
      });
    } else {
      navigator.clipboard.writeText(window.location.href);
      alert('Analysis link copied to clipboard!');
    }
  };
  return (
    
      
      
        
        
          
            
            
            
              {company_name}
            
            
            
              
                 
                {sector}
              
              
                 
                {industry}
              
              
                 
                CEO: {ceo}
              
            
           
          
          
         
       
      
        } 
          title="Key Metrics" 
          subtitle="Real-time financial indicators and performance metrics"
        />
        
        
          = 0 ? '+' : ''}₹${price_change.toFixed(2)} (${price_change_percent >= 0 ? '+' : ''}${price_change_percent.toFixed(2)}%)`}
            trend={price_change}
          />
          
          
          
          
        
       
      
        } 
          title="Price Movement" 
          subtitle="Historical price action over the last 100 trading days"
        />
        
        
       
      {advisorReportText && (
        
          } 
            title="AI Analyst Report"
            subtitle="Comprehensive analysis powered by advanced AI models and real-time market data"
          />
          
          
            
            
              
                
                AI Generated
                •
                Powered by AI
               
              
              
                 ,
                    h2: ({node, ...props}) => ,
                    h3: ({node, ...props}) => ,
                    ul: ({node, ...props}) => ,
                    ol: ({node, ...props}) => 
,
                    li: ({node, ...props}) => ,
                    p: ({node, ...props}) => ,
                    strong: ({node, ...props}) => ,
                    blockquote: ({node, ...props}) => (
                      
                    ),
                  }}
                >
                  {advisorReportText} 
             
           
         
      )}
      
      
        } 
          title="Market Intelligence" 
          subtitle="Latest news and sentiment analysis from multiple sources"
        />
        
        {intelligence_briefing?.articles?.length > 0 ? (
          
            {intelligence_briefing.articles.slice(0, 9).map((item, index) => (
              
            ))}
          
        ) : (
          
            
            No news articles found for this symbol.
            Try checking back later or verify the ticker symbol.
           
        )}
      
 
     
  );
}
export default ResultsDisplay;