import asyncio
from playwright.async_api import async_playwright
import os

async def render():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        
        slides = []
        for c in [9, 10]:
            for s in range(1, 6):
                html = os.path.expanduser(f"~/Documents/kaizen-campaign/campaign-{c}/slide{s}.html")
                png = os.path.expanduser(f"~/Documents/kaizen-campaign/campaign-{c}/slide{s}.png")
                slides.append((html, png))
        
        for html_path, png_path in slides:
            page = await browser.new_page(viewport={"width": 1080, "height": 1080})
            await page.goto(f"file://{html_path}")
            await page.wait_for_timeout(2000)  # wait for fonts
            await page.screenshot(path=png_path, type="png")
            await page.close()
            print(f"✓ {png_path}")
        
        await browser.close()

asyncio.run(render())
