"""Circle Finder - reusable circle detection for ECOS Core.

Two layers are exposed:
  - the Model wrapper (``Model``) for the ECOS BaseModel / opt.json workflow;
  - the pure library (``Circle``, geometry primitives, detector registry) for
    direct use in scripts / notebooks / other projects, with no torch import.
"""
from ecos_core.circle_finder.geometry import (
    Circle,
    circularity,
    fit_circle_lsq,
    fit_circle_trimmed,
    fit_circle_ransac,
    refine_center_subpixel_radial,
    edge_support_score,
)
from ecos_core.circle_finder.detectors import (
    BaseDetector,
    DetectContext,
    register_detector,
    build_detector,
    available_detectors,
    DETECTOR_REGISTRY,
)

# The Model pulls in torch (via BaseModel); import lazily so the pure library
# stays importable in torch-free environments.
try:
    from ecos_core.circle_finder.circle_finder import Model
except Exception:  # pragma: no cover - torch/base_model missing
    Model = None

__all__ = [
    "Model",
    "Circle",
    "circularity",
    "fit_circle_lsq",
    "fit_circle_trimmed",
    "fit_circle_ransac",
    "refine_center_subpixel_radial",
    "edge_support_score",
    "BaseDetector",
    "DetectContext",
    "register_detector",
    "build_detector",
    "available_detectors",
    "DETECTOR_REGISTRY",
]
