#!/usr/bin/env python3
"""Render dasbor HTML jadi gambar PNG supaya bisa dilihat langsung di chat."""
import asyncio

HTML = "file:///home/mantapman/.hermes/profiles/atun/workspace/drafts/dashboard_studiosoft.html"
PNG = "/home/mantapman/.hermes/profiles/atun/workspace/drafts/dashboard_studiosoft.png"


async def main():
    from playwright.async_api import async_playwright
    async with async_playwright() as pw:
        br = await pw.chromium.launch()
        hal = await br.new_page(viewport={"width": 1180, "height": 1400}, device_scale_factor=2)
        await hal.goto(HTML, wait_until="load", timeout=60000)
        await hal.wait_for_timeout(1200)
        await hal.screenshot(path=PNG, full_page=True)
        tinggi = await hal.evaluate("document.body.scrollHeight")
        print(f"tinggi halaman: {tinggi}px → {PNG}")
        await br.close()


asyncio.run(main())
