{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "knowledge-source-map",
  "title": "Knowledge Source Map",
  "description": "An interactive context map linking documents, web pages and databases to an answer, with source search, selection and excerpts.",
  "dependencies": [
    "motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/knowledge-source-map/knowledge-source-map.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\nimport { ArrowUpRight, FileText, Globe, Search, Database, Check, Network } from \"lucide-react\";\n\nexport interface KnowledgeSource { id: string; title: string; kind: \"document\" | \"web\" | \"database\"; excerpt: string; href?: string; updated?: string }\nexport interface KnowledgeSourceMapProps {\n  sources?: KnowledgeSource[];\n  answerTitle?: string;\n  onSourceSelect?: (source: KnowledgeSource) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\nconst seed: KnowledgeSource[] = [\n  { id: \"brief\", title: \"Project brief\", kind: \"document\", excerpt: \"The workspace redesign should simplify the path from a question to a clear next step.\", updated: \"Updated today\" },\n  { id: \"research\", title: \"Customer research\", kind: \"database\", excerpt: \"Teams asked for a single place to review decisions, sources and follow-up work.\", updated: \"Updated yesterday\" },\n  { id: \"guidelines\", title: \"Design principles\", kind: \"web\", excerpt: \"Use a clear visual hierarchy, progressive disclosure and meaningful feedback.\", href: \"https://www.w3.org/WAI/tips/designing/\", updated: \"Reference page\" },\n];\nconst SHEEN = \"linear-gradient(115deg,rgba(255,255,255,.08),rgba(255,255,255,.02) 30%,transparent 48%,rgba(255,255,255,.04) 74%,transparent),linear-gradient(180deg,rgba(255,255,255,.05),transparent 60%)\";\nfunction Island({ children, theme, active = false, warm = false, className }: { children: React.ReactNode; theme: \"dark\" | \"light\"; active?: boolean; warm?: boolean; className?: string }) {\n  const reduce = useReducedMotion();\n  return <motion.div layout={!reduce} transition={{ type: \"spring\", stiffness: 260, damping: 30 }} className={twMerge(clsx(\"relative isolate w-full rounded-[32px] border font-sans antialiased [font-family:Inter,ui-sans-serif,system-ui,sans-serif]\", theme === \"dark\" ? \"border-white/[0.09] bg-[#0E0E10] text-[#EDEDED]\" : \"border-black/[0.09] bg-[#f7f7f8] text-[#202023]\", className))} style={{ backgroundImage: SHEEN, boxShadow: theme === \"dark\" ? \"inset 0 1px 0 #ffffff1f,0 16px 48px #00000025\" : \"inset 0 1px 0 #ffffff,0 16px 48px #00000008\" }}>\n    <motion.div aria-hidden=\"true\" className=\"pointer-events-none absolute -inset-px rounded-[inherit]\" animate={{ opacity: active && !reduce ? [0.35, 0.8, 0.35] : active ? 0.5 : 0.18 }} transition={{ duration: 3, repeat: active && !reduce ? Infinity : 0 }} style={{ padding: 1, background: warm ? \"conic-gradient(from 40deg,transparent 10%,#FF7BD5 32%,#FFB86B 45%,transparent 65%)\" : \"conic-gradient(from 40deg,transparent 10%,#7CF3FF 32%,#6EA8FF 45%,#9B7BFF 55%,transparent 75%)\", mask: \"linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0)\", maskComposite: \"exclude\", WebkitMaskComposite: \"xor\" }} />\n    {children}\n  </motion.div>;\n}\nfunction Orb({ active = false, warm = false, size = 40 }: { active?: boolean; warm?: boolean; size?: number }) {\n  const reduce = useReducedMotion();\n  return <span aria-hidden=\"true\" className=\"relative inline-flex shrink-0 items-center justify-center\" style={{ width: size, height: size }}>\n    <motion.span className=\"absolute inset-0 rounded-full blur-md\" style={{ background: warm ? \"radial-gradient(circle,#ffb86b55,transparent 70%)\" : \"radial-gradient(circle,#9b7bff55,transparent 70%)\" }} animate={{ opacity: active && !reduce ? [0.3, 0.9, 0.3] : 0.3 }} transition={{ duration: 2.5, repeat: active && !reduce ? Infinity : 0 }} />\n    <motion.svg viewBox=\"0 0 40 40\" className=\"relative size-full\" animate={active && !reduce ? { rotate: [0, 12, 0] } : { rotate: 0 }} transition={{ duration: 5, repeat: active && !reduce ? Infinity : 0 }}>{Array.from({ length: 81 }, (_, i) => { const x = i % 9 - 4; const y = Math.floor(i / 9) - 4; const d = Math.hypot(x, y); return d <= 4.1 ? <circle key={i} cx={20 + x * 3.9} cy={20 + y * 3.9} r={Number((1 - d * .13).toFixed(3))} fill=\"currentColor\" opacity={Number((.95 - d * .16).toFixed(3))} /> : null; })}</motion.svg>\n  </span>;\n}\nconst action = \"inline-flex min-h-10 shrink-0 items-center justify-center gap-2 rounded-full border border-current/[0.12] px-4 text-[11px] transition-colors hover:bg-current/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#9B7BFF] disabled:cursor-not-allowed disabled:opacity-35 motion-reduce:transition-none [&_svg]:shrink-0\";\n\n\nexport function KnowledgeSourceMap({ sources = seed, answerTitle = \"Your workspace, connected.\", onSourceSelect, theme = \"dark\", className }: KnowledgeSourceMapProps) {\n  const [selectedId, setSelectedId] = React.useState<string | null>(null);\n  const [query, setQuery] = React.useState(\"\");\n  const id = React.useId();\n  const selected = sources.find(s => s.id === selectedId) ?? sources[0];\n  const visible = sources.filter(s => `${s.title} ${s.kind} ${s.excerpt}`.toLowerCase().includes(query.toLowerCase()));\n  const graphHeight = Math.max(232, visible.length * 68);\n  const safeHref = selected?.href && /^(https?:\\/\\/|\\/(?!\\/))/.test(selected.href) ? selected.href : undefined;\n  return <div className={twMerge(\"mx-auto w-full max-w-[660px]\", className)}><Island theme={theme} className=\"overflow-hidden\">\n    <header className=\"flex items-center gap-3 px-5 pb-5 pt-6 sm:px-6\"><Orb size={44} /><div className=\"min-w-0 flex-1\"><h3 className=\"text-[15px] font-medium tracking-[-0.025em]\">Every answer has a starting point.</h3><p className=\"mt-1 text-[11px] opacity-45\">Explore the context behind the conversation.</p></div><Network size={20} className=\"hidden shrink-0 opacity-30 sm:block\" /></header>\n    <div className=\"px-5 sm:px-6\"><label htmlFor={id} className=\"sr-only\">Find a knowledge source</label><div className=\"flex items-center gap-2 rounded-2xl border border-current/[0.09] bg-current/[0.02] px-3 focus-within:border-[#9B7BFF]/50\"><Search size={17} className=\"opacity-35\" /><input id={id} value={query} onChange={e => setQuery(e.target.value)} placeholder=\"Find a source…\" className=\"min-h-10 min-w-0 flex-1 bg-transparent text-xs outline-none\" /><span className=\"shrink-0 text-[10px] opacity-35\">{visible.length} sources</span></div></div>\n    <div className=\"mx-5 mt-5 max-h-[420px] overflow-y-auto rounded-2xl border border-current/[0.07] bg-current/[0.02] sm:mx-6\">\n      {visible.length ? <div className=\"relative p-3 sm:p-4\" style={{ minHeight: graphHeight }}>\n        <svg aria-hidden=\"true\" viewBox={`0 0 1000 ${graphHeight}`} preserveAspectRatio=\"none\" className=\"pointer-events-none absolute inset-0 hidden size-full sm:block\">{visible.map((s, i) => { const y = (i + .5) * graphHeight / visible.length; return <path key={s.id} d={`M390 ${y} C500 ${y},500 ${graphHeight / 2},610 ${graphHeight / 2}`} fill=\"none\" stroke={selected?.id === s.id ? \"#b5a1ff\" : \"currentColor\"} strokeWidth={selected?.id === s.id ? 1.8 : 1} opacity={selected?.id === s.id ? .7 : .12} />; })}</svg>\n        <div className=\"relative flex flex-col gap-5 sm:flex-row sm:items-center sm:justify-between\">\n          <ul aria-label=\"Knowledge sources\" className=\"flex w-full flex-col gap-2 sm:w-[39%]\" style={{ minHeight: graphHeight - 32, justifyContent: \"space-around\" }}>{visible.map(s => { const Icon = s.kind === \"web\" ? Globe : s.kind === \"database\" ? Database : FileText; return <li key={s.id}><button type=\"button\" aria-pressed={selected?.id === s.id} onClick={() => { setSelectedId(s.id); onSourceSelect?.(s); }} className={clsx(\"flex min-h-12 w-full items-center gap-2.5 rounded-xl border p-3 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[#9B7BFF]\", selected?.id === s.id ? \"border-[#9B7BFF]/40 bg-[#9B7BFF]/[0.08]\" : \"border-current/10 bg-current/[0.025] hover:bg-current/[0.06]\")}><Icon size={18} className=\"shrink-0 opacity-55\" /><span className=\"min-w-0 flex-1 truncate text-[11px]\">{s.title}</span>{selected?.id === s.id && <Check size={15} className=\"shrink-0 text-[#b5a1ff]\" />}</button></li>; })}</ul>\n          <div className=\"flex w-full flex-col items-center justify-center rounded-2xl border border-current/10 bg-current/[0.025] p-4 text-center sm:w-[39%]\"><Orb size={48} active /><span className=\"mt-2 text-[9px] uppercase tracking-wider opacity-35\">Connected context</span><p className=\"mt-2 break-words text-[13px] leading-5\">{answerTitle}</p><span className=\"mt-3 rounded-full border border-current/10 px-2.5 py-1 text-[9px] opacity-40\">{sources.length} linked sources</span></div>\n        </div>\n      </div> : <p className=\"py-14 text-center text-xs opacity-40\">{sources.length ? \"No sources match your search.\" : \"Add a source to connect your context.\"}</p>}\n    </div>\n    {selected && <section aria-label=\"Selected source details\" className=\"m-5 rounded-2xl border border-current/[0.08] p-4 sm:m-6\"><div className=\"flex items-center justify-between gap-3\"><h4 className=\"text-[12px] font-medium\">{selected.title}</h4><span className=\"text-[9px] opacity-35\">{selected.updated ?? selected.kind}</span></div><p className=\"mt-3 break-words text-[12px] leading-6 opacity-55\">{selected.excerpt}</p>{safeHref && <a href={safeHref} target=\"_blank\" rel=\"noopener noreferrer\" className={action + \" mt-4\"}>Open source<ArrowUpRight size={17} /></a>}</section>}\n    <footer className=\"flex items-center justify-between gap-3 border-t border-current/[0.07] px-5 py-4 text-[10px] opacity-35 sm:px-6\"><span>Sources supplied by your application</span><span className=\"shrink-0\">Traceable context</span></footer>\n  </Island></div>;\n}\nexport default KnowledgeSourceMap;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}