/**
 * mizan — Server Functions Client
 *
 * Frontend client for Mizan server functions.
 * Server functions are the core primitive — accessed via React hooks.
 *
 * Two-layer architecture:
 *
 * 1. Library layer (this package) — Generic name-based API
 *    import { useMizan, useMizanContext, useMizanCall } from 'mizan'
 *
 * 2. Generated layer (@/api) — Typed project-specific API
 *    import { useCurrentUser, useUpdateProfile } from '@/api'
 */

// ============================================================================
// React Context & Hooks (primary API)
// ============================================================================

export {
    // Provider
    MizanProvider,
    type MizanProviderProps,
    type MizanHydration,

    // Hooks
    useMizan,
    useMizanContext,
    useMizanCall,
    useMizanStatus,
    usePush,

    // Types
    type MizanContextValue,
    type ConnectionStatus,
    type PushMessage,
    type PushListener,
    type ContextStore,
    type Transport,
} from './context'

// ============================================================================
// HTTP Client
// ============================================================================

export {
    createMizanCSRClient,
    createMizanSSRClient,
    ensureMizanSession,
    Auth,
    type MizanHTTPClient,
    type CSRClientConfig,
    type JWTClientConfig,
    type SSRClientConfig,
} from './client/'

// ============================================================================
// Errors
// ============================================================================

export {
    MizanError,
    type FunctionErrorResponse,
    type ErrorCode,
} from './errors'

// ============================================================================
// Forms
// ============================================================================

export {
    useMizanFormCore,
    type MizanFormState,
    type FormSchema,
    type FormErrors,
    type FormOptions,
    type FormSubmitResult,
    type FormCoreConfig,
    useMizanFormsetCore,
    type MizanFormsetState,
    type FormsetSchema,
    type FormsetErrors,
    type FormsetCoreConfig,
    type FormsetSubmitResult,
    type FieldSchema,
    type FieldChoice,
    type FieldError,
    type FormMeta,
} from './forms'

// ============================================================================
// Configuration
// ============================================================================

export { configureCsrf } from './utils'

// ============================================================================
// Legacy aliases (deprecated)
// ============================================================================

export {
    // Provider aliases
    DjangoContext,
    useDjango,
    useDjangoStatus,
    useServerFunction,
    type DjangoContextValue,
    type DjangoContextProps,
} from './context'

export {
    // Client aliases
    createMizanCSRClient as createDjangoCSRClient,
    createMizanSSRClient as createDjangoSSRClient,
    ensureMizanSession as ensureDjangoSession,
    type MizanHTTPClient as DjangoHTTPClient,
} from './client/'

export { MizanError as DjangoError } from './errors'

export {
    useMizanFormCore as useDjangoFormCore,
    type MizanFormState as DjangoFormState,
    useMizanFormsetCore as useDjangoFormsetCore,
    type MizanFormsetState as DjangoFormsetState,
} from './forms'
