"use client"; import Link from "next/link"; import { useRef, useState, useSyncExternalStore, type FormEvent } from "react"; import { ArrowUpRight, BookOpen, Film, MessageCircle, PenLine, Play, Send, Users, } from "lucide-react"; import SiteShell from "./SiteShell"; import { BookmarkButton, DemoBadge, EmptyState, PageIntro, SearchField, ResultSummary, ShareButton, SocialDialog, } from "./SocialUI"; import { useSocialConfig } from "./SocialExperience"; import { SEED_EBOOKS, SEED_VIDEOS } from "@social/lib/seed"; import { useLocalState } from "@social/lib/useLocalState"; import { socialPath } from "@social/lib/socialPath"; import { socialApi } from "@social/lib/api"; import { socialTx } from "@social/lib/socialTx"; type Kind = "videos" | "date" | "ebook"; const COPY = { videos: { title: "共创 · 视频", accent: "大家拍的" }, date: { title: "共创 · 访谈", accent: "听听大家" }, ebook: { title: "共创 · 小册", accent: "大家写的" }, }; function subscribeSelection(callback: () => void) { window.addEventListener("hashchange", callback); window.addEventListener("popstate", callback); return () => { window.removeEventListener("hashchange", callback); window.removeEventListener("popstate", callback); }; } const readSelection = () => location.hash.slice(1); const emptySelection = () => ""; function setSelection(id: string | null) { const url = new URL(location.href); url.hash = id || ""; history.replaceState(history.state, "", url); window.dispatchEvent(new Event("hashchange")); } function safeSource(value?: string) { if (!value) return undefined; try { const url = new URL(value, "https://nomadro.cn"); return url.protocol === "https:" || url.protocol === "http:" ? value : undefined; } catch { return undefined; } } function ResourcePlayer({ source }: { source: string }) { const [failed, setFailed] = useState(false); return ( <>