{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "social-subscribe-bell",
  "type": "registry:component",
  "title": "Social Subscribe Bell",
  "description": "A Subscribe button that settles into Subscribed and slides out a bell that rings, with a menu for all uploads, highlights only, no notifications or unsubscribe. The bell glyph changes with the chosen mode.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "subscribe",
    "bell",
    "notifications",
    "menu",
    "channel",
    "social"
  ],
  "docs": "https://hyperblur.dev/effects/social-subscribe-bell",
  "files": [
    {
      "path": "registry/hyperblur/social-subscribe-bell.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/social-subscribe-bell.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type SocialSubscribeBellMode = \"all\" | \"personalized\" | \"none\";\n\nexport interface SocialSubscribeBellProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  subscribed?: boolean;\n  defaultSubscribed?: boolean;\n  onSubscribedChange?: (subscribed: boolean) => void;\n  mode?: SocialSubscribeBellMode;\n  defaultMode?: SocialSubscribeBellMode;\n  onModeChange?: (mode: SocialSubscribeBellMode) => void;\n  count?: number;\n  locale?: string;\n  accent?: string;\n  subscribeLabel?: string;\n  subscribedLabel?: string;\n  countLabel?: string;\n}\n\nconst css = `\n.hb-xc11 { --hb-xc11-a: #ff4d4f; position: relative; display: inline-flex; flex-direction: column; align-items: flex-start; gap: 6px; box-sizing: border-box; font-family: inherit; color: #ededed; }\n.hb-xc11 *, .hb-xc11 *::before, .hb-xc11 *::after { box-sizing: border-box; }\n.hb-xc11-row { position: relative; display: inline-flex; align-items: center; height: 38px; }\n.hb-xc11-sub {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 38px;\n  margin: 0;\n  padding: 0 18px;\n  border: 0;\n  border-radius: 999px;\n  font: inherit;\n  font-size: 13.5px;\n  font-weight: 600;\n  color: #ffffff;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xc11-a) 80%, #ffffff), var(--hb-xc11-a));\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 20px -8px color-mix(in srgb, var(--hb-xc11-a) 75%, transparent);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease, padding 0.45s cubic-bezier(0.65, 0, 0.25, 1), border-radius 0.45s cubic-bezier(0.65, 0, 0.25, 1), transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-xc11-sub:active { transform: scale(0.95); }\n.hb-xc11-sub:focus-visible, .hb-xc11-bell:focus-visible, .hb-xc11-opt:focus-visible { outline: 2px solid #ededed; outline-offset: 2px; }\n.hb-xc11[data-on=\"true\"] .hb-xc11-sub { padding: 0 16px 0 14px; border-radius: 999px 0 0 999px; color: #ededed; background: #1f1f1f; box-shadow: inset 0 0 0 1px #2e2e2e, inset 0 1px 0 rgba(255, 255, 255, 0.05); }\n.hb-xc11-tx { display: grid; }\n.hb-xc11-tx > span { grid-area: 1 / 1; white-space: nowrap; transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease; }\n.hb-xc11-tx > span + span { opacity: 0; transform: translateY(80%); }\n.hb-xc11[data-on=\"true\"] .hb-xc11-tx > span:first-child { opacity: 0; transform: translateY(-80%); }\n.hb-xc11[data-on=\"true\"] .hb-xc11-tx > span + span { opacity: 1; transform: none; }\n.hb-xc11-bw { display: grid; grid-template-columns: 0fr; transition: grid-template-columns 0.45s cubic-bezier(0.65, 0, 0.25, 1); }\n.hb-xc11[data-on=\"true\"] .hb-xc11-bw { grid-template-columns: 1fr; }\n.hb-xc11-bw > div { min-width: 0; overflow: hidden; }\n.hb-xc11-bell {\n  display: inline-flex;\n  align-items: center;\n  gap: 4px;\n  height: 38px;\n  margin: 0 0 0 2px;\n  padding: 0 11px 0 12px;\n  border: 0;\n  border-radius: 0 999px 999px 0;\n  font: inherit;\n  color: #ededed;\n  background: #1f1f1f;\n  box-shadow: inset 0 0 0 1px #2e2e2e, inset 0 1px 0 rgba(255, 255, 255, 0.05);\n  cursor: pointer;\n  white-space: nowrap;\n  transition: background 0.25s ease;\n}\n.hb-xc11-bell:hover, .hb-xc11-bell[aria-expanded=\"true\"] { background: #262626; }\n.hb-xc11-bi { display: inline-flex; width: 18px; height: 18px; transform-origin: 50% 3px; }\n.hb-xc11-bi svg { width: 18px; height: 18px; display: block; }\n.hb-xc11-bi[data-ring=\"true\"] { animation: hb-xc11-ring 0.9s cubic-bezier(0.36, 0.07, 0.19, 0.97); }\n.hb-xc11-car { width: 12px; height: 12px; color: #8f8f8f; transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xc11-bell[aria-expanded=\"true\"] .hb-xc11-car { transform: rotate(180deg); }\n.hb-xc11-menu {\n  position: absolute;\n  z-index: 20;\n  top: calc(100% + 6px);\n  right: 0;\n  min-width: 196px;\n  margin: 0;\n  padding: 4px;\n  list-style: none;\n  border-radius: 13px;\n  background: rgba(22, 22, 22, 0.96);\n  -webkit-backdrop-filter: blur(12px);\n  backdrop-filter: blur(12px);\n  box-shadow: inset 0 0 0 1px #2c2c2c, inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 40px -12px rgba(0, 0, 0, 0.9);\n  transform-origin: top right;\n  animation: hb-xc11-pop 0.22s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-xc11-opt {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  height: 30px;\n  margin: 0;\n  padding: 0 10px;\n  border: 0;\n  border-radius: 8px;\n  font: inherit;\n  font-size: 12.5px;\n  font-weight: 500;\n  color: #d4d4d4;\n  background: transparent;\n  cursor: pointer;\n  text-align: left;\n}\n.hb-xc11-opt:hover, .hb-xc11-opt:focus-visible { color: #ffffff; background: #242424; }\n.hb-xc11-opt:focus-visible { outline-offset: -2px; }\n.hb-xc11-opt svg { width: 16px; height: 16px; flex: none; }\n.hb-xc11-opt span:not(.hb-xc11-dot) { flex: 1; }\n.hb-xc11-opt[aria-checked=\"true\"] { color: #ffffff; }\n.hb-xc11-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--hb-xc11-a); }\n.hb-xc11-sep { height: 1px; margin: 4px 6px; background: #2a2a2a; }\n.hb-xc11-opt[data-danger=\"true\"] { color: #ff8a8e; }\n.hb-xc11-cnt { position: relative; height: 16px; overflow: hidden; font-size: 12px; color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-xc11-cnt span { display: block; white-space: nowrap; animation: hb-xc11-up 0.4s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xc11-cnt b { font-weight: 600; color: #d4d4d4; }\n@keyframes hb-xc11-ring { 0% { transform: rotate(0); } 15% { transform: rotate(18deg); } 30% { transform: rotate(-15deg); } 45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); } 100% { transform: rotate(0); } }\n@keyframes hb-xc11-pop { from { opacity: 0; transform: translateY(-4px) scale(0.96); } to { opacity: 1; transform: none; } }\n@keyframes hb-xc11-up { from { opacity: 0; transform: translateY(70%); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xc11-sub, .hb-xc11-tx > span, .hb-xc11-bw, .hb-xc11-car { transition: none; }\n  .hb-xc11-bi[data-ring=\"true\"], .hb-xc11-menu, .hb-xc11-cnt span { animation: none; }\n}\n`;\n\nfunction BellIcon({ mode }: { mode: SocialSubscribeBellMode }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.9} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d=\"M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2h-15z\" fill={mode === \"all\" ? \"currentColor\" : \"none\"} />\n      <path d=\"M10 21h4\" />\n      {mode === \"all\" ? <path d=\"M3 9.5a9 9 0 0 1 2.2-4.7M21 9.5a9 9 0 0 0-2.2-4.7\" /> : null}\n      {mode === \"none\" ? <path d=\"M4 4l16 16\" /> : null}\n    </svg>\n  );\n}\n\nconst MODES: { id: SocialSubscribeBellMode; label: string }[] = [\n  { id: \"all\", label: \"All uploads\" },\n  { id: \"personalized\", label: \"Highlights only\" },\n  { id: \"none\", label: \"No notifications\" },\n];\n\nexport function SocialSubscribeBell({\n  subscribed: subProp,\n  defaultSubscribed = false,\n  onSubscribedChange,\n  mode: modeProp,\n  defaultMode = \"all\",\n  onModeChange,\n  count = 48213,\n  locale = \"en-US\",\n  accent = \"#ff4d4f\",\n  subscribeLabel = \"Subscribe\",\n  subscribedLabel = \"Subscribed\",\n  countLabel = \"subscribers\",\n  className = \"\",\n  style,\n  ...rest\n}: SocialSubscribeBellProps) {\n  const [subInner, setSubInner] = React.useState(defaultSubscribed);\n  const [modeInner, setModeInner] = React.useState<SocialSubscribeBellMode>(defaultMode);\n  const [menu, setMenu] = React.useState(false);\n  const [ring, setRing] = React.useState(0);\n  const on = subProp ?? subInner;\n  const mode = modeProp ?? modeInner;\n  const startOn = subProp ?? defaultSubscribed;\n  const value = (startOn ? count - 1 : count) + (on ? 1 : 0);\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const bellRef = React.useRef<HTMLButtonElement>(null);\n  const optRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const menuId = React.useId();\n\n  React.useEffect(() => {\n    if (!menu) return;\n    function away(e: PointerEvent) {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setMenu(false);\n    }\n    document.addEventListener(\"pointerdown\", away);\n    return () => document.removeEventListener(\"pointerdown\", away);\n  }, [menu]);\n\n  function setSub(next: boolean) {\n    if (subProp === undefined) setSubInner(next);\n    onSubscribedChange?.(next);\n    if (next) setRing((r) => r + 1);\n  }\n\n  function setMode(next: SocialSubscribeBellMode) {\n    if (modeProp === undefined) setModeInner(next);\n    onModeChange?.(next);\n    if (next === \"all\") setRing((r) => r + 1);\n  }\n\n  function openMenu(focusIdx: number) {\n    setMenu(true);\n    window.requestAnimationFrame(() => optRefs.current[focusIdx]?.focus());\n  }\n\n  function closeMenu() {\n    setMenu(false);\n    bellRef.current?.focus();\n  }\n\n  function onMenuKey(e: React.KeyboardEvent<HTMLDivElement>) {\n    const list = optRefs.current.filter(Boolean) as HTMLButtonElement[];\n    const i = list.indexOf(document.activeElement as HTMLButtonElement);\n    if (e.key === \"Escape\") {\n      e.preventDefault();\n      closeMenu();\n    } else if (e.key === \"ArrowDown\") {\n      e.preventDefault();\n      list[(i + 1) % list.length]?.focus();\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault();\n      list[(i - 1 + list.length) % list.length]?.focus();\n    } else if (e.key === \"Tab\") {\n      setMenu(false);\n    }\n  }\n\n  const fmt = new Intl.NumberFormat(locale);\n\n  return (\n    <>\n      <style href=\"hb-social-subscribe-bell\" precedence=\"default\">{css}</style>\n      <div\n        ref={rootRef}\n        className={`hb-xc11 ${className}`}\n        style={{ \"--hb-xc11-a\": accent, ...style } as React.CSSProperties}\n        data-on={on ? \"true\" : undefined}\n        {...rest}\n      >\n        <div className=\"hb-xc11-row\">\n          <button\n            type=\"button\"\n            className=\"hb-xc11-sub\"\n            aria-pressed={on}\n            onClick={() => {\n              if (!on) setSub(true);\n              else openMenu(0);\n            }}\n          >\n            <span className=\"hb-xc11-tx\">\n              <span aria-hidden={on || undefined}>{subscribeLabel}</span>\n              <span aria-hidden={!on || undefined}>{subscribedLabel}</span>\n            </span>\n          </button>\n          <div className=\"hb-xc11-bw\" aria-hidden={on ? undefined : true}>\n            <div>\n              <button\n                ref={bellRef}\n                type=\"button\"\n                className=\"hb-xc11-bell\"\n                tabIndex={on ? 0 : -1}\n                aria-haspopup=\"menu\"\n                aria-expanded={menu}\n                aria-controls={menu ? menuId : undefined}\n                aria-label={`Notifications: ${MODES.find((m) => m.id === mode)?.label ?? mode}`}\n                onClick={() => (menu ? setMenu(false) : openMenu(Math.max(0, MODES.findIndex((m) => m.id === mode))))}\n                onKeyDown={(e) => {\n                  if (e.key === \"ArrowDown\" && !menu) {\n                    e.preventDefault();\n                    openMenu(0);\n                  }\n                }}\n              >\n                <span className=\"hb-xc11-bi\" data-ring={ring > 0 ? \"true\" : undefined} key={ring}>\n                  <BellIcon mode={mode} />\n                </span>\n                <svg className=\"hb-xc11-car\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.8} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"m4 6 4 4 4-4\" />\n                </svg>\n              </button>\n            </div>\n          </div>\n          {menu ? (\n            <div id={menuId} className=\"hb-xc11-menu\" role=\"menu\" aria-label=\"Notification settings\" onKeyDown={onMenuKey}>\n              {MODES.map((m, i) => (\n                <button\n                  key={m.id}\n                  ref={(el) => {\n                    optRefs.current[i] = el;\n                  }}\n                  type=\"button\"\n                  role=\"menuitemradio\"\n                  aria-checked={mode === m.id}\n                  className=\"hb-xc11-opt\"\n                  onClick={() => {\n                    setMode(m.id);\n                    closeMenu();\n                  }}\n                >\n                  <BellIcon mode={m.id} />\n                  <span>{m.label}</span>\n                  {mode === m.id ? <span className=\"hb-xc11-dot\" aria-hidden=\"true\" /> : null}\n                </button>\n              ))}\n              <div className=\"hb-xc11-sep\" role=\"separator\" />\n              <button\n                ref={(el) => {\n                  optRefs.current[MODES.length] = el;\n                }}\n                type=\"button\"\n                role=\"menuitem\"\n                className=\"hb-xc11-opt\"\n                data-danger=\"true\"\n                onClick={() => {\n                  setSub(false);\n                  setMenu(false);\n                  rootRef.current?.querySelector<HTMLButtonElement>(\".hb-xc11-sub\")?.focus();\n                }}\n              >\n                <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={1.9} strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"M6 12h12\" />\n                </svg>\n                <span>Unsubscribe</span>\n              </button>\n            </div>\n          ) : null}\n        </div>\n        <div className=\"hb-xc11-cnt\">\n          <span key={value}>\n            <b>{fmt.format(value)}</b> {countLabel}\n          </span>\n        </div>\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}