interface OnboardingLayoutProps {
  children: React.ReactNode;
}

/**
 * Onboarding Layout
 *
 * Provides basic layout structure for onboarding pages.
 * Authentication is handled at the layout boundary.
 */
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
import { createRouteGuard } from '@/lib/auth/createRouteGuard';

export default async function OnboardingLayout({ children }: OnboardingLayoutProps) {
  const headerStore = await headers();
  const pathname = headerStore.get('x-pathname') || '/';

  const guard = createRouteGuard();
  const result = await guard.enforce({ pathname });
  if (result.type === 'redirect') {
    redirect(result.to);
  }

  return <>{children}</>;
}
