"""Build the HTML/JS/CSS for the chart visualizer. Reads static/visualizer.js and injects chart data via window.CHART_DATA. Returns an iframe with srcdoc for Chrome/Arc compatibility. """ import html import json from pathlib import Path _JS_PATH = Path(__file__).parent / "static" / "visualizer.js" def build_visualizer_html(chart_json: dict) -> str: data_json = json.dumps(chart_json, separators=(",", ":")) js_code = _JS_PATH.read_text(encoding="utf-8") full_html = _TEMPLATE.replace("__JS_CODE__", js_code).replace("__CHART_DATA__", data_json) escaped = html.escape(full_html, quote=True) return ( f'' ) _TEMPLATE = """
"""