"""Protocol-level constants and default configuration values."""

from __future__ import annotations

from enum import IntEnum

from . import _wtransport

__all__: list[str] = [
    "ALPN_H3",
    "BIDIRECTIONAL_STREAM",
    "CLOSE_WEBTRANSPORT_SESSION_TYPE",
    "DEFAULT_ALPN_PROTOCOLS",
    "DEFAULT_BIND_HOST",
    "DEFAULT_CLIENT_MAX_CONNECTIONS",
    "DEFAULT_CLIENT_MAX_SESSIONS",
    "DEFAULT_CLOSE_TIMEOUT",
    "DEFAULT_CONGESTION_CONTROL_ALGORITHM",
    "DEFAULT_CONNECT_TIMEOUT",
    "DEFAULT_CONNECTION_IDLE_TIMEOUT",
    "DEFAULT_DEV_PORT",
    "DEFAULT_FLOW_CONTROL_WINDOW_AUTO_SCALE",
    "DEFAULT_FLOW_CONTROL_WINDOW_SIZE",
    "DEFAULT_INITIAL_MAX_DATA",
    "DEFAULT_INITIAL_MAX_STREAMS_BIDI",
    "DEFAULT_INITIAL_MAX_STREAMS_UNI",
    "DEFAULT_KEEP_ALIVE",
    "DEFAULT_LOG_LEVEL",
    "DEFAULT_MAX_CAPSULE_SIZE",
    "DEFAULT_MAX_CONNECTION_RETRIES",
    "DEFAULT_MAX_DATAGRAM_SIZE",
    "DEFAULT_MAX_EVENT_HISTORY_SIZE",
    "DEFAULT_MAX_EVENT_LISTENERS",
    "DEFAULT_MAX_EVENT_QUEUE_SIZE",
    "DEFAULT_MAX_MESSAGE_SIZE",
    "DEFAULT_MAX_PENDING_EVENTS_PER_SESSION",
    "DEFAULT_MAX_RETRY_DELAY",
    "DEFAULT_MAX_STREAM_READ_BUFFER",
    "DEFAULT_MAX_STREAM_WRITE_BUFFER",
    "DEFAULT_MAX_TOTAL_PENDING_EVENTS",
    "DEFAULT_PENDING_EVENT_TTL",
    "DEFAULT_READ_TIMEOUT",
    "DEFAULT_RESOURCE_CLEANUP_INTERVAL",
    "DEFAULT_RETRY_BACKOFF",
    "DEFAULT_RETRY_DELAY",
    "DEFAULT_SERVER_MAX_CONNECTIONS",
    "DEFAULT_SERVER_MAX_SESSIONS",
    "DEFAULT_STREAM_CREATION_TIMEOUT",
    "DEFAULT_WRITE_TIMEOUT",
    "DRAIN_WEBTRANSPORT_SESSION_TYPE",
    "ErrorCodes",
    "H3_FRAME_TYPE_CANCEL_PUSH",
    "H3_FRAME_TYPE_DATA",
    "H3_FRAME_TYPE_GOAWAY",
    "H3_FRAME_TYPE_HEADERS",
    "H3_FRAME_TYPE_MAX_PUSH_ID",
    "H3_FRAME_TYPE_PUSH_PROMISE",
    "H3_FRAME_TYPE_SETTINGS",
    "H3_FRAME_TYPE_WEBTRANSPORT_STREAM",
    "H3_STREAM_TYPE_CONTROL",
    "H3_STREAM_TYPE_PUSH",
    "H3_STREAM_TYPE_QPACK_DECODER",
    "H3_STREAM_TYPE_QPACK_ENCODER",
    "H3_STREAM_TYPE_WEBTRANSPORT",
    "MAX_CLOSE_REASON_BYTES",
    "MAX_DATAGRAM_SIZE",
    "MAX_PROTOCOL_STREAMS_LIMIT",
    "MAX_STREAM_ID",
    "QPACK_DECODER_MAX_BLOCKED_STREAMS",
    "QPACK_DECODER_MAX_TABLE_CAPACITY",
    "SETTINGS_ENABLE_CONNECT_PROTOCOL",
    "SETTINGS_H3_DATAGRAM",
    "SETTINGS_QPACK_BLOCKED_STREAMS",
    "SETTINGS_QPACK_MAX_TABLE_CAPACITY",
    "SETTINGS_WT_INITIAL_MAX_DATA",
    "SETTINGS_WT_INITIAL_MAX_STREAMS_BIDI",
    "SETTINGS_WT_INITIAL_MAX_STREAMS_UNI",
    "SUPPORTED_CONGESTION_CONTROL_ALGORITHMS",
    "UNIDIRECTIONAL_STREAM",
    "USER_AGENT_HEADER",
    "WEBTRANSPORT_DEFAULT_PORT",
    "WEBTRANSPORT_SCHEME",
    "WT_DATA_BLOCKED_TYPE",
    "WT_MAX_DATA_TYPE",
    "WT_MAX_STREAM_DATA_TYPE",
    "WT_MAX_STREAMS_BIDI_TYPE",
    "WT_MAX_STREAMS_UNI_TYPE",
    "WT_STREAM_DATA_BLOCKED_TYPE",
    "WT_STREAMS_BLOCKED_BIDI_TYPE",
    "WT_STREAMS_BLOCKED_UNI_TYPE",
]

ALPN_H3: str = _wtransport.ALPN_H3
USER_AGENT_HEADER: str = _wtransport.USER_AGENT_HEADER
WEBTRANSPORT_DEFAULT_PORT: int = _wtransport.WEBTRANSPORT_DEFAULT_PORT
WEBTRANSPORT_SCHEME: str = _wtransport.WEBTRANSPORT_SCHEME

BIDIRECTIONAL_STREAM: int = _wtransport.BIDIRECTIONAL_STREAM
CLOSE_WEBTRANSPORT_SESSION_TYPE: int = _wtransport.CLOSE_WEBTRANSPORT_SESSION_TYPE
DRAIN_WEBTRANSPORT_SESSION_TYPE: int = _wtransport.DRAIN_WEBTRANSPORT_SESSION_TYPE
H3_FRAME_TYPE_CANCEL_PUSH: int = _wtransport.H3_FRAME_TYPE_CANCEL_PUSH
H3_FRAME_TYPE_DATA: int = _wtransport.H3_FRAME_TYPE_DATA
H3_FRAME_TYPE_GOAWAY: int = _wtransport.H3_FRAME_TYPE_GOAWAY
H3_FRAME_TYPE_HEADERS: int = _wtransport.H3_FRAME_TYPE_HEADERS
H3_FRAME_TYPE_MAX_PUSH_ID: int = _wtransport.H3_FRAME_TYPE_MAX_PUSH_ID
H3_FRAME_TYPE_PUSH_PROMISE: int = _wtransport.H3_FRAME_TYPE_PUSH_PROMISE
H3_FRAME_TYPE_SETTINGS: int = _wtransport.H3_FRAME_TYPE_SETTINGS
H3_FRAME_TYPE_WEBTRANSPORT_STREAM: int = _wtransport.H3_FRAME_TYPE_WEBTRANSPORT_STREAM
H3_STREAM_TYPE_CONTROL: int = _wtransport.H3_STREAM_TYPE_CONTROL
H3_STREAM_TYPE_PUSH: int = _wtransport.H3_STREAM_TYPE_PUSH
H3_STREAM_TYPE_QPACK_DECODER: int = _wtransport.H3_STREAM_TYPE_QPACK_DECODER
H3_STREAM_TYPE_QPACK_ENCODER: int = _wtransport.H3_STREAM_TYPE_QPACK_ENCODER
H3_STREAM_TYPE_WEBTRANSPORT: int = _wtransport.H3_STREAM_TYPE_WEBTRANSPORT
MAX_CLOSE_REASON_BYTES: int = _wtransport.MAX_CLOSE_REASON_BYTES
MAX_DATAGRAM_SIZE: int = _wtransport.MAX_DATAGRAM_SIZE
MAX_PROTOCOL_STREAMS_LIMIT: int = _wtransport.MAX_PROTOCOL_STREAMS_LIMIT
MAX_STREAM_ID: int = _wtransport.MAX_STREAM_ID
QPACK_DECODER_MAX_BLOCKED_STREAMS: int = _wtransport.QPACK_DECODER_MAX_BLOCKED_STREAMS
QPACK_DECODER_MAX_TABLE_CAPACITY: int = _wtransport.QPACK_DECODER_MAX_TABLE_CAPACITY
SETTINGS_ENABLE_CONNECT_PROTOCOL: int = _wtransport.SETTINGS_ENABLE_CONNECT_PROTOCOL
SETTINGS_H3_DATAGRAM: int = _wtransport.SETTINGS_H3_DATAGRAM
SETTINGS_QPACK_BLOCKED_STREAMS: int = _wtransport.SETTINGS_QPACK_BLOCKED_STREAMS
SETTINGS_QPACK_MAX_TABLE_CAPACITY: int = _wtransport.SETTINGS_QPACK_MAX_TABLE_CAPACITY
SETTINGS_WT_INITIAL_MAX_DATA: int = _wtransport.SETTINGS_WT_INITIAL_MAX_DATA
SETTINGS_WT_INITIAL_MAX_STREAMS_BIDI: int = _wtransport.SETTINGS_WT_INITIAL_MAX_STREAMS_BIDI
SETTINGS_WT_INITIAL_MAX_STREAMS_UNI: int = _wtransport.SETTINGS_WT_INITIAL_MAX_STREAMS_UNI
UNIDIRECTIONAL_STREAM: int = _wtransport.UNIDIRECTIONAL_STREAM
WT_DATA_BLOCKED_TYPE: int = _wtransport.WT_DATA_BLOCKED_TYPE
WT_MAX_DATA_TYPE: int = _wtransport.WT_MAX_DATA_TYPE
WT_MAX_STREAM_DATA_TYPE: int = _wtransport.WT_MAX_STREAM_DATA_TYPE
WT_MAX_STREAMS_BIDI_TYPE: int = _wtransport.WT_MAX_STREAMS_BIDI_TYPE
WT_MAX_STREAMS_UNI_TYPE: int = _wtransport.WT_MAX_STREAMS_UNI_TYPE
WT_STREAM_DATA_BLOCKED_TYPE: int = _wtransport.WT_STREAM_DATA_BLOCKED_TYPE
WT_STREAMS_BLOCKED_BIDI_TYPE: int = _wtransport.WT_STREAMS_BLOCKED_BIDI_TYPE
WT_STREAMS_BLOCKED_UNI_TYPE: int = _wtransport.WT_STREAMS_BLOCKED_UNI_TYPE

DEFAULT_ALPN_PROTOCOLS: list[str] = _wtransport.DEFAULT_ALPN_PROTOCOLS
DEFAULT_BIND_HOST: str = _wtransport.DEFAULT_BIND_HOST
DEFAULT_CLIENT_MAX_CONNECTIONS: int = _wtransport.DEFAULT_CLIENT_MAX_CONNECTIONS
DEFAULT_CLIENT_MAX_SESSIONS: int = _wtransport.DEFAULT_CLIENT_MAX_SESSIONS
DEFAULT_CLOSE_TIMEOUT: float = _wtransport.DEFAULT_CLOSE_TIMEOUT
DEFAULT_CONGESTION_CONTROL_ALGORITHM: str = _wtransport.DEFAULT_CONGESTION_CONTROL_ALGORITHM
DEFAULT_CONNECT_TIMEOUT: float = _wtransport.DEFAULT_CONNECT_TIMEOUT
DEFAULT_CONNECTION_IDLE_TIMEOUT: float = _wtransport.DEFAULT_CONNECTION_IDLE_TIMEOUT
DEFAULT_DEV_PORT: int = _wtransport.DEFAULT_DEV_PORT
DEFAULT_FLOW_CONTROL_WINDOW_AUTO_SCALE: bool = _wtransport.DEFAULT_FLOW_CONTROL_WINDOW_AUTO_SCALE
DEFAULT_FLOW_CONTROL_WINDOW_SIZE: int = _wtransport.DEFAULT_FLOW_CONTROL_WINDOW_SIZE
DEFAULT_INITIAL_MAX_DATA: int = _wtransport.DEFAULT_INITIAL_MAX_DATA
DEFAULT_INITIAL_MAX_STREAMS_BIDI: int = _wtransport.DEFAULT_INITIAL_MAX_STREAMS_BIDI
DEFAULT_INITIAL_MAX_STREAMS_UNI: int = _wtransport.DEFAULT_INITIAL_MAX_STREAMS_UNI
DEFAULT_KEEP_ALIVE: bool = _wtransport.DEFAULT_KEEP_ALIVE
DEFAULT_LOG_LEVEL: str = _wtransport.DEFAULT_LOG_LEVEL
DEFAULT_MAX_CAPSULE_SIZE: int = _wtransport.DEFAULT_MAX_CAPSULE_SIZE
DEFAULT_MAX_CONNECTION_RETRIES: int = _wtransport.DEFAULT_MAX_CONNECTION_RETRIES
DEFAULT_MAX_DATAGRAM_SIZE: int = _wtransport.DEFAULT_MAX_DATAGRAM_SIZE
DEFAULT_MAX_EVENT_HISTORY_SIZE: int = _wtransport.DEFAULT_MAX_EVENT_HISTORY_SIZE
DEFAULT_MAX_EVENT_LISTENERS: int = _wtransport.DEFAULT_MAX_EVENT_LISTENERS
DEFAULT_MAX_EVENT_QUEUE_SIZE: int = _wtransport.DEFAULT_MAX_EVENT_QUEUE_SIZE
DEFAULT_MAX_MESSAGE_SIZE: int = _wtransport.DEFAULT_MAX_MESSAGE_SIZE
DEFAULT_MAX_PENDING_EVENTS_PER_SESSION: int = _wtransport.DEFAULT_MAX_PENDING_EVENTS_PER_SESSION
DEFAULT_MAX_RETRY_DELAY: float = _wtransport.DEFAULT_MAX_RETRY_DELAY
DEFAULT_MAX_STREAM_READ_BUFFER: int = _wtransport.DEFAULT_MAX_STREAM_READ_BUFFER
DEFAULT_MAX_STREAM_WRITE_BUFFER: int = _wtransport.DEFAULT_MAX_STREAM_WRITE_BUFFER
DEFAULT_MAX_TOTAL_PENDING_EVENTS: int = _wtransport.DEFAULT_MAX_TOTAL_PENDING_EVENTS
DEFAULT_PENDING_EVENT_TTL: float = _wtransport.DEFAULT_PENDING_EVENT_TTL
DEFAULT_READ_TIMEOUT: float = _wtransport.DEFAULT_READ_TIMEOUT
DEFAULT_RESOURCE_CLEANUP_INTERVAL: float = _wtransport.DEFAULT_RESOURCE_CLEANUP_INTERVAL
DEFAULT_RETRY_BACKOFF: float = _wtransport.DEFAULT_RETRY_BACKOFF
DEFAULT_RETRY_DELAY: float = _wtransport.DEFAULT_RETRY_DELAY
DEFAULT_SERVER_MAX_CONNECTIONS: int = _wtransport.DEFAULT_SERVER_MAX_CONNECTIONS
DEFAULT_SERVER_MAX_SESSIONS: int = _wtransport.DEFAULT_SERVER_MAX_SESSIONS
DEFAULT_STREAM_CREATION_TIMEOUT: float = _wtransport.DEFAULT_STREAM_CREATION_TIMEOUT
DEFAULT_WRITE_TIMEOUT: float = _wtransport.DEFAULT_WRITE_TIMEOUT
SUPPORTED_CONGESTION_CONTROL_ALGORITHMS: list[str] = _wtransport.SUPPORTED_CONGESTION_CONTROL_ALGORITHMS


class ErrorCodes(IntEnum):
    """Enumeration of WebTransport and HTTP/3 error codes."""

    AEAD_LIMIT_REACHED = _wtransport.ERR_AEAD_LIMIT_REACHED
    APP_AUTHENTICATION_FAILED = _wtransport.ERR_APP_AUTHENTICATION_FAILED
    APP_CONNECTION_TIMEOUT = _wtransport.ERR_APP_CONNECTION_TIMEOUT
    APP_INVALID_REQUEST = _wtransport.ERR_APP_INVALID_REQUEST
    APP_PERMISSION_DENIED = _wtransport.ERR_APP_PERMISSION_DENIED
    APP_RESOURCE_EXHAUSTED = _wtransport.ERR_APP_RESOURCE_EXHAUSTED
    APP_SERVICE_UNAVAILABLE = _wtransport.ERR_APP_SERVICE_UNAVAILABLE
    APPLICATION_ERROR = _wtransport.ERR_APPLICATION_ERROR
    CONNECTION_ID_LIMIT_ERROR = _wtransport.ERR_CONNECTION_ID_LIMIT_ERROR
    CONNECTION_REFUSED = _wtransport.ERR_CONNECTION_REFUSED
    CRYPTO_BUFFER_EXCEEDED = _wtransport.ERR_CRYPTO_BUFFER_EXCEEDED
    FINAL_SIZE_ERROR = _wtransport.ERR_FINAL_SIZE_ERROR
    FLOW_CONTROL_ERROR = _wtransport.ERR_FLOW_CONTROL_ERROR
    FRAME_ENCODING_ERROR = _wtransport.ERR_FRAME_ENCODING_ERROR
    H3_CLOSED_CRITICAL_STREAM = _wtransport.ERR_H3_CLOSED_CRITICAL_STREAM
    H3_CONNECT_ERROR = _wtransport.ERR_H3_CONNECT_ERROR
    H3_DATAGRAM_ERROR = _wtransport.ERR_H3_DATAGRAM_ERROR
    H3_EXCESSIVE_LOAD = _wtransport.ERR_H3_EXCESSIVE_LOAD
    H3_FRAME_ERROR = _wtransport.ERR_H3_FRAME_ERROR
    H3_FRAME_UNEXPECTED = _wtransport.ERR_H3_FRAME_UNEXPECTED
    H3_GENERAL_PROTOCOL_ERROR = _wtransport.ERR_H3_GENERAL_PROTOCOL_ERROR
    H3_ID_ERROR = _wtransport.ERR_H3_ID_ERROR
    H3_INTERNAL_ERROR = _wtransport.ERR_H3_INTERNAL_ERROR
    H3_MESSAGE_ERROR = _wtransport.ERR_H3_MESSAGE_ERROR
    H3_MISSING_SETTINGS = _wtransport.ERR_H3_MISSING_SETTINGS
    H3_NO_ERROR = _wtransport.ERR_H3_NO_ERROR
    H3_REQUEST_CANCELLED = _wtransport.ERR_H3_REQUEST_CANCELLED
    H3_REQUEST_INCOMPLETE = _wtransport.ERR_H3_REQUEST_INCOMPLETE
    H3_REQUEST_REJECTED = _wtransport.ERR_H3_REQUEST_REJECTED
    H3_SETTINGS_ERROR = _wtransport.ERR_H3_SETTINGS_ERROR
    H3_STREAM_CREATION_ERROR = _wtransport.ERR_H3_STREAM_CREATION_ERROR
    H3_VERSION_FALLBACK = _wtransport.ERR_H3_VERSION_FALLBACK
    INTERNAL_ERROR = _wtransport.ERR_INTERNAL_ERROR
    INVALID_TOKEN = _wtransport.ERR_INVALID_TOKEN
    KEY_UPDATE_ERROR = _wtransport.ERR_KEY_UPDATE_ERROR
    LIB_CONNECTION_STATE_ERROR = _wtransport.ERR_LIB_CONNECTION_STATE_ERROR
    LIB_INTERNAL_ERROR = _wtransport.ERR_LIB_INTERNAL_ERROR
    LIB_SESSION_STATE_ERROR = _wtransport.ERR_LIB_SESSION_STATE_ERROR
    LIB_STREAM_STATE_ERROR = _wtransport.ERR_LIB_STREAM_STATE_ERROR
    NO_ERROR = _wtransport.ERR_NO_ERROR
    NO_VIABLE_PATH = _wtransport.ERR_NO_VIABLE_PATH
    PROTOCOL_VIOLATION = _wtransport.ERR_PROTOCOL_VIOLATION
    QPACK_DECODER_STREAM_ERROR = _wtransport.ERR_QPACK_DECODER_STREAM_ERROR
    QPACK_DECOMPRESSION_FAILED = _wtransport.ERR_QPACK_DECOMPRESSION_FAILED
    QPACK_ENCODER_STREAM_ERROR = _wtransport.ERR_QPACK_ENCODER_STREAM_ERROR
    STREAM_LIMIT_ERROR = _wtransport.ERR_STREAM_LIMIT_ERROR
    STREAM_STATE_ERROR = _wtransport.ERR_STREAM_STATE_ERROR
    TRANSPORT_PARAMETER_ERROR = _wtransport.ERR_TRANSPORT_PARAMETER_ERROR
    WT_APPLICATION_ERROR_FIRST = _wtransport.ERR_WT_APPLICATION_ERROR_FIRST
    WT_APPLICATION_ERROR_LAST = _wtransport.ERR_WT_APPLICATION_ERROR_LAST
    WT_BUFFERED_STREAM_REJECTED = _wtransport.ERR_WT_BUFFERED_STREAM_REJECTED
    WT_FLOW_CONTROL_ERROR = _wtransport.ERR_WT_FLOW_CONTROL_ERROR
    WT_SESSION_GONE = _wtransport.ERR_WT_SESSION_GONE
