{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-chat-inbox",
  "type": "registry:component",
  "title": "App Chat Inbox",
  "description": "A team chat screen with channels and direct messages, grouped bubbles with day dividers, a composer with attachment chips and a live typing indicator.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "app-ui",
    "chat",
    "messages",
    "inbox",
    "composer",
    "typing",
    "team"
  ],
  "docs": "https://hyperblur.dev/effects/app-chat-inbox",
  "files": [
    {
      "path": "registry/hyperblur/app-chat-inbox.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/app-chat-inbox.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface AppChatMessage {\n  id: string;\n  author: string;\n  text: string;\n  time: string;\n  day: string;\n  attachments?: string[];\n}\n\nexport interface AppChatConversation {\n  id: string;\n  name: string;\n  kind: \"channel\" | \"dm\";\n  members?: string[];\n  online?: boolean;\n  unread?: number;\n  topic?: string;\n  messages: AppChatMessage[];\n  typing?: string;\n}\n\nexport interface AppChatInboxProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\"> {\n  conversations?: AppChatConversation[];\n  me?: string;\n  defaultConversationId?: string;\n  defaultDraft?: string;\n  defaultAttachments?: string[];\n  accent?: string;\n  onSend?: (conversationId: string, message: AppChatMessage) => void;\n  onConversationChange?: (id: string) => void;\n}\n\nconst defaultConversations: AppChatConversation[] = [\n  {\n    id: \"launch\",\n    name: \"launch-week\",\n    kind: \"channel\",\n    topic: \"Shipping v2.15 on Nov 12\",\n    members: [\"Lena Park\", \"Diego Ramos\", \"Amara Chen\", \"Tom Whitaker\", \"Maya Okafor\"],\n    unread: 0,\n    typing: \"Lena Park\",\n    messages: [\n      { id: \"m1\", author: \"Diego Ramos\", day: \"Yesterday\", time: \"5:48 PM\", text: \"Staging is green again. The Safari tooltip bug was a stacking context on the sidebar.\" },\n      { id: \"m2\", author: \"Diego Ramos\", day: \"Yesterday\", time: \"5:49 PM\", text: \"Fix is in PR 2381 if anyone wants to look before tomorrow.\" },\n      { id: \"m3\", author: \"Maya Okafor\", day: \"Yesterday\", time: \"6:02 PM\", text: \"Reviewed and approved. Nice catch.\" },\n      { id: \"m4\", author: \"Amara Chen\", day: \"Today\", time: \"9:12 AM\", text: \"Final hero is up. I went with the darker gradient, it reads better on the pricing page too.\", attachments: [\"hero-launch-v4.png\"] },\n      { id: \"m5\", author: \"Lena Park\", day: \"Today\", time: \"9:20 AM\", text: \"Love it. Can we get a square crop for the social posts?\" },\n      { id: \"m6\", author: \"Maya Okafor\", day: \"Today\", time: \"9:24 AM\", text: \"I will pair with Amara after standup. Lena, do you still need the changelog draft today?\" },\n    ],\n  },\n  {\n    id: \"lena\",\n    name: \"Lena Park\",\n    kind: \"dm\",\n    online: true,\n    unread: 2,\n    messages: [\n      { id: \"l1\", author: \"Lena Park\", day: \"Today\", time: \"8:41 AM\", text: \"Morning! Quick one about the annual discount copy.\" },\n      { id: \"l2\", author: \"Lena Park\", day: \"Today\", time: \"8:42 AM\", text: \"Is 'two months free' clearer than '17% off'? Testing both next week.\" },\n    ],\n  },\n  {\n    id: \"design\",\n    name: \"design-crit\",\n    kind: \"channel\",\n    topic: \"Thursday 2pm, bring one screen\",\n    members: [\"Amara Chen\", \"Sofia Lind\", \"Maya Okafor\"],\n    unread: 5,\n    messages: [\n      { id: \"d1\", author: \"Sofia Lind\", day: \"Monday\", time: \"3:10 PM\", text: \"Uploaded the type scale explorations. Feedback welcome before Thursday.\", attachments: [\"type-scale-v2.fig\"] },\n      { id: \"d2\", author: \"Amara Chen\", day: \"Monday\", time: \"3:32 PM\", text: \"Option B for headings, option A for body. The 15px base feels right.\" },\n    ],\n  },\n  {\n    id: \"diego\",\n    name: \"Diego Ramos\",\n    kind: \"dm\",\n    online: false,\n    messages: [\n      { id: \"g1\", author: \"Maya Okafor\", day: \"Yesterday\", time: \"4:05 PM\", text: \"Can you take the tooltip bug? It is blocking the release checklist.\" },\n      { id: \"g2\", author: \"Diego Ramos\", day: \"Yesterday\", time: \"4:11 PM\", text: \"On it, should have something by end of day.\" },\n    ],\n  },\n  {\n    id: \"growth\",\n    name: \"growth\",\n    kind: \"channel\",\n    topic: \"Experiments and weekly numbers\",\n    members: [\"Tom Whitaker\", \"Lena Park\", \"Maya Okafor\"],\n    messages: [\n      { id: \"w1\", author: \"Tom Whitaker\", day: \"Yesterday\", time: \"2:00 PM\", text: \"Activation up 4.2 points week over week. The checklist is doing work.\" },\n    ],\n  },\n];\n\nconst replies = [\n  \"Yes please, by 3pm if you can. I will merge it into the release notes.\",\n  \"Sounds good, thanks!\",\n  \"Perfect, adding it to the board now.\",\n  \"Works for me. Ping me when it is ready for review.\",\n];\n\nconst sampleFiles = [\"changelog-draft.md\", \"social-crop-1080.png\", \"metrics-oct.csv\", \"launch-checklist.pdf\"];\nconst palette = [\"#2f7bff\", \"#9b6bff\", \"#ff7a59\", \"#22b07d\", \"#e0a526\", \"#e5508a\", \"#16a3b8\"];\n\nfunction hash(s: string) {\n  let h = 0;\n  for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0;\n  return h >>> 0;\n}\nfunction initials(name: string) {\n  const p = name.split(/\\s+/).filter(Boolean);\n  return ((p[0]?.[0] ?? \"\") + (p[1]?.[0] ?? \"\")).toUpperCase();\n}\n\nconst css = `\n.hb-ye5 {\n  --hb-ye5-accent: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  height: 600px;\n  overflow: hidden;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 16px;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 14px;\n  line-height: 1.45;\n}\n.hb-ye5 *, .hb-ye5 *::before, .hb-ye5 *::after { box-sizing: border-box; }\n.hb-ye5-shell { display: grid; grid-template-columns: 1fr; height: 100%; }\n.hb-ye5-list { display: none; flex-direction: column; min-height: 0; border-right: 1px solid rgba(255,255,255,.08); background: #0d0d0d; }\n.hb-ye5-list-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }\n.hb-ye5-list-h h2 { margin: 0; font-size: 16px; font-weight: 600; }\n.hb-ye5-search { display: flex; align-items: center; gap: 8px; height: 32px; margin: 0 12px 8px; padding: 0 10px; border: 1px solid #222; border-radius: 8px; background: #111; color: #737373; }\n.hb-ye5-search:focus-within { outline: 2px solid var(--hb-ye5-accent); outline-offset: 1px; }\n.hb-ye5-search svg { width: 14px; height: 14px; flex: none; }\n.hb-ye5-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 13px; outline: none; }\n.hb-ye5-convs { flex: 1; overflow: auto; padding: 0 8px 10px; scrollbar-width: thin; scrollbar-color: #262626 transparent; }\n.hb-ye5-sec { padding: 12px 8px 6px; color: #737373; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }\n.hb-ye5-conv { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; width: 100%; margin: 0; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color .15s ease; }\n.hb-ye5-conv:hover { background: #151515; }\n.hb-ye5-conv[aria-selected=\"true\"] { background: #1a1a1a; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }\n.hb-ye5-conv:focus-visible, .hb-ye5-ib:focus-visible, .hb-ye5-send:focus-visible, .hb-ye5-chipx:focus-visible { outline: 2px solid var(--hb-ye5-accent); outline-offset: 1px; }\n.hb-ye5-hash { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #1a1a1a; color: #8f8f8f; font-size: 15px; font-weight: 600; }\n.hb-ye5-av { position: relative; display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 999px; color: #fff; font-size: 11.5px; font-weight: 700; }\n.hb-ye5-av[data-online]::after { content: \"\"; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border: 2px solid #0d0d0d; border-radius: 999px; background: #4b4b4b; }\n.hb-ye5-av[data-online=\"true\"]::after { background: #3ccf91; }\n.hb-ye5-conv-main { min-width: 0; }\n.hb-ye5-conv-name { overflow: hidden; font-size: 13.5px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }\n.hb-ye5-conv[data-unread=\"true\"] .hb-ye5-conv-name { font-weight: 700; }\n.hb-ye5-conv-prev { overflow: hidden; color: #737373; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }\n.hb-ye5-badge { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--hb-ye5-accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; }\n.hb-ye5-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }\n.hb-ye5-th { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }\n.hb-ye5-th-main { flex: 1; min-width: 0; }\n.hb-ye5-th-name { font-size: 15px; font-weight: 600; }\n.hb-ye5-th-topic { overflow: hidden; color: #8f8f8f; font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }\n.hb-ye5-stack { display: flex; }\n.hb-ye5-stack .hb-ye5-av { width: 26px; height: 26px; margin-left: -7px; border: 2px solid #0a0a0a; font-size: 9.5px; }\n.hb-ye5-stack .hb-ye5-av:first-child { margin-left: 0; }\n.hb-ye5-ib { display: grid; place-items: center; width: 32px; height: 32px; flex: none; margin: 0; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #a1a1a1; cursor: pointer; }\n.hb-ye5-ib:hover { border-color: #262626; background: #141414; color: #ededed; }\n.hb-ye5-ib svg { width: 17px; height: 17px; }\n.hb-ye5-msgs { flex: 1; overflow: auto; padding: 8px 18px 14px; scrollbar-width: thin; scrollbar-color: #262626 transparent; }\n.hb-ye5-day { position: relative; margin: 14px 0 8px; text-align: center; }\n.hb-ye5-day::before { content: \"\"; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: rgba(255,255,255,.07); }\n.hb-ye5-day span { position: relative; padding: 3px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 999px; background: #0a0a0a; color: #8f8f8f; font-size: 11.5px; font-weight: 500; }\n.hb-ye5-grp { display: flex; gap: 10px; margin-top: 12px; animation: hb-ye5-in .32s cubic-bezier(.2,.8,.2,1) both; }\n.hb-ye5-grp[data-mine=\"true\"] { flex-direction: row-reverse; }\n.hb-ye5-grp .hb-ye5-av { width: 30px; height: 30px; margin-top: 18px; }\n.hb-ye5-col { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: min(76%, 520px); min-width: 0; }\n.hb-ye5-grp[data-mine=\"true\"] .hb-ye5-col { align-items: flex-end; }\n.hb-ye5-who { display: flex; gap: 8px; padding: 0 4px 2px; font-size: 12px; }\n.hb-ye5-who b { font-weight: 600; }\n.hb-ye5-who span { color: #737373; }\n.hb-ye5-bubble { padding: 8px 12px; border-radius: 4px 14px 14px 4px; background: #171717; color: #e5e5e5; font-size: 13.5px; overflow-wrap: anywhere; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }\n.hb-ye5-who + .hb-ye5-bubble { border-top-left-radius: 14px; }\n.hb-ye5-grp[data-mine=\"true\"] .hb-ye5-bubble { border-radius: 14px 4px 4px 14px; background: var(--hb-ye5-accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }\n.hb-ye5-grp[data-mine=\"true\"] .hb-ye5-who + .hb-ye5-bubble { border-top-right-radius: 14px; }\n.hb-ye5-file { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: #121212; font-size: 12.5px; }\n.hb-ye5-file i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #9b6bff, var(--hb-ye5-accent)); color: #fff; font-style: normal; font-size: 9px; font-weight: 700; text-transform: uppercase; }\n.hb-ye5-file small { display: block; color: #737373; font-size: 11px; }\n.hb-ye5-typing { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: #8f8f8f; font-size: 12px; animation: hb-ye5-in .3s ease both; }\n.hb-ye5-dots { display: inline-flex; gap: 4px; padding: 10px 12px; border-radius: 14px; background: #171717; }\n.hb-ye5-dots i { width: 6px; height: 6px; border-radius: 999px; background: #8f8f8f; animation: hb-ye5-dot 1.2s ease-in-out infinite; }\n.hb-ye5-dots i:nth-child(2) { animation-delay: .15s; }\n.hb-ye5-dots i:nth-child(3) { animation-delay: .3s; }\n.hb-ye5-composer { margin: 0 14px 14px; padding: 8px; border: 1px solid #262626; border-radius: 14px; background: #111; transition: border-color .15s ease, box-shadow .15s ease; }\n.hb-ye5-composer:focus-within { border-color: color-mix(in srgb, var(--hb-ye5-accent) 60%, #262626); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-ye5-accent) 16%, transparent); }\n.hb-ye5-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 8px; }\n.hb-ye5-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 4px 0 6px; border: 1px solid rgba(255,255,255,.09); border-radius: 8px; background: #181818; font-size: 12px; animation: hb-ye5-pop .22s cubic-bezier(.2,1.4,.4,1) both; }\n.hb-ye5-chip i { width: 16px; height: 16px; border-radius: 4px; background: linear-gradient(135deg, #f2a93b, #ff6f5e); }\n.hb-ye5-chipx { display: grid; place-items: center; width: 20px; height: 20px; margin: 0; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #8f8f8f; cursor: pointer; }\n.hb-ye5-chipx:hover { background: #2a2a2a; color: #fff; }\n.hb-ye5-chipx svg { width: 12px; height: 12px; }\n.hb-ye5-input { display: block; width: 100%; min-height: 22px; max-height: 120px; margin: 0; padding: 4px 6px; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 13.5px; line-height: 1.5; resize: none; outline: none; }\n.hb-ye5-input::placeholder { color: #666; }\n.hb-ye5-tools { display: flex; align-items: center; gap: 2px; padding-top: 4px; }\n.hb-ye5-tools .hb-ye5-ib { width: 30px; height: 30px; }\n.hb-ye5-hint { margin-left: auto; margin-right: 8px; color: #555; font-size: 11.5px; }\n.hb-ye5-send { display: inline-flex; align-items: center; gap: 6px; height: 30px; margin: 0; padding: 0 12px; border: 0; border-radius: 8px; background: var(--hb-ye5-accent); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s ease, transform .15s ease; }\n.hb-ye5-send:disabled { opacity: .4; cursor: default; }\n.hb-ye5-send:not(:disabled):active { transform: scale(.96); }\n.hb-ye5-send svg { width: 14px; height: 14px; }\n@keyframes hb-ye5-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }\n@keyframes hb-ye5-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }\n@keyframes hb-ye5-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }\n@container (min-width: 680px) {\n  .hb-ye5-shell { grid-template-columns: 260px 1fr; }\n  .hb-ye5-list { display: flex; }\n}\n@container (max-width: 480px) {\n  .hb-ye5-hint, .hb-ye5-stack { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ye5 *, .hb-ye5 *::before, .hb-ye5 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nfunction Icon({ d }: { d: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n      <path d={d} />\n    </svg>\n  );\n}\n\nfunction Avatar({ name, online }: { name: string; online?: boolean }) {\n  return (\n    <span className=\"hb-ye5-av\" data-online={online === undefined ? undefined : online} style={{ background: palette[hash(name) % palette.length] }} aria-hidden=\"true\">\n      {initials(name)}\n    </span>\n  );\n}\n\nexport function AppChatInbox({\n  conversations: conversationsProp = defaultConversations,\n  me = \"Maya Okafor\",\n  defaultConversationId,\n  defaultDraft = \"\",\n  defaultAttachments = [],\n  accent = \"#2f7bff\",\n  onSend,\n  onConversationChange,\n  className,\n  style,\n  ...rest\n}: AppChatInboxProps) {\n  const [convs, setConvs] = React.useState<AppChatConversation[]>(conversationsProp);\n  const [activeId, setActiveId] = React.useState(defaultConversationId ?? conversationsProp[0]?.id);\n  const [draft, setDraft] = React.useState(defaultDraft);\n  const [attachments, setAttachments] = React.useState<string[]>(defaultAttachments);\n  const [query, setQuery] = React.useState(\"\");\n  const counter = React.useRef(0);\n  const timers = React.useRef<number[]>([]);\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const inputRef = React.useRef<HTMLTextAreaElement>(null);\n  const convRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());\n\n  const active = convs.find((c) => c.id === activeId) ?? convs[0];\n  const filtered = convs.filter((c) => c.name.toLowerCase().includes(query.trim().toLowerCase()));\n  const channels = filtered.filter((c) => c.kind === \"channel\");\n  const dms = filtered.filter((c) => c.kind === \"dm\");\n  const ordered = [...channels, ...dms];\n\n  React.useEffect(() => () => timers.current.forEach((t) => window.clearTimeout(t)), []);\n\n  React.useEffect(() => {\n    const el = scrollRef.current;\n    if (el) el.scrollTop = el.scrollHeight;\n  }, [active?.id, active?.messages.length, active?.typing]);\n\n  const pick = (id: string) => {\n    setActiveId(id);\n    setConvs((list) => list.map((c) => (c.id === id ? { ...c, unread: 0 } : c)));\n    onConversationChange?.(id);\n  };\n\n  const send = () => {\n    const text = draft.trim();\n    if (!active || (!text && !attachments.length)) return;\n    counter.current += 1;\n    const n = counter.current;\n    const msg: AppChatMessage = { id: `me-${n}`, author: me, text, time: \"Now\", day: \"Today\", attachments: attachments.length ? attachments : undefined };\n    const convId = active.id;\n    const other = active.kind === \"dm\" ? active.name : active.typing ?? (active.members ?? []).find((m) => m !== me) ?? active.name;\n    setConvs((list) => list.map((c) => (c.id === convId ? { ...c, typing: undefined, messages: [...c.messages, msg] } : c)));\n    setDraft(\"\");\n    setAttachments([]);\n    onSend?.(convId, msg);\n    timers.current.push(window.setTimeout(() => {\n      setConvs((list) => list.map((c) => (c.id === convId ? { ...c, typing: other } : c)));\n    }, 700));\n    timers.current.push(window.setTimeout(() => {\n      setConvs((list) => list.map((c) => (c.id === convId ? { ...c, typing: undefined, messages: [...c.messages, { id: `re-${n}`, author: other, text: replies[(n - 1) % replies.length], time: \"Now\", day: \"Today\" }] } : c)));\n    }, 2600));\n  };\n\n  const attach = () => {\n    const next = sampleFiles.find((f) => !attachments.includes(f));\n    if (next) setAttachments((a) => [...a, next]);\n    inputRef.current?.focus();\n  };\n\n  const onConvKey = (e: React.KeyboardEvent, index: number) => {\n    if (e.key !== \"ArrowDown\" && e.key !== \"ArrowUp\") return;\n    e.preventDefault();\n    const next = ordered[index + (e.key === \"ArrowDown\" ? 1 : -1)];\n    if (next) {\n      pick(next.id);\n      convRefs.current.get(next.id)?.focus();\n    }\n  };\n\n  const groups: { day: string; runs: { author: string; items: AppChatMessage[] }[] }[] = [];\n  for (const m of active?.messages ?? []) {\n    let g = groups[groups.length - 1];\n    if (!g || g.day !== m.day) {\n      g = { day: m.day, runs: [] };\n      groups.push(g);\n    }\n    const run = g.runs[g.runs.length - 1];\n    if (run && run.author === m.author) run.items.push(m);\n    else g.runs.push({ author: m.author, items: [m] });\n  }\n\n  const renderConv = (c: AppChatConversation) => {\n    const last = c.messages[c.messages.length - 1];\n    const idx = ordered.indexOf(c);\n    return (\n      <button\n        key={c.id}\n        ref={(el) => { if (el) convRefs.current.set(c.id, el); else convRefs.current.delete(c.id); }}\n        type=\"button\"\n        role=\"option\"\n        aria-selected={c.id === active?.id}\n        tabIndex={c.id === active?.id ? 0 : -1}\n        className=\"hb-ye5-conv\"\n        data-unread={!!c.unread}\n        onClick={() => pick(c.id)}\n        onKeyDown={(e) => onConvKey(e, idx)}\n      >\n        {c.kind === \"channel\" ? <span className=\"hb-ye5-hash\" aria-hidden=\"true\">#</span> : <Avatar name={c.name} online={!!c.online} />}\n        <span className=\"hb-ye5-conv-main\">\n          <span className=\"hb-ye5-conv-name\" style={{ display: \"block\" }}>{c.name}</span>\n          <span className=\"hb-ye5-conv-prev\" style={{ display: \"block\" }}>\n            {c.typing ? \"typing...\" : last ? `${last.author === me ? \"You\" : last.author.split(\" \")[0]}: ${last.text || \"sent a file\"}` : \"No messages yet\"}\n          </span>\n        </span>\n        {c.unread ? <span className=\"hb-ye5-badge\" aria-label={`${c.unread} unread`}>{c.unread}</span> : <span />}\n      </button>\n    );\n  };\n\n  return (\n    <div className={[\"hb-ye5\", className].filter(Boolean).join(\" \")} style={{ \"--hb-ye5-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-app-chat-inbox\" precedence=\"default\">{css}</style>\n      <div className=\"hb-ye5-shell\">\n        <nav className=\"hb-ye5-list\" aria-label=\"Conversations\">\n          <div className=\"hb-ye5-list-h\">\n            <h2>Northwind</h2>\n            <button type=\"button\" className=\"hb-ye5-ib\" aria-label=\"New message\"><Icon d=\"M4 20h4L19 9l-4-4L4 16v4Zm10-14 4 4\" /></button>\n          </div>\n          <label className=\"hb-ye5-search\">\n            <Icon d=\"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm9 2-4-4\" />\n            <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder=\"Jump to...\" aria-label=\"Search conversations\" />\n          </label>\n          <div className=\"hb-ye5-convs\" role=\"listbox\" aria-label=\"Conversation list\">\n            {channels.length > 0 && <div className=\"hb-ye5-sec\">Channels</div>}\n            {channels.map(renderConv)}\n            {dms.length > 0 && <div className=\"hb-ye5-sec\">Direct messages</div>}\n            {dms.map(renderConv)}\n          </div>\n        </nav>\n        {active && (\n          <section className=\"hb-ye5-thread\" aria-label={active.name}>\n            <header className=\"hb-ye5-th\">\n              {active.kind === \"channel\" ? <span className=\"hb-ye5-hash\" aria-hidden=\"true\">#</span> : <Avatar name={active.name} online={!!active.online} />}\n              <div className=\"hb-ye5-th-main\">\n                <div className=\"hb-ye5-th-name\">{active.name}</div>\n                <div className=\"hb-ye5-th-topic\">{active.kind === \"channel\" ? active.topic ?? `${active.members?.length ?? 0} members` : active.online ? \"Active now\" : \"Away\"}</div>\n              </div>\n              {active.members && (\n                <div className=\"hb-ye5-stack\" aria-label={`${active.members.length} members`}>\n                  {active.members.slice(0, 4).map((m) => <Avatar key={m} name={m} />)}\n                </div>\n              )}\n              <button type=\"button\" className=\"hb-ye5-ib\" aria-label=\"Start a call\"><Icon d=\"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a1 1 0 0 1-1 1A16 16 0 0 1 4 5a1 1 0 0 1 1-1Z\" /></button>\n              <button type=\"button\" className=\"hb-ye5-ib\" aria-label=\"Search in conversation\"><Icon d=\"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm9 2-4-4\" /></button>\n            </header>\n            <div className=\"hb-ye5-msgs\" ref={scrollRef} role=\"log\" aria-live=\"polite\" aria-label=\"Messages\">\n              {groups.map((g) => (\n                <div key={g.day}>\n                  <div className=\"hb-ye5-day\"><span>{g.day}</span></div>\n                  {g.runs.map((run) => {\n                    const mine = run.author === me;\n                    return (\n                      <div className=\"hb-ye5-grp\" data-mine={mine} key={run.items[0].id}>\n                        <Avatar name={run.author} />\n                        <div className=\"hb-ye5-col\">\n                          <div className=\"hb-ye5-who\"><b>{mine ? \"You\" : run.author}</b><span>{run.items[0].time}</span></div>\n                          {run.items.map((m) => (\n                            <React.Fragment key={m.id}>\n                              {m.text && <div className=\"hb-ye5-bubble\">{m.text}</div>}\n                              {m.attachments?.map((a) => (\n                                <div className=\"hb-ye5-file\" key={a}>\n                                  <i>{a.split(\".\").pop()}</i>\n                                  <span>{a}<small>Shared file</small></span>\n                                </div>\n                              ))}\n                            </React.Fragment>\n                          ))}\n                        </div>\n                      </div>\n                    );\n                  })}\n                </div>\n              ))}\n              {active.typing && (\n                <div className=\"hb-ye5-typing\" aria-live=\"polite\">\n                  <Avatar name={active.typing} />\n                  <span className=\"hb-ye5-dots\" aria-hidden=\"true\"><i /><i /><i /></span>\n                  <span>{active.typing.split(\" \")[0]} is typing</span>\n                </div>\n              )}\n            </div>\n            <form className=\"hb-ye5-composer\" onSubmit={(e) => { e.preventDefault(); send(); }}>\n              {attachments.length > 0 && (\n                <div className=\"hb-ye5-chips\" aria-label=\"Attachments\">\n                  {attachments.map((a) => (\n                    <span className=\"hb-ye5-chip\" key={a}>\n                      <i aria-hidden=\"true\" />\n                      {a}\n                      <button type=\"button\" className=\"hb-ye5-chipx\" aria-label={`Remove ${a}`} onClick={() => setAttachments((list) => list.filter((x) => x !== a))}><Icon d=\"M6 6l12 12M18 6 6 18\" /></button>\n                    </span>\n                  ))}\n                </div>\n              )}\n              <textarea\n                ref={inputRef}\n                className=\"hb-ye5-input\"\n                rows={1}\n                value={draft}\n                placeholder={`Message ${active.kind === \"channel\" ? \"#\" : \"\"}${active.name}`}\n                aria-label=\"Message\"\n                onChange={(e) => setDraft(e.target.value)}\n                onKeyDown={(e) => {\n                  if (e.key === \"Enter\" && !e.shiftKey && !e.nativeEvent.isComposing) {\n                    e.preventDefault();\n                    send();\n                  }\n                }}\n              />\n              <div className=\"hb-ye5-tools\">\n                <button type=\"button\" className=\"hb-ye5-ib\" aria-label=\"Attach file\" onClick={attach}><Icon d=\"M20 11.5l-8 8a5 5 0 0 1-7-7l8.5-8.5a3.5 3.5 0 0 1 5 5L10 17.5a2 2 0 0 1-3-3l7.5-7.5\" /></button>\n                <button type=\"button\" className=\"hb-ye5-ib\" aria-label=\"Mention someone\" onClick={() => { setDraft((d) => `${d}@`); inputRef.current?.focus(); }}><Icon d=\"M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0Zm0 0v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-4 7.5\" /></button>\n                <span className=\"hb-ye5-hint\">Enter to send, Shift + Enter for a new line</span>\n                <button type=\"submit\" className=\"hb-ye5-send\" disabled={!draft.trim() && !attachments.length}>Send<Icon d=\"M5 12h14m-6-6 6 6-6 6\" /></button>\n              </div>\n            </form>\n          </section>\n        )}\n      </div>\n    </div>\n  );\n}\n\nexport default AppChatInbox;\n"
    }
  ]
}