"use client"
import { HeroUIProvider, cn } from "@heroui/react"
import { ToastProvider } from "@heroui/toast"
import { platform } from "@tauri-apps/plugin-os"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import { useEffect, useState } from "react"
import { AuthProvider } from "@/components/auth/AuthProvider"

export default function Providers({ children }: { children: React.ReactNode }) {
  const [os, setOs] = useState("windows")
  useEffect(() => {
    setOs(platform())
  }, [])

  return (
    <HeroUIProvider
      className={cn("h-full bg-zinc-100/95 dark:bg-zinc-900/95", os === "macos" && "rounded-lg")}
    >
      <NextThemesProvider attribute="class" defaultTheme="light">
        <ToastProvider toastOffset={10} placement="top-center" toastProps={{ timeout: 3000 }} />
        <AuthProvider>{children}</AuthProvider>
      </NextThemesProvider>
    </HeroUIProvider>
  )
}
