1// Today: the daily's field live; while it is being produced (or missing),2// a status line and the latest finished day's replay, polling until live.3// A plain checkout without the daily follows the newest game.4import { define } from "../utils.ts";5import Viewer from "../islands/Viewer.tsx";6import Today from "../islands/Today.tsx";7import CopyPrompt from "../islands/CopyPrompt.tsx";8import Login from "../islands/Login.tsx";9import { daily } from "../lib/daily.ts";10import { bootstrapText } from "../lib/prompt.ts";1112export default define.page(function Home(ctx) {13 const replay = ctx.url.searchParams.get("replay");14 const t = ctx.url.searchParams.get("theme");15 const theme = t === "dark" || t === "light" ? t : null;16 const d = daily();17 const status = d?.status() ?? null;18 const origin = ctx.url.origin;19 const prompt = bootstrapText(origin, status?.date ?? null);20 const zoom = Number(ctx.url.searchParams.get("zoom")) || null;21 return (22 <div style="display:flex;flex-direction:column;height:100vh;height:100dvh">23 <nav class="nav">24 <a href="/" class="brand">mosaic</a>25 <span class="sc" style="color:var(--text-dim)">26 {replay ? "replay" : status ? `today ${status.date}` : "live"}27 </span>28 <a href="/calendar">calendar</a>29 {status && <a href={`/leaderboard/${status.date}`}>table</a>}30 <span class="spacer" />31 <CopyPrompt text={prompt} />32 <Login />33 </nav>34 <div style="flex:1;min-height:0">35 {replay || !status36 ? (37 <Viewer38 replay={replay}39 theme={theme}40 live={null}41 day={status?.date ?? null}42 zoom={zoom}43 />44 )45 : <Today initial={status} theme={theme} />}46 </div>47 </div>48 );49});