"""
mizan.client - Server function implementation.

This subpackage contains everything needed to make server functions work:
- The @client decorator (lives in mizan_core.client.function)
- ServerFunction base class (mizan_core.client.function)
- Function execution logic (.executor — Django-specific dispatch)
- JWT authentication (.jwt — Django-specific session integration)

Usage:
    from mizan.client import client, ServerFunction, compose
"""

# Register the Django framework response base so view-path detection works
# in mizan_core.client.function. Has to happen before any @client-decorated
# code is evaluated.
from django.http import HttpResponseBase as _HttpResponseBase
from mizan_core.client.function import set_framework_response_base as _set_response_base
_set_response_base(_HttpResponseBase)


from mizan_core.client.function import (
    # Decorator
    client,
    # Context markers
    ReactContext,
    GlobalContext,
    # Base classes
    ServerFunction,
    ComposedContext,
    # Composition
    compose,
    # Type aliases
    ContextMode,
    # Form helpers
    FormValidationOutput,
    FormSchemaField,
    FormSchemaOutput,
    create_form_functions,
)

from .executor import (
    execute_function,
    function_call_view,
    ErrorCode,
    FunctionError,
    FunctionResult,
)

__all__ = [
    # Decorator
    "client",
    # Context markers
    "ReactContext",
    "GlobalContext",
    # Base classes
    "ServerFunction",
    "ComposedContext",
    # Composition
    "compose",
    # Type aliases
    "ContextMode",
    # Execution
    "execute_function",
    "function_call_view",
    "ErrorCode",
    "FunctionError",
    "FunctionResult",
    # Form helpers
    "FormValidationOutput",
    "FormSchemaField",
    "FormSchemaOutput",
    "create_form_functions",
]
