import { connection } from "next/server";
import type { Metadata } from "next";
import localFont from "next/font/local";
import { NuqsAdapter } from "nuqs/adapters/next/app";
import { RegisterServiceWorker } from "@/components/shell/RegisterServiceWorker";
import { authMode, clerkPublishableKey } from "@/lib/auth/mode";
/** Wraps the tree in Clerk's provider only when the deployment uses
* Clerk; the air-gapped/local build never loads the SDK. The AUTH_MODE
* switch is a runtime env var (same image, per-deployment toggle), so we
* call connection() to opt this out of build-time prerendering — otherwise
* next build bakes in the build host's mode and the toggle never flips
* (see docs/clerk.md). */
async function IdentityProvider({ children }: { children: React.ReactNode }) {
await connection();
if (authMode() !== "clerk") {
return <>{children}>;
}
const { ClerkProvider } = await import("@clerk/nextjs");
return (