import marimo

__generated_with = "0.19.7"
app = marimo.App(width="medium")

with app.setup:
    import marimo as mo
    from pathlib import Path
    import utils


@app.cell
def _():
    mo.md(r"""
    # Tag existing images with Alt-Text

    Based on image content
    """)
    return


@app.cell
def _():
    TAG_SOURCE = Path('data/reports/Perception-Research-Report_2-2.pptx')
    # TAG_TARGET = Path('data/reports/Perception-Research-Report_2-2_tagged.pptx')
    TAG_IMAGE_DIR = Path('figures/2-2-26')
    return TAG_IMAGE_DIR, TAG_SOURCE


@app.cell
def _(TAG_IMAGE_DIR, TAG_SOURCE):
    utils.update_ppt_alt_text(
        ppt_path=TAG_SOURCE, 
        image_source_dir=TAG_IMAGE_DIR, 
        # output_path=TAG_TARGET
    )
    return


@app.cell(hide_code=True)
def _():
    mo.md(r"""
    # Replace Images using Alt-Text
    """)
    return


@app.cell
def _():
    REPLACE_SOURCE = Path('data/reports/Perception-Research-Report_2-2.pptx')
    REPLACE_TARGET = Path('data/reports/Perception-Research-Report_2-2_updated.pptx')

    NEW_IMAGES_DIR = Path('figures/2-2-26')
    return NEW_IMAGES_DIR, REPLACE_SOURCE


@app.cell
def _(NEW_IMAGES_DIR, REPLACE_SOURCE):
    # get all files in the image source directory and subdirectories
    results = utils.pptx_replace_images_from_directory(
        REPLACE_SOURCE,            # Source presentation path,
        NEW_IMAGES_DIR,          # Source directory with new images
        # REPLACE_TARGET  # Output path (optional, defaults to overwrite)
    )
    return


if __name__ == "__main__":
    app.run()
