import "&/fontiran.css";
import AppLayout from "@/layouts/AppLayout";
import MuiLayout from "@/layouts/MuiLayout";
import {LanguageProvider} from "@/lib/app/contexts/language";
import {LoadingProvider} from "@/lib/app/contexts/loading";
import {UserProvider} from "@/lib/app/contexts/user";
import "moment/locale/fa";
import {NextIntlProvider} from "next-intl";
import TitlePage from "@/core/components/TitlePage";
import {SocketProvider} from "@/lib/app/contexts/socket";
import {ToastProvider} from "@/lib/app/contexts/toast";
import Layout from "@/layouts";

const App = ({Component, pageProps}) => {

    return (<>
        <UserProvider>
            <LanguageProvider>
                <NextIntlProvider locale={pageProps.locale} messages={pageProps.messages || {}}>
                    <MuiLayout isBot={pageProps.isBot}>
                        {pageProps.messages ? <TitlePage text={pageProps.title}/> : ''}
                        <LoadingProvider>
                            <ToastProvider>
                                <AppLayout isBot={pageProps.isBot}>
                                    <SocketProvider>
                                        <Layout layout={pageProps.layout}>
                                            <Component {...pageProps} />
                                        </Layout>
                                    </SocketProvider>
                                </AppLayout>
                            </ToastProvider>
                        </LoadingProvider>
                    </MuiLayout>
                </NextIntlProvider>
            </LanguageProvider>
        </UserProvider>
    </>)
};

export default App;
