"""Papercut: Extract knowledge from academic papers.

This module provides a comprehensive Python API for:
- Fetching papers from arXiv, DOI, SSRN, NBER, and URLs
- Extracting text, tables, figures, and references from PDFs
- Document indexing and structure detection
- LLM-powered intelligence features (summarization, reports, study aids)

Simple API (recommended for most users):
    >>> from papercut import fetch_arxiv, extract_text
    >>>
    >>> # Fetch and extract in two lines
    >>> doc = fetch_arxiv("1706.03762", "./papers")
    >>> text = extract_text(doc.path)

Advanced usage (for more control):
    >>> from papercut import ArxivFetcher, PdfPlumberExtractor, TextExtractor
    >>> from pathlib import Path
    >>>
    >>> # Fetch a paper
    >>> fetcher = ArxivFetcher()
    >>> doc = fetcher.fetch("1706.03762", Path("./papers"))
    >>>
    >>> # Extract text
    >>> backend = PdfPlumberExtractor()
    >>> extractor = TextExtractor(backend)
    >>> text = extractor.extract(doc.path)
"""

__version__ = "1.1.0"

# Exceptions
from papercut.exceptions import (
    ConfigError,
    EquationConversionError,
    EquationExtractionError,
    ExtractionError,
    FetchError,
    InvalidPDFError,
    LLMError,
    LLMNotAvailableError,
    MathPixAPIError,
    MissingAPIKeyError,
    NetworkError,
    NoContentError,
    PapercutError,
    PaperNotFoundError,
    RateLimitError,
)

# Fetchers
from papercut.fetchers.arxiv import ArxivFetcher
from papercut.fetchers.base import BaseFetcher, Document
from papercut.fetchers.doi import DOIFetcher
from papercut.fetchers.nber import NBERFetcher
from papercut.fetchers.ssrn import SSRNFetcher
from papercut.fetchers.url import URLFetcher

# Extractors (backends)
from papercut.extractors.base import Extractor
from papercut.extractors.pdfplumber import PdfPlumberExtractor

# Core extraction
from papercut.core.equations import (
    EquationExtractor,
    EquationType,
    ExtractedEquation,
    LaTeXConversion,
)
from papercut.core.figures import ExtractedFigure, FigureExtractor
from papercut.core.references import Reference, ReferenceExtractor
from papercut.core.tables import ExtractedTable, TableExtractor
from papercut.core.text import TextExtractor

# Document indexing
from papercut.index.indexer import (
    DocumentIndex,
    DocumentIndexer,
    FigureInfo,
    Section,
    TableInfo,
)

# Book chapter detection
from papercut.books.splitter import Chapter, ChapterSplitter

# Cache
from papercut.cache import CacheStore, file_hash, get_cache

# Configuration
from papercut.config.settings import Settings, get_settings

# Output formatting
from papercut.output import OutputFormatter, get_formatter

# LLM integration
from papercut.llm import LLMClient, get_client as get_llm_client
from papercut.llm.client import LLMResponse

# Intelligence features (LLM-powered)
from papercut.intelligence import ReportGenerator, StudyAid, Summarizer

# Convenience API
from papercut.api import (
    extract_figures,
    extract_refs,
    extract_tables,
    extract_text,
    extract_text_chunked,
    fetch_arxiv,
    fetch_doi,
    fetch_nber,
    fetch_paper,
    fetch_ssrn,
    fetch_url,
)

__all__ = [
    # Version
    "__version__",
    # Exceptions
    "PapercutError",
    "FetchError",
    "PaperNotFoundError",
    "RateLimitError",
    "NetworkError",
    "ExtractionError",
    "InvalidPDFError",
    "NoContentError",
    "ConfigError",
    "MissingAPIKeyError",
    "LLMError",
    "LLMNotAvailableError",
    "EquationExtractionError",
    "EquationConversionError",
    "MathPixAPIError",
    # Fetchers
    "BaseFetcher",
    "Document",
    "ArxivFetcher",
    "DOIFetcher",
    "SSRNFetcher",
    "NBERFetcher",
    "URLFetcher",
    # Extractors
    "Extractor",
    "PdfPlumberExtractor",
    # Core extraction
    "TextExtractor",
    "TableExtractor",
    "ExtractedTable",
    "ReferenceExtractor",
    "Reference",
    "FigureExtractor",
    "ExtractedFigure",
    "EquationExtractor",
    "ExtractedEquation",
    "EquationType",
    "LaTeXConversion",
    # Document indexing
    "DocumentIndexer",
    "DocumentIndex",
    "Section",
    "TableInfo",
    "FigureInfo",
    # Books
    "ChapterSplitter",
    "Chapter",
    # Cache
    "CacheStore",
    "get_cache",
    "file_hash",
    # Configuration
    "Settings",
    "get_settings",
    # Output
    "OutputFormatter",
    "get_formatter",
    # LLM
    "LLMClient",
    "LLMResponse",
    "get_llm_client",
    # Intelligence
    "Summarizer",
    "ReportGenerator",
    "StudyAid",
    # Convenience API
    "fetch_arxiv",
    "fetch_doi",
    "fetch_ssrn",
    "fetch_nber",
    "fetch_url",
    "fetch_paper",
    "extract_text",
    "extract_text_chunked",
    "extract_tables",
    "extract_refs",
    "extract_figures",
]
