import { DM_Sans, Barlow_Condensed, Playfair_Display } from "next/font/google";
// import "@fancyapps/ui/dist/fancybox/fancybox.css";
import "./globals.css";
import { getSiteInfo } from "./lib/api";
import HeadTags from "./lib/HeadTags";
import { Toaster } from "react-hot-toast";


const barlowCondensed = Barlow_Condensed({
  subsets: ["latin"],
  variable: "--font-barlow-condensed",
  weight: ["500", "600", "700"],
});

const Playfair  = Playfair_Display ({
  subsets: ["Playfair"],
  variable: "--Playfair_Display",
  weight: ["500", "600", "700"],
});

const dmSans = DM_Sans({
  subsets: ["latin"],
  variable: "--font-dm-sans",
  weight: ["300","400","500","600","700"],
});

export async function generateMetadata() {
  const siteInfo = await getSiteInfo();

  return {
    title: siteInfo?.name || "",
    icons: {
      icon: siteInfo?.favicon,
    },
    authors: [{ name: siteInfo?.name || "" }],
  };
}

// async function checkExpiry() {
//   try {
//     const res = await fetch(
//       `https://api-lead.instavyapar.co.in/api/user/check-expiry/6968b75188faeaffdca116ee`,
//       {
//         method: "GET",
//         cache: "no-store",
//       }
//     );
//     const data = await res.json();
//     return data;
//     // console.log("Expiry check:", data);
//   } catch (error) {
//     console.error("Error checking expiry:", error);
//   }
// }

export default async function RootLayout({ children }) {
  // const siteKey = process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY;
  // const expiry = await checkExpiry();
  return (
    <html lang="en">
      <head>
        <HeadTags />
        {/* <HeadTags siteKey={siteKey} /> */}
      </head>
      <body className={`${dmSans.variable} ${barlowCondensed.variable},${Playfair.variable}, antialiased`} >
        {/* {
          expiry?.data?.isExpired ? (
            <div className="min-h-screen flex items-center justify-center bg-white px-4">
              <div className="border border-red-200 rounded-xl p-10 text-center max-w-md">
                <h1 className="text-xl font-semibold text-red-600 mb-3">
                  Subscription Expired
                </h1>
                <p className="text-gray-600">
                  Your subscription has expired. Please contact support to continue.
                </p>
              </div>
            </div>
          ) : <>
            <Toaster />
            {children}
          </>
        } */}
         <>
            <Toaster />
            {children}
          </>
      </body>
    </html>
  );
}