import { Metadata } from 'next'
import Script from 'next/script'
import { SEO_CONFIG, SITE_URL, DEFAULT_OG_IMAGE, generateWebPageSchema, generateBreadcrumbSchema } from '@/lib/seo'

export const metadata: Metadata = {
  title: SEO_CONFIG.discover.title,
  description: SEO_CONFIG.discover.description,
  keywords: SEO_CONFIG.discover.keywords,
  alternates: {
    canonical: `${SITE_URL}/discover`,
  },
  openGraph: {
    title: SEO_CONFIG.discover.title,
    description: SEO_CONFIG.discover.description,
    url: `${SITE_URL}/discover`,
    siteName: 'Pounce',
    images: [
      {
        url: `${SITE_URL}/og-discover.png`,
        width: 1200,
        height: 630,
        alt: 'TLD Pricing & Trends - Pounce',
      },
    ],
    locale: 'en_US',
    type: 'website',
  },
  twitter: {
    card: 'summary_large_image',
    title: SEO_CONFIG.discover.title,
    description: SEO_CONFIG.discover.description,
    images: [`${SITE_URL}/og-discover.png`],
  },
}

export default function DiscoverLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const webPageSchema = generateWebPageSchema({
    title: SEO_CONFIG.discover.title,
    description: SEO_CONFIG.discover.description,
    url: `${SITE_URL}/discover`,
  })
  
  const breadcrumbSchema = generateBreadcrumbSchema([
    { name: 'Home', url: SITE_URL },
    { name: 'TLD Intelligence', url: `${SITE_URL}/discover` },
  ])

  return (
    <>
      <Script
        id="discover-webpage-schema"
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(webPageSchema) }}
      />
      <Script
        id="discover-breadcrumb-schema"
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbSchema) }}
      />
      {children}
    </>
  )
}

