#!/usr/bin/env python3
# -S uv run --script
# /// script
# dependencies = [
#   "click>=8.1.3",
#   "ebooklib>=0.18.0",
#   "epub2audio>=0.1.0",
# ]
# ///
#MISE alias="read-epub"
#MISE description="Read a EPUB file"
"""Read a EPUB file."""

import sys

from pathlib import Path

import click
import ebooklib  # type: ignore
from ebooklib import epub

from src.epub_processor import EpubProcessor


@click.command()
@click.argument("path", type=click.Path(exists=True), default="tests/data/sample.epub")
def read_epub(path: Path) -> epub.EpubBook:
    """Read a EPUB file carefully.

    Meant to be used for debugging.

    Args:
        path: Path to the EPUB file

    Returns:
        epub.EpubBook: The EPUB book
    """
    # from pdb import set_trace; set_trace()
    epub_processor = EpubProcessor(path)

    print(epub_processor.book)
    # for chapter in epub_processor.book.chapters:
    #     print(chapter)
    # Read a new EPUB book
    # book = epub.read_epub(path)

    # print(book.get_items_of_type(ebooklib.ITEM_DOCUMENT))
    # from code import interact; interact(local=locals())

if __name__ == "__main__":
    read_epub()
