import "@/app/globals.css"
import "@scandic-hotels/design-system/style.css"

import Script from "next/script"

import AdobeScript from "@/components/Current/AdobeScript"
import Footer from "@/components/Current/Footer"
import Header from "@/components/Current/Header"
import LangPopup from "@/components/Current/LangPopup"
import SkipToMainContent from "@/components/SkipToMainContent"
import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider"

import type { Metadata } from "next"

import type { LangParams, LayoutArgs } from "@/types/params"

export const fetchCache = "default-no-store"

export const metadata: Metadata = {
  title: "Scandic Hotels",
}

export default async function RootLayout({
  children,
  params,
  languageSwitcher,
  myPagesMobileDropdown,
}: React.PropsWithChildren<
  LayoutArgs<LangParams> & { languageSwitcher: React.ReactNode } & {
    myPagesMobileDropdown: React.ReactNode
  }
>) {
  const { defaultLocale, locale, messages } = await getIntl()
  return (
    <html lang={params.lang}>
      <head>
        {/* eslint-disable-next-line @next/next/no-css-tags */}
        <link rel="stylesheet" href="/_static/css/core.css" />
        {/* eslint-disable-next-line @next/next/no-css-tags */}
        <link rel="stylesheet" href="/_static/css/scandic.css" />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/cookie-bot.js?1705409331007"
        />
        <Script
          strategy="beforeInteractive"
          data-blockingmode="auto"
          data-cbid="6d539de8-3e67-4f0f-a0df-8cef9070f712"
          data-culture={params.lang}
          id="Cookiebot"
          src="https://consent.cookiebot.com/uc.js"
        />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/inline.js?00133e5a37de35c51a5d"
        />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/main.js?89d0030e1a04b3b46d0b"
        />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/ng/polyfills.js?1705409330990"
        />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/ng/runtime.js?1705409330990"
        />
        <Script
          data-cookieconsent="ignore"
          src="/_static/dist/js/ng/main.js?1705409330990"
        />
        <Script id="ensure-datalayer">{`
          window.datalayer = window.datalayer || {}
        `}</Script>
        <AdobeScript />
        <link rel="preconnect" href="https://dev.visualwebsiteoptimizer.com" />
        <Script
          id="vwoCode"
          src="/_static/dist/js/vwo.js?1714979036301"
          strategy="beforeInteractive"
        />
      </head>
      <body className="theme-00Corecolours theme-X0Oldcorecolours">
        <LangPopup lang={params.lang} />
        <SkipToMainContent />
        <ServerIntlProvider intl={{ defaultLocale, locale, messages }}>
          <Header
            lang={params.lang}
            myPagesMobileDropdown={myPagesMobileDropdown}
            languageSwitcher={languageSwitcher}
          />
          {children}
          <Footer lang={params.lang} />
        </ServerIntlProvider>
        <Script id="page-tracking">{`
          typeof _satellite !== "undefined" && _satellite.pageBottom();
        `}</Script>
      </body>
    </html>
  )
}
