import { getFundingSnapshot, getPosts } from '@/lib/api'
import type { Metadata } from 'next'
import BtcPageClient from './BtcPageClient'

const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://trumpsignal.com'
export const revalidate = 30

interface BtcPageProps {
  params: Promise<{ locale: string }>
}

export async function generateMetadata({
  params,
}: BtcPageProps): Promise<Metadata> {
  const { locale } = await params
  const isZh = false  // i18n shelved — Chinese branches kept as dead code for future revival; see messages/zh.json

  return {
    title: isZh ? 'BTC 周期底部信号扫描器' : 'BTC Bottom Reversal Scanner',
    description: isZh
      ? 'Trump Alpha 的比特币周期底部扫描器，使用 AHR999、200 周均线和 Pi Cycle Bottom 三项经典信号做 2-of-3 共振判断，识别低频、高确定性的 BTC 长线底部区域。'
      : 'Bitcoin macro-bottom scanner using a 2-of-3 price confluence: AHR999 deep-value zone, price near the 200-week moving average, and Pi Cycle Bottom. Rare, high-conviction long-only signals.',
    keywords: isZh
      ? [
          'BTC 底部信号',
          '比特币周期底部',
          'AHR999',
          '200 周均线',
          'Pi Cycle Bottom',
          '比特币反转信号',
          '加密价格共振',
        ]
      : [
          'Bitcoin bottom signal',
          'AHR999',
          '200-week moving average',
          'Pi Cycle Bottom',
          'BTC cycle bottom',
          'Bitcoin macro bottom',
          'Bitcoin reversal signal',
          'crypto price confluence',
        ],
    openGraph: {
      title: isZh ? 'BTC 周期底部信号扫描器 | Trump Alpha' : 'BTC Bottom Reversal Scanner | Trump Alpha',
      description: isZh
        ? '用 AHR999、200 周均线和 Pi Cycle Bottom 识别比特币宏观底部。低频，但每次触发都服务于长周期反转。'
        : 'Bitcoin macro-bottom detector: 2-of-3 confluence across AHR999, 200-week MA, and Pi Cycle Bottom. Rare, high-conviction long-only signals.',
    },
    alternates: {
      canonical: `${siteUrl}/${locale}/btc`,
      languages: {
        en: `${siteUrl}/en/btc`,
        'x-default': `${siteUrl}/en/btc`,
      },
    },
  }
}

export default async function BtcPage() {
  const [posts, fundingSnapshot] = await Promise.all([
    getPosts(500, 1).catch(() => null),
    getFundingSnapshot().catch(() => null),
  ])

  return (
    <BtcPageClient
      initialPosts={posts}
      initialFundingSnapshot={fundingSnapshot}
    />
  )
}
