import type { Metadata } from "next";

const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://www.adultworld.ai";

type Props = {
  children: React.ReactNode;
  params: Promise<{ streamId: string }>;
};

export async function generateMetadata({ params }: { params: Promise<{ streamId: string }> }): Promise<Metadata> {
  const { streamId } = await params;
  const url = `${baseUrl}/streams/play/${streamId}`;
  return {
    title: "Live Stream | AdultWorld",
    description: "Watch a live stream on AdultWorld.",
    alternates: { canonical: url },
    openGraph: {
      title: "Live Stream | AdultWorld",
      description: "Watch a live stream on AdultWorld.",
      url,
      type: "video.other",
    },
    twitter: { card: "player", title: "Live Stream | AdultWorld" },
  };
}

export default async function StreamPlayLayout({ children, params }: Props) {
  const { streamId } = await params;
  const videoLd = {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    name: "AdultWorld Live Stream",
    description: "Live broadcaster stream on AdultWorld.",
    uploadDate: new Date().toISOString(),
    contentUrl: `${baseUrl}/streams/play/${streamId}`,
    isLiveBroadcast: true,
  };
  return (
    <>
      <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(videoLd) }} />
      {children}
    </>
  );
}
