"""Core ICSD domain primitives."""

from __future__ import annotations

from importlib import import_module
from typing import Any

from .evidence import (
    AuthoritySource,
    EvidenceBundle,
    EvidenceProvenance,
    EvidenceProvenanceHook,
    EvidenceSignature,
    EvidenceSignatureHook,
    normalise_authority_sources,
    normalise_evidence_provenance,
    normalise_evidence_signatures,
    validate_evidence_payload,
)
from .invariants import Invariant, InvariantProfile, InvariantProfileRegistry, InvariantSet
from .serialise import canonical_json_bytes_for_signing

__all__ = [
    "AuthoritySource",
    "EvidenceBundle",
    "EvidenceProvenance",
    "EvidenceProvenanceHook",
    "EvidenceSignature",
    "EvidenceSignatureHook",
    "Invariant",
    "InvariantProfile",
    "InvariantProfileRegistry",
    "InvariantSet",
    "Transition",
    "TransitionContext",
    "TransitionResult",
    "canonical_json_bytes_for_signing",
    "normalise_authority_sources",
    "normalise_evidence_provenance",
    "normalise_evidence_signatures",
    "validate_evidence_payload",
]


def __getattr__(name: str) -> Any:
    if name in {"Transition", "TransitionContext", "TransitionResult"}:
        module = import_module("icsd.core.transition")
        return getattr(module, name)
    msg = f"module {__name__!r} has no attribute {name!r}"
    raise AttributeError(msg)
