'use client'

import { useContext } from 'react'
import { ComplianceContext, type ComplianceContextValue } from './provider'
import type { SDKState, SDKAction } from '@breakpilot/compliance-sdk-types'

// =============================================================================
// MAIN HOOK
// =============================================================================

export function useCompliance(): ComplianceContextValue {
  const context = useContext(ComplianceContext)
  if (!context) {
    throw new Error('useCompliance must be used within ComplianceProvider')
  }
  return context
}

// =============================================================================
// STATE HOOK
// =============================================================================

export function useComplianceState(): SDKState {
  const { state } = useCompliance()
  return state
}

export function useComplianceDispatch(): React.Dispatch<SDKAction> {
  const { dispatch } = useCompliance()
  return dispatch
}
