import type { Metadata } from "next";
import localFont from "next/font/local";
import { routing } from "@/i18n/routing";
import { notFound } from "next/navigation";
import { getMessages, setRequestLocale } from "next-intl/server";
import { NextIntlClientProvider } from "next-intl";
import BaseLayout from "@/components/root-layout/BaseLayout";
import ReduxProvider from "@/store/redux-provider";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import ReactQueryProvider from "../../utils/react-query";
import { CookiesProvider } from "next-client-cookies/server";
import ClarityProvider from "@/components/providers/ClarityProvider";
import GTMProvider from "@/components/providers/GTMProvider";
import SentryProvider from "@/components/SentryProvider";
import FCMProvider from "@/components/providers/FCMProvider";

// const geistSans = localFont({
//   src: "./fonts/GeistVF.woff",
//   variable: "--font-geist-sans",
//   weight: "100 900",
// });
// const geistMono = localFont({
//   src: "./fonts/GeistMonoVF.woff",
//   variable: "--font-geist-mono",
//   weight: "100 900",
// });

const queryClient = new QueryClient();

const BASE_URL = 'https://dev.outletplus.sa';

export const metadata: Metadata = {
  metadataBase: new URL(BASE_URL),
  title: {
    default: 'Outlet Plus',
    template: '%s | Outlet Plus',
  },
  description:
    'Outlet Plus - Your trusted online pharmacy in Saudi Arabia. Shop medicines, health products, skincare, and wellness items with fast delivery. Best prices and authentic products.',
  keywords: [
    'online pharmacy',
    'pharmacy Saudi Arabia',
    'buy medicines online',
    'health products',
    'skincare',
    'wellness',
    'Outlet Plus',
    'صيدلية اوتلت بلس',
    'صيدلية اون لاين',
    'صيدلية السعودية',
  ],
  authors: [{ name: 'Outlet Plus' }],
  creator: 'Outlet Plus',
  publisher: 'Outlet Plus',
  icons: {
    icon: '/icon.svg',
    apple: '/icon.svg',
  },
  openGraph: {
    type: 'website',
    locale: 'en_US',
    alternateLocale: 'ar_SA',
    url: BASE_URL,
    siteName: 'Outlet Plus',
    title: 'Outlet Plus',
    description:
      'Your trusted online pharmacy in Saudi Arabia. Shop medicines, health products, skincare, and wellness items with fast delivery.',
    images: [
      {
        url: '/og-image.png',
        width: 1200,
        height: 630,
        alt: 'Outlet Plus - Online Pharmacy',
      },
    ],
  },
  twitter: {
    card: 'summary_large_image',
    title: 'Outlet Plus | Online Pharmacy in Saudi Arabia',
    description:
      'Your trusted online pharmacy in Saudi Arabia. Shop medicines, health products, and wellness items.',
    images: ['/og-image.png'],
  },
  robots: {
    index: true,
    follow: true,
    googleBot: {
      index: true,
      follow: true,
      'max-video-preview': -1,
      'max-image-preview': 'large',
      'max-snippet': -1,
    },
  },
  alternates: {
    canonical: BASE_URL,
    languages: {
      'en': `${BASE_URL}/en`,
      'ar': `${BASE_URL}/ar`,
    },
  },
  verification: {
    // Add your verification codes here when you have them
    // google: 'your-google-verification-code',
    // yandex: 'your-yandex-verification-code',
  },
};
export function generateStaticParams() {
  return routing.locales.map((locale) => ({ locale }));
}
export default async function LocaleLayout({
  children,
  params,
}: {
  children: React.ReactNode;
  params: Promise<{ locale: "ar" | "en" }>;
}) {
  const { locale } = await params; // Ensure you resolve `params` if it's a promise.

  if (!routing.locales.includes(locale)) {
    notFound();
  }

  setRequestLocale(locale);
  return (
    <SentryProvider>
      <ReduxProvider>
        <ReactQueryProvider>
          <ClarityProvider />
          <GTMProvider />
          <FCMProvider />
          <BaseLayout locale={locale}>
            <>{children}</>
          </BaseLayout>
        </ReactQueryProvider>
      </ReduxProvider>
    </SentryProvider>
  );
}

// import type { Metadata } from "next";
// import localFont from "next/font/local";
// import { routing } from "@/i18n/routing";
// import {notFound} from 'next/navigation';
// import {getMessages, setRequestLocale} from 'next-intl/server';
// import { NextIntlClientProvider } from "next-intl";
// import BaseLayout from "@/components/root-layout/BaseLayout";
// import ReduxProvider from "@/store/redux-provider";
// import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
// import ReactQueryProvider from '../../utils/react-query'

// // const geistSans = localFont({
// //   src: "./fonts/GeistVF.woff",
// //   variable: "--font-geist-sans",
// //   weight: "100 900",
// // });
// // const geistMono = localFont({
// //   src: "./fonts/GeistMonoVF.woff",
// //   variable: "--font-geist-mono",
// //   weight: "100 900",
// // });

// const queryClient = new QueryClient();
// export const metadata: Metadata = {
//   title: "Outlet",
//   description: "Generated by create next app",
//   icons: {
//     icon: "/icon.svg",
//   },
// };
// export function generateStaticParams() {
//   return routing.locales.map((locale) => ({locale}));
// }
//  export default async function LocaleLayout({
//   //export default function LocaleLayout({
//   children,
//   params
// }: {
//   children: React.ReactNode;
//   // params: Promise<{ locale: "ar" | "en" }>;
//    params: Promise<{ locale: "en" | "ar" }>;
//   //params: { locale: "en" | "ar" };
// }) {
//   //const { locale } =  params;
//   const { locale } = await params; // Ensure you resolve `params` if it's a promise.

//   if (!routing.locales.includes(locale)) {
//     notFound();
//   }

//   setRequestLocale(locale);
//   return (

// <ReduxProvider>

// <ReactQueryProvider>

//    <BaseLayout locale={locale}>

//    {children}
//    </BaseLayout>
// </ReactQueryProvider>

// </ReduxProvider>

//   );
// }
