"use client"

import { useEffect, useState } from "react"

/**
 * Returns true once Zustand stores have rehydrated from localStorage.
 * Use to guard rendering that depends on persisted state so SSR doesn't
 * flash stale defaults before the real persisted data arrives.
 */
export function useStoreHydrated(): boolean {
  const [hydrated, setHydrated] = useState(false)
  useEffect(() => {
    setHydrated(true)
  }, [])
  return hydrated
}
