from __future__ import annotations

from typing import Any, Final

from threading import Lock

from .cache import (
    CacheCapacityConfig,
    CacheLayer,
    CacheManager,
    CacheStatistics,
    InstrumentedLRUCache,
    ManagedLRUCache,
    MappingCacheLayer,
    RedisCacheLayer,
    ShelveCacheLayer,
    SecurityError,
    prune_lock_mapping,
    DNFR_PREP_STATE_KEY,
    DnfrPrepState,
    DnfrCache,
    NODE_SET_CHECKSUM_KEY,
    ScopedCounterCache,
    EdgeCacheManager,
    cached_node_list,
    cached_nodes_and_A,
    clear_node_repr_cache,
    configure_graph_cache_limits,
    configure_global_cache_layers,
    edge_version_cache,
    edge_version_update,
    ensure_node_index_map,
    ensure_node_offset_map,
    new_dnfr_cache,
    _SeedHashCache,
    _GRAPH_CACHE_MANAGER_KEY,
    _graph_cache_manager,
    build_cache_manager,
    get_graph_version,
    increment_edge_version,
    increment_graph_version,
    node_set_checksum,
    reset_global_cache_manager,
    stable_json,
    _GRAPH_CACHE_LAYERS_KEY,
)
from .data import (
    MAX_MATERIALIZE_DEFAULT,
    STRING_TYPES,
    convert_value,
    normalize_optional_int,
    ensure_collection,
    flatten_structure,
    is_non_string_sequence,
    mix_groups,
    negative_weights_warn_once,
    normalize_counter,
    normalize_materialize_limit,
    normalize_weights,
)
from .chunks import auto_chunk_size, resolve_chunk_size
from .graph import (
    get_graph,
    get_graph_mapping,
    mark_dnfr_prep_dirty,
    supports_add_edge,
)
from .numeric import (
    angle_diff,
    angle_diff_array,
    clamp,
    clamp01,
    kahan_sum_nd,
    similarity_abs,
    within_range,
)
from .init import (
    _DEFAULT_CACHE_SIZE,
    _FAILED_IMPORT_LIMIT,
    _IMPORT_STATE,
    _LOGGING_CONFIGURED,
    EMIT_MAP,
    IMPORT_LOG,
    LazyImportProxy,
    WarnOnce,
    _configure_root,
    _reset_import_state,
    _reset_logging_state,
    _warn_failure,
    cached_import,
    get_logger,
    get_nodenx,
    get_numpy,
    prune_failed_imports,
    warm_cached_import,
    warn_once,
)
from .io import (
    DEFAULT_PARAMS,
    JsonDumpsParams,
    StructuredFileError,
    clear_orjson_param_warnings,
    json_dumps,
    read_structured_file,
    safe_write,
)
from .callbacks import (
    CallbackEvent,
    CallbackManager,
    callback_manager,
    CallbackSpec,
)

__all__ = (
    "IMPORT_LOG",
    "WarnOnce",
    "cached_import",
    "warm_cached_import",
    "LazyImportProxy",
    "get_logger",
    "get_lock",
    "get_nodenx",
    "get_numpy",
    "prune_failed_imports",
    "warn_once",
    "convert_value",
    "normalize_optional_int",
    "normalize_weights",
    "normalize_counter",
    "normalize_materialize_limit",
    "ensure_collection",
    "flatten_structure",
    "is_non_string_sequence",
    "STRING_TYPES",
    "MAX_MATERIALIZE_DEFAULT",
    "negative_weights_warn_once",
    "mix_groups",
    "angle_diff",
    "angle_diff_array",
    "clamp",
    "clamp01",
    "auto_chunk_size",
    "resolve_chunk_size",
    "CacheCapacityConfig",
    "CacheLayer",
    "CacheManager",
    "CacheStatistics",
    "InstrumentedLRUCache",
    "ManagedLRUCache",
    "MappingCacheLayer",
    "RedisCacheLayer",
    "ShelveCacheLayer",
    "SecurityError",
    "prune_lock_mapping",
    "EdgeCacheManager",
    "DNFR_PREP_STATE_KEY",
    "DnfrPrepState",
    "DnfrCache",
    "NODE_SET_CHECKSUM_KEY",
    "ScopedCounterCache",
    "cached_node_list",
    "cached_nodes_and_A",
    "clear_node_repr_cache",
    "edge_version_cache",
    "edge_version_update",
    "configure_global_cache_layers",
    "ensure_node_index_map",
    "ensure_node_offset_map",
    "new_dnfr_cache",
    "get_graph_version",
    "increment_edge_version",
    "increment_graph_version",
    "configure_graph_cache_limits",
    "build_cache_manager",
    "_graph_cache_manager",
    "_GRAPH_CACHE_MANAGER_KEY",
    "node_set_checksum",
    "stable_json",
    "reset_global_cache_manager",
    "_SeedHashCache",
    "_GRAPH_CACHE_LAYERS_KEY",
    "get_graph",
    "get_graph_mapping",
    "mark_dnfr_prep_dirty",
    "supports_add_edge",
    "JsonDumpsParams",
    "DEFAULT_PARAMS",
    "json_dumps",
    "clear_orjson_param_warnings",
    "read_structured_file",
    "safe_write",
    "StructuredFileError",
    "kahan_sum_nd",
    "similarity_abs",
    "within_range",
    "_configure_root",
    "_LOGGING_CONFIGURED",
    "_reset_logging_state",
    "_reset_import_state",
    "_IMPORT_STATE",
    "_warn_failure",
    "_FAILED_IMPORT_LIMIT",
    "_DEFAULT_CACHE_SIZE",
    "EMIT_MAP",
    "CallbackEvent",
    "CallbackManager",
    "callback_manager",
    "CallbackSpec",
)

def get_lock(name: str, /) -> Lock: ...

_DYNAMIC_EXPORTS: Final[frozenset[str]]

def __getattr__(name: str) -> Any: ...
