import type { Metadata } from "next";
import localFont from "next/font/local";
import { defaultSEOConfig } from "@/config/seoConfig";
import { pageSeo, siteKeywords } from "@/config/pageSeo";
import SiteJsonLd from "@/components/seo/SiteJsonLd";

import "./globals.css";
import Layout from "@/components/Layout";
import RegisterSW from "@/components/RegisterSW";

const iranSansFont = localFont({
  src: "./../../public/fonts/IRANSansX-Regular.woff",
});

const defaultTitle = pageSeo.home.title;

export const metadata: Metadata = {
  title: {
    default: defaultTitle,
  },
  description: pageSeo.home.description,
  metadataBase: new URL("https://modstagram.com"),
  keywords: siteKeywords,
  authors: [{ name: "Modstagram", url: "https://modstagram.com" }],
  creator: "Modstagram",
  alternates: {
    canonical: "/",
  },
  manifest: "/manifest.json",
  icons: {
    icon: [{ url: "/favicon.ico", type: "image/x-icon" }],
    shortcut: ["/favicon.ico"],
    apple: [
      { url: "/images/icons/apple-touch-icon.png" },
      { url: "/images/icons/192x192.png" },
    ],
  },
  appleWebApp: {
    capable: true,
    statusBarStyle: "black",
  },
  openGraph: {
    title: defaultSEOConfig.openGraph?.title || defaultTitle,
    description: defaultSEOConfig.openGraph?.description || "",
    url: defaultSEOConfig.openGraph?.url || "",
    siteName: defaultSEOConfig.openGraph?.site_name || "",
    locale: "fa_IR",
    type: "website",
  },
  robots: "index, follow",
  twitter: {
    card: "summary_large_image",
    title: defaultTitle,
    description: defaultSEOConfig.description || "",
    creator: "@modstagram",
    images: defaultSEOConfig.openGraph?.images?.map((img) => img.url) || [],
  },
  verification: {
    google: "yVjB5yKPchPUtxl33GWVyMvjH6wCEInqEvaH7ZsXXMo",
  },
  other: {
    "theme-color": "#ffffff",
    "msapplication-TileColor": "#0072BC",
    samandehi: "522190795",
  },
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="fa" dir="rtl" suppressHydrationWarning>
      <body className={`${iranSansFont.className} antialiased`}>
        <SiteJsonLd />
        <RegisterSW />
        <Layout>{children}</Layout>
      </body>
    </html>
  );
}
