@the-portland-company/shell 0.76.2 → 0.76.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-chrome.cjs +24 -2
- package/dist/app-chrome.cjs.map +1 -1
- package/dist/app-chrome.js +2 -2
- package/dist/chrome.css +4 -1
- package/dist/{chunk-6KX3DWBC.js → chunk-Z2VEYL2A.js} +26 -4
- package/dist/chunk-Z2VEYL2A.js.map +1 -0
- package/dist/native.cjs +24 -2
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6KX3DWBC.js.map +0 -1
package/dist/native.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/topbarIconSlot.ts","../src/lib/brandGlyphs.tsx","../src/lib/deprecation.ts","../src/native/orgFilter.ts","../src/nav-preference.ts","../src/speculation/emitRules.ts","../src/speculation/SpeculationRulesScript.tsx","../src/theme-preference.ts","../src/native/chromeActions.tsx","../src/components/FormColumn.tsx","../src/native/standardNavIcons.ts","../src/native/standardNav.ts","../src/native/index.tsx"],"names":["useState","useEffect","FiBatteryCharging","FiBattery","FiZap","FiGrid","FiBell","FiAlertTriangle","FiAlertCircle","FiLifeBuoy","FiHelpCircle","FiMoon","FiSun","FiInfo","FiMail","FiMessageSquare","FiSettings","FiUser","useMemo","useSyncExternalStore","jsxs","jsx","createContext","useRef","useContext","Fragment","useCallback","createPortal","clsx","LuHouse","LuUsers","LuMail","LuMessageSquare","LuLayoutDashboard","LuActivity","LuLifeBuoy","LuLayoutGrid","LuList","LuUpload","LuPencil","LuFileText","LuSend","LuClock","LuUser","LuChartColumn","LuBriefcase","LuSettings","LuCreditCard","LuDollarSign","LuShare2","LuPhone","LuMap","LuMapPin","LuTarget","LuFlag","LuUsersRound","LuMousePointerClick","LuClipboardList","LuCircleUser","LuCrosshair","LuLandmark","LuChartNoAxesColumn","LuDoorOpen","LuSignpost"],"m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QAAA,EAAA,MAAA,CAAO,KAAA,EACV,CAAA,GACE,IAAA;AAAA,UACH,cAAA,KAAmB,MAAA,mBAClBA,cAAAA,CAAC,KAAA,EAAA,EAAI,oBAAA,EAAmB,EAAA,EAAG,SAAA,EAAW,MAAA,CAAO,KAAA,GAAQ,WAAA,GAAc,MAAA,EAChE,QAAA,EACH,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BASAA,cAAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,oBAAA,EAAmB,EAAA;AAAA,gBACnB,SAAA,EAAW,CAAA,4FAAA,EAA+F,MAAA,CAAO,KAAA,GAAQ,cAAc,cAAc,CAAA,CAAA;AAAA,gBAEpJ;AAAA;AAAA;AACH;AAAA,SAAA,EAEJ;AAAA;AAAA;AAAA,GACF;AAEJ","file":"native.cjs","sourcesContent":["import { useEffect, useState } from 'react'\n\n/**\n * The six canonical top-bar action slots (Reference/Global-Rules v9 → top-bar\n * icons). Each slot's GLYPH is unique and comes from the Brand API\n * `topbarIcons.items.*` tokens, exposed as `--topbar-icon-<slot>` CSS vars\n * whose value is the brand-icon NAME. Every OTHER property — size, gap, color,\n * hover, selected — is universal across all six slots.\n */\nexport type TopBarIconSlot =\n | 'comms-fuel'\n | 'apps'\n | 'notifications'\n | 'alerts'\n | 'support'\n | 'dark-mode'\n\n/**\n * Reads the glyph NAME for a slot from its `--topbar-icon-<slot>` CSS var.\n *\n * Runs in an effect because the Brand stylesheet is appended to <head> at\n * runtime (Global Rules forbids baking it into the build), so the var is not\n * resolvable during SSR or the first synchronous render. The MutationObserver\n * re-reads once the stylesheet lands so the glyph upgrades from the caller's\n * fallback without a reload.\n *\n * Returns null when the slot has no Brand glyph — callers render their own\n * fallback icon in that case.\n */\nexport function useTopBarIconSlotGlyph(slot: TopBarIconSlot): string | null {\n const [name, setName] = useState<string | null>(null)\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n const read = () => {\n const raw = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--topbar-icon-${slot}`)\n .trim()\n // Brand may emit the name quoted (e.g. \"bell\"); strip the quotes.\n .replace(/^['\"]|['\"]$/g, '')\n setName(raw.length > 0 ? raw : null)\n }\n\n read()\n\n const observer = new MutationObserver(read)\n observer.observe(document.head, { childList: true, subtree: true })\n return () => observer.disconnect()\n }, [slot])\n\n return name\n}\n\n/** Path to a brand-icon SVG in the consuming app's public dir. */\nexport function brandIconSrc(name: string, basePath = '/brand/icons/') {\n return `${basePath}${name}.svg`\n}\n","import type { ComponentType } from 'react'\nimport {\n FiAlertCircle,\n FiBattery,\n FiBatteryCharging,\n FiAlertTriangle,\n FiBell,\n FiGrid,\n FiHelpCircle,\n FiInfo,\n FiLifeBuoy,\n FiMail,\n FiMessageSquare,\n FiMoon,\n FiSettings,\n FiSun,\n FiUser,\n FiZap,\n} from 'react-icons/fi'\n\nexport type GlyphComponent = ComponentType<{ size?: number | string; className?: string }>\n\n/**\n * Brand-glyph registry: maps the icon NAME the Brand API emits (e.g.\n * `--topbar-icon-comms-fuel: bolt`) to a component.\n *\n * These names are Feather/Lucide icon names, NOT asset filenames — there is no\n * `/brand/icons/<name>.svg` for them in any app, and treating them as URLs\n * renders a broken image. Resolving them against the icon library the shell\n * already depends on keeps every app consistent with zero vendored assets.\n *\n * Aliases are included where Brand and Feather disagree on a name (`bolt` vs\n * `zap`, `life-buoy` vs `life-ring`).\n */\nconst GLYPHS: Record<string, GlyphComponent> = {\n // Communications Fuel reads as a LEVEL, so its glyph is a battery. `bolt`/\n // `zap` stay mapped for older Brand values.\n 'battery-charging': FiBatteryCharging,\n battery: FiBattery,\n fuel: FiBatteryCharging,\n bolt: FiZap,\n zap: FiZap,\n grid: FiGrid,\n apps: FiGrid,\n bell: FiBell,\n notification: FiBell,\n 'alert-triangle': FiAlertTriangle,\n alert: FiAlertTriangle,\n 'alert-circle': FiAlertCircle,\n 'life-buoy': FiLifeBuoy,\n 'life-ring': FiLifeBuoy,\n support: FiLifeBuoy,\n 'help-circle': FiHelpCircle,\n moon: FiMoon,\n sun: FiSun,\n info: FiInfo,\n mail: FiMail,\n 'message-square': FiMessageSquare,\n settings: FiSettings,\n user: FiUser,\n}\n\n/**\n * Resolve a Brand glyph name to a component. Returns null for an unknown name\n * so the caller renders its own fallback — an unrecognized token must never\n * produce a broken or empty icon.\n */\nexport function resolveBrandGlyph(name: string | null | undefined): GlyphComponent | null {\n if (!name) return null\n return GLYPHS[name.trim().toLowerCase()] ?? null\n}\n\n/** Names the registry knows — exported for tests and tooling. */\nexport const KNOWN_BRAND_GLYPHS = Object.keys(GLYPHS)\n","// One-time console warnings for retired shell API, in development only.\n\nconst warned = new Set<string>()\n\nfunction isDev(): boolean {\n try {\n return typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n } catch {\n return false\n }\n}\n\n/** Warn once per `key` in dev; silent in production builds. */\nexport function warnDeprecated(key: string, message: string): void {\n if (!isDev() || warned.has(key)) return\n warned.add(key)\n console.warn(`[@the-portland-company/shell] ${message}`)\n}\n\n/** Test hook: forget which warnings have fired. */\nexport function resetDeprecationWarnings(): void {\n warned.clear()\n}\n","/**\n * Organization-list filtering for the sidebar org selector.\n *\n * Accounts that belong to many organizations (a consultant managing a dozen\n * committees) got a 288 px panel showing seven rows and a near-invisible macOS\n * scrollbar — measured 2026-09-04: \"I cannot select other organizations\".\n * The panel now grows with the viewport and, above this threshold, gains a\n * type-to-filter box so any org is one keystroke away.\n */\nexport const ORG_FILTER_THRESHOLD = 8\n\nexport type FilterableOrg = { id: string; name: string | null }\n\n/** Case- and accent-insensitive substring match on the org name (or id prefix). */\nexport function filterOrgs<T extends FilterableOrg>(orgs: readonly T[], query: string): T[] {\n const q = normalize(query)\n if (!q) return [...orgs]\n return orgs.filter((o) => normalize(o.name ?? '').includes(q) || o.id.toLowerCase().startsWith(q))\n}\n\nexport function shouldShowOrgFilter(count: number): boolean {\n return count > ORG_FILTER_THRESHOLD\n}\n\nfunction normalize(s: string): string {\n return s\n .normalize('NFD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .trim()\n}\n","// Universal navigation-display preference — the same cross-app contract as the\n// theme (see ./theme-preference, which this deliberately mirrors).\n//\n// The user's choice of how navigation renders (Menu / Tabs / Both) follows the\n// authenticated user across every Politogy app + subdomain. Three layers:\n// 1. VRM Core `profiles.nav_display_preference` — source of truth, persisted\n// via the chrome API (`PATCH me/preferences { navDisplay }`) and read back\n// from `GET me` (`navDisplay`).\n// 2. `.politogyvrm.com` cookie `politogy_nav_display` — the cross-subdomain\n// vehicle (app session cookies are host-only, and so is localStorage).\n// 3. localStorage — same-app fast reads and cross-tab `storage` events.\n//\n// Before this existed the preference lived ONLY in localStorage under\n// `vrm.navDisplay`, which is per-ORIGIN: every app subdomain kept its own copy\n// and a freshly opened app booted the default, so the setting appeared not to\n// hold when moving between apps. The legacy key is still read as a fallback so\n// an existing local choice survives the upgrade.\n//\n// Server-safe (no 'use client'): layouts may import NAV_DISPLAY_PREPAINT_SCRIPT.\n\nexport type NavDisplayPreference = 'menu' | 'tabs' | 'both'\n\n// One key for BOTH the localStorage store and the cross-subdomain cookie, so a\n// choice in one app is the same key in the next.\nexport const NAV_DISPLAY_STORAGE_KEY = 'politogy_nav_display'\nexport const NAV_DISPLAY_COOKIE = 'politogy_nav_display'\n\n/** Pre-0.37 host-only key. Read for migration; never written. */\nexport const LEGACY_NAV_DISPLAY_KEY = 'vrm.navDisplay'\n\nexport const NAV_DISPLAY_DEFAULT: NavDisplayPreference = 'both'\n\nconst VALID: readonly NavDisplayPreference[] = ['menu', 'tabs', 'both']\n\nexport function isNavDisplayPreference(v: unknown): v is NavDisplayPreference {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v)\n}\n\n/** Read the shared cookie (browser only; null on the server or when unset). */\nexport function readNavDisplayCookie(): NavDisplayPreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isNavDisplayPreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n// Same host-aware scoping as the theme cookie: parent domain on\n// *.politogyvrm.com so every app subdomain reads it, host-only elsewhere\n// (localhost, *.pages.dev preview) because browsers silently drop a mismatched\n// Domain attribute. 1-year, SameSite=Lax, Secure on https.\nexport function writeNavDisplayCookie(pref: NavDisplayPreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${NAV_DISPLAY_COOKIE}=${encodeURIComponent(\n pref,\n )}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n}\n\n/** Read the local store, falling back to the legacy host-only key. */\nexport function readNavDisplayLocal(): NavDisplayPreference | null {\n if (typeof localStorage === 'undefined') return null\n try {\n const current = localStorage.getItem(NAV_DISPLAY_STORAGE_KEY)\n if (isNavDisplayPreference(current)) return current\n const legacy = localStorage.getItem(LEGACY_NAV_DISPLAY_KEY)\n return isNavDisplayPreference(legacy) ? legacy : null\n } catch {\n return null\n }\n}\n\nexport function writeNavDisplayLocal(pref: NavDisplayPreference): void {\n if (typeof localStorage === 'undefined') return\n try {\n localStorage.setItem(NAV_DISPLAY_STORAGE_KEY, pref)\n } catch {\n /* storage unavailable */\n }\n}\n\n/** Boot precedence: cookie → localStorage (incl. legacy) → default. */\nexport function resolveNavDisplay(): NavDisplayPreference {\n return readNavDisplayCookie() ?? readNavDisplayLocal() ?? NAV_DISPLAY_DEFAULT\n}\n\n// Inline pre-paint script — optional, and the mirror of THEME_PREPAINT_SCRIPT.\n// Nav display has no paint-blocking visual (the frame is client-rendered), but\n// seeding localStorage from the cookie before hydration keeps the first render\n// on the synced value instead of the default. Self-contained and silent.\nexport const NAV_DISPLAY_PREPAINT_SCRIPT = `(function(){try{\nvar KEY=${JSON.stringify(NAV_DISPLAY_STORAGE_KEY)};\nvar VALID=[\"menu\",\"tabs\",\"both\"];\nfunction fromCookie(){try{var m=document.cookie.match(/(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}\nvar cookie=fromCookie();\nif(cookie&&VALID.indexOf(cookie)!==-1){var ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}\nif(cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}}\n}catch(e){}})();`\n\n// ---------------------------------------------------------------------------\n// Rail expand preference — Left-Navigation §11.6: below `md` the rail\n// collapses to the 64px icon rail; \"the user can also collapse and expand it;\n// the choice is remembered per user\". Same cookie + localStorage layers as the\n// nav-display preference above (no server column yet), so the choice follows\n// the user across every app subdomain and survives reloads. Only an explicit\n// Expand / Collapse writes it; a route change that closes the overlay does not.\n// ---------------------------------------------------------------------------\n\nexport type RailPreference = 'expanded' | 'collapsed'\n\nexport const RAIL_STORAGE_KEY = 'politogy_rail'\nexport const RAIL_COOKIE = 'politogy_rail'\nexport const RAIL_DEFAULT: RailPreference = 'collapsed'\n\nexport function isRailPreference(v: unknown): v is RailPreference {\n return v === 'expanded' || v === 'collapsed'\n}\n\nexport function readRailPreference(): RailPreference {\n if (typeof document !== 'undefined') {\n try {\n const m = document.cookie.match(new RegExp(`(?:^|;\\\\s*)${RAIL_COOKIE}=([^;]+)`))\n const v = m ? decodeURIComponent(m[1]) : null\n if (isRailPreference(v)) return v\n } catch {\n /* ignore */\n }\n }\n if (typeof localStorage !== 'undefined') {\n try {\n const v = localStorage.getItem(RAIL_STORAGE_KEY)\n if (isRailPreference(v)) return v\n } catch {\n /* ignore */\n }\n }\n return RAIL_DEFAULT\n}\n\nexport function writeRailPreference(pref: RailPreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n try {\n document.cookie = `${RAIL_COOKIE}=${pref}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n } catch {\n /* ignore */\n }\n try {\n localStorage.setItem(RAIL_STORAGE_KEY, pref)\n } catch {\n /* storage unavailable */\n }\n}\n","import type { AppRegistryEntry } from '../types'\nimport type { NavItem } from '../native/index'\n\n/**\n * Build a Speculation Rules JSON payload that prerenders other apps in the\n * registry on moderate eagerness. Returns null when there are no eligible\n * other apps to prerender (e.g., this is the only app in the registry).\n *\n * @deprecated Legacy `AppRegistryEntry[]`-based registry is unused by any\n * current consumer. Cross-app sidebar nav now ships real `NavItem[]` trees\n * (`standardPolitogyNav`) — use `buildNavSpeculationRules` instead, which this\n * now delegates to.\n *\n * The host app is expected to render this as\n * `<script type=\"speculationrules\">{json}</script>` in <head> at runtime.\n */\nexport function buildSpeculationRules(\n currentApp: string,\n registry: AppRegistryEntry[],\n): string | null {\n const others = registry.filter(\n (entry) => entry.id !== currentApp && entry.visible !== false,\n )\n if (others.length === 0) return null\n const payload = {\n prerender: [\n {\n urls: others.map((entry) => entry.path),\n eagerness: 'moderate' as const,\n },\n ],\n }\n return JSON.stringify(payload)\n}\n\n/**\n * Labels the shell will never prerender or prefetch, even if a consumer's nav\n * tree somehow carries an `href` for them (sign-out is normally a footer\n * `onClick`, never a `NavItem.href` — this is a second guard, not the primary\n * one). Case-insensitive substring match against the row's label.\n */\nconst DESTRUCTIVE_LABEL_PATTERNS = ['sign out', 'signout', 'log out', 'logout', 'delete']\n\n/** URL substrings that mark a link as destructive/non-idempotent regardless of label. */\nconst DESTRUCTIVE_PATH_PATTERNS = ['/signout', '/sign-out', '/logout', '/log-out']\n\nfunction isDestructive(item: { label: string; href?: string }): boolean {\n const label = item.label.toLowerCase()\n if (DESTRUCTIVE_LABEL_PATTERNS.some((p) => label.includes(p))) return true\n const href = (item.href ?? '').toLowerCase()\n return DESTRUCTIVE_PATH_PATTERNS.some((p) => href.includes(p))\n}\n\n/**\n * Walk a `NavItem[]` tree (as produced by `standardPolitogyNav`) and collect\n * every absolute, cross-origin, non-destructive, GET-safe link — the\n * candidate set for prerender/prefetch. Sections and action rows (`onClick`,\n * no `href`) are skipped; children are walked too (sub-menu rows like\n * \"Command Center\" / \"New Poll\" are real cross-app destinations).\n */\nexport function collectSiblingAppUrls(items: NavItem[], currentOrigin: string): string[] {\n const urls = new Set<string>()\n const walk = (list: NavItem[]) => {\n for (const item of list) {\n if (item.kind === 'section') continue\n if (item.href && !isDestructive(item)) {\n try {\n const url = new URL(item.href, currentOrigin)\n if (url.origin !== currentOrigin && /^https?:$/.test(url.protocol)) {\n urls.add(url.href)\n }\n } catch {\n // Malformed href — skip rather than throw during nav render.\n }\n }\n if (item.children?.length) walk(item.children)\n }\n }\n walk(items)\n return Array.from(urls)\n}\n\nexport interface NavSpeculationRules {\n prerender: [{ source: 'list'; urls: string[]; eagerness: 'moderate' }]\n}\n\n/**\n * Build the Speculation Rules payload for a consumer's real sidebar nav tree:\n * every sibling `*.politogyvrm.com` app link, `eagerness: \"moderate\"` (the\n * browser's own heuristic — prerender starts on hover/pointerdown of a\n * matching `<a>`, not on page load). Sign-out and other destructive rows are\n * excluded by `collectSiblingAppUrls`. Returns `null` when there is nothing\n * to speculate on (e.g., an empty or single-app tree).\n *\n * Each target origin must opt in by sending\n * `Supports-Loading-Mode: credentialed-prerender` on its responses, per the\n * Speculation Rules cross-origin prerender contract — without it the browser\n * silently falls back to a normal navigation. (Other apps are adding this\n * header separately.)\n */\nexport function buildNavSpeculationRules(\n items: NavItem[],\n currentOrigin: string = typeof window !== 'undefined' ? window.location.origin : '',\n): NavSpeculationRules | null {\n const urls = collectSiblingAppUrls(items, currentOrigin)\n if (urls.length === 0) return null\n return {\n prerender: [{ source: 'list', urls, eagerness: 'moderate' }],\n }\n}\n","import { useEffect, useMemo } from 'react'\nimport type { NavItem } from '../native/index'\nimport { buildNavSpeculationRules, collectSiblingAppUrls } from './emitRules'\n\nconst SCRIPT_ID = 'politogy-speculation-rules'\nconst PREFETCH_ATTR = 'data-politogy-speculation-prefetch'\n\n/**\n * Renders the cross-app Speculation Rules `<script>` for the current\n * consumer's sidebar nav tree, and mounts in every `NavAppShell` — so it is\n * never an opt-in an app has to remember. Browsers that support Speculation\n * Rules prerender a sibling `*.politogyvrm.com` app the moment the user\n * hovers or pointers-down on its sidebar link (`eagerness: \"moderate\"`);\n * browsers that don't fall back, after the page goes idle, to plain\n * `<link rel=\"prefetch\">` tags for the same URLs, so the next click is still\n * warmed by a DNS/TLS/HTML fetch even without a prerendered document.\n *\n * Each sibling origin must send `Supports-Loading-Mode:\n * credentialed-prerender` on its responses for the prerender to actually\n * happen while the user is authenticated (cross-origin prerender is opt-in\n * on the destination). Without it, browsers degrade this to a normal\n * navigation — the hover/click still works, it's just not pre-warmed.\n *\n * Renders nothing visible; this is a side-effecting `<script>` injector.\n */\nexport function SpeculationRulesScript({ items }: { items: NavItem[] }) {\n const origin = typeof window !== 'undefined' ? window.location.origin : ''\n const rules = useMemo(() => buildNavSpeculationRules(items, origin), [items, origin])\n const json = rules ? JSON.stringify(rules) : null\n\n // Native Speculation Rules — covers the hover/pointerdown prerender case in\n // supporting browsers (Chromium). Declarative: no listeners needed, the\n // browser applies its own \"moderate\" heuristic to matching <a> elements.\n useEffect(() => {\n if (!json || typeof document === 'undefined') return\n let el = document.getElementById(SCRIPT_ID) as HTMLScriptElement | null\n if (!el) {\n el = document.createElement('script')\n el.id = SCRIPT_ID\n el.type = 'speculationrules'\n document.head.appendChild(el)\n }\n el.textContent = json\n return () => {\n // Leave the tag in place across route changes within the same app —\n // only strip it if this effect instance's app unmounts entirely with no\n // sibling to replace it.\n }\n }, [json])\n\n // Idle-prefetch fallback for browsers without Speculation Rules support\n // (or where the destination hasn't sent the opt-in header): warm the\n // connection/document via <link rel=\"prefetch\"> once the main thread is\n // idle, so it never competes with first-paint work.\n useEffect(() => {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const supportsSpecRules =\n typeof HTMLScriptElement !== 'undefined' &&\n typeof (HTMLScriptElement as unknown as { supports?: (t: string) => boolean }).supports ===\n 'function' &&\n (HTMLScriptElement as unknown as { supports: (t: string) => boolean }).supports(\n 'speculationrules',\n )\n if (supportsSpecRules) return\n const urls = collectSiblingAppUrls(items, origin)\n if (urls.length === 0) return\n\n const schedule: (cb: () => void) => void =\n typeof (window as unknown as { requestIdleCallback?: (cb: () => void) => void })\n .requestIdleCallback === 'function'\n ? (window as unknown as { requestIdleCallback: (cb: () => void) => void })\n .requestIdleCallback\n : (cb: () => void) => setTimeout(cb, 2000)\n\n const added: HTMLLinkElement[] = []\n schedule(() => {\n for (const url of urls) {\n if (document.querySelector(`link[${PREFETCH_ATTR}][href=\"${url}\"]`)) continue\n const link = document.createElement('link')\n link.rel = 'prefetch'\n link.href = url\n link.setAttribute(PREFETCH_ATTR, '')\n document.head.appendChild(link)\n added.push(link)\n }\n })\n return () => {\n added.forEach((l) => l.remove())\n }\n }, [items, origin])\n\n return null\n}\n","// Universal theme preference — the ONE cross-app contract.\n//\n// One theme choice (Light / Dark / System) follows the authenticated user\n// across every Politogy app + subdomain. Three layers cooperate:\n// 1. VRM Core `profiles.theme_preference` — source of truth, persisted via\n// the chrome API (`PATCH me/preferences { themePreference }`) and read\n// back from `GET me` (`themePreference`).\n// 2. `.politogyvrm.com` cookie `politogy_theme` — zero-flash pre-paint\n// vehicle that crosses subdomains (auth session cookies are host-only).\n// 3. localStorage `politogy_theme` — offline fallback store.\n//\n// Ported verbatim from contacts/apps/web/src/lib/theme.ts (the origin of the\n// contract) so every app runs the identical behavior from npm. This module is\n// server-safe (no 'use client'): layouts import THEME_PREPAINT_SCRIPT for the\n// pre-paint inline script. The client-side hook lives in ./native\n// (useThemePreference).\n\nexport type ThemePreference = 'light' | 'dark' | 'system'\n\n// Single converged key for BOTH the localStorage store and the\n// cross-subdomain cookie, so a choice in one app is the same key in the next.\nexport const THEME_STORAGE_KEY = 'politogy_theme'\nexport const THEME_COOKIE = 'politogy_theme'\n\n// A local choice that has NOT yet reached VRM Core `profiles.theme_preference`.\n//\n// Politogy ID (auth.politogyvrm.com) has no chrome-API session to PATCH, so a\n// theme picked on the login screen only ever lands in the cookie. Without this\n// marker the next app booted the stale profile value through the reconcile step\n// below and overwrote the user's fresh choice — the \"I set System and it keeps\n// going back to Light\" bug (HITL 2026-07-23). The flag rides the same\n// cross-subdomain cookie so the first app that CAN talk to the chrome API\n// pushes the choice up instead of pulling the stale one down.\nexport const THEME_PENDING_COOKIE = 'politogy_theme_pending'\n\nconst VALID: readonly ThemePreference[] = ['light', 'dark', 'system']\n\nexport function isThemePreference(v: unknown): v is ThemePreference {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v)\n}\n\n/** Read the shared cookie (browser only; null on the server or when unset). */\nexport function readThemeCookie(): ThemePreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${THEME_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isThemePreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n// Set the cross-subdomain cookie. On a *.politogyvrm.com host we scope it to\n// the parent domain so every app subdomain reads it; on any other host\n// (localhost, *.pages.dev preview) we fall back to a host-only cookie so\n// local/preview theming still works without a mismatched Domain attribute\n// (which browsers silently drop). 1-year, SameSite=Lax, Secure on https.\nexport function writeThemeCookie(pref: ThemePreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const onParentDomain = /(^|\\.)politogyvrm\\.com$/i.test(host)\n const domainAttr = onParentDomain ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${THEME_COOKIE}=${encodeURIComponent(\n pref,\n )}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n}\n\n// Write an arbitrary cross-subdomain cookie with the same scoping rules as the\n// theme cookie itself (parent domain on *.politogyvrm.com, host-only elsewhere).\nfunction writeSharedCookie(name: string, value: string, maxAgeSeconds: number): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${name}=${encodeURIComponent(\n value,\n )}; Path=/; Max-Age=${maxAgeSeconds}; SameSite=Lax${domainAttr}${secure}`\n}\n\n/**\n * Mark the current cookie value as a local choice that still has to reach the\n * user's profile. Call this from any surface that changes the theme WITHOUT a\n * chrome-API session (Politogy ID's login screen is the only one today).\n */\nexport function markThemeChoicePending(pref: ThemePreference): void {\n writeSharedCookie(THEME_PENDING_COOKIE, pref, 31536000)\n}\n\n/** The pending (not-yet-persisted) local choice, if any. */\nexport function readPendingThemeChoice(): ThemePreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${THEME_PENDING_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isThemePreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n/** Clear the pending marker once the choice has been written to the profile. */\nexport function clearPendingThemeChoice(): void {\n writeSharedCookie(THEME_PENDING_COOKIE, '', 0)\n}\n\n/** Resolve a preference to the concrete light/dark it renders as right now. */\nexport function resolveTheme(_pref: ThemePreference): 'light' | 'dark' {\n // Light only. Reference/UI-Platform retired Dark Mode (2026-09-21) and\n // Reference/Global-Rules forbids gating colour on prefers-color-scheme, so\n // every stored preference (including a legacy 'dark' or 'system') renders\n // light. The type keeps 'dark' so stored values still parse.\n return 'light'\n}\n\n/**\n * Read the stored preference the way the pre-paint script does — cookie →\n * localStorage → `'system'`. Kept in lockstep with THEME_PREPAINT_SCRIPT so a\n * runtime reader can never disagree with what was applied before paint.\n */\nexport function readStoredThemePreference(): ThemePreference {\n const cookie = readThemeCookie()\n if (cookie) return cookie\n try {\n const stored = window.localStorage.getItem(THEME_STORAGE_KEY)\n if (isThemePreference(stored)) return stored\n } catch {\n /* localStorage may be unavailable (private mode) */\n }\n return 'system'\n}\n\n/**\n * The concrete light/dark the document is rendering as right now.\n *\n * This is the value anything theme-derived must follow — notably Chakra's\n * `colorMode`. Chakra used to be pinned to light while this resolved to dark,\n * which rendered dark chrome tokens over light Chakra content (the \"dark\n * labels on a light page\" desync).\n */\nexport function readResolvedTheme(): 'light' | 'dark' {\n return resolveTheme(readStoredThemePreference())\n}\n\n/** Apply a preference to the document: toggles `.dark` + `data-theme` on\n * `<html>` (both selectors the chrome's dark token block matches) and sets\n * `color-scheme` so native controls follow. */\nexport function applyThemePreference(pref: ThemePreference): void {\n if (typeof document === 'undefined') return\n const resolved = resolveTheme(pref)\n const d = document.documentElement\n d.classList.toggle('dark', resolved === 'dark')\n try {\n d.setAttribute('data-theme', resolved)\n d.style.colorScheme = resolved\n } catch {\n /* non-fatal */\n }\n}\n\n// Inline pre-paint script — render it in <head> (or as the first child of\n// <body>) so the theme applies before first paint. Resolves the preference\n// from cookie → localStorage → OS, applies the `.dark` class + `color-scheme`,\n// and seeds localStorage from the cookie so the app hydrates to the synced\n// value (the cross-subdomain flash fix). Self-contained, dependency-free, and\n// wrapped so any failure is silent (never blocks paint).\nexport const THEME_PREPAINT_SCRIPT = `(function(){try{\nvar KEY=${JSON.stringify(THEME_STORAGE_KEY)};\nvar VALID=[\"light\",\"dark\",\"system\"];\nfunction fromCookie(){try{var m=document.cookie.match(/(?:^|;\\\\s*)${THEME_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}\nvar cookie=fromCookie();\nvar ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}\nvar pref=cookie||ls||\"system\";\nif(VALID.indexOf(pref)===-1)pref=\"system\";\nif(cookie&&cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}\nvar dark=false;\nvar d=document.documentElement;\nif(dark)d.classList.add(\"dark\");else d.classList.remove(\"dark\");\ntry{d.setAttribute(\"data-theme\",dark?\"dark\":\"light\");d.style.colorScheme=dark?\"dark\":\"light\";}catch(e){}\n}catch(e){}})();`\n","// ---------------------------------------------------------------------------\n// Native chrome actions — Tailwind-only top-bar widgets (Fuel, Notifications,\n// Support, Navigation-display) backed by the shared chrome API\n// (politogy-contacts-api on Railway). Zero Chakra, zero router, zero fetch\n// opinion: the consuming app injects ONE fetcher via <NavChromeProvider> —\n// typically a same-origin proxy route that attaches its own session's Bearer\n// token server-side — and every widget in every app runs this exact code.\n//\n// Data endpoints (paths are relative; the app's fetcher owns the base URL):\n// GET communications/fuel-status (header x-contacts-org: <core org id>)\n// GET notifications (header x-contacts-org: <core org id>)\n// GET orgs\n// POST support { message }\n//\n// Loading states follow Global-Rules \"Loading & Async States\": the chrome\n// (button, popover frame, labels) always renders; only the VALUE area shows a\n// skeleton shimmer — never a spinner, never a blank panel.\n// ---------------------------------------------------------------------------\n\n'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type ComponentType,\n type ReactNode,\n} from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useTopBarIconSlotGlyph, type TopBarIconSlot } from '../lib/topbarIconSlot'\nimport { resolveBrandGlyph } from '../lib/brandGlyphs'\nimport {\n applyThemePreference,\n isThemePreference,\n readThemeCookie,\n writeThemeCookie,\n readPendingThemeChoice,\n markThemeChoicePending,\n clearPendingThemeChoice,\n THEME_STORAGE_KEY,\n type ThemePreference as SharedThemePreference,\n} from '../theme-preference'\n\ntype NavIconLike = ComponentType<{ size?: number; className?: string }>\n\n// ---------------------------------------------------------------------------\n// Core-app deep links. The billing surface lives on the VRM-core app; we would\n// derive its origin from POLITOGY_APPS.vrm, but that registry lives in\n// ../app-chrome which imports THIS module — so pulling it in here would create\n// an import cycle. One local constant instead (kept in step with the registry's\n// `vrm` origin).\n// ---------------------------------------------------------------------------\n\nexport const CORE_APP_ORIGIN = 'https://app.politogyvrm.com'\n/** Text/Email fuel top-up page (SMS Signal + Email Broadcast). */\nexport const CORE_BILLING_PATH = '/organization-settings/subscription-billing/text-email'\nconst CORE_BILLING_URL = `${CORE_APP_ORIGIN}${CORE_BILLING_PATH}`\nconst QUARANTINED_CONTACTS_URL = `https://contacts.politogyvrm.com/duplicates`\n\n/** Specs origin — same env-aware-constant pattern as CORE_APP_ORIGIN. */\nexport const SPECS_ORIGIN = 'https://specs.politogyvrm.com'\n\n/**\n * Stamp the active org onto a cross-app link, the same `?org=<uuid>` selector\n * the nav tree and Mode pill use. A bare link into VRM core drops a multi-org\n * user into whatever org core defaults to, which is a different account than\n * the one whose fuel / quarantine counts they just clicked.\n */\nfunction withOrgParam(url: string, orgId: string | null | undefined): string {\n if (!orgId) return url\n return `${url}${url.includes('?') ? '&' : '?'}org=${orgId}`\n}\n\n/** Scope the quarantined-contacts view to one sender. */\nfunction withPhoneParam(url: string, phone: string | null | undefined): string {\n if (!phone) return url\n return `${url}${url.includes('?') ? '&' : '?'}phone=${encodeURIComponent(phone)}`\n}\n\n/**\n * Resolve an organization logo URL for rendering in ANY app.\n *\n * `organizations.logo_url` is authored by VRM core and stored as a ROOT-RELATIVE\n * core route — `/api/storage/public?bucket=organization-logos&path=<org>/logo.png`\n * (the signed-storage proxy). VRM core renders it correctly because that path\n * resolves against its own origin; every other app resolves it against its own\n * origin (forms.politogyvrm.com/api/storage/public), gets a 404, and shows a\n * broken image. The chrome API passes the stored value through verbatim, so the\n * resolution belongs here — one definition for every app, core included.\n *\n * Absolute URLs (http/https/data/blob) pass through untouched.\n */\nexport function resolveOrgLogoUrl(url: string | null | undefined): string | undefined {\n const raw = url?.trim()\n if (!raw) return undefined\n if (/^(?:[a-z][a-z0-9+.-]*:|\\/\\/)/i.test(raw)) return raw\n return `${CORE_APP_ORIGIN}${raw.startsWith('/') ? '' : '/'}${raw}`\n}\n\n// ---------------------------------------------------------------------------\n// Shared 32×32 circular top-bar button chrome — the ONE definition of the\n// top-bar trigger (Global Rules: no slot hand-rolls its own trigger/badge).\n// NavTopBar's structured actionsList buttons use this same builder.\n// ---------------------------------------------------------------------------\n\n/**\n * Glyph size inside every top-bar icon button — Reference/UI-Platform v30:\n * \"34px buttons / 17px glyph / 6px gap\".\n */\nexport const TOPBAR_GLYPH_SIZE = 17\n\nexport function topBarIconButtonClass(tone: 'default' | 'warning' | 'danger' = 'default'): string {\n const toneClass =\n tone === 'danger' || tone === 'warning'\n ? 'text-[color:var(--chrome-danger)] hover:text-[color:var(--chrome-danger)]'\n : 'text-[color:var(--topbar-icon-color,var(--muted))] hover:text-[color:var(--topbar-icon-hover-color,var(--foreground))] hover:bg-[color:var(--topbar-icon-hover-bg,transparent)]'\n return [\n // `group/tbtip` powers the shared <TopBarTooltip> rendered inside the trigger.\n 'group/tbtip relative flex items-center justify-center rounded-[var(--topbar-icon-button-radius,5px)] border border-transparent transition',\n 'h-[var(--topbar-icon-button-size,34px)] w-[var(--topbar-icon-button-size,34px)]',\n toneClass,\n ].join(' ')\n}\n\n/** The shared count badge — one definition, used by every slot. */\n// ---------------------------------------------------------------------------\n// Top-bar panel registry.\n//\n// The top bar hosts two KINDS of surface: panels (opened deliberately by the\n// user from an icon) and transient nudges (the low-fuel hint, the new-reply\n// toast) that appear on their own. They are separate components under separate\n// triggers, so nothing stopped a nudge from covering an open panel — measured\n// in production: the reply toast over the notifications header, and the\n// low-fuel nudge over the same header from the fuel trigger two icons away.\n//\n// A module-scoped counter is enough: any nudge can ask \"is a panel open?\"\n// without the slots having to know about each other.\n// ---------------------------------------------------------------------------\nlet openPanelCount = 0\nconst panelListeners = new Set<() => void>()\nconst emitPanelChange = () => panelListeners.forEach((l) => l())\n\nfunction setPanelOpenGlobal(open: boolean) {\n openPanelCount = Math.max(0, openPanelCount + (open ? 1 : -1))\n emitPanelChange()\n}\n\n/** True while ANY top-bar panel is open. Nudges use it to stay out of the way. */\nexport function useAnyTopBarPanelOpen() {\n return useSyncExternalStore(\n (cb) => {\n panelListeners.add(cb)\n return () => panelListeners.delete(cb)\n },\n () => openPanelCount > 0,\n () => false,\n )\n}\n\nexport function TopBarCountBadge({ count }: { count: number }) {\n if (!(count > 0)) return null\n return (\n <span className=\"absolute -top-[5px] -right-[5px] flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--chrome-danger)] px-1 text-[10px] font-bold leading-4 text-[#FFFFFF]\">\n {count > 99 ? '99+' : count}\n </span>\n )\n}\n\n/**\n * The shared hover tooltip every top-bar control renders BELOW itself: an\n * up-pointing arrow at the icon, a bold title line and a muted description.\n * Pure CSS (group-hover) so it works on <a>, <button> and <summary> triggers.\n * The trigger must carry `group/tbtip relative` (topBarIconButtonClass does).\n */\nexport function TopBarTooltip({\n title,\n description,\n}: {\n title: string\n description?: ReactNode\n}) {\n return (\n <span\n role=\"tooltip\"\n className=\"pointer-events-none absolute left-1/2 top-full z-50 mt-2 hidden w-max max-w-56 -translate-x-1/2 flex-col rounded-lg border border-[color:var(--line)] bg-[color:var(--panel-elevated)] px-3 py-2 text-left shadow-[var(--shadow-soft)] group-hover/tbtip:flex\"\n >\n {/* Arrow pointing up at the icon */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] left-1/2 h-2.5 w-2.5 -translate-x-1/2 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]\"\n />\n <span className=\"text-xs font-semibold text-[color:var(--foreground)]\">{title}</span>\n {description ? (\n <span className=\"mt-0.5 text-[11px] leading-snug text-[color:var(--muted)]\">\n {description}\n </span>\n ) : null}\n </span>\n )\n}\n\n/**\n * The up-pointing arrow every top-bar panel renders, anchored under its\n * trigger icon (panels are right-aligned, so the arrow sits at the trigger's\n * center: 16px in from the panel's right edge). One definition — every menu\n * points at its own icon identically.\n */\nexport function TopBarPanelArrow() {\n return (\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]\"\n />\n )\n}\n\n/**\n * Wrapper for third-party top-bar widgets that ship their own launcher button\n * (e.g. DevNotes). Normalizes the trigger to the universal 32px circular slot\n * (chrome.css `.topbar-widget-slot`) and adds the standard tooltip.\n */\nexport function TopBarWidgetSlot({\n title,\n description,\n children,\n}: {\n title: string\n description?: string\n children: ReactNode\n}) {\n return (\n <span className=\"topbar-widget-slot group/tbtip relative inline-flex\">\n {children}\n <TopBarTooltip title={title} description={description} />\n </span>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Theme control — Light / System / Dark, rendered inside the account menu.\n// Controlled: the app owns persistence (profile + cross-subdomain cookie).\n// ---------------------------------------------------------------------------\n\nexport type ThemePreference = SharedThemePreference\n\nconst THEME_OPTIONS: { value: ThemePreference; label: string }[] = [\n { value: 'light', label: 'Light' },\n]\n\nexport function NavThemeControl({\n value,\n onChange,\n}: {\n value: ThemePreference\n onChange: (next: ThemePreference) => void\n}) {\n return (\n <div className=\"px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Appearance\n </p>\n <div\n role=\"radiogroup\"\n aria-label=\"Appearance\"\n className=\"flex overflow-hidden rounded-full border border-[color:var(--line)]\"\n >\n {THEME_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex-1 px-3 py-1.5 text-xs font-semibold transition',\n value === opt.value\n ? 'bg-[color:var(--color-accent)] text-[#FFFFFF]'\n : 'text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {opt.label}\n </button>\n ))}\n </div>\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Chrome data context — the injected fetcher.\n// ---------------------------------------------------------------------------\n\nexport type NavChromeFetcher = (\n path: string,\n init?: { method?: string; headers?: Record<string, string>; body?: string },\n) => Promise<unknown>\n\n/** GET me — the authenticated user's chrome identity from the shared API.\n * userName prefers the VRM-core profile full name over token claims. */\nexport type ChromeMe = {\n user: string | null\n userName: string | null\n avatarUrl: string | null\n themePreference: string | null\n /** Universal navigation-display choice ('menu'|'tabs'|'both'); null when\n * unset or when the profile column is absent in this environment. */\n navDisplay: string | null\n /** The user's durable active-org preference (full org uuid); null when unset\n * or when the profile column is absent. Adopted only when the request\n * carries no `?org=`/cookie selector — URL → cookie → profile → default. */\n activeOrg?: string | null\n account?: string | null\n accountName?: string | null\n role?: string | null\n /** Contact reply-to, when the profile carries them (optional/tolerant). */\n email?: string | null\n phone?: string | null\n}\n\n/** In-flight-promise + short-TTL cache entry for one (endpoint, orgId) key. */\ntype ChromeFetchCacheEntry = { promise: Promise<unknown>; expiresAt: number }\n\n/** Default freshness window for de-duped chrome reads (orgs/me/notifications/\n * fuel-status). Short enough that a stale value never survives one nav, long\n * enough to collapse every hook mounted on the same page paint into one call. */\nconst CHROME_FETCH_CACHE_TTL_MS = 30_000\n\nfunction chromeCacheKey(path: string, orgId?: string | null): string {\n return orgId === undefined ? path : `${path}::${orgId ?? ''}`\n}\n\n/**\n * A shared read cache scoped to one `<NavChromeProvider>` (one fetcher, one\n * page boot). Every consumer of a given (path, orgId) pair within the TTL\n * window awaits the SAME promise instead of firing its own request — this is\n * what collapsed `/orgs` (2-4x), `/me` (2-3x) and `/notifications` (2-3x) per\n * page load, 1-3.5s each, down to one call apiece (nav-latency-report.md\n * Table 2). Keying by orgId means switching the active org is itself the\n * invalidation: the new org gets a fresh key, never the previous org's cached\n * value. A failed request is evicted immediately so the next consumer retries\n * rather than replaying the same rejection for the rest of the TTL.\n */\nfunction createChromeFetchCache(getFetchJson: () => NavChromeFetcher) {\n const cache = new Map<string, ChromeFetchCacheEntry>()\n\n function dedupedFetch(\n path: string,\n init: Parameters<NavChromeFetcher>[1] | undefined,\n opts: { orgId?: string | null; ttlMs?: number } = {},\n ): Promise<unknown> {\n const key = chromeCacheKey(path, opts.orgId)\n const now = Date.now()\n const hit = cache.get(key)\n if (hit && hit.expiresAt > now) return hit.promise\n // Return the fetcher's own promise (no extra `.catch` hop) so callers see\n // the same microtask depth as a direct fetchJson call; the boot screen's\n // first-tick dismissal (frameBootChrome.test) depends on that.\n const promise = getFetchJson()(path, init)\n promise.catch(() => cache.delete(key))\n cache.set(key, { promise, expiresAt: now + (opts.ttlMs ?? CHROME_FETCH_CACHE_TTL_MS) })\n return promise\n }\n\n /** Force the next read of `path` (any org) to skip the cache. Used after a\n * mutation that changes what an endpoint would return (e.g. marking chrome\n * notifications read server-side, if that ever moves off local storage). */\n function invalidate(path: string) {\n for (const key of cache.keys()) {\n if (key === path || key.startsWith(`${path}::`)) cache.delete(key)\n }\n }\n\n return { dedupedFetch, invalidate }\n}\n\ntype NavChromeContextValue = {\n fetchJson: NavChromeFetcher\n dedupedFetch: ReturnType<typeof createChromeFetchCache>['dedupedFetch']\n invalidateChromeCache: ReturnType<typeof createChromeFetchCache>['invalidate']\n me: ChromeMe | null\n meLoaded: boolean\n}\n\nconst NavChromeContext = createContext<NavChromeContextValue | null>(null)\n\nexport function NavChromeProvider({\n fetchJson,\n children,\n}: {\n fetchJson: NavChromeFetcher\n children: ReactNode\n}) {\n // The cache outlives re-renders but always calls the LATEST fetchJson (the\n // consuming app may pass a new function identity every render).\n const fetchJsonRef = useRef(fetchJson)\n fetchJsonRef.current = fetchJson\n const cacheRef = useRef<ReturnType<typeof createChromeFetchCache> | null>(null)\n if (!cacheRef.current) {\n cacheRef.current = createChromeFetchCache(() => fetchJsonRef.current)\n }\n const { dedupedFetch, invalidate: invalidateChromeCache } = cacheRef.current\n\n // ONE `me` fetch per provider — identity (profile name/avatar) and the\n // theme reconciliation both hang off it.\n const [me, setMe] = useState<ChromeMe | null>(null)\n const [meLoaded, setMeLoaded] = useState(false)\n useEffect(() => {\n let cancelled = false\n dedupedFetch('me', undefined)\n .then((data) => {\n if (!cancelled) setMe(data as ChromeMe)\n })\n .catch(() => {\n /* degraded: session identity stands in */\n })\n .finally(() => {\n if (!cancelled) setMeLoaded(true)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch])\n\n return (\n <NavChromeContext.Provider value={{ fetchJson, dedupedFetch, invalidateChromeCache, me, meLoaded }}>\n {children}\n </NavChromeContext.Provider>\n )\n}\n\n/** The authenticated user's chrome identity (profile name / avatar / theme). */\nexport function useChromeMe(): { me: ChromeMe | null; loaded: boolean } {\n const ctx = useContext(NavChromeContext)\n return { me: ctx?.me ?? null, loaded: ctx?.meLoaded ?? false }\n}\n\n/** The provider's de-duped chrome read (null outside <NavChromeProvider>). */\nexport function useNavChromeDedupedFetch(): NavChromeContextValue['dedupedFetch'] | null {\n return useContext(NavChromeContext)?.dedupedFetch ?? null\n}\n\n/** The injected chrome fetcher (null outside <NavChromeProvider>). */\nexport function useNavChromeFetcher(): NavChromeFetcher | null {\n return useContext(NavChromeContext)?.fetchJson ?? null\n}\n\nfunction useNavChrome(component: string): NavChromeContextValue {\n const ctx = useContext(NavChromeContext)\n if (!ctx) {\n throw new Error(\n `${component} must be rendered inside <NavChromeProvider> (inject the chrome API fetcher there).`,\n )\n }\n return ctx\n}\n\n// ---------------------------------------------------------------------------\n// Data shapes (mirror of politogy-contacts-api responses).\n// ---------------------------------------------------------------------------\n\nexport type FuelChannelStatus = {\n remainingUnits: number\n rawBalanceUnits: number\n usedUnits: number\n lowFuel: boolean\n lowFuelThreshold: number\n}\n\nexport type CommunicationsFuelStatus = {\n organizationId: string\n signal: FuelChannelStatus\n broadcast: FuelChannelStatus\n combinedAvailableCredits: number\n}\n\nexport type ChromeNotificationAlert = {\n id: string\n title: string\n description: string\n href: string | null\n kind: string\n}\n\nexport type ChromeNotificationReply = {\n id: string\n contactId: string | null\n name: string\n preview: string\n /** Optional deep-link to the conversation; the new-reply toast opens it. */\n href?: string\n /**\n * Optional arrival timestamp. Present, it lets the trigger badge count a\n * reply as \"unseen\" only when it is newer than the last time the panel was\n * opened; absent (older payloads), replies simply don't survive the first\n * open as unseen. Tolerated either way.\n */\n createdAt?: string\n}\n\n/** A running or finished contact import surfaced in the notifications panel. */\nexport type ChromeNotificationImport = {\n id: string\n label: string\n /** 0–100 progress, or null when indeterminate (no bar rendered). */\n percent: number | null\n status: 'active' | 'completed'\n href: string | null\n}\n\n/** A cluster of quarantined contacts sharing one phone number. */\nexport type ChromeNotificationQuarantine = {\n phone: string\n count: number\n /** Upstream may omit it; the row already renders conditionally on it. */\n latestAt: string | null\n}\n\nexport type ChromeNotificationsPayload = {\n organizationId: string\n alerts: ChromeNotificationAlert[]\n replies: ChromeNotificationReply[]\n /** Optional — running/finished imports (tolerant when absent). */\n imports?: ChromeNotificationImport[]\n /** Optional — clustered quarantined contacts (tolerant when absent). */\n quarantined?: ChromeNotificationQuarantine[]\n}\n\nexport type ChromeOrgSummary = {\n id: string\n name: string | null\n logoUrl: string | null\n brandColor: string | null\n role: string | null\n /** Un-mapped VRM-core membership role (e.g. \"super_admin\"). */\n rawRole?: string | null\n}\n\n/**\n * Fetch the signed-in user's VRM-core organizations through the injected\n * fetcher. Exposed as a hook so the org switcher in the sidebar and the\n * org-scoped widgets share one request.\n */\nexport function useChromeOrgs({ enabled = true }: { enabled?: boolean } = {}): {\n orgs: ChromeOrgSummary[] | null\n loading: boolean\n error: boolean\n} {\n const { dedupedFetch } = useNavChrome('useChromeOrgs')\n const [orgs, setOrgs] = useState<ChromeOrgSummary[] | null>(null)\n const [loading, setLoading] = useState(enabled)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n // Disabled when the app already holds the org list from its token-backed\n // session (auth-owned active org): no per-request chrome `/api/orgs` call.\n if (!enabled) {\n setLoading(false)\n return\n }\n let cancelled = false\n setLoading(true)\n setError(false)\n dedupedFetch('orgs', undefined)\n .then((data) => {\n if (cancelled) return\n const list = (data as { orgs?: ChromeOrgSummary[] })?.orgs ?? []\n setOrgs(list)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, enabled])\n\n return { orgs, loading, error }\n}\n\n// ---------------------------------------------------------------------------\n// Internal building blocks.\n// ---------------------------------------------------------------------------\n\n/** Value-area skeleton shimmer (chrome/labels stay static per Global Rules). */\nfunction ValueSkeleton({ className }: { className?: string }) {\n return (\n <span\n aria-hidden\n className={[\n 'inline-block animate-pulse rounded bg-[color:var(--panel-elevated)]',\n className ?? 'h-4 w-16',\n ].join(' ')}\n />\n )\n}\n\n/** Slot-driven glyph: Brand-token name when resolvable, fallback otherwise. */\nfunction SlotGlyph({\n slot,\n fallback: Fallback,\n size = TOPBAR_GLYPH_SIZE,\n}: {\n slot?: TopBarIconSlot\n fallback: NavIconLike\n size?: number\n}) {\n const glyphName = useTopBarIconSlotGlyph(slot ?? 'apps')\n const BrandGlyph = slot ? resolveBrandGlyph(glyphName) : null\n const Glyph = BrandGlyph ?? Fallback\n return <Glyph size={size} className=\"text-current\" />\n}\n\n/**\n * A top-bar popover: the shared circular trigger + a right-aligned panel.\n * Closes on outside click / Escape. Purely presentational.\n *\n * EXPORTED so an app with a richer panel than the stock actions can render it\n * inside the SHARED chrome — same 32px trigger, same tooltip, same badge, same\n * panel surface and arrow — instead of hand-rolling a trigger and drifting.\n * This is the enabling step for folding VRM's Fuel breakdown, import-progress,\n * alerts and reply-feed panels into the shared cluster one at a time, without\n * dropping capability (shell-nav-handoff §4; UI-Platform forbids migrating an\n * app to a rendering that loses an element it already ships).\n */\nexport function TopBarPopover({\n label,\n description,\n slot,\n fallbackIcon,\n badge,\n tone,\n onOpen,\n openToken,\n onOpenChange,\n children,\n panelClassName,\n}: {\n label: string\n description?: string\n slot?: TopBarIconSlot\n fallbackIcon: NavIconLike\n badge?: number\n tone?: 'default' | 'warning' | 'danger'\n onOpen?: () => void\n /**\n * Imperative \"open\" signal: whenever this number CHANGES the panel opens\n * (and `onOpen` fires). Lets a sibling — e.g. the notifications toast — open\n * the panel without owning the popover's state. Undefined disables it.\n */\n openToken?: number\n /**\n * Notified on every open/close. A sibling surface anchored to the same\n * trigger (e.g. the notifications toast) must know when the panel is open so\n * the two never render on top of each other — Reference/UI-Platform gives\n * every top-bar panel ONE surface anchored to its trigger, so a second\n * surface at the same anchor always occludes it.\n */\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n panelClassName?: string\n}) {\n const [open, setOpen] = useState(false)\n const onOpenChangeRef = useRef(onOpenChange)\n onOpenChangeRef.current = onOpenChange\n useEffect(() => {\n onOpenChangeRef.current?.(open)\n if (!open) return\n setPanelOpenGlobal(true)\n return () => setPanelOpenGlobal(false)\n }, [open])\n const rootRef = useRef<HTMLDivElement | null>(null)\n const lastOpenTokenRef = useRef(openToken)\n\n // React to external open signals (skips the initial value on mount).\n useEffect(() => {\n if (openToken === undefined) return\n if (openToken === lastOpenTokenRef.current) return\n lastOpenTokenRef.current = openToken\n setOpen((v) => {\n if (!v) onOpen?.()\n return true\n })\n }, [openToken, onOpen])\n\n useEffect(() => {\n if (!open) return\n const onDocClick = (e: MouseEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false)\n }\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false)\n }\n document.addEventListener('mousedown', onDocClick)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onDocClick)\n document.removeEventListener('keydown', onKey)\n }\n }, [open])\n\n return (\n <div ref={rootRef} className=\"relative\">\n <button\n type=\"button\"\n aria-label={label}\n aria-expanded={open}\n className={topBarIconButtonClass(tone)}\n onClick={() => {\n setOpen((v) => {\n const next = !v\n if (next) onOpen?.()\n return next\n })\n }}\n >\n <SlotGlyph slot={slot} fallback={fallbackIcon} />\n {typeof badge === 'number' ? <TopBarCountBadge count={badge} /> : null}\n {!open ? <TopBarTooltip title={label} description={description} /> : null}\n </button>\n {open ? (\n <div\n className={[\n 'absolute right-0 z-40 mt-2 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]',\n panelClassName ?? 'w-80',\n ].join(' ')}\n >\n <TopBarPanelArrow />\n <div className=\"overflow-hidden rounded-xl\">{children}</div>\n </div>\n ) : null}\n </div>\n )\n}\n\n// Inline fallback glyphs (Feather-style paths) so the package needs no icon dep.\nfunction BatteryGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"1\" y=\"6\" width=\"18\" height=\"12\" rx=\"2\" ry=\"2\" />\n <line x1=\"23\" y1=\"10\" x2=\"23\" y2=\"14\" />\n <line x1=\"5\" y1=\"10\" x2=\"5\" y2=\"14\" />\n <line x1=\"9\" y1=\"10\" x2=\"9\" y2=\"14\" />\n </svg>\n )\n}\n\nfunction BellGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9\" />\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n </svg>\n )\n}\n\nfunction BellOffGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n <path d=\"M18.63 13A17.9 17.9 0 0 1 18 8\" />\n <path d=\"M6.26 6.26A5.86 5.86 0 0 0 6 8c0 7-3 9-3 9h14\" />\n <path d=\"M18 8a6 6 0 0 0-9.33-5\" />\n <line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\" />\n </svg>\n )\n}\n\nfunction LifeBuoyGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <line x1=\"4.93\" y1=\"4.93\" x2=\"9.17\" y2=\"9.17\" />\n <line x1=\"14.83\" y1=\"14.83\" x2=\"19.07\" y2=\"19.07\" />\n <line x1=\"14.83\" y1=\"9.17\" x2=\"19.07\" y2=\"4.93\" />\n <line x1=\"4.93\" y1=\"19.07\" x2=\"9.17\" y2=\"14.83\" />\n </svg>\n )\n}\n\nfunction LayoutGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\" />\n <line x1=\"3\" y1=\"9\" x2=\"21\" y2=\"9\" />\n <line x1=\"9\" y1=\"21\" x2=\"9\" y2=\"9\" />\n </svg>\n )\n}\n\nfunction PlusGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n )\n}\n\nfunction XGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\nfunction CheckGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// FuelAction — Communications Fuel balance (battery glyph + popover meters).\n// ---------------------------------------------------------------------------\n\nconst LOW_FUEL_HINT_DISMISSED_KEY = 'politogy_low_fuel_hint_dismissed'\n\nfunction FuelRow({\n label,\n channel,\n loading,\n addHref,\n addLabel,\n}: {\n label: string\n channel: FuelChannelStatus | null\n loading: boolean\n /** Billing deep-link for the small \"+\" top-up button (omit to hide it). */\n addHref?: string\n addLabel?: string\n}) {\n const remaining = channel?.remainingUnits ?? 0\n const total = channel ? Math.max(channel.rawBalanceUnits, channel.remainingUnits) : 0\n const ratio = total > 0 ? Math.min(100, Math.max(0, (remaining / total) * 100)) : 0\n const low = channel?.lowFuel ?? false\n\n return (\n <div className=\"w-full\">\n <div className=\"mb-1 flex items-center justify-between gap-2\">\n <span className=\"text-xs font-semibold text-[color:var(--foreground)]\">{label}</span>\n <div className=\"flex items-center gap-2\">\n {loading ? (\n <ValueSkeleton className=\"h-3.5 w-14\" />\n ) : (\n <span\n className={[\n 'text-xs font-semibold tabular-nums',\n low ? 'text-[color:var(--chrome-danger)]' : 'text-[color:var(--muted)]',\n ].join(' ')}\n >\n {remaining.toLocaleString()} left\n </span>\n )}\n {addHref ? (\n <a\n href={addHref}\n aria-label={addLabel}\n className=\"flex h-5 w-5 items-center justify-center rounded-full border border-[color:var(--line)] text-[color:var(--muted)] transition hover:border-[color:var(--foreground)] hover:text-[color:var(--foreground)]\"\n >\n <PlusGlyph />\n </a>\n ) : null}\n </div>\n </div>\n <div className=\"h-1.5 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n {loading ? (\n <div className=\"h-full w-full animate-pulse bg-[color:var(--line)]\" />\n ) : (\n <div\n className={[\n 'h-full rounded-full transition-[width]',\n low ? 'bg-[color:var(--chrome-danger)]' : 'bg-[color:var(--color-ok,#00A651)]',\n ].join(' ')}\n style={{ width: `${ratio}%` }}\n />\n )}\n </div>\n </div>\n )\n}\n\n/**\n * The low-fuel nudge: a small bubble anchored below the fuel trigger (arrow up)\n * with a \"Buy More Fuel\" deep-link. Dismissible; the dismissal persists for the\n * session (sessionStorage) so it never re-appears until a fresh session — and\n * the flag clears once fuel is no longer low, so a later drain can nudge again.\n */\nfunction LowFuelHint({ lowFuel, orgId }: { lowFuel: boolean; orgId: string | null }) {\n const [dismissed, setDismissed] = useState<boolean>(() => {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(LOW_FUEL_HINT_DISMISSED_KEY) === '1'\n } catch {\n return false\n }\n })\n\n useEffect(() => {\n if (lowFuel) return\n try {\n window.sessionStorage.removeItem(LOW_FUEL_HINT_DISMISSED_KEY)\n } catch {\n /* unavailable */\n }\n }, [lowFuel])\n\n // Yield to any open panel: the nudge is wider than its own trigger and the\n // panels are right-aligned, so it lands on top of whichever one is open\n // (measured on contacts: it covered the notifications panel's header).\n const panelOpen = useAnyTopBarPanelOpen()\n\n if (!lowFuel || dismissed || panelOpen) return null\n\n const dismiss = () => {\n try {\n window.sessionStorage.setItem(LOW_FUEL_HINT_DISMISSED_KEY, '1')\n } catch {\n /* unavailable */\n }\n setDismissed(true)\n }\n\n return (\n <div\n role=\"status\"\n className=\"absolute right-0 top-[calc(100%+10px)] z-50 w-60 rounded-lg border border-[color:var(--chrome-danger)] bg-[color:var(--chrome-danger)] px-3 py-2 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n onClick={(e) => e.stopPropagation()}\n >\n {/* Arrow pointing up at the fuel button (mirrors TopBarPanelArrow's offset). */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 bg-[color:var(--chrome-danger)]\"\n />\n <div className=\"flex items-start gap-2\">\n <div className=\"flex-1\">\n <p className=\"text-sm font-semibold\">You’re low on fuel</p>\n <a\n href={withOrgParam(CORE_BILLING_URL, orgId)}\n className=\"mt-1 inline-block text-sm font-bold underline hover:opacity-90\"\n >\n Buy More Fuel\n </a>\n </div>\n <button\n type=\"button\"\n aria-label=\"Dismiss low fuel notice\"\n onClick={dismiss}\n className=\"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[#FFFFFF]/90 transition hover:bg-[#FFFFFF]/20\"\n >\n <XGlyph />\n </button>\n </div>\n </div>\n )\n}\n\nexport function FuelAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch } = useNavChrome('FuelAction')\n const [fuel, setFuel] = useState<CommunicationsFuelStatus | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n setLoading(true)\n setError(false)\n setFuel(null)\n dedupedFetch(\n 'communications/fuel-status',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (cancelled) return\n setFuel((data as { fuel?: CommunicationsFuelStatus | null })?.fuel ?? null)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, orgId])\n\n const low = !!fuel && (fuel.signal.lowFuel || fuel.broadcast.lowFuel)\n\n return (\n // The nudge anchors to the trigger, so it sits OUTSIDE the popover panel in\n // its own relative wrapper (same shape the VRM widget used).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Communications Fuel\"\n description=\"Remaining SMS and email sending balance for the active organization.\"\n slot=\"comms-fuel\"\n fallbackIcon={BatteryGlyph}\n tone={low ? 'warning' : 'default'}\n >\n <div className=\"px-4 py-3\">\n <p className=\"mb-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Communications Fuel\n </p>\n {error || (!loading && !fuel) ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Fuel balance is unavailable right now.\n </p>\n ) : (\n <div className=\"flex flex-col gap-3\">\n <FuelRow\n label=\"SMS Signal\"\n channel={fuel?.signal ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add SMS Signal fuel\"\n />\n <FuelRow\n label=\"Email Broadcast\"\n channel={fuel?.broadcast ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add Email Broadcast fuel\"\n />\n </div>\n )}\n </div>\n </TopBarPopover>\n <LowFuelHint lowFuel={low} orgId={orgId} />\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NotificationsAction — bell + count badge + alerts/replies popover.\n// ---------------------------------------------------------------------------\n\n/** Per-org read/seen state, persisted client-side (localStorage). */\ntype NotifState = {\n readAlertIds: string[]\n lastSeenAt: string | null\n /** Reply ids already surfaced as a toast, so none re-toasts (capped ~50). */\n toastedReplyIds: string[]\n}\n\nfunction notifStateKey(orgId: string | null): string {\n return `politogy_chrome_notif_state:${orgId ?? 'none'}`\n}\n\nfunction readNotifState(orgId: string | null): NotifState {\n const empty: NotifState = { readAlertIds: [], lastSeenAt: null, toastedReplyIds: [] }\n if (typeof window === 'undefined') return empty\n try {\n const raw = window.localStorage.getItem(notifStateKey(orgId))\n if (!raw) return empty\n const parsed = JSON.parse(raw) as Partial<NotifState>\n return {\n readAlertIds: Array.isArray(parsed?.readAlertIds)\n ? parsed.readAlertIds.filter((id): id is string => typeof id === 'string')\n : [],\n lastSeenAt: typeof parsed?.lastSeenAt === 'string' ? parsed.lastSeenAt : null,\n toastedReplyIds: Array.isArray(parsed?.toastedReplyIds)\n ? parsed.toastedReplyIds.filter((id): id is string => typeof id === 'string')\n : [],\n }\n } catch {\n return empty\n }\n}\n\nfunction writeNotifState(orgId: string | null, state: NotifState): void {\n if (typeof window === 'undefined') return\n try {\n window.localStorage.setItem(notifStateKey(orgId), JSON.stringify(state))\n } catch {\n /* unavailable */\n }\n}\n\n/**\n * Session-scoped mute for the rotating new-reply toasts. Session (not local)\n * storage on purpose: silencing is a \"not right now\" gesture, so a reload\n * restores the toasts rather than silently disabling them forever.\n */\nconst TOASTS_MUTED_KEY = 'politogy_chrome_toasts_muted'\n\nfunction readToastsMuted(): boolean {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(TOASTS_MUTED_KEY) === '1'\n } catch {\n return false\n }\n}\n\nfunction writeToastsMuted(muted: boolean): void {\n if (typeof window === 'undefined') return\n try {\n if (muted) window.sessionStorage.setItem(TOASTS_MUTED_KEY, '1')\n else window.sessionStorage.removeItem(TOASTS_MUTED_KEY)\n } catch {\n /* unavailable */\n }\n}\n\n/** Format a raw phone into US (XXX) XXX-XXXX; leave anything else as-is. */\nfunction formatPhone(raw: string): string {\n const digits = raw.replace(/\\D/g, '')\n const ten = digits.length === 11 && digits.startsWith('1') ? digits.slice(1) : digits\n if (ten.length === 10) return `(${ten.slice(0, 3)}) ${ten.slice(3, 6)}-${ten.slice(6)}`\n return raw\n}\n\nfunction ImportRow({ imp }: { imp: ChromeNotificationImport }) {\n const pct = imp.percent == null ? null : Math.max(0, Math.min(100, imp.percent))\n return (\n <>\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate text-sm text-[color:var(--foreground)]\">{imp.label}</span>\n {pct != null ? (\n <span className=\"shrink-0 text-xs tabular-nums text-[color:var(--muted)]\">\n {Math.round(pct)}%\n </span>\n ) : null}\n </div>\n {pct != null ? (\n <div className=\"mt-1 h-1 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n <div\n className=\"h-full rounded-full bg-[color:var(--color-accent)] transition-[width]\"\n style={{ width: `${pct}%` }}\n />\n </div>\n ) : null}\n </>\n )\n}\n\n/**\n * Transient \"new reply\" toast anchored below the bell. Dark bubble with an\n * up-arrow, sender + preview; auto-fades after ~12s; clicking activates it.\n * Mirrors VRM's NewTextBellPopup. Purely presentational — the parent owns which\n * reply shows and what a click does.\n */\nfunction NewReplyToast({\n reply,\n onActivate,\n onClose,\n onSilence,\n ttlMs = 12000,\n}: {\n reply: ChromeNotificationReply\n onActivate: () => void\n onClose: () => void\n onSilence: () => void\n ttlMs?: number\n}) {\n const [visible, setVisible] = useState(false)\n const onCloseRef = useRef(onClose)\n onCloseRef.current = onClose\n\n useEffect(() => {\n setVisible(true)\n const fadeAt = Math.max(0, ttlMs - 450)\n const t1 = window.setTimeout(() => setVisible(false), fadeAt)\n const t2 = window.setTimeout(() => onCloseRef.current(), ttlMs)\n return () => {\n window.clearTimeout(t1)\n window.clearTimeout(t2)\n }\n }, [ttlMs])\n\n const activate = () => {\n setVisible(false)\n onActivate()\n }\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n aria-label=\"Open new reply\"\n onClick={activate}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n activate()\n }\n }}\n className=\"absolute right-[-6px] top-[calc(100%+12px)] z-50 min-w-[240px] max-w-[320px] cursor-pointer rounded-xl bg-[#161616] px-4 py-3 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n style={{\n opacity: visible ? 1 : 0,\n transform: visible ? 'translateY(0px)' : 'translateY(-4px)',\n transition: 'opacity 250ms ease, transform 250ms ease',\n }}\n >\n {/* Up-arrow pointing at the bell. */}\n <span\n aria-hidden\n className=\"absolute right-[18px] top-[-7px] h-0 w-0 border-x-[8px] border-x-transparent border-b-[8px] border-b-[#161616]\"\n />\n {/* Dismiss this ONE toast without navigating. The bubble itself is the\n activate target, so the close control has to stop propagation or\n \"get rid of it\" would mean \"open it\" (reported 2026-08-12). */}\n <button\n type=\"button\"\n aria-label=\"Dismiss notification\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onClose()\n }}\n className=\"absolute right-2 top-2 flex h-5 w-5 items-center justify-center rounded-full text-[#FFFFFF] opacity-60 transition hover:bg-[#FFFFFF]/10 hover:opacity-100\"\n >\n <XGlyph size={12} />\n </button>\n <p className=\"truncate pr-6 text-sm font-semibold\">{reply.name}</p>\n <p className=\"mt-1 truncate text-xs opacity-85\">{reply.preview}</p>\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onSilence()\n }}\n className=\"mt-2 inline-flex items-center gap-1 text-[11px] font-semibold text-[#FFFFFF] opacity-60 transition hover:opacity-100\"\n >\n <BellOffGlyph size={12} />\n Silence notifications\n </button>\n </div>\n )\n}\n\nexport function NotificationsAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch } = useNavChrome('NotificationsAction')\n const [payload, setPayload] = useState<ChromeNotificationsPayload | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n const [notif, setNotif] = useState<NotifState>(() => readNotifState(orgId))\n const [toastReply, setToastReply] = useState<ChromeNotificationReply | null>(null)\n const [toastsMuted, setToastsMuted] = useState<boolean>(() => readToastsMuted())\n const [openToken, setOpenToken] = useState(0)\n const [panelOpen, setPanelOpen] = useState(false)\n // Also yield to a panel opened from a NEIGHBOURING trigger — the fuel panel\n // is right-aligned and wide enough to sit under the bell.\n const anyPanelOpen = useAnyTopBarPanelOpen()\n\n // Re-hydrate the read/seen watermark whenever the active org changes.\n useEffect(() => {\n setNotif(readNotifState(orgId))\n setToastReply(null)\n }, [orgId])\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n setLoading(true)\n setError(false)\n setPayload(null)\n dedupedFetch(\n 'notifications',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (!cancelled) setPayload(data as ChromeNotificationsPayload)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, orgId])\n\n // 10DLC registration alert: surfaced only in the notifications panel/badge\n // (unread state). No auto-redirect — see Decisions in PR for feat/spec-overlay.\n\n const markRead = useCallback(\n (id: string) => {\n setNotif((prev) => {\n if (prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: [...prev.readAlertIds, id] }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId],\n )\n\n const markUnread = useCallback(\n (id: string) => {\n setNotif((prev) => {\n if (!prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: prev.readAlertIds.filter((x) => x !== id) }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId],\n )\n\n // Opening the panel advances the \"last seen\" watermark (replies are seen).\n const onOpen = useCallback(() => {\n // The panel shows the reply the toast was previewing, so the toast has\n // nothing left to say — retire it rather than let it cover the panel.\n setToastReply(null)\n setNotif((prev) => {\n const next = { ...prev, lastSeenAt: new Date().toISOString() }\n writeNotifState(orgId, next)\n return next\n })\n }, [orgId])\n\n const alerts = payload?.alerts ?? []\n const replies = payload?.replies ?? []\n const imports = payload?.imports ?? []\n const quarantined = payload?.quarantined ?? []\n\n // New-reply toast: surface the newest reply that is (a) newer than the seen\n // watermark and (b) not already toasted this org. One at a time; the id is\n // recorded so a re-render / re-fetch never re-toasts it (capped at 50).\n useEffect(() => {\n // Silenced for this session — surface nothing new (the badge still counts).\n if (toastsMuted) return\n if (!payload || toastReply || panelOpen) return\n const candidate = replies\n .filter((r) => {\n if (!r.createdAt) return false\n if (notif.lastSeenAt && r.createdAt <= notif.lastSeenAt) return false\n return !notif.toastedReplyIds.includes(r.id)\n })\n .sort((a, b) => (a.createdAt! < b.createdAt! ? 1 : -1))[0]\n if (!candidate) return\n setToastReply(candidate)\n setNotif((prev) => {\n const next = {\n ...prev,\n toastedReplyIds: [candidate.id, ...prev.toastedReplyIds].slice(0, 50),\n }\n writeNotifState(orgId, next)\n return next\n })\n }, [\n payload,\n replies,\n toastReply,\n panelOpen,\n toastsMuted,\n notif.lastSeenAt,\n notif.toastedReplyIds,\n orgId,\n ])\n\n // Toast click: navigate to the reply's href when it carries one; otherwise\n // open the notifications panel (which also advances the seen watermark).\n const setMuted = useCallback((muted: boolean) => {\n writeToastsMuted(muted)\n setToastsMuted(muted)\n }, [])\n\n const onToastSilence = useCallback(() => {\n setMuted(true)\n setToastReply(null)\n }, [setMuted])\n\n const onToastActivate = useCallback(() => {\n const href = toastReply?.href\n setToastReply(null)\n if (href && typeof window !== 'undefined') {\n window.location.assign(href)\n return\n }\n setOpenToken((t) => t + 1)\n }, [toastReply])\n\n // Badge: UNREAD alerts + replies newer than the last-seen watermark. A reply\n // with no timestamp counts before the first open, then is treated as seen.\n const unreadAlertCount = alerts.filter((a) => !notif.readAlertIds.includes(a.id)).length\n const unseenReplyCount = replies.filter((r) => {\n if (!notif.lastSeenAt) return true\n if (!r.createdAt) return false\n return r.createdAt > notif.lastSeenAt\n }).length\n const badgeCount = unreadAlertCount + unseenReplyCount\n\n const isEmpty =\n alerts.length === 0 && replies.length === 0 && imports.length === 0 && quarantined.length === 0\n\n return (\n // Relative wrapper so the new-reply toast anchors to the bell trigger,\n // outside the popover panel (same pattern as the fuel low-fuel nudge).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Alerts & Notifications\"\n description=\"System alerts and recent activity for the active organization.\"\n slot=\"notifications\"\n fallbackIcon={BellGlyph}\n badge={loading ? 0 : badgeCount}\n onOpen={onOpen}\n openToken={openToken}\n onOpenChange={setPanelOpen}\n >\n <div className=\"px-4 py-3\">\n <div className=\"mb-2 flex items-center justify-between gap-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Notifications\n </p>\n {/* Only shown once silenced — the way back, in the same session. */}\n {toastsMuted ? (\n <button\n type=\"button\"\n onClick={() => setMuted(false)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n Unsilence\n </button>\n ) : null}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-2 py-1\">\n <ValueSkeleton className=\"h-4 w-full\" />\n <ValueSkeleton className=\"h-4 w-3/4\" />\n </div>\n ) : error ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Notifications are unavailable right now.\n </p>\n ) : isEmpty ? (\n <p className=\"py-1 text-sm text-[color:var(--muted)]\">You’re all caught up.</p>\n ) : (\n <div className=\"flex max-h-80 flex-col gap-2 overflow-y-auto\">\n {/* Alerts (with per-item read toggle) + replies — unchanged order. */}\n {alerts.length > 0 || replies.length > 0 ? (\n <ul className=\"flex flex-col gap-1\">\n {alerts.map((a) => {\n const isRead = notif.readAlertIds.includes(a.id)\n return (\n <li key={a.id} className={isRead ? 'opacity-50' : undefined}>\n <div className=\"flex items-start gap-1 rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n <a\n href={a.href ?? '#'}\n onClick={() => markRead(a.id)}\n className=\"block min-w-0 flex-1\"\n >\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {a.title}\n </p>\n <p className=\"text-xs text-[color:var(--muted)]\">{a.description}</p>\n </a>\n <button\n type=\"button\"\n aria-label={isRead ? 'Mark as unread' : 'Mark as read'}\n onClick={() => (isRead ? markUnread(a.id) : markRead(a.id))}\n className=\"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[color:var(--muted)] transition hover:bg-[color:var(--panel-elevated)] hover:text-[color:var(--foreground)]\"\n >\n <CheckGlyph />\n </button>\n </div>\n </li>\n )\n })}\n {/* A reply row is a REAL link when it carries a deep-link, so\n the hover highlight leads somewhere: the conversation the\n reply arrived in (reported 2026-08-12). Rows without an\n href stay inert rather than pretending to be clickable. */}\n {replies.map((r) => {\n const body = (\n <>\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {r.name}\n </p>\n <p className=\"truncate text-xs text-[color:var(--muted)]\">{r.preview}</p>\n </>\n )\n return (\n <li key={r.id}>\n {r.href ? (\n <a\n href={r.href}\n aria-label={`Open the conversation with ${r.name}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--panel)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n {body}\n </a>\n ) : (\n <div className=\"rounded-lg px-2 py-2\">{body}</div>\n )}\n </li>\n )\n })}\n </ul>\n ) : null}\n\n {/* Imports — running/finished contact imports. */}\n {imports.length > 0 ? (\n <div>\n <p className=\"mb-1 px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Imports\n </p>\n <ul className=\"flex flex-col gap-1\">\n {imports.map((imp) => (\n <li key={imp.id} className=\"rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n {imp.href ? (\n <a href={imp.href} className=\"block\">\n <ImportRow imp={imp} />\n </a>\n ) : (\n <ImportRow imp={imp} />\n )}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {/* Quarantined contact clusters. */}\n {quarantined.length > 0 ? (\n <div>\n <div className=\"mb-1 flex items-center justify-between px-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Quarantined Contacts\n </p>\n <a\n href={withOrgParam(QUARANTINED_CONTACTS_URL, orgId)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n View all\n </a>\n </div>\n <ul className=\"flex flex-col gap-1\">\n {/* Each row is a REAL link, not a div with a hover class. It\n used to carry a hover highlight on a non-interactive <li>,\n so the row advertised interactivity and then did nothing\n when clicked (reported 2026-08-03). An affordance has to\n lead somewhere: the row opens the quarantined-contacts\n view filtered to that number — the same destination as\n \"View all\", scoped. Being an <a> makes it keyboard\n focusable and Enter-activatable for free. */}\n {quarantined.map((q) => (\n <li key={q.phone}>\n <a\n href={withPhoneParam(withOrgParam(QUARANTINED_CONTACTS_URL, orgId), q.phone)}\n aria-label={`Review ${q.count} quarantined message${q.count === 1 ? '' : 's'} from ${formatPhone(q.phone)}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--nav-row-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {formatPhone(q.phone)}\n </span>\n {/* Same geometry as the shared TopBarCountBadge (16px\n circle, 10px/400, px-1); it sits in flow rather\n than absolutely on a 32px trigger, because this is\n a list row and not a top-bar icon. */}\n <span className=\"flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--panel)] px-1 text-[10px] font-normal leading-none tabular-nums text-[color:var(--muted)]\">\n {q.count > 99 ? '99+' : q.count}\n </span>\n </div>\n {q.latestAt ? (\n <p className=\"text-xs text-[color:var(--muted)]\">\n {new Date(q.latestAt).toLocaleString()}\n </p>\n ) : null}\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n </div>\n )}\n </div>\n </TopBarPopover>\n {/* Only ONE surface at this anchor at a time: the toast yields to the panel\n (both hang off the bell trigger, so rendering both means the toast sits\n on the panel's header — Reference/UI-Platform, one surface per trigger). */}\n {toastReply && !panelOpen && !anyPanelOpen ? (\n <NewReplyToast\n reply={toastReply}\n onActivate={onToastActivate}\n onClose={() => setToastReply(null)}\n onSilence={onToastSilence}\n />\n ) : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SupportAction — life-buoy trigger + the shared support-request modal\n// (never a mailto:, never an app-local form — Reference/UI-Platform).\n// ---------------------------------------------------------------------------\n\n/**\n * Compose the delivered support message: the user's note, then a context block\n * carrying the page, URL and active org — plus a Reply-to line when the user\n * had to supply contact details the profile was missing. The upstream contract\n * stays `POST support { message }`; this just enriches the text (VRM parity).\n */\nfunction composeSupportMessage(input: {\n note: string\n pageTitle: string\n url: string\n orgName?: string | null\n replyEmail?: string\n replyPhone?: string\n}): string {\n const ctx = [`Page: ${input.pageTitle || 'Unknown'}`, `URL: ${input.url}`]\n if (input.orgName) ctx.push(`Org: ${input.orgName}`)\n const reply = [input.replyEmail?.trim(), input.replyPhone?.trim()].filter(Boolean).join(' / ')\n if (reply) ctx.push(`Reply-to: ${reply}`)\n return `${input.note.trim()}\\n\\n---\\n${ctx.join('\\n')}`\n}\n\nexport function SupportAction({\n orgId,\n orgs: knownOrgs,\n}: { orgId?: string | null; orgs?: { id: string; name: string | null }[] } = {}) {\n const { fetchJson } = useNavChrome('SupportAction')\n const { me, loaded } = useChromeMe()\n // A caller that already holds the org list skips the chrome `/api/orgs` call.\n const { orgs: fetchedOrgs } = useChromeOrgs({ enabled: !knownOrgs })\n const orgs = knownOrgs ?? fetchedOrgs\n const [open, setOpen] = useState(false)\n const [message, setMessage] = useState('')\n const [email, setEmail] = useState('')\n const [phone, setPhone] = useState('')\n const [showEmailError, setShowEmailError] = useState(false)\n const [state, setState] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle')\n\n // The profile knows email/phone unless the chrome `me` loaded without them —\n // then we collect the missing one(s) in the modal (email required, phone not).\n const meEmail = me?.email ?? null\n const mePhone = me?.phone ?? null\n const missingEmail = loaded && !meEmail\n const missingPhone = loaded && !mePhone\n\n const activeOrg =\n (orgId ? orgs?.find((o) => o.id === orgId) : null) ??\n (orgs && orgs.length === 1 ? orgs[0] : null)\n const orgName = activeOrg?.name ?? null\n\n const close = useCallback(() => {\n setOpen(false)\n setState('idle')\n setMessage('')\n setShowEmailError(false)\n }, [])\n\n // Seed the contact inputs from the profile whenever the modal opens.\n useEffect(() => {\n if (!open) return\n setEmail(meEmail ?? '')\n setPhone(mePhone ?? '')\n setShowEmailError(false)\n }, [open, meEmail, mePhone])\n\n useEffect(() => {\n if (!open) return\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') close()\n }\n document.addEventListener('keydown', onKey)\n return () => document.removeEventListener('keydown', onKey)\n }, [open, close])\n\n const submit = async () => {\n if (!message.trim() || state === 'sending') return\n\n const resolvedEmail = (missingEmail ? email : meEmail ?? '').trim()\n const resolvedPhone = (missingPhone ? phone : mePhone ?? '').trim()\n // Email is required when the profile didn't carry one.\n if (missingEmail && !resolvedEmail) {\n setShowEmailError(true)\n return\n }\n setShowEmailError(false)\n\n const collectedContact = missingEmail || missingPhone\n const fullMessage = composeSupportMessage({\n note: message,\n pageTitle: typeof document !== 'undefined' ? document.title : '',\n url: typeof window !== 'undefined' ? window.location.href : '',\n orgName,\n replyEmail: collectedContact ? resolvedEmail : undefined,\n replyPhone: collectedContact ? resolvedPhone : undefined,\n })\n\n setState('sending')\n try {\n await fetchJson('support', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ message: fullMessage }),\n })\n setState('sent')\n } catch {\n setState('error')\n }\n }\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Support\"\n className={topBarIconButtonClass()}\n onClick={() => setOpen(true)}\n >\n <SlotGlyph slot=\"support\" fallback={LifeBuoyGlyph} />\n <TopBarTooltip\n title=\"Support\"\n description=\"Send a support request to the Politogy team.\"\n />\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n // Portaled to <body>: the top bar's backdrop-blur creates a CSS\n // containing block, so a fixed-position descendant would center on\n // the HEADER (rendering off-screen) instead of the viewport.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Support request\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) close()\n }}\n >\n <div className=\"w-full max-w-md rounded-2xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-6 shadow-[var(--shadow-soft)]\">\n <h2 className=\"text-lg font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Contact Support\n </h2>\n {state === 'sent' ? (\n <>\n <p className=\"mt-3 text-sm text-[color:var(--muted)]\">\n Your request was sent. The team will reply by email.\n </p>\n <div className=\"mt-5 flex justify-end\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full bg-[color:var(--color-accent)] px-4 py-2 text-sm font-semibold text-[#FFFFFF] hover:opacity-90\"\n >\n Done\n </button>\n </div>\n </>\n ) : (\n <>\n <p className=\"mt-1 text-sm text-[color:var(--muted)]\">\n Describe the problem or question. Your account details ride along\n automatically.\n </p>\n {missingEmail ? (\n <label className=\"mt-4 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your email\n </span>\n <input\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder=\"you@example.com\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {showEmailError ? (\n <span className=\"mt-1 block text-xs text-[color:var(--chrome-danger)]\">\n Enter an email so support can reply.\n </span>\n ) : null}\n </label>\n ) : null}\n {missingPhone ? (\n <label className=\"mt-3 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your phone — optional\n </span>\n <input\n type=\"tel\"\n value={phone}\n onChange={(e) => setPhone(e.target.value)}\n placeholder=\"(503) 555-1212\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n </label>\n ) : null}\n <textarea\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n rows={5}\n placeholder=\"How can we help?\"\n className=\"mt-4 w-full resize-y rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {state === 'error' ? (\n <p className=\"mt-2 text-sm text-[color:var(--chrome-danger)]\">\n Sending failed — try again.\n </p>\n ) : null}\n <div className=\"mt-4 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full border border-[color:var(--line)] px-4 py-2 text-sm font-semibold text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={submit}\n disabled={!message.trim() || state === 'sending'}\n className=\"rounded-full bg-[color:var(--color-accent)] px-4 py-2 text-sm font-semibold text-[#FFFFFF] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {state === 'sending' ? 'Sending…' : 'Send request'}\n </button>\n </div>\n </>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SpecOverlayAction — Spencer + Ben only. A top-bar \"Spec\" trigger showing\n// the current page's spec compliance / visual-regression status, from the\n// Specs app's overlay API. Renders NOTHING when the viewer isn't allowed —\n// no icon, no badge, no console noise — so this is invisible to every other\n// user. All calls are plain cross-origin fetches with same-site cookies\n// (credentials: 'include'); this does NOT go through the chrome proxy\n// fetchJson, which is same-origin only.\n// ---------------------------------------------------------------------------\n\ntype SpecOverlayAccess = { allowed: boolean; email?: string }\n\ntype SpecOverlayStatus =\n | {\n matched: true\n spec_slug: string\n spec_title: string\n target_id: string\n label: string\n viewport: string\n /** null when there is no finished compare run yet — never coerce to 0. */\n mismatch_pct: number | null\n finished_at: string | null\n passed: boolean | null\n spec_url: string\n compare_url: string\n overlay_url: string\n live_selector?: string | null\n capture_url?: string\n theme?: 'light' | 'dark' | null\n live_source?: 'worker' | 'viewer' | null\n live_size?: { width: number; height: number } | null\n design_size?: { width: number; height: number } | null\n /** Ready-to-paste repair prompt for an AI agent (latest run). */\n prompt?: string | null\n }\n | { matched: false; search_url: string }\n\nconst SPEC_OVERLAY_ACCESS_CACHE_KEY = 'politogy_spec_overlay_access'\n\nfunction readSpecOverlayAccessCache(): SpecOverlayAccess | null {\n if (typeof window === 'undefined') return null\n try {\n const raw = window.sessionStorage.getItem(SPEC_OVERLAY_ACCESS_CACHE_KEY)\n if (!raw) return null\n const parsed = JSON.parse(raw)\n if (typeof parsed?.allowed === 'boolean') return parsed as SpecOverlayAccess\n } catch {\n /* ignore */\n }\n return null\n}\n\nfunction writeSpecOverlayAccessCache(access: SpecOverlayAccess): void {\n if (typeof window === 'undefined') return\n try {\n window.sessionStorage.setItem(SPEC_OVERLAY_ACCESS_CACHE_KEY, JSON.stringify(access))\n } catch {\n /* ignore */\n }\n}\n\n/**\n * Notifies subscribers whenever the URL changes via pushState, replaceState\n * or a back/forward navigation. Patches `history` exactly once per page\n * (module-level guard) no matter how many components subscribe.\n */\ntype LocationChangeListener = () => void\nconst locationChangeListeners = new Set<LocationChangeListener>()\nlet historyPatched = false\n\nfunction ensureHistoryPatched(): void {\n if (historyPatched || typeof window === 'undefined') return\n historyPatched = true\n const notify = () => locationChangeListeners.forEach((fn) => fn())\n const originalPushState = window.history.pushState.bind(window.history)\n const originalReplaceState = window.history.replaceState.bind(window.history)\n window.history.pushState = (...args: Parameters<History['pushState']>) => {\n originalPushState(...args)\n notify()\n }\n window.history.replaceState = (...args: Parameters<History['replaceState']>) => {\n originalReplaceState(...args)\n notify()\n }\n window.addEventListener('popstate', notify)\n}\n\nfunction useLocationHref(): string {\n const [href, setHref] = useState(() =>\n typeof window === 'undefined' ? '' : window.location.href,\n )\n useEffect(() => {\n ensureHistoryPatched()\n const onChange = () => setHref(window.location.href)\n locationChangeListeners.add(onChange)\n return () => {\n locationChangeListeners.delete(onChange)\n }\n }, [])\n return href\n}\n\nfunction specOverlayFetchJson(path: string): Promise<unknown> {\n // Bounded: this hits a cross-origin app (specs.politogyvrm.com) from every\n // page's top bar. An unbounded call here let a stuck access/status check\n // keep the page's network alive indefinitely — which blocks `networkidle`\n // and tripped visual-regression captures' own 45s navigation timeout on\n // the very pages this widget instruments (seen on a2p 2026-10-02).\n return fetch(`${SPECS_ORIGIN}${path}`, { credentials: 'include', signal: AbortSignal.timeout(10_000) }).then((res) => {\n if (!res.ok) throw new Error(`spec overlay ${path}: ${res.status}`)\n return res.json()\n })\n}\n\n/**\n * True when this page is being driven by an automated capture session\n * (Cloudflare Browser Rendering / CDP-controlled Chromium — the Specs\n * design-compare tool, among others) rather than a real Spencer/Ben\n * session. `navigator.webdriver` is the standard CDP automation flag.\n * SpecOverlayAction must never self-trigger a capture loop in this case:\n * doing so competed with the very capture session rendering the page for\n * network activity, keeping `networkidle` from ever being reached.\n */\nfunction isAutomatedCaptureSession(): boolean {\n return typeof navigator !== 'undefined' && navigator.webdriver === true\n}\n\nfunction currentChromeTheme(): 'light' | 'dark' {\n const root = document.documentElement\n if (root.classList.contains('dark') || root.getAttribute('data-theme') === 'dark') return 'dark'\n if (root.classList.contains('light') || root.getAttribute('data-theme') === 'light') return 'light'\n return 'light'\n}\n\n/** Marks the drawer portal so the page raster leaves it out. */\nconst SPEC_OVERLAY_ROOT_ATTR = 'data-spec-overlay-root'\n\n/**\n * The viewer's real view: rasterize THIS page in the browser (DOM → canvas,\n * no permission prompt) at viewport size, without the Spec drawer, and send it\n * to Specs as the LIVE side of a compare. Their org, data and theme are\n * exactly what is on screen, cropped to the content region. Nothing but the PNG\n * and page facts leaves the browser.\n */\nasync function captureMyView(\n status: Extract<SpecOverlayStatus, { matched: true }>,\n orgId: string | null | undefined,\n orgName: string | null | undefined,\n): Promise<void> {\n const { domToCanvas } = await import('modern-screenshot')\n const w = window.innerWidth\n const h = window.innerHeight\n const theme = currentChromeTheme()\n const bg = getComputedStyle(document.body).backgroundColor || (theme === 'dark' ? '#0b0b0c' : '#ffffff')\n const full = await domToCanvas(document.body, {\n width: w,\n height: h,\n scale: 1,\n backgroundColor: bg,\n // Cross-origin images that refuse CORS render blank instead of failing.\n fetch: { requestInit: { mode: 'cors', credentials: 'omit' }, placeholderImage: '' },\n // Drop the Spec drawer and everything fixed (sidebar, toasts, popovers):\n // the design is the page body only, so chrome would only add noise.\n filter: (node) =>\n !(node instanceof Element) ||\n (!node.hasAttribute(SPEC_OVERLAY_ROOT_ATTR) && getComputedStyle(node).position !== 'fixed'),\n style: { transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)` },\n })\n\n // Score the content region only — the target's live_selector, else the\n // shell's content column (below the top bar and beta banner, right of the\n // sidebar) — so LIVE covers the same region as the design export.\n const el =\n (status.live_selector ? document.querySelector(status.live_selector) : null) ??\n document.querySelector('[data-shell-content]')\n let region = { x: 0, y: 0, width: w, height: h }\n if (el) {\n const r = el.getBoundingClientRect()\n const x = Math.max(0, Math.round(r.left))\n const y = Math.max(0, Math.round(r.top))\n region = { x, y, width: Math.min(w - x, Math.round(r.width)), height: Math.min(h - y, Math.round(r.height)) }\n }\n const out = document.createElement('canvas')\n out.width = region.width\n out.height = region.height\n const ctx = out.getContext('2d')\n if (!ctx) throw new Error('page raster failed')\n ctx.drawImage(full, region.x, region.y, region.width, region.height, 0, 0, region.width, region.height)\n const blob = await new Promise<Blob | null>((resolve) => out.toBlob(resolve, 'image/png'))\n if (!blob) throw new Error('page raster failed')\n const form = new FormData()\n form.append('image', blob, 'live.png')\n form.append(\n 'meta',\n JSON.stringify({ url: window.location.href, theme, org_id: orgId ?? null, org_name: orgName ?? null, crop: null }),\n )\n const res = await fetch(status.capture_url ?? `${SPECS_ORIGIN}/api/overlay/capture`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'X-Spec-Capture': '1' },\n body: form,\n signal: AbortSignal.timeout(10_000),\n })\n if (!res.ok) throw new Error(`capture ${res.status}: ${(await res.text()).slice(0, 160)}`)\n}\n\n/** Spinner + LIVE/DIFF skeletons shown while the capture and compare run. */\nexport function SpecCaptureLoading() {\n return (\n <div data-spec-capture-loading=\"\" role=\"status\" aria-live=\"polite\" className=\"flex-1 overflow-hidden px-4 py-4\">\n <div className=\"mb-4 flex items-center gap-3 text-sm text-[color:var(--foreground)]\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block h-5 w-5 animate-spin rounded-full border-2 border-[color:var(--line)] border-t-[color:var(--color-accent)] motion-reduce:animate-none\"\n />\n Capturing your view and comparing…\n </div>\n {['Live — your view', 'Diff'].map((label) => (\n <div key={label} className=\"mb-4\">\n <p className=\"mb-1 text-xs font-semibold uppercase tracking-wide text-[color:var(--muted)]\">{label}</p>\n <div aria-hidden=\"true\" className=\"h-40 w-full animate-pulse rounded border border-[color:var(--line)] bg-[color:var(--panel)] motion-reduce:animate-none\" />\n </div>\n ))}\n </div>\n )\n}\n\n/** Status URL for this page in the viewer's current theme. */\nfunction specOverlayStatusPath(): string {\n return `/api/overlay/status?url=${encodeURIComponent(window.location.href)}&theme=${currentChromeTheme()}`\n}\n\nexport function SpecOverlayAction({ orgId, orgName }: { orgId?: string | null; orgName?: string | null } = {}) {\n const [access, setAccess] = useState<SpecOverlayAccess | null>(() => readSpecOverlayAccessCache())\n const [status, setStatus] = useState<SpecOverlayStatus | null>(null)\n const [open, setOpen] = useState(false)\n const [capture, setCapture] = useState<{ state: 'idle' | 'busy' | 'error'; message?: string }>({ state: 'idle' })\n const [frameKey, setFrameKey] = useState(0)\n const [copied, setCopied] = useState<'idle' | 'copied' | 'failed'>('idle')\n const href = useLocationHref()\n const automated = isAutomatedCaptureSession()\n\n // Resolve access once per session (cached in sessionStorage).\n useEffect(() => {\n if (access || automated) return\n let cancelled = false\n specOverlayFetchJson('/api/overlay/access')\n .then((data) => {\n if (cancelled) return\n const next: SpecOverlayAccess =\n data && typeof (data as SpecOverlayAccess).allowed === 'boolean'\n ? (data as SpecOverlayAccess)\n : { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n .catch(() => {\n if (cancelled) return\n const next: SpecOverlayAccess = { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n return () => {\n cancelled = true\n }\n }, [access])\n\n // Fetch status for the current page, debounced 300ms, on every route\n // change and org change. Only once access is known to be allowed.\n useEffect(() => {\n if (automated || !access?.allowed || typeof window === 'undefined') return\n const timer = window.setTimeout(() => {\n specOverlayFetchJson(specOverlayStatusPath())\n .then((data) => setStatus(data as SpecOverlayStatus))\n .catch(() => setStatus(null))\n }, 300)\n return () => window.clearTimeout(timer)\n }, [access?.allowed, href, orgId])\n\n // Opening the drawer captures the viewer's real view automatically — no\n // click, no prompt. The raster runs while the drawer is open; the drawer is\n // filtered out of the frame. One capture per open.\n const captureRun = useRef(0)\n // Live-read access inside the retry loop below: access can be revoked\n // mid-poll (session expiry, org switch), and the loop must stop hitting\n // /api/overlay/status the moment that happens rather than riding out its\n // full 45 × 3s budget regardless.\n const accessRef = useRef(access)\n accessRef.current = access\n const runCapture = async (s: Extract<SpecOverlayStatus, { matched: true }>) => {\n const run = ++captureRun.current\n const before = s.live_source === 'viewer' ? s.finished_at : null\n setCapture({ state: 'busy' })\n try {\n // Let the drawer paint first so the page is idle while we raster.\n await new Promise((r) => setTimeout(r, 150))\n await captureMyView(s, orgId, orgName)\n for (let i = 0; i < 45; i++) {\n await new Promise((r) => setTimeout(r, 3000))\n if (run !== captureRun.current) return\n // Access lost mid-poll: stop, but never leave the spinner up forever.\n if (!accessRef.current?.allowed) {\n setCapture({ state: 'idle' })\n return\n }\n const next = (await specOverlayFetchJson(specOverlayStatusPath()).catch(() => null)) as SpecOverlayStatus | null\n if (next && next.matched && next.live_source === 'viewer' && next.finished_at !== before) {\n setStatus(next)\n setFrameKey((k) => k + 1)\n setCapture({ state: 'idle' })\n return\n }\n }\n setCapture({ state: 'error', message: 'Compare did not finish in 2 min.' })\n } catch (e) {\n if (run === captureRun.current) setCapture({ state: 'error', message: e instanceof Error ? e.message : String(e) })\n }\n }\n useEffect(() => {\n if (automated || !open || !status || !status.matched) return\n void runCapture(status)\n return () => {\n captureRun.current++\n }\n // Only re-run on open / page change, not on every status refresh.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, status && status.matched ? status.target_id : null])\n\n\n if (automated || !access?.allowed) return null\n\n const hasScore = status && status.matched && typeof status.mismatch_pct === 'number'\n const badgeLabel =\n hasScore ? `${Math.round((status as Extract<SpecOverlayStatus, { matched: true }>).mismatch_pct as number)}%` : status ? '—' : undefined\n const badgeTone: 'default' | 'warning' | 'danger' =\n hasScore ? (status && status.matched && status.passed ? 'default' : 'danger') : 'default'\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Spec\"\n aria-expanded={open}\n className={topBarIconButtonClass(badgeTone)}\n onClick={() => setOpen(true)}\n >\n <LayoutGlyph size={TOPBAR_GLYPH_SIZE} className=\"text-current\" />\n {badgeLabel ? (\n <span\n className={[\n 'absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-normal leading-none text-[#FFFFFF]',\n hasScore\n ? status && status.matched && status.passed\n ? 'bg-[color:var(--chrome-success,#2f855a)]'\n : 'bg-[color:var(--chrome-danger)]'\n : 'bg-[color:var(--muted)]',\n ].join(' ')}\n >\n {badgeLabel}\n </span>\n ) : null}\n {!open ? (\n <TopBarTooltip\n title=\"Spec\"\n description=\"Spec design + visual regression for this page.\"\n />\n ) : null}\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n className=\"fixed inset-0 z-50 flex justify-end bg-black/40\"\n {...{ [SPEC_OVERLAY_ROOT_ATTR]: '' }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Spec overlay\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) setOpen(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') setOpen(false)\n }}\n >\n <div className=\"flex h-full w-full max-w-[480px] flex-col border-l border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]\">\n <div className=\"flex items-center justify-between gap-2 border-b border-[color:var(--line)] px-4 py-3\">\n <h2 className=\"truncate text-sm font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Spec{status && status.matched ? `: ${status.spec_title}` : ''}\n </h2>\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={() => setOpen(false)}\n className=\"rounded-full p-1 text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]\"\n >\n <CloseGlyph size={16} />\n </button>\n </div>\n {status && status.matched ? (\n <>\n <div className=\"flex items-center gap-3 border-b border-[color:var(--line)] px-4 py-2 text-xs font-semibold\">\n <a\n href={status.spec_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent)] hover:underline\"\n >\n Open spec ↗\n </a>\n <a\n href={status.compare_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent)] hover:underline\"\n >\n Compare tab ↗\n </a>\n <button\n type=\"button\"\n disabled={capture.state === 'busy'}\n onClick={() => void runCapture(status)}\n className=\"ml-auto rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Your view is captured when the drawer opens. Recapture after changing the page.\"\n >\n {capture.state === 'busy' ? 'Capturing…' : 'Recapture'}\n </button>\n <button\n type=\"button\"\n data-spec-copy-prompt=\"\"\n disabled={capture.state === 'busy' || !status.prompt}\n onClick={() => {\n const text = status.prompt\n if (!text) return\n // The prompt is already in hand, so the write stays inside the click gesture.\n navigator.clipboard\n .writeText(text)\n .then(() => setCopied('copied'))\n .catch(() => setCopied('failed'))\n .finally(() => window.setTimeout(() => setCopied('idle'), 2000))\n }}\n className=\"rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Copy a repair prompt for an AI agent: spec, score, image links, top mismatched regions and instructions.\"\n >\n {copied === 'copied' ? 'Copied ✓' : copied === 'failed' ? 'Copy failed' : 'Copy prompt'}\n </button>\n </div>\n {status.live_size && status.design_size && capture.state !== 'busy' ? (\n <p\n data-spec-sizes=\"\"\n className={[\n 'border-b border-[color:var(--line)] px-4 py-1.5 text-xs',\n status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? 'text-[color:var(--muted)]'\n : 'font-semibold text-[color:var(--chrome-danger)]',\n ].join(' ')}\n >\n Live {status.live_size.width}×{status.live_size.height} · Design {status.design_size.width}×\n {status.design_size.height}\n {status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? ' · sizes match'\n : ' · SIZE MISMATCH'}\n </p>\n ) : null}\n {capture.state === 'error' ? (\n <p className=\"border-b border-[color:var(--line)] px-4 py-2 text-xs text-[color:var(--chrome-danger)]\">\n {capture.message}\n </p>\n ) : null}\n {capture.state === 'busy' ? (\n <SpecCaptureLoading />\n ) : (\n <iframe\n key={frameKey}\n src={status.overlay_url}\n title=\"Spec overlay\"\n className=\"h-full w-full flex-1 border-0\"\n />\n )}\n </>\n ) : status && !status.matched ? (\n <div className=\"p-4 text-sm text-[color:var(--muted)]\">\n <p>No compare target covers this page.</p>\n <a\n href={status.search_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"mt-2 inline-block font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n Search specs ↗\n </a>\n </div>\n ) : (\n <div className=\"p-4\">\n <ValueSkeleton className=\"h-4 w-full\" />\n </div>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\nfunction CloseGlyph({ size = 16, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NavDisplayAction — the Menu / Tabs / Both navigation-display switcher.\n// Controlled: the app owns persistence (localStorage/profile) and layout\n// consequences (sub-menu visibility, tab strip visibility).\n// ---------------------------------------------------------------------------\n\nexport type NavDisplayMode = 'menu' | 'tabs' | 'both'\n\nexport const NAV_DISPLAY_OPTIONS: { value: NavDisplayMode; label: string }[] = [\n { value: 'menu', label: 'Sub Menu' },\n { value: 'tabs', label: 'Tabs Only' },\n { value: 'both', label: 'Both' },\n]\n\nexport function NavDisplayAction({\n value,\n onChange,\n}: {\n value: NavDisplayMode\n onChange: (next: NavDisplayMode) => void\n}) {\n return (\n <TopBarPopover\n label=\"Navigation Display\"\n description=\"Show navigation as a sub-menu, tabs, or both.\"\n fallbackIcon={LayoutGlyph}\n panelClassName=\"w-44\"\n >\n <div className=\"py-1\" role=\"radiogroup\" aria-label=\"Navigation display\">\n {NAV_DISPLAY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex w-full items-center justify-between px-4 py-2 text-left text-sm font-medium',\n value === opt.value\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n {opt.label}\n {value === opt.value ? <span aria-hidden>✓</span> : null}\n </button>\n ))}\n </div>\n </TopBarPopover>\n )\n}\n\n// ---------------------------------------------------------------------------\n// useThemePreference — the cross-app theme state machine (Task: theme derived\n// from the Auth system, live across tabs and apps).\n//\n// boot : cookie → localStorage → \"system\" (the pre-paint script already\n// painted this), then ONCE per session reconcile against the\n// profile value from `GET me` (authoritative) when a fetcher is\n// available.\n// change : apply + localStorage + cross-subdomain cookie + best-effort\n// `PATCH me/preferences { themePreference }`.\n// sync : same-app tabs via the `storage` event; other-app tabs re-read the\n// shared cookie on focus/visibility; `system` follows live OS\n// changes via matchMedia.\n// ---------------------------------------------------------------------------\n\nexport function useThemePreference(): {\n value: ThemePreference\n setValue: (next: ThemePreference) => void\n} {\n const ctx = useContext(NavChromeContext)\n const fetchJson = ctx?.fetchJson ?? null\n const [value, setValueState] = useState<ThemePreference>('system')\n const reconciled = useRef(false)\n\n // Boot: cookie → localStorage → system.\n useEffect(() => {\n const cookie = readThemeCookie()\n let ls: string | null = null\n try {\n ls = localStorage.getItem(THEME_STORAGE_KEY)\n } catch {\n /* unavailable */\n }\n const pref = cookie ?? (isThemePreference(ls) ? ls : null) ?? 'system'\n setValueState(pref)\n applyThemePreference(pref)\n }, [])\n\n // Once per session: converge on the profile's saved choice (authoritative),\n // reusing the provider's single `me` fetch.\n const meCtx = useContext(NavChromeContext)\n useEffect(() => {\n if (reconciled.current) return\n // A choice made where no chrome-API session exists (Politogy ID's login\n // screen) is still only in the cookie. Push it UP rather than pulling the\n // stale profile value DOWN — otherwise the user's fresh pick is silently\n // reverted on the next app they open (HITL 2026-07-23: \"I set System and it\n // keeps switching back to Light\").\n const pending = readPendingThemeChoice()\n if (pending) {\n // Only latch once the profile write has actually been attempted, so a\n // later `me` arrival still gets a chance to persist it.\n if (meCtx?.me) reconciled.current = true\n setValueState(pending)\n applyThemePreference(pending)\n writeThemeCookie(pending)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pending)\n } catch {\n /* unavailable */\n }\n if (!meCtx?.me) return\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: pending }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n return\n }\n const pref = meCtx?.me?.themePreference\n if (isThemePreference(pref)) {\n reconciled.current = true\n setValueState(pref)\n applyThemePreference(pref)\n writeThemeCookie(pref)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pref)\n } catch {\n /* unavailable */\n }\n }\n }, [meCtx?.me])\n\n // Live sync: storage events (same-app tabs), focus/visibility cookie\n // re-reads (other-app tabs), and OS changes while on \"system\".\n useEffect(() => {\n const onStorage = (e: StorageEvent) => {\n if (e.key === THEME_STORAGE_KEY && isThemePreference(e.newValue)) {\n setValueState(e.newValue)\n applyThemePreference(e.newValue)\n }\n }\n const onWake = () => {\n const cookie = readThemeCookie()\n if (cookie) {\n setValueState((prev) => {\n if (cookie !== prev) applyThemePreference(cookie)\n return cookie\n })\n }\n }\n window.addEventListener('storage', onStorage)\n window.addEventListener('focus', onWake)\n document.addEventListener('visibilitychange', onWake)\n return () => {\n window.removeEventListener('storage', onStorage)\n window.removeEventListener('focus', onWake)\n document.removeEventListener('visibilitychange', onWake)\n }\n }, [])\n\n\n const setValue = useCallback(\n (next: ThemePreference) => {\n setValueState(next)\n applyThemePreference(next)\n writeThemeCookie(next)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, next)\n } catch {\n /* unavailable */\n }\n // Best-effort profile persistence — a theme toggle never errors. Until it\n // lands, the choice stays marked pending so the next app pushes it up\n // instead of reconciling the stale profile value back down.\n markThemeChoicePending(next)\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: next }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n },\n [fetchJson],\n )\n\n return { value, setValue }\n}\n","import type { ReactNode } from 'react';\nimport clsx from 'clsx';\n\ntype FormColumnProps = {\n children: ReactNode;\n className?: string;\n};\n\n/**\n * The ONE constrained layout inside the frame's fluid `<main>` (Brand guideline\n * \"Content width is fluid\"): a single left-aligned column, 960px max, for form\n * and settings pages — single-record edit forms, Organization Settings tabs,\n * My Profile, activation and setup flows. Data surfaces (tables, dashboards,\n * maps) never use it; they take the full fluid width.\n *\n * It adds no gutter of its own — `<main>` already owns the 24px / 16px gutter —\n * and it is never centered. There is no width prop on purpose: a per-page\n * max-width is exactly what the guideline forbids.\n */\nexport default function FormColumn({ children, className }: FormColumnProps) {\n return (\n <div data-shell-form-column=\"\" className={clsx('w-full max-w-[960px]', className)}>\n {children}\n </div>\n );\n}\n","import type { NavIcon } from './index'\nimport type { StandardNavIconKey } from './standardNav'\nimport {\n LuActivity,\n LuBriefcase,\n LuChartColumn,\n LuChartNoAxesColumn,\n LuCircleUser,\n LuClipboardList,\n LuClock,\n LuCreditCard,\n LuCrosshair,\n LuDollarSign,\n LuDoorOpen,\n LuFileText,\n LuFlag,\n LuHouse,\n LuLandmark,\n LuLayoutDashboard,\n LuLayoutGrid,\n LuLifeBuoy,\n LuList,\n LuMail,\n LuMap,\n LuMapPin,\n LuMessageSquare,\n LuMousePointerClick,\n LuPencil,\n LuPhone,\n LuSend,\n LuSettings,\n LuShare2,\n LuSignpost,\n LuTarget,\n LuUpload,\n LuUser,\n LuUsers,\n LuUsersRound,\n} from 'react-icons/lu'\n\n/**\n * The canonical icon map for standardPolitogyNav — ONE definition so every\n * app renders identical glyphs (including the Organization Settings branch:\n * briefcase / settings / creditCard / dollarSign / share).\n */\nexport const standardNavIcons: Record<StandardNavIconKey, NavIcon> = {\n home: LuHouse,\n users: LuUsers,\n mail: LuMail,\n messageSquare: LuMessageSquare,\n layout: LuLayoutDashboard,\n activity: LuActivity,\n lifeBuoy: LuLifeBuoy,\n grid: LuLayoutGrid,\n list: LuList,\n upload: LuUpload,\n edit: LuPencil,\n fileText: LuFileText,\n send: LuSend,\n clock: LuClock,\n user: LuUser,\n barChart: LuChartColumn,\n briefcase: LuBriefcase,\n settings: LuSettings,\n creditCard: LuCreditCard,\n dollarSign: LuDollarSign,\n share: LuShare2,\n // Campaign / Petition mode slots.\n phone: LuPhone,\n map: LuMap,\n mapPin: LuMapPin,\n target: LuTarget,\n flag: LuFlag,\n layoutDashboard: LuLayoutDashboard,\n usersRound: LuUsersRound,\n mousePointerClick: LuMousePointerClick,\n clipboardList: LuClipboardList,\n circleUser: LuCircleUser,\n crosshair: LuCrosshair,\n landmark: LuLandmark,\n chartNoAxes: LuChartNoAxesColumn,\n doorOpen: LuDoorOpen,\n signpost: LuSignpost,\n}\n","import { standardNavIcons } from './standardNavIcons'\nimport type { NavIcon, NavItem } from './index'\n\n// ---------------------------------------------------------------------------\n// standardPolitogyNav — the canonical Politogy VRM menu, per operating Mode.\n//\n// This is the single source of truth for the navigation every politogy app\n// renders. The RELATIONSHIP tree is extracted verbatim from VRM core's\n// relationship-mode sidebar (`getRelationshipLinkItems`); the CAMPAIGN and\n// PETITION trees mirror VRM core's mode-scoped menus. Apps consume the same\n// menu everywhere; an app that owns one of the items (e.g. the standalone\n// Contacts app) nests its own pages as that item's children while every other\n// entry links out to another *.politogyvrm.com app as an absolute URL —\n// full-page navigation with SSO shared across the domain.\n//\n// Which tree an app renders is NOT the user's live mode selection — it is the\n// app's own mode, mapped from the app registry (see `POLITOGY_APPS[app].mode`),\n// EXCEPT for a DUAL-MODE app (`POLITOGY_APPS[app].dual`, today: a2p — Specs/A2P:\n// \"the SMS/MMS delivery engine for Relationship Mode and Campaign Mode\"). A\n// dual app has no single fixed mode: its EFFECTIVE mode is resolved per-visit\n// by `resolveActiveMode` (mode-preference.ts) — `?mode=` query param on the\n// current URL → the `politogy_active_mode` cookie (written by every pinned app\n// and core whenever their own mode is known) → the app's own `dual.defaultMode`\n// — and THAT resolved value substitutes for `meta.mode` wherever this function\n// or the Mode pill would otherwise read it. A campaign-scoped, non-dual app\n// (phonebank / canvass / signs) always renders the Campaign tree; an unscoped\n// app (forms / surveys / polls / contacts) always renders Relationship, exactly\n// as before. Switching modes is a full-page navigation between mode homes (the\n// Mode pill's job), and each destination is itself pinned (or, for a2p,\n// resolved) — so the tree is deterministic from app identity + the mode\n// resolution above, never a value an app has to pass.\n// ---------------------------------------------------------------------------\n\n/**\n * Icon slots used by the standard menus. The shell stays icon-library-agnostic:\n * callers map each key to their own icon components (lucide, react-icons, …).\n * A missing key simply renders that row without an icon.\n */\nexport type StandardNavIconKey =\n | 'home'\n | 'users'\n | 'mail'\n | 'messageSquare'\n | 'layout'\n | 'activity'\n | 'lifeBuoy'\n | 'grid'\n | 'list'\n | 'upload'\n | 'edit'\n | 'fileText'\n | 'send'\n | 'clock'\n | 'user'\n | 'barChart'\n | 'briefcase'\n | 'settings'\n | 'creditCard'\n | 'dollarSign'\n | 'share'\n // Campaign / Petition mode slots.\n | 'phone'\n | 'map'\n | 'mapPin'\n | 'target'\n | 'flag'\n // Left-Navigation §9 Lucide slots.\n | 'layoutDashboard'\n | 'usersRound'\n | 'mousePointerClick'\n | 'clipboardList'\n | 'circleUser'\n | 'crosshair'\n | 'landmark'\n | 'chartNoAxes'\n | 'doorOpen'\n | 'signpost'\n\n/** The operating Mode whose nav tree to build. Defaults to `relationship`. */\nexport type StandardNavMode = 'relationship' | 'campaign' | 'petition'\n\n/**\n * Per-feature availability for the Campaign tree. Campaign Mode ships its apps\n * incrementally: a disabled feature is omitted from the nav entirely (rather\n * than rendered as a dead/disabled row), and its flag flips to `true` in a\n * later patch release as the app goes live. Dashboard and Voter Contact are\n * core-hosted and always present, so they carry no flag.\n */\nexport interface CampaignFeatureAvailability {\n a2p: boolean\n phonebank: boolean\n canvass: boolean\n signs: boolean\n tribes: boolean\n polling: boolean\n}\n\n/**\n * Launch state at this shell version: every Campaign feature is deployed and\n * live (a2p / phonebank / canvass / signs .politogyvrm.com all serve the app\n * behind SSO as of 2026-07-24), so no row is hidden. The flags remain so a\n * future feature can ship dark, and so a caller can hide one per-deployment.\n */\nexport const CAMPAIGN_FEATURE_AVAILABILITY: CampaignFeatureAvailability = {\n a2p: true,\n phonebank: true,\n canvass: true,\n signs: true,\n tribes: true,\n polling: true,\n}\n\n/** Absolute origins for the standalone Campaign / Petition apps. */\nconst A2P_ORIGIN = 'https://a2p.politogyvrm.com/'\nconst PHONEBANK_ORIGIN = 'https://phonebank.politogyvrm.com/'\nconst CANVASS_ORIGIN = 'https://canvass.politogyvrm.com/'\nconst SIGNS_ORIGIN = 'https://signs.politogyvrm.com/'\nconst POLLS_ORIGIN = 'https://polls.politogyvrm.com/'\n// app.politogyvrm.com (VRM core) is retired (Reference/UI-Platform →\n// \"Retirement of app.politogyvrm.com\", DECIDED 2026-10-07). These are its V2\n// replacements: Settings owns org settings/billing, Dashboard owns the\n// Relationship/Campaign dashboards and Battleground, auth owns the Politogy\n// ID account pages (my-profile, invite acceptance).\nconst SETTINGS_ORIGIN = 'https://settings.politogyvrm.com/'\nconst DASHBOARD_ORIGIN = 'https://dashboard.politogyvrm.com/'\nconst AUTH_ORIGIN = 'https://auth.politogyvrm.com/'\n// Tribes is a page inside the standalone Contacts app (Specs/Tribes: Tribes is\n// implemented as an extension of Contacts). Matches app-shell.tsx's `/tribes`.\nconst CONTACTS_TRIBES = 'https://contacts.politogyvrm.com/tribes'\n// Petition Mode is its own standalone app on its own subdomain (the petitions\n// repo deploys production to petition-mode.politogyvrm.com).\nconst PETITION_MODE_ORIGIN = 'https://petition-mode.politogyvrm.com/'\n\nexport interface StandardNavOptions {\n /**\n * @deprecated app.politogyvrm.com (VRM core) is retired (Reference/UI-Platform\n * → \"Retirement of app.politogyvrm.com\"). Every row this tree used to resolve\n * against VRM core now points at its V2 host directly, so this is unused.\n * Kept only so existing callers don't need to drop the field immediately.\n */\n coreBaseUrl?: string\n /** Icon component per slot; omitted slots render icon-less rows. */\n icons?: Partial<Record<StandardNavIconKey, NavIcon>>\n /**\n * App-local override for the \"Contacts\" item. `children` are used verbatim\n * (NOT absolutized) so the owning app nests its own routes; `href` (also\n * verbatim) feeds active-detection for the group header. When omitted, the\n * item carries VRM core's own contacts sub-pages as absolute links.\n * (Relationship tree only.)\n */\n contactsItem?: {\n href?: string\n children?: NavItem[]\n /**\n * Live contact count shown right-aligned on the Contacts row, already\n * formatted for display (\"31.9K\"). Only the owning app knows it.\n * (Specs/Contacts design: `Contacts · 31.9K`.)\n */\n count?: string | number | null\n }\n /**\n * Top-level rows to OMIT, by label (case-insensitive), e.g. `['Polls','CTAs']`.\n * The Specs/Contacts design rail lists Relationship → Collect → Account with\n * exactly Dashboard · Contacts · Email broadcast · SMS/MMS blast / Calls to\n * action · Forms · Surveys / My profile · Organization settings; apps that\n * still surface Polls / CTAs keep them by default. A section row with no\n * remaining items is dropped too.\n */\n hiddenItems?: string[]\n /**\n * App-local override for the Petition-mode \"Dashboard\" entry, same contract\n * as `contactsItem`: `href`/`children` used verbatim so the Petitions app\n * nests its own routes under the entry. (Petition tree only.)\n */\n petitionsItem?: { href?: string; children?: NavItem[] }\n /**\n * The trailing \"Support\" row. VRM core opens its SupportRequestModal here;\n * other apps supply their own handler (`onClick`) or a link (`href`).\n * Omitted or `false` → no Support row. Appended to every mode's tree.\n */\n supportItem?: { onClick?: () => void; href?: string } | false\n /**\n * Which mode's tree to build. Default `relationship`, whose output is\n * byte-for-byte what this function produced before modes existed.\n */\n mode?: StandardNavMode\n /**\n * Active organization id (full UUID). EVERY link in EVERY tree carries it as\n * `?org=<uuid>` — the same convention the Mode switcher and My Account menu\n * use — so the destination app opens on the same org instead of the user's\n * default one. Omit it only when the caller genuinely has no active org yet.\n */\n activeOrgId?: string | null\n /**\n * Per-feature Campaign availability overrides, merged over\n * `CAMPAIGN_FEATURE_AVAILABILITY`. Only meaningful for the Campaign tree.\n */\n campaignAvailability?: Partial<CampaignFeatureAvailability>\n}\n\n/**\n * Drop the top-level rows named in `hidden` (case-insensitive label match),\n * then any section row left with no rows beneath it.\n */\nfunction applyHiddenItems(items: NavItem[], hidden?: string[]): NavItem[] {\n if (!hidden || hidden.length === 0) return items\n const drop = new Set(hidden.map((h) => h.trim().toLowerCase()))\n const kept = items.filter((i) => i.kind === 'section' || !drop.has(i.label.toLowerCase()))\n return kept.filter((item, idx) => {\n if (item.kind !== 'section') return true\n const next = kept[idx + 1]\n return !!next && next.kind !== 'section'\n })\n}\n\n/**\n * One sub-item of a standalone app, as a path RELATIVE to that app's origin\n * (`''` is the app root). Resolved against the origin and given the active-org\n * query param, exactly like the parent row it hangs under.\n */\ntype CrossAppLeaf = { label: string; icon: StandardNavIconKey; path: string }\n\nconst CONTACTS_APP = 'https://contacts.politogyvrm.com'\n\nconst APP_CONTACTS_CHILDREN = [\n { label: 'Dashboard', icon: 'grid' as const, href: `${CONTACTS_APP}/` },\n { label: 'All Contacts', icon: 'list' as const, href: `${CONTACTS_APP}/contacts` },\n { label: 'Tribes', icon: 'users' as const, href: `${CONTACTS_APP}/tribes` },\n { label: 'Import', icon: 'upload' as const, href: `${CONTACTS_APP}/import` },\n { label: 'Fields', icon: 'layout' as const, href: `${CONTACTS_APP}/fields` },\n { label: 'Activity', icon: 'activity' as const, href: `${CONTACTS_APP}/activity` },\n { label: 'Duplicates', icon: 'fileText' as const, href: `${CONTACTS_APP}/duplicates` },\n]\n\n// Email Broadcast now points at the standalone Email Engine V2 app\n// (email.politogyvrm.com, Specs/Email-Engine six tabs + Deliverability). The\n// V1 surface inside VRM core stays reachable as the last child while both run\n// in parallel. Absolute hrefs so active-detection lights this group when the\n// user is inside the Email app (same pattern as Contacts / Forms / Surveys).\nconst EMAIL_APP = 'https://email.politogyvrm.com'\nconst APP_EMAIL_CHILDREN = [\n { label: 'Dashboard', icon: 'grid' as const, href: `${EMAIL_APP}/dashboard` },\n { label: 'Creative Canvas', icon: 'edit' as const, href: `${EMAIL_APP}/canvas` },\n { label: 'Sender Information', icon: 'mail' as const, href: `${EMAIL_APP}/sender` },\n { label: 'Recipients', icon: 'user' as const, href: `${EMAIL_APP}/recipients` },\n { label: 'Send & Automate', icon: 'send' as const, href: `${EMAIL_APP}/send` },\n { label: 'Statistics', icon: 'barChart' as const, href: `${EMAIL_APP}/statistics` },\n { label: 'Deliverability', icon: 'activity' as const, href: `${EMAIL_APP}/deliverability` },\n]\n// Organization Settings — promoted from the My Account menu into the left nav\n// (HITL directive 2026-07-23). Mirrors the main app's former page IA, now\n// served by the standalone Settings app (settings.politogyvrm.com, Specs/\n// Organization-Settings v12) rather than VRM core: /organization-settings/:tab,\n// with Subscription & Billing carrying its own third level\n// (/organization-settings/subscription-billing/:tab). This is the canonical\n// depth-3 example the nav renderers support.\ntype CoreBranch = CrossAppLeaf & { children?: CrossAppLeaf[] }\n\nconst ORG_SETTINGS_CHILDREN: CoreBranch[] = [\n { label: 'General', icon: 'settings', path: 'organization-settings' },\n {\n label: 'Subscription & Billing',\n icon: 'creditCard',\n path: 'organization-settings/subscription-billing',\n children: [\n { label: 'Current Plan', icon: 'fileText', path: 'organization-settings/subscription-billing/current-plan' },\n { label: 'SMS, MMS & Email Usage', icon: 'activity', path: 'organization-settings/subscription-billing/text-email' },\n { label: 'Wallet', icon: 'dollarSign', path: 'organization-settings/subscription-billing/wallet' },\n { label: '10DLC', icon: 'messageSquare', path: 'organization-settings/subscription-billing/10dlc' },\n { label: 'Billing History', icon: 'clock', path: 'organization-settings/subscription-billing/billing-history' },\n ],\n },\n { label: 'Email', icon: 'mail', path: 'organization-settings/email-settings' },\n { label: 'Users', icon: 'users', path: 'organization-settings/users' },\n { label: 'Shared Links', icon: 'share', path: 'organization-settings/shared-links' },\n]\n\n// The NEW standalone acquisition apps (forms./surveys./polls.politogyvrm.com)\n// replace the legacy in-core \"Forms & Surveys\" system (HITL directive\n// 2026-07-23; removal plan: politogy/docs/legacy-forms-removal-plan.md).\n// Absolute cross-app links — SSO carries the session.\nconst APP_FORMS_CHILDREN = [\n { label: 'Forms', icon: 'list' as const, href: 'https://forms.politogyvrm.com/?tab=forms' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://forms.politogyvrm.com/?tab=canvas' },\n { label: 'Submissions', icon: 'fileText' as const, href: 'https://forms.politogyvrm.com/?tab=submissions' },\n]\n// The Surveys sub-menu mirrors the app's tab strip: Surveys / Canvas / Results.\n// Canvas and Results are survey-scoped routes (/surveys/:id/canvas), so with no\n// survey selected the list page carries a ?view= param — distinct hrefs, so\n// active-detection singles out exactly one (identical hrefs were the earlier\n// all-active bug; query params ARE compared, hashes are not).\nconst APP_SURVEYS_CHILDREN = [\n { label: 'Surveys', icon: 'list' as const, href: 'https://surveys.politogyvrm.com/surveys' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://surveys.politogyvrm.com/surveys?view=canvas' },\n { label: 'Results', icon: 'barChart' as const, href: 'https://surveys.politogyvrm.com/surveys?view=results' },\n]\nconst APP_POLLS_CHILDREN = [\n { label: 'Command Center', icon: 'grid' as const, href: 'https://polls.politogyvrm.com/' },\n { label: 'New Poll', icon: 'edit' as const, href: 'https://polls.politogyvrm.com/polls/new' },\n]\n// Standalone CTAs app (ctas.politogyvrm.com, Specs/CTAs) — same pattern as\n// Forms/Surveys/Polls above. This is also now the target for the\n// \"Calls to action\" row in the Relationship tree (the legacy in-core feature\n// it used to render was retired with app.politogyvrm.com).\nconst APP_CTAS_CHILDREN = [\n { label: 'CTAs', icon: 'list' as const, href: 'https://ctas.politogyvrm.com/' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://ctas.politogyvrm.com/?tab=canvas' },\n]\n\n// ---------------------------------------------------------------------------\n// Campaign app sub-navigation.\n//\n// Reference/UI-Platform v13 (Left bar → Navigation): \"The canonical VRM nav\n// tree — PARENT GROUPS WITH SUB-ITEMS. The app's own pages nest under their\n// group.\" The Campaign tree shipped as eight flat rows with no `children`, so\n// the Navigation Display control's \"Both\" and \"Sub Menu\" modes had nothing to\n// expand in the left bar of a2p / phonebank / canvass / signs — the three modes\n// rendered an identical sidebar and the control looked broken.\n//\n// Each list below is the app's OWN section list, taken verbatim from that app's\n// in-app tab strip (its `components/Shell.tsx`), so the sidebar sub-menu and the\n// page tab strip name the same sections in the same order — the sidebar/tab\n// agreement Reference/UI-Platform exists to enforce.\n// ---------------------------------------------------------------------------\n\n/** a2p/components/Shell.tsx `TABS` — the six A2P tabs. */\nconst APP_A2P_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: 'dashboard' },\n { label: 'Compose', icon: 'edit', path: 'compose' },\n { label: 'Recipients', icon: 'user', path: 'recipients' },\n { label: 'Tech Check', icon: 'activity', path: 'tech-check' },\n { label: 'Status', icon: 'clock', path: 'status' },\n { label: 'Conversations', icon: 'messageSquare', path: 'conversations' },\n]\n\n/** phonebank/components/Shell.tsx `NAV` — the Manager console's sections. */\nconst APP_PHONEBANK_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: '' },\n { label: 'Campaigns', icon: 'phone', path: 'campaigns' },\n { label: 'Inbound', icon: 'messageSquare', path: 'inbound' },\n { label: 'Reports', icon: 'barChart', path: 'reports' },\n]\n\n/** canvass/components/Shell.tsx `SECTIONS` — the manager console's sections. */\nconst APP_CANVASS_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: '' },\n { label: 'Campaigns', icon: 'target', path: 'campaigns' },\n { label: 'Canvassers', icon: 'users', path: 'canvassers' },\n]\n\n/**\n * signs/components/Shell.tsx `SECTIONS`. Review Queue is Manager+ in the app's\n * tab strip; the shared tree carries no role input, so the row is listed for\n * everyone and the ROUTE enforces it — /review renders a \"available to Managers\n * and Admins\" notice and loads no queue data for a volunteer (signs\n * app/review/page.tsx). Listing it keeps sidebar and tab strip identical for the\n * managers who use it rather than re-opening per-app nav drift.\n */\nconst APP_SIGNS_CHILDREN: CrossAppLeaf[] = [\n { label: 'Map', icon: 'map', path: '' },\n { label: 'Placements', icon: 'list', path: 'placements' },\n { label: 'Review Queue', icon: 'fileText', path: 'review' },\n { label: 'Recovery', icon: 'flag', path: 'recovery' },\n { label: 'Reports', icon: 'barChart', path: 'reports' },\n]\n\n/**\n * Build the standard Politogy VRM menu for the given `mode` (default\n * `relationship`), in the exact order and wording the main app renders it. See\n * `StandardNavOptions` for the app-specific hooks (`contactsItem`,\n * `supportItem`) and the Campaign inputs (`activeOrgId`, `campaignAvailability`).\n */\nexport function standardPolitogyNav(opts: StandardNavOptions): NavItem[] {\n // Left-Navigation §8.1: every row is a Lucide icon + label. Callers may\n // override per slot; otherwise the shared Lucide map applies.\n const icon = (key: StandardNavIconKey): NavIcon | undefined => opts.icons?.[key] ?? standardNavIcons[key]\n\n // EVERY link this tree emits leaves the current app (core routes are\n // cross-app for a standalone app, and the app-owned rows are supplied by the\n // caller), so each one carries the active org as `?org=<full-uuid>` — the\n // full id is the only collision-free selector (contacts-api matches exact id\n // first, then a short suffix that can collide across a user's orgs). Without\n // it a multi-org user following a bare cross-app link lands in whatever org\n // the destination defaults to; the cookie is only the fallback for a bare\n // URL, the param is the explicit selector. Active-detection ignores `org`\n // (isNavItemActive's ACTIVE_IGNORED_PARAMS) so stamping it selects nothing\n // differently, and it keeps the org in the address bar for bookmarking.\n const orgParam = opts.activeOrgId ? `org=${opts.activeOrgId}` : ''\n const withOrg = (url: string): string =>\n orgParam ? `${url}${url.includes('?') ? '&' : '?'}${orgParam}` : url\n\n const leaves = (origin: string, children: CrossAppLeaf[]): NavItem[] =>\n appLeaves(origin, children)\n const branches = (origin: string, children: CoreBranch[]): NavItem[] => {\n const o = origin.replace(/\\/+$/, '')\n return children.map((c) => ({\n label: c.label,\n icon: icon(c.icon),\n href: withOrg(`${o}/${c.path}`),\n children: c.children ? leaves(origin, c.children) : undefined,\n }))\n }\n\n // Sub-items of a standalone app: `origin` + the app-relative path, carrying\n // the active org the way the parent row does. Trailing slash on the origin\n // is normalized so `''` yields the app root and `x` yields `/x`. An optional\n // `modeParam` (a DUAL app entered from a mode other than its own default,\n // e.g. the Relationship tree's a2p row) is stamped on every leaf too, so the\n // destination resolves the same mode the row that got you there was in.\n const appLeaves = (\n origin: string,\n children: CrossAppLeaf[],\n modeParam?: StandardNavMode,\n ): NavItem[] => {\n const base = origin.replace(/\\/+$/, '')\n return children.map((c) => {\n const url = c.path ? `${base}/${c.path}` : `${base}/`\n const withMode = modeParam ? `${url}${url.includes('?') ? '&' : '?'}mode=${modeParam}` : url\n return { label: c.label, icon: icon(c.icon), href: withOrg(withMode) }\n })\n }\n\n // Left-Navigation §9.4: ACCOUNT is the last section in every mode.\n const accountRows = (): NavItem[] => [\n { kind: 'section', label: 'Account' },\n // My Profile moved to the Politogy ID account app (auth.politogyvrm.com)\n // with the retirement of app.politogyvrm.com.\n { label: 'My profile', icon: icon('circleUser'), href: withOrg(`${AUTH_ORIGIN}my-profile`) },\n {\n label: 'Organization settings',\n icon: icon('settings'),\n // Organization settings moved to the standalone Settings app\n // (settings.politogyvrm.com, Specs/Organization-Settings v12).\n href: withOrg(`${SETTINGS_ORIGIN}organization-settings`),\n children: branches(SETTINGS_ORIGIN, ORG_SETTINGS_CHILDREN),\n },\n ]\n\n const buildRelationship = (): NavItem[] => {\n const contacts: NavItem = opts.contactsItem\n ? {\n label: 'Contacts',\n icon: icon('usersRound'),\n href: opts.contactsItem.href,\n children: opts.contactsItem.children,\n badge: opts.contactsItem.count ?? undefined,\n }\n : {\n label: 'Contacts',\n icon: icon('usersRound'),\n href: withOrg(`${CONTACTS_APP}/`),\n children: APP_CONTACTS_CHILDREN.map((c) => ({\n label: c.label,\n icon: icon(c.icon),\n href: withOrg(c.href),\n })),\n }\n\n // Specs/Contacts design rail (Reference/UI-Platform → Left bar: section\n // rows via `kind: 'section'`, sentence-case labels). Three groups:\n // RELATIONSHIP Dashboard · Contacts · Email broadcast · SMS/MMS blast\n // COLLECT Calls to action · Forms · Surveys (· Polls · CTAs)\n // ACCOUNT My profile · Organization settings\n return [\n { kind: 'section', label: 'Relationship' },\n // Dashboard moved to the standalone Dashboard app (dashboard.politogyvrm.com,\n // Specs/Relationship-Dashboard) with the retirement of app.politogyvrm.com.\n { label: 'Dashboard', icon: icon('layoutDashboard'), href: withOrg(DASHBOARD_ORIGIN) },\n contacts,\n {\n label: 'Email broadcast',\n icon: icon('mail'),\n href: withOrg(`${EMAIL_APP}/dashboard`),\n children: APP_EMAIL_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n // SMS/MMS Blast is the a2p app entered in RELATIONSHIP mode (a2p is\n // dual-mode; Specs/A2P). The `?mode=relationship` param pins the\n // destination's tree so the row that got you there is the row that\n // lights up on arrival.\n label: 'SMS/MMS blast',\n icon: icon('messageSquare'),\n href: withOrg(`${A2P_ORIGIN}?mode=relationship`),\n children: appLeaves(A2P_ORIGIN, APP_A2P_CHILDREN, 'relationship'),\n },\n { kind: 'section', label: 'Collect' },\n // Calls to action moved to the standalone CTAs app (ctas./runtime.\n // politogyvrm.com, Specs/CTAs) with the retirement of app.politogyvrm.com.\n {\n label: 'Calls to action',\n icon: icon('mousePointerClick'),\n href: withOrg('https://ctas.politogyvrm.com/'),\n children: APP_CTAS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n label: 'Forms',\n icon: icon('fileText'),\n href: withOrg('https://forms.politogyvrm.com/'),\n children: APP_FORMS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n label: 'Surveys',\n icon: icon('clipboardList'),\n href: withOrg('https://surveys.politogyvrm.com/surveys'),\n children: APP_SURVEYS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n // Polls (polls.politogyvrm.com) — kept in the default Collect section;\n // apps that want it hidden pass `hiddenItems: ['Polls']`. Regression:\n // dropped entirely in 03c4dc2 when app.politogyvrm.com retired; restored\n // here (this row is independent of the retired app).\n {\n label: 'Polls',\n icon: icon('chartNoAxes'),\n href: withOrg(POLLS_ORIGIN),\n children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n ...accountRows(),\n ]\n }\n\n // Campaign tree — Dashboard + the 7 Campaign Mode features. Dashboard and\n // Voter Contact are core-hosted (VRM core /campaign/*); the rest link out to\n // standalone apps and are gated by CAMPAIGN_FEATURE_AVAILABILITY.\n const buildCampaign = (): NavItem[] => {\n const avail: CampaignFeatureAvailability = {\n ...CAMPAIGN_FEATURE_AVAILABILITY,\n ...opts.campaignAvailability,\n }\n type Gated = NavItem & { flag?: keyof CampaignFeatureAvailability }\n const rows: Gated[] = [\n // Left-Navigation §9.2: Race data -> Research -> GOTV -> Account.\n // Battleground is the Campaign landing page; there is no Campaign\n // Dashboard row, and Voter Contact and Tribes have no row.\n { kind: 'section', label: 'Race data' },\n // Battleground moved to the Dashboard app (dashboard.politogyvrm.com)\n // until a dedicated Battleground host is decided (UI-Platform route table).\n { label: 'Battleground', icon: icon('crosshair'), href: withOrg(`${DASHBOARD_ORIGIN}battleground`) },\n // District data moved to the Dashboard app (dashboard.politogyvrm.com)\n // per Reference/UI-Platform v44.\n { label: 'District data', icon: icon('landmark'), href: withOrg(`${DASHBOARD_ORIGIN}districts`) },\n { kind: 'section', label: 'Research' },\n {\n label: 'Polling',\n icon: icon('chartNoAxes'),\n href: withOrg(POLLS_ORIGIN),\n children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n flag: 'polling',\n },\n { kind: 'section', label: 'GOTV' },\n {\n label: 'Field canvassing',\n icon: icon('doorOpen'),\n href: withOrg(CANVASS_ORIGIN),\n children: appLeaves(CANVASS_ORIGIN, APP_CANVASS_CHILDREN),\n flag: 'canvass',\n },\n {\n label: 'Phone banking',\n icon: icon('phone'),\n href: withOrg(PHONEBANK_ORIGIN),\n children: appLeaves(PHONEBANK_ORIGIN, APP_PHONEBANK_CHILDREN),\n flag: 'phonebank',\n },\n {\n label: 'A2P texting',\n icon: icon('messageSquare'),\n href: withOrg(A2P_ORIGIN),\n children: appLeaves(A2P_ORIGIN, APP_A2P_CHILDREN),\n flag: 'a2p',\n },\n {\n label: 'Sign mapping',\n icon: icon('signpost'),\n href: withOrg(SIGNS_ORIGIN),\n children: appLeaves(SIGNS_ORIGIN, APP_SIGNS_CHILDREN),\n flag: 'signs',\n },\n ...accountRows(),\n ]\n const kept = rows\n .filter((r) => !r.flag || avail[r.flag])\n .map(({ flag: _flag, ...item }) => item as NavItem)\n // Drop a section left with no rows under it (e.g. Research when polling is off).\n return kept.filter((item, idx) => {\n if (item.kind !== 'section') return true\n const next = kept[idx + 1]\n return !!next && next.kind !== 'section'\n })\n }\n\n // Petition tree — the Petition Mode home (its own standalone app). The\n // Petitions app nests its own routes via `petitionsItem` (the contactsItem\n // contract); everyone else gets the minimal cross-app link. Labeled\n // Dashboard so the shared breadcrumb trail anchors correctly.\n const buildPetition = (): NavItem[] => [\n opts.petitionsItem\n ? {\n label: 'Dashboard',\n icon: icon('home'),\n href: opts.petitionsItem.href ?? withOrg(PETITION_MODE_ORIGIN),\n children: opts.petitionsItem.children,\n }\n : { label: 'Dashboard', icon: icon('home'), href: withOrg(PETITION_MODE_ORIGIN) },\n ]\n\n const mode = opts.mode ?? 'relationship'\n const built =\n mode === 'campaign'\n ? buildCampaign()\n : mode === 'petition'\n ? buildPetition()\n : buildRelationship()\n const items = applyHiddenItems(built, opts.hiddenItems)\n\n if (opts.supportItem) {\n items.push({\n label: 'Support',\n icon: icon('lifeBuoy'),\n href: opts.supportItem.href,\n onClick: opts.supportItem.onClick,\n })\n }\n\n return items\n}\n","// ---------------------------------------------------------------------------\n// Framework-agnostic chrome (sidebar + top navbar) for @the-portland-company/shell.\n//\n// The other chrome in this package (ShellChrome, Sidebar, Header, …) is built\n// on Chakra UI v2 + react-router and targets Vite SPAs. That stack cannot be\n// imported into a Next.js / React 19 / Tailwind app. This \"native\" module is a\n// dependency-light alternative: pure React (no Chakra, no emotion, no\n// react-router, no icon library) whose styling is driven entirely by the CSS\n// design tokens shipped in `@the-portland-company/shell/chrome.css`.\n//\n// It is a FAITHFUL VISUAL TWIN of the Chakra chrome (Sidebar.tsx / Header.tsx /\n// OrgPill / ModePill / NavItem / UserMenu): same 240px sidebar, brand-logo\n// slot, \"ORGANIZATION\" org pill, mode pill, solid active nav rows, pipe-\n// separated footer links + commit string, and an avatar+name+email+chevron user\n// menu — so an app rendering this looks identical to the main VRM app.\n//\n// Every app concern (nav items, org, mode, user, links, icons, the routing\n// Link component, the theme toggle) is injected via props, so both the Contacts\n// app (Next.js) and the VRM app could consume the same components.\n// ---------------------------------------------------------------------------\n\nimport type { ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react'\nimport { Fragment, createContext, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { useTopBarIconSlotGlyph, type TopBarIconSlot } from '../lib/topbarIconSlot'\nimport { resolveBrandGlyph } from '../lib/brandGlyphs'\nimport { warnDeprecated } from '../lib/deprecation'\nimport { filterOrgs, shouldShowOrgFilter } from './orgFilter'\nimport { readRailPreference, writeRailPreference } from '../nav-preference'\nimport { SpeculationRulesScript } from '../speculation/SpeculationRulesScript'\nimport {\n topBarIconButtonClass,\n TopBarTooltip,\n TopBarPanelArrow,\n NavThemeControl,\n resolveOrgLogoUrl,\n NAV_DISPLAY_OPTIONS,\n TOPBAR_GLYPH_SIZE,\n type ThemePreference,\n type NavDisplayMode,\n} from './chromeActions'\n\n// Data-backed top-bar widgets (Fuel, Notifications, Support, Nav-display) +\n// the injected-fetcher provider they hang off. One implementation for every app.\nexport {\n NavChromeProvider,\n CORE_APP_ORIGIN,\n CORE_BILLING_PATH,\n SPECS_ORIGIN,\n FuelAction,\n NotificationsAction,\n SupportAction,\n SpecOverlayAction,\n NavDisplayAction,\n NavThemeControl,\n TopBarCountBadge,\n TopBarPanelArrow,\n TopBarTooltip,\n TopBarWidgetSlot,\n TopBarPopover,\n topBarIconButtonClass,\n resolveOrgLogoUrl,\n useChromeMe,\n useChromeOrgs,\n useNavChromeFetcher,\n useNavChromeDedupedFetch,\n useThemePreference,\n} from './chromeActions'\nexport type {\n ChromeMe,\n NavChromeFetcher,\n NavDisplayMode,\n ThemePreference,\n ChromeOrgSummary,\n ChromeNotificationsPayload,\n ChromeNotificationAlert,\n ChromeNotificationReply,\n ChromeNotificationImport,\n ChromeNotificationQuarantine,\n CommunicationsFuelStatus,\n FuelChannelStatus,\n} from './chromeActions'\n\n// An icon is any component that accepts an optional size + className. This\n// matches both `lucide-react` and `react-icons` icon signatures, so consuming\n// apps pass their own icon set without this package depending on one.\nexport type NavIcon = ComponentType<{ size?: number; className?: string; strokeWidth?: number }>\n\nexport type NavItem = {\n /**\n * What this row IS. Defaults to `'link'` — every existing `NavItem[]` keeps\n * its exact type and rendering.\n *\n * `'section'` is a non-interactive heading that groups the rows beneath it:\n * uppercase, muted, letterspaced, not focusable, no hover. Only `label` is\n * read; `href`, `icon`, `onClick` and `children` are ignored.\n *\n * The legacy chrome supported this and 0.43 dropped it, so apps faked it by\n * passing `disabled` rows with no href — which looks approximately right and\n * is wrong where it counts: a disabled row announces as an unavailable\n * CONTROL to a screen reader, when it is not a control at all. A section is\n * its own kind of row (Reference/UI-Platform → Left bar).\n *\n * Deliberately a widened field rather than a discriminated union: a union\n * would make `item.href` a type error for every existing consumer that reads\n * it, turning an additive feature into a breaking change.\n */\n kind?: 'link' | 'section'\n /** Route to link to. Optional when `onClick` is supplied (renders a button). */\n href?: string\n label: string\n icon?: NavIcon\n /**\n * When supplied the row renders as a `<button>` (styled identically to the\n * link rows) instead of a routed link — used for actions like \"Support\".\n */\n onClick?: () => void\n /**\n * Disables the row: non-interactive and dimmed, with `disabledTitle` shown as\n * a hover tooltip explaining why. Mirrors `NavTab`'s existing contract so a\n * gated row looks the same whether it renders in the sidebar or a tab strip.\n * Without this, an app that gates a section (VRM dims Email / SMS until setup\n * is complete) had no way to express it and the row rendered fully clickable\n * (shell-nav-handoff §3).\n */\n disabled?: boolean\n /** Tooltip for a disabled row — say why, and how to resolve it. */\n disabledTitle?: string\n /**\n * Right-aligned count/annotation on the row — e.g. the live contact count\n * on \"Contacts\" (`31.9K`). Pre-formatted by the app; the shell only draws\n * it (Specs/Contacts design rail). Omitted/null draws nothing.\n */\n badge?: string | number | null\n /**\n * Nested sub-items. When present, the row becomes an expandable GROUP header.\n * Clicking it always toggles the children open/closed and rotates the\n * right-aligned chevron; if the item ALSO carries an `onClick`, that runs too,\n * so a parent can navigate to its section dashboard while expanding\n * (shell-nav-handoff §2). An `href` alone never navigates from a group header. The sidebar runs a single-open accordion (opening one group closes\n * the others) and auto-expands whichever group contains the active route —\n * mirroring the main VRM app's Chakra sidebar. Children render as smaller nav\n * rows on a lighter panel and support both `href` links and `onClick` actions.\n */\n children?: NavItem[]\n}\n\n// The routing primitive is injected so each app supplies its own (Next.js\n// `<Link>`, react-router `<Link>`, or a plain `<a>`). Defaults to an anchor.\nexport type NavLinkProps = {\n href: string\n className?: string\n 'aria-current'?: 'page' | undefined\n children: ReactNode\n // Optional passthrough attributes so the same injected link can back a\n // routed nav row OR a routed tab (which needs ARIA tab semantics + inline\n // token geometry). Next.js `<Link>`, react-router `<Link>` and a plain <a>\n // all accept these DOM props, and DefaultLink spreads them onto its anchor.\n role?: string\n 'aria-selected'?: boolean\n 'aria-label'?: string\n title?: string\n style?: CSSProperties\n}\nexport type NavLinkComponent = ComponentType<NavLinkProps>\n\n/**\n * URL-scheme allow-list for host-supplied hrefs. React does not neutralize\n * `javascript:`/`data:` schemes on anchor href, so any app-supplied nav/footer/\n * action href must be validated before it reaches the DOM. Permits absolute\n * http(s), mailto/tel, and in-app relative targets; everything else → '#'.\n */\nconst safeHref = (h?: string) =>\n h && /^(https?:|mailto:|tel:|\\/|#|\\.)/i.test(h.trim()) ? h : '#'\n\nconst DefaultLink: NavLinkComponent = ({ href, children, ...rest }) => (\n <a href={safeHref(href)} {...rest}>\n {children}\n </a>\n)\n\n/**\n * Default active-route test. Handles three href shapes so the CURRENT app's\n * item + sub-item select correctly in the cross-app menu (HITL 2026-07-23):\n * - relative path: exact for \"/\", prefix otherwise (legacy behavior);\n * - absolute URL: active only when its host matches window.location.host,\n * then compared by path (and query, when the href carries one — e.g.\n * forms' /?tab=canvas sub-items);\n * - query-only relative hrefs likewise compare location.search.\n *\n * The `org` param is EXCLUDED from the query comparison. Campaign / Petition\n * links carry `?org=<last6>` purely to hand the active organization to the\n * destination app (`standardPolitogyNav`'s `activeOrgId`); it scopes data, it\n * does not identify a page. Comparing it would deselect every campaign row the\n * moment an org is active, because the app's own URL bar carries no `org=`.\n */\nconst ACTIVE_IGNORED_PARAMS = new Set(['org'])\n\nexport function isNavItemActive(pathname: string, href: string): boolean {\n let targetPath = href\n let targetSearch = ''\n if (/^https?:\\/\\//i.test(href)) {\n if (typeof window === 'undefined') return false\n try {\n const u = new URL(href)\n if (u.host !== window.location.host) return false\n targetPath = u.pathname\n targetSearch = u.search\n } catch {\n return false\n }\n } else {\n const qi = href.indexOf('?')\n if (qi >= 0) {\n targetPath = href.slice(0, qi) || '/'\n targetSearch = href.slice(qi)\n }\n }\n // Every IDENTIFYING key=value in the target query must be present in the\n // location. Once the scoping params are dropped a link like\n // \"https://signs.politogyvrm.com/placements?org=abc123\" is a plain path href\n // again and falls through to the path rules below.\n const want = new URLSearchParams(targetSearch)\n for (const k of ACTIVE_IGNORED_PARAMS) want.delete(k)\n if (Array.from(want).length > 0) {\n if (typeof window === 'undefined') return false\n if (pathname !== targetPath) return false\n const have = new URLSearchParams(window.location.search)\n for (const [k, v] of want) if (have.get(k) !== v) return false\n return true\n }\n if (targetPath === '/') return pathname === '/'\n return pathname === targetPath || pathname.startsWith(`${targetPath}/`)\n}\n\n/**\n * Stable identity for an expandable nav group's accordion state. Prefers the\n * item's href; falls back to an index-scoped label so two groups can never\n * collide even when they share a label and have no href.\n */\nfunction groupKeyOf(item: NavItem, index: number): string {\n return item.href ?? `nav-group-${index}-${item.label}`\n}\n\n/** True when any of a group's children links to the active route. */\nfunction hasActiveChild(\n item: NavItem,\n pathname: string,\n activeFn: (pathname: string, href: string) => boolean,\n): boolean {\n return (item.children ?? []).some(\n (child) =>\n (child.href ? activeFn(pathname, child.href) : false) ||\n // Depth-3: a grandchild owning the route also opens the top group.\n (child.children ?? []).some((leaf) =>\n leaf.href ? activeFn(pathname, leaf.href) : false,\n ),\n )\n}\n\n/**\n * Color-coded tone classes for the sidebar environment chip, matching the main\n * VRM app: prod red, staging orange, local/dev green, unknown gray.\n */\nfunction firstLeafHref(item: NavItem): string | undefined {\n for (const c of item.children ?? []) {\n if (c.kind === 'section') continue\n if (c.href) return c.href\n const deep = firstLeafHref(c)\n if (deep) return deep\n }\n return undefined\n}\n\n/** A multi-mode app (VRM core) renders NavAppShell without a registry modeId;\n * its current mode label still decides the rail colour (Left-Navigation §5). */\nexport function modeIdFromLabel(label: string | undefined): string | undefined {\n const l = label?.trim().toLowerCase()\n return l ? l.replace(/\\s+mode$/, '') : undefined\n}\n\n/** \"Ben Edtl\" -> \"Ben E.\" (Left-Navigation §10). One word stays as is. */\nexport function shortUserName(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n if (parts.length < 2) return parts[0] ?? ''\n return `${parts[0]} ${parts[parts.length - 1][0].toUpperCase()}.`\n}\n\n/** Short environment name for the rail's build line (\"prod\", \"staging\", \"local\"). */\nexport function shortEnvLabel(label: string): string {\n const l = label.trim().toLowerCase()\n if (l === 'production') return 'prod'\n if (l === 'development') return 'dev'\n return l\n}\n\nexport function envChipClasses(label: string): string {\n const l = label.toLowerCase()\n if (l === 'production' || l === 'prod')\n return 'bg-[#fee2e2] text-[#ef4444]'\n if (l === 'staging' || l === 'stage')\n return 'bg-[#ffedd5] text-[#f97316]'\n if (l === 'local' || l === 'development' || l === 'dev')\n return 'bg-[#dcfce7] text-[#22c55e]'\n return 'bg-[rgba(107,114,128,0.16)] text-[#6b7280]'\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavBrand = {\n /** Where the logo links to. Defaults to \"/\". */\n homeHref?: string\n /**\n * Brand logo image src. When supplied this renders as the wordmark logo\n * (matching the main app's BrandLogo), and `badgeLabel`/`title`/`subtitle`\n * are used only as the no-image fallback.\n */\n logoSrc?: string\n logoAlt?: string\n /**\n * The square mark shown at the top of the COLLAPSED rail (Left-Navigation\n * §11.6) — Brand `assets.logoSquare`, the all-white vrm tile. Falls back to\n * the badge when omitted.\n */\n logoSquareSrc?: string\n /**\n * The logo URLs are still resolving from the Brand token sheet. The rail\n * reserves the logo's box and draws nothing — never the badge fallback,\n * which would flash a stand-in on every load.\n */\n logoPending?: boolean\n /** Short label shown inside the brand badge fallback (e.g. \"P\"). */\n badgeLabel: string\n title: string\n subtitle?: string\n}\n\nexport type NavOrgOption = {\n id: string\n name: string | null\n logoUrl?: string | null\n /** The org's Brand Kit icon mark; falls back to `logoUrl`, then initials. */\n iconUrl?: string | null\n brandColor?: string | null\n role?: string | null\n}\n\nexport type NavOrg = {\n name: string | null\n /** Full org id. When present, a copy affordance is shown by the label. */\n id?: string | null\n /** Optional org logo for the pill badge; falls back to initials. */\n logoUrl?: string | null\n /**\n * The org's Brand Kit icon mark, shown on the collapsed rail (32px, on its\n * white tile). Falls back to `logoUrl` scaled to fit, then initials.\n */\n iconUrl?: string | null\n /** Solid pill background (the org's brand color). Defaults to the accent. */\n brandColor?: string | null\n /** Org's secondary Brand Kit color; the card's bottom-edge gradient runs\n * primary → secondary. Falls back to the Politogy gradient when unset. */\n brandColorSecondary?: string | null\n /**\n * Organization Settings §7.1–§7.2: when the org has no logo yet, an Account\n * Admin sees an \"Upload logo\" link in the band instead of the org name.\n */\n canUploadLogo?: boolean\n uploadLogoHref?: string\n onClick?: () => void\n /**\n * The user's organizations. When present (even one), the pill renders as a\n * dropdown SWITCHER (Reference/UI-Platform \"Organization selector\": never a\n * static label in a multi-org app); selecting one calls `onSwitch(id)`.\n */\n organizations?: NavOrgOption[]\n onSwitch?: (id: string) => void\n /**\n * The active org is still resolving from the chrome API. Renders a skeleton\n * pill instead of a name. Required because the app's own workspace label is\n * NOT the organization: showing it while the real org loads flashes a wrong\n * value (Global Rules — async values shimmer, they never render a stand-in).\n */\n loading?: boolean\n}\n\nexport type NavModeOption = {\n id: string\n label: string\n icon?: NavIcon\n /**\n * Left-Navigation §7: a mode the organization does not hold is always\n * shown (never hidden), dimmed, and not selectable. Defaults to true.\n */\n available?: boolean\n /** Tooltip for an unavailable mode, e.g. \"Campaign Mode isn't active for\n * this organization.\" Appended with \"See upgrade options\" for an Account\n * Admin on a paid account (never during a trial). */\n unavailableTooltip?: string\n}\n\nexport type NavMode = {\n label: string\n icon?: NavIcon\n /**\n * Entitled modes for the active organization. With more than one option the\n * pill renders as a SELECTOR (dropdown); with zero/one it stays the classic\n * disabled single-mode pill. Selecting calls onSelect(id).\n */\n options?: NavModeOption[]\n onSelect?: (id: string) => void\n}\n\nexport type NavFooterLink = { label: string; href: string; external?: boolean }\n\nexport type NavFooter = {\n /**\n * Build metadata (env chip / commit / version / date / author). OPTIONAL:\n * omit envLabel/version/commit to render a links-only footer — apps show\n * the meta block to Super Administrators only (Reference/UI-Platform).\n */\n envLabel?: string\n version?: string\n commit?: string\n links?: NavFooterLink[]\n /** ISO date (or any Date-parseable string) of the deployed commit. */\n commitDate?: string\n /** Full name of the commit author (only the first name is shown). */\n commitAuthor?: string\n /**\n * The signed-in user, drawn as a card (avatar · name · email · chevron)\n * ABOVE the links row. Reference/UI-Platform v30 → Left bar: \"The user —\n * avatar, name, email and the user menu — lives in the left bar footer.\"\n * Clicking it opens the account menu UPWARD. `NavAppShell` fills these from\n * `topBar.user` / `topBar.userMenu` / `topBar.onSignOut` automatically, so\n * standalone `NavSidebar` consumers pass them only when they want the card.\n */\n user?: NavUser | null\n userMenu?: NavUserMenu | null\n onSignOut?: () => void\n}\n\nexport type NavSidebarProps = {\n pathname: string\n brand: NavBrand\n nav: {\n groupLabel?: string\n items: NavItem[]\n isActive?: (pathname: string, href: string) => boolean\n /**\n * Render each top-level group's CHILDREN directly at the root of the rail\n * — no parent header row, no accordion. For an app whose whole tree nests\n * under one entry (Petitions), that parent row is pure anatomy: V1 never\n * had it, it duplicates the first child's route, and it costs a level of\n * indentation. Sections render as sections; rows render with the 'flat'\n * variant (top-level geometry, wash active treatment). Top-level items\n * WITHOUT children render unchanged, so a mixed tree degrades sanely.\n */\n flatten?: boolean\n }\n org?: NavOrg | null\n mode?: NavMode | null\n footer?: NavFooter | null\n linkComponent?: NavLinkComponent\n /**\n * Small-screen expand state (owned by `NavAppShell`). The rail is never\n * hidden (Left-Navigation §11.6): at `md` and up it is the full rail, below\n * `md` it collapses to the 64px icon rail. `open` expands the collapsed\n * rail to the full rail as a modal drawer with a backdrop, and `onClose`\n * wires the backdrop, the close button, and Escape. `md` and up ignores\n * both.\n */\n open?: boolean\n onClose?: () => void\n /**\n * Expands the collapsed (below `md`) rail. When set, the square logo tile at\n * the top of the collapsed rail becomes the \"Expand navigation\" control —\n * the Left-Navigation Design draws no other toggle and no top-bar hamburger.\n */\n onOpen?: () => void\n /**\n * Closes the expanded rail after a nav-link click without counting as the\n * user's Collapse choice. Defaults to `onClose`.\n */\n onNavigate?: () => void\n}\n\n// Default org-pill BADGE background — the chrome accent, matching the main\n// app's fallback (mode primary) when an org has no explicit brand color. In a\n// Mode with its own accent this follows the Mode. Only the circular badge takes\n// it; the pill body stays neutral (Reference/UI-Platform → Left bar).\nconst ORG_PILL_DEFAULT = 'var(--color-accent)'\n\n// Left-Navigation §11.6: below `md` the rail collapses to the 64px icon rail;\n// it is never hidden. The collapse is pure CSS (`max-md:` utilities), so there\n// is one DOM tree and no hydration flash. It applies only while the rail is\n// not expanded as the small-screen drawer, which is what this context carries\n// down to the rows.\nconst RailCollapsibleContext = createContext(false)\n\n/** Returns `cls` when the small-screen collapse applies to this rail, else ''. */\nfunction useRailCollapse(): (cls: string) => string {\n const collapsible = useContext(RailCollapsibleContext)\n return (cls) => (collapsible ? cls : '')\n}\n\n/**\n * The organization on the collapsed rail: its Brand Kit icon mark, 32px, on a\n * white tile (Left-Navigation §11.6). Rendered inside the same switcher\n * trigger as the full card, so the switcher stays interactive when collapsed.\n */\nfunction OrgIconMark({ org, logoSrc }: { org: NavOrg; logoSrc?: string }) {\n const rc = useRailCollapse()\n const src = resolveOrgLogoUrl(org.iconUrl) ?? logoSrc\n return (\n <span\n aria-hidden\n data-rail-org-mark=\"\"\n className={`hidden h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-[5px] bg-[#FFFFFF] text-[11px] font-bold text-neutral-800 ${rc('max-md:flex')}`}\n >\n {src ? (\n <img src={src} alt=\"\" className=\"max-h-full max-w-full object-contain\" />\n ) : (\n (org.name ?? 'Org').slice(0, 2).toUpperCase()\n )}\n </span>\n )\n}\n\nexport function NavSidebar({\n pathname,\n brand,\n nav,\n org,\n mode,\n footer,\n linkComponent,\n open,\n onClose,\n onOpen,\n onNavigate,\n}: NavSidebarProps) {\n const Link = linkComponent ?? DefaultLink\n // The small-screen collapse applies whenever the rail is not expanded as\n // the drawer (see RailCollapsibleContext).\n const collapsible = !open\n const rc = (cls: string) => (collapsible ? cls : '')\n // Focus management for the mobile drawer: on open, move focus to the close\n // button; on close, return it to whatever had focus before (the hamburger,\n // in practice). Escape closes while the drawer is open.\n const asideRef = useRef<HTMLElement>(null)\n const closeButtonRef = useRef<HTMLButtonElement>(null)\n const previouslyFocusedRef = useRef<HTMLElement | null>(null)\n useEffect(() => {\n if (open) {\n previouslyFocusedRef.current = document.activeElement as HTMLElement | null\n closeButtonRef.current?.focus()\n } else if (previouslyFocusedRef.current) {\n previouslyFocusedRef.current.focus()\n previouslyFocusedRef.current = null\n }\n }, [open])\n useEffect(() => {\n if (!open) return\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose?.()\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [open, onClose])\n // Focus trap: Tab/Shift+Tab must stay inside the drawer while it is open —\n // no `inert` attribute (React 18/19 compatibility), so this is a plain\n // keydown handler that wraps focus at the first/last focusable element.\n const trapTab = (e: ReactKeyboardEvent<HTMLElement>) => {\n if (!open || e.key !== 'Tab') return\n const root = asideRef.current\n if (!root) return\n const focusable = Array.from(\n root.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n ),\n ).filter((el) => {\n if (el.hidden) return false\n const style = window.getComputedStyle(el)\n return style.display !== 'none' && style.visibility !== 'hidden'\n })\n if (focusable.length === 0) return\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n if (e.shiftKey) {\n if (document.activeElement === first) {\n e.preventDefault()\n last.focus()\n }\n } else if (document.activeElement === last) {\n e.preventDefault()\n first.focus()\n }\n }\n const activeFn = nav.isActive ?? isNavItemActive\n const ModeIcon = mode?.icon\n // Core stores logo_url as a core-relative storage route; resolve it against\n // the core origin so it loads in EVERY app, not just app.politogyvrm.com.\n const orgLogoSrc = resolveOrgLogoUrl(org?.logoUrl)\n // Left-Navigation §6: brand-color gradient strip along the logo band's\n // bottom edge; the Politogy gradient (blue → purple → red) until the org\n // sets its own Brand Kit colors.\n const orgGradient = org?.brandColor\n ? `linear-gradient(to right, ${org.brandColor}, ${org.brandColorSecondary || org.brandColor})`\n : 'linear-gradient(to right, #007BFF, #A54B7A, #E63946)'\n // Design rail: the org card border is the org's brand color at 42% alpha\n // (`rgba(74,192,231,.42)` in the Specs/Contacts design); hairline otherwise.\n const orgCardStyle = hexToRgba(org?.brandColor, 0.42)\n ? { borderColor: hexToRgba(org?.brandColor, 0.42) as string }\n : undefined\n\n // Single-open accordion for expandable nav groups, mirroring the main VRM\n // app's Chakra sidebar. `activeGroupKey` is the group (if any) that owns the\n // current route; deriving it as a primitive string keeps the auto-expand\n // effect from firing when `nav.items` is a fresh array reference each render\n // (which would otherwise clobber a manual toggle).\n const activeGroupKey = useMemo(() => {\n for (let i = 0; i < nav.items.length; i++) {\n const item = nav.items[i]\n if (item.children && item.children.length > 0 && hasActiveChild(item, pathname, activeFn)) {\n return groupKeyOf(item, i)\n }\n }\n return null\n }, [nav.items, pathname, activeFn])\n\n // Seed the open group from the active route on first paint (no expand flash),\n // then keep it synced as the route changes. Manual toggles between route\n // changes are preserved because the effect only reruns when the *derived*\n // active group actually changes.\n const [openGroup, setOpenGroup] = useState<string | null>(activeGroupKey)\n // Org selector type-to-filter (see ./orgFilter.ts). Reset whenever the popover closes.\n const [orgFilter, setOrgFilter] = useState('')\n useEffect(() => {\n setOpenGroup(activeGroupKey)\n }, [activeGroupKey])\n const toggleGroup = (key: string) =>\n setOpenGroup((prev) => (prev === key ? null : key))\n\n return (\n <RailCollapsibleContext.Provider value={collapsible}>\n {/* Backdrop — small-screen drawer only, dismisses on click. */}\n {open ? (\n <div\n aria-hidden\n className=\"fixed inset-0 z-40 bg-black/40 md:hidden\"\n onClick={onClose}\n />\n ) : null}\n <aside\n ref={asideRef}\n id=\"politogy-nav-drawer\"\n role={open ? 'dialog' : undefined}\n aria-modal={open ? 'true' : undefined}\n aria-label={open ? 'Navigation' : undefined}\n className={clsx(\n 'fixed inset-y-0 left-0 flex flex-col border-r border-[color:var(--sidebar-line,var(--line))] bg-[color:var(--sidebar-bg,var(--nav-surface))]',\n // Never hidden: the 64px icon rail below `md`, the full rail from\n // `md` up, and the full rail as a drawer when expanded below `md`.\n open\n ? 'z-50 w-[var(--sidebar-width,236px)]'\n : 'z-30 w-[var(--sidebar-collapsed-width,64px)] md:w-[var(--sidebar-width,236px)]',\n )}\n // Pin the rail's own font explicitly to the Brand token (Reference/UI-Platform\n // \"Typography\") rather than relying on inherited `body` styles. An app that\n // sets its own body font on a sub-view (e.g. Contacts) would otherwise leak\n // into the rail purely by inheritance — one shell definition, never app-derived.\n style={{ fontFamily: 'var(--font-family, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif)' }}\n onKeyDown={trapTab}\n onClick={(e) => {\n // Any nav-link click closes the drawer — including a click on the\n // CURRENT route's link, which would otherwise strand it open since\n // `pathname` never changes to trigger NavAppShell's close effect.\n if (open && (e.target as HTMLElement).closest('a[href]')) (onNavigate ?? onClose)?.()\n }}\n >\n {/* Close button — small-screen drawer only. */}\n {open ? (\n <button\n type=\"button\"\n ref={closeButtonRef}\n onClick={onClose}\n aria-label=\"Collapse navigation\"\n className=\"absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full text-[color:var(--muted)] transition hover:bg-[color:var(--panel-elevated)] hover:text-[color:var(--foreground)] md:hidden\"\n >\n <CloseIcon />\n </button>\n ) : null}\n {/* Header — brand, org card, mode switcher (Specs/Contacts design\n rail: padding 16px 18px, 14px between blocks, hairline below). */}\n <div className={`flex flex-shrink-0 flex-col gap-[14px] border-b border-[color:var(--sidebar-line,var(--line))] px-[18px] py-4 ${rc('max-md:items-center max-md:px-[10px]')}`}>\n {/* Brand — the lockup directly on the rail, no plate; the square\n tile when collapsed. Badge only when no logo was supplied at all. */}\n {/* Below `md` the collapsed rail's logo tile is the expand control\n (Left-Navigation §11.6: the rail is never hidden; the user expands\n it from the rail itself). Hidden while expanded and from `md` up. */}\n {onOpen ? (\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label=\"Expand navigation\"\n aria-expanded={open ?? false}\n data-rail-toggle=\"expand\"\n className={`hidden h-8 w-8 items-center justify-center rounded-lg ${rc('max-md:flex')}`}\n >\n {brand.logoSquareSrc ? (\n <img src={brand.logoSquareSrc} alt=\"\" draggable={false} className=\"h-8 w-8 object-contain\" />\n ) : brand.logoPending ? (\n <span aria-hidden className=\"block h-8 w-8\" />\n ) : (\n <span className=\"flex h-8 w-8 items-center justify-center rounded-xl bg-[color:var(--color-accent)] text-sm font-black text-[#FFFFFF]\">\n {brand.badgeLabel}\n </span>\n )}\n </button>\n ) : null}\n <Link\n href={brand.homeHref ?? '/'}\n aria-label={brand.logoAlt ?? brand.title}\n className={`flex items-center gap-2.5 ${rc('max-md:justify-center')} ${onOpen ? rc('max-md:hidden') : ''}`}\n >\n {brand.logoSquareSrc ? (\n <img\n src={brand.logoSquareSrc}\n alt=\"\"\n draggable={false}\n data-rail-logo=\"square\"\n className={`hidden h-8 w-8 object-contain ${rc('max-md:block')}`}\n />\n ) : brand.logoPending ? (\n <span aria-hidden className={`hidden h-8 w-8 ${rc('max-md:block')}`} />\n ) : null}\n {brand.logoSrc ? (\n <img\n src={brand.logoSrc}\n alt={brand.logoAlt ?? brand.title}\n draggable={false}\n data-rail-logo=\"horizontal\"\n className={`h-[var(--sidebar-brand-logo-height,24px)] w-auto object-contain ${rc('max-md:hidden')}`}\n />\n ) : brand.logoPending ? (\n <span\n aria-hidden\n className={`block h-[var(--sidebar-brand-logo-height,24px)] ${rc('max-md:hidden')}`}\n />\n ) : (\n <>\n <span\n className={`flex h-9 w-9 items-center justify-center rounded-xl bg-[color:var(--color-accent)] text-base font-black text-[#FFFFFF] shadow-sm ${brand.logoSquareSrc ? rc('max-md:hidden') : ''}`}\n >\n {brand.badgeLabel}\n </span>\n <span className={`flex flex-col leading-tight ${rc('max-md:hidden')}`}>\n <span className=\"text-base font-extrabold tracking-[-0.01em] text-[color:var(--color-accent)]\">\n {brand.title}\n </span>\n {brand.subtitle ? (\n <span className=\"text-[11px] font-semibold uppercase tracking-[0.16em] text-[color:var(--muted)]\">\n {brand.subtitle}\n </span>\n ) : null}\n </span>\n </>\n )}\n </Link>\n\n {/* Organization switcher */}\n {org ? (\n <div className={rc('max-md:flex max-md:justify-center')}>\n <div className={`mb-[7px] mt-[7px] flex items-center justify-between ${rc('max-md:hidden')}`}>\n <p className={NAV_EYEBROW_CLASS}>\n Organization\n </p>\n </div>\n {org.loading ? (\n <div className={`flex w-full items-center gap-2.5 rounded-md border border-[color:var(--line)] bg-[color:var(--panel-elevated)] px-2.5 py-2 shadow-sm ${rc('max-md:w-auto max-md:border-0 max-md:bg-transparent max-md:p-0 max-md:shadow-none')}`}>\n <span\n aria-hidden\n className=\"h-7 w-7 shrink-0 animate-pulse rounded-full bg-[color:var(--panel)]\"\n />\n <span\n aria-hidden\n className={`h-4 flex-1 animate-pulse rounded bg-[color:var(--panel)] ${rc('max-md:hidden')}`}\n />\n <span className=\"sr-only\">Loading organization</span>\n </div>\n ) : org.organizations && org.organizations.length > 0 && org.onSwitch ? (\n <details data-nav-details className=\"group relative\">\n <summary\n style={orgCardStyle}\n title={org.name ?? undefined}\n className={`flex w-full cursor-pointer list-none flex-col overflow-hidden rounded-[5px] border border-[color:var(--sidebar-card-border,var(--sidebar-line,var(--line)))] bg-[color:var(--sidebar-card-bg,var(--panel-elevated))] text-left text-[color:var(--sidebar-text,var(--foreground))] transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))] [&::-webkit-details-marker]:hidden ${rc('max-md:w-auto max-md:items-center max-md:overflow-visible max-md:border-0 max-md:bg-transparent')}`}\n >\n <OrgIconMark org={org} logoSrc={orgLogoSrc} />\n {/* Logo band: white, org's Primary Brand Kit logo ≤70px, never\n cropped/stretched/recolored; \"Upload logo\" for an Admin\n with no logo yet; otherwise the org's display name. */}\n <span className={`relative flex h-[var(--sidebar-org-band-height,70px)] w-full items-center justify-center bg-[#FFFFFF] px-3 py-[7px] ${rc('max-md:hidden')}`}>\n {orgLogoSrc ? (\n <img src={orgLogoSrc} alt=\"\" className=\"max-h-full max-w-[132px] object-contain\" />\n ) : org.canUploadLogo ? (\n <a\n href={org.uploadLogoHref ?? '#'}\n onClick={(e) => e.stopPropagation()}\n className=\"text-xs font-semibold text-[color:var(--color-accent)] underline\"\n >\n Upload logo\n </a>\n ) : (\n <span className=\"truncate text-sm font-semibold text-neutral-800\">\n {org.name ?? 'Organization'}\n </span>\n )}\n <span aria-hidden className=\"absolute inset-x-0 bottom-0 h-[3px]\" style={{ backgroundImage: orgGradient }} />\n </span>\n <span className={`flex w-full min-w-0 items-center justify-between gap-[9px] px-[10px] py-[10px] ${rc('max-md:hidden')}`}>\n <span className=\"flex min-w-0 flex-col\">\n <span\n title={org.name ?? undefined}\n className=\"truncate text-[12px] font-semibold leading-[1.2]\"\n >\n {org.name ?? 'No organizations'}\n </span>\n {org.id && !org.loading ? <OrgIdCopyButton id={org.id} /> : null}\n </span>\n <ChevronDown size={14} />\n </span>\n </summary>\n <div className={`absolute left-0 right-0 z-40 mt-1 max-h-[min(60vh,520px)] overflow-y-auto rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 shadow-[var(--shadow-soft)] ${rc('max-md:right-auto max-md:w-[236px]')}`}>\n {shouldShowOrgFilter(org.organizations.length) ? (\n <div className=\"sticky top-0 z-10 bg-[color:var(--panel-elevated)] px-2 pb-1 pt-1\">\n <input\n type=\"search\"\n value={orgFilter}\n onChange={(e) => setOrgFilter(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n setOrgFilter('')\n e.currentTarget.closest('details')?.removeAttribute('open')\n }\n }}\n placeholder={`Filter ${org.organizations.length} organizations`}\n aria-label=\"Filter organizations\"\n autoComplete=\"off\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-1.5 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n </div>\n ) : null}\n {filterOrgs(org.organizations, orgFilter).length === 0 ? (\n <p className=\"px-3 py-2 text-sm text-[color:var(--muted)]\">No organization matches “{orgFilter}”.</p>\n ) : null}\n {filterOrgs(org.organizations, orgFilter).map((o) => {\n const selected = o.id === org.id\n return (\n <button\n key={o.id}\n type=\"button\"\n onClick={(e) => {\n // Close the <details> popover, then switch.\n e.currentTarget.closest('details')?.removeAttribute('open')\n setOrgFilter('')\n if (!selected) org.onSwitch?.(o.id)\n }}\n aria-current={selected ? 'true' : undefined}\n className={[\n 'flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm',\n selected\n ? 'font-semibold text-[color:var(--color-accent)]'\n : 'font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n <span\n style={{ backgroundColor: o.brandColor || ORG_PILL_DEFAULT }}\n className=\"flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-full text-[10px] font-bold text-[#FFFFFF]\"\n >\n {resolveOrgLogoUrl(o.logoUrl) ? (\n <img\n src={resolveOrgLogoUrl(o.logoUrl)}\n alt=\"\"\n className=\"h-full w-full object-cover\"\n />\n ) : (\n (o.name ?? 'Org').slice(0, 2).toUpperCase()\n )}\n </span>\n <span title={o.name ?? o.id} className=\"truncate\">\n {o.name ?? o.id.slice(0, 8)}\n </span>\n </button>\n )\n })}\n </div>\n </details>\n ) : (\n <button\n type=\"button\"\n onClick={org.onClick}\n style={orgCardStyle}\n title={org.name ?? undefined}\n className={`flex w-full flex-col overflow-hidden rounded-[5px] border border-[color:var(--sidebar-card-border,var(--sidebar-line,var(--line)))] bg-[color:var(--sidebar-card-bg,var(--panel-elevated))] text-left text-[color:var(--sidebar-text,var(--foreground))] transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))] ${rc('max-md:w-auto max-md:items-center max-md:overflow-visible max-md:border-0 max-md:bg-transparent')}`}\n >\n <OrgIconMark org={org} logoSrc={orgLogoSrc} />\n <span className={`relative flex h-[var(--sidebar-org-band-height,70px)] w-full items-center justify-center bg-[#FFFFFF] px-3 py-[7px] ${rc('max-md:hidden')}`}>\n {orgLogoSrc ? (\n <img src={orgLogoSrc} alt=\"\" className=\"max-h-full max-w-[132px] object-contain\" />\n ) : org.canUploadLogo ? (\n <a\n href={org.uploadLogoHref ?? '#'}\n onClick={(e) => e.stopPropagation()}\n className=\"text-xs font-semibold text-[color:var(--color-accent)] underline\"\n >\n Upload logo\n </a>\n ) : (\n <span className=\"truncate text-sm font-semibold text-neutral-800\">\n {org.name ?? 'Organization'}\n </span>\n )}\n <span aria-hidden className=\"absolute inset-x-0 bottom-0 h-[3px]\" style={{ backgroundImage: orgGradient }} />\n </span>\n <span className={`flex w-full min-w-0 items-center justify-between gap-[9px] px-[10px] py-[10px] ${rc('max-md:hidden')}`}>\n <span className=\"flex min-w-0 flex-col\">\n <span\n title={org.name ?? undefined}\n className=\"truncate text-[12px] font-semibold leading-[1.2]\"\n >\n {org.name ?? 'No organizations'}\n </span>\n {org.id && !org.loading ? <OrgIdCopyButton id={org.id} /> : null}\n </span>\n <ChevronDown size={14} />\n </span>\n </button>\n )}\n </div>\n ) : null}\n\n {/* Mode selector — Reference/UI-Platform: \"A row of three icon buttons\n — Relationship · Campaign · Petition — under the org card, never a\n dropdown, with the current mode's name beneath.\" Identical in every\n app, mode-scoped apps included: the app's own mode is selected and\n the other available modes navigate to that mode's landing page. */}\n {mode ? (\n <div className={rc('max-md:w-full')}>\n <div\n role=\"radiogroup\"\n aria-label=\"Mode\"\n className={`flex w-full items-center gap-1 rounded-lg border border-[color:var(--border-inverse,var(--sidebar-line,var(--line)))] bg-[color:var(--mode-track-bg,var(--panel-elevated))] p-[3px] ${rc('max-md:flex-col max-md:items-stretch')}`}\n >\n {(mode.options && mode.options.length > 0 ? mode.options : [{ id: mode.label, label: mode.label, icon: ModeIcon }]).map(\n (opt) => {\n const selected = opt.label === mode.label\n const OptIcon = opt.icon\n const available = opt.available ?? true\n const title = !available\n ? opt.unavailableTooltip ?? `${opt.label} isn't active for this organization.`\n : opt.label\n return (\n <button\n key={opt.id}\n type=\"button\"\n role=\"radio\"\n title={title}\n aria-label={title}\n aria-checked={selected}\n aria-current={selected ? 'true' : undefined}\n onClick={() => {\n if (available && !selected) mode.onSelect?.(opt.id)\n }}\n disabled={!available}\n className={[\n `flex flex-none items-center justify-center rounded-[5px] px-[9px] py-[6px] transition ${rc('max-md:flex-1')}`,\n !available\n ? 'cursor-not-allowed text-[color:var(--sidebar-text-muted,var(--muted))] opacity-35'\n : selected\n ? 'bg-[color:var(--sidebar-mode-selected-bg,var(--mode-accent,var(--color-accent)))] text-[color:var(--mode-on-accent,white)]'\n : 'text-[color:var(--sidebar-text-muted,var(--muted))] hover:bg-[#FFFFFF]/5 hover:text-[color:var(--sidebar-text,var(--foreground))]',\n ].join(' ')}\n >\n {OptIcon ? <OptIcon size={15} className=\"shrink-0\" /> : null}\n </button>\n )\n },\n )}\n </div>\n {/* Sentence-case caption, left-aligned under the switcher\n (\"Relationship mode\") — Specs/Contacts design rail. */}\n <p className={`mt-1.5 text-left text-[11px] leading-[1.2] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] ${rc('max-md:hidden')}`}>\n {modeCaption(mode.label)}\n </p>\n </div>\n ) : null}\n </div>\n\n {/* Scroll region: nav only — the header above stays put. */}\n <div className=\"flex flex-1 flex-col overflow-y-auto px-[10px] py-3\">\n {/* Nav list */}\n <nav className=\"flex flex-col gap-0.5\">\n {nav.groupLabel ? (\n <p className={`${NAV_EYEBROW_CLASS} px-2 pb-1.5 pt-1 ${rc('max-md:hidden')}`}>\n {nav.groupLabel}\n </p>\n ) : null}\n {nav.items.map((item, idx) => {\n // Section heading: groups the rows beneath it. Non-interactive and\n // not focusable, so it is skipped by tab order and never reads as a\n // dead control. Top margin except on the first row, so the groups\n // separate without a stray gap at the top of the rail.\n if (item.kind === 'section') {\n return (\n <NavSectionRow\n key={`section-${idx}-${item.label}`}\n label={item.label}\n first={idx === 0}\n />\n )\n }\n // Flattened tree: the group's children ARE the rail. See nav.flatten.\n if (nav.flatten && item.children && item.children.length > 0) {\n return item.children.map((child, i) => {\n if (child.kind === 'section') {\n return (\n <NavSectionRow\n key={`flat-section-${idx}-${i}-${child.label}`}\n label={child.label}\n first={idx === 0 && i === 0}\n />\n )\n }\n return (\n <NavRow\n key={child.href ?? `flat-${idx}-${i}-${child.label}`}\n item={child}\n active={child.href ? activeFn(pathname, child.href) : false}\n Link={Link}\n variant=\"flat\"\n />\n )\n })\n }\n // Left-Navigation §8.2: the bar is flat — no sub-menus, no\n // accordions, no chevrons. A row with children renders as one row\n // linking to its own page (or its first child's) and is active\n // whenever any page beneath it is (§11.3, by route prefix). The\n // children stay in the tree for breadcrumbs and in-page tabs.\n if (item.children && item.children.length > 0) {\n const selfActive = item.href ? activeFn(pathname, item.href) : false\n const parentActive = selfActive || hasActiveChild(item, pathname, activeFn)\n return (\n <NavRow\n key={item.href ?? groupKeyOf(item, idx)}\n item={{ ...item, href: item.href ?? firstLeafHref(item), children: undefined }}\n active={parentActive}\n Link={Link}\n />\n )\n }\n const active = item.href ? activeFn(pathname, item.href) : false\n return (\n <NavRow\n key={item.href ?? `nav-${idx}-${item.label}`}\n item={item}\n active={active}\n Link={Link}\n />\n )\n })}\n </nav>\n </div>\n\n {/* Footer — user card (account menu opens upward), then the links row,\n then the build meta (non-production only). Specs/Contacts design rail. */}\n {footer ? (\n <div className={`relative flex-shrink-0 border-t border-[color:var(--sidebar-line,var(--line))] px-[14px] py-3 ${rc('max-md:px-[10px]')}`}>\n {footer.user ? (\n <NavSidebarUserCard\n user={footer.user}\n userMenu={footer.userMenu ?? undefined}\n onSignOut={footer.onSignOut}\n />\n ) : null}\n {footer.links && footer.links.length > 0 ? (\n <div className={`flex flex-wrap items-center justify-center gap-[6px] text-[11px] leading-[1.2] ${footer.user ? 'mt-3' : ''} ${rc('max-md:hidden')}`}>\n {footer.links.map((l, i) => (\n <Fragment key={l.label}>\n {i > 0 ? <span aria-hidden className=\"text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))]\">·</span> : null}\n <a\n href={safeHref(l.href)}\n className=\"text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] hover:text-[color:var(--sidebar-text,var(--foreground))] hover:underline\"\n >\n {l.label}\n </a>\n </Fragment>\n ))}\n </div>\n ) : null}\n {footer.envLabel || footer.commit || footer.version ? (\n <div\n data-shell-meta\n className={`mt-1.5 flex flex-col items-center gap-0.5 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] text-[color:var(--sidebar-meta-text,rgba(255,255,255,0.72))] ${rc('max-md:hidden')}`}\n >\n {/* Row 1: env | commit | version — Specs/Left-Navigation §9:\n plain mono text, centered, no leading or trailing pipes. */}\n <div className=\"flex items-center gap-1.5\">\n {[\n footer.envLabel ? shortEnvLabel(footer.envLabel) : null,\n footer.commit ? footer.commit.slice(-4) : null,\n footer.version ? `v${footer.version.replace(/^v/, '')}` : null,\n ]\n .filter((v): v is string => Boolean(v))\n .map((v, i) => (\n <Fragment key={i}>\n {i > 0 ? <span>|</span> : null}\n <span>{v}</span>\n </Fragment>\n ))}\n </div>\n {/* Row 2: date | author (only when supplied) */}\n {footer.commitDate || footer.commitAuthor ? (\n <div className=\"flex items-center gap-1.5\">\n {footer.commitDate ? (\n <span>\n {new Date(footer.commitDate).toLocaleDateString(undefined, {\n month: 'short',\n day: 'numeric',\n })}\n </span>\n ) : null}\n {footer.commitDate && footer.commitAuthor ? (\n <span>|</span>\n ) : null}\n {footer.commitAuthor ? (\n <span>{footer.commitAuthor.split(/\\s+/)[0]}</span>\n ) : null}\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n ) : null}\n </aside>\n </RailCollapsibleContext.Provider>\n )\n}\n\n// Inline hamburger / close glyphs for the mobile nav drawer — no icon\n// dependency, same idiom as every other inline SVG in this file.\nfunction HamburgerIcon() {\n return (\n <svg\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\" />\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\" />\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\" />\n </svg>\n )\n}\n\n/** 14px book-open glyph for the \"Build notes\" quiet button (design). */\nfunction BookOpenIcon() {\n return (\n <svg\n width={14}\n height={14}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 7v14\" />\n <path d=\"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z\" />\n </svg>\n )\n}\n\nfunction SearchIcon({ className }: { className?: string } = {}) {\n return (\n <svg\n width={16}\n height={16}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\" />\n </svg>\n )\n}\n\nfunction CloseIcon() {\n return (\n <svg\n width={20}\n height={20}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\n// Inline chevron-down (mirrors lucide `ChevronDown`) — no icon dependency.\n// Callers may override `className` to add a rotation (used by expandable groups).\nfunction ChevronDown({ className, size = 16 }: { className?: string; size?: number } = {}) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className ?? 'shrink-0 opacity-80'}\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n )\n}\n\n// A single sidebar nav row. Renders as a routed <Link> (href) or a <button>\n// (onClick), styled identically. Inactive rows animate a left→right gradient\n// sweep on hover (matching the main app); active rows keep the solid accent.\n//\n// `variant=\"sub\"` renders the smaller child rows inside an expanded group: a\n// tighter row whose ACTIVE state is a lighter elevated surface with accent\n// text (not a solid fill — that stays reserved for top-level/parent rows,\n// exactly as the main VRM app's Chakra sidebar treats active sub-items).\n//\n// The gradient was hardcoded to the race-red 400/500 stops; it now reads the\n// token so a Mode with its own accent sweeps in its own colour. chrome.css\n// defaults it to those same two stops, so nothing moves for anyone else.\nconst NAV_HOVER_GRADIENT = 'var(--nav-hover-gradient)'\n\n// A non-interactive section heading. Groups the rows beneath it; not a control,\n// so it is not focusable and carries no hover, no aria-disabled and no role.\n//\n// Rendered at BOTH levels: an app whose routes are nested under a standard nav\n// entry (Petitions nests its whole tree under the Petition Mode row) needs its\n// sections inside the expanded group, not only at the top level.\n//\n// `first` suppresses the leading margin so a rail that opens with a section\n// does not start with a gap.\n// Rail typography/geometry — Specs/Contacts design rail (Reference/UI-Platform\n// v30 → Left bar). Every token has an inline fallback so an app that is not\n// mode-scoped (white rail) keeps a sane rendering.\nconst NAV_EYEBROW_CLASS =\n 'text-[11px] font-bold uppercase leading-[1.2] tracking-[0.09em] text-[color:var(--sidebar-eyebrow,var(--sidebar-text-muted,var(--muted)))]'\nconst NAV_TOP_ICON_SIZE = 17\nconst NAV_TOP_ROW_CLASS = (active: boolean) =>\n `gap-[11px] px-[10px] py-[9px] text-[13px] leading-none ${active ? 'font-semibold' : 'font-normal'}`\nconst NAV_TOP_ACTIVE_CLASS =\n 'bg-[color:var(--sidebar-active-bg,var(--color-accent))] text-[color:var(--sidebar-active-text,white)]'\nconst NAV_TOP_INACTIVE_CLASS =\n 'text-[color:var(--sidebar-row-text,var(--sidebar-text,var(--muted)))] hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel-elevated))] hover:text-[color:var(--sidebar-text,var(--foreground))]'\n\n/** \"Relationship Mode\" → \"Relationship mode\" (design caption is sentence case). */\nfunction modeCaption(label: string): string {\n return label.replace(/\\s+Mode$/i, ' mode')\n}\n\n/** 2px inset rail on the active row, in the Mode accent (design: inset 2px 0 0 0). */\nfunction NavActiveRail() {\n // `--mode-accent` is only set by a declared Mode chrome group; the inline\n // `transparent` fallback is what every other app gets — present but\n // invisible, and absolutely positioned so it moves nothing.\n return (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-0 left-0 w-[2px]\"\n style={{ background: 'var(--mode-accent, transparent)' }}\n />\n )\n}\n\n/** Right-aligned mono count on a nav row (`Contacts · 31.9K`). */\nfunction NavRowBadge({ value }: { value?: string | number | null }) {\n const rc = useRailCollapse()\n if (value === undefined || value === null || value === '') return null\n return (\n <span className={`ml-auto shrink-0 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] font-semibold leading-none text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] ${rc('max-md:hidden')}`}>\n {value}\n </span>\n )\n}\n\nfunction NavSectionRow({\n label,\n first,\n variant = 'top',\n}: {\n label: string\n first: boolean\n variant?: 'top' | 'sub'\n}) {\n const rc = useRailCollapse()\n // Collapsed rail: the eyebrow becomes a 1px divider (Left-Navigation §11.6).\n // The label stays in the DOM so it is still a heading for screen readers.\n const collapsed =\n variant === 'sub'\n ? ''\n : first\n ? rc('max-md:sr-only')\n : rc(\n 'max-md:mx-2 max-md:my-2 max-md:h-px max-md:overflow-hidden max-md:bg-[color:var(--sidebar-line,var(--line))] max-md:p-0 max-md:text-transparent',\n )\n return (\n <p\n className={[\n NAV_EYEBROW_CLASS,\n variant === 'sub' ? 'px-3 pb-0.5' : 'px-2 pb-1.5 pt-1',\n first ? '' : variant === 'sub' ? 'mt-3' : 'mt-[14px]',\n collapsed,\n ].join(' ')}\n >\n {label}\n </p>\n )\n}\n\nfunction NavRow({\n item,\n active,\n Link,\n variant = 'top',\n}: {\n item: NavItem\n active: boolean\n Link: NavLinkComponent\n variant?: 'top' | 'sub' | 'flat'\n}) {\n const rc = useRailCollapse()\n const Icon = item.icon\n const isSub = variant === 'sub'\n // 'flat' rows keep top-level geometry but take the wash active treatment —\n // tinted surface + accent text — the way V1's full-height rail rows did,\n // rather than the solid fill reserved for parent rows.\n const washActive = variant !== 'top'\n // The active sub-row surface follows the Mode when one is declared.\n //\n // The fallback is INLINE, and has to be. `--mode-accent-surface` is only ever\n // set inside `[data-politogy-mode]`, so an app that is not mode-scoped never\n // has it — and a bare `var(--x)` with no fallback is invalid at\n // computed-value time, which would drop `background-color` all the way to\n // `transparent` and silently delete the active highlight for Contacts, Forms,\n // Surveys and Polls. Nor can the fallback be hoisted into a `:root`\n // declaration: `.dark` is a separate top-level selector here, so a `:root`\n // alias would freeze the LIGHT `--panel-elevated` and inherit it into dark.\n // Resolving at the point of use is the only placement that is correct in both\n // themes, scoped and unscoped.\n const activeClasses = washActive\n ? 'bg-[color:var(--mode-accent-surface,var(--panel-elevated))] text-[color:var(--color-accent)] shadow-sm'\n : NAV_TOP_ACTIVE_CLASS\n const wrapperClasses = [\n 'group relative block overflow-hidden transition',\n isSub ? 'rounded-md' : 'rounded-[5px]',\n active ? activeClasses : isSub ? 'text-[color:var(--sidebar-text,var(--muted))] hover:text-[#FFFFFF]' : NAV_TOP_INACTIVE_CLASS,\n ].join(' ')\n\n const rowPadding = isSub ? 'gap-3 px-3 py-1.5 text-[13px] font-semibold' : NAV_TOP_ROW_CLASS(active)\n const iconSize = isSub ? 16 : NAV_TOP_ICON_SIZE\n // Glyphs inherit the row's text color in every variant.\n const iconClass = 'text-current'\n\n const inner = (\n <>\n {!active ? (\n // Sub rows keep the left→right gradient sweep; top-level rows take a\n // flat wash on hover (design rail: rgba(255,255,255,.05)).\n isSub ? (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-0 left-0 w-0 transition-[width] duration-300 group-hover:w-full\"\n style={{ background: NAV_HOVER_GRADIENT }}\n />\n ) : null\n ) : (\n <NavActiveRail />\n )}\n <span className={`relative z-10 flex items-center ${rowPadding} ${rc('max-md:justify-center max-md:px-0')}`}>\n {Icon ? (\n <Icon size={iconSize} className={`shrink-0 ${iconClass}`} />\n ) : (\n // A row with no glyph still needs something on the icon rail.\n <span aria-hidden className={`hidden text-[11px] font-semibold uppercase ${rc('max-md:inline')}`}>\n {item.label.slice(0, 2)}\n </span>\n )}\n <span className={`min-w-0 flex-1 truncate ${rc('max-md:hidden')}`}>{item.label}</span>\n <NavRowBadge value={item.badge} />\n </span>\n </>\n )\n\n // A gated row renders as a non-interactive span: dimmed, not focusable, and\n // carrying its reason as a tooltip. Same treatment a disabled NavTab gets, so\n // gating reads identically in the sidebar and in a tab strip.\n if (item.disabled) {\n return (\n <span\n aria-disabled=\"true\"\n title={item.disabledTitle ?? item.label}\n className={`${wrapperClasses} cursor-not-allowed opacity-50`}\n >\n {inner}\n </span>\n )\n }\n\n if (item.onClick && !item.href) {\n return (\n <button\n type=\"button\"\n onClick={item.onClick}\n title={item.label}\n className={`w-full text-left ${wrapperClasses}`}\n >\n {inner}\n </button>\n )\n }\n\n return (\n <Link\n href={item.href ?? '#'}\n aria-current={active ? 'page' : undefined}\n // The tooltip names the row; on the collapsed rail it is also the\n // row's accessible name, since the label is not displayed.\n title={item.label}\n className={wrapperClasses}\n >\n {inner}\n </Link>\n )\n}\n\n// An expandable nav GROUP: a toggle header + a collapsible list of child rows.\n// Faithful twin of the main VRM app's Chakra accordion (Sidebar.tsx /\n// NavItem.tsx):\n// - Clicking the header toggles the children — it never navigates, even when\n// the group carries an `href`.\n// - A right-aligned chevron rotates 180° when open.\n// - The header goes solid accent (white text) when the group owns the active\n// route (its own href OR any child), matching top-level active rows; when\n// merely open it lifts onto the `--panel` surface; otherwise it's a muted row\n// with the same left→right gradient hover sweep as every other nav row.\n// - Children sit on the lighter `--panel` surface, indented and rounded, each\n// rendered through the SAME injected LinkComponent (or as a button for\n// `onClick` children) via <NavRow variant=\"sub\" />.\nfunction NavGroup({\n item,\n active,\n open,\n onToggle,\n pathname,\n activeFn,\n Link,\n}: {\n item: NavItem\n active: boolean\n open: boolean\n onToggle: () => void\n pathname: string\n activeFn: (pathname: string, href: string) => boolean\n Link: NavLinkComponent\n}) {\n const rc = useRailCollapse()\n const Icon = item.icon\n const headerClasses = [\n 'group relative block w-full overflow-hidden text-left transition',\n open ? 'rounded-t-[5px]' : 'rounded-[5px]',\n active\n ? NAV_TOP_ACTIVE_CLASS\n : open\n ? 'bg-[color:var(--sidebar-row-hover-bg,var(--panel))] text-[color:var(--sidebar-text,var(--foreground))]'\n : NAV_TOP_INACTIVE_CLASS,\n ].join(' ')\n\n return (\n <div>\n <button\n type=\"button\"\n // A group header ALWAYS toggles. When the item also carries its own\n // onClick, that runs too — so a parent can navigate to its section\n // dashboard (e.g. Email Broadcast → /relationship/email/dashboard) and\n // expand in one click. Existing apps pass no parent onClick, so their\n // behavior is unchanged (shell-nav-handoff §2).\n onClick={() => {\n onToggle()\n item.onClick?.()\n }}\n aria-expanded={open}\n title={item.label}\n className={headerClasses}\n >\n {active ? <NavActiveRail /> : null}\n <span className={`relative z-10 flex items-center ${NAV_TOP_ROW_CLASS(active)} ${rc('max-md:justify-center max-md:px-0')}`}>\n {Icon ? (\n <Icon size={NAV_TOP_ICON_SIZE} className=\"shrink-0 text-current\" />\n ) : null}\n <span className={`min-w-0 flex-1 truncate ${rc('max-md:hidden')}`}>{item.label}</span>\n <NavRowBadge value={item.badge} />\n <ChevronDown\n className={[\n 'shrink-0 opacity-80 transition-transform duration-200',\n open ? 'rotate-180' : '',\n rc('max-md:hidden'),\n ].join(' ')}\n />\n </span>\n </button>\n\n {open ? (\n <div className={`overflow-hidden rounded-b-md bg-[color:var(--nav-submenu-bg)] p-1 ${rc('max-md:hidden')}`}>\n <div className=\"flex flex-col gap-0.5\">\n {item.children!.map((child, i) => {\n if (child.kind === 'section') {\n return (\n <NavSectionRow\n key={`sub-section-${i}-${child.label}`}\n label={child.label}\n first={i === 0}\n variant=\"sub\"\n />\n )\n }\n const childActive = child.href ? activeFn(pathname, child.href) : false\n // Depth-3: a child that carries its own children renders as a\n // NESTED collapsible sub-group (e.g. Organization Settings →\n // Subscription & Billing → Wallet). Deeper levels are not\n // rendered — three is the platform maximum.\n if (child.children && child.children.length > 0) {\n return (\n <NavSubGroup\n key={child.href ?? `subgrp-${i}-${child.label}`}\n item={child}\n pathname={pathname}\n activeFn={activeFn}\n Link={Link}\n />\n )\n }\n return (\n <NavRow\n key={child.href ?? `sub-${i}-${child.label}`}\n item={child}\n active={childActive}\n Link={Link}\n variant=\"sub\"\n />\n )\n })}\n </div>\n </div>\n ) : null}\n </div>\n )\n}\n\n// A second-level group INSIDE an expanded group — the depth-3 renderer\n// (Reference/UI-Platform: sub-sub items). Auto-expands when it owns the active\n// route; otherwise toggles locally. Grandchildren render as further-indented\n// sub rows on the same panel surface.\nfunction NavSubGroup({\n item,\n pathname,\n activeFn,\n Link,\n}: {\n item: NavItem\n pathname: string\n activeFn: (pathname: string, href: string) => boolean\n Link: NavLinkComponent\n}) {\n const ownsActive =\n (item.href ? activeFn(pathname, item.href) : false) ||\n (item.children ?? []).some((c) => (c.href ? activeFn(pathname, c.href) : false))\n const [open, setOpen] = useState(ownsActive)\n useEffect(() => {\n if (ownsActive) setOpen(true)\n }, [ownsActive])\n const Icon = item.icon\n\n return (\n <div>\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-expanded={open}\n className={[\n 'flex w-full items-center gap-2.5 rounded px-3 py-1.5 text-left text-[13px] font-medium transition',\n ownsActive\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--sidebar-text,var(--muted))] hover:bg-[color:var(--nav-row-hover)] hover:text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {Icon ? <Icon size={15} className=\"shrink-0 text-current\" /> : null}\n <span className=\"flex-1\">{item.label}</span>\n <ChevronDown\n className={[\n 'shrink-0 opacity-70 transition-transform duration-200',\n open ? 'rotate-180' : '',\n ].join(' ')}\n />\n </button>\n {open ? (\n <div className=\"ml-4 flex flex-col gap-0.5 border-l border-[color:var(--line)] pl-2\">\n {item.children!.map((leaf, i) => (\n <NavRow\n key={leaf.href ?? `subsub-${i}-${leaf.label}`}\n item={leaf}\n active={leaf.href ? activeFn(pathname, leaf.href) : false}\n Link={Link}\n variant=\"sub\"\n />\n ))}\n </div>\n ) : null}\n </div>\n )\n}\n\n// Right-aligned copy affordance for the org id, shown beside the \"Organization\"\n// label. Copies the full id and briefly swaps its text to \"Copied\".\nfunction OrgIdCopyButton({ id }: { id: string }) {\n const [copied, setCopied] = useState(false)\n return (\n <button\n type=\"button\"\n onClick={() => {\n try {\n void navigator.clipboard?.writeText(id)\n } catch {\n /* clipboard unavailable — ignore */\n }\n setCopied(true)\n setTimeout(() => setCopied(false), 1500)\n }}\n title=\"Copy organization id\"\n className=\"-ml-1 rounded px-1 text-left font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[12px] leading-[1.2] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))]\"\n >\n {copied ? 'Copied' : `…${id.slice(-8)}`}\n </button>\n )\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavUser = {\n name: string | null\n email?: string | null\n /** Profile PHOTO url — highest-precedence avatar source. */\n avatarUrl?: string | null\n /** Memoji url — used when no photo is set; falls back to initials. */\n memojiUrl?: string | null\n tier?: string | null\n role?: string | null\n}\n\nexport type NavTopBarAction = {\n key: string\n /**\n * Canonical top-bar slot. When set, the glyph is sourced by NAME from the\n * Brand API via `--topbar-icon-<slot>`; `icon` becomes the fallback used\n * until the runtime Brand stylesheet lands (or when the token is unset).\n */\n slot?: TopBarIconSlot\n icon: NavIcon\n label: string\n onClick?: () => void\n href?: string\n badge?: number | null\n tone?: 'default' | 'warning' | 'danger'\n /** Tooltip body shown under the icon (label is the tooltip title). */\n description?: string\n}\n\nexport type NavLinkedAccount = {\n id: string\n name: string | null\n email?: string | null\n avatarUrl?: string | null\n active?: boolean\n}\n\nexport type NavRoleBadge = {\n role: string\n orgName?: string | null\n}\n\n/**\n * The My Account menu (avatar dropdown) — mirrors the main VRM app's user\n * menu: My Profile / Organization Settings links, a ROLES & ORGANIZATIONS\n * section, an ACCOUNTS switcher, an optional theme control, then Sign out.\n * Every section renders only when its data is supplied.\n */\nexport type NavUserMenu = {\n myProfileHref?: string\n organizationSettingsHref?: string\n roles?: NavRoleBadge[]\n accounts?: NavLinkedAccount[]\n onSwitchAccount?: (id: string) => void\n onRemoveAccount?: (id: string) => void\n addAccountHref?: string\n onAddAccount?: () => void\n /**\n * Navigation display (Sub Menu / Tabs Only / Both) — lives in the account\n * menu since 0.68.0; the top-bar `NavDisplayAction` popover is retired from\n * the standard cluster (design: 4 icon buttons + Help).\n */\n navDisplay?: {\n value: NavDisplayMode\n onChange: (next: NavDisplayMode) => void\n }\n /** Theme preference segmented control (Light / System / Dark). */\n theme?: {\n value: ThemePreference\n onChange: (next: ThemePreference) => void\n }\n}\n\nexport type NavBreadcrumb = {\n label: string\n href?: string\n}\n\nexport type NavTopBarProps = {\n /**\n * Chrome-owned page title line (`<h1>` above main). Omit when the page body\n * owns its own title (registry `pageTitle: false`, e.g. Contacts).\n */\n title?: string\n subtitle?: string\n /**\n * Breadcrumb trail rendered UNDER the page title (Reference/UI-Platform:\n * every page and sub-page/tab shows its location). Last crumb = current\n * location (non-link); earlier crumbs may carry hrefs.\n */\n breadcrumbs?: NavBreadcrumb[]\n user?: NavUser | null\n userMenu?: NavUserMenu\n onSignOut?: () => void\n /**\n * Structured icon-button action cluster (32×32 circular buttons with optional\n * count badges), rendered before the `actions` slot. Matches the main app's\n * topbar action icons.\n */\n actionsList?: NavTopBarAction[]\n /** App-specific action cluster rendered left of the theme toggle. */\n actions?: ReactNode\n /** Theme toggle slot (injected so this package needs no theme dependency). */\n themeToggle?: ReactNode\n /**\n * Mobile drawer trigger (owned by `NavAppShell`). Supplying it renders a\n * hamburger button, hidden at `lg` and up, as the first thing in the header\n * — below `lg` the sidebar is otherwise unreachable. Omit to render no\n * hamburger at all (e.g. `NavTopBar` used standalone).\n */\n onOpenNav?: () => void\n /** Whether the drawer `onOpenNav` opens is currently open (drives `aria-expanded`). */\n navOpen?: boolean\n /**\n * Universal search — Reference/UI-Platform \"Top bar → required elements\":\n * the search field, 320px wide, at the left end of the bar; nothing else\n * sits on the left. Omit `onChange`/`onSubmit` for a decorative field (an\n * app that has not wired search yet still gets the correct chrome).\n */\n search?: {\n placeholder?: string\n value?: string\n onChange?: (value: string) => void\n onSubmit?: (value: string) => void\n }\n /**\n * Build notes — a quiet text button that starts the right-hand group\n * (Reference/UI-Platform \"Top bar → required elements\").\n */\n /**\n * Where the My Account trigger lives. `'topbar'` (default for a standalone\n * `NavTopBar`) keeps the avatar + name + chevron at the right end of the bar;\n * `'sidebar'` / `'none'` hide it here — `NavAppShell` passes `'sidebar'` and\n * draws the user card in the left-bar footer instead (UI-Platform v30:\n * \"There is no My Account badge in the top bar\").\n */\n accountMenu?: 'topbar' | 'sidebar' | 'none'\n buildNotes?: {\n label?: string\n onOpen?: () => void\n }\n}\n\nexport function NavTopBar({\n title,\n subtitle,\n breadcrumbs,\n user,\n userMenu,\n onSignOut,\n actionsList,\n actions,\n themeToggle,\n onOpenNav,\n navOpen,\n search,\n buildNotes,\n accountMenu = 'topbar',\n}: NavTopBarProps) {\n // Real name = anything that isn't empty and isn't an email address. The\n // trigger shows \"First L.\" — never the email on both lines.\n const rawName = user?.name?.trim() || ''\n const hasRealName = rawName.length > 0 && !rawName.includes('@')\n const displayName = hasRealName ? formatFirstLast(rawName) : (user?.email ?? 'Signed in')\n const initials = (hasRealName ? rawName : (user?.email ?? 'P')).slice(0, 2).toUpperCase()\n const secondary = hasRealName\n ? user?.email || [user?.tier, user?.role].filter(Boolean).join(' · ') || 'member'\n : [user?.tier, user?.role].filter(Boolean).join(' · ') || 'member'\n // `title` / `subtitle` / `breadcrumbs` are no longer rendered here —\n // Reference/UI-Platform \"Page header\" moved the title into the main body\n // (22px below this bar) and retired the breadcrumb trail entirely. They\n // stay accepted on the prop type so apps mid-migration do not break the\n // build; the chrome just stops drawing them.\n void title\n void subtitle\n void breadcrumbs\n return (\n <div className=\"sticky top-0 z-20\">\n <header className=\"flex min-w-0 h-[var(--topbar-height,60px)] items-center justify-between gap-[8px] md:gap-[14px] border-b border-[color:var(--line)] bg-[color:var(--panel)] px-[var(--topbar-padding-x,20px)]\">\n {onOpenNav ? (\n <button\n type=\"button\"\n onClick={onOpenNav}\n aria-label=\"Open menu\"\n aria-expanded={navOpen ?? false}\n aria-controls=\"politogy-nav-drawer\"\n className={`${topBarIconButtonClass('default')} mr-1 shrink-0 md:hidden`}\n >\n <HamburgerIcon />\n </button>\n ) : null}\n\n {/* Universal search — the only thing on the left end of the bar. 320px\n (Reference/UI-Platform); below md it shrinks so the bar never pushes\n the page wider than a 390px phone. */}\n <label className=\"relative flex h-9 w-[320px] min-w-0 max-w-full shrink items-center md:shrink-0\">\n <SearchIcon className=\"pointer-events-none absolute left-[10px] h-[15px] w-[15px] text-[color:var(--muted)]\" />\n <input\n type=\"search\"\n placeholder={search?.placeholder ?? 'Search'}\n value={search?.value}\n onChange={search?.onChange ? (e) => search.onChange?.(e.target.value) : undefined}\n onKeyDown={\n search?.onSubmit\n ? (e) => {\n if (e.key === 'Enter') search.onSubmit?.((e.target as HTMLInputElement).value)\n }\n : undefined\n }\n readOnly={!search?.onChange}\n className=\"h-full w-full rounded-[5px] border border-[color:var(--line)] bg-[color:var(--surface-sunken,var(--panel-elevated))] pl-[33px] pr-10 text-[13px] text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n <kbd\n aria-hidden\n className=\"pointer-events-none absolute right-[10px] hidden md:block rounded-[3px] border border-[color:var(--line)] px-[5px] py-px font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[12px] leading-[1.2] text-[color:var(--muted)]\"\n >\n /\n </kbd>\n </label>\n\n <div className=\"relative ml-auto flex shrink-0 items-center gap-[var(--topbar-icon-gap,8px)]\">\n {/* Reference/UI-Platform \"Top bar — required elements\" (2026-10-03):\n there is no Build notes control. Rendered only if an app opts in. */}\n {buildNotes ? (\n <button\n type=\"button\"\n onClick={buildNotes?.onOpen}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[5px] px-3 text-xs font-semibold text-[color:var(--muted)] transition hover:bg-[color:var(--surface-sunken,var(--panel-elevated))] hover:text-[color:var(--foreground)]\"\n >\n <BookOpenIcon />\n {buildNotes?.label ?? 'Build notes'}\n </button>\n ) : null}\n {actionsList && actionsList.length > 0\n ? actionsList.map((action) => (\n <NavTopBarActionButton key={action.key} action={action} />\n ))\n : null}\n {actions}\n {themeToggle}\n\n {/* My Account menu — avatar + name/email + chevron trigger, with the\n full account dropdown (profile/org links, roles, account switcher,\n appearance, sign out). Native <details> popover. Hidden when the\n shell draws the user card in the left-bar footer instead. */}\n {accountMenu === 'topbar' ? (\n <details data-nav-details className=\"group/acct relative\">\n <summary className=\"group/tbtip relative flex cursor-pointer list-none items-center gap-2.5 rounded-full py-1 pl-1 pr-2 transition hover:bg-[color:var(--panel-elevated)] [&::-webkit-details-marker]:hidden\">\n {/* Same circle size as every top-bar icon button (one shared var).\n Avatar precedence: photo → memoji → initials. */}\n <span className=\"flex h-[var(--topbar-icon-button-size,32px)] w-[var(--topbar-icon-button-size,32px)] items-center justify-center overflow-hidden rounded-full bg-[color:var(--color-accent)] text-xs font-bold text-[#FFFFFF]\">\n {user?.avatarUrl || user?.memojiUrl ? (\n <img\n src={(user.avatarUrl || user.memojiUrl) as string}\n alt=\"\"\n className=\"h-full w-full object-cover\"\n />\n ) : (\n initials\n )}\n </span>\n <span className=\"hidden flex-col leading-tight md:flex\">\n <span className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {displayName}\n </span>\n <span className=\"text-xs text-[color:var(--muted)]\">{secondary}</span>\n </span>\n <ChevronDown />\n <span className=\"group-open/acct:hidden\">\n <TopBarTooltip\n title=\"My Account\"\n description={\n <>\n {hasRealName ? rawName : user?.email ?? 'Signed in'}\n {user?.email ? (\n <>\n <br />\n {user.email}\n </>\n ) : null}\n <br />\n Profile, organizations, appearance and sign out.\n </>\n }\n />\n </span>\n </summary>\n {/*\n The menu grows with the user's data — roles, linked accounts, the\n theme control — and on a short viewport (or a user in many orgs) it\n ran past the bottom of the screen with no way to scroll, putting\n Sign out permanently out of reach. Cap the panel at the viewport,\n scroll the SECTIONS, and keep Sign out outside that scroll area so\n it is always on screen no matter how long the list gets.\n */}\n <NavAccountMenuPanel userMenu={userMenu} onSignOut={onSignOut} placement=\"below\" />\n </details>\n ) : null}\n {accountMenu === 'topbar' && !hasRealName && user ? (\n <NamePromptBubble profileHref={userMenu?.myProfileHref} />\n ) : null}\n </div>\n </header>\n {/* Brand gradient rule — Reference/UI-Platform \"Top bar → required\n elements\": \"A 3px strip of the brand gradient (blue → red) runs\n directly beneath it.\" Chrome-owned token, never the party-identity\n race-red. */}\n <div\n aria-hidden\n className=\"h-[3px] w-full shrink-0\"\n style={{\n background:\n 'var(--chrome-gradient, linear-gradient(to right, #007BFF, #A54B7A, #E63946))',\n }}\n />\n </div>\n )\n}\n\n/**\n * The account menu body — profile/org links, roles, account switcher,\n * appearance, navigation display, sign out. One definition drawn from two\n * triggers: the top-bar avatar (`placement=\"below\"`, legacy) and the left-bar\n * footer user card (`placement=\"above\"`, Reference/UI-Platform v30).\n */\nfunction NavAccountMenuPanel({\n userMenu,\n onSignOut,\n placement,\n}: {\n userMenu?: NavUserMenu\n onSignOut?: () => void\n placement: 'below' | 'above'\n}) {\n const rc = useRailCollapse()\n const wrapper =\n placement === 'above'\n ? rc('max-md:right-auto max-md:w-64') + ' absolute bottom-full left-0 right-0 z-40 mb-2 flex max-h-[calc(100vh-5rem)] flex-col overflow-hidden rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 text-[color:var(--foreground)] shadow-[var(--shadow-soft)]'\n : 'absolute right-0 z-30 mt-2 flex max-h-[calc(100vh-5rem)] w-72 flex-col overflow-hidden rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 shadow-[var(--shadow-soft)]'\n return (\n <div className={wrapper}>\n {placement === 'below' ? <TopBarPanelArrow /> : null}\n <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain\">\n {userMenu?.myProfileHref ? (\n <a\n href={safeHref(userMenu.myProfileHref)}\n className=\"flex w-full items-center gap-2.5 px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n <ProfileIcon />\n My Profile\n </a>\n ) : null}\n {userMenu?.organizationSettingsHref ? (\n <a\n href={safeHref(userMenu.organizationSettingsHref)}\n className=\"flex w-full items-center gap-2.5 border-t border-[color:var(--line)] px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n <BriefcaseIcon />\n Organization Settings\n </a>\n ) : null}\n\n {userMenu?.roles && userMenu.roles.length > 0 ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Roles & Organizations\n </p>\n <ul className=\"flex flex-col gap-1.5\">\n {userMenu.roles.map((r, i) => (\n <li key={`${r.role}-${i}`} className=\"flex flex-wrap items-center gap-1.5 text-sm\">\n <span className=\"rounded-md bg-[color:var(--panel)] px-2 py-0.5 text-xs font-bold uppercase tracking-wide text-[color:var(--foreground)]\">\n {r.role}\n </span>\n {r.orgName ? (\n <span className=\"text-[color:var(--muted)]\">in {r.orgName}</span>\n ) : null}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {userMenu?.accounts && userMenu.accounts.length > 0 ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Accounts\n </p>\n <ul className=\"flex flex-col gap-1\">\n {userMenu.accounts.map((a) => (\n <li key={a.id} className=\"flex items-center gap-2.5\">\n <button\n type=\"button\"\n onClick={() => {\n if (!a.active) userMenu.onSwitchAccount?.(a.id)\n }}\n className=\"flex min-w-0 flex-1 items-center gap-2.5 rounded-lg px-1 py-1 text-left hover:bg-[color:var(--panel)]\"\n >\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[color:var(--color-accent)] text-[11px] font-bold text-[#FFFFFF]\">\n {a.avatarUrl ? (\n <img src={a.avatarUrl} alt=\"\" className=\"h-full w-full object-cover\" />\n ) : (\n (a.name ?? a.email ?? '?').slice(0, 2).toUpperCase()\n )}\n </span>\n <span className=\"flex min-w-0 flex-col leading-tight\">\n <span\n className={[\n 'truncate text-sm font-semibold',\n a.active\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {a.name ?? a.email ?? a.id.slice(0, 8)}\n </span>\n <span className=\"truncate text-xs text-[color:var(--muted)]\">\n {a.active ? 'Active' : a.email ?? ''}\n </span>\n </span>\n </button>\n {!a.active && userMenu.onRemoveAccount ? (\n <button\n type=\"button\"\n aria-label={`Remove ${a.name ?? a.email ?? 'account'}`}\n onClick={() => userMenu.onRemoveAccount?.(a.id)}\n className=\"shrink-0 rounded p-1 text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <TrashIcon />\n </button>\n ) : null}\n </li>\n ))}\n </ul>\n {userMenu.addAccountHref || userMenu.onAddAccount ? (\n userMenu.addAccountHref ? (\n <a\n href={safeHref(userMenu.addAccountHref)}\n className=\"mt-1.5 flex items-center gap-2.5 rounded-lg px-1 py-1.5 text-sm font-semibold text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <AddUserIcon />\n Add Account\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={userMenu.onAddAccount}\n className=\"mt-1.5 flex w-full items-center gap-2.5 rounded-lg px-1 py-1.5 text-left text-sm font-semibold text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <AddUserIcon />\n Add Account\n </button>\n )\n ) : null}\n </div>\n ) : null}\n\n {userMenu?.theme ? (\n <div className=\"border-t border-[color:var(--line)]\">\n <NavThemeControl\n value={userMenu.theme.value}\n onChange={userMenu.theme.onChange}\n />\n </div>\n ) : null}\n {userMenu?.navDisplay ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Navigation display\n </p>\n <div role=\"radiogroup\" aria-label=\"Navigation display\" className=\"flex flex-col gap-0.5\">\n {NAV_DISPLAY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={userMenu.navDisplay?.value === opt.value}\n onClick={() => userMenu.navDisplay?.onChange(opt.value)}\n className={[\n 'flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left text-sm font-medium',\n userMenu.navDisplay?.value === opt.value\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n {opt.label}\n {userMenu.navDisplay?.value === opt.value ? <span aria-hidden>✓</span> : null}\n </button>\n ))}\n </div>\n </div>\n ) : null}\n </div>\n\n {onSignOut ? (\n <button\n type=\"button\"\n onClick={onSignOut}\n className=\"flex w-full shrink-0 items-center gap-2.5 border-t border-[color:var(--line)] px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)] hover:text-[color:var(--color-accent)]\"\n >\n <SignOutIcon />\n Sign out\n </button>\n ) : null}\n </div>\n )\n}\n\n/**\n * Left-bar footer user card: 28px avatar · name · email · chevron-up. Opens\n * the account menu upward (Specs/Contacts design rail; UI-Platform v30 →\n * \"The user … lives in the left bar footer\").\n */\nfunction NavSidebarUserCard({\n user,\n userMenu,\n onSignOut,\n}: {\n user: NavUser\n userMenu?: NavUserMenu\n onSignOut?: () => void\n}) {\n const rawName = user.name?.trim() || ''\n const hasRealName = rawName.length > 0 && !rawName.includes('@')\n // Left-Navigation §10: \"First L.\" — first name plus last initial.\n const displayName = hasRealName ? shortUserName(rawName) : (user.email ?? 'Signed in')\n const initials = hasRealName\n ? rawName.split(/\\s+/).filter(Boolean).slice(0, 2).map((w) => w[0]).join('').toUpperCase()\n : (user.email ?? 'P').slice(0, 2).toUpperCase()\n const secondary = hasRealName\n ? user.email || [user.tier, user.role].filter(Boolean).join(' · ') || 'member'\n : [user.tier, user.role].filter(Boolean).join(' · ') || 'member'\n const rc = useRailCollapse()\n return (\n <details data-nav-details className=\"group/acct relative\">\n <summary\n aria-label=\"My Account\"\n className={`flex w-full cursor-pointer list-none items-center gap-[9px] rounded-[5px] px-1 py-1 text-left transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel-elevated))] [&::-webkit-details-marker]:hidden ${rc('max-md:justify-center max-md:px-0')}`}\n >\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[color:var(--sidebar-avatar-bg,var(--color-accent))] text-[11px] font-bold text-[#FFFFFF]\">\n {user.avatarUrl || user.memojiUrl ? (\n <img src={(user.avatarUrl || user.memojiUrl) as string} alt=\"\" className=\"h-full w-full object-cover\" />\n ) : (\n initials\n )}\n </span>\n <span className={`flex min-w-0 flex-1 flex-col ${rc('max-md:hidden')}`}>\n <span className=\"truncate text-[12px] font-semibold leading-[1.2] text-[color:var(--sidebar-text,var(--foreground))]\">\n {displayName}\n </span>\n <span className=\"truncate text-[11px] leading-[1.3] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))]\">\n {secondary}\n </span>\n </span>\n <ChevronDown size={14} className={`shrink-0 rotate-180 text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] transition group-open/acct:rotate-0 ${rc('max-md:hidden')}`} />\n </summary>\n <NavAccountMenuPanel userMenu={userMenu} onSignOut={onSignOut} placement=\"above\" />\n {!hasRealName ? <NamePromptBubble profileHref={userMenu?.myProfileHref} placement=\"above\" /> : null}\n </details>\n )\n}\n\n/** `#RRGGBB` (+ optional alpha) → `rgba(r,g,b,a)`; undefined for anything else. */\nfunction hexToRgba(hex: string | null | undefined, alpha: number): string | undefined {\n if (!hex) return undefined\n const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim())\n if (!m) return undefined\n const n = parseInt(m[1], 16)\n return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`\n}\n\n/**\n * Floating, per-session-dismissable bubble under the account trigger that\n * prompts a user with no display name to set their first + last name. The\n * arrow points up at the avatar; dismissal is remembered in sessionStorage\n * until they actually set a name.\n */\nfunction NamePromptBubble({ profileHref, placement = 'below' }: { profileHref?: string; placement?: 'below' | 'above' }) {\n const KEY = 'politogy_name_prompt_dismissed'\n const [dismissed, setDismissed] = useState(true)\n useEffect(() => {\n try {\n setDismissed(sessionStorage.getItem(KEY) === '1')\n } catch {\n setDismissed(false)\n }\n }, [])\n if (dismissed) return null\n return (\n <div\n className={\n placement === 'above'\n ? 'absolute bottom-full left-0 z-30 mb-2 w-64 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-3 text-left shadow-[var(--shadow-soft)]'\n : 'absolute right-4 top-full z-30 mt-2 w-64 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-3 shadow-[var(--shadow-soft)]'\n }\n >\n <span\n aria-hidden\n className={\n placement === 'above'\n ? 'absolute -bottom-[5px] left-[14px] h-2.5 w-2.5 rotate-45 border-b border-r border-[color:var(--line)] bg-[color:var(--panel-elevated)]'\n : 'absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]'\n }\n />\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n Add your name\n </p>\n <p className=\"mt-0.5 text-xs leading-snug text-[color:var(--muted)]\">\n Set your first and last name so teammates see you — not your email.\n </p>\n <div className=\"mt-2 flex items-center gap-2\">\n {profileHref ? (\n <a\n href={safeHref(profileHref)}\n className=\"rounded-full bg-[color:var(--color-accent)] px-3 py-1 text-xs font-semibold text-[#FFFFFF] hover:opacity-90\"\n >\n Set name\n </a>\n ) : null}\n <button\n type=\"button\"\n onClick={() => {\n setDismissed(true)\n try {\n sessionStorage.setItem(KEY, '1')\n } catch {\n /* session-only dismiss */\n }\n }}\n className=\"rounded-full border border-[color:var(--line)] px-3 py-1 text-xs font-semibold text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n Dismiss\n </button>\n </div>\n </div>\n )\n}\n\n/** \"Spencer Hill\" → \"Spencer H.\" — first name + last initial. */\nfunction formatFirstLast(name: string): string {\n const parts = name.split(/\\s+/).filter(Boolean)\n if (parts.length === 1) return parts[0]\n return `${parts[0]} ${parts[parts.length - 1][0].toUpperCase()}.`\n}\n\nfunction ProfileIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\" />\n <circle cx=\"12\" cy=\"7\" r=\"4\" />\n </svg>\n )\n}\n\nfunction BriefcaseIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"14\" rx=\"2\" ry=\"2\" />\n <path d=\"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16\" />\n </svg>\n )\n}\n\nfunction TrashIcon() {\n return (\n <svg width={14} height={14} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <polyline points=\"3 6 5 6 21 6\" />\n <path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\" />\n </svg>\n )\n}\n\nfunction AddUserIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2\" />\n <circle cx=\"8.5\" cy=\"7\" r=\"4\" />\n <line x1=\"20\" y1=\"8\" x2=\"20\" y2=\"14\" />\n <line x1=\"23\" y1=\"11\" x2=\"17\" y2=\"11\" />\n </svg>\n )\n}\n\n// Inline log-out glyph (mirrors lucide `LogOut`) to avoid an icon dependency.\nfunction SignOutIcon() {\n return (\n <svg\n width={15}\n height={15}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4\" />\n <polyline points=\"16 17 21 12 16 7\" />\n <line x1=\"21\" x2=\"9\" y1=\"12\" y2=\"12\" />\n </svg>\n )\n}\n\n// A single 32×32 circular icon button for the top bar's structured action list.\n// Renders an <a> when `href` is present (external links open in a new tab),\n// otherwise a <button>. Shows a red count badge when `badge > 0`.\nfunction NavTopBarActionButton({ action }: { action: NavTopBarAction }) {\n const Icon = action.icon\n // Universal treatment (Global Rules v9): size, color and hover are a single\n // shared value across every top-bar slot — only the glyph varies per slot.\n // Tone is a semantic state, not a bespoke per-slot style. The class comes\n // from the ONE shared builder in chromeActions so the data-backed widgets\n // and this structured list can never drift apart.\n const className = topBarIconButtonClass(action.tone ?? 'default')\n\n // Per-slot glyph from Brand; `icon` is the fallback until the token resolves.\n // Brand emits Feather/Lucide glyph NAMES, not asset paths.\n const glyphName = useTopBarIconSlotGlyph(action.slot ?? 'apps')\n const BrandGlyph = action.slot ? resolveBrandGlyph(glyphName) : null\n const Glyph = BrandGlyph ?? Icon\n\n const content = (\n <>\n <Glyph size={TOPBAR_GLYPH_SIZE} className=\"text-current\" />\n {typeof action.badge === 'number' && action.badge > 0 ? (\n <span className=\"absolute -top-[5px] -right-[5px] flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--chrome-danger,var(--color-accent))] px-1 text-[10px] font-bold leading-4 text-[#FFFFFF]\">\n {action.badge}\n </span>\n ) : null}\n <TopBarTooltip title={action.label} description={action.description} />\n </>\n )\n\n const isExternal = action.href ? /^https?:\\/\\//.test(action.href) : false\n\n if (action.href) {\n return (\n <a\n href={safeHref(action.href)}\n aria-label={action.label}\n className={className}\n {...(isExternal ? { target: '_blank', rel: 'noreferrer' } : {})}\n >\n {content}\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={action.onClick}\n aria-label={action.label}\n className={className}\n >\n {content}\n </button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Page tab strip — THE canonical page tab strip (shell 0.69.0).\n//\n// Brand guideline \"Tabs are an underlined strip\" (components-tabs-geometry):\n// a row of text tabs, each with an optional mono count pill, above a 1px G3\n// rule, with no folder or card chrome. Tabs are 13px semibold with 12px\n// vertical padding (12px / 8px when small). The selected tab is Graphite with\n// a 2px underline in the MODE COLOR (`modes.<mode>.primary`), read as\n// `--mode-accent` — never `modes.<mode>.accent`, which is white and only for\n// highlights on the dark rail. Unselected tabs are G4 and turn Graphite on\n// hover.\n//\n// It sits in the page body, below the page header, aligned to the content\n// gutter (Brand guideline \"UX Navigation\"). Apps render it inside the frame's\n// `children`; they never hand-roll or restyle a tab strip.\n//\n// Why this one and not the main entry's `HeaderTabBar` (now @deprecated): it\n// has no Chakra or react-router dependency, so every app can import it\n// whatever its framework; it renders `href` tabs through the app's own link\n// primitive, so sub-views are URL-addressable; and it already carries the\n// tablist / tab / disabled semantics. `HeaderTabBar` is icon-only by\n// construction (its label is only a tooltip) and state-only (no links).\n//\n// Colors come from the Brand `--tab-*` / `--color-*` vars emitted by\n// `/api/tokens?format=css`, with literal fallbacks so the strip still renders\n// before the runtime token sheet loads.\n// ---------------------------------------------------------------------------\n\nexport type NavTab = {\n /** Stable identity (used as the React key). */\n key: string\n /** The tab's visible text. */\n label: string\n /**\n * A Lucide icon rendered 6px left of the label (Reference/UI-Platform →\n * Tabs, decided 2026-10-06: \"Icon + label. Each tab is a Lucide icon.\"),\n * 15px / 1.75 stroke (13px on a small strip), following the label's\n * selected / unselected / hover color via `currentColor`. Icon-ONLY tabs\n * (no label) are retired — this always pairs with `label`.\n */\n icon?: NavIcon\n /** Optional count, drawn as a mono pill after the label. */\n count?: string | number | null\n /** Route to link to (rendered through `linkComponent`). */\n href?: string\n /** Click handler — rendered as a `<button>` when there's no `href`. */\n onSelect?: () => void\n /** Whether this tab is the active one (drives the mode-color underline). */\n selected?: boolean\n /**\n * Non-interactive, dimmed tab (e.g. Surveys' Canvas/Results before a survey\n * is chosen). Renders a non-navigating span; `disabledTitle` is the tooltip\n * explaining why.\n */\n disabled?: boolean\n disabledTitle?: string\n}\n\nexport type NavTabStripProps = {\n tabs: NavTab[]\n /** Accessible name for the tablist. */\n 'aria-label'?: string\n /** Routing primitive for `href` tabs (Next `<Link>`, etc). Defaults to <a>. */\n linkComponent?: NavLinkComponent\n /** `'sm'`: 12px text with 8px vertical padding. Default `'md'` (13px / 12px). */\n size?: 'md' | 'sm'\n /** Extra classes on the tablist container. */\n className?: string\n /**\n * Optional tab panel rendered directly below the strip, on the page\n * surface with no card chrome. Omit to render only the strip and compose\n * the page body yourself.\n */\n children?: ReactNode\n}\n\n/** The mode color on light surfaces (Reference/UI-Platform → Per-mode branding). */\nconst TAB_UNDERLINE_COLOR = 'var(--mode-accent, var(--color-accent))'\n\nfunction NavTabButton({\n tab,\n Link,\n size,\n}: {\n tab: NavTab\n Link: NavLinkComponent\n size: 'md' | 'sm'\n}) {\n const { label, icon: Icon, count, href, onSelect, selected, disabled, disabledTitle } = tab\n\n // The 2px underline sits on the strip's 1px rule (`-mb-px`), so the selected\n // tab's underline replaces the rule beneath it rather than stacking on it.\n const base =\n '-mb-px inline-flex shrink-0 items-center gap-2 border-b-2 font-semibold leading-none transition-colors'\n const sizeClass = size === 'sm' ? 'py-2 text-[12px]' : 'py-3 text-[13px]'\n const stateClass = disabled\n ? 'cursor-not-allowed border-transparent text-[color:var(--color-g4,#929599)] opacity-50'\n : selected\n ? 'text-[color:var(--tab-selected-color,#2F3136)]'\n : 'border-transparent text-[color:var(--color-g4,#929599)] hover:text-[color:var(--tab-hover-color,#2F3136)]'\n const className = `${base} ${sizeClass} ${stateClass}`\n const style: CSSProperties | undefined =\n selected && !disabled ? { borderBottomColor: TAB_UNDERLINE_COLOR } : undefined\n\n const iconSize = size === 'sm' ? 13 : 15\n const content = (\n <>\n {Icon ? (\n <Icon size={iconSize} className=\"shrink-0 text-current\" strokeWidth={1.75} />\n ) : null}\n <span>{label}</span>\n {count !== undefined && count !== null && count !== '' ? (\n <span className=\"rounded-full bg-[color:var(--color-g2,#ECEEEF)] px-1.5 py-0.5 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] font-semibold leading-none\">\n {count}\n </span>\n ) : null}\n </>\n )\n\n // Disabled: non-navigating span, still exposed as a tab for AT.\n if (disabled) {\n return (\n <span\n role=\"tab\"\n aria-selected={false}\n aria-disabled=\"true\"\n aria-label={label}\n title={disabledTitle}\n className={className}\n style={style}\n >\n {content}\n </span>\n )\n }\n\n if (href) {\n return (\n <Link\n href={href}\n role=\"tab\"\n aria-selected={selected ? true : false}\n aria-label={label}\n className={className}\n style={style}\n >\n {content}\n </Link>\n )\n }\n\n return (\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={selected ? true : false}\n aria-label={label}\n onClick={onSelect}\n className={className}\n style={style}\n >\n {content}\n </button>\n )\n}\n\n/**\n * The canonical page tab strip: underlined text tabs on a 1px rule. Render it\n * in the page body below the page header; pass the app's `Link` as\n * `linkComponent` for `href` tabs.\n */\nexport function NavTabStrip({\n tabs,\n 'aria-label': ariaLabel,\n linkComponent,\n size = 'md',\n className,\n children,\n}: NavTabStripProps) {\n const Link = linkComponent ?? DefaultLink\n return (\n <>\n <div\n role=\"tablist\"\n aria-label={ariaLabel}\n className={[\n 'flex items-end gap-[var(--tab-gap,24px)] border-b border-[color:var(--tab-border-color,#D7DADF)]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tabs.map((tab) => (\n <NavTabButton key={tab.key} tab={tab} Link={Link} size={size} />\n ))}\n </div>\n {children !== undefined ? <div className=\"pt-5\">{children}</div> : null}\n </>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Beta banner — a full-width amber NOTICE strip rendered directly below the top\n// bar (a semantic notice, not a chrome surface, so it keeps its amber hue in\n// both themes via the --beta-banner-* tokens in chrome.css). One line, centered,\n// with a bold + underlined link to the Beta Terms & Conditions.\n// ---------------------------------------------------------------------------\n\nconst BETA_BANNER_DEFAULTS = {\n text: 'Our product is in Beta. Thank you for participating in the Pilot Program. ',\n linkLabel: 'You can click here to see the Terms & Conditions for Beta users.',\n href: 'https://app.politogyvrm.com/beta-terms-and-conditions',\n} as const\n\n/**\n * sessionStorage key holding the Beta-banner dismissal. sessionStorage — not\n * localStorage — so the dismissal lasts only for the browser session; and it is\n * additionally cleared on sign-out (see `clearBetaBannerDismissal`, called from\n * the chrome frame) so a fresh LOGIN always re-shows the notice.\n */\nexport const BETA_BANNER_DISMISS_KEY = 'politogy_beta_banner_dismissed'\n\n/**\n * Re-arm the Beta banner. The chrome frame calls this on sign-out so the notice\n * reappears at the next login rather than staying hidden across the boundary\n * (sessionStorage survives an in-tab logout→login round trip on its own).\n */\nexport function clearBetaBannerDismissal(): void {\n if (typeof window === 'undefined') return\n try {\n window.sessionStorage.removeItem(BETA_BANNER_DISMISS_KEY)\n } catch {\n /* storage unavailable (private mode / disabled) — nothing to clear */\n }\n}\n\nexport type NavBetaBannerProps = {\n /** Leading sentence(s) before the link. Defaults to the standard Beta copy. */\n text?: string\n /** Bold + underlined link label. Defaults to the standard Terms copy. */\n linkLabel?: string\n /** Terms & Conditions URL (opens in a new tab). Defaults to the app T&C page. */\n href?: string\n /**\n * Show a dismiss (×) button that hides the banner for the rest of the browser\n * session. Cleared on sign-out, so it returns at the next login. Default true.\n */\n dismissible?: boolean\n}\n\nexport function NavBetaBanner({ text, linkLabel, href, dismissible = true }: NavBetaBannerProps) {\n const body = text ?? BETA_BANNER_DEFAULTS.text\n const label = linkLabel ?? BETA_BANNER_DEFAULTS.linkLabel\n const target = href ?? BETA_BANNER_DEFAULTS.href\n\n // Start visible on both server and first client render (sessionStorage is not\n // readable during SSR), then hide in an effect if this session already\n // dismissed it — this keeps hydration markup identical and avoids a mismatch.\n const [dismissed, setDismissed] = useState(false)\n useEffect(() => {\n if (!dismissible) return\n try {\n if (window.sessionStorage.getItem(BETA_BANNER_DISMISS_KEY) === '1') setDismissed(true)\n } catch {\n /* storage unavailable — leave the banner visible */\n }\n }, [dismissible])\n\n if (dismissible && dismissed) return null\n\n const onDismiss = () => {\n setDismissed(true)\n try {\n window.sessionStorage.setItem(BETA_BANNER_DISMISS_KEY, '1')\n } catch {\n /* storage unavailable — banner still hides for this render */\n }\n }\n\n return (\n <div\n role=\"note\"\n className=\"relative w-full px-10 py-2 text-center text-sm\"\n style={{\n // Amber warning fill, matching the \"10DLC Registration Required\" notice\n // (HITL 2026-07-29). This used to fall through to `--color-accent`, the\n // brand RED, so a participation notice read as an error. The\n // --beta-banner-* tokens carry the amber defaults (chrome.css) and a\n // Brand edit still wins over them.\n background: 'var(--beta-banner-bg, #FEEBC8)',\n color: 'var(--beta-banner-text, #1A202C)',\n }}\n >\n <span>{body}</span>\n <a\n href={safeHref(target)}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"font-bold underline\"\n style={{ color: 'var(--beta-banner-text, #1A202C)' }}\n >\n {label}\n </a>\n {dismissible ? (\n <button\n type=\"button\"\n onClick={onDismiss}\n aria-label=\"Dismiss this notice\"\n title=\"Dismiss\"\n className=\"absolute right-2 top-1/2 -translate-y-1/2 flex h-6 w-6 items-center justify-center rounded text-base leading-none opacity-70 hover:opacity-100\"\n style={{ color: 'var(--beta-banner-text, #1A202C)' }}\n >\n ×\n </button>\n ) : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavAppShellProps = {\n sidebar: NavSidebarProps\n topBar: NavTopBarProps\n /**\n * When supplied, a full-width Beta notice strip renders directly below the top\n * bar. Presence of the prop enables it; all fields fall back to the standard\n * Beta copy + Terms & Conditions link.\n */\n betaBanner?: NavBetaBannerProps\n /**\n * @deprecated The frame's content area is one fluid `<main>` (Brand\n * guideline \"Content width is fluid\"): the 24px gutter (16px below `md`),\n * no max-width and no centered container. Apps never emit their own page\n * container, so there is nothing left to choose here.\n *\n * `'bare'` is still honored — it renders `children` with no `<main>` and no\n * gutter — only so VRM core, which renders `NavAppShell` directly around\n * pages that still carry their own `PageContainer`, does not get a nested\n * `<main>` before it migrates. It warns in development and will be removed.\n * `'padded'` is now the same as omitting the prop.\n */\n contentWrapper?: 'padded' | 'bare'\n /**\n * The operating Mode this frame is scoped to, stamped on the root as\n * `data-politogy-mode` so the Brand API's per-Mode chrome tokens can target\n * it (Reference/UI-Platform → \"Per-mode branding — one accent per Mode\").\n *\n * This is app IDENTITY, not app configuration: `PolitogyAppFrame` passes it\n * from the `POLITOGY_APPS` registry, never from a prop an app supplies, so an\n * app still cannot choose its own chrome colour.\n *\n * Omitted (or a Mode that declares no chrome group in the Brand API) => every\n * accent falls back to the global one, exactly as before 0.47.\n */\n modeId?: string\n /**\n * Where the user card / account menu renders. `'sidebar'` (default since\n * 0.68.0) draws it in the left-bar footer and hides the top-bar trigger\n * (Reference/UI-Platform v30); `'topbar'` restores the 0.67 top-right badge.\n */\n accountMenuPlacement?: 'sidebar' | 'topbar'\n children: ReactNode\n}\n\n/**\n * Full chrome: branded left sidebar + sticky top navbar + scrollable content\n * region. Presentational only — wrap it in app-level auth/gating as needed.\n */\n/**\n * Closes any open chrome <details data-nav-details> (org switcher, mode\n * selector, My Account) when the pointer lands outside it or Escape is\n * pressed — dropdowns must deselect on outside click (HITL 2026-07-23).\n */\nfunction useCloseNavDetailsOnOutsideClick() {\n useEffect(() => {\n const close = (target: Node | null) => {\n document.querySelectorAll('details[data-nav-details][open]').forEach((d) => {\n if (!target || !d.contains(target)) d.removeAttribute('open')\n })\n }\n const onPointerDown = (e: MouseEvent) => close(e.target as Node)\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') close(null)\n }\n document.addEventListener('mousedown', onPointerDown)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onPointerDown)\n document.removeEventListener('keydown', onKey)\n }\n }, [])\n}\n\nexport function NavAppShell({\n sidebar,\n topBar,\n betaBanner,\n contentWrapper = 'padded',\n accountMenuPlacement = 'sidebar',\n modeId,\n children,\n}: NavAppShellProps) {\n useCloseNavDetailsOnOutsideClick()\n if (contentWrapper === 'bare') {\n warnDeprecated(\n 'contentWrapper',\n \"`contentWrapper: 'bare'` is deprecated: the frame's <main> is fluid and apps must not emit their own page container. Remove the app's PageContainer and drop the prop.\",\n )\n }\n // Below `md` the rail is the 64px icon rail (see NavSidebar). The shell owns\n // the expanded-drawer state so the hamburger (NavTopBar) and the drawer\n // (NavSidebar) can stay presentational.\n const [navOpen, setNavOpen] = useState(false)\n const expandRail = () => {\n writeRailPreference('expanded')\n setNavOpen(true)\n }\n const collapseRail = () => {\n writeRailPreference('collapsed')\n setNavOpen(false)\n }\n // Route navigation closes the drawer — a stale open drawer over a new page\n // reads as broken, not as \"still browsing\".\n useEffect(() => {\n setNavOpen(false)\n }, [sidebar.pathname])\n // Left-Navigation §11.6: the expand choice is remembered per user. Read it\n // back after mount (no hydration mismatch); it only applies below `md`,\n // where the rail is collapsed. Explicit Expand / Collapse writes it.\n useEffect(() => {\n if (readRailPreference() !== 'expanded') return\n const narrow =\n typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia('(max-width: 767.98px)').matches\n : false\n if (narrow) setNavOpen(true)\n }, [])\n // The page behind a mobile drawer must not scroll while it's open.\n useEffect(() => {\n if (!navOpen) return\n const previous = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n return () => {\n document.body.style.overflow = previous\n }\n }, [navOpen])\n // The user card lives in the left-bar footer (UI-Platform v30). Lift the\n // top bar's user / menu / sign-out into the sidebar footer unless the app\n // already supplied them there or opted back into the top-bar badge.\n const sidebarFooter: NavFooter | null | undefined =\n accountMenuPlacement === 'sidebar' && topBar.user\n ? {\n ...(sidebar.footer ?? {}),\n user: sidebar.footer?.user ?? topBar.user,\n userMenu: sidebar.footer?.userMenu ?? topBar.userMenu,\n onSignOut: sidebar.footer?.onSignOut ?? topBar.onSignOut,\n }\n : sidebar.footer\n return (\n <div\n data-politogy-mode={modeId ?? modeIdFromLabel(sidebar.mode?.label)}\n className=\"min-h-screen bg-[color:var(--background)] text-[color:var(--foreground)]\"\n >\n {/* Cross-app sidebar nav speculation: every consumer rendering\n NavAppShell gets this for free (no per-app opt-in) — see\n src/speculation/SpeculationRulesScript.tsx. */}\n <SpeculationRulesScript items={sidebar.nav.items} />\n <NavSidebar\n {...sidebar}\n footer={sidebarFooter}\n open={navOpen}\n onClose={collapseRail}\n onOpen={expandRail}\n onNavigate={() => setNavOpen(false)}\n />\n {/* The rail is never hidden, so content is always offset by it: 64px\n below `md`, the full rail from `md` up. */}\n <div className=\"pl-[var(--sidebar-collapsed-width,64px)] md:pl-[var(--sidebar-width,236px)]\">\n <NavTopBar\n {...topBar}\n accountMenu={topBar.accountMenu ?? (accountMenuPlacement === 'sidebar' ? 'sidebar' : 'topbar')}\n />\n {betaBanner ? <NavBetaBanner {...betaBanner} /> : null}\n {/* Reference/UI-Platform \"Page header\": the title lives in the page\n body now, 22px below the top bar, not in the bar itself and never\n as a breadcrumb trail. Rendered here — above both wrapper modes —\n so a 'bare' app (which owns its own content furniture) still gets\n the required chrome-owned title line. */}\n {topBar.title ? (\n <h1 className=\"px-4 pt-7 text-xl font-semibold text-[color:var(--foreground)] md:px-6\">\n {topBar.title}\n </h1>\n ) : null}\n {contentWrapper === 'bare' ? (\n <div data-shell-content=\"\" className={topBar.title ? 'mt-[22px]' : undefined}>\n {children}\n </div>\n ) : (\n // Brand guidelines \"Content width is fluid\" + \"Content body\n // padding\": `<main>` fills the space beside the rail with ONE\n // gutter — 24px, or 16px below `md`, horizontally and vertically —\n // and has no max-width and no centered container. Form and settings\n // pages constrain themselves with <FormColumn> (960px, left-aligned).\n // The shell owns the page background and the gutter; an app's own\n // cards are its own furniture and stay app-owned.\n <main\n data-shell-content=\"\"\n className={`min-h-[calc(100vh-63px)] bg-[color:var(--chrome-page-bg,#F4F5F7)] px-4 pb-4 md:px-6 md:pb-6 ${topBar.title ? 'pt-[22px]' : 'pt-4 md:pt-6'}`}\n >\n {children}\n </main>\n )}\n </div>\n </div>\n )\n}\n\n// The one constrained layout inside the fluid <main>: a 960px left-aligned\n// column for form and settings pages. Re-exported here (as well as from the\n// main entry) so an app needs no Chakra / react-router peer to use it.\nexport { default as FormColumn } from '../components/FormColumn'\n\n// Canonical Politogy VRM menu — the standard nav structure every politogy app\n// renders, per operating Mode, with hooks for the app-owned \"Contacts\" item and\n// Support handler, plus the Campaign feature-availability config.\nexport {\n standardPolitogyNav,\n CAMPAIGN_FEATURE_AVAILABILITY,\n type StandardNavIconKey,\n type StandardNavOptions,\n type StandardNavMode,\n type CampaignFeatureAvailability,\n} from './standardNav'\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/topbarIconSlot.ts","../src/lib/brandGlyphs.tsx","../src/lib/deprecation.ts","../src/native/orgFilter.ts","../src/nav-preference.ts","../src/speculation/emitRules.ts","../src/speculation/SpeculationRulesScript.tsx","../src/theme-preference.ts","../src/native/chromeActions.tsx","../src/components/FormColumn.tsx","../src/native/standardNavIcons.ts","../src/native/standardNav.ts","../src/native/index.tsx"],"names":["useState","useEffect","FiBatteryCharging","FiBattery","FiZap","FiGrid","FiBell","FiAlertTriangle","FiAlertCircle","FiLifeBuoy","FiHelpCircle","FiMoon","FiSun","FiInfo","FiMail","FiMessageSquare","FiSettings","FiUser","useMemo","useSyncExternalStore","jsxs","jsx","createContext","useRef","useContext","Fragment","lowFuelHintVisible","useCallback","createPortal","clsx","LuHouse","LuUsers","LuMail","LuMessageSquare","LuLayoutDashboard","LuActivity","LuLifeBuoy","LuLayoutGrid","LuList","LuUpload","LuPencil","LuFileText","LuSend","LuClock","LuUser","LuChartColumn","LuBriefcase","LuSettings","LuCreditCard","LuDollarSign","LuShare2","LuPhone","LuMap","LuMapPin","LuTarget","LuFlag","LuUsersRound","LuMousePointerClick","LuClipboardList","LuCircleUser","LuCrosshair","LuLandmark","LuChartNoAxesColumn","LuDoorOpen","LuSignpost"],"mappings":";;;;;;;;;;;;;;AA6BO,SAAS,uBAAuB,IAAA,EAAqC;AAC1E,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAAwB,IAAI,CAAA;AAEpD,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,OA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","file":"native.cjs","sourcesContent":["import { useEffect, useState } from 'react'\n\n/**\n * The six canonical top-bar action slots (Reference/Global-Rules v9 → top-bar\n * icons). Each slot's GLYPH is unique and comes from the Brand API\n * `topbarIcons.items.*` tokens, exposed as `--topbar-icon-<slot>` CSS vars\n * whose value is the brand-icon NAME. Every OTHER property — size, gap, color,\n * hover, selected — is universal across all six slots.\n */\nexport type TopBarIconSlot =\n | 'comms-fuel'\n | 'apps'\n | 'notifications'\n | 'alerts'\n | 'support'\n | 'dark-mode'\n\n/**\n * Reads the glyph NAME for a slot from its `--topbar-icon-<slot>` CSS var.\n *\n * Runs in an effect because the Brand stylesheet is appended to <head> at\n * runtime (Global Rules forbids baking it into the build), so the var is not\n * resolvable during SSR or the first synchronous render. The MutationObserver\n * re-reads once the stylesheet lands so the glyph upgrades from the caller's\n * fallback without a reload.\n *\n * Returns null when the slot has no Brand glyph — callers render their own\n * fallback icon in that case.\n */\nexport function useTopBarIconSlotGlyph(slot: TopBarIconSlot): string | null {\n const [name, setName] = useState<string | null>(null)\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n const read = () => {\n const raw = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--topbar-icon-${slot}`)\n .trim()\n // Brand may emit the name quoted (e.g. \"bell\"); strip the quotes.\n .replace(/^['\"]|['\"]$/g, '')\n setName(raw.length > 0 ? raw : null)\n }\n\n read()\n\n const observer = new MutationObserver(read)\n observer.observe(document.head, { childList: true, subtree: true })\n return () => observer.disconnect()\n }, [slot])\n\n return name\n}\n\n/** Path to a brand-icon SVG in the consuming app's public dir. */\nexport function brandIconSrc(name: string, basePath = '/brand/icons/') {\n return `${basePath}${name}.svg`\n}\n","import type { ComponentType } from 'react'\nimport {\n FiAlertCircle,\n FiBattery,\n FiBatteryCharging,\n FiAlertTriangle,\n FiBell,\n FiGrid,\n FiHelpCircle,\n FiInfo,\n FiLifeBuoy,\n FiMail,\n FiMessageSquare,\n FiMoon,\n FiSettings,\n FiSun,\n FiUser,\n FiZap,\n} from 'react-icons/fi'\n\nexport type GlyphComponent = ComponentType<{ size?: number | string; className?: string }>\n\n/**\n * Brand-glyph registry: maps the icon NAME the Brand API emits (e.g.\n * `--topbar-icon-comms-fuel: bolt`) to a component.\n *\n * These names are Feather/Lucide icon names, NOT asset filenames — there is no\n * `/brand/icons/<name>.svg` for them in any app, and treating them as URLs\n * renders a broken image. Resolving them against the icon library the shell\n * already depends on keeps every app consistent with zero vendored assets.\n *\n * Aliases are included where Brand and Feather disagree on a name (`bolt` vs\n * `zap`, `life-buoy` vs `life-ring`).\n */\nconst GLYPHS: Record<string, GlyphComponent> = {\n // Communications Fuel reads as a LEVEL, so its glyph is a battery. `bolt`/\n // `zap` stay mapped for older Brand values.\n 'battery-charging': FiBatteryCharging,\n battery: FiBattery,\n fuel: FiBatteryCharging,\n bolt: FiZap,\n zap: FiZap,\n grid: FiGrid,\n apps: FiGrid,\n bell: FiBell,\n notification: FiBell,\n 'alert-triangle': FiAlertTriangle,\n alert: FiAlertTriangle,\n 'alert-circle': FiAlertCircle,\n 'life-buoy': FiLifeBuoy,\n 'life-ring': FiLifeBuoy,\n support: FiLifeBuoy,\n 'help-circle': FiHelpCircle,\n moon: FiMoon,\n sun: FiSun,\n info: FiInfo,\n mail: FiMail,\n 'message-square': FiMessageSquare,\n settings: FiSettings,\n user: FiUser,\n}\n\n/**\n * Resolve a Brand glyph name to a component. Returns null for an unknown name\n * so the caller renders its own fallback — an unrecognized token must never\n * produce a broken or empty icon.\n */\nexport function resolveBrandGlyph(name: string | null | undefined): GlyphComponent | null {\n if (!name) return null\n return GLYPHS[name.trim().toLowerCase()] ?? null\n}\n\n/** Names the registry knows — exported for tests and tooling. */\nexport const KNOWN_BRAND_GLYPHS = Object.keys(GLYPHS)\n","// One-time console warnings for retired shell API, in development only.\n\nconst warned = new Set<string>()\n\nfunction isDev(): boolean {\n try {\n return typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n } catch {\n return false\n }\n}\n\n/** Warn once per `key` in dev; silent in production builds. */\nexport function warnDeprecated(key: string, message: string): void {\n if (!isDev() || warned.has(key)) return\n warned.add(key)\n console.warn(`[@the-portland-company/shell] ${message}`)\n}\n\n/** Test hook: forget which warnings have fired. */\nexport function resetDeprecationWarnings(): void {\n warned.clear()\n}\n","/**\n * Organization-list filtering for the sidebar org selector.\n *\n * Accounts that belong to many organizations (a consultant managing a dozen\n * committees) got a 288 px panel showing seven rows and a near-invisible macOS\n * scrollbar — measured 2026-09-04: \"I cannot select other organizations\".\n * The panel now grows with the viewport and, above this threshold, gains a\n * type-to-filter box so any org is one keystroke away.\n */\nexport const ORG_FILTER_THRESHOLD = 8\n\nexport type FilterableOrg = { id: string; name: string | null }\n\n/** Case- and accent-insensitive substring match on the org name (or id prefix). */\nexport function filterOrgs<T extends FilterableOrg>(orgs: readonly T[], query: string): T[] {\n const q = normalize(query)\n if (!q) return [...orgs]\n return orgs.filter((o) => normalize(o.name ?? '').includes(q) || o.id.toLowerCase().startsWith(q))\n}\n\nexport function shouldShowOrgFilter(count: number): boolean {\n return count > ORG_FILTER_THRESHOLD\n}\n\nfunction normalize(s: string): string {\n return s\n .normalize('NFD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .trim()\n}\n","// Universal navigation-display preference — the same cross-app contract as the\n// theme (see ./theme-preference, which this deliberately mirrors).\n//\n// The user's choice of how navigation renders (Menu / Tabs / Both) follows the\n// authenticated user across every Politogy app + subdomain. Three layers:\n// 1. VRM Core `profiles.nav_display_preference` — source of truth, persisted\n// via the chrome API (`PATCH me/preferences { navDisplay }`) and read back\n// from `GET me` (`navDisplay`).\n// 2. `.politogyvrm.com` cookie `politogy_nav_display` — the cross-subdomain\n// vehicle (app session cookies are host-only, and so is localStorage).\n// 3. localStorage — same-app fast reads and cross-tab `storage` events.\n//\n// Before this existed the preference lived ONLY in localStorage under\n// `vrm.navDisplay`, which is per-ORIGIN: every app subdomain kept its own copy\n// and a freshly opened app booted the default, so the setting appeared not to\n// hold when moving between apps. The legacy key is still read as a fallback so\n// an existing local choice survives the upgrade.\n//\n// Server-safe (no 'use client'): layouts may import NAV_DISPLAY_PREPAINT_SCRIPT.\n\nexport type NavDisplayPreference = 'menu' | 'tabs' | 'both'\n\n// One key for BOTH the localStorage store and the cross-subdomain cookie, so a\n// choice in one app is the same key in the next.\nexport const NAV_DISPLAY_STORAGE_KEY = 'politogy_nav_display'\nexport const NAV_DISPLAY_COOKIE = 'politogy_nav_display'\n\n/** Pre-0.37 host-only key. Read for migration; never written. */\nexport const LEGACY_NAV_DISPLAY_KEY = 'vrm.navDisplay'\n\nexport const NAV_DISPLAY_DEFAULT: NavDisplayPreference = 'both'\n\nconst VALID: readonly NavDisplayPreference[] = ['menu', 'tabs', 'both']\n\nexport function isNavDisplayPreference(v: unknown): v is NavDisplayPreference {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v)\n}\n\n/** Read the shared cookie (browser only; null on the server or when unset). */\nexport function readNavDisplayCookie(): NavDisplayPreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isNavDisplayPreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n// Same host-aware scoping as the theme cookie: parent domain on\n// *.politogyvrm.com so every app subdomain reads it, host-only elsewhere\n// (localhost, *.pages.dev preview) because browsers silently drop a mismatched\n// Domain attribute. 1-year, SameSite=Lax, Secure on https.\nexport function writeNavDisplayCookie(pref: NavDisplayPreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${NAV_DISPLAY_COOKIE}=${encodeURIComponent(\n pref,\n )}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n}\n\n/** Read the local store, falling back to the legacy host-only key. */\nexport function readNavDisplayLocal(): NavDisplayPreference | null {\n if (typeof localStorage === 'undefined') return null\n try {\n const current = localStorage.getItem(NAV_DISPLAY_STORAGE_KEY)\n if (isNavDisplayPreference(current)) return current\n const legacy = localStorage.getItem(LEGACY_NAV_DISPLAY_KEY)\n return isNavDisplayPreference(legacy) ? legacy : null\n } catch {\n return null\n }\n}\n\nexport function writeNavDisplayLocal(pref: NavDisplayPreference): void {\n if (typeof localStorage === 'undefined') return\n try {\n localStorage.setItem(NAV_DISPLAY_STORAGE_KEY, pref)\n } catch {\n /* storage unavailable */\n }\n}\n\n/** Boot precedence: cookie → localStorage (incl. legacy) → default. */\nexport function resolveNavDisplay(): NavDisplayPreference {\n return readNavDisplayCookie() ?? readNavDisplayLocal() ?? NAV_DISPLAY_DEFAULT\n}\n\n// Inline pre-paint script — optional, and the mirror of THEME_PREPAINT_SCRIPT.\n// Nav display has no paint-blocking visual (the frame is client-rendered), but\n// seeding localStorage from the cookie before hydration keeps the first render\n// on the synced value instead of the default. Self-contained and silent.\nexport const NAV_DISPLAY_PREPAINT_SCRIPT = `(function(){try{\nvar KEY=${JSON.stringify(NAV_DISPLAY_STORAGE_KEY)};\nvar VALID=[\"menu\",\"tabs\",\"both\"];\nfunction fromCookie(){try{var m=document.cookie.match(/(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}\nvar cookie=fromCookie();\nif(cookie&&VALID.indexOf(cookie)!==-1){var ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}\nif(cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}}\n}catch(e){}})();`\n\n// ---------------------------------------------------------------------------\n// Rail expand preference — Left-Navigation §11.6: below `md` the rail\n// collapses to the 64px icon rail; \"the user can also collapse and expand it;\n// the choice is remembered per user\". Same cookie + localStorage layers as the\n// nav-display preference above (no server column yet), so the choice follows\n// the user across every app subdomain and survives reloads. Only an explicit\n// Expand / Collapse writes it; a route change that closes the overlay does not.\n// ---------------------------------------------------------------------------\n\nexport type RailPreference = 'expanded' | 'collapsed'\n\nexport const RAIL_STORAGE_KEY = 'politogy_rail'\nexport const RAIL_COOKIE = 'politogy_rail'\nexport const RAIL_DEFAULT: RailPreference = 'collapsed'\n\nexport function isRailPreference(v: unknown): v is RailPreference {\n return v === 'expanded' || v === 'collapsed'\n}\n\nexport function readRailPreference(): RailPreference {\n if (typeof document !== 'undefined') {\n try {\n const m = document.cookie.match(new RegExp(`(?:^|;\\\\s*)${RAIL_COOKIE}=([^;]+)`))\n const v = m ? decodeURIComponent(m[1]) : null\n if (isRailPreference(v)) return v\n } catch {\n /* ignore */\n }\n }\n if (typeof localStorage !== 'undefined') {\n try {\n const v = localStorage.getItem(RAIL_STORAGE_KEY)\n if (isRailPreference(v)) return v\n } catch {\n /* ignore */\n }\n }\n return RAIL_DEFAULT\n}\n\nexport function writeRailPreference(pref: RailPreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n try {\n document.cookie = `${RAIL_COOKIE}=${pref}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n } catch {\n /* ignore */\n }\n try {\n localStorage.setItem(RAIL_STORAGE_KEY, pref)\n } catch {\n /* storage unavailable */\n }\n}\n","import type { AppRegistryEntry } from '../types'\nimport type { NavItem } from '../native/index'\n\n/**\n * Build a Speculation Rules JSON payload that prerenders other apps in the\n * registry on moderate eagerness. Returns null when there are no eligible\n * other apps to prerender (e.g., this is the only app in the registry).\n *\n * @deprecated Legacy `AppRegistryEntry[]`-based registry is unused by any\n * current consumer. Cross-app sidebar nav now ships real `NavItem[]` trees\n * (`standardPolitogyNav`) — use `buildNavSpeculationRules` instead, which this\n * now delegates to.\n *\n * The host app is expected to render this as\n * `<script type=\"speculationrules\">{json}</script>` in <head> at runtime.\n */\nexport function buildSpeculationRules(\n currentApp: string,\n registry: AppRegistryEntry[],\n): string | null {\n const others = registry.filter(\n (entry) => entry.id !== currentApp && entry.visible !== false,\n )\n if (others.length === 0) return null\n const payload = {\n prerender: [\n {\n urls: others.map((entry) => entry.path),\n eagerness: 'moderate' as const,\n },\n ],\n }\n return JSON.stringify(payload)\n}\n\n/**\n * Labels the shell will never prerender or prefetch, even if a consumer's nav\n * tree somehow carries an `href` for them (sign-out is normally a footer\n * `onClick`, never a `NavItem.href` — this is a second guard, not the primary\n * one). Case-insensitive substring match against the row's label.\n */\nconst DESTRUCTIVE_LABEL_PATTERNS = ['sign out', 'signout', 'log out', 'logout', 'delete']\n\n/** URL substrings that mark a link as destructive/non-idempotent regardless of label. */\nconst DESTRUCTIVE_PATH_PATTERNS = ['/signout', '/sign-out', '/logout', '/log-out']\n\nfunction isDestructive(item: { label: string; href?: string }): boolean {\n const label = item.label.toLowerCase()\n if (DESTRUCTIVE_LABEL_PATTERNS.some((p) => label.includes(p))) return true\n const href = (item.href ?? '').toLowerCase()\n return DESTRUCTIVE_PATH_PATTERNS.some((p) => href.includes(p))\n}\n\n/**\n * Walk a `NavItem[]` tree (as produced by `standardPolitogyNav`) and collect\n * every absolute, cross-origin, non-destructive, GET-safe link — the\n * candidate set for prerender/prefetch. Sections and action rows (`onClick`,\n * no `href`) are skipped; children are walked too (sub-menu rows like\n * \"Command Center\" / \"New Poll\" are real cross-app destinations).\n */\nexport function collectSiblingAppUrls(items: NavItem[], currentOrigin: string): string[] {\n const urls = new Set<string>()\n const walk = (list: NavItem[]) => {\n for (const item of list) {\n if (item.kind === 'section') continue\n if (item.href && !isDestructive(item)) {\n try {\n const url = new URL(item.href, currentOrigin)\n if (url.origin !== currentOrigin && /^https?:$/.test(url.protocol)) {\n urls.add(url.href)\n }\n } catch {\n // Malformed href — skip rather than throw during nav render.\n }\n }\n if (item.children?.length) walk(item.children)\n }\n }\n walk(items)\n return Array.from(urls)\n}\n\nexport interface NavSpeculationRules {\n prerender: [{ source: 'list'; urls: string[]; eagerness: 'moderate' }]\n}\n\n/**\n * Build the Speculation Rules payload for a consumer's real sidebar nav tree:\n * every sibling `*.politogyvrm.com` app link, `eagerness: \"moderate\"` (the\n * browser's own heuristic — prerender starts on hover/pointerdown of a\n * matching `<a>`, not on page load). Sign-out and other destructive rows are\n * excluded by `collectSiblingAppUrls`. Returns `null` when there is nothing\n * to speculate on (e.g., an empty or single-app tree).\n *\n * Each target origin must opt in by sending\n * `Supports-Loading-Mode: credentialed-prerender` on its responses, per the\n * Speculation Rules cross-origin prerender contract — without it the browser\n * silently falls back to a normal navigation. (Other apps are adding this\n * header separately.)\n */\nexport function buildNavSpeculationRules(\n items: NavItem[],\n currentOrigin: string = typeof window !== 'undefined' ? window.location.origin : '',\n): NavSpeculationRules | null {\n const urls = collectSiblingAppUrls(items, currentOrigin)\n if (urls.length === 0) return null\n return {\n prerender: [{ source: 'list', urls, eagerness: 'moderate' }],\n }\n}\n","import { useEffect, useMemo } from 'react'\nimport type { NavItem } from '../native/index'\nimport { buildNavSpeculationRules, collectSiblingAppUrls } from './emitRules'\n\nconst SCRIPT_ID = 'politogy-speculation-rules'\nconst PREFETCH_ATTR = 'data-politogy-speculation-prefetch'\n\n/**\n * Renders the cross-app Speculation Rules `<script>` for the current\n * consumer's sidebar nav tree, and mounts in every `NavAppShell` — so it is\n * never an opt-in an app has to remember. Browsers that support Speculation\n * Rules prerender a sibling `*.politogyvrm.com` app the moment the user\n * hovers or pointers-down on its sidebar link (`eagerness: \"moderate\"`);\n * browsers that don't fall back, after the page goes idle, to plain\n * `<link rel=\"prefetch\">` tags for the same URLs, so the next click is still\n * warmed by a DNS/TLS/HTML fetch even without a prerendered document.\n *\n * Each sibling origin must send `Supports-Loading-Mode:\n * credentialed-prerender` on its responses for the prerender to actually\n * happen while the user is authenticated (cross-origin prerender is opt-in\n * on the destination). Without it, browsers degrade this to a normal\n * navigation — the hover/click still works, it's just not pre-warmed.\n *\n * Renders nothing visible; this is a side-effecting `<script>` injector.\n */\nexport function SpeculationRulesScript({ items }: { items: NavItem[] }) {\n const origin = typeof window !== 'undefined' ? window.location.origin : ''\n const rules = useMemo(() => buildNavSpeculationRules(items, origin), [items, origin])\n const json = rules ? JSON.stringify(rules) : null\n\n // Native Speculation Rules — covers the hover/pointerdown prerender case in\n // supporting browsers (Chromium). Declarative: no listeners needed, the\n // browser applies its own \"moderate\" heuristic to matching <a> elements.\n useEffect(() => {\n if (!json || typeof document === 'undefined') return\n let el = document.getElementById(SCRIPT_ID) as HTMLScriptElement | null\n if (!el) {\n el = document.createElement('script')\n el.id = SCRIPT_ID\n el.type = 'speculationrules'\n document.head.appendChild(el)\n }\n el.textContent = json\n return () => {\n // Leave the tag in place across route changes within the same app —\n // only strip it if this effect instance's app unmounts entirely with no\n // sibling to replace it.\n }\n }, [json])\n\n // Idle-prefetch fallback for browsers without Speculation Rules support\n // (or where the destination hasn't sent the opt-in header): warm the\n // connection/document via <link rel=\"prefetch\"> once the main thread is\n // idle, so it never competes with first-paint work.\n useEffect(() => {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const supportsSpecRules =\n typeof HTMLScriptElement !== 'undefined' &&\n typeof (HTMLScriptElement as unknown as { supports?: (t: string) => boolean }).supports ===\n 'function' &&\n (HTMLScriptElement as unknown as { supports: (t: string) => boolean }).supports(\n 'speculationrules',\n )\n if (supportsSpecRules) return\n const urls = collectSiblingAppUrls(items, origin)\n if (urls.length === 0) return\n\n const schedule: (cb: () => void) => void =\n typeof (window as unknown as { requestIdleCallback?: (cb: () => void) => void })\n .requestIdleCallback === 'function'\n ? (window as unknown as { requestIdleCallback: (cb: () => void) => void })\n .requestIdleCallback\n : (cb: () => void) => setTimeout(cb, 2000)\n\n const added: HTMLLinkElement[] = []\n schedule(() => {\n for (const url of urls) {\n if (document.querySelector(`link[${PREFETCH_ATTR}][href=\"${url}\"]`)) continue\n const link = document.createElement('link')\n link.rel = 'prefetch'\n link.href = url\n link.setAttribute(PREFETCH_ATTR, '')\n document.head.appendChild(link)\n added.push(link)\n }\n })\n return () => {\n added.forEach((l) => l.remove())\n }\n }, [items, origin])\n\n return null\n}\n","// Universal theme preference — the ONE cross-app contract.\n//\n// One theme choice (Light / Dark / System) follows the authenticated user\n// across every Politogy app + subdomain. Three layers cooperate:\n// 1. VRM Core `profiles.theme_preference` — source of truth, persisted via\n// the chrome API (`PATCH me/preferences { themePreference }`) and read\n// back from `GET me` (`themePreference`).\n// 2. `.politogyvrm.com` cookie `politogy_theme` — zero-flash pre-paint\n// vehicle that crosses subdomains (auth session cookies are host-only).\n// 3. localStorage `politogy_theme` — offline fallback store.\n//\n// Ported verbatim from contacts/apps/web/src/lib/theme.ts (the origin of the\n// contract) so every app runs the identical behavior from npm. This module is\n// server-safe (no 'use client'): layouts import THEME_PREPAINT_SCRIPT for the\n// pre-paint inline script. The client-side hook lives in ./native\n// (useThemePreference).\n\nexport type ThemePreference = 'light' | 'dark' | 'system'\n\n// Single converged key for BOTH the localStorage store and the\n// cross-subdomain cookie, so a choice in one app is the same key in the next.\nexport const THEME_STORAGE_KEY = 'politogy_theme'\nexport const THEME_COOKIE = 'politogy_theme'\n\n// A local choice that has NOT yet reached VRM Core `profiles.theme_preference`.\n//\n// Politogy ID (auth.politogyvrm.com) has no chrome-API session to PATCH, so a\n// theme picked on the login screen only ever lands in the cookie. Without this\n// marker the next app booted the stale profile value through the reconcile step\n// below and overwrote the user's fresh choice — the \"I set System and it keeps\n// going back to Light\" bug (HITL 2026-07-23). The flag rides the same\n// cross-subdomain cookie so the first app that CAN talk to the chrome API\n// pushes the choice up instead of pulling the stale one down.\nexport const THEME_PENDING_COOKIE = 'politogy_theme_pending'\n\nconst VALID: readonly ThemePreference[] = ['light', 'dark', 'system']\n\nexport function isThemePreference(v: unknown): v is ThemePreference {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v)\n}\n\n/** Read the shared cookie (browser only; null on the server or when unset). */\nexport function readThemeCookie(): ThemePreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${THEME_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isThemePreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n// Set the cross-subdomain cookie. On a *.politogyvrm.com host we scope it to\n// the parent domain so every app subdomain reads it; on any other host\n// (localhost, *.pages.dev preview) we fall back to a host-only cookie so\n// local/preview theming still works without a mismatched Domain attribute\n// (which browsers silently drop). 1-year, SameSite=Lax, Secure on https.\nexport function writeThemeCookie(pref: ThemePreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const onParentDomain = /(^|\\.)politogyvrm\\.com$/i.test(host)\n const domainAttr = onParentDomain ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${THEME_COOKIE}=${encodeURIComponent(\n pref,\n )}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n}\n\n// Write an arbitrary cross-subdomain cookie with the same scoping rules as the\n// theme cookie itself (parent domain on *.politogyvrm.com, host-only elsewhere).\nfunction writeSharedCookie(name: string, value: string, maxAgeSeconds: number): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${name}=${encodeURIComponent(\n value,\n )}; Path=/; Max-Age=${maxAgeSeconds}; SameSite=Lax${domainAttr}${secure}`\n}\n\n/**\n * Mark the current cookie value as a local choice that still has to reach the\n * user's profile. Call this from any surface that changes the theme WITHOUT a\n * chrome-API session (Politogy ID's login screen is the only one today).\n */\nexport function markThemeChoicePending(pref: ThemePreference): void {\n writeSharedCookie(THEME_PENDING_COOKIE, pref, 31536000)\n}\n\n/** The pending (not-yet-persisted) local choice, if any. */\nexport function readPendingThemeChoice(): ThemePreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${THEME_PENDING_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isThemePreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n/** Clear the pending marker once the choice has been written to the profile. */\nexport function clearPendingThemeChoice(): void {\n writeSharedCookie(THEME_PENDING_COOKIE, '', 0)\n}\n\n/** Resolve a preference to the concrete light/dark it renders as right now. */\nexport function resolveTheme(_pref: ThemePreference): 'light' | 'dark' {\n // Light only. Reference/UI-Platform retired Dark Mode (2026-09-21) and\n // Reference/Global-Rules forbids gating colour on prefers-color-scheme, so\n // every stored preference (including a legacy 'dark' or 'system') renders\n // light. The type keeps 'dark' so stored values still parse.\n return 'light'\n}\n\n/**\n * Read the stored preference the way the pre-paint script does — cookie →\n * localStorage → `'system'`. Kept in lockstep with THEME_PREPAINT_SCRIPT so a\n * runtime reader can never disagree with what was applied before paint.\n */\nexport function readStoredThemePreference(): ThemePreference {\n const cookie = readThemeCookie()\n if (cookie) return cookie\n try {\n const stored = window.localStorage.getItem(THEME_STORAGE_KEY)\n if (isThemePreference(stored)) return stored\n } catch {\n /* localStorage may be unavailable (private mode) */\n }\n return 'system'\n}\n\n/**\n * The concrete light/dark the document is rendering as right now.\n *\n * This is the value anything theme-derived must follow — notably Chakra's\n * `colorMode`. Chakra used to be pinned to light while this resolved to dark,\n * which rendered dark chrome tokens over light Chakra content (the \"dark\n * labels on a light page\" desync).\n */\nexport function readResolvedTheme(): 'light' | 'dark' {\n return resolveTheme(readStoredThemePreference())\n}\n\n/** Apply a preference to the document: toggles `.dark` + `data-theme` on\n * `<html>` (both selectors the chrome's dark token block matches) and sets\n * `color-scheme` so native controls follow. */\nexport function applyThemePreference(pref: ThemePreference): void {\n if (typeof document === 'undefined') return\n const resolved = resolveTheme(pref)\n const d = document.documentElement\n d.classList.toggle('dark', resolved === 'dark')\n try {\n d.setAttribute('data-theme', resolved)\n d.style.colorScheme = resolved\n } catch {\n /* non-fatal */\n }\n}\n\n// Inline pre-paint script — render it in <head> (or as the first child of\n// <body>) so the theme applies before first paint. Resolves the preference\n// from cookie → localStorage → OS, applies the `.dark` class + `color-scheme`,\n// and seeds localStorage from the cookie so the app hydrates to the synced\n// value (the cross-subdomain flash fix). Self-contained, dependency-free, and\n// wrapped so any failure is silent (never blocks paint).\nexport const THEME_PREPAINT_SCRIPT = `(function(){try{\nvar KEY=${JSON.stringify(THEME_STORAGE_KEY)};\nvar VALID=[\"light\",\"dark\",\"system\"];\nfunction fromCookie(){try{var m=document.cookie.match(/(?:^|;\\\\s*)${THEME_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}\nvar cookie=fromCookie();\nvar ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}\nvar pref=cookie||ls||\"system\";\nif(VALID.indexOf(pref)===-1)pref=\"system\";\nif(cookie&&cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}\nvar dark=false;\nvar d=document.documentElement;\nif(dark)d.classList.add(\"dark\");else d.classList.remove(\"dark\");\ntry{d.setAttribute(\"data-theme\",dark?\"dark\":\"light\");d.style.colorScheme=dark?\"dark\":\"light\";}catch(e){}\n}catch(e){}})();`\n","// ---------------------------------------------------------------------------\n// Native chrome actions — Tailwind-only top-bar widgets (Fuel, Notifications,\n// Support, Navigation-display) backed by the shared chrome API\n// (politogy-contacts-api on Railway). Zero Chakra, zero router, zero fetch\n// opinion: the consuming app injects ONE fetcher via <NavChromeProvider> —\n// typically a same-origin proxy route that attaches its own session's Bearer\n// token server-side — and every widget in every app runs this exact code.\n//\n// Data endpoints (paths are relative; the app's fetcher owns the base URL):\n// GET communications/fuel-status (header x-contacts-org: <core org id>)\n// GET notifications (header x-contacts-org: <core org id>)\n// GET orgs\n// POST support { message }\n//\n// Loading states follow Global-Rules \"Loading & Async States\": the chrome\n// (button, popover frame, labels) always renders; only the VALUE area shows a\n// skeleton shimmer — never a spinner, never a blank panel.\n// ---------------------------------------------------------------------------\n\n'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type ComponentType,\n type ReactNode,\n} from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useTopBarIconSlotGlyph, type TopBarIconSlot } from '../lib/topbarIconSlot'\nimport { resolveBrandGlyph } from '../lib/brandGlyphs'\nimport {\n applyThemePreference,\n isThemePreference,\n readThemeCookie,\n writeThemeCookie,\n readPendingThemeChoice,\n markThemeChoicePending,\n clearPendingThemeChoice,\n THEME_STORAGE_KEY,\n type ThemePreference as SharedThemePreference,\n} from '../theme-preference'\n\ntype NavIconLike = ComponentType<{ size?: number; className?: string }>\n\n// ---------------------------------------------------------------------------\n// Core-app deep links. The billing surface lives on the VRM-core app; we would\n// derive its origin from POLITOGY_APPS.vrm, but that registry lives in\n// ../app-chrome which imports THIS module — so pulling it in here would create\n// an import cycle. One local constant instead (kept in step with the registry's\n// `vrm` origin).\n// ---------------------------------------------------------------------------\n\nexport const CORE_APP_ORIGIN = 'https://app.politogyvrm.com'\n/** Text/Email fuel top-up page (SMS Signal + Email Broadcast). */\nexport const CORE_BILLING_PATH = '/organization-settings/subscription-billing/text-email'\nconst CORE_BILLING_URL = `${CORE_APP_ORIGIN}${CORE_BILLING_PATH}`\nconst QUARANTINED_CONTACTS_URL = `https://contacts.politogyvrm.com/duplicates`\n\n/** Specs origin — same env-aware-constant pattern as CORE_APP_ORIGIN. */\nexport const SPECS_ORIGIN = 'https://specs.politogyvrm.com'\n\n/**\n * Stamp the active org onto a cross-app link, the same `?org=<uuid>` selector\n * the nav tree and Mode pill use. A bare link into VRM core drops a multi-org\n * user into whatever org core defaults to, which is a different account than\n * the one whose fuel / quarantine counts they just clicked.\n */\nfunction withOrgParam(url: string, orgId: string | null | undefined): string {\n if (!orgId) return url\n return `${url}${url.includes('?') ? '&' : '?'}org=${orgId}`\n}\n\n/** Scope the quarantined-contacts view to one sender. */\nfunction withPhoneParam(url: string, phone: string | null | undefined): string {\n if (!phone) return url\n return `${url}${url.includes('?') ? '&' : '?'}phone=${encodeURIComponent(phone)}`\n}\n\n/**\n * Resolve an organization logo URL for rendering in ANY app.\n *\n * `organizations.logo_url` is authored by VRM core and stored as a ROOT-RELATIVE\n * core route — `/api/storage/public?bucket=organization-logos&path=<org>/logo.png`\n * (the signed-storage proxy). VRM core renders it correctly because that path\n * resolves against its own origin; every other app resolves it against its own\n * origin (forms.politogyvrm.com/api/storage/public), gets a 404, and shows a\n * broken image. The chrome API passes the stored value through verbatim, so the\n * resolution belongs here — one definition for every app, core included.\n *\n * Absolute URLs (http/https/data/blob) pass through untouched.\n */\nexport function resolveOrgLogoUrl(url: string | null | undefined): string | undefined {\n const raw = url?.trim()\n if (!raw) return undefined\n if (/^(?:[a-z][a-z0-9+.-]*:|\\/\\/)/i.test(raw)) return raw\n return `${CORE_APP_ORIGIN}${raw.startsWith('/') ? '' : '/'}${raw}`\n}\n\n// ---------------------------------------------------------------------------\n// Shared 32×32 circular top-bar button chrome — the ONE definition of the\n// top-bar trigger (Global Rules: no slot hand-rolls its own trigger/badge).\n// NavTopBar's structured actionsList buttons use this same builder.\n// ---------------------------------------------------------------------------\n\n/**\n * Glyph size inside every top-bar icon button — Reference/UI-Platform v30:\n * \"34px buttons / 17px glyph / 6px gap\".\n */\nexport const TOPBAR_GLYPH_SIZE = 17\n\nexport function topBarIconButtonClass(tone: 'default' | 'warning' | 'danger' = 'default'): string {\n const toneClass =\n tone === 'danger' || tone === 'warning'\n ? 'text-[color:var(--chrome-danger)] hover:text-[color:var(--chrome-danger)]'\n : 'text-[color:var(--topbar-icon-color,var(--muted))] hover:text-[color:var(--topbar-icon-hover-color,var(--foreground))] hover:bg-[color:var(--topbar-icon-hover-bg,transparent)]'\n return [\n // `group/tbtip` powers the shared <TopBarTooltip> rendered inside the trigger.\n 'group/tbtip relative flex items-center justify-center rounded-[var(--topbar-icon-button-radius,5px)] border border-transparent transition',\n 'h-[var(--topbar-icon-button-size,34px)] w-[var(--topbar-icon-button-size,34px)]',\n toneClass,\n ].join(' ')\n}\n\n/** The shared count badge — one definition, used by every slot. */\n// ---------------------------------------------------------------------------\n// Top-bar panel registry.\n//\n// The top bar hosts two KINDS of surface: panels (opened deliberately by the\n// user from an icon) and transient nudges (the low-fuel hint, the new-reply\n// toast) that appear on their own. They are separate components under separate\n// triggers, so nothing stopped a nudge from covering an open panel — measured\n// in production: the reply toast over the notifications header, and the\n// low-fuel nudge over the same header from the fuel trigger two icons away.\n//\n// A module-scoped counter is enough: any nudge can ask \"is a panel open?\"\n// without the slots having to know about each other.\n// ---------------------------------------------------------------------------\nlet openPanelCount = 0\nconst panelListeners = new Set<() => void>()\nconst emitPanelChange = () => panelListeners.forEach((l) => l())\n\nfunction setPanelOpenGlobal(open: boolean) {\n openPanelCount = Math.max(0, openPanelCount + (open ? 1 : -1))\n emitPanelChange()\n}\n\n/** True while ANY top-bar panel is open. Nudges use it to stay out of the way. */\nexport function useAnyTopBarPanelOpen() {\n return useSyncExternalStore(\n (cb) => {\n panelListeners.add(cb)\n return () => panelListeners.delete(cb)\n },\n () => openPanelCount > 0,\n () => false,\n )\n}\n\nexport function TopBarCountBadge({ count }: { count: number }) {\n if (!(count > 0)) return null\n return (\n <span className=\"absolute -top-[5px] -right-[5px] flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--chrome-danger)] px-1 text-[10px] font-bold leading-4 text-[#FFFFFF]\">\n {count > 99 ? '99+' : count}\n </span>\n )\n}\n\n/**\n * The shared hover tooltip every top-bar control renders BELOW itself: an\n * up-pointing arrow at the icon, a bold title line and a muted description.\n * Pure CSS (group-hover) so it works on <a>, <button> and <summary> triggers.\n * The trigger must carry `group/tbtip relative` (topBarIconButtonClass does).\n */\nexport function TopBarTooltip({\n title,\n description,\n}: {\n title: string\n description?: ReactNode\n}) {\n return (\n <span\n role=\"tooltip\"\n className=\"pointer-events-none absolute left-1/2 top-full z-50 mt-2 hidden w-max max-w-56 -translate-x-1/2 flex-col rounded-lg border border-[color:var(--line)] bg-[color:var(--panel-elevated)] px-3 py-2 text-left shadow-[var(--shadow-soft)] group-hover/tbtip:flex\"\n >\n {/* Arrow pointing up at the icon */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] left-1/2 h-2.5 w-2.5 -translate-x-1/2 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]\"\n />\n <span className=\"text-xs font-semibold text-[color:var(--foreground)]\">{title}</span>\n {description ? (\n <span className=\"mt-0.5 text-[11px] leading-snug text-[color:var(--muted)]\">\n {description}\n </span>\n ) : null}\n </span>\n )\n}\n\n/**\n * The up-pointing arrow every top-bar panel renders, anchored under its\n * trigger icon (panels are right-aligned, so the arrow sits at the trigger's\n * center: 16px in from the panel's right edge). One definition — every menu\n * points at its own icon identically.\n */\nexport function TopBarPanelArrow() {\n return (\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]\"\n />\n )\n}\n\n/**\n * Wrapper for third-party top-bar widgets that ship their own launcher button\n * (e.g. DevNotes). Normalizes the trigger to the universal 32px circular slot\n * (chrome.css `.topbar-widget-slot`) and adds the standard tooltip.\n */\nexport function TopBarWidgetSlot({\n title,\n description,\n children,\n}: {\n title: string\n description?: string\n children: ReactNode\n}) {\n return (\n <span className=\"topbar-widget-slot group/tbtip relative inline-flex\">\n {children}\n <TopBarTooltip title={title} description={description} />\n </span>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Theme control — Light / System / Dark, rendered inside the account menu.\n// Controlled: the app owns persistence (profile + cross-subdomain cookie).\n// ---------------------------------------------------------------------------\n\nexport type ThemePreference = SharedThemePreference\n\nconst THEME_OPTIONS: { value: ThemePreference; label: string }[] = [\n { value: 'light', label: 'Light' },\n]\n\nexport function NavThemeControl({\n value,\n onChange,\n}: {\n value: ThemePreference\n onChange: (next: ThemePreference) => void\n}) {\n return (\n <div className=\"px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Appearance\n </p>\n <div\n role=\"radiogroup\"\n aria-label=\"Appearance\"\n className=\"flex overflow-hidden rounded-full border border-[color:var(--line)]\"\n >\n {THEME_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex-1 px-3 py-1.5 text-xs font-semibold transition',\n value === opt.value\n ? 'bg-[color:var(--color-accent)] text-[#FFFFFF]'\n : 'text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {opt.label}\n </button>\n ))}\n </div>\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Chrome data context — the injected fetcher.\n// ---------------------------------------------------------------------------\n\nexport type NavChromeFetcher = (\n path: string,\n init?: { method?: string; headers?: Record<string, string>; body?: string },\n) => Promise<unknown>\n\n/** GET me — the authenticated user's chrome identity from the shared API.\n * userName prefers the VRM-core profile full name over token claims. */\nexport type ChromeMe = {\n user: string | null\n userName: string | null\n avatarUrl: string | null\n themePreference: string | null\n /** Universal navigation-display choice ('menu'|'tabs'|'both'); null when\n * unset or when the profile column is absent in this environment. */\n navDisplay: string | null\n /** The user's durable active-org preference (full org uuid); null when unset\n * or when the profile column is absent. Adopted only when the request\n * carries no `?org=`/cookie selector — URL → cookie → profile → default. */\n activeOrg?: string | null\n account?: string | null\n accountName?: string | null\n role?: string | null\n /** Contact reply-to, when the profile carries them (optional/tolerant). */\n email?: string | null\n phone?: string | null\n}\n\n/** In-flight-promise + short-TTL cache entry for one (endpoint, orgId) key. */\ntype ChromeFetchCacheEntry = { promise: Promise<unknown>; expiresAt: number }\n\n/** Default freshness window for de-duped chrome reads (orgs/me/notifications/\n * fuel-status). Short enough that a stale value never survives one nav, long\n * enough to collapse every hook mounted on the same page paint into one call. */\nconst CHROME_FETCH_CACHE_TTL_MS = 30_000\n\nfunction chromeCacheKey(path: string, orgId?: string | null): string {\n return orgId === undefined ? path : `${path}::${orgId ?? ''}`\n}\n\n/**\n * A shared read cache scoped to one `<NavChromeProvider>` (one fetcher, one\n * page boot). Every consumer of a given (path, orgId) pair within the TTL\n * window awaits the SAME promise instead of firing its own request — this is\n * what collapsed `/orgs` (2-4x), `/me` (2-3x) and `/notifications` (2-3x) per\n * page load, 1-3.5s each, down to one call apiece (nav-latency-report.md\n * Table 2). Keying by orgId means switching the active org is itself the\n * invalidation: the new org gets a fresh key, never the previous org's cached\n * value. A failed request is evicted immediately so the next consumer retries\n * rather than replaying the same rejection for the rest of the TTL.\n */\nfunction createChromeFetchCache(getFetchJson: () => NavChromeFetcher) {\n const cache = new Map<string, ChromeFetchCacheEntry>()\n\n function dedupedFetch(\n path: string,\n init: Parameters<NavChromeFetcher>[1] | undefined,\n opts: { orgId?: string | null; ttlMs?: number } = {},\n ): Promise<unknown> {\n const key = chromeCacheKey(path, opts.orgId)\n const now = Date.now()\n const hit = cache.get(key)\n if (hit && hit.expiresAt > now) return hit.promise\n // Return the fetcher's own promise (no extra `.catch` hop) so callers see\n // the same microtask depth as a direct fetchJson call; the boot screen's\n // first-tick dismissal (frameBootChrome.test) depends on that.\n const promise = getFetchJson()(path, init)\n promise.catch(() => cache.delete(key))\n cache.set(key, { promise, expiresAt: now + (opts.ttlMs ?? CHROME_FETCH_CACHE_TTL_MS) })\n return promise\n }\n\n /** Force the next read of `path` (any org) to skip the cache. Used after a\n * mutation that changes what an endpoint would return (e.g. marking chrome\n * notifications read server-side, if that ever moves off local storage). */\n function invalidate(path: string) {\n for (const key of cache.keys()) {\n if (key === path || key.startsWith(`${path}::`)) cache.delete(key)\n }\n }\n\n return { dedupedFetch, invalidate }\n}\n\ntype NavChromeContextValue = {\n fetchJson: NavChromeFetcher\n dedupedFetch: ReturnType<typeof createChromeFetchCache>['dedupedFetch']\n invalidateChromeCache: ReturnType<typeof createChromeFetchCache>['invalidate']\n me: ChromeMe | null\n meLoaded: boolean\n}\n\nconst NavChromeContext = createContext<NavChromeContextValue | null>(null)\n\nexport function NavChromeProvider({\n fetchJson,\n children,\n}: {\n fetchJson: NavChromeFetcher\n children: ReactNode\n}) {\n // The cache outlives re-renders but always calls the LATEST fetchJson (the\n // consuming app may pass a new function identity every render).\n const fetchJsonRef = useRef(fetchJson)\n fetchJsonRef.current = fetchJson\n const cacheRef = useRef<ReturnType<typeof createChromeFetchCache> | null>(null)\n if (!cacheRef.current) {\n cacheRef.current = createChromeFetchCache(() => fetchJsonRef.current)\n }\n const { dedupedFetch, invalidate: invalidateChromeCache } = cacheRef.current\n\n // ONE `me` fetch per provider — identity (profile name/avatar) and the\n // theme reconciliation both hang off it.\n const [me, setMe] = useState<ChromeMe | null>(null)\n const [meLoaded, setMeLoaded] = useState(false)\n useEffect(() => {\n let cancelled = false\n dedupedFetch('me', undefined)\n .then((data) => {\n if (!cancelled) setMe(data as ChromeMe)\n })\n .catch(() => {\n /* degraded: session identity stands in */\n })\n .finally(() => {\n if (!cancelled) setMeLoaded(true)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch])\n\n return (\n <NavChromeContext.Provider value={{ fetchJson, dedupedFetch, invalidateChromeCache, me, meLoaded }}>\n {children}\n </NavChromeContext.Provider>\n )\n}\n\n/** The authenticated user's chrome identity (profile name / avatar / theme). */\nexport function useChromeMe(): { me: ChromeMe | null; loaded: boolean } {\n const ctx = useContext(NavChromeContext)\n return { me: ctx?.me ?? null, loaded: ctx?.meLoaded ?? false }\n}\n\n/** The provider's de-duped chrome read (null outside <NavChromeProvider>). */\nexport function useNavChromeDedupedFetch(): NavChromeContextValue['dedupedFetch'] | null {\n return useContext(NavChromeContext)?.dedupedFetch ?? null\n}\n\n/** The injected chrome fetcher (null outside <NavChromeProvider>). */\nexport function useNavChromeFetcher(): NavChromeFetcher | null {\n return useContext(NavChromeContext)?.fetchJson ?? null\n}\n\nfunction useNavChrome(component: string): NavChromeContextValue {\n const ctx = useContext(NavChromeContext)\n if (!ctx) {\n throw new Error(\n `${component} must be rendered inside <NavChromeProvider> (inject the chrome API fetcher there).`,\n )\n }\n return ctx\n}\n\n// ---------------------------------------------------------------------------\n// Data shapes (mirror of politogy-contacts-api responses).\n// ---------------------------------------------------------------------------\n\nexport type FuelChannelStatus = {\n remainingUnits: number\n rawBalanceUnits: number\n usedUnits: number\n lowFuel: boolean\n lowFuelThreshold: number\n}\n\nexport type CommunicationsFuelStatus = {\n organizationId: string\n signal: FuelChannelStatus\n broadcast: FuelChannelStatus\n combinedAvailableCredits: number\n}\n\nexport type ChromeNotificationAlert = {\n id: string\n title: string\n description: string\n href: string | null\n kind: string\n}\n\nexport type ChromeNotificationReply = {\n id: string\n contactId: string | null\n name: string\n preview: string\n /** Optional deep-link to the conversation; the new-reply toast opens it. */\n href?: string\n /**\n * Optional arrival timestamp. Present, it lets the trigger badge count a\n * reply as \"unseen\" only when it is newer than the last time the panel was\n * opened; absent (older payloads), replies simply don't survive the first\n * open as unseen. Tolerated either way.\n */\n createdAt?: string\n}\n\n/** A running or finished contact import surfaced in the notifications panel. */\nexport type ChromeNotificationImport = {\n id: string\n label: string\n /** 0–100 progress, or null when indeterminate (no bar rendered). */\n percent: number | null\n status: 'active' | 'completed'\n href: string | null\n}\n\n/** A cluster of quarantined contacts sharing one phone number. */\nexport type ChromeNotificationQuarantine = {\n phone: string\n count: number\n /** Upstream may omit it; the row already renders conditionally on it. */\n latestAt: string | null\n}\n\nexport type ChromeNotificationsPayload = {\n organizationId: string\n alerts: ChromeNotificationAlert[]\n replies: ChromeNotificationReply[]\n /** Optional — running/finished imports (tolerant when absent). */\n imports?: ChromeNotificationImport[]\n /** Optional — clustered quarantined contacts (tolerant when absent). */\n quarantined?: ChromeNotificationQuarantine[]\n}\n\nexport type ChromeOrgSummary = {\n id: string\n name: string | null\n logoUrl: string | null\n brandColor: string | null\n role: string | null\n /** Un-mapped VRM-core membership role (e.g. \"super_admin\"). */\n rawRole?: string | null\n}\n\n/**\n * Fetch the signed-in user's VRM-core organizations through the injected\n * fetcher. Exposed as a hook so the org switcher in the sidebar and the\n * org-scoped widgets share one request.\n */\nexport function useChromeOrgs({ enabled = true }: { enabled?: boolean } = {}): {\n orgs: ChromeOrgSummary[] | null\n loading: boolean\n error: boolean\n} {\n const { dedupedFetch } = useNavChrome('useChromeOrgs')\n const [orgs, setOrgs] = useState<ChromeOrgSummary[] | null>(null)\n const [loading, setLoading] = useState(enabled)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n // Disabled when the app already holds the org list from its token-backed\n // session (auth-owned active org): no per-request chrome `/api/orgs` call.\n if (!enabled) {\n setLoading(false)\n return\n }\n let cancelled = false\n setLoading(true)\n setError(false)\n dedupedFetch('orgs', undefined)\n .then((data) => {\n if (cancelled) return\n const list = (data as { orgs?: ChromeOrgSummary[] })?.orgs ?? []\n setOrgs(list)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, enabled])\n\n return { orgs, loading, error }\n}\n\n// ---------------------------------------------------------------------------\n// Internal building blocks.\n// ---------------------------------------------------------------------------\n\n/** Value-area skeleton shimmer (chrome/labels stay static per Global Rules). */\nfunction ValueSkeleton({ className }: { className?: string }) {\n return (\n <span\n aria-hidden\n className={[\n 'inline-block animate-pulse rounded bg-[color:var(--panel-elevated)]',\n className ?? 'h-4 w-16',\n ].join(' ')}\n />\n )\n}\n\n/** Slot-driven glyph: Brand-token name when resolvable, fallback otherwise. */\nfunction SlotGlyph({\n slot,\n fallback: Fallback,\n size = TOPBAR_GLYPH_SIZE,\n}: {\n slot?: TopBarIconSlot\n fallback: NavIconLike\n size?: number\n}) {\n const glyphName = useTopBarIconSlotGlyph(slot ?? 'apps')\n const BrandGlyph = slot ? resolveBrandGlyph(glyphName) : null\n const Glyph = BrandGlyph ?? Fallback\n return <Glyph size={size} className=\"text-current\" />\n}\n\n/**\n * A top-bar popover: the shared circular trigger + a right-aligned panel.\n * Closes on outside click / Escape. Purely presentational.\n *\n * EXPORTED so an app with a richer panel than the stock actions can render it\n * inside the SHARED chrome — same 32px trigger, same tooltip, same badge, same\n * panel surface and arrow — instead of hand-rolling a trigger and drifting.\n * This is the enabling step for folding VRM's Fuel breakdown, import-progress,\n * alerts and reply-feed panels into the shared cluster one at a time, without\n * dropping capability (shell-nav-handoff §4; UI-Platform forbids migrating an\n * app to a rendering that loses an element it already ships).\n */\nexport function TopBarPopover({\n label,\n description,\n slot,\n fallbackIcon,\n badge,\n tone,\n onOpen,\n openToken,\n onOpenChange,\n children,\n panelClassName,\n}: {\n label: string\n description?: string\n slot?: TopBarIconSlot\n fallbackIcon: NavIconLike\n badge?: number\n tone?: 'default' | 'warning' | 'danger'\n onOpen?: () => void\n /**\n * Imperative \"open\" signal: whenever this number CHANGES the panel opens\n * (and `onOpen` fires). Lets a sibling — e.g. the notifications toast — open\n * the panel without owning the popover's state. Undefined disables it.\n */\n openToken?: number\n /**\n * Notified on every open/close. A sibling surface anchored to the same\n * trigger (e.g. the notifications toast) must know when the panel is open so\n * the two never render on top of each other — Reference/UI-Platform gives\n * every top-bar panel ONE surface anchored to its trigger, so a second\n * surface at the same anchor always occludes it.\n */\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n panelClassName?: string\n}) {\n const [open, setOpen] = useState(false)\n const onOpenChangeRef = useRef(onOpenChange)\n onOpenChangeRef.current = onOpenChange\n useEffect(() => {\n onOpenChangeRef.current?.(open)\n if (!open) return\n setPanelOpenGlobal(true)\n return () => setPanelOpenGlobal(false)\n }, [open])\n const rootRef = useRef<HTMLDivElement | null>(null)\n const lastOpenTokenRef = useRef(openToken)\n\n // React to external open signals (skips the initial value on mount).\n useEffect(() => {\n if (openToken === undefined) return\n if (openToken === lastOpenTokenRef.current) return\n lastOpenTokenRef.current = openToken\n setOpen((v) => {\n if (!v) onOpen?.()\n return true\n })\n }, [openToken, onOpen])\n\n useEffect(() => {\n if (!open) return\n const onDocClick = (e: MouseEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false)\n }\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false)\n }\n document.addEventListener('mousedown', onDocClick)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onDocClick)\n document.removeEventListener('keydown', onKey)\n }\n }, [open])\n\n return (\n <div ref={rootRef} className=\"relative\">\n <button\n type=\"button\"\n aria-label={label}\n aria-expanded={open}\n className={topBarIconButtonClass(tone)}\n onClick={() => {\n setOpen((v) => {\n const next = !v\n if (next) onOpen?.()\n return next\n })\n }}\n >\n <SlotGlyph slot={slot} fallback={fallbackIcon} />\n {typeof badge === 'number' ? <TopBarCountBadge count={badge} /> : null}\n {!open ? <TopBarTooltip title={label} description={description} /> : null}\n </button>\n {open ? (\n <div\n className={[\n 'absolute right-0 z-40 mt-2 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]',\n panelClassName ?? 'w-80',\n ].join(' ')}\n >\n <TopBarPanelArrow />\n <div className=\"overflow-hidden rounded-xl\">{children}</div>\n </div>\n ) : null}\n </div>\n )\n}\n\n// Inline fallback glyphs (Feather-style paths) so the package needs no icon dep.\nfunction BatteryGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"1\" y=\"6\" width=\"18\" height=\"12\" rx=\"2\" ry=\"2\" />\n <line x1=\"23\" y1=\"10\" x2=\"23\" y2=\"14\" />\n <line x1=\"5\" y1=\"10\" x2=\"5\" y2=\"14\" />\n <line x1=\"9\" y1=\"10\" x2=\"9\" y2=\"14\" />\n </svg>\n )\n}\n\nfunction BellGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9\" />\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n </svg>\n )\n}\n\nfunction BellOffGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n <path d=\"M18.63 13A17.9 17.9 0 0 1 18 8\" />\n <path d=\"M6.26 6.26A5.86 5.86 0 0 0 6 8c0 7-3 9-3 9h14\" />\n <path d=\"M18 8a6 6 0 0 0-9.33-5\" />\n <line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\" />\n </svg>\n )\n}\n\nfunction LifeBuoyGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <line x1=\"4.93\" y1=\"4.93\" x2=\"9.17\" y2=\"9.17\" />\n <line x1=\"14.83\" y1=\"14.83\" x2=\"19.07\" y2=\"19.07\" />\n <line x1=\"14.83\" y1=\"9.17\" x2=\"19.07\" y2=\"4.93\" />\n <line x1=\"4.93\" y1=\"19.07\" x2=\"9.17\" y2=\"14.83\" />\n </svg>\n )\n}\n\nfunction LayoutGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\" />\n <line x1=\"3\" y1=\"9\" x2=\"21\" y2=\"9\" />\n <line x1=\"9\" y1=\"21\" x2=\"9\" y2=\"9\" />\n </svg>\n )\n}\n\nfunction PlusGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n )\n}\n\nfunction XGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\nfunction CheckGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// FuelAction — Communications Fuel balance (battery glyph + popover meters).\n// ---------------------------------------------------------------------------\n\nconst LOW_FUEL_HINT_DISMISSED_KEY = 'politogy_low_fuel_hint_dismissed'\n\nfunction FuelRow({\n label,\n channel,\n loading,\n addHref,\n addLabel,\n}: {\n label: string\n channel: FuelChannelStatus | null\n loading: boolean\n /** Billing deep-link for the small \"+\" top-up button (omit to hide it). */\n addHref?: string\n addLabel?: string\n}) {\n const remaining = channel?.remainingUnits ?? 0\n const total = channel ? Math.max(channel.rawBalanceUnits, channel.remainingUnits) : 0\n const ratio = total > 0 ? Math.min(100, Math.max(0, (remaining / total) * 100)) : 0\n const low = channel?.lowFuel ?? false\n\n return (\n <div className=\"w-full\">\n <div className=\"mb-1 flex items-center justify-between gap-2\">\n <span className=\"text-xs font-semibold text-[color:var(--foreground)]\">{label}</span>\n <div className=\"flex items-center gap-2\">\n {loading ? (\n <ValueSkeleton className=\"h-3.5 w-14\" />\n ) : (\n <span\n className={[\n 'text-xs font-semibold tabular-nums',\n low ? 'text-[color:var(--chrome-danger)]' : 'text-[color:var(--muted)]',\n ].join(' ')}\n >\n {remaining.toLocaleString()} left\n </span>\n )}\n {addHref ? (\n <a\n href={addHref}\n aria-label={addLabel}\n className=\"flex h-5 w-5 items-center justify-center rounded-full border border-[color:var(--line)] text-[color:var(--muted)] transition hover:border-[color:var(--foreground)] hover:text-[color:var(--foreground)]\"\n >\n <PlusGlyph />\n </a>\n ) : null}\n </div>\n </div>\n <div className=\"h-1.5 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n {loading ? (\n <div className=\"h-full w-full animate-pulse bg-[color:var(--line)]\" />\n ) : (\n <div\n className={[\n 'h-full rounded-full transition-[width]',\n low ? 'bg-[color:var(--chrome-danger)]' : 'bg-[color:var(--color-ok,#00A651)]',\n ].join(' ')}\n style={{ width: `${ratio}%` }}\n />\n )}\n </div>\n </div>\n )\n}\n\n// Both the low-fuel nudge and the new-reply toast are wide (240-320px)\n// absolute bubbles anchored to adjacent top-bar icons (Fuel, then\n// Notifications). Anchored-right boxes expand LEFTWARD from their trigger,\n// so a wide toast under the (further-right) bell can reach back over the\n// (further-left) fuel icon's hint, same z-50 — whichever mounted later\n// painted on top and the fuel banner got cut off/hidden (reported on\n// contacts.politogyvrm.com, 2026-10-09). This tiny external store lets the\n// toast learn the hint's visibility without a shared provider, so it can\n// drop below it instead of overlapping: the banner always stacks above the\n// toast, never the other way round.\nlet lowFuelHintVisible = false\nconst lowFuelHintListeners = new Set<() => void>()\nfunction setLowFuelHintVisible(visible: boolean): void {\n if (lowFuelHintVisible === visible) return\n lowFuelHintVisible = visible\n lowFuelHintListeners.forEach((l) => l())\n}\nfunction subscribeLowFuelHintVisible(onChange: () => void): () => void {\n lowFuelHintListeners.add(onChange)\n return () => lowFuelHintListeners.delete(onChange)\n}\nfunction useLowFuelHintVisible(): boolean {\n return useSyncExternalStore(subscribeLowFuelHintVisible, () => lowFuelHintVisible)\n}\n// Height (card + arrow + gap) the toast must clear when the hint is also up.\nconst LOW_FUEL_HINT_CLEARANCE_PX = 96\n\n/**\n * The low-fuel nudge: a small bubble anchored below the fuel trigger (arrow up)\n * with a \"Buy More Fuel\" deep-link. Dismissible; the dismissal persists for the\n * session (sessionStorage) so it never re-appears until a fresh session — and\n * the flag clears once fuel is no longer low, so a later drain can nudge again.\n */\nfunction LowFuelHint({ lowFuel, orgId }: { lowFuel: boolean; orgId: string | null }) {\n const [dismissed, setDismissed] = useState<boolean>(() => {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(LOW_FUEL_HINT_DISMISSED_KEY) === '1'\n } catch {\n return false\n }\n })\n\n useEffect(() => {\n if (lowFuel) return\n try {\n window.sessionStorage.removeItem(LOW_FUEL_HINT_DISMISSED_KEY)\n } catch {\n /* unavailable */\n }\n }, [lowFuel])\n\n // Yield to any open panel: the nudge is wider than its own trigger and the\n // panels are right-aligned, so it lands on top of whichever one is open\n // (measured on contacts: it covered the notifications panel's header).\n const panelOpen = useAnyTopBarPanelOpen()\n const showing = lowFuel && !dismissed && !panelOpen\n\n // Published so the new-reply toast (anchored to the adjacent Notifications\n // icon) can drop below this banner instead of racing it for the same\n // on-screen space. Effect, not inline: setting external-store state during\n // render is not allowed.\n useEffect(() => {\n setLowFuelHintVisible(showing)\n return () => setLowFuelHintVisible(false)\n }, [showing])\n\n if (!showing) return null\n\n const dismiss = () => {\n try {\n window.sessionStorage.setItem(LOW_FUEL_HINT_DISMISSED_KEY, '1')\n } catch {\n /* unavailable */\n }\n setDismissed(true)\n }\n\n return (\n <div\n role=\"status\"\n // z-[60]: one tier above the new-reply toast (z-50) so this banner is\n // never the one that gets covered when both are up at once.\n className=\"absolute right-0 top-[calc(100%+10px)] z-[60] w-60 rounded-lg border border-[color:var(--chrome-danger)] bg-[color:var(--chrome-danger)] px-3 py-2 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n onClick={(e) => e.stopPropagation()}\n >\n {/* Arrow pointing up at the fuel button (mirrors TopBarPanelArrow's offset). */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 bg-[color:var(--chrome-danger)]\"\n />\n <div className=\"flex items-start gap-2\">\n <div className=\"flex-1\">\n <p className=\"text-sm font-semibold\">You’re low on fuel</p>\n <a\n href={withOrgParam(CORE_BILLING_URL, orgId)}\n className=\"mt-1 inline-block text-sm font-bold underline hover:opacity-90\"\n >\n Buy More Fuel\n </a>\n </div>\n <button\n type=\"button\"\n aria-label=\"Dismiss low fuel notice\"\n onClick={dismiss}\n className=\"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[#FFFFFF]/90 transition hover:bg-[#FFFFFF]/20\"\n >\n <XGlyph />\n </button>\n </div>\n </div>\n )\n}\n\nexport function FuelAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch } = useNavChrome('FuelAction')\n const [fuel, setFuel] = useState<CommunicationsFuelStatus | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n setLoading(true)\n setError(false)\n setFuel(null)\n dedupedFetch(\n 'communications/fuel-status',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (cancelled) return\n setFuel((data as { fuel?: CommunicationsFuelStatus | null })?.fuel ?? null)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, orgId])\n\n const low = !!fuel && (fuel.signal.lowFuel || fuel.broadcast.lowFuel)\n\n return (\n // The nudge anchors to the trigger, so it sits OUTSIDE the popover panel in\n // its own relative wrapper (same shape the VRM widget used).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Communications Fuel\"\n description=\"Remaining SMS and email sending balance for the active organization.\"\n slot=\"comms-fuel\"\n fallbackIcon={BatteryGlyph}\n tone={low ? 'warning' : 'default'}\n >\n <div className=\"px-4 py-3\">\n <p className=\"mb-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Communications Fuel\n </p>\n {error || (!loading && !fuel) ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Fuel balance is unavailable right now.\n </p>\n ) : (\n <div className=\"flex flex-col gap-3\">\n <FuelRow\n label=\"SMS Signal\"\n channel={fuel?.signal ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add SMS Signal fuel\"\n />\n <FuelRow\n label=\"Email Broadcast\"\n channel={fuel?.broadcast ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add Email Broadcast fuel\"\n />\n </div>\n )}\n </div>\n </TopBarPopover>\n <LowFuelHint lowFuel={low} orgId={orgId} />\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NotificationsAction — bell + count badge + alerts/replies popover.\n// ---------------------------------------------------------------------------\n\n/** Per-org read/seen state, persisted client-side (localStorage). */\ntype NotifState = {\n readAlertIds: string[]\n lastSeenAt: string | null\n /** Reply ids already surfaced as a toast, so none re-toasts (capped ~50). */\n toastedReplyIds: string[]\n}\n\nfunction notifStateKey(orgId: string | null): string {\n return `politogy_chrome_notif_state:${orgId ?? 'none'}`\n}\n\nfunction readNotifState(orgId: string | null): NotifState {\n const empty: NotifState = { readAlertIds: [], lastSeenAt: null, toastedReplyIds: [] }\n if (typeof window === 'undefined') return empty\n try {\n const raw = window.localStorage.getItem(notifStateKey(orgId))\n if (!raw) return empty\n const parsed = JSON.parse(raw) as Partial<NotifState>\n return {\n readAlertIds: Array.isArray(parsed?.readAlertIds)\n ? parsed.readAlertIds.filter((id): id is string => typeof id === 'string')\n : [],\n lastSeenAt: typeof parsed?.lastSeenAt === 'string' ? parsed.lastSeenAt : null,\n toastedReplyIds: Array.isArray(parsed?.toastedReplyIds)\n ? parsed.toastedReplyIds.filter((id): id is string => typeof id === 'string')\n : [],\n }\n } catch {\n return empty\n }\n}\n\nfunction writeNotifState(orgId: string | null, state: NotifState): void {\n if (typeof window === 'undefined') return\n try {\n window.localStorage.setItem(notifStateKey(orgId), JSON.stringify(state))\n } catch {\n /* unavailable */\n }\n}\n\n/**\n * Session-scoped mute for the rotating new-reply toasts. Session (not local)\n * storage on purpose: silencing is a \"not right now\" gesture, so a reload\n * restores the toasts rather than silently disabling them forever.\n */\nconst TOASTS_MUTED_KEY = 'politogy_chrome_toasts_muted'\n\nfunction readToastsMuted(): boolean {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(TOASTS_MUTED_KEY) === '1'\n } catch {\n return false\n }\n}\n\nfunction writeToastsMuted(muted: boolean): void {\n if (typeof window === 'undefined') return\n try {\n if (muted) window.sessionStorage.setItem(TOASTS_MUTED_KEY, '1')\n else window.sessionStorage.removeItem(TOASTS_MUTED_KEY)\n } catch {\n /* unavailable */\n }\n}\n\n/** Format a raw phone into US (XXX) XXX-XXXX; leave anything else as-is. */\nfunction formatPhone(raw: string): string {\n const digits = raw.replace(/\\D/g, '')\n const ten = digits.length === 11 && digits.startsWith('1') ? digits.slice(1) : digits\n if (ten.length === 10) return `(${ten.slice(0, 3)}) ${ten.slice(3, 6)}-${ten.slice(6)}`\n return raw\n}\n\nfunction ImportRow({ imp }: { imp: ChromeNotificationImport }) {\n const pct = imp.percent == null ? null : Math.max(0, Math.min(100, imp.percent))\n return (\n <>\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate text-sm text-[color:var(--foreground)]\">{imp.label}</span>\n {pct != null ? (\n <span className=\"shrink-0 text-xs tabular-nums text-[color:var(--muted)]\">\n {Math.round(pct)}%\n </span>\n ) : null}\n </div>\n {pct != null ? (\n <div className=\"mt-1 h-1 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n <div\n className=\"h-full rounded-full bg-[color:var(--color-accent)] transition-[width]\"\n style={{ width: `${pct}%` }}\n />\n </div>\n ) : null}\n </>\n )\n}\n\n/**\n * Transient \"new reply\" toast anchored below the bell. Dark bubble with an\n * up-arrow, sender + preview; auto-fades after ~12s; clicking activates it.\n * Mirrors VRM's NewTextBellPopup. Purely presentational — the parent owns which\n * reply shows and what a click does.\n */\nfunction NewReplyToast({\n reply,\n onActivate,\n onClose,\n onSilence,\n ttlMs = 12000,\n}: {\n reply: ChromeNotificationReply\n onActivate: () => void\n onClose: () => void\n onSilence: () => void\n ttlMs?: number\n}) {\n const [visible, setVisible] = useState(false)\n const onCloseRef = useRef(onClose)\n onCloseRef.current = onClose\n const lowFuelHintVisible = useLowFuelHintVisible()\n\n useEffect(() => {\n setVisible(true)\n const fadeAt = Math.max(0, ttlMs - 450)\n const t1 = window.setTimeout(() => setVisible(false), fadeAt)\n const t2 = window.setTimeout(() => onCloseRef.current(), ttlMs)\n return () => {\n window.clearTimeout(t1)\n window.clearTimeout(t2)\n }\n }, [ttlMs])\n\n const activate = () => {\n setVisible(false)\n onActivate()\n }\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n aria-label=\"Open new reply\"\n onClick={activate}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n activate()\n }\n }}\n // z-50, below the low-fuel banner's z-[60] — and when that banner is\n // up, pushed down past it so the two stack instead of overlapping\n // (see LOW_FUEL_HINT_CLEARANCE_PX; both bubbles are wide enough to\n // reach across the Fuel ↔ Notifications gap at these icon spacings).\n className=\"absolute right-[-6px] top-[calc(100%+12px)] z-50 min-w-[240px] max-w-[320px] cursor-pointer rounded-xl bg-[#161616] px-4 py-3 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n style={{\n top: lowFuelHintVisible ? `calc(100% + 12px + ${LOW_FUEL_HINT_CLEARANCE_PX}px)` : undefined,\n opacity: visible ? 1 : 0,\n transform: visible ? 'translateY(0px)' : 'translateY(-4px)',\n transition: 'opacity 250ms ease, transform 250ms ease',\n }}\n >\n {/* Up-arrow pointing at the bell. */}\n <span\n aria-hidden\n className=\"absolute right-[18px] top-[-7px] h-0 w-0 border-x-[8px] border-x-transparent border-b-[8px] border-b-[#161616]\"\n />\n {/* Dismiss this ONE toast without navigating. The bubble itself is the\n activate target, so the close control has to stop propagation or\n \"get rid of it\" would mean \"open it\" (reported 2026-08-12). */}\n <button\n type=\"button\"\n aria-label=\"Dismiss notification\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onClose()\n }}\n className=\"absolute right-2 top-2 flex h-5 w-5 items-center justify-center rounded-full text-[#FFFFFF] opacity-60 transition hover:bg-[#FFFFFF]/10 hover:opacity-100\"\n >\n <XGlyph size={12} />\n </button>\n <p className=\"truncate pr-6 text-sm font-semibold\">{reply.name}</p>\n <p className=\"mt-1 truncate text-xs opacity-85\">{reply.preview}</p>\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onSilence()\n }}\n className=\"mt-2 inline-flex items-center gap-1 text-[11px] font-semibold text-[#FFFFFF] opacity-60 transition hover:opacity-100\"\n >\n <BellOffGlyph size={12} />\n Silence notifications\n </button>\n </div>\n )\n}\n\nexport function NotificationsAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch } = useNavChrome('NotificationsAction')\n const [payload, setPayload] = useState<ChromeNotificationsPayload | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n const [notif, setNotif] = useState<NotifState>(() => readNotifState(orgId))\n const [toastReply, setToastReply] = useState<ChromeNotificationReply | null>(null)\n const [toastsMuted, setToastsMuted] = useState<boolean>(() => readToastsMuted())\n const [openToken, setOpenToken] = useState(0)\n const [panelOpen, setPanelOpen] = useState(false)\n // Also yield to a panel opened from a NEIGHBOURING trigger — the fuel panel\n // is right-aligned and wide enough to sit under the bell.\n const anyPanelOpen = useAnyTopBarPanelOpen()\n\n // Re-hydrate the read/seen watermark whenever the active org changes.\n useEffect(() => {\n setNotif(readNotifState(orgId))\n setToastReply(null)\n }, [orgId])\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n setLoading(true)\n setError(false)\n setPayload(null)\n dedupedFetch(\n 'notifications',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (!cancelled) setPayload(data as ChromeNotificationsPayload)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, orgId])\n\n // 10DLC registration alert: surfaced only in the notifications panel/badge\n // (unread state). No auto-redirect — see Decisions in PR for feat/spec-overlay.\n\n const markRead = useCallback(\n (id: string) => {\n setNotif((prev) => {\n if (prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: [...prev.readAlertIds, id] }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId],\n )\n\n const markUnread = useCallback(\n (id: string) => {\n setNotif((prev) => {\n if (!prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: prev.readAlertIds.filter((x) => x !== id) }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId],\n )\n\n // Opening the panel advances the \"last seen\" watermark (replies are seen).\n const onOpen = useCallback(() => {\n // The panel shows the reply the toast was previewing, so the toast has\n // nothing left to say — retire it rather than let it cover the panel.\n setToastReply(null)\n setNotif((prev) => {\n const next = { ...prev, lastSeenAt: new Date().toISOString() }\n writeNotifState(orgId, next)\n return next\n })\n }, [orgId])\n\n const alerts = payload?.alerts ?? []\n const replies = payload?.replies ?? []\n const imports = payload?.imports ?? []\n const quarantined = payload?.quarantined ?? []\n\n // New-reply toast: surface the newest reply that is (a) newer than the seen\n // watermark and (b) not already toasted this org. One at a time; the id is\n // recorded so a re-render / re-fetch never re-toasts it (capped at 50).\n useEffect(() => {\n // Silenced for this session — surface nothing new (the badge still counts).\n if (toastsMuted) return\n if (!payload || toastReply || panelOpen) return\n const candidate = replies\n .filter((r) => {\n if (!r.createdAt) return false\n if (notif.lastSeenAt && r.createdAt <= notif.lastSeenAt) return false\n return !notif.toastedReplyIds.includes(r.id)\n })\n .sort((a, b) => (a.createdAt! < b.createdAt! ? 1 : -1))[0]\n if (!candidate) return\n setToastReply(candidate)\n setNotif((prev) => {\n const next = {\n ...prev,\n toastedReplyIds: [candidate.id, ...prev.toastedReplyIds].slice(0, 50),\n }\n writeNotifState(orgId, next)\n return next\n })\n }, [\n payload,\n replies,\n toastReply,\n panelOpen,\n toastsMuted,\n notif.lastSeenAt,\n notif.toastedReplyIds,\n orgId,\n ])\n\n // Toast click: navigate to the reply's href when it carries one; otherwise\n // open the notifications panel (which also advances the seen watermark).\n const setMuted = useCallback((muted: boolean) => {\n writeToastsMuted(muted)\n setToastsMuted(muted)\n }, [])\n\n const onToastSilence = useCallback(() => {\n setMuted(true)\n setToastReply(null)\n }, [setMuted])\n\n const onToastActivate = useCallback(() => {\n const href = toastReply?.href\n setToastReply(null)\n if (href && typeof window !== 'undefined') {\n window.location.assign(href)\n return\n }\n setOpenToken((t) => t + 1)\n }, [toastReply])\n\n // Badge: UNREAD alerts + replies newer than the last-seen watermark. A reply\n // with no timestamp counts before the first open, then is treated as seen.\n const unreadAlertCount = alerts.filter((a) => !notif.readAlertIds.includes(a.id)).length\n const unseenReplyCount = replies.filter((r) => {\n if (!notif.lastSeenAt) return true\n if (!r.createdAt) return false\n return r.createdAt > notif.lastSeenAt\n }).length\n const badgeCount = unreadAlertCount + unseenReplyCount\n\n const isEmpty =\n alerts.length === 0 && replies.length === 0 && imports.length === 0 && quarantined.length === 0\n\n return (\n // Relative wrapper so the new-reply toast anchors to the bell trigger,\n // outside the popover panel (same pattern as the fuel low-fuel nudge).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Alerts & Notifications\"\n description=\"System alerts and recent activity for the active organization.\"\n slot=\"notifications\"\n fallbackIcon={BellGlyph}\n badge={loading ? 0 : badgeCount}\n onOpen={onOpen}\n openToken={openToken}\n onOpenChange={setPanelOpen}\n >\n <div className=\"px-4 py-3\">\n <div className=\"mb-2 flex items-center justify-between gap-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Notifications\n </p>\n {/* Only shown once silenced — the way back, in the same session. */}\n {toastsMuted ? (\n <button\n type=\"button\"\n onClick={() => setMuted(false)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n Unsilence\n </button>\n ) : null}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-2 py-1\">\n <ValueSkeleton className=\"h-4 w-full\" />\n <ValueSkeleton className=\"h-4 w-3/4\" />\n </div>\n ) : error ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Notifications are unavailable right now.\n </p>\n ) : isEmpty ? (\n <p className=\"py-1 text-sm text-[color:var(--muted)]\">You’re all caught up.</p>\n ) : (\n <div className=\"flex max-h-80 flex-col gap-2 overflow-y-auto\">\n {/* Alerts (with per-item read toggle) + replies — unchanged order. */}\n {alerts.length > 0 || replies.length > 0 ? (\n <ul className=\"flex flex-col gap-1\">\n {alerts.map((a) => {\n const isRead = notif.readAlertIds.includes(a.id)\n return (\n <li key={a.id} className={isRead ? 'opacity-50' : undefined}>\n <div className=\"flex items-start gap-1 rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n <a\n href={a.href ?? '#'}\n onClick={() => markRead(a.id)}\n className=\"block min-w-0 flex-1\"\n >\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {a.title}\n </p>\n <p className=\"text-xs text-[color:var(--muted)]\">{a.description}</p>\n </a>\n <button\n type=\"button\"\n aria-label={isRead ? 'Mark as unread' : 'Mark as read'}\n onClick={() => (isRead ? markUnread(a.id) : markRead(a.id))}\n className=\"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[color:var(--muted)] transition hover:bg-[color:var(--panel-elevated)] hover:text-[color:var(--foreground)]\"\n >\n <CheckGlyph />\n </button>\n </div>\n </li>\n )\n })}\n {/* A reply row is a REAL link when it carries a deep-link, so\n the hover highlight leads somewhere: the conversation the\n reply arrived in (reported 2026-08-12). Rows without an\n href stay inert rather than pretending to be clickable. */}\n {replies.map((r) => {\n const body = (\n <>\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {r.name}\n </p>\n <p className=\"truncate text-xs text-[color:var(--muted)]\">{r.preview}</p>\n </>\n )\n return (\n <li key={r.id}>\n {r.href ? (\n <a\n href={r.href}\n aria-label={`Open the conversation with ${r.name}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--panel)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n {body}\n </a>\n ) : (\n <div className=\"rounded-lg px-2 py-2\">{body}</div>\n )}\n </li>\n )\n })}\n </ul>\n ) : null}\n\n {/* Imports — running/finished contact imports. */}\n {imports.length > 0 ? (\n <div>\n <p className=\"mb-1 px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Imports\n </p>\n <ul className=\"flex flex-col gap-1\">\n {imports.map((imp) => (\n <li key={imp.id} className=\"rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n {imp.href ? (\n <a href={imp.href} className=\"block\">\n <ImportRow imp={imp} />\n </a>\n ) : (\n <ImportRow imp={imp} />\n )}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {/* Quarantined contact clusters. */}\n {quarantined.length > 0 ? (\n <div>\n <div className=\"mb-1 flex items-center justify-between px-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Quarantined Contacts\n </p>\n <a\n href={withOrgParam(QUARANTINED_CONTACTS_URL, orgId)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n View all\n </a>\n </div>\n <ul className=\"flex flex-col gap-1\">\n {/* Each row is a REAL link, not a div with a hover class. It\n used to carry a hover highlight on a non-interactive <li>,\n so the row advertised interactivity and then did nothing\n when clicked (reported 2026-08-03). An affordance has to\n lead somewhere: the row opens the quarantined-contacts\n view filtered to that number — the same destination as\n \"View all\", scoped. Being an <a> makes it keyboard\n focusable and Enter-activatable for free. */}\n {quarantined.map((q) => (\n <li key={q.phone}>\n <a\n href={withPhoneParam(withOrgParam(QUARANTINED_CONTACTS_URL, orgId), q.phone)}\n aria-label={`Review ${q.count} quarantined message${q.count === 1 ? '' : 's'} from ${formatPhone(q.phone)}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--nav-row-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {formatPhone(q.phone)}\n </span>\n {/* Same geometry as the shared TopBarCountBadge (16px\n circle, 10px/400, px-1); it sits in flow rather\n than absolutely on a 32px trigger, because this is\n a list row and not a top-bar icon. */}\n <span className=\"flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--panel)] px-1 text-[10px] font-normal leading-none tabular-nums text-[color:var(--muted)]\">\n {q.count > 99 ? '99+' : q.count}\n </span>\n </div>\n {q.latestAt ? (\n <p className=\"text-xs text-[color:var(--muted)]\">\n {new Date(q.latestAt).toLocaleString()}\n </p>\n ) : null}\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n </div>\n )}\n </div>\n </TopBarPopover>\n {/* Only ONE surface at this anchor at a time: the toast yields to the panel\n (both hang off the bell trigger, so rendering both means the toast sits\n on the panel's header — Reference/UI-Platform, one surface per trigger). */}\n {toastReply && !panelOpen && !anyPanelOpen ? (\n <NewReplyToast\n reply={toastReply}\n onActivate={onToastActivate}\n onClose={() => setToastReply(null)}\n onSilence={onToastSilence}\n />\n ) : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SupportAction — life-buoy trigger + the shared support-request modal\n// (never a mailto:, never an app-local form — Reference/UI-Platform).\n// ---------------------------------------------------------------------------\n\n/**\n * Compose the delivered support message: the user's note, then a context block\n * carrying the page, URL and active org — plus a Reply-to line when the user\n * had to supply contact details the profile was missing. The upstream contract\n * stays `POST support { message }`; this just enriches the text (VRM parity).\n */\nfunction composeSupportMessage(input: {\n note: string\n pageTitle: string\n url: string\n orgName?: string | null\n replyEmail?: string\n replyPhone?: string\n}): string {\n const ctx = [`Page: ${input.pageTitle || 'Unknown'}`, `URL: ${input.url}`]\n if (input.orgName) ctx.push(`Org: ${input.orgName}`)\n const reply = [input.replyEmail?.trim(), input.replyPhone?.trim()].filter(Boolean).join(' / ')\n if (reply) ctx.push(`Reply-to: ${reply}`)\n return `${input.note.trim()}\\n\\n---\\n${ctx.join('\\n')}`\n}\n\nexport function SupportAction({\n orgId,\n orgs: knownOrgs,\n}: { orgId?: string | null; orgs?: { id: string; name: string | null }[] } = {}) {\n const { fetchJson } = useNavChrome('SupportAction')\n const { me, loaded } = useChromeMe()\n // A caller that already holds the org list skips the chrome `/api/orgs` call.\n const { orgs: fetchedOrgs } = useChromeOrgs({ enabled: !knownOrgs })\n const orgs = knownOrgs ?? fetchedOrgs\n const [open, setOpen] = useState(false)\n const [message, setMessage] = useState('')\n const [email, setEmail] = useState('')\n const [phone, setPhone] = useState('')\n const [showEmailError, setShowEmailError] = useState(false)\n const [state, setState] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle')\n\n // The profile knows email/phone unless the chrome `me` loaded without them —\n // then we collect the missing one(s) in the modal (email required, phone not).\n const meEmail = me?.email ?? null\n const mePhone = me?.phone ?? null\n const missingEmail = loaded && !meEmail\n const missingPhone = loaded && !mePhone\n\n const activeOrg =\n (orgId ? orgs?.find((o) => o.id === orgId) : null) ??\n (orgs && orgs.length === 1 ? orgs[0] : null)\n const orgName = activeOrg?.name ?? null\n\n const close = useCallback(() => {\n setOpen(false)\n setState('idle')\n setMessage('')\n setShowEmailError(false)\n }, [])\n\n // Seed the contact inputs from the profile whenever the modal opens.\n useEffect(() => {\n if (!open) return\n setEmail(meEmail ?? '')\n setPhone(mePhone ?? '')\n setShowEmailError(false)\n }, [open, meEmail, mePhone])\n\n useEffect(() => {\n if (!open) return\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') close()\n }\n document.addEventListener('keydown', onKey)\n return () => document.removeEventListener('keydown', onKey)\n }, [open, close])\n\n const submit = async () => {\n if (!message.trim() || state === 'sending') return\n\n const resolvedEmail = (missingEmail ? email : meEmail ?? '').trim()\n const resolvedPhone = (missingPhone ? phone : mePhone ?? '').trim()\n // Email is required when the profile didn't carry one.\n if (missingEmail && !resolvedEmail) {\n setShowEmailError(true)\n return\n }\n setShowEmailError(false)\n\n const collectedContact = missingEmail || missingPhone\n const fullMessage = composeSupportMessage({\n note: message,\n pageTitle: typeof document !== 'undefined' ? document.title : '',\n url: typeof window !== 'undefined' ? window.location.href : '',\n orgName,\n replyEmail: collectedContact ? resolvedEmail : undefined,\n replyPhone: collectedContact ? resolvedPhone : undefined,\n })\n\n setState('sending')\n try {\n await fetchJson('support', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ message: fullMessage }),\n })\n setState('sent')\n } catch {\n setState('error')\n }\n }\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Support\"\n className={topBarIconButtonClass()}\n onClick={() => setOpen(true)}\n >\n <SlotGlyph slot=\"support\" fallback={LifeBuoyGlyph} />\n <TopBarTooltip\n title=\"Support\"\n description=\"Send a support request to the Politogy team.\"\n />\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n // Portaled to <body>: the top bar's backdrop-blur creates a CSS\n // containing block, so a fixed-position descendant would center on\n // the HEADER (rendering off-screen) instead of the viewport.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Support request\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) close()\n }}\n >\n <div className=\"w-full max-w-md rounded-2xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-6 shadow-[var(--shadow-soft)]\">\n <h2 className=\"text-lg font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Contact Support\n </h2>\n {state === 'sent' ? (\n <>\n <p className=\"mt-3 text-sm text-[color:var(--muted)]\">\n Your request was sent. The team will reply by email.\n </p>\n <div className=\"mt-5 flex justify-end\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full bg-[color:var(--color-accent)] px-4 py-2 text-sm font-semibold text-[#FFFFFF] hover:opacity-90\"\n >\n Done\n </button>\n </div>\n </>\n ) : (\n <>\n <p className=\"mt-1 text-sm text-[color:var(--muted)]\">\n Describe the problem or question. Your account details ride along\n automatically.\n </p>\n {missingEmail ? (\n <label className=\"mt-4 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your email\n </span>\n <input\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder=\"you@example.com\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {showEmailError ? (\n <span className=\"mt-1 block text-xs text-[color:var(--chrome-danger)]\">\n Enter an email so support can reply.\n </span>\n ) : null}\n </label>\n ) : null}\n {missingPhone ? (\n <label className=\"mt-3 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your phone — optional\n </span>\n <input\n type=\"tel\"\n value={phone}\n onChange={(e) => setPhone(e.target.value)}\n placeholder=\"(503) 555-1212\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n </label>\n ) : null}\n <textarea\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n rows={5}\n placeholder=\"How can we help?\"\n className=\"mt-4 w-full resize-y rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {state === 'error' ? (\n <p className=\"mt-2 text-sm text-[color:var(--chrome-danger)]\">\n Sending failed — try again.\n </p>\n ) : null}\n <div className=\"mt-4 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full border border-[color:var(--line)] px-4 py-2 text-sm font-semibold text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={submit}\n disabled={!message.trim() || state === 'sending'}\n className=\"rounded-full bg-[color:var(--color-accent)] px-4 py-2 text-sm font-semibold text-[#FFFFFF] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {state === 'sending' ? 'Sending…' : 'Send request'}\n </button>\n </div>\n </>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SpecOverlayAction — Spencer + Ben only. A top-bar \"Spec\" trigger showing\n// the current page's spec compliance / visual-regression status, from the\n// Specs app's overlay API. Renders NOTHING when the viewer isn't allowed —\n// no icon, no badge, no console noise — so this is invisible to every other\n// user. All calls are plain cross-origin fetches with same-site cookies\n// (credentials: 'include'); this does NOT go through the chrome proxy\n// fetchJson, which is same-origin only.\n// ---------------------------------------------------------------------------\n\ntype SpecOverlayAccess = { allowed: boolean; email?: string }\n\ntype SpecOverlayStatus =\n | {\n matched: true\n spec_slug: string\n spec_title: string\n target_id: string\n label: string\n viewport: string\n /** null when there is no finished compare run yet — never coerce to 0. */\n mismatch_pct: number | null\n finished_at: string | null\n passed: boolean | null\n spec_url: string\n compare_url: string\n overlay_url: string\n live_selector?: string | null\n capture_url?: string\n theme?: 'light' | 'dark' | null\n live_source?: 'worker' | 'viewer' | null\n live_size?: { width: number; height: number } | null\n design_size?: { width: number; height: number } | null\n /** Ready-to-paste repair prompt for an AI agent (latest run). */\n prompt?: string | null\n }\n | { matched: false; search_url: string }\n\nconst SPEC_OVERLAY_ACCESS_CACHE_KEY = 'politogy_spec_overlay_access'\n\nfunction readSpecOverlayAccessCache(): SpecOverlayAccess | null {\n if (typeof window === 'undefined') return null\n try {\n const raw = window.sessionStorage.getItem(SPEC_OVERLAY_ACCESS_CACHE_KEY)\n if (!raw) return null\n const parsed = JSON.parse(raw)\n if (typeof parsed?.allowed === 'boolean') return parsed as SpecOverlayAccess\n } catch {\n /* ignore */\n }\n return null\n}\n\nfunction writeSpecOverlayAccessCache(access: SpecOverlayAccess): void {\n if (typeof window === 'undefined') return\n try {\n window.sessionStorage.setItem(SPEC_OVERLAY_ACCESS_CACHE_KEY, JSON.stringify(access))\n } catch {\n /* ignore */\n }\n}\n\n/**\n * Notifies subscribers whenever the URL changes via pushState, replaceState\n * or a back/forward navigation. Patches `history` exactly once per page\n * (module-level guard) no matter how many components subscribe.\n */\ntype LocationChangeListener = () => void\nconst locationChangeListeners = new Set<LocationChangeListener>()\nlet historyPatched = false\n\nfunction ensureHistoryPatched(): void {\n if (historyPatched || typeof window === 'undefined') return\n historyPatched = true\n const notify = () => locationChangeListeners.forEach((fn) => fn())\n const originalPushState = window.history.pushState.bind(window.history)\n const originalReplaceState = window.history.replaceState.bind(window.history)\n window.history.pushState = (...args: Parameters<History['pushState']>) => {\n originalPushState(...args)\n notify()\n }\n window.history.replaceState = (...args: Parameters<History['replaceState']>) => {\n originalReplaceState(...args)\n notify()\n }\n window.addEventListener('popstate', notify)\n}\n\nfunction useLocationHref(): string {\n const [href, setHref] = useState(() =>\n typeof window === 'undefined' ? '' : window.location.href,\n )\n useEffect(() => {\n ensureHistoryPatched()\n const onChange = () => setHref(window.location.href)\n locationChangeListeners.add(onChange)\n return () => {\n locationChangeListeners.delete(onChange)\n }\n }, [])\n return href\n}\n\nfunction specOverlayFetchJson(path: string): Promise<unknown> {\n // Bounded: this hits a cross-origin app (specs.politogyvrm.com) from every\n // page's top bar. An unbounded call here let a stuck access/status check\n // keep the page's network alive indefinitely — which blocks `networkidle`\n // and tripped visual-regression captures' own 45s navigation timeout on\n // the very pages this widget instruments (seen on a2p 2026-10-02).\n return fetch(`${SPECS_ORIGIN}${path}`, { credentials: 'include', signal: AbortSignal.timeout(10_000) }).then((res) => {\n if (!res.ok) throw new Error(`spec overlay ${path}: ${res.status}`)\n return res.json()\n })\n}\n\n/**\n * True when this page is being driven by an automated capture session\n * (Cloudflare Browser Rendering / CDP-controlled Chromium — the Specs\n * design-compare tool, among others) rather than a real Spencer/Ben\n * session. `navigator.webdriver` is the standard CDP automation flag.\n * SpecOverlayAction must never self-trigger a capture loop in this case:\n * doing so competed with the very capture session rendering the page for\n * network activity, keeping `networkidle` from ever being reached.\n */\nfunction isAutomatedCaptureSession(): boolean {\n return typeof navigator !== 'undefined' && navigator.webdriver === true\n}\n\nfunction currentChromeTheme(): 'light' | 'dark' {\n const root = document.documentElement\n if (root.classList.contains('dark') || root.getAttribute('data-theme') === 'dark') return 'dark'\n if (root.classList.contains('light') || root.getAttribute('data-theme') === 'light') return 'light'\n return 'light'\n}\n\n/** Marks the drawer portal so the page raster leaves it out. */\nconst SPEC_OVERLAY_ROOT_ATTR = 'data-spec-overlay-root'\n\n/**\n * The viewer's real view: rasterize THIS page in the browser (DOM → canvas,\n * no permission prompt) at viewport size, without the Spec drawer, and send it\n * to Specs as the LIVE side of a compare. Their org, data and theme are\n * exactly what is on screen, cropped to the content region. Nothing but the PNG\n * and page facts leaves the browser.\n */\nasync function captureMyView(\n status: Extract<SpecOverlayStatus, { matched: true }>,\n orgId: string | null | undefined,\n orgName: string | null | undefined,\n): Promise<void> {\n const { domToCanvas } = await import('modern-screenshot')\n const w = window.innerWidth\n const h = window.innerHeight\n const theme = currentChromeTheme()\n const bg = getComputedStyle(document.body).backgroundColor || (theme === 'dark' ? '#0b0b0c' : '#ffffff')\n const full = await domToCanvas(document.body, {\n width: w,\n height: h,\n scale: 1,\n backgroundColor: bg,\n // Cross-origin images that refuse CORS render blank instead of failing.\n fetch: { requestInit: { mode: 'cors', credentials: 'omit' }, placeholderImage: '' },\n // Drop the Spec drawer and everything fixed (sidebar, toasts, popovers):\n // the design is the page body only, so chrome would only add noise.\n filter: (node) =>\n !(node instanceof Element) ||\n (!node.hasAttribute(SPEC_OVERLAY_ROOT_ATTR) && getComputedStyle(node).position !== 'fixed'),\n style: { transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)` },\n })\n\n // Score the content region only — the target's live_selector, else the\n // shell's content column (below the top bar and beta banner, right of the\n // sidebar) — so LIVE covers the same region as the design export.\n const el =\n (status.live_selector ? document.querySelector(status.live_selector) : null) ??\n document.querySelector('[data-shell-content]')\n let region = { x: 0, y: 0, width: w, height: h }\n if (el) {\n const r = el.getBoundingClientRect()\n const x = Math.max(0, Math.round(r.left))\n const y = Math.max(0, Math.round(r.top))\n region = { x, y, width: Math.min(w - x, Math.round(r.width)), height: Math.min(h - y, Math.round(r.height)) }\n }\n const out = document.createElement('canvas')\n out.width = region.width\n out.height = region.height\n const ctx = out.getContext('2d')\n if (!ctx) throw new Error('page raster failed')\n ctx.drawImage(full, region.x, region.y, region.width, region.height, 0, 0, region.width, region.height)\n const blob = await new Promise<Blob | null>((resolve) => out.toBlob(resolve, 'image/png'))\n if (!blob) throw new Error('page raster failed')\n const form = new FormData()\n form.append('image', blob, 'live.png')\n form.append(\n 'meta',\n JSON.stringify({ url: window.location.href, theme, org_id: orgId ?? null, org_name: orgName ?? null, crop: null }),\n )\n const res = await fetch(status.capture_url ?? `${SPECS_ORIGIN}/api/overlay/capture`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'X-Spec-Capture': '1' },\n body: form,\n signal: AbortSignal.timeout(10_000),\n })\n if (!res.ok) throw new Error(`capture ${res.status}: ${(await res.text()).slice(0, 160)}`)\n}\n\n/** Spinner + LIVE/DIFF skeletons shown while the capture and compare run. */\nexport function SpecCaptureLoading() {\n return (\n <div data-spec-capture-loading=\"\" role=\"status\" aria-live=\"polite\" className=\"flex-1 overflow-hidden px-4 py-4\">\n <div className=\"mb-4 flex items-center gap-3 text-sm text-[color:var(--foreground)]\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block h-5 w-5 animate-spin rounded-full border-2 border-[color:var(--line)] border-t-[color:var(--color-accent)] motion-reduce:animate-none\"\n />\n Capturing your view and comparing…\n </div>\n {['Live — your view', 'Diff'].map((label) => (\n <div key={label} className=\"mb-4\">\n <p className=\"mb-1 text-xs font-semibold uppercase tracking-wide text-[color:var(--muted)]\">{label}</p>\n <div aria-hidden=\"true\" className=\"h-40 w-full animate-pulse rounded border border-[color:var(--line)] bg-[color:var(--panel)] motion-reduce:animate-none\" />\n </div>\n ))}\n </div>\n )\n}\n\n/** Status URL for this page in the viewer's current theme. */\nfunction specOverlayStatusPath(): string {\n return `/api/overlay/status?url=${encodeURIComponent(window.location.href)}&theme=${currentChromeTheme()}`\n}\n\nexport function SpecOverlayAction({ orgId, orgName }: { orgId?: string | null; orgName?: string | null } = {}) {\n const [access, setAccess] = useState<SpecOverlayAccess | null>(() => readSpecOverlayAccessCache())\n const [status, setStatus] = useState<SpecOverlayStatus | null>(null)\n const [open, setOpen] = useState(false)\n const [capture, setCapture] = useState<{ state: 'idle' | 'busy' | 'error'; message?: string }>({ state: 'idle' })\n const [frameKey, setFrameKey] = useState(0)\n const [copied, setCopied] = useState<'idle' | 'copied' | 'failed'>('idle')\n const href = useLocationHref()\n const automated = isAutomatedCaptureSession()\n\n // Resolve access once per session (cached in sessionStorage).\n useEffect(() => {\n if (access || automated) return\n let cancelled = false\n specOverlayFetchJson('/api/overlay/access')\n .then((data) => {\n if (cancelled) return\n const next: SpecOverlayAccess =\n data && typeof (data as SpecOverlayAccess).allowed === 'boolean'\n ? (data as SpecOverlayAccess)\n : { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n .catch(() => {\n if (cancelled) return\n const next: SpecOverlayAccess = { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n return () => {\n cancelled = true\n }\n }, [access])\n\n // Fetch status for the current page, debounced 300ms, on every route\n // change and org change. Only once access is known to be allowed.\n useEffect(() => {\n if (automated || !access?.allowed || typeof window === 'undefined') return\n const timer = window.setTimeout(() => {\n specOverlayFetchJson(specOverlayStatusPath())\n .then((data) => setStatus(data as SpecOverlayStatus))\n .catch(() => setStatus(null))\n }, 300)\n return () => window.clearTimeout(timer)\n }, [access?.allowed, href, orgId])\n\n // Opening the drawer captures the viewer's real view automatically — no\n // click, no prompt. The raster runs while the drawer is open; the drawer is\n // filtered out of the frame. One capture per open.\n const captureRun = useRef(0)\n // Live-read access inside the retry loop below: access can be revoked\n // mid-poll (session expiry, org switch), and the loop must stop hitting\n // /api/overlay/status the moment that happens rather than riding out its\n // full 45 × 3s budget regardless.\n const accessRef = useRef(access)\n accessRef.current = access\n const runCapture = async (s: Extract<SpecOverlayStatus, { matched: true }>) => {\n const run = ++captureRun.current\n const before = s.live_source === 'viewer' ? s.finished_at : null\n setCapture({ state: 'busy' })\n try {\n // Let the drawer paint first so the page is idle while we raster.\n await new Promise((r) => setTimeout(r, 150))\n await captureMyView(s, orgId, orgName)\n for (let i = 0; i < 45; i++) {\n await new Promise((r) => setTimeout(r, 3000))\n if (run !== captureRun.current) return\n // Access lost mid-poll: stop, but never leave the spinner up forever.\n if (!accessRef.current?.allowed) {\n setCapture({ state: 'idle' })\n return\n }\n const next = (await specOverlayFetchJson(specOverlayStatusPath()).catch(() => null)) as SpecOverlayStatus | null\n if (next && next.matched && next.live_source === 'viewer' && next.finished_at !== before) {\n setStatus(next)\n setFrameKey((k) => k + 1)\n setCapture({ state: 'idle' })\n return\n }\n }\n setCapture({ state: 'error', message: 'Compare did not finish in 2 min.' })\n } catch (e) {\n if (run === captureRun.current) setCapture({ state: 'error', message: e instanceof Error ? e.message : String(e) })\n }\n }\n useEffect(() => {\n if (automated || !open || !status || !status.matched) return\n void runCapture(status)\n return () => {\n captureRun.current++\n }\n // Only re-run on open / page change, not on every status refresh.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, status && status.matched ? status.target_id : null])\n\n\n if (automated || !access?.allowed) return null\n\n const hasScore = status && status.matched && typeof status.mismatch_pct === 'number'\n const badgeLabel =\n hasScore ? `${Math.round((status as Extract<SpecOverlayStatus, { matched: true }>).mismatch_pct as number)}%` : status ? '—' : undefined\n const badgeTone: 'default' | 'warning' | 'danger' =\n hasScore ? (status && status.matched && status.passed ? 'default' : 'danger') : 'default'\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Spec\"\n aria-expanded={open}\n className={topBarIconButtonClass(badgeTone)}\n onClick={() => setOpen(true)}\n >\n <LayoutGlyph size={TOPBAR_GLYPH_SIZE} className=\"text-current\" />\n {badgeLabel ? (\n <span\n className={[\n 'absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-normal leading-none text-[#FFFFFF]',\n hasScore\n ? status && status.matched && status.passed\n ? 'bg-[color:var(--chrome-success,#2f855a)]'\n : 'bg-[color:var(--chrome-danger)]'\n : 'bg-[color:var(--muted)]',\n ].join(' ')}\n >\n {badgeLabel}\n </span>\n ) : null}\n {!open ? (\n <TopBarTooltip\n title=\"Spec\"\n description=\"Spec design + visual regression for this page.\"\n />\n ) : null}\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n className=\"fixed inset-0 z-50 flex justify-end bg-black/40\"\n {...{ [SPEC_OVERLAY_ROOT_ATTR]: '' }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Spec overlay\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) setOpen(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') setOpen(false)\n }}\n >\n <div className=\"flex h-full w-full max-w-[480px] flex-col border-l border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]\">\n <div className=\"flex items-center justify-between gap-2 border-b border-[color:var(--line)] px-4 py-3\">\n <h2 className=\"truncate text-sm font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Spec{status && status.matched ? `: ${status.spec_title}` : ''}\n </h2>\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={() => setOpen(false)}\n className=\"rounded-full p-1 text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]\"\n >\n <CloseGlyph size={16} />\n </button>\n </div>\n {status && status.matched ? (\n <>\n <div className=\"flex items-center gap-3 border-b border-[color:var(--line)] px-4 py-2 text-xs font-semibold\">\n <a\n href={status.spec_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent)] hover:underline\"\n >\n Open spec ↗\n </a>\n <a\n href={status.compare_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent)] hover:underline\"\n >\n Compare tab ↗\n </a>\n <button\n type=\"button\"\n disabled={capture.state === 'busy'}\n onClick={() => void runCapture(status)}\n className=\"ml-auto rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Your view is captured when the drawer opens. Recapture after changing the page.\"\n >\n {capture.state === 'busy' ? 'Capturing…' : 'Recapture'}\n </button>\n <button\n type=\"button\"\n data-spec-copy-prompt=\"\"\n disabled={capture.state === 'busy' || !status.prompt}\n onClick={() => {\n const text = status.prompt\n if (!text) return\n // The prompt is already in hand, so the write stays inside the click gesture.\n navigator.clipboard\n .writeText(text)\n .then(() => setCopied('copied'))\n .catch(() => setCopied('failed'))\n .finally(() => window.setTimeout(() => setCopied('idle'), 2000))\n }}\n className=\"rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Copy a repair prompt for an AI agent: spec, score, image links, top mismatched regions and instructions.\"\n >\n {copied === 'copied' ? 'Copied ✓' : copied === 'failed' ? 'Copy failed' : 'Copy prompt'}\n </button>\n </div>\n {status.live_size && status.design_size && capture.state !== 'busy' ? (\n <p\n data-spec-sizes=\"\"\n className={[\n 'border-b border-[color:var(--line)] px-4 py-1.5 text-xs',\n status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? 'text-[color:var(--muted)]'\n : 'font-semibold text-[color:var(--chrome-danger)]',\n ].join(' ')}\n >\n Live {status.live_size.width}×{status.live_size.height} · Design {status.design_size.width}×\n {status.design_size.height}\n {status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? ' · sizes match'\n : ' · SIZE MISMATCH'}\n </p>\n ) : null}\n {capture.state === 'error' ? (\n <p className=\"border-b border-[color:var(--line)] px-4 py-2 text-xs text-[color:var(--chrome-danger)]\">\n {capture.message}\n </p>\n ) : null}\n {capture.state === 'busy' ? (\n <SpecCaptureLoading />\n ) : (\n <iframe\n key={frameKey}\n src={status.overlay_url}\n title=\"Spec overlay\"\n className=\"h-full w-full flex-1 border-0\"\n />\n )}\n </>\n ) : status && !status.matched ? (\n <div className=\"p-4 text-sm text-[color:var(--muted)]\">\n <p>No compare target covers this page.</p>\n <a\n href={status.search_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"mt-2 inline-block font-semibold text-[color:var(--color-accent)] hover:underline\"\n >\n Search specs ↗\n </a>\n </div>\n ) : (\n <div className=\"p-4\">\n <ValueSkeleton className=\"h-4 w-full\" />\n </div>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\nfunction CloseGlyph({ size = 16, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NavDisplayAction — the Menu / Tabs / Both navigation-display switcher.\n// Controlled: the app owns persistence (localStorage/profile) and layout\n// consequences (sub-menu visibility, tab strip visibility).\n// ---------------------------------------------------------------------------\n\nexport type NavDisplayMode = 'menu' | 'tabs' | 'both'\n\nexport const NAV_DISPLAY_OPTIONS: { value: NavDisplayMode; label: string }[] = [\n { value: 'menu', label: 'Sub Menu' },\n { value: 'tabs', label: 'Tabs Only' },\n { value: 'both', label: 'Both' },\n]\n\nexport function NavDisplayAction({\n value,\n onChange,\n}: {\n value: NavDisplayMode\n onChange: (next: NavDisplayMode) => void\n}) {\n return (\n <TopBarPopover\n label=\"Navigation Display\"\n description=\"Show navigation as a sub-menu, tabs, or both.\"\n fallbackIcon={LayoutGlyph}\n panelClassName=\"w-44\"\n >\n <div className=\"py-1\" role=\"radiogroup\" aria-label=\"Navigation display\">\n {NAV_DISPLAY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex w-full items-center justify-between px-4 py-2 text-left text-sm font-medium',\n value === opt.value\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n {opt.label}\n {value === opt.value ? <span aria-hidden>✓</span> : null}\n </button>\n ))}\n </div>\n </TopBarPopover>\n )\n}\n\n// ---------------------------------------------------------------------------\n// useThemePreference — the cross-app theme state machine (Task: theme derived\n// from the Auth system, live across tabs and apps).\n//\n// boot : cookie → localStorage → \"system\" (the pre-paint script already\n// painted this), then ONCE per session reconcile against the\n// profile value from `GET me` (authoritative) when a fetcher is\n// available.\n// change : apply + localStorage + cross-subdomain cookie + best-effort\n// `PATCH me/preferences { themePreference }`.\n// sync : same-app tabs via the `storage` event; other-app tabs re-read the\n// shared cookie on focus/visibility; `system` follows live OS\n// changes via matchMedia.\n// ---------------------------------------------------------------------------\n\nexport function useThemePreference(): {\n value: ThemePreference\n setValue: (next: ThemePreference) => void\n} {\n const ctx = useContext(NavChromeContext)\n const fetchJson = ctx?.fetchJson ?? null\n const [value, setValueState] = useState<ThemePreference>('system')\n const reconciled = useRef(false)\n\n // Boot: cookie → localStorage → system.\n useEffect(() => {\n const cookie = readThemeCookie()\n let ls: string | null = null\n try {\n ls = localStorage.getItem(THEME_STORAGE_KEY)\n } catch {\n /* unavailable */\n }\n const pref = cookie ?? (isThemePreference(ls) ? ls : null) ?? 'system'\n setValueState(pref)\n applyThemePreference(pref)\n }, [])\n\n // Once per session: converge on the profile's saved choice (authoritative),\n // reusing the provider's single `me` fetch.\n const meCtx = useContext(NavChromeContext)\n useEffect(() => {\n if (reconciled.current) return\n // A choice made where no chrome-API session exists (Politogy ID's login\n // screen) is still only in the cookie. Push it UP rather than pulling the\n // stale profile value DOWN — otherwise the user's fresh pick is silently\n // reverted on the next app they open (HITL 2026-07-23: \"I set System and it\n // keeps switching back to Light\").\n const pending = readPendingThemeChoice()\n if (pending) {\n // Only latch once the profile write has actually been attempted, so a\n // later `me` arrival still gets a chance to persist it.\n if (meCtx?.me) reconciled.current = true\n setValueState(pending)\n applyThemePreference(pending)\n writeThemeCookie(pending)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pending)\n } catch {\n /* unavailable */\n }\n if (!meCtx?.me) return\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: pending }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n return\n }\n const pref = meCtx?.me?.themePreference\n if (isThemePreference(pref)) {\n reconciled.current = true\n setValueState(pref)\n applyThemePreference(pref)\n writeThemeCookie(pref)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pref)\n } catch {\n /* unavailable */\n }\n }\n }, [meCtx?.me])\n\n // Live sync: storage events (same-app tabs), focus/visibility cookie\n // re-reads (other-app tabs), and OS changes while on \"system\".\n useEffect(() => {\n const onStorage = (e: StorageEvent) => {\n if (e.key === THEME_STORAGE_KEY && isThemePreference(e.newValue)) {\n setValueState(e.newValue)\n applyThemePreference(e.newValue)\n }\n }\n const onWake = () => {\n const cookie = readThemeCookie()\n if (cookie) {\n setValueState((prev) => {\n if (cookie !== prev) applyThemePreference(cookie)\n return cookie\n })\n }\n }\n window.addEventListener('storage', onStorage)\n window.addEventListener('focus', onWake)\n document.addEventListener('visibilitychange', onWake)\n return () => {\n window.removeEventListener('storage', onStorage)\n window.removeEventListener('focus', onWake)\n document.removeEventListener('visibilitychange', onWake)\n }\n }, [])\n\n\n const setValue = useCallback(\n (next: ThemePreference) => {\n setValueState(next)\n applyThemePreference(next)\n writeThemeCookie(next)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, next)\n } catch {\n /* unavailable */\n }\n // Best-effort profile persistence — a theme toggle never errors. Until it\n // lands, the choice stays marked pending so the next app pushes it up\n // instead of reconciling the stale profile value back down.\n markThemeChoicePending(next)\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: next }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n },\n [fetchJson],\n )\n\n return { value, setValue }\n}\n","import type { ReactNode } from 'react';\nimport clsx from 'clsx';\n\ntype FormColumnProps = {\n children: ReactNode;\n className?: string;\n};\n\n/**\n * The ONE constrained layout inside the frame's fluid `<main>` (Brand guideline\n * \"Content width is fluid\"): a single left-aligned column, 960px max, for form\n * and settings pages — single-record edit forms, Organization Settings tabs,\n * My Profile, activation and setup flows. Data surfaces (tables, dashboards,\n * maps) never use it; they take the full fluid width.\n *\n * It adds no gutter of its own — `<main>` already owns the 24px / 16px gutter —\n * and it is never centered. There is no width prop on purpose: a per-page\n * max-width is exactly what the guideline forbids.\n */\nexport default function FormColumn({ children, className }: FormColumnProps) {\n return (\n <div data-shell-form-column=\"\" className={clsx('w-full max-w-[960px]', className)}>\n {children}\n </div>\n );\n}\n","import type { NavIcon } from './index'\nimport type { StandardNavIconKey } from './standardNav'\nimport {\n LuActivity,\n LuBriefcase,\n LuChartColumn,\n LuChartNoAxesColumn,\n LuCircleUser,\n LuClipboardList,\n LuClock,\n LuCreditCard,\n LuCrosshair,\n LuDollarSign,\n LuDoorOpen,\n LuFileText,\n LuFlag,\n LuHouse,\n LuLandmark,\n LuLayoutDashboard,\n LuLayoutGrid,\n LuLifeBuoy,\n LuList,\n LuMail,\n LuMap,\n LuMapPin,\n LuMessageSquare,\n LuMousePointerClick,\n LuPencil,\n LuPhone,\n LuSend,\n LuSettings,\n LuShare2,\n LuSignpost,\n LuTarget,\n LuUpload,\n LuUser,\n LuUsers,\n LuUsersRound,\n} from 'react-icons/lu'\n\n/**\n * The canonical icon map for standardPolitogyNav — ONE definition so every\n * app renders identical glyphs (including the Organization Settings branch:\n * briefcase / settings / creditCard / dollarSign / share).\n */\nexport const standardNavIcons: Record<StandardNavIconKey, NavIcon> = {\n home: LuHouse,\n users: LuUsers,\n mail: LuMail,\n messageSquare: LuMessageSquare,\n layout: LuLayoutDashboard,\n activity: LuActivity,\n lifeBuoy: LuLifeBuoy,\n grid: LuLayoutGrid,\n list: LuList,\n upload: LuUpload,\n edit: LuPencil,\n fileText: LuFileText,\n send: LuSend,\n clock: LuClock,\n user: LuUser,\n barChart: LuChartColumn,\n briefcase: LuBriefcase,\n settings: LuSettings,\n creditCard: LuCreditCard,\n dollarSign: LuDollarSign,\n share: LuShare2,\n // Campaign / Petition mode slots.\n phone: LuPhone,\n map: LuMap,\n mapPin: LuMapPin,\n target: LuTarget,\n flag: LuFlag,\n layoutDashboard: LuLayoutDashboard,\n usersRound: LuUsersRound,\n mousePointerClick: LuMousePointerClick,\n clipboardList: LuClipboardList,\n circleUser: LuCircleUser,\n crosshair: LuCrosshair,\n landmark: LuLandmark,\n chartNoAxes: LuChartNoAxesColumn,\n doorOpen: LuDoorOpen,\n signpost: LuSignpost,\n}\n","import { standardNavIcons } from './standardNavIcons'\nimport type { NavIcon, NavItem } from './index'\n\n// ---------------------------------------------------------------------------\n// standardPolitogyNav — the canonical Politogy VRM menu, per operating Mode.\n//\n// This is the single source of truth for the navigation every politogy app\n// renders. The RELATIONSHIP tree is extracted verbatim from VRM core's\n// relationship-mode sidebar (`getRelationshipLinkItems`); the CAMPAIGN and\n// PETITION trees mirror VRM core's mode-scoped menus. Apps consume the same\n// menu everywhere; an app that owns one of the items (e.g. the standalone\n// Contacts app) nests its own pages as that item's children while every other\n// entry links out to another *.politogyvrm.com app as an absolute URL —\n// full-page navigation with SSO shared across the domain.\n//\n// Which tree an app renders is NOT the user's live mode selection — it is the\n// app's own mode, mapped from the app registry (see `POLITOGY_APPS[app].mode`),\n// EXCEPT for a DUAL-MODE app (`POLITOGY_APPS[app].dual`, today: a2p — Specs/A2P:\n// \"the SMS/MMS delivery engine for Relationship Mode and Campaign Mode\"). A\n// dual app has no single fixed mode: its EFFECTIVE mode is resolved per-visit\n// by `resolveActiveMode` (mode-preference.ts) — `?mode=` query param on the\n// current URL → the `politogy_active_mode` cookie (written by every pinned app\n// and core whenever their own mode is known) → the app's own `dual.defaultMode`\n// — and THAT resolved value substitutes for `meta.mode` wherever this function\n// or the Mode pill would otherwise read it. A campaign-scoped, non-dual app\n// (phonebank / canvass / signs) always renders the Campaign tree; an unscoped\n// app (forms / surveys / polls / contacts) always renders Relationship, exactly\n// as before. Switching modes is a full-page navigation between mode homes (the\n// Mode pill's job), and each destination is itself pinned (or, for a2p,\n// resolved) — so the tree is deterministic from app identity + the mode\n// resolution above, never a value an app has to pass.\n// ---------------------------------------------------------------------------\n\n/**\n * Icon slots used by the standard menus. The shell stays icon-library-agnostic:\n * callers map each key to their own icon components (lucide, react-icons, …).\n * A missing key simply renders that row without an icon.\n */\nexport type StandardNavIconKey =\n | 'home'\n | 'users'\n | 'mail'\n | 'messageSquare'\n | 'layout'\n | 'activity'\n | 'lifeBuoy'\n | 'grid'\n | 'list'\n | 'upload'\n | 'edit'\n | 'fileText'\n | 'send'\n | 'clock'\n | 'user'\n | 'barChart'\n | 'briefcase'\n | 'settings'\n | 'creditCard'\n | 'dollarSign'\n | 'share'\n // Campaign / Petition mode slots.\n | 'phone'\n | 'map'\n | 'mapPin'\n | 'target'\n | 'flag'\n // Left-Navigation §9 Lucide slots.\n | 'layoutDashboard'\n | 'usersRound'\n | 'mousePointerClick'\n | 'clipboardList'\n | 'circleUser'\n | 'crosshair'\n | 'landmark'\n | 'chartNoAxes'\n | 'doorOpen'\n | 'signpost'\n\n/** The operating Mode whose nav tree to build. Defaults to `relationship`. */\nexport type StandardNavMode = 'relationship' | 'campaign' | 'petition'\n\n/**\n * Per-feature availability for the Campaign tree. Campaign Mode ships its apps\n * incrementally: a disabled feature is omitted from the nav entirely (rather\n * than rendered as a dead/disabled row), and its flag flips to `true` in a\n * later patch release as the app goes live. Dashboard and Voter Contact are\n * core-hosted and always present, so they carry no flag.\n */\nexport interface CampaignFeatureAvailability {\n a2p: boolean\n phonebank: boolean\n canvass: boolean\n signs: boolean\n tribes: boolean\n polling: boolean\n}\n\n/**\n * Launch state at this shell version: every Campaign feature is deployed and\n * live (a2p / phonebank / canvass / signs .politogyvrm.com all serve the app\n * behind SSO as of 2026-07-24), so no row is hidden. The flags remain so a\n * future feature can ship dark, and so a caller can hide one per-deployment.\n */\nexport const CAMPAIGN_FEATURE_AVAILABILITY: CampaignFeatureAvailability = {\n a2p: true,\n phonebank: true,\n canvass: true,\n signs: true,\n tribes: true,\n polling: true,\n}\n\n/** Absolute origins for the standalone Campaign / Petition apps. */\nconst A2P_ORIGIN = 'https://a2p.politogyvrm.com/'\nconst PHONEBANK_ORIGIN = 'https://phonebank.politogyvrm.com/'\nconst CANVASS_ORIGIN = 'https://canvass.politogyvrm.com/'\nconst SIGNS_ORIGIN = 'https://signs.politogyvrm.com/'\nconst POLLS_ORIGIN = 'https://polls.politogyvrm.com/'\n// app.politogyvrm.com (VRM core) is retired (Reference/UI-Platform →\n// \"Retirement of app.politogyvrm.com\", DECIDED 2026-10-07). These are its V2\n// replacements: Settings owns org settings/billing, Dashboard owns the\n// Relationship/Campaign dashboards and Battleground, auth owns the Politogy\n// ID account pages (my-profile, invite acceptance).\nconst SETTINGS_ORIGIN = 'https://settings.politogyvrm.com/'\nconst DASHBOARD_ORIGIN = 'https://dashboard.politogyvrm.com/'\nconst AUTH_ORIGIN = 'https://auth.politogyvrm.com/'\n// Tribes is a page inside the standalone Contacts app (Specs/Tribes: Tribes is\n// implemented as an extension of Contacts). Matches app-shell.tsx's `/tribes`.\nconst CONTACTS_TRIBES = 'https://contacts.politogyvrm.com/tribes'\n// Petition Mode is its own standalone app on its own subdomain (the petitions\n// repo deploys production to petition-mode.politogyvrm.com).\nconst PETITION_MODE_ORIGIN = 'https://petition-mode.politogyvrm.com/'\n\nexport interface StandardNavOptions {\n /**\n * @deprecated app.politogyvrm.com (VRM core) is retired (Reference/UI-Platform\n * → \"Retirement of app.politogyvrm.com\"). Every row this tree used to resolve\n * against VRM core now points at its V2 host directly, so this is unused.\n * Kept only so existing callers don't need to drop the field immediately.\n */\n coreBaseUrl?: string\n /** Icon component per slot; omitted slots render icon-less rows. */\n icons?: Partial<Record<StandardNavIconKey, NavIcon>>\n /**\n * App-local override for the \"Contacts\" item. `children` are used verbatim\n * (NOT absolutized) so the owning app nests its own routes; `href` (also\n * verbatim) feeds active-detection for the group header. When omitted, the\n * item carries VRM core's own contacts sub-pages as absolute links.\n * (Relationship tree only.)\n */\n contactsItem?: {\n href?: string\n children?: NavItem[]\n /**\n * Live contact count shown right-aligned on the Contacts row, already\n * formatted for display (\"31.9K\"). Only the owning app knows it.\n * (Specs/Contacts design: `Contacts · 31.9K`.)\n */\n count?: string | number | null\n }\n /**\n * Top-level rows to OMIT, by label (case-insensitive), e.g. `['Polls','CTAs']`.\n * The Specs/Contacts design rail lists Relationship → Collect → Account with\n * exactly Dashboard · Contacts · Email broadcast · SMS/MMS blast / Calls to\n * action · Forms · Surveys / My profile · Organization settings; apps that\n * still surface Polls / CTAs keep them by default. A section row with no\n * remaining items is dropped too.\n */\n hiddenItems?: string[]\n /**\n * App-local override for the Petition-mode \"Dashboard\" entry, same contract\n * as `contactsItem`: `href`/`children` used verbatim so the Petitions app\n * nests its own routes under the entry. (Petition tree only.)\n */\n petitionsItem?: { href?: string; children?: NavItem[] }\n /**\n * The trailing \"Support\" row. VRM core opens its SupportRequestModal here;\n * other apps supply their own handler (`onClick`) or a link (`href`).\n * Omitted or `false` → no Support row. Appended to every mode's tree.\n */\n supportItem?: { onClick?: () => void; href?: string } | false\n /**\n * Which mode's tree to build. Default `relationship`, whose output is\n * byte-for-byte what this function produced before modes existed.\n */\n mode?: StandardNavMode\n /**\n * Active organization id (full UUID). EVERY link in EVERY tree carries it as\n * `?org=<uuid>` — the same convention the Mode switcher and My Account menu\n * use — so the destination app opens on the same org instead of the user's\n * default one. Omit it only when the caller genuinely has no active org yet.\n */\n activeOrgId?: string | null\n /**\n * Per-feature Campaign availability overrides, merged over\n * `CAMPAIGN_FEATURE_AVAILABILITY`. Only meaningful for the Campaign tree.\n */\n campaignAvailability?: Partial<CampaignFeatureAvailability>\n}\n\n/**\n * Drop the top-level rows named in `hidden` (case-insensitive label match),\n * then any section row left with no rows beneath it.\n */\nfunction applyHiddenItems(items: NavItem[], hidden?: string[]): NavItem[] {\n if (!hidden || hidden.length === 0) return items\n const drop = new Set(hidden.map((h) => h.trim().toLowerCase()))\n const kept = items.filter((i) => i.kind === 'section' || !drop.has(i.label.toLowerCase()))\n return kept.filter((item, idx) => {\n if (item.kind !== 'section') return true\n const next = kept[idx + 1]\n return !!next && next.kind !== 'section'\n })\n}\n\n/**\n * One sub-item of a standalone app, as a path RELATIVE to that app's origin\n * (`''` is the app root). Resolved against the origin and given the active-org\n * query param, exactly like the parent row it hangs under.\n */\ntype CrossAppLeaf = { label: string; icon: StandardNavIconKey; path: string }\n\nconst CONTACTS_APP = 'https://contacts.politogyvrm.com'\n\nconst APP_CONTACTS_CHILDREN = [\n { label: 'Dashboard', icon: 'grid' as const, href: `${CONTACTS_APP}/` },\n { label: 'All Contacts', icon: 'list' as const, href: `${CONTACTS_APP}/contacts` },\n { label: 'Tribes', icon: 'users' as const, href: `${CONTACTS_APP}/tribes` },\n { label: 'Import', icon: 'upload' as const, href: `${CONTACTS_APP}/import` },\n { label: 'Fields', icon: 'layout' as const, href: `${CONTACTS_APP}/fields` },\n { label: 'Activity', icon: 'activity' as const, href: `${CONTACTS_APP}/activity` },\n { label: 'Duplicates', icon: 'fileText' as const, href: `${CONTACTS_APP}/duplicates` },\n]\n\n// Email Broadcast now points at the standalone Email Engine V2 app\n// (email.politogyvrm.com, Specs/Email-Engine six tabs + Deliverability). The\n// V1 surface inside VRM core stays reachable as the last child while both run\n// in parallel. Absolute hrefs so active-detection lights this group when the\n// user is inside the Email app (same pattern as Contacts / Forms / Surveys).\nconst EMAIL_APP = 'https://email.politogyvrm.com'\nconst APP_EMAIL_CHILDREN = [\n { label: 'Dashboard', icon: 'grid' as const, href: `${EMAIL_APP}/dashboard` },\n { label: 'Creative Canvas', icon: 'edit' as const, href: `${EMAIL_APP}/canvas` },\n { label: 'Sender Information', icon: 'mail' as const, href: `${EMAIL_APP}/sender` },\n { label: 'Recipients', icon: 'user' as const, href: `${EMAIL_APP}/recipients` },\n { label: 'Send & Automate', icon: 'send' as const, href: `${EMAIL_APP}/send` },\n { label: 'Statistics', icon: 'barChart' as const, href: `${EMAIL_APP}/statistics` },\n { label: 'Deliverability', icon: 'activity' as const, href: `${EMAIL_APP}/deliverability` },\n]\n// Organization Settings — promoted from the My Account menu into the left nav\n// (HITL directive 2026-07-23). Mirrors the main app's former page IA, now\n// served by the standalone Settings app (settings.politogyvrm.com, Specs/\n// Organization-Settings v12) rather than VRM core: /organization-settings/:tab,\n// with Subscription & Billing carrying its own third level\n// (/organization-settings/subscription-billing/:tab). This is the canonical\n// depth-3 example the nav renderers support.\ntype CoreBranch = CrossAppLeaf & { children?: CrossAppLeaf[] }\n\nconst ORG_SETTINGS_CHILDREN: CoreBranch[] = [\n { label: 'General', icon: 'settings', path: 'organization-settings' },\n {\n label: 'Subscription & Billing',\n icon: 'creditCard',\n path: 'organization-settings/subscription-billing',\n children: [\n { label: 'Current Plan', icon: 'fileText', path: 'organization-settings/subscription-billing/current-plan' },\n { label: 'SMS, MMS & Email Usage', icon: 'activity', path: 'organization-settings/subscription-billing/text-email' },\n { label: 'Wallet', icon: 'dollarSign', path: 'organization-settings/subscription-billing/wallet' },\n { label: '10DLC', icon: 'messageSquare', path: 'organization-settings/subscription-billing/10dlc' },\n { label: 'Billing History', icon: 'clock', path: 'organization-settings/subscription-billing/billing-history' },\n ],\n },\n { label: 'Email', icon: 'mail', path: 'organization-settings/email-settings' },\n { label: 'Users', icon: 'users', path: 'organization-settings/users' },\n { label: 'Shared Links', icon: 'share', path: 'organization-settings/shared-links' },\n]\n\n// The NEW standalone acquisition apps (forms./surveys./polls.politogyvrm.com)\n// replace the legacy in-core \"Forms & Surveys\" system (HITL directive\n// 2026-07-23; removal plan: politogy/docs/legacy-forms-removal-plan.md).\n// Absolute cross-app links — SSO carries the session.\nconst APP_FORMS_CHILDREN = [\n { label: 'Forms', icon: 'list' as const, href: 'https://forms.politogyvrm.com/?tab=forms' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://forms.politogyvrm.com/?tab=canvas' },\n { label: 'Submissions', icon: 'fileText' as const, href: 'https://forms.politogyvrm.com/?tab=submissions' },\n]\n// The Surveys sub-menu mirrors the app's tab strip: Surveys / Canvas / Results.\n// Canvas and Results are survey-scoped routes (/surveys/:id/canvas), so with no\n// survey selected the list page carries a ?view= param — distinct hrefs, so\n// active-detection singles out exactly one (identical hrefs were the earlier\n// all-active bug; query params ARE compared, hashes are not).\nconst APP_SURVEYS_CHILDREN = [\n { label: 'Surveys', icon: 'list' as const, href: 'https://surveys.politogyvrm.com/surveys' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://surveys.politogyvrm.com/surveys?view=canvas' },\n { label: 'Results', icon: 'barChart' as const, href: 'https://surveys.politogyvrm.com/surveys?view=results' },\n]\nconst APP_POLLS_CHILDREN = [\n { label: 'Command Center', icon: 'grid' as const, href: 'https://polls.politogyvrm.com/' },\n { label: 'New Poll', icon: 'edit' as const, href: 'https://polls.politogyvrm.com/polls/new' },\n]\n// Standalone CTAs app (ctas.politogyvrm.com, Specs/CTAs) — same pattern as\n// Forms/Surveys/Polls above. This is also now the target for the\n// \"Calls to action\" row in the Relationship tree (the legacy in-core feature\n// it used to render was retired with app.politogyvrm.com).\nconst APP_CTAS_CHILDREN = [\n { label: 'CTAs', icon: 'list' as const, href: 'https://ctas.politogyvrm.com/' },\n { label: 'Canvas', icon: 'edit' as const, href: 'https://ctas.politogyvrm.com/?tab=canvas' },\n]\n\n// ---------------------------------------------------------------------------\n// Campaign app sub-navigation.\n//\n// Reference/UI-Platform v13 (Left bar → Navigation): \"The canonical VRM nav\n// tree — PARENT GROUPS WITH SUB-ITEMS. The app's own pages nest under their\n// group.\" The Campaign tree shipped as eight flat rows with no `children`, so\n// the Navigation Display control's \"Both\" and \"Sub Menu\" modes had nothing to\n// expand in the left bar of a2p / phonebank / canvass / signs — the three modes\n// rendered an identical sidebar and the control looked broken.\n//\n// Each list below is the app's OWN section list, taken verbatim from that app's\n// in-app tab strip (its `components/Shell.tsx`), so the sidebar sub-menu and the\n// page tab strip name the same sections in the same order — the sidebar/tab\n// agreement Reference/UI-Platform exists to enforce.\n// ---------------------------------------------------------------------------\n\n/** a2p/components/Shell.tsx `TABS` — the six A2P tabs. */\nconst APP_A2P_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: 'dashboard' },\n { label: 'Compose', icon: 'edit', path: 'compose' },\n { label: 'Recipients', icon: 'user', path: 'recipients' },\n { label: 'Tech Check', icon: 'activity', path: 'tech-check' },\n { label: 'Status', icon: 'clock', path: 'status' },\n { label: 'Conversations', icon: 'messageSquare', path: 'conversations' },\n]\n\n/** phonebank/components/Shell.tsx `NAV` — the Manager console's sections. */\nconst APP_PHONEBANK_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: '' },\n { label: 'Campaigns', icon: 'phone', path: 'campaigns' },\n { label: 'Inbound', icon: 'messageSquare', path: 'inbound' },\n { label: 'Reports', icon: 'barChart', path: 'reports' },\n]\n\n/** canvass/components/Shell.tsx `SECTIONS` — the manager console's sections. */\nconst APP_CANVASS_CHILDREN: CrossAppLeaf[] = [\n { label: 'Dashboard', icon: 'grid', path: '' },\n { label: 'Campaigns', icon: 'target', path: 'campaigns' },\n { label: 'Canvassers', icon: 'users', path: 'canvassers' },\n]\n\n/**\n * signs/components/Shell.tsx `SECTIONS`. Review Queue is Manager+ in the app's\n * tab strip; the shared tree carries no role input, so the row is listed for\n * everyone and the ROUTE enforces it — /review renders a \"available to Managers\n * and Admins\" notice and loads no queue data for a volunteer (signs\n * app/review/page.tsx). Listing it keeps sidebar and tab strip identical for the\n * managers who use it rather than re-opening per-app nav drift.\n */\nconst APP_SIGNS_CHILDREN: CrossAppLeaf[] = [\n { label: 'Map', icon: 'map', path: '' },\n { label: 'Placements', icon: 'list', path: 'placements' },\n { label: 'Review Queue', icon: 'fileText', path: 'review' },\n { label: 'Recovery', icon: 'flag', path: 'recovery' },\n { label: 'Reports', icon: 'barChart', path: 'reports' },\n]\n\n/**\n * Build the standard Politogy VRM menu for the given `mode` (default\n * `relationship`), in the exact order and wording the main app renders it. See\n * `StandardNavOptions` for the app-specific hooks (`contactsItem`,\n * `supportItem`) and the Campaign inputs (`activeOrgId`, `campaignAvailability`).\n */\nexport function standardPolitogyNav(opts: StandardNavOptions): NavItem[] {\n // Left-Navigation §8.1: every row is a Lucide icon + label. Callers may\n // override per slot; otherwise the shared Lucide map applies.\n const icon = (key: StandardNavIconKey): NavIcon | undefined => opts.icons?.[key] ?? standardNavIcons[key]\n\n // EVERY link this tree emits leaves the current app (core routes are\n // cross-app for a standalone app, and the app-owned rows are supplied by the\n // caller), so each one carries the active org as `?org=<full-uuid>` — the\n // full id is the only collision-free selector (contacts-api matches exact id\n // first, then a short suffix that can collide across a user's orgs). Without\n // it a multi-org user following a bare cross-app link lands in whatever org\n // the destination defaults to; the cookie is only the fallback for a bare\n // URL, the param is the explicit selector. Active-detection ignores `org`\n // (isNavItemActive's ACTIVE_IGNORED_PARAMS) so stamping it selects nothing\n // differently, and it keeps the org in the address bar for bookmarking.\n const orgParam = opts.activeOrgId ? `org=${opts.activeOrgId}` : ''\n const withOrg = (url: string): string =>\n orgParam ? `${url}${url.includes('?') ? '&' : '?'}${orgParam}` : url\n\n const leaves = (origin: string, children: CrossAppLeaf[]): NavItem[] =>\n appLeaves(origin, children)\n const branches = (origin: string, children: CoreBranch[]): NavItem[] => {\n const o = origin.replace(/\\/+$/, '')\n return children.map((c) => ({\n label: c.label,\n icon: icon(c.icon),\n href: withOrg(`${o}/${c.path}`),\n children: c.children ? leaves(origin, c.children) : undefined,\n }))\n }\n\n // Sub-items of a standalone app: `origin` + the app-relative path, carrying\n // the active org the way the parent row does. Trailing slash on the origin\n // is normalized so `''` yields the app root and `x` yields `/x`. An optional\n // `modeParam` (a DUAL app entered from a mode other than its own default,\n // e.g. the Relationship tree's a2p row) is stamped on every leaf too, so the\n // destination resolves the same mode the row that got you there was in.\n const appLeaves = (\n origin: string,\n children: CrossAppLeaf[],\n modeParam?: StandardNavMode,\n ): NavItem[] => {\n const base = origin.replace(/\\/+$/, '')\n return children.map((c) => {\n const url = c.path ? `${base}/${c.path}` : `${base}/`\n const withMode = modeParam ? `${url}${url.includes('?') ? '&' : '?'}mode=${modeParam}` : url\n return { label: c.label, icon: icon(c.icon), href: withOrg(withMode) }\n })\n }\n\n // Left-Navigation §9.4: ACCOUNT is the last section in every mode.\n const accountRows = (): NavItem[] => [\n { kind: 'section', label: 'Account' },\n // My Profile moved to the Politogy ID account app (auth.politogyvrm.com)\n // with the retirement of app.politogyvrm.com.\n { label: 'My profile', icon: icon('circleUser'), href: withOrg(`${AUTH_ORIGIN}my-profile`) },\n {\n label: 'Organization settings',\n icon: icon('settings'),\n // Organization settings moved to the standalone Settings app\n // (settings.politogyvrm.com, Specs/Organization-Settings v12).\n href: withOrg(`${SETTINGS_ORIGIN}organization-settings`),\n children: branches(SETTINGS_ORIGIN, ORG_SETTINGS_CHILDREN),\n },\n ]\n\n const buildRelationship = (): NavItem[] => {\n const contacts: NavItem = opts.contactsItem\n ? {\n label: 'Contacts',\n icon: icon('usersRound'),\n href: opts.contactsItem.href,\n children: opts.contactsItem.children,\n badge: opts.contactsItem.count ?? undefined,\n }\n : {\n label: 'Contacts',\n icon: icon('usersRound'),\n href: withOrg(`${CONTACTS_APP}/`),\n children: APP_CONTACTS_CHILDREN.map((c) => ({\n label: c.label,\n icon: icon(c.icon),\n href: withOrg(c.href),\n })),\n }\n\n // Specs/Contacts design rail (Reference/UI-Platform → Left bar: section\n // rows via `kind: 'section'`, sentence-case labels). Three groups:\n // RELATIONSHIP Dashboard · Contacts · Email broadcast · SMS/MMS blast\n // COLLECT Calls to action · Forms · Surveys (· Polls · CTAs)\n // ACCOUNT My profile · Organization settings\n return [\n { kind: 'section', label: 'Relationship' },\n // Dashboard moved to the standalone Dashboard app (dashboard.politogyvrm.com,\n // Specs/Relationship-Dashboard) with the retirement of app.politogyvrm.com.\n { label: 'Dashboard', icon: icon('layoutDashboard'), href: withOrg(DASHBOARD_ORIGIN) },\n contacts,\n {\n label: 'Email broadcast',\n icon: icon('mail'),\n href: withOrg(`${EMAIL_APP}/dashboard`),\n children: APP_EMAIL_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n // SMS/MMS Blast is the a2p app entered in RELATIONSHIP mode (a2p is\n // dual-mode; Specs/A2P). The `?mode=relationship` param pins the\n // destination's tree so the row that got you there is the row that\n // lights up on arrival.\n label: 'SMS/MMS blast',\n icon: icon('messageSquare'),\n href: withOrg(`${A2P_ORIGIN}?mode=relationship`),\n children: appLeaves(A2P_ORIGIN, APP_A2P_CHILDREN, 'relationship'),\n },\n { kind: 'section', label: 'Collect' },\n // Calls to action moved to the standalone CTAs app (ctas./runtime.\n // politogyvrm.com, Specs/CTAs) with the retirement of app.politogyvrm.com.\n {\n label: 'Calls to action',\n icon: icon('mousePointerClick'),\n href: withOrg('https://ctas.politogyvrm.com/'),\n children: APP_CTAS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n label: 'Forms',\n icon: icon('fileText'),\n href: withOrg('https://forms.politogyvrm.com/'),\n children: APP_FORMS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n {\n label: 'Surveys',\n icon: icon('clipboardList'),\n href: withOrg('https://surveys.politogyvrm.com/surveys'),\n children: APP_SURVEYS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n // Polls (polls.politogyvrm.com) — kept in the default Collect section;\n // apps that want it hidden pass `hiddenItems: ['Polls']`. Regression:\n // dropped entirely in 03c4dc2 when app.politogyvrm.com retired; restored\n // here (this row is independent of the retired app).\n {\n label: 'Polls',\n icon: icon('chartNoAxes'),\n href: withOrg(POLLS_ORIGIN),\n children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n },\n ...accountRows(),\n ]\n }\n\n // Campaign tree — Dashboard + the 7 Campaign Mode features. Dashboard and\n // Voter Contact are core-hosted (VRM core /campaign/*); the rest link out to\n // standalone apps and are gated by CAMPAIGN_FEATURE_AVAILABILITY.\n const buildCampaign = (): NavItem[] => {\n const avail: CampaignFeatureAvailability = {\n ...CAMPAIGN_FEATURE_AVAILABILITY,\n ...opts.campaignAvailability,\n }\n type Gated = NavItem & { flag?: keyof CampaignFeatureAvailability }\n const rows: Gated[] = [\n // Left-Navigation §9.2: Race data -> Research -> GOTV -> Account.\n // Battleground is the Campaign landing page; there is no Campaign\n // Dashboard row, and Voter Contact and Tribes have no row.\n { kind: 'section', label: 'Race data' },\n // Battleground moved to the Dashboard app (dashboard.politogyvrm.com)\n // until a dedicated Battleground host is decided (UI-Platform route table).\n { label: 'Battleground', icon: icon('crosshair'), href: withOrg(`${DASHBOARD_ORIGIN}battleground`) },\n // District data moved to the Dashboard app (dashboard.politogyvrm.com)\n // per Reference/UI-Platform v44.\n { label: 'District data', icon: icon('landmark'), href: withOrg(`${DASHBOARD_ORIGIN}districts`) },\n { kind: 'section', label: 'Research' },\n {\n label: 'Polling',\n icon: icon('chartNoAxes'),\n href: withOrg(POLLS_ORIGIN),\n children: APP_POLLS_CHILDREN.map((c) => ({ label: c.label, icon: icon(c.icon), href: withOrg(c.href) })),\n flag: 'polling',\n },\n { kind: 'section', label: 'GOTV' },\n {\n label: 'Field canvassing',\n icon: icon('doorOpen'),\n href: withOrg(CANVASS_ORIGIN),\n children: appLeaves(CANVASS_ORIGIN, APP_CANVASS_CHILDREN),\n flag: 'canvass',\n },\n {\n label: 'Phone banking',\n icon: icon('phone'),\n href: withOrg(PHONEBANK_ORIGIN),\n children: appLeaves(PHONEBANK_ORIGIN, APP_PHONEBANK_CHILDREN),\n flag: 'phonebank',\n },\n {\n label: 'A2P texting',\n icon: icon('messageSquare'),\n href: withOrg(A2P_ORIGIN),\n children: appLeaves(A2P_ORIGIN, APP_A2P_CHILDREN),\n flag: 'a2p',\n },\n {\n label: 'Sign mapping',\n icon: icon('signpost'),\n href: withOrg(SIGNS_ORIGIN),\n children: appLeaves(SIGNS_ORIGIN, APP_SIGNS_CHILDREN),\n flag: 'signs',\n },\n ...accountRows(),\n ]\n const kept = rows\n .filter((r) => !r.flag || avail[r.flag])\n .map(({ flag: _flag, ...item }) => item as NavItem)\n // Drop a section left with no rows under it (e.g. Research when polling is off).\n return kept.filter((item, idx) => {\n if (item.kind !== 'section') return true\n const next = kept[idx + 1]\n return !!next && next.kind !== 'section'\n })\n }\n\n // Petition tree — the Petition Mode home (its own standalone app). The\n // Petitions app nests its own routes via `petitionsItem` (the contactsItem\n // contract); everyone else gets the minimal cross-app link. Labeled\n // Dashboard so the shared breadcrumb trail anchors correctly.\n const buildPetition = (): NavItem[] => [\n opts.petitionsItem\n ? {\n label: 'Dashboard',\n icon: icon('home'),\n href: opts.petitionsItem.href ?? withOrg(PETITION_MODE_ORIGIN),\n children: opts.petitionsItem.children,\n }\n : { label: 'Dashboard', icon: icon('home'), href: withOrg(PETITION_MODE_ORIGIN) },\n ]\n\n const mode = opts.mode ?? 'relationship'\n const built =\n mode === 'campaign'\n ? buildCampaign()\n : mode === 'petition'\n ? buildPetition()\n : buildRelationship()\n const items = applyHiddenItems(built, opts.hiddenItems)\n\n if (opts.supportItem) {\n items.push({\n label: 'Support',\n icon: icon('lifeBuoy'),\n href: opts.supportItem.href,\n onClick: opts.supportItem.onClick,\n })\n }\n\n return items\n}\n","// ---------------------------------------------------------------------------\n// Framework-agnostic chrome (sidebar + top navbar) for @the-portland-company/shell.\n//\n// The other chrome in this package (ShellChrome, Sidebar, Header, …) is built\n// on Chakra UI v2 + react-router and targets Vite SPAs. That stack cannot be\n// imported into a Next.js / React 19 / Tailwind app. This \"native\" module is a\n// dependency-light alternative: pure React (no Chakra, no emotion, no\n// react-router, no icon library) whose styling is driven entirely by the CSS\n// design tokens shipped in `@the-portland-company/shell/chrome.css`.\n//\n// It is a FAITHFUL VISUAL TWIN of the Chakra chrome (Sidebar.tsx / Header.tsx /\n// OrgPill / ModePill / NavItem / UserMenu): same 240px sidebar, brand-logo\n// slot, \"ORGANIZATION\" org pill, mode pill, solid active nav rows, pipe-\n// separated footer links + commit string, and an avatar+name+email+chevron user\n// menu — so an app rendering this looks identical to the main VRM app.\n//\n// Every app concern (nav items, org, mode, user, links, icons, the routing\n// Link component, the theme toggle) is injected via props, so both the Contacts\n// app (Next.js) and the VRM app could consume the same components.\n// ---------------------------------------------------------------------------\n\nimport type { ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react'\nimport { Fragment, createContext, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport clsx from 'clsx'\nimport { useTopBarIconSlotGlyph, type TopBarIconSlot } from '../lib/topbarIconSlot'\nimport { resolveBrandGlyph } from '../lib/brandGlyphs'\nimport { warnDeprecated } from '../lib/deprecation'\nimport { filterOrgs, shouldShowOrgFilter } from './orgFilter'\nimport { readRailPreference, writeRailPreference } from '../nav-preference'\nimport { SpeculationRulesScript } from '../speculation/SpeculationRulesScript'\nimport {\n topBarIconButtonClass,\n TopBarTooltip,\n TopBarPanelArrow,\n NavThemeControl,\n resolveOrgLogoUrl,\n NAV_DISPLAY_OPTIONS,\n TOPBAR_GLYPH_SIZE,\n type ThemePreference,\n type NavDisplayMode,\n} from './chromeActions'\n\n// Data-backed top-bar widgets (Fuel, Notifications, Support, Nav-display) +\n// the injected-fetcher provider they hang off. One implementation for every app.\nexport {\n NavChromeProvider,\n CORE_APP_ORIGIN,\n CORE_BILLING_PATH,\n SPECS_ORIGIN,\n FuelAction,\n NotificationsAction,\n SupportAction,\n SpecOverlayAction,\n NavDisplayAction,\n NavThemeControl,\n TopBarCountBadge,\n TopBarPanelArrow,\n TopBarTooltip,\n TopBarWidgetSlot,\n TopBarPopover,\n topBarIconButtonClass,\n resolveOrgLogoUrl,\n useChromeMe,\n useChromeOrgs,\n useNavChromeFetcher,\n useNavChromeDedupedFetch,\n useThemePreference,\n} from './chromeActions'\nexport type {\n ChromeMe,\n NavChromeFetcher,\n NavDisplayMode,\n ThemePreference,\n ChromeOrgSummary,\n ChromeNotificationsPayload,\n ChromeNotificationAlert,\n ChromeNotificationReply,\n ChromeNotificationImport,\n ChromeNotificationQuarantine,\n CommunicationsFuelStatus,\n FuelChannelStatus,\n} from './chromeActions'\n\n// An icon is any component that accepts an optional size + className. This\n// matches both `lucide-react` and `react-icons` icon signatures, so consuming\n// apps pass their own icon set without this package depending on one.\nexport type NavIcon = ComponentType<{ size?: number; className?: string; strokeWidth?: number }>\n\nexport type NavItem = {\n /**\n * What this row IS. Defaults to `'link'` — every existing `NavItem[]` keeps\n * its exact type and rendering.\n *\n * `'section'` is a non-interactive heading that groups the rows beneath it:\n * uppercase, muted, letterspaced, not focusable, no hover. Only `label` is\n * read; `href`, `icon`, `onClick` and `children` are ignored.\n *\n * The legacy chrome supported this and 0.43 dropped it, so apps faked it by\n * passing `disabled` rows with no href — which looks approximately right and\n * is wrong where it counts: a disabled row announces as an unavailable\n * CONTROL to a screen reader, when it is not a control at all. A section is\n * its own kind of row (Reference/UI-Platform → Left bar).\n *\n * Deliberately a widened field rather than a discriminated union: a union\n * would make `item.href` a type error for every existing consumer that reads\n * it, turning an additive feature into a breaking change.\n */\n kind?: 'link' | 'section'\n /** Route to link to. Optional when `onClick` is supplied (renders a button). */\n href?: string\n label: string\n icon?: NavIcon\n /**\n * When supplied the row renders as a `<button>` (styled identically to the\n * link rows) instead of a routed link — used for actions like \"Support\".\n */\n onClick?: () => void\n /**\n * Disables the row: non-interactive and dimmed, with `disabledTitle` shown as\n * a hover tooltip explaining why. Mirrors `NavTab`'s existing contract so a\n * gated row looks the same whether it renders in the sidebar or a tab strip.\n * Without this, an app that gates a section (VRM dims Email / SMS until setup\n * is complete) had no way to express it and the row rendered fully clickable\n * (shell-nav-handoff §3).\n */\n disabled?: boolean\n /** Tooltip for a disabled row — say why, and how to resolve it. */\n disabledTitle?: string\n /**\n * Right-aligned count/annotation on the row — e.g. the live contact count\n * on \"Contacts\" (`31.9K`). Pre-formatted by the app; the shell only draws\n * it (Specs/Contacts design rail). Omitted/null draws nothing.\n */\n badge?: string | number | null\n /**\n * Nested sub-items. When present, the row becomes an expandable GROUP header.\n * Clicking it always toggles the children open/closed and rotates the\n * right-aligned chevron; if the item ALSO carries an `onClick`, that runs too,\n * so a parent can navigate to its section dashboard while expanding\n * (shell-nav-handoff §2). An `href` alone never navigates from a group header. The sidebar runs a single-open accordion (opening one group closes\n * the others) and auto-expands whichever group contains the active route —\n * mirroring the main VRM app's Chakra sidebar. Children render as smaller nav\n * rows on a lighter panel and support both `href` links and `onClick` actions.\n */\n children?: NavItem[]\n}\n\n// The routing primitive is injected so each app supplies its own (Next.js\n// `<Link>`, react-router `<Link>`, or a plain `<a>`). Defaults to an anchor.\nexport type NavLinkProps = {\n href: string\n className?: string\n 'aria-current'?: 'page' | undefined\n children: ReactNode\n // Optional passthrough attributes so the same injected link can back a\n // routed nav row OR a routed tab (which needs ARIA tab semantics + inline\n // token geometry). Next.js `<Link>`, react-router `<Link>` and a plain <a>\n // all accept these DOM props, and DefaultLink spreads them onto its anchor.\n role?: string\n 'aria-selected'?: boolean\n 'aria-label'?: string\n title?: string\n style?: CSSProperties\n}\nexport type NavLinkComponent = ComponentType<NavLinkProps>\n\n/**\n * URL-scheme allow-list for host-supplied hrefs. React does not neutralize\n * `javascript:`/`data:` schemes on anchor href, so any app-supplied nav/footer/\n * action href must be validated before it reaches the DOM. Permits absolute\n * http(s), mailto/tel, and in-app relative targets; everything else → '#'.\n */\nconst safeHref = (h?: string) =>\n h && /^(https?:|mailto:|tel:|\\/|#|\\.)/i.test(h.trim()) ? h : '#'\n\nconst DefaultLink: NavLinkComponent = ({ href, children, ...rest }) => (\n <a href={safeHref(href)} {...rest}>\n {children}\n </a>\n)\n\n/**\n * Default active-route test. Handles three href shapes so the CURRENT app's\n * item + sub-item select correctly in the cross-app menu (HITL 2026-07-23):\n * - relative path: exact for \"/\", prefix otherwise (legacy behavior);\n * - absolute URL: active only when its host matches window.location.host,\n * then compared by path (and query, when the href carries one — e.g.\n * forms' /?tab=canvas sub-items);\n * - query-only relative hrefs likewise compare location.search.\n *\n * The `org` param is EXCLUDED from the query comparison. Campaign / Petition\n * links carry `?org=<last6>` purely to hand the active organization to the\n * destination app (`standardPolitogyNav`'s `activeOrgId`); it scopes data, it\n * does not identify a page. Comparing it would deselect every campaign row the\n * moment an org is active, because the app's own URL bar carries no `org=`.\n */\nconst ACTIVE_IGNORED_PARAMS = new Set(['org'])\n\nexport function isNavItemActive(pathname: string, href: string): boolean {\n let targetPath = href\n let targetSearch = ''\n if (/^https?:\\/\\//i.test(href)) {\n if (typeof window === 'undefined') return false\n try {\n const u = new URL(href)\n if (u.host !== window.location.host) return false\n targetPath = u.pathname\n targetSearch = u.search\n } catch {\n return false\n }\n } else {\n const qi = href.indexOf('?')\n if (qi >= 0) {\n targetPath = href.slice(0, qi) || '/'\n targetSearch = href.slice(qi)\n }\n }\n // Every IDENTIFYING key=value in the target query must be present in the\n // location. Once the scoping params are dropped a link like\n // \"https://signs.politogyvrm.com/placements?org=abc123\" is a plain path href\n // again and falls through to the path rules below.\n const want = new URLSearchParams(targetSearch)\n for (const k of ACTIVE_IGNORED_PARAMS) want.delete(k)\n if (Array.from(want).length > 0) {\n if (typeof window === 'undefined') return false\n if (pathname !== targetPath) return false\n const have = new URLSearchParams(window.location.search)\n for (const [k, v] of want) if (have.get(k) !== v) return false\n return true\n }\n if (targetPath === '/') return pathname === '/'\n return pathname === targetPath || pathname.startsWith(`${targetPath}/`)\n}\n\n/**\n * Stable identity for an expandable nav group's accordion state. Prefers the\n * item's href; falls back to an index-scoped label so two groups can never\n * collide even when they share a label and have no href.\n */\nfunction groupKeyOf(item: NavItem, index: number): string {\n return item.href ?? `nav-group-${index}-${item.label}`\n}\n\n/** True when any of a group's children links to the active route. */\nfunction hasActiveChild(\n item: NavItem,\n pathname: string,\n activeFn: (pathname: string, href: string) => boolean,\n): boolean {\n return (item.children ?? []).some(\n (child) =>\n (child.href ? activeFn(pathname, child.href) : false) ||\n // Depth-3: a grandchild owning the route also opens the top group.\n (child.children ?? []).some((leaf) =>\n leaf.href ? activeFn(pathname, leaf.href) : false,\n ),\n )\n}\n\n/**\n * Color-coded tone classes for the sidebar environment chip, matching the main\n * VRM app: prod red, staging orange, local/dev green, unknown gray.\n */\nfunction firstLeafHref(item: NavItem): string | undefined {\n for (const c of item.children ?? []) {\n if (c.kind === 'section') continue\n if (c.href) return c.href\n const deep = firstLeafHref(c)\n if (deep) return deep\n }\n return undefined\n}\n\n/** A multi-mode app (VRM core) renders NavAppShell without a registry modeId;\n * its current mode label still decides the rail colour (Left-Navigation §5). */\nexport function modeIdFromLabel(label: string | undefined): string | undefined {\n const l = label?.trim().toLowerCase()\n return l ? l.replace(/\\s+mode$/, '') : undefined\n}\n\n/** \"Ben Edtl\" -> \"Ben E.\" (Left-Navigation §10). One word stays as is. */\nexport function shortUserName(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n if (parts.length < 2) return parts[0] ?? ''\n return `${parts[0]} ${parts[parts.length - 1][0].toUpperCase()}.`\n}\n\n/** Short environment name for the rail's build line (\"prod\", \"staging\", \"local\"). */\nexport function shortEnvLabel(label: string): string {\n const l = label.trim().toLowerCase()\n if (l === 'production') return 'prod'\n if (l === 'development') return 'dev'\n return l\n}\n\nexport function envChipClasses(label: string): string {\n const l = label.toLowerCase()\n if (l === 'production' || l === 'prod')\n return 'bg-[#fee2e2] text-[#ef4444]'\n if (l === 'staging' || l === 'stage')\n return 'bg-[#ffedd5] text-[#f97316]'\n if (l === 'local' || l === 'development' || l === 'dev')\n return 'bg-[#dcfce7] text-[#22c55e]'\n return 'bg-[rgba(107,114,128,0.16)] text-[#6b7280]'\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavBrand = {\n /** Where the logo links to. Defaults to \"/\". */\n homeHref?: string\n /**\n * Brand logo image src. When supplied this renders as the wordmark logo\n * (matching the main app's BrandLogo), and `badgeLabel`/`title`/`subtitle`\n * are used only as the no-image fallback.\n */\n logoSrc?: string\n logoAlt?: string\n /**\n * The square mark shown at the top of the COLLAPSED rail (Left-Navigation\n * §11.6) — Brand `assets.logoSquare`, the all-white vrm tile. Falls back to\n * the badge when omitted.\n */\n logoSquareSrc?: string\n /**\n * The logo URLs are still resolving from the Brand token sheet. The rail\n * reserves the logo's box and draws nothing — never the badge fallback,\n * which would flash a stand-in on every load.\n */\n logoPending?: boolean\n /** Short label shown inside the brand badge fallback (e.g. \"P\"). */\n badgeLabel: string\n title: string\n subtitle?: string\n}\n\nexport type NavOrgOption = {\n id: string\n name: string | null\n logoUrl?: string | null\n /** The org's Brand Kit icon mark; falls back to `logoUrl`, then initials. */\n iconUrl?: string | null\n brandColor?: string | null\n role?: string | null\n}\n\nexport type NavOrg = {\n name: string | null\n /** Full org id. When present, a copy affordance is shown by the label. */\n id?: string | null\n /** Optional org logo for the pill badge; falls back to initials. */\n logoUrl?: string | null\n /**\n * The org's Brand Kit icon mark, shown on the collapsed rail (32px, on its\n * white tile). Falls back to `logoUrl` scaled to fit, then initials.\n */\n iconUrl?: string | null\n /** Solid pill background (the org's brand color). Defaults to the accent. */\n brandColor?: string | null\n /** Org's secondary Brand Kit color; the card's bottom-edge gradient runs\n * primary → secondary. Falls back to the Politogy gradient when unset. */\n brandColorSecondary?: string | null\n /**\n * Organization Settings §7.1–§7.2: when the org has no logo yet, an Account\n * Admin sees an \"Upload logo\" link in the band instead of the org name.\n */\n canUploadLogo?: boolean\n uploadLogoHref?: string\n onClick?: () => void\n /**\n * The user's organizations. When present (even one), the pill renders as a\n * dropdown SWITCHER (Reference/UI-Platform \"Organization selector\": never a\n * static label in a multi-org app); selecting one calls `onSwitch(id)`.\n */\n organizations?: NavOrgOption[]\n onSwitch?: (id: string) => void\n /**\n * The active org is still resolving from the chrome API. Renders a skeleton\n * pill instead of a name. Required because the app's own workspace label is\n * NOT the organization: showing it while the real org loads flashes a wrong\n * value (Global Rules — async values shimmer, they never render a stand-in).\n */\n loading?: boolean\n}\n\nexport type NavModeOption = {\n id: string\n label: string\n icon?: NavIcon\n /**\n * Left-Navigation §7: a mode the organization does not hold is always\n * shown (never hidden), dimmed, and not selectable. Defaults to true.\n */\n available?: boolean\n /** Tooltip for an unavailable mode, e.g. \"Campaign Mode isn't active for\n * this organization.\" Appended with \"See upgrade options\" for an Account\n * Admin on a paid account (never during a trial). */\n unavailableTooltip?: string\n}\n\nexport type NavMode = {\n label: string\n icon?: NavIcon\n /**\n * Entitled modes for the active organization. With more than one option the\n * pill renders as a SELECTOR (dropdown); with zero/one it stays the classic\n * disabled single-mode pill. Selecting calls onSelect(id).\n */\n options?: NavModeOption[]\n onSelect?: (id: string) => void\n}\n\nexport type NavFooterLink = { label: string; href: string; external?: boolean }\n\nexport type NavFooter = {\n /**\n * Build metadata (env chip / commit / version / date / author). OPTIONAL:\n * omit envLabel/version/commit to render a links-only footer — apps show\n * the meta block to Super Administrators only (Reference/UI-Platform).\n */\n envLabel?: string\n version?: string\n commit?: string\n links?: NavFooterLink[]\n /** ISO date (or any Date-parseable string) of the deployed commit. */\n commitDate?: string\n /** Full name of the commit author (only the first name is shown). */\n commitAuthor?: string\n /**\n * The signed-in user, drawn as a card (avatar · name · email · chevron)\n * ABOVE the links row. Reference/UI-Platform v30 → Left bar: \"The user —\n * avatar, name, email and the user menu — lives in the left bar footer.\"\n * Clicking it opens the account menu UPWARD. `NavAppShell` fills these from\n * `topBar.user` / `topBar.userMenu` / `topBar.onSignOut` automatically, so\n * standalone `NavSidebar` consumers pass them only when they want the card.\n */\n user?: NavUser | null\n userMenu?: NavUserMenu | null\n onSignOut?: () => void\n}\n\nexport type NavSidebarProps = {\n pathname: string\n brand: NavBrand\n nav: {\n groupLabel?: string\n items: NavItem[]\n isActive?: (pathname: string, href: string) => boolean\n /**\n * Render each top-level group's CHILDREN directly at the root of the rail\n * — no parent header row, no accordion. For an app whose whole tree nests\n * under one entry (Petitions), that parent row is pure anatomy: V1 never\n * had it, it duplicates the first child's route, and it costs a level of\n * indentation. Sections render as sections; rows render with the 'flat'\n * variant (top-level geometry, wash active treatment). Top-level items\n * WITHOUT children render unchanged, so a mixed tree degrades sanely.\n */\n flatten?: boolean\n }\n org?: NavOrg | null\n mode?: NavMode | null\n footer?: NavFooter | null\n linkComponent?: NavLinkComponent\n /**\n * Small-screen expand state (owned by `NavAppShell`). The rail is never\n * hidden (Left-Navigation §11.6): at `md` and up it is the full rail, below\n * `md` it collapses to the 64px icon rail. `open` expands the collapsed\n * rail to the full rail as a modal drawer with a backdrop, and `onClose`\n * wires the backdrop, the close button, and Escape. `md` and up ignores\n * both.\n */\n open?: boolean\n onClose?: () => void\n /**\n * Expands the collapsed (below `md`) rail. When set, the square logo tile at\n * the top of the collapsed rail becomes the \"Expand navigation\" control —\n * the Left-Navigation Design draws no other toggle and no top-bar hamburger.\n */\n onOpen?: () => void\n /**\n * Closes the expanded rail after a nav-link click without counting as the\n * user's Collapse choice. Defaults to `onClose`.\n */\n onNavigate?: () => void\n}\n\n// Default org-pill BADGE background — the chrome accent, matching the main\n// app's fallback (mode primary) when an org has no explicit brand color. In a\n// Mode with its own accent this follows the Mode. Only the circular badge takes\n// it; the pill body stays neutral (Reference/UI-Platform → Left bar).\nconst ORG_PILL_DEFAULT = 'var(--color-accent)'\n\n// Left-Navigation §11.6: below `md` the rail collapses to the 64px icon rail;\n// it is never hidden. The collapse is pure CSS (`max-md:` utilities), so there\n// is one DOM tree and no hydration flash. It applies only while the rail is\n// not expanded as the small-screen drawer, which is what this context carries\n// down to the rows.\nconst RailCollapsibleContext = createContext(false)\n\n/** Returns `cls` when the small-screen collapse applies to this rail, else ''. */\nfunction useRailCollapse(): (cls: string) => string {\n const collapsible = useContext(RailCollapsibleContext)\n return (cls) => (collapsible ? cls : '')\n}\n\n/**\n * The organization on the collapsed rail: its Brand Kit icon mark, 32px, on a\n * white tile (Left-Navigation §11.6). Rendered inside the same switcher\n * trigger as the full card, so the switcher stays interactive when collapsed.\n */\nfunction OrgIconMark({ org, logoSrc }: { org: NavOrg; logoSrc?: string }) {\n const rc = useRailCollapse()\n const src = resolveOrgLogoUrl(org.iconUrl) ?? logoSrc\n return (\n <span\n aria-hidden\n data-rail-org-mark=\"\"\n className={`hidden h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-[5px] bg-[#FFFFFF] text-[11px] font-bold text-neutral-800 ${rc('max-md:flex')}`}\n >\n {src ? (\n <img src={src} alt=\"\" className=\"max-h-full max-w-full object-contain\" />\n ) : (\n (org.name ?? 'Org').slice(0, 2).toUpperCase()\n )}\n </span>\n )\n}\n\nexport function NavSidebar({\n pathname,\n brand,\n nav,\n org,\n mode,\n footer,\n linkComponent,\n open,\n onClose,\n onOpen,\n onNavigate,\n}: NavSidebarProps) {\n const Link = linkComponent ?? DefaultLink\n // The small-screen collapse applies whenever the rail is not expanded as\n // the drawer (see RailCollapsibleContext).\n const collapsible = !open\n const rc = (cls: string) => (collapsible ? cls : '')\n // Focus management for the mobile drawer: on open, move focus to the close\n // button; on close, return it to whatever had focus before (the hamburger,\n // in practice). Escape closes while the drawer is open.\n const asideRef = useRef<HTMLElement>(null)\n const closeButtonRef = useRef<HTMLButtonElement>(null)\n const previouslyFocusedRef = useRef<HTMLElement | null>(null)\n useEffect(() => {\n if (open) {\n previouslyFocusedRef.current = document.activeElement as HTMLElement | null\n closeButtonRef.current?.focus()\n } else if (previouslyFocusedRef.current) {\n previouslyFocusedRef.current.focus()\n previouslyFocusedRef.current = null\n }\n }, [open])\n useEffect(() => {\n if (!open) return\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose?.()\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [open, onClose])\n // Focus trap: Tab/Shift+Tab must stay inside the drawer while it is open —\n // no `inert` attribute (React 18/19 compatibility), so this is a plain\n // keydown handler that wraps focus at the first/last focusable element.\n const trapTab = (e: ReactKeyboardEvent<HTMLElement>) => {\n if (!open || e.key !== 'Tab') return\n const root = asideRef.current\n if (!root) return\n const focusable = Array.from(\n root.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])',\n ),\n ).filter((el) => {\n if (el.hidden) return false\n const style = window.getComputedStyle(el)\n return style.display !== 'none' && style.visibility !== 'hidden'\n })\n if (focusable.length === 0) return\n const first = focusable[0]\n const last = focusable[focusable.length - 1]\n if (e.shiftKey) {\n if (document.activeElement === first) {\n e.preventDefault()\n last.focus()\n }\n } else if (document.activeElement === last) {\n e.preventDefault()\n first.focus()\n }\n }\n const activeFn = nav.isActive ?? isNavItemActive\n const ModeIcon = mode?.icon\n // Core stores logo_url as a core-relative storage route; resolve it against\n // the core origin so it loads in EVERY app, not just app.politogyvrm.com.\n const orgLogoSrc = resolveOrgLogoUrl(org?.logoUrl)\n // Left-Navigation §6: brand-color gradient strip along the logo band's\n // bottom edge; the Politogy gradient (blue → purple → red) until the org\n // sets its own Brand Kit colors.\n const orgGradient = org?.brandColor\n ? `linear-gradient(to right, ${org.brandColor}, ${org.brandColorSecondary || org.brandColor})`\n : 'linear-gradient(to right, #007BFF, #A54B7A, #E63946)'\n // Design rail: the org card border is the org's brand color at 42% alpha\n // (`rgba(74,192,231,.42)` in the Specs/Contacts design); hairline otherwise.\n const orgCardStyle = hexToRgba(org?.brandColor, 0.42)\n ? { borderColor: hexToRgba(org?.brandColor, 0.42) as string }\n : undefined\n\n // Single-open accordion for expandable nav groups, mirroring the main VRM\n // app's Chakra sidebar. `activeGroupKey` is the group (if any) that owns the\n // current route; deriving it as a primitive string keeps the auto-expand\n // effect from firing when `nav.items` is a fresh array reference each render\n // (which would otherwise clobber a manual toggle).\n const activeGroupKey = useMemo(() => {\n for (let i = 0; i < nav.items.length; i++) {\n const item = nav.items[i]\n if (item.children && item.children.length > 0 && hasActiveChild(item, pathname, activeFn)) {\n return groupKeyOf(item, i)\n }\n }\n return null\n }, [nav.items, pathname, activeFn])\n\n // Seed the open group from the active route on first paint (no expand flash),\n // then keep it synced as the route changes. Manual toggles between route\n // changes are preserved because the effect only reruns when the *derived*\n // active group actually changes.\n const [openGroup, setOpenGroup] = useState<string | null>(activeGroupKey)\n // Org selector type-to-filter (see ./orgFilter.ts). Reset whenever the popover closes.\n const [orgFilter, setOrgFilter] = useState('')\n useEffect(() => {\n setOpenGroup(activeGroupKey)\n }, [activeGroupKey])\n const toggleGroup = (key: string) =>\n setOpenGroup((prev) => (prev === key ? null : key))\n\n return (\n <RailCollapsibleContext.Provider value={collapsible}>\n {/* Backdrop — small-screen drawer only, dismisses on click. */}\n {open ? (\n <div\n aria-hidden\n className=\"fixed inset-0 z-40 bg-black/40 md:hidden\"\n onClick={onClose}\n />\n ) : null}\n <aside\n ref={asideRef}\n id=\"politogy-nav-drawer\"\n role={open ? 'dialog' : undefined}\n aria-modal={open ? 'true' : undefined}\n aria-label={open ? 'Navigation' : undefined}\n className={clsx(\n 'fixed inset-y-0 left-0 flex flex-col border-r border-[color:var(--sidebar-line,var(--line))] bg-[color:var(--sidebar-bg,var(--nav-surface))]',\n // Never hidden: the 64px icon rail below `md`, the full rail from\n // `md` up, and the full rail as a drawer when expanded below `md`.\n open\n ? 'z-50 w-[var(--sidebar-width,236px)]'\n : 'z-30 w-[var(--sidebar-collapsed-width,64px)] md:w-[var(--sidebar-width,236px)]',\n )}\n // Pin the rail's own font explicitly to the Brand token (Reference/UI-Platform\n // \"Typography\") rather than relying on inherited `body` styles. An app that\n // sets its own body font on a sub-view (e.g. Contacts) would otherwise leak\n // into the rail purely by inheritance — one shell definition, never app-derived.\n style={{ fontFamily: 'var(--font-family, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif)' }}\n onKeyDown={trapTab}\n onClick={(e) => {\n // Any nav-link click closes the drawer — including a click on the\n // CURRENT route's link, which would otherwise strand it open since\n // `pathname` never changes to trigger NavAppShell's close effect.\n if (open && (e.target as HTMLElement).closest('a[href]')) (onNavigate ?? onClose)?.()\n }}\n >\n {/* Close button — small-screen drawer only. */}\n {open ? (\n <button\n type=\"button\"\n ref={closeButtonRef}\n onClick={onClose}\n aria-label=\"Collapse navigation\"\n className=\"absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full text-[color:var(--muted)] transition hover:bg-[color:var(--panel-elevated)] hover:text-[color:var(--foreground)] md:hidden\"\n >\n <CloseIcon />\n </button>\n ) : null}\n {/* Header — brand, org card, mode switcher (Specs/Contacts design\n rail: padding 16px 18px, 14px between blocks, hairline below). */}\n <div className={`flex flex-shrink-0 flex-col gap-[14px] border-b border-[color:var(--sidebar-line,var(--line))] px-[18px] py-4 ${rc('max-md:items-center max-md:px-[10px]')}`}>\n {/* Brand — the lockup directly on the rail, no plate; the square\n tile when collapsed. Badge only when no logo was supplied at all. */}\n {/* Below `md` the collapsed rail's logo tile is the expand control\n (Left-Navigation §11.6: the rail is never hidden; the user expands\n it from the rail itself). Hidden while expanded and from `md` up. */}\n {onOpen ? (\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label=\"Expand navigation\"\n aria-expanded={open ?? false}\n data-rail-toggle=\"expand\"\n className={`hidden h-8 w-8 items-center justify-center rounded-lg ${rc('max-md:flex')}`}\n >\n {brand.logoSquareSrc ? (\n <img src={brand.logoSquareSrc} alt=\"\" draggable={false} className=\"h-8 w-8 object-contain\" />\n ) : brand.logoPending ? (\n <span aria-hidden className=\"block h-8 w-8\" />\n ) : (\n <span className=\"flex h-8 w-8 items-center justify-center rounded-xl bg-[color:var(--color-accent)] text-sm font-black text-[#FFFFFF]\">\n {brand.badgeLabel}\n </span>\n )}\n </button>\n ) : null}\n <Link\n href={brand.homeHref ?? '/'}\n aria-label={brand.logoAlt ?? brand.title}\n className={`flex items-center gap-2.5 ${rc('max-md:justify-center')} ${onOpen ? rc('max-md:hidden') : ''}`}\n >\n {brand.logoSquareSrc ? (\n <img\n src={brand.logoSquareSrc}\n alt=\"\"\n draggable={false}\n data-rail-logo=\"square\"\n className={`hidden h-8 w-8 object-contain ${rc('max-md:block')}`}\n />\n ) : brand.logoPending ? (\n <span aria-hidden className={`hidden h-8 w-8 ${rc('max-md:block')}`} />\n ) : null}\n {brand.logoSrc ? (\n <img\n src={brand.logoSrc}\n alt={brand.logoAlt ?? brand.title}\n draggable={false}\n data-rail-logo=\"horizontal\"\n className={`h-[var(--sidebar-brand-logo-height,24px)] w-auto object-contain ${rc('max-md:hidden')}`}\n />\n ) : brand.logoPending ? (\n <span\n aria-hidden\n className={`block h-[var(--sidebar-brand-logo-height,24px)] ${rc('max-md:hidden')}`}\n />\n ) : (\n <>\n <span\n className={`flex h-9 w-9 items-center justify-center rounded-xl bg-[color:var(--color-accent)] text-base font-black text-[#FFFFFF] shadow-sm ${brand.logoSquareSrc ? rc('max-md:hidden') : ''}`}\n >\n {brand.badgeLabel}\n </span>\n <span className={`flex flex-col leading-tight ${rc('max-md:hidden')}`}>\n <span className=\"text-base font-extrabold tracking-[-0.01em] text-[color:var(--color-accent)]\">\n {brand.title}\n </span>\n {brand.subtitle ? (\n <span className=\"text-[11px] font-semibold uppercase tracking-[0.16em] text-[color:var(--muted)]\">\n {brand.subtitle}\n </span>\n ) : null}\n </span>\n </>\n )}\n </Link>\n\n {/* Organization switcher */}\n {org ? (\n <div className={rc('max-md:flex max-md:justify-center')}>\n <div className={`mb-[7px] mt-[7px] flex items-center justify-between ${rc('max-md:hidden')}`}>\n <p className={NAV_EYEBROW_CLASS}>\n Organization\n </p>\n </div>\n {org.loading ? (\n <div className={`flex w-full items-center gap-2.5 rounded-md border border-[color:var(--line)] bg-[color:var(--panel-elevated)] px-2.5 py-2 shadow-sm ${rc('max-md:w-auto max-md:border-0 max-md:bg-transparent max-md:p-0 max-md:shadow-none')}`}>\n <span\n aria-hidden\n className=\"h-7 w-7 shrink-0 animate-pulse rounded-full bg-[color:var(--panel)]\"\n />\n <span\n aria-hidden\n className={`h-4 flex-1 animate-pulse rounded bg-[color:var(--panel)] ${rc('max-md:hidden')}`}\n />\n <span className=\"sr-only\">Loading organization</span>\n </div>\n ) : org.organizations && org.organizations.length > 0 && org.onSwitch ? (\n <details data-nav-details className=\"group relative\">\n <summary\n style={orgCardStyle}\n title={org.name ?? undefined}\n className={`flex w-full cursor-pointer list-none flex-col overflow-hidden rounded-[5px] border border-[color:var(--sidebar-card-border,var(--sidebar-line,var(--line)))] bg-[color:var(--sidebar-card-bg,var(--panel-elevated))] text-left text-[color:var(--sidebar-text,var(--foreground))] transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))] [&::-webkit-details-marker]:hidden ${rc('max-md:w-auto max-md:items-center max-md:overflow-visible max-md:border-0 max-md:bg-transparent')}`}\n >\n <OrgIconMark org={org} logoSrc={orgLogoSrc} />\n {/* Logo band: white, org's Primary Brand Kit logo ≤70px, never\n cropped/stretched/recolored; \"Upload logo\" for an Admin\n with no logo yet; otherwise the org's display name. */}\n <span className={`relative flex h-[var(--sidebar-org-band-height,70px)] w-full items-center justify-center bg-[#FFFFFF] px-3 py-[7px] ${rc('max-md:hidden')}`}>\n {orgLogoSrc ? (\n <img src={orgLogoSrc} alt=\"\" className=\"max-h-full max-w-[132px] object-contain\" />\n ) : org.canUploadLogo ? (\n <a\n href={org.uploadLogoHref ?? '#'}\n onClick={(e) => e.stopPropagation()}\n className=\"text-xs font-semibold text-[color:var(--color-accent)] underline\"\n >\n Upload logo\n </a>\n ) : (\n <span className=\"truncate text-sm font-semibold text-neutral-800\">\n {org.name ?? 'Organization'}\n </span>\n )}\n <span aria-hidden className=\"absolute inset-x-0 bottom-0 h-[3px]\" style={{ backgroundImage: orgGradient }} />\n </span>\n <span className={`flex w-full min-w-0 items-center justify-between gap-[9px] px-[10px] py-[10px] ${rc('max-md:hidden')}`}>\n <span className=\"flex min-w-0 flex-col\">\n <span\n title={org.name ?? undefined}\n className=\"truncate text-[12px] font-semibold leading-[1.2]\"\n >\n {org.name ?? 'No organizations'}\n </span>\n {org.id && !org.loading ? <OrgIdCopyButton id={org.id} /> : null}\n </span>\n <ChevronDown size={14} />\n </span>\n </summary>\n <div className={`absolute left-0 right-0 z-40 mt-1 max-h-[min(60vh,520px)] overflow-y-auto rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 shadow-[var(--shadow-soft)] ${rc('max-md:right-auto max-md:w-[236px]')}`}>\n {shouldShowOrgFilter(org.organizations.length) ? (\n <div className=\"sticky top-0 z-10 bg-[color:var(--panel-elevated)] px-2 pb-1 pt-1\">\n <input\n type=\"search\"\n value={orgFilter}\n onChange={(e) => setOrgFilter(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n setOrgFilter('')\n e.currentTarget.closest('details')?.removeAttribute('open')\n }\n }}\n placeholder={`Filter ${org.organizations.length} organizations`}\n aria-label=\"Filter organizations\"\n autoComplete=\"off\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-1.5 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n </div>\n ) : null}\n {filterOrgs(org.organizations, orgFilter).length === 0 ? (\n <p className=\"px-3 py-2 text-sm text-[color:var(--muted)]\">No organization matches “{orgFilter}”.</p>\n ) : null}\n {filterOrgs(org.organizations, orgFilter).map((o) => {\n const selected = o.id === org.id\n return (\n <button\n key={o.id}\n type=\"button\"\n onClick={(e) => {\n // Close the <details> popover, then switch.\n e.currentTarget.closest('details')?.removeAttribute('open')\n setOrgFilter('')\n if (!selected) org.onSwitch?.(o.id)\n }}\n aria-current={selected ? 'true' : undefined}\n className={[\n 'flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm',\n selected\n ? 'font-semibold text-[color:var(--color-accent)]'\n : 'font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n <span\n style={{ backgroundColor: o.brandColor || ORG_PILL_DEFAULT }}\n className=\"flex h-6 w-6 shrink-0 items-center justify-center overflow-hidden rounded-full text-[10px] font-bold text-[#FFFFFF]\"\n >\n {resolveOrgLogoUrl(o.logoUrl) ? (\n <img\n src={resolveOrgLogoUrl(o.logoUrl)}\n alt=\"\"\n className=\"h-full w-full object-cover\"\n />\n ) : (\n (o.name ?? 'Org').slice(0, 2).toUpperCase()\n )}\n </span>\n <span title={o.name ?? o.id} className=\"truncate\">\n {o.name ?? o.id.slice(0, 8)}\n </span>\n </button>\n )\n })}\n </div>\n </details>\n ) : (\n <button\n type=\"button\"\n onClick={org.onClick}\n style={orgCardStyle}\n title={org.name ?? undefined}\n className={`flex w-full flex-col overflow-hidden rounded-[5px] border border-[color:var(--sidebar-card-border,var(--sidebar-line,var(--line)))] bg-[color:var(--sidebar-card-bg,var(--panel-elevated))] text-left text-[color:var(--sidebar-text,var(--foreground))] transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))] ${rc('max-md:w-auto max-md:items-center max-md:overflow-visible max-md:border-0 max-md:bg-transparent')}`}\n >\n <OrgIconMark org={org} logoSrc={orgLogoSrc} />\n <span className={`relative flex h-[var(--sidebar-org-band-height,70px)] w-full items-center justify-center bg-[#FFFFFF] px-3 py-[7px] ${rc('max-md:hidden')}`}>\n {orgLogoSrc ? (\n <img src={orgLogoSrc} alt=\"\" className=\"max-h-full max-w-[132px] object-contain\" />\n ) : org.canUploadLogo ? (\n <a\n href={org.uploadLogoHref ?? '#'}\n onClick={(e) => e.stopPropagation()}\n className=\"text-xs font-semibold text-[color:var(--color-accent)] underline\"\n >\n Upload logo\n </a>\n ) : (\n <span className=\"truncate text-sm font-semibold text-neutral-800\">\n {org.name ?? 'Organization'}\n </span>\n )}\n <span aria-hidden className=\"absolute inset-x-0 bottom-0 h-[3px]\" style={{ backgroundImage: orgGradient }} />\n </span>\n <span className={`flex w-full min-w-0 items-center justify-between gap-[9px] px-[10px] py-[10px] ${rc('max-md:hidden')}`}>\n <span className=\"flex min-w-0 flex-col\">\n <span\n title={org.name ?? undefined}\n className=\"truncate text-[12px] font-semibold leading-[1.2]\"\n >\n {org.name ?? 'No organizations'}\n </span>\n {org.id && !org.loading ? <OrgIdCopyButton id={org.id} /> : null}\n </span>\n <ChevronDown size={14} />\n </span>\n </button>\n )}\n </div>\n ) : null}\n\n {/* Mode selector — Reference/UI-Platform: \"A row of three icon buttons\n — Relationship · Campaign · Petition — under the org card, never a\n dropdown, with the current mode's name beneath.\" Identical in every\n app, mode-scoped apps included: the app's own mode is selected and\n the other available modes navigate to that mode's landing page. */}\n {mode ? (\n <div className={rc('max-md:w-full')}>\n <div\n role=\"radiogroup\"\n aria-label=\"Mode\"\n className={`flex w-full items-center gap-1 rounded-lg border border-[color:var(--border-inverse,var(--sidebar-line,var(--line)))] bg-[color:var(--mode-track-bg,var(--panel-elevated))] p-[3px] ${rc('max-md:flex-col max-md:items-stretch')}`}\n >\n {(mode.options && mode.options.length > 0 ? mode.options : [{ id: mode.label, label: mode.label, icon: ModeIcon }]).map(\n (opt) => {\n const selected = opt.label === mode.label\n const OptIcon = opt.icon\n const available = opt.available ?? true\n const title = !available\n ? opt.unavailableTooltip ?? `${opt.label} isn't active for this organization.`\n : opt.label\n return (\n <button\n key={opt.id}\n type=\"button\"\n role=\"radio\"\n title={title}\n aria-label={title}\n aria-checked={selected}\n aria-current={selected ? 'true' : undefined}\n onClick={() => {\n if (available && !selected) mode.onSelect?.(opt.id)\n }}\n disabled={!available}\n className={[\n `flex flex-none items-center justify-center rounded-[5px] px-[9px] py-[6px] transition ${rc('max-md:flex-1')}`,\n !available\n ? 'cursor-not-allowed text-[color:var(--sidebar-text-muted,var(--muted))] opacity-35'\n : selected\n ? 'bg-[color:var(--sidebar-mode-selected-bg,var(--mode-accent,var(--color-accent)))] text-[color:var(--mode-on-accent,white)]'\n : 'text-[color:var(--sidebar-text-muted,var(--muted))] hover:bg-[#FFFFFF]/5 hover:text-[color:var(--sidebar-text,var(--foreground))]',\n ].join(' ')}\n >\n {OptIcon ? <OptIcon size={15} className=\"shrink-0\" /> : null}\n </button>\n )\n },\n )}\n </div>\n {/* Sentence-case caption, left-aligned under the switcher\n (\"Relationship mode\") — Specs/Contacts design rail. */}\n <p className={`mt-1.5 text-left text-[11px] leading-[1.2] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] ${rc('max-md:hidden')}`}>\n {modeCaption(mode.label)}\n </p>\n </div>\n ) : null}\n </div>\n\n {/* Scroll region: nav only — the header above stays put. */}\n <div className=\"flex flex-1 flex-col overflow-y-auto px-[10px] py-3\">\n {/* Nav list */}\n <nav className=\"flex flex-col gap-0.5\">\n {nav.groupLabel ? (\n <p className={`${NAV_EYEBROW_CLASS} px-2 pb-1.5 pt-1 ${rc('max-md:hidden')}`}>\n {nav.groupLabel}\n </p>\n ) : null}\n {nav.items.map((item, idx) => {\n // Section heading: groups the rows beneath it. Non-interactive and\n // not focusable, so it is skipped by tab order and never reads as a\n // dead control. Top margin except on the first row, so the groups\n // separate without a stray gap at the top of the rail.\n if (item.kind === 'section') {\n return (\n <NavSectionRow\n key={`section-${idx}-${item.label}`}\n label={item.label}\n first={idx === 0}\n />\n )\n }\n // Flattened tree: the group's children ARE the rail. See nav.flatten.\n if (nav.flatten && item.children && item.children.length > 0) {\n return item.children.map((child, i) => {\n if (child.kind === 'section') {\n return (\n <NavSectionRow\n key={`flat-section-${idx}-${i}-${child.label}`}\n label={child.label}\n first={idx === 0 && i === 0}\n />\n )\n }\n return (\n <NavRow\n key={child.href ?? `flat-${idx}-${i}-${child.label}`}\n item={child}\n active={child.href ? activeFn(pathname, child.href) : false}\n Link={Link}\n variant=\"flat\"\n />\n )\n })\n }\n // Left-Navigation §8.2: the bar is flat — no sub-menus, no\n // accordions, no chevrons. A row with children renders as one row\n // linking to its own page (or its first child's) and is active\n // whenever any page beneath it is (§11.3, by route prefix). The\n // children stay in the tree for breadcrumbs and in-page tabs.\n if (item.children && item.children.length > 0) {\n const selfActive = item.href ? activeFn(pathname, item.href) : false\n const parentActive = selfActive || hasActiveChild(item, pathname, activeFn)\n return (\n <NavRow\n key={item.href ?? groupKeyOf(item, idx)}\n item={{ ...item, href: item.href ?? firstLeafHref(item), children: undefined }}\n active={parentActive}\n Link={Link}\n />\n )\n }\n const active = item.href ? activeFn(pathname, item.href) : false\n return (\n <NavRow\n key={item.href ?? `nav-${idx}-${item.label}`}\n item={item}\n active={active}\n Link={Link}\n />\n )\n })}\n </nav>\n </div>\n\n {/* Footer — user card (account menu opens upward), then the links row,\n then the build meta (non-production only). Specs/Contacts design rail. */}\n {footer ? (\n <div className={`relative flex-shrink-0 border-t border-[color:var(--sidebar-line,var(--line))] px-[14px] py-3 ${rc('max-md:px-[10px]')}`}>\n {footer.user ? (\n <NavSidebarUserCard\n user={footer.user}\n userMenu={footer.userMenu ?? undefined}\n onSignOut={footer.onSignOut}\n />\n ) : null}\n {footer.links && footer.links.length > 0 ? (\n <div className={`flex flex-wrap items-center justify-center gap-[6px] text-[11px] leading-[1.2] ${footer.user ? 'mt-3' : ''} ${rc('max-md:hidden')}`}>\n {footer.links.map((l, i) => (\n <Fragment key={l.label}>\n {i > 0 ? <span aria-hidden className=\"text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))]\">·</span> : null}\n <a\n href={safeHref(l.href)}\n className=\"text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] hover:text-[color:var(--sidebar-text,var(--foreground))] hover:underline\"\n >\n {l.label}\n </a>\n </Fragment>\n ))}\n </div>\n ) : null}\n {footer.envLabel || footer.commit || footer.version ? (\n <div\n data-shell-meta\n className={`mt-1.5 flex flex-col items-center gap-0.5 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] text-[color:var(--sidebar-meta-text,rgba(255,255,255,0.72))] ${rc('max-md:hidden')}`}\n >\n {/* Row 1: env | commit | version — Specs/Left-Navigation §9:\n plain mono text, centered, no leading or trailing pipes. */}\n <div className=\"flex items-center gap-1.5\">\n {[\n footer.envLabel ? shortEnvLabel(footer.envLabel) : null,\n footer.commit ? footer.commit.slice(-4) : null,\n footer.version ? `v${footer.version.replace(/^v/, '')}` : null,\n ]\n .filter((v): v is string => Boolean(v))\n .map((v, i) => (\n <Fragment key={i}>\n {i > 0 ? <span>|</span> : null}\n <span>{v}</span>\n </Fragment>\n ))}\n </div>\n {/* Row 2: date | author (only when supplied) */}\n {footer.commitDate || footer.commitAuthor ? (\n <div className=\"flex items-center gap-1.5\">\n {footer.commitDate ? (\n <span>\n {new Date(footer.commitDate).toLocaleDateString(undefined, {\n month: 'short',\n day: 'numeric',\n })}\n </span>\n ) : null}\n {footer.commitDate && footer.commitAuthor ? (\n <span>|</span>\n ) : null}\n {footer.commitAuthor ? (\n <span>{footer.commitAuthor.split(/\\s+/)[0]}</span>\n ) : null}\n </div>\n ) : null}\n </div>\n ) : null}\n </div>\n ) : null}\n </aside>\n </RailCollapsibleContext.Provider>\n )\n}\n\n// Inline hamburger / close glyphs for the mobile nav drawer — no icon\n// dependency, same idiom as every other inline SVG in this file.\nfunction HamburgerIcon() {\n return (\n <svg\n width={24}\n height={24}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\" />\n <line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\" />\n <line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\" />\n </svg>\n )\n}\n\n/** 14px book-open glyph for the \"Build notes\" quiet button (design). */\nfunction BookOpenIcon() {\n return (\n <svg\n width={14}\n height={14}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 7v14\" />\n <path d=\"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z\" />\n </svg>\n )\n}\n\nfunction SearchIcon({ className }: { className?: string } = {}) {\n return (\n <svg\n width={16}\n height={16}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\" />\n </svg>\n )\n}\n\nfunction CloseIcon() {\n return (\n <svg\n width={20}\n height={20}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\n// Inline chevron-down (mirrors lucide `ChevronDown`) — no icon dependency.\n// Callers may override `className` to add a rotation (used by expandable groups).\nfunction ChevronDown({ className, size = 16 }: { className?: string; size?: number } = {}) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className ?? 'shrink-0 opacity-80'}\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n )\n}\n\n// A single sidebar nav row. Renders as a routed <Link> (href) or a <button>\n// (onClick), styled identically. Inactive rows animate a left→right gradient\n// sweep on hover (matching the main app); active rows keep the solid accent.\n//\n// `variant=\"sub\"` renders the smaller child rows inside an expanded group: a\n// tighter row whose ACTIVE state is a lighter elevated surface with accent\n// text (not a solid fill — that stays reserved for top-level/parent rows,\n// exactly as the main VRM app's Chakra sidebar treats active sub-items).\n//\n// The gradient was hardcoded to the race-red 400/500 stops; it now reads the\n// token so a Mode with its own accent sweeps in its own colour. chrome.css\n// defaults it to those same two stops, so nothing moves for anyone else.\nconst NAV_HOVER_GRADIENT = 'var(--nav-hover-gradient)'\n\n// A non-interactive section heading. Groups the rows beneath it; not a control,\n// so it is not focusable and carries no hover, no aria-disabled and no role.\n//\n// Rendered at BOTH levels: an app whose routes are nested under a standard nav\n// entry (Petitions nests its whole tree under the Petition Mode row) needs its\n// sections inside the expanded group, not only at the top level.\n//\n// `first` suppresses the leading margin so a rail that opens with a section\n// does not start with a gap.\n// Rail typography/geometry — Specs/Contacts design rail (Reference/UI-Platform\n// v30 → Left bar). Every token has an inline fallback so an app that is not\n// mode-scoped (white rail) keeps a sane rendering.\nconst NAV_EYEBROW_CLASS =\n 'text-[11px] font-bold uppercase leading-[1.2] tracking-[0.09em] text-[color:var(--sidebar-eyebrow,var(--sidebar-text-muted,var(--muted)))]'\nconst NAV_TOP_ICON_SIZE = 17\nconst NAV_TOP_ROW_CLASS = (active: boolean) =>\n `gap-[11px] px-[10px] py-[9px] text-[13px] leading-none ${active ? 'font-semibold' : 'font-normal'}`\nconst NAV_TOP_ACTIVE_CLASS =\n 'bg-[color:var(--sidebar-active-bg,var(--color-accent))] text-[color:var(--sidebar-active-text,white)]'\nconst NAV_TOP_INACTIVE_CLASS =\n 'text-[color:var(--sidebar-row-text,var(--sidebar-text,var(--muted)))] hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel-elevated))] hover:text-[color:var(--sidebar-text,var(--foreground))]'\n\n/** \"Relationship Mode\" → \"Relationship mode\" (design caption is sentence case). */\nfunction modeCaption(label: string): string {\n return label.replace(/\\s+Mode$/i, ' mode')\n}\n\n/** 2px inset rail on the active row, in the Mode accent (design: inset 2px 0 0 0). */\nfunction NavActiveRail() {\n // `--mode-accent` is only set by a declared Mode chrome group; the inline\n // `transparent` fallback is what every other app gets — present but\n // invisible, and absolutely positioned so it moves nothing.\n return (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-0 left-0 w-[2px]\"\n style={{ background: 'var(--mode-accent, transparent)' }}\n />\n )\n}\n\n/** Right-aligned mono count on a nav row (`Contacts · 31.9K`). */\nfunction NavRowBadge({ value }: { value?: string | number | null }) {\n const rc = useRailCollapse()\n if (value === undefined || value === null || value === '') return null\n return (\n <span className={`ml-auto shrink-0 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] font-semibold leading-none text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] ${rc('max-md:hidden')}`}>\n {value}\n </span>\n )\n}\n\nfunction NavSectionRow({\n label,\n first,\n variant = 'top',\n}: {\n label: string\n first: boolean\n variant?: 'top' | 'sub'\n}) {\n const rc = useRailCollapse()\n // Collapsed rail: the eyebrow becomes a 1px divider (Left-Navigation §11.6).\n // The label stays in the DOM so it is still a heading for screen readers.\n const collapsed =\n variant === 'sub'\n ? ''\n : first\n ? rc('max-md:sr-only')\n : rc(\n 'max-md:mx-2 max-md:my-2 max-md:h-px max-md:overflow-hidden max-md:bg-[color:var(--sidebar-line,var(--line))] max-md:p-0 max-md:text-transparent',\n )\n return (\n <p\n className={[\n NAV_EYEBROW_CLASS,\n variant === 'sub' ? 'px-3 pb-0.5' : 'px-2 pb-1.5 pt-1',\n first ? '' : variant === 'sub' ? 'mt-3' : 'mt-[14px]',\n collapsed,\n ].join(' ')}\n >\n {label}\n </p>\n )\n}\n\nfunction NavRow({\n item,\n active,\n Link,\n variant = 'top',\n}: {\n item: NavItem\n active: boolean\n Link: NavLinkComponent\n variant?: 'top' | 'sub' | 'flat'\n}) {\n const rc = useRailCollapse()\n const Icon = item.icon\n const isSub = variant === 'sub'\n // 'flat' rows keep top-level geometry but take the wash active treatment —\n // tinted surface + accent text — the way V1's full-height rail rows did,\n // rather than the solid fill reserved for parent rows.\n const washActive = variant !== 'top'\n // The active sub-row surface follows the Mode when one is declared.\n //\n // The fallback is INLINE, and has to be. `--mode-accent-surface` is only ever\n // set inside `[data-politogy-mode]`, so an app that is not mode-scoped never\n // has it — and a bare `var(--x)` with no fallback is invalid at\n // computed-value time, which would drop `background-color` all the way to\n // `transparent` and silently delete the active highlight for Contacts, Forms,\n // Surveys and Polls. Nor can the fallback be hoisted into a `:root`\n // declaration: `.dark` is a separate top-level selector here, so a `:root`\n // alias would freeze the LIGHT `--panel-elevated` and inherit it into dark.\n // Resolving at the point of use is the only placement that is correct in both\n // themes, scoped and unscoped.\n const activeClasses = washActive\n ? 'bg-[color:var(--mode-accent-surface,var(--panel-elevated))] text-[color:var(--color-accent)] shadow-sm'\n : NAV_TOP_ACTIVE_CLASS\n const wrapperClasses = [\n 'group relative block overflow-hidden transition',\n isSub ? 'rounded-md' : 'rounded-[5px]',\n active ? activeClasses : isSub ? 'text-[color:var(--sidebar-text,var(--muted))] hover:text-[#FFFFFF]' : NAV_TOP_INACTIVE_CLASS,\n ].join(' ')\n\n const rowPadding = isSub ? 'gap-3 px-3 py-1.5 text-[13px] font-semibold' : NAV_TOP_ROW_CLASS(active)\n const iconSize = isSub ? 16 : NAV_TOP_ICON_SIZE\n // Glyphs inherit the row's text color in every variant.\n const iconClass = 'text-current'\n\n const inner = (\n <>\n {!active ? (\n // Sub rows keep the left→right gradient sweep; top-level rows take a\n // flat wash on hover (design rail: rgba(255,255,255,.05)).\n isSub ? (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-0 left-0 w-0 transition-[width] duration-300 group-hover:w-full\"\n style={{ background: NAV_HOVER_GRADIENT }}\n />\n ) : null\n ) : (\n <NavActiveRail />\n )}\n <span className={`relative z-10 flex items-center ${rowPadding} ${rc('max-md:justify-center max-md:px-0')}`}>\n {Icon ? (\n <Icon size={iconSize} className={`shrink-0 ${iconClass}`} />\n ) : (\n // A row with no glyph still needs something on the icon rail.\n <span aria-hidden className={`hidden text-[11px] font-semibold uppercase ${rc('max-md:inline')}`}>\n {item.label.slice(0, 2)}\n </span>\n )}\n <span className={`min-w-0 flex-1 truncate ${rc('max-md:hidden')}`}>{item.label}</span>\n <NavRowBadge value={item.badge} />\n </span>\n </>\n )\n\n // A gated row renders as a non-interactive span: dimmed, not focusable, and\n // carrying its reason as a tooltip. Same treatment a disabled NavTab gets, so\n // gating reads identically in the sidebar and in a tab strip.\n if (item.disabled) {\n return (\n <span\n aria-disabled=\"true\"\n title={item.disabledTitle ?? item.label}\n className={`${wrapperClasses} cursor-not-allowed opacity-50`}\n >\n {inner}\n </span>\n )\n }\n\n if (item.onClick && !item.href) {\n return (\n <button\n type=\"button\"\n onClick={item.onClick}\n title={item.label}\n className={`w-full text-left ${wrapperClasses}`}\n >\n {inner}\n </button>\n )\n }\n\n return (\n <Link\n href={item.href ?? '#'}\n aria-current={active ? 'page' : undefined}\n // The tooltip names the row; on the collapsed rail it is also the\n // row's accessible name, since the label is not displayed.\n title={item.label}\n className={wrapperClasses}\n >\n {inner}\n </Link>\n )\n}\n\n// An expandable nav GROUP: a toggle header + a collapsible list of child rows.\n// Faithful twin of the main VRM app's Chakra accordion (Sidebar.tsx /\n// NavItem.tsx):\n// - Clicking the header toggles the children — it never navigates, even when\n// the group carries an `href`.\n// - A right-aligned chevron rotates 180° when open.\n// - The header goes solid accent (white text) when the group owns the active\n// route (its own href OR any child), matching top-level active rows; when\n// merely open it lifts onto the `--panel` surface; otherwise it's a muted row\n// with the same left→right gradient hover sweep as every other nav row.\n// - Children sit on the lighter `--panel` surface, indented and rounded, each\n// rendered through the SAME injected LinkComponent (or as a button for\n// `onClick` children) via <NavRow variant=\"sub\" />.\nfunction NavGroup({\n item,\n active,\n open,\n onToggle,\n pathname,\n activeFn,\n Link,\n}: {\n item: NavItem\n active: boolean\n open: boolean\n onToggle: () => void\n pathname: string\n activeFn: (pathname: string, href: string) => boolean\n Link: NavLinkComponent\n}) {\n const rc = useRailCollapse()\n const Icon = item.icon\n const headerClasses = [\n 'group relative block w-full overflow-hidden text-left transition',\n open ? 'rounded-t-[5px]' : 'rounded-[5px]',\n active\n ? NAV_TOP_ACTIVE_CLASS\n : open\n ? 'bg-[color:var(--sidebar-row-hover-bg,var(--panel))] text-[color:var(--sidebar-text,var(--foreground))]'\n : NAV_TOP_INACTIVE_CLASS,\n ].join(' ')\n\n return (\n <div>\n <button\n type=\"button\"\n // A group header ALWAYS toggles. When the item also carries its own\n // onClick, that runs too — so a parent can navigate to its section\n // dashboard (e.g. Email Broadcast → /relationship/email/dashboard) and\n // expand in one click. Existing apps pass no parent onClick, so their\n // behavior is unchanged (shell-nav-handoff §2).\n onClick={() => {\n onToggle()\n item.onClick?.()\n }}\n aria-expanded={open}\n title={item.label}\n className={headerClasses}\n >\n {active ? <NavActiveRail /> : null}\n <span className={`relative z-10 flex items-center ${NAV_TOP_ROW_CLASS(active)} ${rc('max-md:justify-center max-md:px-0')}`}>\n {Icon ? (\n <Icon size={NAV_TOP_ICON_SIZE} className=\"shrink-0 text-current\" />\n ) : null}\n <span className={`min-w-0 flex-1 truncate ${rc('max-md:hidden')}`}>{item.label}</span>\n <NavRowBadge value={item.badge} />\n <ChevronDown\n className={[\n 'shrink-0 opacity-80 transition-transform duration-200',\n open ? 'rotate-180' : '',\n rc('max-md:hidden'),\n ].join(' ')}\n />\n </span>\n </button>\n\n {open ? (\n <div className={`overflow-hidden rounded-b-md bg-[color:var(--nav-submenu-bg)] p-1 ${rc('max-md:hidden')}`}>\n <div className=\"flex flex-col gap-0.5\">\n {item.children!.map((child, i) => {\n if (child.kind === 'section') {\n return (\n <NavSectionRow\n key={`sub-section-${i}-${child.label}`}\n label={child.label}\n first={i === 0}\n variant=\"sub\"\n />\n )\n }\n const childActive = child.href ? activeFn(pathname, child.href) : false\n // Depth-3: a child that carries its own children renders as a\n // NESTED collapsible sub-group (e.g. Organization Settings →\n // Subscription & Billing → Wallet). Deeper levels are not\n // rendered — three is the platform maximum.\n if (child.children && child.children.length > 0) {\n return (\n <NavSubGroup\n key={child.href ?? `subgrp-${i}-${child.label}`}\n item={child}\n pathname={pathname}\n activeFn={activeFn}\n Link={Link}\n />\n )\n }\n return (\n <NavRow\n key={child.href ?? `sub-${i}-${child.label}`}\n item={child}\n active={childActive}\n Link={Link}\n variant=\"sub\"\n />\n )\n })}\n </div>\n </div>\n ) : null}\n </div>\n )\n}\n\n// A second-level group INSIDE an expanded group — the depth-3 renderer\n// (Reference/UI-Platform: sub-sub items). Auto-expands when it owns the active\n// route; otherwise toggles locally. Grandchildren render as further-indented\n// sub rows on the same panel surface.\nfunction NavSubGroup({\n item,\n pathname,\n activeFn,\n Link,\n}: {\n item: NavItem\n pathname: string\n activeFn: (pathname: string, href: string) => boolean\n Link: NavLinkComponent\n}) {\n const ownsActive =\n (item.href ? activeFn(pathname, item.href) : false) ||\n (item.children ?? []).some((c) => (c.href ? activeFn(pathname, c.href) : false))\n const [open, setOpen] = useState(ownsActive)\n useEffect(() => {\n if (ownsActive) setOpen(true)\n }, [ownsActive])\n const Icon = item.icon\n\n return (\n <div>\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-expanded={open}\n className={[\n 'flex w-full items-center gap-2.5 rounded px-3 py-1.5 text-left text-[13px] font-medium transition',\n ownsActive\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--sidebar-text,var(--muted))] hover:bg-[color:var(--nav-row-hover)] hover:text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {Icon ? <Icon size={15} className=\"shrink-0 text-current\" /> : null}\n <span className=\"flex-1\">{item.label}</span>\n <ChevronDown\n className={[\n 'shrink-0 opacity-70 transition-transform duration-200',\n open ? 'rotate-180' : '',\n ].join(' ')}\n />\n </button>\n {open ? (\n <div className=\"ml-4 flex flex-col gap-0.5 border-l border-[color:var(--line)] pl-2\">\n {item.children!.map((leaf, i) => (\n <NavRow\n key={leaf.href ?? `subsub-${i}-${leaf.label}`}\n item={leaf}\n active={leaf.href ? activeFn(pathname, leaf.href) : false}\n Link={Link}\n variant=\"sub\"\n />\n ))}\n </div>\n ) : null}\n </div>\n )\n}\n\n// Right-aligned copy affordance for the org id, shown beside the \"Organization\"\n// label. Copies the full id and briefly swaps its text to \"Copied\".\nfunction OrgIdCopyButton({ id }: { id: string }) {\n const [copied, setCopied] = useState(false)\n return (\n <button\n type=\"button\"\n onClick={() => {\n try {\n void navigator.clipboard?.writeText(id)\n } catch {\n /* clipboard unavailable — ignore */\n }\n setCopied(true)\n setTimeout(() => setCopied(false), 1500)\n }}\n title=\"Copy organization id\"\n className=\"-ml-1 rounded px-1 text-left font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[12px] leading-[1.2] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel))]\"\n >\n {copied ? 'Copied' : `…${id.slice(-8)}`}\n </button>\n )\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavUser = {\n name: string | null\n email?: string | null\n /** Profile PHOTO url — highest-precedence avatar source. */\n avatarUrl?: string | null\n /** Memoji url — used when no photo is set; falls back to initials. */\n memojiUrl?: string | null\n tier?: string | null\n role?: string | null\n}\n\nexport type NavTopBarAction = {\n key: string\n /**\n * Canonical top-bar slot. When set, the glyph is sourced by NAME from the\n * Brand API via `--topbar-icon-<slot>`; `icon` becomes the fallback used\n * until the runtime Brand stylesheet lands (or when the token is unset).\n */\n slot?: TopBarIconSlot\n icon: NavIcon\n label: string\n onClick?: () => void\n href?: string\n badge?: number | null\n tone?: 'default' | 'warning' | 'danger'\n /** Tooltip body shown under the icon (label is the tooltip title). */\n description?: string\n}\n\nexport type NavLinkedAccount = {\n id: string\n name: string | null\n email?: string | null\n avatarUrl?: string | null\n active?: boolean\n}\n\nexport type NavRoleBadge = {\n role: string\n orgName?: string | null\n}\n\n/**\n * The My Account menu (avatar dropdown) — mirrors the main VRM app's user\n * menu: My Profile / Organization Settings links, a ROLES & ORGANIZATIONS\n * section, an ACCOUNTS switcher, an optional theme control, then Sign out.\n * Every section renders only when its data is supplied.\n */\nexport type NavUserMenu = {\n myProfileHref?: string\n organizationSettingsHref?: string\n roles?: NavRoleBadge[]\n accounts?: NavLinkedAccount[]\n onSwitchAccount?: (id: string) => void\n onRemoveAccount?: (id: string) => void\n addAccountHref?: string\n onAddAccount?: () => void\n /**\n * Navigation display (Sub Menu / Tabs Only / Both) — lives in the account\n * menu since 0.68.0; the top-bar `NavDisplayAction` popover is retired from\n * the standard cluster (design: 4 icon buttons + Help).\n */\n navDisplay?: {\n value: NavDisplayMode\n onChange: (next: NavDisplayMode) => void\n }\n /** Theme preference segmented control (Light / System / Dark). */\n theme?: {\n value: ThemePreference\n onChange: (next: ThemePreference) => void\n }\n}\n\nexport type NavBreadcrumb = {\n label: string\n href?: string\n}\n\nexport type NavTopBarProps = {\n /**\n * Chrome-owned page title line (`<h1>` above main). Omit when the page body\n * owns its own title (registry `pageTitle: false`, e.g. Contacts).\n */\n title?: string\n subtitle?: string\n /**\n * Breadcrumb trail rendered UNDER the page title (Reference/UI-Platform:\n * every page and sub-page/tab shows its location). Last crumb = current\n * location (non-link); earlier crumbs may carry hrefs.\n */\n breadcrumbs?: NavBreadcrumb[]\n user?: NavUser | null\n userMenu?: NavUserMenu\n onSignOut?: () => void\n /**\n * Structured icon-button action cluster (32×32 circular buttons with optional\n * count badges), rendered before the `actions` slot. Matches the main app's\n * topbar action icons.\n */\n actionsList?: NavTopBarAction[]\n /** App-specific action cluster rendered left of the theme toggle. */\n actions?: ReactNode\n /** Theme toggle slot (injected so this package needs no theme dependency). */\n themeToggle?: ReactNode\n /**\n * Mobile drawer trigger (owned by `NavAppShell`). Supplying it renders a\n * hamburger button, hidden at `lg` and up, as the first thing in the header\n * — below `lg` the sidebar is otherwise unreachable. Omit to render no\n * hamburger at all (e.g. `NavTopBar` used standalone).\n */\n onOpenNav?: () => void\n /** Whether the drawer `onOpenNav` opens is currently open (drives `aria-expanded`). */\n navOpen?: boolean\n /**\n * Universal search — Reference/UI-Platform \"Top bar → required elements\":\n * the search field, 320px wide, at the left end of the bar; nothing else\n * sits on the left. Omit `onChange`/`onSubmit` for a decorative field (an\n * app that has not wired search yet still gets the correct chrome).\n */\n search?: {\n placeholder?: string\n value?: string\n onChange?: (value: string) => void\n onSubmit?: (value: string) => void\n }\n /**\n * Build notes — a quiet text button that starts the right-hand group\n * (Reference/UI-Platform \"Top bar → required elements\").\n */\n /**\n * Where the My Account trigger lives. `'topbar'` (default for a standalone\n * `NavTopBar`) keeps the avatar + name + chevron at the right end of the bar;\n * `'sidebar'` / `'none'` hide it here — `NavAppShell` passes `'sidebar'` and\n * draws the user card in the left-bar footer instead (UI-Platform v30:\n * \"There is no My Account badge in the top bar\").\n */\n accountMenu?: 'topbar' | 'sidebar' | 'none'\n buildNotes?: {\n label?: string\n onOpen?: () => void\n }\n}\n\nexport function NavTopBar({\n title,\n subtitle,\n breadcrumbs,\n user,\n userMenu,\n onSignOut,\n actionsList,\n actions,\n themeToggle,\n onOpenNav,\n navOpen,\n search,\n buildNotes,\n accountMenu = 'topbar',\n}: NavTopBarProps) {\n // Real name = anything that isn't empty and isn't an email address. The\n // trigger shows \"First L.\" — never the email on both lines.\n const rawName = user?.name?.trim() || ''\n const hasRealName = rawName.length > 0 && !rawName.includes('@')\n const displayName = hasRealName ? formatFirstLast(rawName) : (user?.email ?? 'Signed in')\n const initials = (hasRealName ? rawName : (user?.email ?? 'P')).slice(0, 2).toUpperCase()\n const secondary = hasRealName\n ? user?.email || [user?.tier, user?.role].filter(Boolean).join(' · ') || 'member'\n : [user?.tier, user?.role].filter(Boolean).join(' · ') || 'member'\n // `title` / `subtitle` / `breadcrumbs` are no longer rendered here —\n // Reference/UI-Platform \"Page header\" moved the title into the main body\n // (22px below this bar) and retired the breadcrumb trail entirely. They\n // stay accepted on the prop type so apps mid-migration do not break the\n // build; the chrome just stops drawing them.\n void title\n void subtitle\n void breadcrumbs\n return (\n <div className=\"sticky top-0 z-20\">\n <header className=\"flex min-w-0 h-[var(--topbar-height,60px)] items-center justify-between gap-[8px] md:gap-[14px] border-b border-[color:var(--line)] bg-[color:var(--panel)] px-[var(--topbar-padding-x,20px)]\">\n {onOpenNav ? (\n <button\n type=\"button\"\n onClick={onOpenNav}\n aria-label=\"Open menu\"\n aria-expanded={navOpen ?? false}\n aria-controls=\"politogy-nav-drawer\"\n className={`${topBarIconButtonClass('default')} mr-1 shrink-0 md:hidden`}\n >\n <HamburgerIcon />\n </button>\n ) : null}\n\n {/* Universal search — the only thing on the left end of the bar. 320px\n (Reference/UI-Platform); below md it shrinks so the bar never pushes\n the page wider than a 390px phone. */}\n <label className=\"relative flex h-9 w-[320px] min-w-0 max-w-full shrink items-center md:shrink-0\">\n <SearchIcon className=\"pointer-events-none absolute left-[10px] h-[15px] w-[15px] text-[color:var(--muted)]\" />\n <input\n type=\"search\"\n placeholder={search?.placeholder ?? 'Search'}\n value={search?.value}\n onChange={search?.onChange ? (e) => search.onChange?.(e.target.value) : undefined}\n onKeyDown={\n search?.onSubmit\n ? (e) => {\n if (e.key === 'Enter') search.onSubmit?.((e.target as HTMLInputElement).value)\n }\n : undefined\n }\n readOnly={!search?.onChange}\n className=\"h-full w-full rounded-[5px] border border-[color:var(--line)] bg-[color:var(--surface-sunken,var(--panel-elevated))] pl-[33px] pr-10 text-[13px] text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n <kbd\n aria-hidden\n className=\"pointer-events-none absolute right-[10px] hidden md:block rounded-[3px] border border-[color:var(--line)] px-[5px] py-px font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[12px] leading-[1.2] text-[color:var(--muted)]\"\n >\n /\n </kbd>\n </label>\n\n <div className=\"relative ml-auto flex shrink-0 items-center gap-[var(--topbar-icon-gap,8px)]\">\n {/* Reference/UI-Platform \"Top bar — required elements\" (2026-10-03):\n there is no Build notes control. Rendered only if an app opts in. */}\n {buildNotes ? (\n <button\n type=\"button\"\n onClick={buildNotes?.onOpen}\n className=\"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-[5px] px-3 text-xs font-semibold text-[color:var(--muted)] transition hover:bg-[color:var(--surface-sunken,var(--panel-elevated))] hover:text-[color:var(--foreground)]\"\n >\n <BookOpenIcon />\n {buildNotes?.label ?? 'Build notes'}\n </button>\n ) : null}\n {actionsList && actionsList.length > 0\n ? actionsList.map((action) => (\n <NavTopBarActionButton key={action.key} action={action} />\n ))\n : null}\n {actions}\n {themeToggle}\n\n {/* My Account menu — avatar + name/email + chevron trigger, with the\n full account dropdown (profile/org links, roles, account switcher,\n appearance, sign out). Native <details> popover. Hidden when the\n shell draws the user card in the left-bar footer instead. */}\n {accountMenu === 'topbar' ? (\n <details data-nav-details className=\"group/acct relative\">\n <summary className=\"group/tbtip relative flex cursor-pointer list-none items-center gap-2.5 rounded-full py-1 pl-1 pr-2 transition hover:bg-[color:var(--panel-elevated)] [&::-webkit-details-marker]:hidden\">\n {/* Same circle size as every top-bar icon button (one shared var).\n Avatar precedence: photo → memoji → initials. */}\n <span className=\"flex h-[var(--topbar-icon-button-size,32px)] w-[var(--topbar-icon-button-size,32px)] items-center justify-center overflow-hidden rounded-full bg-[color:var(--color-accent)] text-xs font-bold text-[#FFFFFF]\">\n {user?.avatarUrl || user?.memojiUrl ? (\n <img\n src={(user.avatarUrl || user.memojiUrl) as string}\n alt=\"\"\n className=\"h-full w-full object-cover\"\n />\n ) : (\n initials\n )}\n </span>\n <span className=\"hidden flex-col leading-tight md:flex\">\n <span className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {displayName}\n </span>\n <span className=\"text-xs text-[color:var(--muted)]\">{secondary}</span>\n </span>\n <ChevronDown />\n <span className=\"group-open/acct:hidden\">\n <TopBarTooltip\n title=\"My Account\"\n description={\n <>\n {hasRealName ? rawName : user?.email ?? 'Signed in'}\n {user?.email ? (\n <>\n <br />\n {user.email}\n </>\n ) : null}\n <br />\n Profile, organizations, appearance and sign out.\n </>\n }\n />\n </span>\n </summary>\n {/*\n The menu grows with the user's data — roles, linked accounts, the\n theme control — and on a short viewport (or a user in many orgs) it\n ran past the bottom of the screen with no way to scroll, putting\n Sign out permanently out of reach. Cap the panel at the viewport,\n scroll the SECTIONS, and keep Sign out outside that scroll area so\n it is always on screen no matter how long the list gets.\n */}\n <NavAccountMenuPanel userMenu={userMenu} onSignOut={onSignOut} placement=\"below\" />\n </details>\n ) : null}\n {accountMenu === 'topbar' && !hasRealName && user ? (\n <NamePromptBubble profileHref={userMenu?.myProfileHref} />\n ) : null}\n </div>\n </header>\n {/* Brand gradient rule — Reference/UI-Platform \"Top bar → required\n elements\": \"A 3px strip of the brand gradient (blue → red) runs\n directly beneath it.\" Chrome-owned token, never the party-identity\n race-red. */}\n <div\n aria-hidden\n className=\"h-[3px] w-full shrink-0\"\n style={{\n background:\n 'var(--chrome-gradient, linear-gradient(to right, #007BFF, #A54B7A, #E63946))',\n }}\n />\n </div>\n )\n}\n\n/**\n * The account menu body — profile/org links, roles, account switcher,\n * appearance, navigation display, sign out. One definition drawn from two\n * triggers: the top-bar avatar (`placement=\"below\"`, legacy) and the left-bar\n * footer user card (`placement=\"above\"`, Reference/UI-Platform v30).\n */\nfunction NavAccountMenuPanel({\n userMenu,\n onSignOut,\n placement,\n}: {\n userMenu?: NavUserMenu\n onSignOut?: () => void\n placement: 'below' | 'above'\n}) {\n const rc = useRailCollapse()\n const wrapper =\n placement === 'above'\n ? rc('max-md:right-auto max-md:w-64') + ' absolute bottom-full left-0 right-0 z-40 mb-2 flex max-h-[calc(100vh-5rem)] flex-col overflow-hidden rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 text-[color:var(--foreground)] shadow-[var(--shadow-soft)]'\n : 'absolute right-0 z-30 mt-2 flex max-h-[calc(100vh-5rem)] w-72 flex-col overflow-hidden rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] py-1 shadow-[var(--shadow-soft)]'\n return (\n <div className={wrapper}>\n {placement === 'below' ? <TopBarPanelArrow /> : null}\n <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain\">\n {userMenu?.myProfileHref ? (\n <a\n href={safeHref(userMenu.myProfileHref)}\n className=\"flex w-full items-center gap-2.5 px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n <ProfileIcon />\n My Profile\n </a>\n ) : null}\n {userMenu?.organizationSettingsHref ? (\n <a\n href={safeHref(userMenu.organizationSettingsHref)}\n className=\"flex w-full items-center gap-2.5 border-t border-[color:var(--line)] px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n <BriefcaseIcon />\n Organization Settings\n </a>\n ) : null}\n\n {userMenu?.roles && userMenu.roles.length > 0 ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Roles & Organizations\n </p>\n <ul className=\"flex flex-col gap-1.5\">\n {userMenu.roles.map((r, i) => (\n <li key={`${r.role}-${i}`} className=\"flex flex-wrap items-center gap-1.5 text-sm\">\n <span className=\"rounded-md bg-[color:var(--panel)] px-2 py-0.5 text-xs font-bold uppercase tracking-wide text-[color:var(--foreground)]\">\n {r.role}\n </span>\n {r.orgName ? (\n <span className=\"text-[color:var(--muted)]\">in {r.orgName}</span>\n ) : null}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {userMenu?.accounts && userMenu.accounts.length > 0 ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Accounts\n </p>\n <ul className=\"flex flex-col gap-1\">\n {userMenu.accounts.map((a) => (\n <li key={a.id} className=\"flex items-center gap-2.5\">\n <button\n type=\"button\"\n onClick={() => {\n if (!a.active) userMenu.onSwitchAccount?.(a.id)\n }}\n className=\"flex min-w-0 flex-1 items-center gap-2.5 rounded-lg px-1 py-1 text-left hover:bg-[color:var(--panel)]\"\n >\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[color:var(--color-accent)] text-[11px] font-bold text-[#FFFFFF]\">\n {a.avatarUrl ? (\n <img src={a.avatarUrl} alt=\"\" className=\"h-full w-full object-cover\" />\n ) : (\n (a.name ?? a.email ?? '?').slice(0, 2).toUpperCase()\n )}\n </span>\n <span className=\"flex min-w-0 flex-col leading-tight\">\n <span\n className={[\n 'truncate text-sm font-semibold',\n a.active\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {a.name ?? a.email ?? a.id.slice(0, 8)}\n </span>\n <span className=\"truncate text-xs text-[color:var(--muted)]\">\n {a.active ? 'Active' : a.email ?? ''}\n </span>\n </span>\n </button>\n {!a.active && userMenu.onRemoveAccount ? (\n <button\n type=\"button\"\n aria-label={`Remove ${a.name ?? a.email ?? 'account'}`}\n onClick={() => userMenu.onRemoveAccount?.(a.id)}\n className=\"shrink-0 rounded p-1 text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <TrashIcon />\n </button>\n ) : null}\n </li>\n ))}\n </ul>\n {userMenu.addAccountHref || userMenu.onAddAccount ? (\n userMenu.addAccountHref ? (\n <a\n href={safeHref(userMenu.addAccountHref)}\n className=\"mt-1.5 flex items-center gap-2.5 rounded-lg px-1 py-1.5 text-sm font-semibold text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <AddUserIcon />\n Add Account\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={userMenu.onAddAccount}\n className=\"mt-1.5 flex w-full items-center gap-2.5 rounded-lg px-1 py-1.5 text-left text-sm font-semibold text-[color:var(--color-accent)] hover:bg-[color:var(--panel)]\"\n >\n <AddUserIcon />\n Add Account\n </button>\n )\n ) : null}\n </div>\n ) : null}\n\n {userMenu?.theme ? (\n <div className=\"border-t border-[color:var(--line)]\">\n <NavThemeControl\n value={userMenu.theme.value}\n onChange={userMenu.theme.onChange}\n />\n </div>\n ) : null}\n {userMenu?.navDisplay ? (\n <div className=\"border-t border-[color:var(--line)] px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Navigation display\n </p>\n <div role=\"radiogroup\" aria-label=\"Navigation display\" className=\"flex flex-col gap-0.5\">\n {NAV_DISPLAY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={userMenu.navDisplay?.value === opt.value}\n onClick={() => userMenu.navDisplay?.onChange(opt.value)}\n className={[\n 'flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left text-sm font-medium',\n userMenu.navDisplay?.value === opt.value\n ? 'text-[color:var(--color-accent)]'\n : 'text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n {opt.label}\n {userMenu.navDisplay?.value === opt.value ? <span aria-hidden>✓</span> : null}\n </button>\n ))}\n </div>\n </div>\n ) : null}\n </div>\n\n {onSignOut ? (\n <button\n type=\"button\"\n onClick={onSignOut}\n className=\"flex w-full shrink-0 items-center gap-2.5 border-t border-[color:var(--line)] px-4 py-2.5 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)] hover:text-[color:var(--color-accent)]\"\n >\n <SignOutIcon />\n Sign out\n </button>\n ) : null}\n </div>\n )\n}\n\n/**\n * Left-bar footer user card: 28px avatar · name · email · chevron-up. Opens\n * the account menu upward (Specs/Contacts design rail; UI-Platform v30 →\n * \"The user … lives in the left bar footer\").\n */\nfunction NavSidebarUserCard({\n user,\n userMenu,\n onSignOut,\n}: {\n user: NavUser\n userMenu?: NavUserMenu\n onSignOut?: () => void\n}) {\n const rawName = user.name?.trim() || ''\n const hasRealName = rawName.length > 0 && !rawName.includes('@')\n // Left-Navigation §10: \"First L.\" — first name plus last initial.\n const displayName = hasRealName ? shortUserName(rawName) : (user.email ?? 'Signed in')\n const initials = hasRealName\n ? rawName.split(/\\s+/).filter(Boolean).slice(0, 2).map((w) => w[0]).join('').toUpperCase()\n : (user.email ?? 'P').slice(0, 2).toUpperCase()\n const secondary = hasRealName\n ? user.email || [user.tier, user.role].filter(Boolean).join(' · ') || 'member'\n : [user.tier, user.role].filter(Boolean).join(' · ') || 'member'\n const rc = useRailCollapse()\n return (\n <details data-nav-details className=\"group/acct relative\">\n <summary\n aria-label=\"My Account\"\n className={`flex w-full cursor-pointer list-none items-center gap-[9px] rounded-[5px] px-1 py-1 text-left transition hover:bg-[color:var(--sidebar-row-hover-bg,var(--panel-elevated))] [&::-webkit-details-marker]:hidden ${rc('max-md:justify-center max-md:px-0')}`}\n >\n <span className=\"flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-full bg-[color:var(--sidebar-avatar-bg,var(--color-accent))] text-[11px] font-bold text-[#FFFFFF]\">\n {user.avatarUrl || user.memojiUrl ? (\n <img src={(user.avatarUrl || user.memojiUrl) as string} alt=\"\" className=\"h-full w-full object-cover\" />\n ) : (\n initials\n )}\n </span>\n <span className={`flex min-w-0 flex-1 flex-col ${rc('max-md:hidden')}`}>\n <span className=\"truncate text-[12px] font-semibold leading-[1.2] text-[color:var(--sidebar-text,var(--foreground))]\">\n {displayName}\n </span>\n <span className=\"truncate text-[11px] leading-[1.3] text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))]\">\n {secondary}\n </span>\n </span>\n <ChevronDown size={14} className={`shrink-0 rotate-180 text-[color:var(--sidebar-caption,var(--sidebar-text-muted,var(--muted)))] transition group-open/acct:rotate-0 ${rc('max-md:hidden')}`} />\n </summary>\n <NavAccountMenuPanel userMenu={userMenu} onSignOut={onSignOut} placement=\"above\" />\n {!hasRealName ? <NamePromptBubble profileHref={userMenu?.myProfileHref} placement=\"above\" /> : null}\n </details>\n )\n}\n\n/** `#RRGGBB` (+ optional alpha) → `rgba(r,g,b,a)`; undefined for anything else. */\nfunction hexToRgba(hex: string | null | undefined, alpha: number): string | undefined {\n if (!hex) return undefined\n const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim())\n if (!m) return undefined\n const n = parseInt(m[1], 16)\n return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`\n}\n\n/**\n * Floating, per-session-dismissable bubble under the account trigger that\n * prompts a user with no display name to set their first + last name. The\n * arrow points up at the avatar; dismissal is remembered in sessionStorage\n * until they actually set a name.\n */\nfunction NamePromptBubble({ profileHref, placement = 'below' }: { profileHref?: string; placement?: 'below' | 'above' }) {\n const KEY = 'politogy_name_prompt_dismissed'\n const [dismissed, setDismissed] = useState(true)\n useEffect(() => {\n try {\n setDismissed(sessionStorage.getItem(KEY) === '1')\n } catch {\n setDismissed(false)\n }\n }, [])\n if (dismissed) return null\n return (\n <div\n className={\n placement === 'above'\n ? 'absolute bottom-full left-0 z-30 mb-2 w-64 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-3 text-left shadow-[var(--shadow-soft)]'\n : 'absolute right-4 top-full z-30 mt-2 w-64 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-3 shadow-[var(--shadow-soft)]'\n }\n >\n <span\n aria-hidden\n className={\n placement === 'above'\n ? 'absolute -bottom-[5px] left-[14px] h-2.5 w-2.5 rotate-45 border-b border-r border-[color:var(--line)] bg-[color:var(--panel-elevated)]'\n : 'absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]'\n }\n />\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n Add your name\n </p>\n <p className=\"mt-0.5 text-xs leading-snug text-[color:var(--muted)]\">\n Set your first and last name so teammates see you — not your email.\n </p>\n <div className=\"mt-2 flex items-center gap-2\">\n {profileHref ? (\n <a\n href={safeHref(profileHref)}\n className=\"rounded-full bg-[color:var(--color-accent)] px-3 py-1 text-xs font-semibold text-[#FFFFFF] hover:opacity-90\"\n >\n Set name\n </a>\n ) : null}\n <button\n type=\"button\"\n onClick={() => {\n setDismissed(true)\n try {\n sessionStorage.setItem(KEY, '1')\n } catch {\n /* session-only dismiss */\n }\n }}\n className=\"rounded-full border border-[color:var(--line)] px-3 py-1 text-xs font-semibold text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n Dismiss\n </button>\n </div>\n </div>\n )\n}\n\n/** \"Spencer Hill\" → \"Spencer H.\" — first name + last initial. */\nfunction formatFirstLast(name: string): string {\n const parts = name.split(/\\s+/).filter(Boolean)\n if (parts.length === 1) return parts[0]\n return `${parts[0]} ${parts[parts.length - 1][0].toUpperCase()}.`\n}\n\nfunction ProfileIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\" />\n <circle cx=\"12\" cy=\"7\" r=\"4\" />\n </svg>\n )\n}\n\nfunction BriefcaseIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"14\" rx=\"2\" ry=\"2\" />\n <path d=\"M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16\" />\n </svg>\n )\n}\n\nfunction TrashIcon() {\n return (\n <svg width={14} height={14} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <polyline points=\"3 6 5 6 21 6\" />\n <path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\" />\n </svg>\n )\n}\n\nfunction AddUserIcon() {\n return (\n <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d=\"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2\" />\n <circle cx=\"8.5\" cy=\"7\" r=\"4\" />\n <line x1=\"20\" y1=\"8\" x2=\"20\" y2=\"14\" />\n <line x1=\"23\" y1=\"11\" x2=\"17\" y2=\"11\" />\n </svg>\n )\n}\n\n// Inline log-out glyph (mirrors lucide `LogOut`) to avoid an icon dependency.\nfunction SignOutIcon() {\n return (\n <svg\n width={15}\n height={15}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4\" />\n <polyline points=\"16 17 21 12 16 7\" />\n <line x1=\"21\" x2=\"9\" y1=\"12\" y2=\"12\" />\n </svg>\n )\n}\n\n// A single 32×32 circular icon button for the top bar's structured action list.\n// Renders an <a> when `href` is present (external links open in a new tab),\n// otherwise a <button>. Shows a red count badge when `badge > 0`.\nfunction NavTopBarActionButton({ action }: { action: NavTopBarAction }) {\n const Icon = action.icon\n // Universal treatment (Global Rules v9): size, color and hover are a single\n // shared value across every top-bar slot — only the glyph varies per slot.\n // Tone is a semantic state, not a bespoke per-slot style. The class comes\n // from the ONE shared builder in chromeActions so the data-backed widgets\n // and this structured list can never drift apart.\n const className = topBarIconButtonClass(action.tone ?? 'default')\n\n // Per-slot glyph from Brand; `icon` is the fallback until the token resolves.\n // Brand emits Feather/Lucide glyph NAMES, not asset paths.\n const glyphName = useTopBarIconSlotGlyph(action.slot ?? 'apps')\n const BrandGlyph = action.slot ? resolveBrandGlyph(glyphName) : null\n const Glyph = BrandGlyph ?? Icon\n\n const content = (\n <>\n <Glyph size={TOPBAR_GLYPH_SIZE} className=\"text-current\" />\n {typeof action.badge === 'number' && action.badge > 0 ? (\n <span className=\"absolute -top-[5px] -right-[5px] flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--chrome-danger,var(--color-accent))] px-1 text-[10px] font-bold leading-4 text-[#FFFFFF]\">\n {action.badge}\n </span>\n ) : null}\n <TopBarTooltip title={action.label} description={action.description} />\n </>\n )\n\n const isExternal = action.href ? /^https?:\\/\\//.test(action.href) : false\n\n if (action.href) {\n return (\n <a\n href={safeHref(action.href)}\n aria-label={action.label}\n className={className}\n {...(isExternal ? { target: '_blank', rel: 'noreferrer' } : {})}\n >\n {content}\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={action.onClick}\n aria-label={action.label}\n className={className}\n >\n {content}\n </button>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Page tab strip — THE canonical page tab strip (shell 0.69.0).\n//\n// Brand guideline \"Tabs are an underlined strip\" (components-tabs-geometry):\n// a row of text tabs, each with an optional mono count pill, above a 1px G3\n// rule, with no folder or card chrome. Tabs are 13px semibold with 12px\n// vertical padding (12px / 8px when small). The selected tab is Graphite with\n// a 2px underline in the MODE COLOR (`modes.<mode>.primary`), read as\n// `--mode-accent` — never `modes.<mode>.accent`, which is white and only for\n// highlights on the dark rail. Unselected tabs are G4 and turn Graphite on\n// hover.\n//\n// It sits in the page body, below the page header, aligned to the content\n// gutter (Brand guideline \"UX Navigation\"). Apps render it inside the frame's\n// `children`; they never hand-roll or restyle a tab strip.\n//\n// Why this one and not the main entry's `HeaderTabBar` (now @deprecated): it\n// has no Chakra or react-router dependency, so every app can import it\n// whatever its framework; it renders `href` tabs through the app's own link\n// primitive, so sub-views are URL-addressable; and it already carries the\n// tablist / tab / disabled semantics. `HeaderTabBar` is icon-only by\n// construction (its label is only a tooltip) and state-only (no links).\n//\n// Colors come from the Brand `--tab-*` / `--color-*` vars emitted by\n// `/api/tokens?format=css`, with literal fallbacks so the strip still renders\n// before the runtime token sheet loads.\n// ---------------------------------------------------------------------------\n\nexport type NavTab = {\n /** Stable identity (used as the React key). */\n key: string\n /** The tab's visible text. */\n label: string\n /**\n * A Lucide icon rendered 6px left of the label (Reference/UI-Platform →\n * Tabs, decided 2026-10-06: \"Icon + label. Each tab is a Lucide icon.\"),\n * 15px / 1.75 stroke (13px on a small strip), following the label's\n * selected / unselected / hover color via `currentColor`. Icon-ONLY tabs\n * (no label) are retired — this always pairs with `label`.\n */\n icon?: NavIcon\n /** Optional count, drawn as a mono pill after the label. */\n count?: string | number | null\n /** Route to link to (rendered through `linkComponent`). */\n href?: string\n /** Click handler — rendered as a `<button>` when there's no `href`. */\n onSelect?: () => void\n /** Whether this tab is the active one (drives the mode-color underline). */\n selected?: boolean\n /**\n * Non-interactive, dimmed tab (e.g. Surveys' Canvas/Results before a survey\n * is chosen). Renders a non-navigating span; `disabledTitle` is the tooltip\n * explaining why.\n */\n disabled?: boolean\n disabledTitle?: string\n}\n\nexport type NavTabStripProps = {\n tabs: NavTab[]\n /** Accessible name for the tablist. */\n 'aria-label'?: string\n /** Routing primitive for `href` tabs (Next `<Link>`, etc). Defaults to <a>. */\n linkComponent?: NavLinkComponent\n /** `'sm'`: 12px text with 8px vertical padding. Default `'md'` (13px / 12px). */\n size?: 'md' | 'sm'\n /** Extra classes on the tablist container. */\n className?: string\n /**\n * Optional tab panel rendered directly below the strip, on the page\n * surface with no card chrome. Omit to render only the strip and compose\n * the page body yourself.\n */\n children?: ReactNode\n}\n\n/** The mode color on light surfaces (Reference/UI-Platform → Per-mode branding). */\nconst TAB_UNDERLINE_COLOR = 'var(--mode-accent, var(--color-accent))'\n\nfunction NavTabButton({\n tab,\n Link,\n size,\n}: {\n tab: NavTab\n Link: NavLinkComponent\n size: 'md' | 'sm'\n}) {\n const { label, icon: Icon, count, href, onSelect, selected, disabled, disabledTitle } = tab\n\n // The 2px underline sits on the strip's 1px rule (`-mb-px`), so the selected\n // tab's underline replaces the rule beneath it rather than stacking on it.\n const base =\n '-mb-px inline-flex shrink-0 items-center gap-2 border-b-2 font-semibold leading-none transition-colors'\n const sizeClass = size === 'sm' ? 'py-2 text-[12px]' : 'py-3 text-[13px]'\n const stateClass = disabled\n ? 'cursor-not-allowed border-transparent text-[color:var(--color-g4,#929599)] opacity-50'\n : selected\n ? 'text-[color:var(--tab-selected-color,#2F3136)]'\n : 'border-transparent text-[color:var(--color-g4,#929599)] hover:text-[color:var(--tab-hover-color,#2F3136)]'\n const className = `${base} ${sizeClass} ${stateClass}`\n const style: CSSProperties | undefined =\n selected && !disabled ? { borderBottomColor: TAB_UNDERLINE_COLOR } : undefined\n\n const iconSize = size === 'sm' ? 13 : 15\n const content = (\n <>\n {Icon ? (\n <Icon size={iconSize} className=\"shrink-0 text-current\" strokeWidth={1.75} />\n ) : null}\n <span>{label}</span>\n {count !== undefined && count !== null && count !== '' ? (\n <span className=\"rounded-full bg-[color:var(--color-g2,#ECEEEF)] px-1.5 py-0.5 font-[family-name:var(--font-mono,ui-monospace,monospace)] text-[11px] font-semibold leading-none\">\n {count}\n </span>\n ) : null}\n </>\n )\n\n // Disabled: non-navigating span, still exposed as a tab for AT.\n if (disabled) {\n return (\n <span\n role=\"tab\"\n aria-selected={false}\n aria-disabled=\"true\"\n aria-label={label}\n title={disabledTitle}\n className={className}\n style={style}\n >\n {content}\n </span>\n )\n }\n\n if (href) {\n return (\n <Link\n href={href}\n role=\"tab\"\n aria-selected={selected ? true : false}\n aria-label={label}\n className={className}\n style={style}\n >\n {content}\n </Link>\n )\n }\n\n return (\n <button\n type=\"button\"\n role=\"tab\"\n aria-selected={selected ? true : false}\n aria-label={label}\n onClick={onSelect}\n className={className}\n style={style}\n >\n {content}\n </button>\n )\n}\n\n/**\n * The canonical page tab strip: underlined text tabs on a 1px rule. Render it\n * in the page body below the page header; pass the app's `Link` as\n * `linkComponent` for `href` tabs.\n */\nexport function NavTabStrip({\n tabs,\n 'aria-label': ariaLabel,\n linkComponent,\n size = 'md',\n className,\n children,\n}: NavTabStripProps) {\n const Link = linkComponent ?? DefaultLink\n return (\n <>\n <div\n role=\"tablist\"\n aria-label={ariaLabel}\n className={[\n 'flex items-end gap-[var(--tab-gap,24px)] border-b border-[color:var(--tab-border-color,#D7DADF)]',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tabs.map((tab) => (\n <NavTabButton key={tab.key} tab={tab} Link={Link} size={size} />\n ))}\n </div>\n {children !== undefined ? <div className=\"pt-5\">{children}</div> : null}\n </>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Beta banner — a full-width amber NOTICE strip rendered directly below the top\n// bar (a semantic notice, not a chrome surface, so it keeps its amber hue in\n// both themes via the --beta-banner-* tokens in chrome.css). One line, centered,\n// with a bold + underlined link to the Beta Terms & Conditions.\n// ---------------------------------------------------------------------------\n\nconst BETA_BANNER_DEFAULTS = {\n text: 'Our product is in Beta. Thank you for participating in the Pilot Program. ',\n linkLabel: 'You can click here to see the Terms & Conditions for Beta users.',\n href: 'https://app.politogyvrm.com/beta-terms-and-conditions',\n} as const\n\n/**\n * sessionStorage key holding the Beta-banner dismissal. sessionStorage — not\n * localStorage — so the dismissal lasts only for the browser session; and it is\n * additionally cleared on sign-out (see `clearBetaBannerDismissal`, called from\n * the chrome frame) so a fresh LOGIN always re-shows the notice.\n */\nexport const BETA_BANNER_DISMISS_KEY = 'politogy_beta_banner_dismissed'\n\n/**\n * Re-arm the Beta banner. The chrome frame calls this on sign-out so the notice\n * reappears at the next login rather than staying hidden across the boundary\n * (sessionStorage survives an in-tab logout→login round trip on its own).\n */\nexport function clearBetaBannerDismissal(): void {\n if (typeof window === 'undefined') return\n try {\n window.sessionStorage.removeItem(BETA_BANNER_DISMISS_KEY)\n } catch {\n /* storage unavailable (private mode / disabled) — nothing to clear */\n }\n}\n\nexport type NavBetaBannerProps = {\n /** Leading sentence(s) before the link. Defaults to the standard Beta copy. */\n text?: string\n /** Bold + underlined link label. Defaults to the standard Terms copy. */\n linkLabel?: string\n /** Terms & Conditions URL (opens in a new tab). Defaults to the app T&C page. */\n href?: string\n /**\n * Show a dismiss (×) button that hides the banner for the rest of the browser\n * session. Cleared on sign-out, so it returns at the next login. Default true.\n */\n dismissible?: boolean\n}\n\nexport function NavBetaBanner({ text, linkLabel, href, dismissible = true }: NavBetaBannerProps) {\n const body = text ?? BETA_BANNER_DEFAULTS.text\n const label = linkLabel ?? BETA_BANNER_DEFAULTS.linkLabel\n const target = href ?? BETA_BANNER_DEFAULTS.href\n\n // Start visible on both server and first client render (sessionStorage is not\n // readable during SSR), then hide in an effect if this session already\n // dismissed it — this keeps hydration markup identical and avoids a mismatch.\n const [dismissed, setDismissed] = useState(false)\n useEffect(() => {\n if (!dismissible) return\n try {\n if (window.sessionStorage.getItem(BETA_BANNER_DISMISS_KEY) === '1') setDismissed(true)\n } catch {\n /* storage unavailable — leave the banner visible */\n }\n }, [dismissible])\n\n if (dismissible && dismissed) return null\n\n const onDismiss = () => {\n setDismissed(true)\n try {\n window.sessionStorage.setItem(BETA_BANNER_DISMISS_KEY, '1')\n } catch {\n /* storage unavailable — banner still hides for this render */\n }\n }\n\n return (\n <div\n role=\"note\"\n className=\"relative w-full px-10 py-2 text-center text-sm\"\n style={{\n // Amber warning fill, matching the \"10DLC Registration Required\" notice\n // (HITL 2026-07-29). This used to fall through to `--color-accent`, the\n // brand RED, so a participation notice read as an error. The\n // --beta-banner-* tokens carry the amber defaults (chrome.css) and a\n // Brand edit still wins over them.\n background: 'var(--beta-banner-bg, #FEEBC8)',\n color: 'var(--beta-banner-text, #1A202C)',\n }}\n >\n <span>{body}</span>\n <a\n href={safeHref(target)}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"font-bold underline\"\n style={{ color: 'var(--beta-banner-text, #1A202C)' }}\n >\n {label}\n </a>\n {dismissible ? (\n <button\n type=\"button\"\n onClick={onDismiss}\n aria-label=\"Dismiss this notice\"\n title=\"Dismiss\"\n className=\"absolute right-2 top-1/2 -translate-y-1/2 flex h-6 w-6 items-center justify-center rounded text-base leading-none opacity-70 hover:opacity-100\"\n style={{ color: 'var(--beta-banner-text, #1A202C)' }}\n >\n ×\n </button>\n ) : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n\nexport type NavAppShellProps = {\n sidebar: NavSidebarProps\n topBar: NavTopBarProps\n /**\n * When supplied, a full-width Beta notice strip renders directly below the top\n * bar. Presence of the prop enables it; all fields fall back to the standard\n * Beta copy + Terms & Conditions link.\n */\n betaBanner?: NavBetaBannerProps\n /**\n * @deprecated The frame's content area is one fluid `<main>` (Brand\n * guideline \"Content width is fluid\"): the 24px gutter (16px below `md`),\n * no max-width and no centered container. Apps never emit their own page\n * container, so there is nothing left to choose here.\n *\n * `'bare'` is still honored — it renders `children` with no `<main>` and no\n * gutter — only so VRM core, which renders `NavAppShell` directly around\n * pages that still carry their own `PageContainer`, does not get a nested\n * `<main>` before it migrates. It warns in development and will be removed.\n * `'padded'` is now the same as omitting the prop.\n */\n contentWrapper?: 'padded' | 'bare'\n /**\n * The operating Mode this frame is scoped to, stamped on the root as\n * `data-politogy-mode` so the Brand API's per-Mode chrome tokens can target\n * it (Reference/UI-Platform → \"Per-mode branding — one accent per Mode\").\n *\n * This is app IDENTITY, not app configuration: `PolitogyAppFrame` passes it\n * from the `POLITOGY_APPS` registry, never from a prop an app supplies, so an\n * app still cannot choose its own chrome colour.\n *\n * Omitted (or a Mode that declares no chrome group in the Brand API) => every\n * accent falls back to the global one, exactly as before 0.47.\n */\n modeId?: string\n /**\n * Where the user card / account menu renders. `'sidebar'` (default since\n * 0.68.0) draws it in the left-bar footer and hides the top-bar trigger\n * (Reference/UI-Platform v30); `'topbar'` restores the 0.67 top-right badge.\n */\n accountMenuPlacement?: 'sidebar' | 'topbar'\n children: ReactNode\n}\n\n/**\n * Full chrome: branded left sidebar + sticky top navbar + scrollable content\n * region. Presentational only — wrap it in app-level auth/gating as needed.\n */\n/**\n * Closes any open chrome <details data-nav-details> (org switcher, mode\n * selector, My Account) when the pointer lands outside it or Escape is\n * pressed — dropdowns must deselect on outside click (HITL 2026-07-23).\n */\nfunction useCloseNavDetailsOnOutsideClick() {\n useEffect(() => {\n const close = (target: Node | null) => {\n document.querySelectorAll('details[data-nav-details][open]').forEach((d) => {\n if (!target || !d.contains(target)) d.removeAttribute('open')\n })\n }\n const onPointerDown = (e: MouseEvent) => close(e.target as Node)\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') close(null)\n }\n document.addEventListener('mousedown', onPointerDown)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onPointerDown)\n document.removeEventListener('keydown', onKey)\n }\n }, [])\n}\n\nexport function NavAppShell({\n sidebar,\n topBar,\n betaBanner,\n contentWrapper = 'padded',\n accountMenuPlacement = 'sidebar',\n modeId,\n children,\n}: NavAppShellProps) {\n useCloseNavDetailsOnOutsideClick()\n if (contentWrapper === 'bare') {\n warnDeprecated(\n 'contentWrapper',\n \"`contentWrapper: 'bare'` is deprecated: the frame's <main> is fluid and apps must not emit their own page container. Remove the app's PageContainer and drop the prop.\",\n )\n }\n // Below `md` the rail is the 64px icon rail (see NavSidebar). The shell owns\n // the expanded-drawer state so the hamburger (NavTopBar) and the drawer\n // (NavSidebar) can stay presentational.\n const [navOpen, setNavOpen] = useState(false)\n const expandRail = () => {\n writeRailPreference('expanded')\n setNavOpen(true)\n }\n const collapseRail = () => {\n writeRailPreference('collapsed')\n setNavOpen(false)\n }\n // Route navigation closes the drawer — a stale open drawer over a new page\n // reads as broken, not as \"still browsing\".\n useEffect(() => {\n setNavOpen(false)\n }, [sidebar.pathname])\n // Left-Navigation §11.6: the expand choice is remembered per user. Read it\n // back after mount (no hydration mismatch); it only applies below `md`,\n // where the rail is collapsed. Explicit Expand / Collapse writes it.\n useEffect(() => {\n if (readRailPreference() !== 'expanded') return\n const narrow =\n typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia('(max-width: 767.98px)').matches\n : false\n if (narrow) setNavOpen(true)\n }, [])\n // The page behind a mobile drawer must not scroll while it's open.\n useEffect(() => {\n if (!navOpen) return\n const previous = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n return () => {\n document.body.style.overflow = previous\n }\n }, [navOpen])\n // The user card lives in the left-bar footer (UI-Platform v30). Lift the\n // top bar's user / menu / sign-out into the sidebar footer unless the app\n // already supplied them there or opted back into the top-bar badge.\n const sidebarFooter: NavFooter | null | undefined =\n accountMenuPlacement === 'sidebar' && topBar.user\n ? {\n ...(sidebar.footer ?? {}),\n user: sidebar.footer?.user ?? topBar.user,\n userMenu: sidebar.footer?.userMenu ?? topBar.userMenu,\n onSignOut: sidebar.footer?.onSignOut ?? topBar.onSignOut,\n }\n : sidebar.footer\n return (\n <div\n data-politogy-mode={modeId ?? modeIdFromLabel(sidebar.mode?.label)}\n className=\"min-h-screen bg-[color:var(--background)] text-[color:var(--foreground)]\"\n >\n {/* Cross-app sidebar nav speculation: every consumer rendering\n NavAppShell gets this for free (no per-app opt-in) — see\n src/speculation/SpeculationRulesScript.tsx. */}\n <SpeculationRulesScript items={sidebar.nav.items} />\n <NavSidebar\n {...sidebar}\n footer={sidebarFooter}\n open={navOpen}\n onClose={collapseRail}\n onOpen={expandRail}\n onNavigate={() => setNavOpen(false)}\n />\n {/* The rail is never hidden, so content is always offset by it: 64px\n below `md`, the full rail from `md` up. */}\n <div className=\"pl-[var(--sidebar-collapsed-width,64px)] md:pl-[var(--sidebar-width,236px)]\">\n <NavTopBar\n {...topBar}\n accountMenu={topBar.accountMenu ?? (accountMenuPlacement === 'sidebar' ? 'sidebar' : 'topbar')}\n />\n {betaBanner ? <NavBetaBanner {...betaBanner} /> : null}\n {/* Reference/UI-Platform \"Page header\": the title lives in the page\n body now, 22px below the top bar, not in the bar itself and never\n as a breadcrumb trail. Rendered here — above both wrapper modes —\n so a 'bare' app (which owns its own content furniture) still gets\n the required chrome-owned title line. */}\n {topBar.title ? (\n <h1 className=\"px-4 pt-7 text-xl font-semibold text-[color:var(--foreground)] md:px-6\">\n {topBar.title}\n </h1>\n ) : null}\n {contentWrapper === 'bare' ? (\n <div data-shell-content=\"\" className={topBar.title ? 'mt-[22px]' : undefined}>\n {children}\n </div>\n ) : (\n // Brand guidelines \"Content width is fluid\" + \"Content body\n // padding\": `<main>` fills the space beside the rail with ONE\n // gutter — 24px, or 16px below `md`, horizontally and vertically —\n // and has no max-width and no centered container. Form and settings\n // pages constrain themselves with <FormColumn> (960px, left-aligned).\n // The shell owns the page background and the gutter; an app's own\n // cards are its own furniture and stay app-owned.\n <main\n data-shell-content=\"\"\n className={`min-h-[calc(100vh-63px)] bg-[color:var(--chrome-page-bg,#F4F5F7)] px-4 pb-4 md:px-6 md:pb-6 ${topBar.title ? 'pt-[22px]' : 'pt-4 md:pt-6'}`}\n >\n {children}\n </main>\n )}\n </div>\n </div>\n )\n}\n\n// The one constrained layout inside the fluid <main>: a 960px left-aligned\n// column for form and settings pages. Re-exported here (as well as from the\n// main entry) so an app needs no Chakra / react-router peer to use it.\nexport { default as FormColumn } from '../components/FormColumn'\n\n// Canonical Politogy VRM menu — the standard nav structure every politogy app\n// renders, per operating Mode, with hooks for the app-owned \"Contacts\" item and\n// Support handler, plus the Campaign feature-availability config.\nexport {\n standardPolitogyNav,\n CAMPAIGN_FEATURE_AVAILABILITY,\n type StandardNavIconKey,\n type StandardNavOptions,\n type StandardNavMode,\n type CampaignFeatureAvailability,\n} from './standardNav'\n"]}
|