{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popover-hover-profile",
  "type": "registry:component",
  "title": "Hover Profile Card",
  "description": "An @mention that shows a profile card on hover, with an underline that fills while the open delay runs and a grace period so the pointer can travel into the card. Includes a contribution grid, a follow toggle with a live count and keyboard access on focus.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "hover-card",
    "popover",
    "mention",
    "profile",
    "follow",
    "intent"
  ],
  "docs": "https://hyperblur.dev/effects/popover-hover-profile",
  "files": [
    {
      "path": "registry/hyperblur/popover-hover-profile.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/popover-hover-profile.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PopoverHoverProfileUser {\n  handle: string;\n  name: string;\n  role: string;\n  location: string;\n  localTime: string;\n  bio: string;\n  repos: number;\n  followers: number;\n  following: number;\n  online?: boolean;\n}\n\nexport interface PopoverHoverProfileProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n  user?: PopoverHoverProfileUser;\n  children?: React.ReactNode;\n  openDelay?: number;\n  closeDelay?: number;\n  side?: \"bottom\" | \"top\";\n  defaultFollowing?: boolean;\n  onFollowChange?: (following: boolean) => void;\n  onMessage?: () => void;\n  embedded?: boolean;\n  accent?: string;\n}\n\nconst defaultUser: PopoverHoverProfileUser = {\n  handle: \"mara.lin\",\n  name: \"Mara Lindqvist\",\n  role: \"Staff engineer, Payments\",\n  location: \"Stockholm\",\n  localTime: \"16:42\",\n  bio: \"Making refunds boring. Previously ledger infra at Klarna. Writes about idempotency.\",\n  repos: 48,\n  followers: 2148,\n  following: 180,\n  online: true,\n};\n\nfunction hash(s: string, i: number) {\n  let x = 2166136261 ^ i;\n  for (let k = 0; k < s.length; k++) x = Math.imul(x ^ s.charCodeAt(k), 16777619);\n  x = Math.imul(x ^ (x >>> 15), 2246822507);\n  return (x ^ (x >>> 13)) >>> 0;\n}\n\nconst css = `\n.hb-xf2 { --hb-xf2-accent: #2f7bff; --hb-xf2-delay: 380ms; position: relative; display: inline; box-sizing: border-box; font-family: inherit; }\n.hb-xf2 *, .hb-xf2 *::before, .hb-xf2 *::after { box-sizing: border-box; }\n.hb-xf2-mention { all: unset; position: relative; display: inline; font: inherit; font-weight: 600; color: color-mix(in srgb, var(--hb-xf2-accent) 55%, #fff); cursor: pointer; border-radius: 4px; padding: 0 2px; background: color-mix(in srgb, var(--hb-xf2-accent) 12%, transparent); transition: background .2s; }\n.hb-xf2-mention:hover, .hb-xf2-mention[aria-expanded=\"true\"] { background: color-mix(in srgb, var(--hb-xf2-accent) 22%, transparent); }\n.hb-xf2-mention:focus-visible { outline: 2px solid var(--hb-xf2-accent); outline-offset: 2px; }\n.hb-xf2-line { position: absolute; left: 2px; right: 2px; bottom: -2px; height: 2px; border-radius: 2px; background: var(--hb-xf2-accent); transform: scaleX(0); transform-origin: left; pointer-events: none; }\n.hb-xf2-mention[data-intent=\"true\"] .hb-xf2-line { transform: scaleX(1); transition: transform var(--hb-xf2-delay) cubic-bezier(.4,.1,.3,1); }\n.hb-xf2-mention[aria-expanded=\"true\"] .hb-xf2-line { transform: scaleX(1); opacity: 0; transition: opacity .2s; }\n.hb-xf2-card { position: absolute; left: -8px; z-index: 60; width: 300px; max-width: calc(100vw - 24px); display: block; border-radius: 18px; overflow: hidden; background: #121212; border: 1px solid #2a2a2a; color: #ededed; text-align: left; font-weight: 400; line-height: 1.4; white-space: normal; box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 30px 60px -20px rgba(0,0,0,.8), 0 10px 20px -10px rgba(0,0,0,.6); outline: none; }\n.hb-xf2-card[data-side=\"bottom\"] { top: calc(100% + 10px); transform-origin: 24px -10px; }\n.hb-xf2-card[data-side=\"top\"] { bottom: calc(100% + 10px); transform-origin: 24px calc(100% + 10px); }\n.hb-xf2-card[data-state=\"open\"] { animation: hb-xf2-in .36s cubic-bezier(.16,1,.3,1) both; }\n.hb-xf2-card[data-state=\"closed\"] { animation: hb-xf2-out .15s ease-in both; pointer-events: none; }\n.hb-xf2-card::before { content: \"\"; position: absolute; left: 0; right: 0; height: 14px; }\n.hb-xf2-card[data-side=\"bottom\"]::before { top: -14px; }\n.hb-xf2-card[data-side=\"top\"]::before { bottom: -14px; }\n.hb-xf2-cover { position: relative; height: 56px; background: var(--hb-xf2-cover); }\n.hb-xf2-cover::after { content: \"\"; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, rgba(255,255,255,.07) 0 1px, transparent 1px 9px), linear-gradient(transparent 40%, #121212); }\n.hb-xf2-top { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 14px; margin-top: -26px; position: relative; z-index: 1; }\n.hb-xf2-ava { position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; font-size: 17px; font-weight: 600; letter-spacing: -.02em; color: #fff; background: var(--hb-xf2-ava); box-shadow: 0 0 0 3px #121212, 0 6px 16px -6px rgba(0,0,0,.8); }\n.hb-xf2-online { position: absolute; right: 1px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 2.5px #121212; }\n.hb-xf2-btns { display: flex; gap: 6px; padding-bottom: 2px; }\n.hb-xf2-btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s, border-color .2s, transform .15s cubic-bezier(.3,.7,.4,1); }\n.hb-xf2-btn:active { transform: scale(.95); }\n.hb-xf2-btn:focus-visible { outline: 2px solid var(--hb-xf2-accent); outline-offset: 2px; }\n.hb-xf2-ghost { width: 30px; padding: 0; color: #a1a1a1; border: 1px solid #2c2c2c; background: #171717; }\n.hb-xf2-ghost:hover { color: #ededed; border-color: #3a3a3a; }\n.hb-xf2-ghost svg { width: 14px; height: 14px; }\n.hb-xf2-follow { min-width: 84px; color: #0a0a0a; background: #ededed; box-shadow: inset 0 -1px 0 rgba(0,0,0,.15); }\n.hb-xf2-follow:hover { background: #fff; }\n.hb-xf2-follow[aria-pressed=\"true\"] { color: #ededed; background: #1c1c1c; box-shadow: inset 0 0 0 1px #333; }\n.hb-xf2-follow[aria-pressed=\"true\"]:hover { color: #ff7a7a; box-shadow: inset 0 0 0 1px #5a2a2a; }\n.hb-xf2-follow svg { width: 12px; height: 12px; }\n.hb-xf2-main { padding: 10px 14px 0; }\n.hb-xf2-name { display: flex; align-items: baseline; gap: 6px; margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }\n.hb-xf2-handle { font-size: 12px; font-weight: 400; color: #8f8f8f; }\n.hb-xf2-role { margin: 2px 0 0; font-size: 12px; color: #a1a1a1; }\n.hb-xf2-bio { margin: 8px 0 0; font-size: 12.5px; color: #d4d4d4; }\n.hb-xf2-where { display: flex; gap: 12px; margin-top: 8px; font-size: 11.5px; color: #8f8f8f; }\n.hb-xf2-where span { display: inline-flex; align-items: center; gap: 4px; }\n.hb-xf2-where svg { width: 12px; height: 12px; }\n.hb-xf2-graph { display: block; width: 100%; height: auto; margin: 12px 0 0; }\n.hb-xf2-cell { animation: hb-xf2-pop .5s cubic-bezier(.2,.8,.2,1) both; transform-box: fill-box; transform-origin: center; }\n.hb-xf2-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; border-top: 1px solid #222; }\n.hb-xf2-stat { padding: 10px 0 12px; text-align: center; font-size: 11px; color: #8f8f8f; }\n.hb-xf2-stat + .hb-xf2-stat { border-left: 1px solid #222; }\n.hb-xf2-num { display: block; height: 18px; overflow: hidden; font-size: 14px; font-weight: 600; color: #ededed; font-variant-numeric: tabular-nums; }\n.hb-xf2-num span { display: block; animation: hb-xf2-roll .4s cubic-bezier(.2,.9,.3,1.2) both; }\n.hb-xf2-embedded { display: inline-block; }\n.hb-xf2-embedded .hb-xf2-card { position: relative; left: auto; top: auto; bottom: auto; margin-top: 10px; animation: none; }\n@keyframes hb-xf2-in { from { opacity: 0; transform: translateY(-6px) scale(.94); } to { opacity: 1; transform: none; } }\n@keyframes hb-xf2-out { to { opacity: 0; transform: translateY(-4px) scale(.97); } }\n@keyframes hb-xf2-pop { from { opacity: 0; transform: scale(.2); } }\n@keyframes hb-xf2-roll { from { transform: translateY(100%); opacity: 0; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xf2 *, .hb-xf2 *::before { animation: none !important; transition: none !important; }\n}\n`;\n\nexport function PopoverHoverProfile({\n  user = defaultUser,\n  children,\n  openDelay = 380,\n  closeDelay = 220,\n  side = \"bottom\",\n  defaultFollowing = false,\n  onFollowChange,\n  onMessage,\n  embedded = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PopoverHoverProfileProps) {\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [open, setOpen] = React.useState(embedded);\n  const [mounted, setMounted] = React.useState(embedded);\n  const [intent, setIntent] = React.useState(false);\n  const [following, setFollowing] = React.useState(defaultFollowing);\n  const openTimer = React.useRef(0);\n  const closeTimer = React.useRef(0);\n  const unmountTimer = React.useRef(0);\n  const triggerRef = React.useRef<HTMLButtonElement>(null);\n  const cardRef = React.useRef<HTMLSpanElement>(null);\n\n  if (open && !mounted) setMounted(true);\n\n  React.useEffect(\n    () => () => {\n      window.clearTimeout(openTimer.current);\n      window.clearTimeout(closeTimer.current);\n      window.clearTimeout(unmountTimer.current);\n    },\n    [],\n  );\n\n  const show = (now: boolean) => {\n    window.clearTimeout(closeTimer.current);\n    window.clearTimeout(unmountTimer.current);\n    if (open) return;\n    if (now) {\n      setOpen(true);\n      return;\n    }\n    setIntent(true);\n    window.clearTimeout(openTimer.current);\n    openTimer.current = window.setTimeout(() => {\n      setIntent(false);\n      setOpen(true);\n    }, openDelay);\n  };\n\n  const hide = (now: boolean) => {\n    window.clearTimeout(openTimer.current);\n    setIntent(false);\n    if (embedded) return;\n    window.clearTimeout(closeTimer.current);\n    closeTimer.current = window.setTimeout(() => {\n      setOpen(false);\n      unmountTimer.current = window.setTimeout(() => setMounted(false), 160);\n    }, now ? 0 : closeDelay);\n  };\n\n  const toggleFollow = () => {\n    const next = !following;\n    setFollowing(next);\n    onFollowChange?.(next);\n  };\n\n  const followers = user.followers + (following && !defaultFollowing ? 1 : !following && defaultFollowing ? -1 : 0);\n  const initials = user.name.split(\" \").map((s) => s[0]).join(\"\").slice(0, 2).toUpperCase();\n  const h1 = hash(user.handle, 1) % 360;\n  const h2 = (h1 + 40 + (hash(user.handle, 2) % 80)) % 360;\n  const vars = {\n    \"--hb-xf2-accent\": accent,\n    \"--hb-xf2-delay\": `${openDelay}ms`,\n    \"--hb-xf2-cover\": `linear-gradient(120deg, hsl(${h1} 70% 42%), hsl(${h2} 75% 30%) 60%, hsl(${(h2 + 30) % 360} 60% 18%))`,\n    \"--hb-xf2-ava\": `radial-gradient(circle at 30% 25%, hsl(${h1} 80% 66%), hsl(${h2} 70% 38%))`,\n  } as React.CSSProperties;\n\n  const cols = 26;\n  const rows = 5;\n  const cells: React.ReactNode[] = [];\n  for (let c = 0; c < cols; c++) {\n    for (let r = 0; r < rows; r++) {\n      const v = hash(user.handle, c * rows + r + 10) % 100;\n      const trend = c / cols;\n      const level = v < 30 - trend * 18 ? 0 : v < 60 ? 1 : v < 84 ? 2 : 3;\n      const fill = level === 0 ? \"#1d1d1d\" : `color-mix(in srgb, ${accent} ${[0, 35, 65, 100][level]}%, #1d1d1d)`;\n      cells.push(\n        <rect\n          key={`${c}-${r}`}\n          className=\"hb-xf2-cell\"\n          x={c * 9}\n          y={r * 9}\n          width=\"7\"\n          height=\"7\"\n          rx=\"1.6\"\n          style={{ fill, animationDelay: `${(c * 0.012 + r * 0.02).toFixed(3)}s` }}\n        />,\n      );\n    }\n  }\n\n  return (\n    <span\n      className={`hb-xf2 ${embedded ? \"hb-xf2-embedded\" : \"\"} ${className}`}\n      style={{ ...vars, ...style }}\n      onPointerEnter={(e) => e.pointerType === \"mouse\" && show(false)}\n      onPointerLeave={(e) => e.pointerType === \"mouse\" && hide(false)}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && open && !embedded) {\n          e.stopPropagation();\n          hide(true);\n          triggerRef.current?.focus();\n        }\n      }}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node)) hide(false);\n      }}\n      {...rest}\n    >\n      <style href=\"hb-popover-hover-profile\" precedence=\"default\">{css}</style>\n      <button\n        ref={triggerRef}\n        type=\"button\"\n        className=\"hb-xf2-mention\"\n        data-intent={intent}\n        aria-expanded={open}\n        aria-controls={`${uid}-card`}\n        aria-haspopup=\"dialog\"\n        onFocus={() => show(true)}\n        onClick={() => (open && !embedded ? hide(true) : show(true))}\n      >\n        {children ?? `@${user.handle}`}\n        <span className=\"hb-xf2-line\" aria-hidden=\"true\" />\n      </button>\n      {mounted && (\n        <span\n          ref={cardRef}\n          id={`${uid}-card`}\n          role=\"dialog\"\n          aria-label={`${user.name} profile`}\n          className=\"hb-xf2-card\"\n          data-side={side}\n          data-state={open ? \"open\" : \"closed\"}\n        >\n          <span className=\"hb-xf2-cover\" style={{ display: \"block\" }} aria-hidden=\"true\" />\n          <span className=\"hb-xf2-top\">\n            <span className=\"hb-xf2-ava\" aria-hidden=\"true\">\n              {initials}\n              {user.online && <span className=\"hb-xf2-online\" />}\n            </span>\n            <span className=\"hb-xf2-btns\">\n              <button type=\"button\" className=\"hb-xf2-btn hb-xf2-ghost\" aria-label={`Message ${user.name}`} onClick={onMessage}>\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 5h16v11H9l-5 4z\" /></svg>\n              </button>\n              <button type=\"button\" className=\"hb-xf2-btn hb-xf2-follow\" aria-pressed={following} onClick={toggleFollow}>\n                {following ? (\n                  <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m2.5 6.2 2.3 2.3 4.7-5\" /></svg>\n                ) : (\n                  <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"M6 2v8M2 6h8\" /></svg>\n                )}\n                {following ? \"Following\" : \"Follow\"}\n              </button>\n            </span>\n          </span>\n          <span className=\"hb-xf2-main\" style={{ display: \"block\" }}>\n            <span className=\"hb-xf2-name\" style={{ display: \"flex\" }}>\n              {user.name}\n              <span className=\"hb-xf2-handle\">@{user.handle}</span>\n            </span>\n            <span className=\"hb-xf2-role\" style={{ display: \"block\" }}>{user.role}</span>\n            <span className=\"hb-xf2-bio\" style={{ display: \"block\" }}>{user.bio}</span>\n            <span className=\"hb-xf2-where\">\n              <span>\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" aria-hidden=\"true\"><path d=\"M12 21s-7-6.2-7-11.5a7 7 0 0 1 14 0C19 14.8 12 21 12 21Z\" /><circle cx=\"12\" cy=\"9.5\" r=\"2.5\" /></svg>\n                {user.location}\n              </span>\n              <span>\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><circle cx=\"12\" cy=\"12\" r=\"8.5\" /><path d=\"M12 7.5V12l3 2\" /></svg>\n                {user.localTime} local\n              </span>\n            </span>\n            <svg className=\"hb-xf2-graph\" viewBox={`0 0 ${cols * 9 - 2} ${rows * 9 - 2}`} role=\"img\" aria-label=\"Contributions over the last six months\">\n              {cells}\n            </svg>\n          </span>\n          <span className=\"hb-xf2-stats\">\n            <span className=\"hb-xf2-stat\"><span className=\"hb-xf2-num\">{user.repos}</span>Repos</span>\n            <span className=\"hb-xf2-stat\">\n              <span className=\"hb-xf2-num\" aria-live=\"polite\"><span key={followers}>{followers.toLocaleString(\"en-US\")}</span></span>\n              Followers\n            </span>\n            <span className=\"hb-xf2-stat\"><span className=\"hb-xf2-num\">{user.following}</span>Following</span>\n          </span>\n        </span>\n      )}\n    </span>\n  );\n}\n"
    }
  ]
}