from __future__ import annotations

import html

from ..assets.base_css import BASE_CSS
from ..assets.base_js import BASE_JS
from .nav import nav


def page(title: str, active: str, body: str, script: str = "") -> str:
    return f"""<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>{html.escape(title)}</title>
  <style>{BASE_CSS}</style>
</head>
<body>
  <div class="layout">
    <nav class="nav">
      <div class="brand">Argus MVP</div>
      {nav(active)}
      <div style="margin-top:12px" class="muted">
        Token stored in browser localStorage as <code>mvp_token</code>.
      </div>
    </nav>
    <main class="main">
      {body}
    </main>
  </div>
  <script>{BASE_JS}</script>
  <script>{script}</script>
</body>
</html>"""

