import type { Metadata } from 'next';
import { getSEOConfig } from '../../../lib/seo-config';
import SupportServerComponent from '@/app/components/support/SupportServerComponent';

// Generate static params for supported locales
export async function generateStaticParams() {
    return [
        { locale: 'zh' },
        { locale: 'zh-CN' },
        { locale: 'zh-TW' },
        { locale: 'en' },
    ];
}

// Generate metadata for the support page
export async function generateMetadata({
    params: { locale },
}: {
    params: { locale: string };
}): Promise<Metadata> {
    const language = locale === 'zh' ? 'zh-CN' : locale === 'zh-CN' ? 'zh-CN' : locale === 'zh-TW' ? 'zh-TW' : 'en';
    const seo = getSEOConfig('support', language);

    return {
        title: seo.title,
        description: seo.description,
        keywords: seo.keywords,
        openGraph: {
            title: seo.openGraph?.title,
            description: seo.openGraph?.description,
            type: seo.openGraph?.type as any,
            images: seo.openGraph?.images,
        },
        twitter: {
            card: seo.twitter?.card as any,
            title: seo.twitter?.title,
            description: seo.twitter?.description,
            images: seo.twitter?.images,
        },
        alternates: {
            canonical: locale === 'zh' ? '/support' : `/${locale}/support`,
            languages: {
                'zh-CN': '/support',
                'zh-TW': '/zh-TW/support',
                en: '/en/support',
            },
        },
    };
}

export default function SupportPage({ params: { locale } }: { params: { locale: string } }) {
    const mappedLocale = locale === 'zh' ? 'zh-CN' : locale === 'zh-CN' ? 'zh-CN' : locale === 'zh-TW' ? 'zh-TW' : 'en';
    
    return <SupportServerComponent locale={mappedLocale} />;
}
