import type { CSSProperties } from "react"; export type StartupSurface = "chat" | "settings" | "skills" | "apps" | "channels" | "automations" | "remote"; /** Also inlined in index.html: keep document startup independent of app modules. */ export function readStartupLayout() { let hash = window.location.hash.slice(1); let sidebarExpanded = true; let sidebarWidth = 272; try { if ((!hash || hash === "/" || hash === "/new") && Date.now() - Number(localStorage.getItem("nanobot-webui.restartStartedAt") || 0) < 300_000) { hash = (localStorage.getItem("nanobot-webui.restartRoute") || hash).replace(/^#/, ""); } const stored = localStorage.getItem("nanobot-webui.sidebar"); sidebarExpanded = stored === null || stored === "1"; const width = Number(localStorage.getItem("nanobot-webui.sidebar.width")); if (Number.isFinite(width) && width >= 220) sidebarWidth = Math.min(480, width); } catch { // Storage can be unavailable in private browsing; use the shell's defaults. } const [path, query = ""] = hash.split("?", 2); const section = new URLSearchParams(query).get("section") || "overview"; const page = path === "/settings" ? section : path.slice(1); let surface: StartupSurface = "chat"; if (page === "skills" || page === "apps" || page === "channels" || page === "automations" || page === "remote") surface = page; else if (path === "/settings") surface = "settings"; const now = new Date(); const firstDay = new Date(now.getFullYear(), now.getMonth(), 1); const days = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate(); const calendarWeeks = Math.ceil(((firstDay.getDay() + 6) % 7 + days) / 7); return { surface, section, sidebarExpanded, sidebarWidth, calendarWeeks, existingChat: /^\/(chat|temporary)\/.+/.test(path) }; } interface StartupSkeletonProps { surface?: StartupSurface; section?: string; sidebarExpanded?: boolean; sidebarWidth?: number; existingChat?: boolean; calendarWeeks?: number; embedded?: boolean; label?: string; } function Block({ className = "" }: { className?: string }) { return
; } /** One markup/CSS contract for the HTML first paint and React's loading boundaries. */ export function StartupSkeleton({ surface = "chat", section = "overview", sidebarExpanded = true, sidebarWidth = 272, existingChat = false, calendarWeeks = 5, embedded = false, label = "Loading nanobot…", }: StartupSkeletonProps) { const Root = embedded ? "section" : "main"; return (