import React from 'react';
import { TradingViewWidget } from '@/components/TradingViewWidget';

interface StockChartProps {
  symbol: string;
}

export function StockChart({ symbol }: StockChartProps) {
    // Simple heuristic to detect market. 
    // If 6 digits at start or ends with .SH/.SZ, it's likely China.
    // Otherwise default to US (or let TradingView handle it).
    const isChina = /^\d{6}/.test(symbol) || symbol.endsWith('.SH') || symbol.endsWith('.SZ');
    const market = isChina ? 'china' : 'us';

  return (
        <div className="h-[500px] w-full mt-4">
             <TradingViewWidget symbol={symbol} market={market} height={500} />
    </div>
  );
}
