import { createContext, useContext } from "react"
import type { DrawerDirection } from "./drawer.type"

interface DrawerContextValue {
  direction: DrawerDirection
  isOpen: boolean
  onOpenChange: (open: boolean) => void
}

export const DrawerContext = createContext<DrawerContextValue | null>(null)

export function useDrawerContext() {
  const context = useContext(DrawerContext)
  if (!context) {
    throw new Error("useDrawerContext must be used within a Drawer")
  }
  return context
}
