'use client';

import type { ReactNode } from 'react';
import { usePathname } from 'next/navigation';
import { Toaster } from '@/components/ui/sonner';
import { Navbar } from '@/components/navbar';
import { SiteConfigSync } from '@/components/site-config-sync';
import { VisitTracker } from '@/components/visit-tracker';
import { AccountThemeSync } from '@/components/account-theme-sync';

export function AppShell({ children }: { children: ReactNode }) {
  const pathname = usePathname();
  const isConsole = pathname === '/console' || pathname.startsWith('/console/');

  return (
    <>
      <SiteConfigSync />
      <AccountThemeSync />
      {!isConsole && <VisitTracker />}
      {!isConsole && <Navbar />}
      <main>{children}</main>
      <Toaster />
    </>
  );
}
