{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popup-island-notification",
  "type": "registry:component",
  "title": "Island Notification",
  "description": "A notification pill at the top of the screen that morphs into a card with a springy resize, then into an inline reply field. Messages queue with an unread count, collapse on a paused-on-hover timer and end in an All caught up state.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "notification",
    "dynamic-island",
    "toast",
    "reply",
    "morph",
    "queue"
  ],
  "docs": "https://hyperblur.dev/effects/popup-island-notification",
  "files": [
    {
      "path": "registry/hyperblur/popup-island-notification.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/popup-island-notification.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PopupIslandItem {\n  id: string;\n  from: string;\n  context: string;\n  time: string;\n  message: string;\n  tint?: string;\n}\n\nexport interface PopupIslandNotificationProps extends React.HTMLAttributes<HTMLDivElement> {\n  notifications?: PopupIslandItem[];\n  defaultExpanded?: boolean;\n  duration?: number;\n  position?: \"top\" | \"bottom\";\n  onReply?: (id: string, text: string) => void;\n  onMarkRead?: (id: string) => void;\n  onExpandedChange?: (expanded: boolean) => void;\n  loop?: boolean;\n  embedded?: boolean;\n  accent?: string;\n}\n\nconst defaultNotifications: PopupIslandItem[] = [\n  { id: \"n1\", from: \"Priya Raman\", context: \"#design-review\", time: \"now\", message: \"Pushed the new onboarding frames. Can you check the empty states before standup?\", tint: \"#e0679a\" },\n  { id: \"n2\", from: \"Diego Alvarez\", context: \"Pull request #318\", time: \"2m\", message: \"Approved with one nit: the retry delay should back off, not stay at 2s.\", tint: \"#4fa3ff\" },\n  { id: \"n3\", from: \"Hana Sato\", context: \"Direct message\", time: \"9m\", message: \"Lunch at Tartine at 12:30? I booked a table for four.\", tint: \"#f2a53a\" },\n];\n\nconst css = `\n.hb-xf11 { --hb-xf11-accent: #3ddc84; position: fixed; left: 50%; top: 12px; z-index: 950; transform: translateX(-50%); box-sizing: border-box; font-family: inherit; color: #ededed; }\n.hb-xf11[data-pos=\"bottom\"] { top: auto; bottom: 16px; }\n.hb-xf11 *, .hb-xf11 *::before, .hb-xf11 *::after { box-sizing: border-box; }\n.hb-xf11-embedded { position: relative; left: auto; top: auto; bottom: auto; transform: none; display: flex; justify-content: center; width: 100%; }\n.hb-xf11-island { position: relative; width: var(--hb-xf11-w); height: var(--hb-xf11-h); max-width: calc(100vw - 24px); border-radius: var(--hb-xf11-r); background: #050505; box-shadow: inset 0 0 0 1px rgba(255,255,255,.07), inset 0 1px 0 rgba(255,255,255,.06), 0 20px 50px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.6); overflow: hidden; transition: width .55s cubic-bezier(.32,1.4,.46,1), height .55s cubic-bezier(.32,1.4,.46,1), border-radius .5s cubic-bezier(.32,1.2,.46,1); animation: hb-xf11-drop .6s cubic-bezier(.3,1.4,.5,1) both; }\n.hb-xf11-embedded .hb-xf11-island { max-width: 100%; }\n.hb-xf11-pill { all: unset; box-sizing: border-box; position: absolute; inset: 0; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 6px; cursor: pointer; transition: opacity .2s ease; }\n.hb-xf11-pill:focus-visible { outline: 2px solid var(--hb-xf11-accent); outline-offset: -2px; border-radius: inherit; }\n.hb-xf11[data-mode=\"expanded\"] .hb-xf11-pill, .hb-xf11[data-mode=\"reply\"] .hb-xf11-pill { opacity: 0; pointer-events: none; }\n.hb-xf11-mini { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--hb-xf11-tint) 70%, #fff), var(--hb-xf11-tint)); }\n.hb-xf11-pilltext { flex: 1; min-width: 0; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xf11-wave { display: flex; align-items: center; gap: 2px; height: 14px; }\n.hb-xf11-wave i { font-style: normal; width: 2.5px; border-radius: 2px; background: var(--hb-xf11-accent); animation: hb-xf11-wave 1s ease-in-out infinite; }\n.hb-xf11-wave i:nth-child(1) { height: 6px; }\n.hb-xf11-wave i:nth-child(2) { height: 12px; animation-delay: .15s; }\n.hb-xf11-wave i:nth-child(3) { height: 8px; animation-delay: .3s; }\n.hb-xf11-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #0a0a0a; background: var(--hb-xf11-accent); font-variant-numeric: tabular-nums; }\n.hb-xf11-done { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; color: #d4d4d4; animation: hb-xf11-fade .4s ease .2s both; }\n.hb-xf11-done svg { width: 14px; height: 14px; color: var(--hb-xf11-accent); }\n.hb-xf11-card { position: absolute; left: 0; top: 0; width: min(360px, calc(100vw - 24px)); padding: 14px 14px 12px; opacity: 0; pointer-events: none; transform: scale(.94); transform-origin: 50% 0; filter: blur(4px); transition: opacity .25s ease, transform .45s cubic-bezier(.3,1.3,.5,1), filter .3s ease; }\n.hb-xf11-embedded .hb-xf11-card { width: var(--hb-xf11-w); max-width: 100%; }\n.hb-xf11[data-mode=\"expanded\"] .hb-xf11-card, .hb-xf11[data-mode=\"reply\"] .hb-xf11-card { opacity: 1; pointer-events: auto; transform: none; filter: none; transition-delay: .12s, .08s, .12s; }\n.hb-xf11-row { display: flex; gap: 11px; }\n.hb-xf11-ava { position: relative; width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--hb-xf11-tint) 70%, #fff), var(--hb-xf11-tint)); }\n.hb-xf11-ava::after { content: \"\"; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--hb-xf11-accent); box-shadow: 0 0 0 2.5px #050505; }\n.hb-xf11-head { display: flex; align-items: baseline; gap: 6px; }\n.hb-xf11-from { font-size: 13px; font-weight: 600; white-space: nowrap; }\n.hb-xf11-ctx { flex: 1; min-width: 0; font-size: 11.5px; color: #7a7a7a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xf11-time { font-size: 11px; color: #6a6a6a; }\n.hb-xf11-msg { margin: 3px 0 0; font-size: 12.5px; line-height: 1.42; color: #cfcfcf; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }\n.hb-xf11-actions { display: flex; gap: 6px; margin-top: 11px; }\n.hb-xf11-btn { all: unset; box-sizing: border-box; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: #1a1a1a; color: #ededed; transition: background .2s, transform .15s cubic-bezier(.3,.7,.4,1); }\n.hb-xf11-btn:hover { background: #242424; }\n.hb-xf11-btn:active { transform: scale(.96); }\n.hb-xf11-btn:focus-visible { outline: 2px solid var(--hb-xf11-accent); outline-offset: 2px; }\n.hb-xf11-btn svg { width: 13px; height: 13px; }\n.hb-xf11-primary { background: #ededed; color: #0a0a0a; }\n.hb-xf11-primary:hover { background: #fff; }\n.hb-xf11-reply { display: flex; gap: 6px; margin-top: 11px; padding: 4px 4px 4px 12px; border-radius: 999px; background: #151515; border: 1px solid #262626; animation: hb-xf11-fade .3s ease both; }\n.hb-xf11-reply:focus-within { border-color: color-mix(in srgb, var(--hb-xf11-accent) 50%, #262626); }\n.hb-xf11-input { flex: 1; min-width: 0; height: 28px; border: 0; outline: 0; background: transparent; color: #ededed; font: inherit; font-size: 12.5px; }\n.hb-xf11-input::placeholder { color: #5a5a5a; }\n.hb-xf11-send { all: unset; box-sizing: border-box; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #0a0a0a; background: var(--hb-xf11-accent); cursor: pointer; transition: transform .15s cubic-bezier(.3,.7,.4,1), opacity .2s; }\n.hb-xf11-send:disabled { opacity: .35; cursor: default; }\n.hb-xf11-send:not(:disabled):active { transform: scale(.9); }\n.hb-xf11-send:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-xf11-send svg { width: 13px; height: 13px; }\n.hb-xf11-timer { position: absolute; left: 20px; right: 20px; bottom: 0; height: 2px; border-radius: 2px; background: rgba(255,255,255,.06); overflow: hidden; opacity: 0; transition: opacity .3s; }\n.hb-xf11[data-mode=\"expanded\"] .hb-xf11-timer { opacity: 1; }\n.hb-xf11-timer span { position: absolute; inset: 0; background: color-mix(in srgb, var(--hb-xf11-accent) 70%, transparent); transform-origin: left; animation: hb-xf11-timer var(--hb-xf11-ms) linear forwards; }\n.hb-xf11[data-hold=\"true\"] .hb-xf11-timer span { animation-play-state: paused; }\n.hb-xf11-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@keyframes hb-xf11-drop { from { opacity: 0; transform: translateY(-16px) scale(.6); } }\n@keyframes hb-xf11-wave { 0%, 100% { transform: scaleY(.5); } 50% { transform: scaleY(1); } }\n@keyframes hb-xf11-fade { from { opacity: 0; } }\n@keyframes hb-xf11-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xf11 *, .hb-xf11 *::before, .hb-xf11 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nexport function PopupIslandNotification({\n  notifications = defaultNotifications,\n  defaultExpanded,\n  duration = 6000,\n  position = \"top\",\n  onReply,\n  onMarkRead,\n  onExpandedChange,\n  loop = false,\n  embedded = false,\n  accent = \"#3ddc84\",\n  className = \"\",\n  style,\n  ...rest\n}: PopupIslandNotificationProps) {\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [queue, setQueue] = React.useState(notifications);\n  const [mode, setMode] = React.useState<\"collapsed\" | \"expanded\" | \"reply\">((defaultExpanded ?? embedded) ? \"expanded\" : \"collapsed\");\n  const [draft, setDraft] = React.useState(\"\");\n  const [hold, setHold] = React.useState(false);\n  const [sent, setSent] = React.useState(\"\");\n  const pillRef = React.useRef<HTMLButtonElement>(null);\n  const cardRef = React.useRef<HTMLDivElement>(null);\n  const inputRef = React.useRef<HTMLInputElement>(null);\n  const focusPill = React.useRef(false);\n  const item = queue[0];\n\n  const change = React.useCallback(\n    (next: \"collapsed\" | \"expanded\" | \"reply\") => {\n      setMode(next);\n      onExpandedChange?.(next !== \"collapsed\");\n    },\n    [onExpandedChange],\n  );\n\n  React.useEffect(() => {\n    if (mode === \"reply\") {\n      const f = requestAnimationFrame(() => inputRef.current?.focus({ preventScroll: true }));\n      return () => cancelAnimationFrame(f);\n    }\n    if (mode === \"collapsed\" && focusPill.current) {\n      focusPill.current = false;\n      pillRef.current?.focus({ preventScroll: true });\n    }\n  }, [mode]);\n\n  React.useEffect(() => {\n    if (mode !== \"expanded\" || hold || !item) return;\n    const t = window.setTimeout(() => change(\"collapsed\"), duration);\n    return () => window.clearTimeout(t);\n  }, [mode, hold, item, duration, change]);\n\n  const next = () => {\n    if (!item) return;\n    onMarkRead?.(item.id);\n    const rest = queue.slice(1);\n    focusPill.current = cardRef.current?.contains(document.activeElement) ?? false;\n    change(\"collapsed\");\n    window.setTimeout(() => {\n      setQueue(rest);\n      setDraft(\"\");\n      if (rest.length) window.setTimeout(() => change(\"expanded\"), 380);\n      else if (loop)\n        window.setTimeout(() => {\n          setQueue(notifications);\n          window.setTimeout(() => change(\"expanded\"), 420);\n        }, 2400);\n    }, 300);\n  };\n\n  const send = (e: React.FormEvent) => {\n    e.preventDefault();\n    if (!item || !draft.trim()) return;\n    onReply?.(item.id, draft.trim());\n    setSent(`Reply sent to ${item.from}`);\n    next();\n  };\n\n  const sizes = !item\n    ? { w: 168, h: 36, r: 18 }\n    : mode === \"collapsed\"\n      ? { w: 216, h: 38, r: 19 }\n      : { w: 360, h: 140, r: 28 };\n  const initials = item ? item.from.split(\" \").map((s) => s[0]).join(\"\").slice(0, 2).toUpperCase() : \"\";\n  const vars = {\n    \"--hb-xf11-accent\": accent,\n    \"--hb-xf11-tint\": item?.tint ?? accent,\n    \"--hb-xf11-w\": `${sizes.w}px`,\n    \"--hb-xf11-h\": `${sizes.h}px`,\n    \"--hb-xf11-r\": `${sizes.r}px`,\n    \"--hb-xf11-ms\": `${duration}ms`,\n  } as React.CSSProperties;\n\n  return (\n    <div\n      className={`hb-xf11 ${embedded ? \"hb-xf11-embedded\" : \"\"} ${className}`}\n      data-mode={item ? mode : \"empty\"}\n      data-pos={position}\n      data-hold={hold}\n      style={{ ...vars, ...style }}\n      role=\"region\"\n      aria-label=\"Notifications\"\n      onPointerEnter={() => setHold(true)}\n      onPointerLeave={() => setHold(false)}\n      onFocus={() => setHold(true)}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node)) setHold(false);\n      }}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && mode !== \"collapsed\") {\n          e.stopPropagation();\n          focusPill.current = true;\n          change(\"collapsed\");\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-popup-island-notification\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xf11-sr\" aria-live=\"polite\">{item ? `New message from ${item.from}: ${item.message}` : sent || \"All caught up\"}</span>\n      <div className=\"hb-xf11-island\">\n        {item ? (\n          <>\n            <button\n              ref={pillRef}\n              type=\"button\"\n              className=\"hb-xf11-pill\"\n              aria-expanded={mode !== \"collapsed\"}\n              aria-controls={`${uid}-card`}\n              tabIndex={mode === \"collapsed\" ? 0 : -1}\n              onClick={() => change(\"expanded\")}\n            >\n              <span className=\"hb-xf11-mini\" aria-hidden=\"true\">{initials}</span>\n              <span className=\"hb-xf11-pilltext\">{item.from}</span>\n              <span className=\"hb-xf11-wave\" aria-hidden=\"true\"><i /><i /><i /></span>\n              <span className=\"hb-xf11-count\" aria-label={`${queue.length} unread`}>{queue.length}</span>\n            </button>\n            <div ref={cardRef} id={`${uid}-card`} className=\"hb-xf11-card\" inert={mode === \"collapsed\"}>\n              <div className=\"hb-xf11-row\">\n                <span className=\"hb-xf11-ava\" aria-hidden=\"true\">{initials}</span>\n                <div style={{ flex: 1, minWidth: 0 }}>\n                  <div className=\"hb-xf11-head\">\n                    <span className=\"hb-xf11-from\">{item.from}</span>\n                    <span className=\"hb-xf11-ctx\">{item.context}</span>\n                    <span className=\"hb-xf11-time\">{item.time}</span>\n                  </div>\n                  <p className=\"hb-xf11-msg\">{item.message}</p>\n                </div>\n              </div>\n              {mode === \"reply\" ? (\n                <form className=\"hb-xf11-reply\" onSubmit={send}>\n                  <input\n                    ref={inputRef}\n                    className=\"hb-xf11-input\"\n                    value={draft}\n                    placeholder={`Reply to ${item.from.split(\" \")[0]}`}\n                    aria-label={`Reply to ${item.from}`}\n                    onChange={(e) => setDraft(e.target.value)}\n                  />\n                  <button type=\"submit\" className=\"hb-xf11-send\" aria-label=\"Send reply\" disabled={!draft.trim()}>\n                    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M8 13V3M3.5 7.5 8 3l4.5 4.5\" /></svg>\n                  </button>\n                </form>\n              ) : (\n                <div className=\"hb-xf11-actions\">\n                  <button type=\"button\" className=\"hb-xf11-btn\" onClick={() => change(\"reply\")}>\n                    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M6.5 4 3 7.5 6.5 11M3 7.5h6.5a3.5 3.5 0 0 1 3.5 3.5v1\" /></svg>\n                    Reply\n                  </button>\n                  <button type=\"button\" className=\"hb-xf11-btn hb-xf11-primary\" onClick={next}>\n                    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m3.5 8.3 3 3 6-6.6\" /></svg>\n                    Mark read\n                  </button>\n                </div>\n              )}\n            </div>\n            {mode === \"expanded\" && (\n              <span className=\"hb-xf11-timer\" aria-hidden=\"true\"><span key={item.id} /></span>\n            )}\n          </>\n        ) : (\n          <span className=\"hb-xf11-done\">\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"m3.5 8.3 3 3 6-6.6\" /></svg>\n            All caught up\n          </span>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}