import type { Metadata } from "next";
import "./global.css";
import { LoginModalProvider } from "@/app/LoginModalContext";
import { LoginModal } from "@/app/LoginModal";
import { loadCurrentDid } from "@/data/queries";
import { AuthProvider } from "@/app/AuthContext";
export const metadata: Metadata = {
  metadataBase: new URL("https://sidetrail.app"),
  title: "sidetrail",
  description: "trails worth walking",
};

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <Auth>
          <LoginModalProvider>
            {children}
            <LoginModal />
          </LoginModalProvider>
        </Auth>
      </body>
    </html>
  );
}

async function Auth({ children }: { children: React.ReactNode }) {
  const didPromise = loadCurrentDid();
  return <AuthProvider didPromise={didPromise}>{children}</AuthProvider>;
}
