import type { Metadata } from 'next';
import PublicProfile from './PublicProfile';

/**
 * /u/[handle] (A1 Session 10) — a user's PUBLIC ledger profile. Thin server
 * wrapper for metadata (+ the segment's opengraph-image.tsx share card);
 * the record itself renders in the PublicProfile client component.
 *
 * PUBLIC route — never gated. Publishing is the owner's explicit choice;
 * once published, the whole settled record is the page. Misses included.
 */
export async function generateMetadata({ params }: { params: Promise<{ handle: string }> }): Promise<Metadata> {
  const { handle } = await params;
  const h = decodeURIComponent(handle || '').slice(0, 20).toLowerCase();
  const title = `CLV-verified record — @${h} · VYNDR`;
  const description = `@${h}'s settled betting record on VYNDR — every read, every result, closing-line value included. Nothing curated, nothing deleted.`;
  return {
    title,
    description,
    openGraph: { title, description },
    twitter: { card: 'summary_large_image', title, description },
  };
}

export default async function PublicProfilePage({ params }: { params: Promise<{ handle: string }> }) {
  const { handle } = await params;
  return <PublicProfile handle={decodeURIComponent(handle || '')} />;
}
