"use client"; import Link from "next/link"; import { useEffect, useMemo, useState } from "react"; import { usePathname } from "next/navigation"; import { CYBERLUX_ENTRY_COOKIE, parseCyberluxEntry, type CyberluxEntry, } from "@/lib/cyberluxEntry"; import { formatRingLabel } from "@/lib/forumRings"; import { useAccount } from "@/contexts/AccountContext"; import { getChatterSlice } from "@/lib/shopChatterThreads"; function readEntry(): CyberluxEntry { if (typeof document === "undefined") return "hub"; const raw = `; ${document.cookie}`; const part = raw.split(`; ${CYBERLUX_ENTRY_COOKIE}=`); if (part.length !== 2) return "hub"; const v = part.pop()?.split(";").shift(); return parseCyberluxEntry(v); } type HubSkin = { bar: string; accent: string }; const DEFAULT_HUB_SKIN: HubSkin = { bar: "border-zinc-700/40 bg-[#050608]/98 text-zinc-500", accent: "text-zinc-400", }; const SKINS: Partial> = { hub: { bar: "border-cyan-500/25 bg-[#050608]/95 text-zinc-400", accent: "text-cyan-400/90", }, forum: { bar: "border-[#5c4030] bg-[#090705]/98 text-[#b8a995]", accent: "text-[#ff9a3c]", }, exchange: { bar: "border-[#4a3f36]/90 bg-[#0b0907]/98 text-[#a89888]", accent: "text-[#d4a574]", }, wiki: { bar: "border-[#334155] bg-[#080c15]/98 text-[#94a3b8]", accent: "text-[#7dd3fc]", }, market: { bar: "border-emerald-900/45 bg-[#030806]/98 text-[#9db0a4]", accent: "text-[#6ee7b7]", }, barter: { bar: "border-rose-900/40 bg-[#0a0606]/98 text-[#c8a8a8]", accent: "text-[#fb7185]", }, chatter: { bar: "border-violet-900/45 bg-[#070510]/98 text-[#a898c4]", accent: "text-[#c4b5fd]", }, search: { bar: "border-slate-600/45 bg-[#050608]/98 text-[#94a3b8]", accent: "text-[#93c5fd]", }, syndicate: { bar: "border-yellow-900/35 bg-[#0b0905]/98 text-[#b8a878]", accent: "text-[#facc15]", }, w: { bar: "border-fuchsia-900/35 bg-[#08060a]/98 text-[#c4a8d4]", accent: "text-[#e879f9]", }, }; function hubSkinFor(entry: CyberluxEntry): HubSkin { return SKINS[entry] ?? DEFAULT_HUB_SKIN; } const PREVIEW_N = 3; /** * Fixed strip above the disclosure bar: in-world “hub chatter” threads (forum links). * Hidden on `/chatter` where the full archive already fills the view. */ export default function HubChatterPublicStrip() { const pathname = usePathname(); const { user, hydrated } = useAccount(); const [entry, setEntry] = useState("hub"); const threads = useMemo(() => getChatterSlice(1, PREVIEW_N).items, []); useEffect(() => { setEntry(readEntry()); }, []); if (pathname?.startsWith("/chatter")) return null; const skin = hubSkinFor(entry); return ( ); }