"use client";

import "@/lib/i18n";
import { LanguageProvider } from "@/contexts/LanguageProvider";
import { ThemeProvider } from "@/contexts/ThemeContext";
import { ReactQueryProvider } from "@/providers/ReactQueryProvider";
import { Toaster } from "react-hot-toast";
import BackgroundPrefetch from "@/components/BackgroundPrefetch";
import ScrollRestorationInit from "@/components/ScrollRestorationInit";
import TitleGuardian from "@/components/TitleGuardian";
import AuthSessionSync from "@/components/auth/AuthSessionSync";
import PwaInstallPrompt from "@/components/pwa/PwaInstallPrompt";
import PwaBootSplash from "@/components/pwa/PwaBootSplash";
import PwaHead from "@/components/PwaHead";
import NotificationBridge from "@/components/notifications/NotificationBridge";

interface ILayoutProps {
  children: React.ReactNode;
}
function Layout({ children }: ILayoutProps) {
  return (
    <ThemeProvider>
      <LanguageProvider>
        <ReactQueryProvider>
        <PwaHead />
        <PwaBootSplash />
        <ScrollRestorationInit />
        <TitleGuardian />
        <Toaster />
        <AuthSessionSync />
        <PwaInstallPrompt />
        <BackgroundPrefetch />
        <NotificationBridge />
        {children}
        </ReactQueryProvider>
      </LanguageProvider>
    </ThemeProvider>
  );
}

export default Layout;
