{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notification-center",
  "title": "Notification center",
  "description": "A bell with how many are unread, which opens the notifications grouped by day, with All and Unread tabs, as a popover or, unless motion is reduced, a bottom sheet on a phone. Three variants: short rows for lots of small news, a feed with actions in its rows, and an inbox archived down to empty with Undo.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/icon-tile.json",
    "https://kinoui.com/r/animated-number.json",
    "https://kinoui.com/r/avatar.json",
    "https://kinoui.com/r/badge.json",
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/empty.json",
    "https://kinoui.com/r/tabs.json",
    "https://kinoui.com/r/tooltip.json",
    "https://kinoui.com/r/announce.json",
    "https://kinoui.com/r/count-badge.json",
    "https://kinoui.com/r/controllable.json",
    "https://kinoui.com/r/dates.json",
    "https://kinoui.com/r/flow.json",
    "https://kinoui.com/r/highlight.json",
    "https://kinoui.com/r/popover.json",
    "https://kinoui.com/r/refs.json",
    "https://kinoui.com/r/settle.json",
    "https://kinoui.com/r/swap.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/notification-center/notification-center.tsx",
      "content": "'use client'\n\nimport { Button, buttonVariants } from '@/registry/components/kino/button'\nimport type {\n  NotificationItem,\n  NotificationTab,\n} from '@/registry/components/kino/notification-center/notification-list'\nimport {\n  type Archived,\n  MarkAllRead,\n  NotificationActions,\n  NotificationArchive,\n  type NotificationCenterProps as ShellProps,\n  NotificationMedia,\n  NotificationOpen,\n  NotificationReadToggle,\n  NotificationRow,\n  NotificationShell,\n  NotificationTime,\n  useCenter,\n  useRow,\n} from '@/registry/components/kino/notification-center/notification-parts'\nimport { PopoverFooter } from '@/registry/components/kino/popover'\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from '@/registry/components/kino/tooltip'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { announce } from '@/registry/lib/announce'\nimport { settle } from '@/registry/lib/settle'\nimport { Swap } from '@/registry/lib/swap'\nimport { type ComponentProps, type ReactNode, useId, useState } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A bell with how many are unread, which opens the notifications grouped by\n * day, with All and Unread tabs: a popover, or a bottom sheet on a phone\n * unless motion is reduced. Nothing is marked read by being seen, only by opening a row, its own\n * button, or Mark all as read. Three variants:\n *\n * - `triage`, the default: short rows, many to a screen, for a product that\n *   sends a lot of small news. Under the pointer the time gives way to the\n *   row's button.\n * - `feed`: led by the people in it, what they wrote quoted under them, and\n *   a notification's `actions` as buttons in its row (accept an invite,\n *   approve a review), whose result stays on the row.\n * - `inbox`: notifications are archived once dealt with, down to \"You're\n *   all caught up\", and come back with Undo until the panel closes.\n *\n *   <NotificationCenter\n *     notifications={notifications}\n *     onNotificationsChange={(next, change) => save(next, change)}\n *     footer={<NotificationSettingsLink href='/settings/notifications' />}\n *   />\n */\n\ntype NotificationCenterVariant = 'triage' | 'feed' | 'inbox'\n\ntype NotificationCenterProps = ShellProps & {\n  /** How the rows read and what they do: see above. */\n  variant?: NotificationCenterVariant\n}\n\n/** Each tab's empty state, in each variant's words. */\nconst EMPTY: Record<\n  NotificationCenterVariant,\n  Record<NotificationTab, { title: string; description: string }>\n> = {\n  triage: {\n    all: {\n      title: 'No notifications yet',\n      description: 'When someone assigns or mentions you, it shows here.',\n    },\n    unread: {\n      title: 'You’re all caught up',\n      description: 'Nothing new since you last looked.',\n    },\n  },\n  feed: {\n    all: {\n      title: 'No notifications yet',\n      description: 'Mentions, replies and invites from your team show here.',\n    },\n    unread: {\n      title: 'You’re all caught up',\n      description: 'Nothing new since you last looked.',\n    },\n  },\n  inbox: {\n    all: { title: 'You’re all caught up', description: 'New notifications show here.' },\n    unread: {\n      title: 'Nothing unread',\n      description: 'Read notifications wait in All until you archive them.',\n    },\n  },\n}\n\nfunction NotificationCenter({\n  variant = 'triage',\n  footer,\n  onOpenChange,\n  ...props\n}: NotificationCenterProps) {\n  // What Inbox's archives took, which Undo puts back, until the panel closes.\n  const [taken, setTaken] = useState<Archived[]>([])\n  const inbox = variant === 'inbox'\n  return (\n    <NotificationShell\n      {...props}\n      onOpenChange={(open, details) => {\n        onOpenChange?.(open, details)\n        if (!open && !details.canceled) setTaken([])\n      }}\n      // Archives made while Undo shows come back together.\n      onArchived={(archived) => setTaken((was) => [...was, archived])}\n      header={inbox ? InboxHeader : MarkAllReadHeader}\n      empty={EMPTY[variant]}\n      footer={inbox ? undefined : footer}\n      below={\n        inbox ? (\n          <InboxFooter taken={taken} onDone={() => setTaken([])}>\n            {footer}\n          </InboxFooter>\n        ) : null\n      }\n      row={(item) =>\n        variant === 'feed' ? (\n          <FeedRow key={item.id} item={item} />\n        ) : inbox ? (\n          <InboxRow key={item.id} item={item} />\n        ) : (\n          <TriageRow key={item.id} item={item} />\n        )\n      }\n    />\n  )\n}\n\n/** One line or two: who or what it's from, what happened and when. */\nfunction TriageRow({ item }: { item: NotificationItem }) {\n  return (\n    <NotificationRow\n      item={item}\n      // Half a row's padding: many to a screen.\n      className='min-h-(--control-height) items-center px-(--notification-inset) py-[calc(var(--row-padding)*0.5)]'\n    >\n      <NotificationMedia size='xs' />\n      <NotificationOpen className='line-clamp-2 flex-1 leading-snug'>\n        {item.title}\n      </NotificationOpen>\n      {/* Under the pointer the row's button covers the time; on a touch screen they sit side by side. */}\n      <NotificationTime className='transition-opacity duration-(--motion-enter-duration) ease-(--motion-enter-fade-easing) [@media(hover:hover)]:group-has-[:focus-visible]/notification:opacity-0 [@media(hover:hover)]:group-hover/notification:opacity-0' />\n      <NotificationActions className='-ms-1.5 -me-1 [@media(hover:hover)]:end-1.5 [@media(hover:hover)]:top-1/2 [@media(hover:hover)]:-translate-y-1/2 [@media(hover:hover)]:m-0'>\n        <NotificationReadToggle />\n      </NotificationActions>\n    </NotificationRow>\n  )\n}\n\n/** Who did it, large, then what they did, when, what they wrote and the row's own actions. */\nfunction FeedRow({ item }: { item: NotificationItem }) {\n  return (\n    <NotificationRow\n      item={item}\n      className='items-start gap-3 px-(--notification-inset) py-[calc(var(--row-padding)*0.8)]'\n    >\n      <NotificationMedia size='md' />\n      <div className='flex min-w-0 flex-1 flex-col gap-1.5'>\n        {/* Clear of the row's button, which floats at its end. */}\n        <div className='flex min-w-0 flex-col gap-0.5 [@media(hover:hover)]:pe-7'>\n          <NotificationOpen className='leading-snug'>{item.title}</NotificationOpen>\n          <NotificationTime />\n        </div>\n        {item.description ? (\n          // What they wrote, quoted: a line on its start edge sets it apart from the title,\n          // and in its own direction: an English comment in a Hebrew app reads left to right.\n          <p\n            dir='auto'\n            className='text-muted-foreground border-border line-clamp-3 border-s-2 ps-2.5 leading-snug text-pretty'\n          >\n            {item.description}\n          </p>\n        ) : null}\n        {item.actions?.length ? <FeedActions item={item} /> : null}\n      </div>\n      <NotificationActions className='-me-1 -mt-0.5 [@media(hover:hover)]:end-1.5 [@media(hover:hover)]:top-1.5 [@media(hover:hover)]:m-0'>\n        <NotificationReadToggle />\n      </NotificationActions>\n    </NotificationRow>\n  )\n}\n\n/** The title and a line of detail, the time, and the row's buttons: read and Archive. */\nfunction InboxRow({ item }: { item: NotificationItem }) {\n  return (\n    <NotificationRow\n      item={item}\n      className='items-start gap-2.5 px-(--notification-inset) py-[calc(var(--row-padding)*0.65)]'\n    >\n      <NotificationMedia className='mt-px' />\n      {/* Clear of the fade at the start of the row's buttons, which float over the time. */}\n      <div className='flex min-w-0 flex-1 flex-col gap-0.5 [@media(hover:hover)]:pe-3'>\n        <NotificationOpen className='line-clamp-2 leading-snug'>\n          {item.title}\n        </NotificationOpen>\n        {item.description ? (\n          // In its own direction, as words someone wrote may be.\n          <span dir='auto' className='text-muted-foreground min-w-0 truncate text-xs'>\n            {item.description}\n          </span>\n        ) : null}\n      </div>\n      <NotificationTime className='pt-0.5' />\n      <NotificationActions className='-me-1 [@media(hover:hover)]:end-1.5 [@media(hover:hover)]:top-1.5 [@media(hover:hover)]:m-0'>\n        <NotificationReadToggle />\n        <NotificationArchive />\n      </NotificationActions>\n    </NotificationRow>\n  )\n}\n\n/**\n * A row's own buttons, such as Accept and Decline. While one runs both are\n * held, and the one pressed shows it is working; once it has run they give\n * way to what it did, kept on the notification as its `done`, and the row\n * is read. In Unread the row stays, so what it did can be seen. One that\n * fails leaves them as they were, and says so.\n */\nfunction FeedActions({ item }: { item: NotificationItem }) {\n  const { act, focusRow } = useCenter()\n  const { titleId } = useRow()\n  const [running, setRunning] = useState<number | null>(null)\n  // The one that failed last, said under the buttons until it works or another is pressed.\n  const [failed, setFailed] = useState<number | null>(null)\n  const failureId = useId()\n  const actions = item.actions ?? []\n  const finished = item.done === undefined ? null : actions[item.done]\n  return (\n    <div className='relative z-10 pt-0.5'>\n      <Swap block id={finished ? 'done' : 'actions'} align='start'>\n        {finished ? (\n          <p className='text-muted-foreground flex items-center gap-1.5 text-sm'>\n            <IconPlaceholder\n              lucide='CheckIcon'\n              tabler='IconCheck'\n              phosphor='CheckIcon'\n              remixicon='RiCheckLine'\n              hugeicons='Tick02Icon'\n              aria-hidden\n              className='text-success-foreground size-4'\n            />\n            {finished.done}\n          </p>\n        ) : (\n          <div className='flex flex-col gap-1.5'>\n            <div className='flex flex-wrap gap-2'>\n              {actions.map((action, index) => (\n                <Button\n                  key={action.label}\n                  size='sm'\n                  variant={action.variant === 'secondary' ? 'outline' : 'default'}\n                  // The failure, once there, describes the button it came from.\n                  aria-describedby={\n                    failed === index ? `${titleId} ${failureId}` : titleId\n                  }\n                  loading={running === index}\n                  disabled={running !== null && running !== index}\n                  onClick={() => {\n                    setRunning(index)\n                    // A retry keeps the line, so the row doesn't shrink and grow back.\n                    if (failed !== index) setFailed(null)\n                    settle(action.run, (ok) => {\n                      setRunning(null)\n                      if (!ok) {\n                        setFailed(index)\n                        announce(failure(action.label))\n                        return\n                      }\n                      // Its buttons are about to go: focus on them goes to the row's title.\n                      const active = document.activeElement\n                      const row = `[data-notification-id=\"${CSS.escape(item.id)}\"]`\n                      if (!active || active === document.body || active.closest(row)) {\n                        focusRow(item)\n                      }\n                      announce(typeof action.done === 'string' ? action.done : 'Done')\n                      act(item, index)\n                    })\n                  }}\n                >\n                  {action.label}\n                </Button>\n              ))}\n            </div>\n            {/* Rolls in and out, as the done line does, and the row glides to its height. */}\n            <Swap block id={failed === null ? 'none' : `failed-${failed}`} align='start'>\n              {failed === null || !actions[failed] ? null : (\n                <p id={failureId} className='text-destructive text-xs'>\n                  {failure(actions[failed].label)}\n                </p>\n              )}\n            </Swap>\n          </div>\n        )}\n      </Swap>\n    </div>\n  )\n}\n\n/** What a row says when its action fails: Couldn't accept. Try again. */\nfunction failure(label: string) {\n  return `Couldn’t ${label.toLowerCase()}. Try again.`\n}\n\n/** Mark all as read, with its words: Triage's and Feed's header. */\nfunction MarkAllReadHeader({\n  unread,\n  markAllRead,\n}: {\n  unread: number\n  markAllRead: () => void\n}) {\n  return <MarkAllRead unread={unread} onClick={markAllRead} />\n}\n\n/** Mark all as read and Archive all read, as icons named by their tooltips. */\nfunction InboxHeader({\n  unread,\n  markAllRead,\n}: {\n  unread: number\n  markAllRead: () => void\n}) {\n  const { archiveRead, readCount } = useArchiveRead()\n  return (\n    <div className='-me-1.5 flex shrink-0 items-center gap-0.5'>\n      <HeaderButton\n        label='Mark all as read'\n        disabled={unread === 0}\n        onClick={markAllRead}\n      >\n        <IconPlaceholder\n          lucide='CheckCheckIcon'\n          tabler='IconChecks'\n          phosphor='ChecksIcon'\n          remixicon='RiCheckDoubleLine'\n          hugeicons='TickDouble02Icon'\n          aria-hidden\n        />\n      </HeaderButton>\n      <HeaderButton\n        label='Archive all read'\n        disabled={readCount === 0}\n        onClick={archiveRead}\n      >\n        <IconPlaceholder\n          lucide='ArchiveIcon'\n          tabler='IconArchive'\n          phosphor='ArchiveIcon'\n          remixicon='RiArchiveLine'\n          hugeicons='Archive02Icon'\n          aria-hidden\n        />\n      </HeaderButton>\n    </div>\n  )\n}\n\n/** Archives every read notification at once. */\nfunction useArchiveRead() {\n  const { archive, items } = useCenter()\n  const read = items.filter((item) => item.read)\n  return { archiveRead: () => archive(read), readCount: read.length }\n}\n\nfunction HeaderButton({\n  label,\n  disabled,\n  onClick,\n  children,\n}: {\n  label: string\n  disabled: boolean\n  onClick: () => void\n  children: ReactNode\n}) {\n  return (\n    <Tooltip>\n      <TooltipTrigger\n        render={\n          <Button\n            variant='ghost'\n            size='icon-sm'\n            aria-label={label}\n            disabled={disabled}\n            focusableWhenDisabled\n            onClick={onClick}\n            className='text-muted-foreground'\n          />\n        }\n      >\n        {children}\n      </TooltipTrigger>\n      <TooltipContent>{label}</TooltipContent>\n    </Tooltip>\n  )\n}\n\n/**\n * The footer: the app's own, such as a settings link, which gives way after\n * an archive to how many were archived and Undo, there until the panel\n * closes, so no one has to race a timer to it.\n */\nfunction InboxFooter({\n  taken,\n  onDone,\n  children,\n}: {\n  taken: Archived[]\n  onDone: () => void\n  children?: ReactNode\n}) {\n  const { restore } = useCenter()\n  const count = taken.reduce((sum, archived) => sum + archived.items.length, 0)\n  if (count === 0 && !children) return null\n  return (\n    <PopoverFooter className='min-h-(--control-height) @xs:justify-start'>\n      <Swap\n        block\n        fill\n        id={count > 0 ? 'undo' : 'footer'}\n        align='start'\n        className='min-w-0 flex-1'\n      >\n        {count > 0 ? (\n          <div className='flex w-full items-center gap-2'>\n            <span className='text-muted-foreground min-w-0 flex-1 text-sm tabular-nums'>\n              {count === 1 ? 'Archived' : `${count} archived`}\n            </span>\n            <Button\n              size='sm'\n              variant='ghost'\n              className='-me-2'\n              onClick={() => {\n                restore(taken)\n                onDone()\n              }}\n            >\n              <IconPlaceholder\n                lucide='Undo2Icon'\n                tabler='IconArrowBackUp'\n                phosphor='ArrowUUpLeftIcon'\n                remixicon='RiArrowGoBackLine'\n                hugeicons='Undo02Icon'\n                aria-hidden\n              />\n              Undo\n            </Button>\n          </div>\n        ) : (\n          <div className='flex w-full items-center'>{children}</div>\n        )}\n      </Swap>\n    </PopoverFooter>\n  )\n}\n\n/**\n * A link to the notification settings, with its icon, for the footer: a\n * link in a ghost Button's look, its icon lined up with the title.\n */\nfunction NotificationSettingsLink({\n  className,\n  children = 'Notification settings',\n  ...props\n}: ComponentProps<'a'>) {\n  return (\n    <a\n      data-slot='notification-settings-link'\n      className={cn(\n        buttonVariants({ variant: 'ghost', size: 'sm' }),\n        // Its padding and its 1px border, so its icon lines up with the title.\n        'text-muted-foreground -ms-[calc(var(--control-padding)+1px)]',\n        className,\n      )}\n      {...props}\n    >\n      <IconPlaceholder\n        lucide='SettingsIcon'\n        tabler='IconSettings'\n        phosphor='GearIcon'\n        remixicon='RiSettings3Line'\n        hugeicons='Settings01Icon'\n        aria-hidden\n      />\n      {children}\n    </a>\n  )\n}\n\nexport { NotificationCenter, NotificationSettingsLink }\nexport type { NotificationCenterProps, NotificationCenterVariant }\nexport type {\n  NotificationAction,\n  NotificationChange,\n  NotificationItem,\n  NotificationTab,\n} from '@/registry/components/kino/notification-center/notification-list'\n",
      "type": "registry:component",
      "target": "@components/kino/notification-center/notification-center.tsx"
    },
    {
      "path": "registry/components/kino/notification-center/notification-parts.tsx",
      "content": "'use client'\n\nimport { AnimatedNumber } from '@/registry/components/kino/animated-number'\nimport { Badge } from '@/registry/components/kino/badge'\nimport { Button } from '@/registry/components/kino/button'\nimport {\n  Empty,\n  EmptyDescription,\n  EmptyHeader,\n  EmptyMedia,\n  EmptyTitle,\n} from '@/registry/components/kino/empty'\nimport { IconTile } from '@/registry/components/kino/icon-tile'\nimport { NotificationBell } from '@/registry/components/kino/notification-center/notification-bell'\nimport {\n  type Archived,\n  dayGroups,\n  focusAfterLeaving,\n  markRead,\n  type NotificationChange,\n  restoreItems,\n  type NotificationItem,\n  type NotificationTab,\n  unreadCount,\n  visibleItems,\n  withoutItems,\n} from '@/registry/components/kino/notification-center/notification-list'\nimport {\n  Popover,\n  PopoverBody,\n  PopoverClose,\n  PopoverContent,\n  PopoverFooter,\n  PopoverHeader,\n  type PopoverOpenChangeDetails,\n  PopoverTitle,\n} from '@/registry/components/kino/popover'\nimport { Tabs, TabsList, TabsPanel, TabsTab } from '@/registry/components/kino/tabs'\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipGroup,\n  TooltipTrigger,\n} from '@/registry/components/kino/tooltip'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { announce } from '@/registry/lib/announce'\nimport { useControllable } from '@/registry/lib/controllable'\nimport {\n  clockTime,\n  dayHeading,\n  instantLabel,\n  timeAgo,\n  useLocale,\n  useNow,\n  wallClock,\n} from '@/registry/lib/dates'\nimport { useFlow } from '@/registry/lib/flow'\nimport {\n  followPointer,\n  itemMatching,\n  rowHighlightClassName,\n  tintedRowTextClassName,\n} from '@/registry/lib/highlight'\nimport { markMounted, mergeRefs } from '@/registry/lib/refs'\nimport { Swap } from '@/registry/lib/swap'\nimport {\n  type ComponentType,\n  createContext,\n  type MouseEvent,\n  type ReactNode,\n  use,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * What every notification center shares: the bell, the panel it opens (a\n * popover, or a bottom sheet on a phone unless motion is reduced), the All and Unread tabs, the days\n * the notifications fall on, and the rows' common parts. A row that leaves\n * fades where it was on `exit` while the rows under it glide up on `layout`\n * to close its gap (`useFlow`), and focus moves to the row that takes its\n * place. Nothing is marked read by being seen: only by opening the row, its\n * own button, or Mark all as read.\n */\n\nexport interface NotificationCenterProps {\n  /** The notifications, newest or oldest first. Give them with `onNotificationsChange` to own them. */\n  notifications?: NotificationItem[]\n  defaultNotifications?: NotificationItem[]\n  /** Called with the notifications after a change, and what changed, so the app can tell its server. */\n  onNotificationsChange?: (\n    notifications: NotificationItem[],\n    change: NotificationChange,\n  ) => void\n  /** Called when a row is opened, before its link is followed; the panel then closes. */\n  onOpenNotification?: (item: NotificationItem, event: MouseEvent) => void\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean, details: PopoverOpenChangeDetails) => void\n  /** Which notifications show: `all`, or only those still `unread`. */\n  tab?: NotificationTab\n  defaultTab?: NotificationTab\n  onTabChange?: (tab: NotificationTab) => void\n  /** Whether the popover holds the focus and makes the page inert. The sheet on a phone always does. */\n  modal?: boolean\n  /** What the notifications are called: the panel's title and the bell's name. */\n  title?: string\n  /** Under the list, such as a link to the notification settings. */\n  footer?: ReactNode\n  /** The locale times and days are written in; the browser's when left out. */\n  locale?: string\n  /** The time zone days start in; the visitor's own when left out. */\n  timeZone?: string\n  /** For the bell's place in the page. */\n  className?: string\n}\n\ninterface CenterContextValue {\n  locale: string\n  timeZone: string | undefined\n  /** The time now, in ms, a minute at a time; null until the browser has it. */\n  now: number | null\n  /** Every notification, in the order given. */\n  items: NotificationItem[]\n  setRead: (item: NotificationItem, read: boolean) => void\n  /** Records that the row's action at `index` was taken: it is read, and in Unread it stays until the tab changes. */\n  act: (item: NotificationItem, index: number) => void\n  /** Takes these out of the list, to be put back with `restore`. */\n  archive: (archived: NotificationItem[]) => void\n  /** Puts back what archives took, latest last, each where it was, and focuses the first. */\n  restore: (taken: readonly Archived[]) => void\n  /** Moves focus to the row's title, once it has rendered. */\n  focusRow: (item: NotificationItem) => void\n  open: (item: NotificationItem, event: MouseEvent) => void\n  /** Whether a row can be opened: it has a link, or the app listens. */\n  opens: (item: NotificationItem) => boolean\n}\n\nconst CenterContext = createContext<CenterContextValue | null>(null)\n\nfunction useCenter() {\n  const center = use(CenterContext)\n  if (!center)\n    throw new Error('A notification part must sit inside its NotificationCenter.')\n  return center\n}\n\n/** The id of the row's title, which names it and describes its buttons. */\nconst RowContext = createContext<{\n  item: NotificationItem\n  titleId: string\n} | null>(null)\n\nfunction useRow() {\n  const row = use(RowContext)\n  if (!row) throw new Error('A notification row part must sit inside NotificationRow.')\n  return row\n}\n\n/** The words a screen reader hears after a change. */\nfunction changeMessage(change: NotificationChange): string {\n  const many = change.ids.length > 1\n  if (change.reason === 'read') return many ? 'All marked as read' : 'Marked as read'\n  if (change.reason === 'unread') return 'Marked as unread'\n  if (change.reason === 'action') return ''\n  // Undo is at the bottom of the panel, which Tab reaches last.\n  if (change.reason === 'archive')\n    return `${many ? `${change.ids.length} archived` : 'Archived'}. Undo is at the bottom of the panel.`\n  return many ? `${change.ids.length} restored` : 'Restored'\n}\n\n/**\n * The notification center's state, the bell and the panel, which each\n * variant fills: `Header` is what acts on every row, beside the title;\n * `row` draws one notification; `below` sits over the footer, such as an\n * undo.\n */\nfunction NotificationShell({\n  notifications,\n  defaultNotifications = [],\n  onNotificationsChange,\n  onOpenNotification,\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  tab: tabProp,\n  defaultTab = 'all',\n  onTabChange,\n  modal,\n  title = 'Notifications',\n  footer,\n  locale: localeProp,\n  timeZone,\n  className,\n  header: Header,\n  row,\n  empty,\n  below,\n  onArchived,\n}: NotificationCenterProps & {\n  /** A component, not a function called here: it gets handlers that read the latest list. */\n  header: ComponentType<{ unread: number; markAllRead: () => void }>\n  row: (item: NotificationItem) => ReactNode\n  /** The empty state of each tab. */\n  empty: Record<NotificationTab, { title: string; description: string }>\n  below?: ReactNode\n  /** Called with what an archive took, so a direction can offer it back. */\n  onArchived?: (taken: Archived) => void\n}) {\n  const locale = useLocale(localeProp)\n  const now = useNow()\n  const [items, setItems] = useControllable(\n    notifications,\n    defaultNotifications,\n    undefined,\n  )\n  const [tab, changeTab] = useControllable(tabProp, defaultTab, onTabChange)\n  // Rows answered in Unread stay there, read, until the tab changes or the panel closes, so\n  // what the answer did can be seen.\n  const [kept, setKept] = useState<readonly string[]>([])\n  const setTab = (next: NotificationTab) => {\n    setKept([])\n    changeTab(next)\n  }\n  const [isOpen, setOpen] = useControllable<boolean, [PopoverOpenChangeDetails]>(\n    openProp,\n    defaultOpen,\n    onOpenChange,\n  )\n  const changeOpen = (next: boolean, details: PopoverOpenChangeDetails) => {\n    setOpen(next, details)\n    if (!next && !details.canceled) setKept([])\n  }\n  // What a handler that runs later, such as an action's once its promise\n  // settles, works on: the list and the tab as they are then.\n  const latest = useRef({ items, tab })\n  useLayoutEffect(() => {\n    latest.current = { items, tab }\n  })\n  const unread = unreadCount(items)\n\n  // A notification that arrives is heard, with how many are unread now; one\n  // marked unread again, or put back, is not new.\n  const known = useRef<Set<string> | null>(null)\n  useEffect(() => {\n    const seen = known.current\n    known.current = new Set([...(seen ?? []), ...items.map((item) => item.id)])\n    if (!seen) return\n    const arrived = items.filter((item) => !item.read && !seen.has(item.id)).length\n    if (arrived === 0) return\n    announce(\n      `${arrived === 1 ? 'New notification' : `${arrived} new notifications`}. ${unreadCount(items)} unread`,\n    )\n  }, [items])\n\n  const change = (next: NotificationItem[], what: NotificationChange) => {\n    setItems(next)\n    latest.current = { ...latest.current, items: next }\n    onNotificationsChange?.(next, what)\n    announce(changeMessage(what))\n  }\n\n  // Where focus goes once a row that had it leaves.\n  const [focusNext, setFocusNext] = useState<{\n    id: string | null\n    control: string\n  } | null>(null)\n  const leave = (leaving: string[]) => {\n    const active = document.activeElement\n    const from = active?.closest<HTMLElement>('[data-notification-id]')\n    if (!from) return\n    const now = latest.current\n    const order = visibleItems(now.items, now.tab, kept).map((item) => item.id)\n    setFocusNext({\n      id: focusAfterLeaving(order, leaving, from.dataset.notificationId ?? ''),\n      control: active?.getAttribute('data-notification-control') ?? 'open',\n    })\n  }\n\n  const api: CenterContextValue = {\n    locale,\n    timeZone,\n    now,\n    setRead: (item, read) => {\n      const now = latest.current\n      if (now.tab === 'unread' && read) leave([item.id])\n      change(markRead(now.items, [item.id], read), {\n        reason: read ? 'read' : 'unread',\n        ids: [item.id],\n      })\n    },\n    act: (item, index) => {\n      const now = latest.current\n      if (now.tab === 'unread') setKept((was) => [...was, item.id])\n      change(\n        now.items.map((each) =>\n          each.id === item.id ? { ...each, read: true, done: index } : each,\n        ),\n        { reason: 'action', ids: [item.id], action: index },\n      )\n    },\n    items,\n    archive: (archived) => {\n      if (archived.length === 0) return\n      const now = latest.current\n      const ids = archived.map((item) => item.id)\n      leave(ids)\n      // Where each was, put back first to last so each lands where it was.\n      const at = ids.map((id) => now.items.findIndex((item) => item.id === id))\n      const order = at.map((_, index) => index).sort((a, b) => at[a] - at[b])\n      change(withoutItems(now.items, ids), { reason: 'archive', ids })\n      onArchived?.({\n        items: order.map((index) => archived[index]),\n        at: order.map((index) => at[index]),\n      })\n    },\n    restore: (taken) => {\n      const ids = taken.flatMap((archived) => archived.items.map((item) => item.id))\n      change(restoreItems(latest.current.items, taken), { reason: 'restore', ids })\n      // What restored them is about to go: focus goes to the first one back.\n      setFocusNext({ id: ids[0] ?? null, control: 'open' })\n    },\n    focusRow: (item) => setFocusNext({ id: item.id, control: 'open' }),\n    open: (item, event) => {\n      if (!item.read)\n        change(markRead(latest.current.items, [item.id], true), {\n          reason: 'read',\n          ids: [item.id],\n        })\n      onOpenNotification?.(item, event)\n    },\n    opens: (item) => item.href !== undefined || onOpenNotification !== undefined,\n  }\n\n  const markAllRead = () => {\n    const now = latest.current\n    const ids = now.items.filter((item) => !item.read).map((item) => item.id)\n    if (ids.length === 0) return\n    if (now.tab === 'unread') leave(ids)\n    // Rows kept in Unread after an answer go with the rest.\n    setKept([])\n    change(markRead(now.items, ids, true), { reason: 'read', ids })\n  }\n\n  return (\n    <CenterContext value={api}>\n      {/* A bottom sheet on a phone, where a list this long needs the screen's width, unless motion is reduced. */}\n      <Popover open={isOpen} onOpenChange={changeOpen} modal={modal} presentation='auto'>\n        <NotificationBell\n          count={unread}\n          title={title}\n          locale={localeProp}\n          className={className}\n        />\n        <PopoverContent\n          align='end'\n          // The picked tab, so a press of Enter on opening never marks everything read.\n          initialFocus='[role=tab][aria-selected=true]'\n          // A header, a body that scrolls and a footer. The popover is always\n          // `--notification-center-height` tall, so the other tab never resizes it;\n          // the sheet follows what it holds.\n          className='min-h-0 w-(--notification-center-width,24rem) gap-0 p-0 group-data-[presentation=popover]/popup:h-(--notification-center-height,32rem) group-data-[presentation=popover]/popup:max-h-[calc(var(--popup-available-height)-2px)]'\n        >\n          <Tabs\n            value={tab}\n            onValueChange={(next) => setTab(next as NotificationTab)}\n            className='contents'\n          >\n            <PopoverHeader className='shrink-0 gap-3 px-(--popover-edge) pt-(--popover-edge) pb-2 group-data-[presentation=sheet]/popup:pb-5'>\n              <div className='flex min-h-(--control-height-sm) items-center gap-2'>\n                <PopoverTitle className='min-w-0 flex-1 text-base wrap-break-word'>\n                  {title}\n                </PopoverTitle>\n                <Header unread={unread} markAllRead={markAllRead} />\n              </div>\n              <TabsList\n                aria-label='Filter notifications'\n                className='self-stretch *:w-full'\n              >\n                <TabsTab value='all' className='flex-1'>\n                  All\n                </TabsTab>\n                <TabsTab value='unread' className='flex-1'>\n                  Unread\n                  {/* The count fades away at none as the label glides back to the middle, and back. */}\n                  <Swap id={unread > 0 ? 'count' : 'none'} className='-ms-(--button-gap)'>\n                    {unread > 0 ? (\n                      <span className='ps-(--button-gap)'>\n                        <Badge variant='secondary'>\n                          <AnimatedNumber value={unread} locale={localeProp} />\n                        </Badge>\n                      </span>\n                    ) : null}\n                  </Swap>\n                </TabsTab>\n              </TabsList>\n            </PopoverHeader>\n            {/* Rows sit `--notification-inset` in from the body's sides, so their content lines up with the title. */}\n            <PopoverBody className='min-h-full px-[calc(var(--popover-edge)-var(--notification-inset))] pb-1.5 [--notification-inset:calc(var(--control-padding)*0.8)]'>\n              {(['all', 'unread'] as const).map((value) => (\n                <TabsPanel\n                  key={value}\n                  value={value}\n                  // Its rows take focus, and the body scrolls by keyboard: the panel needn't, except empty.\n                  tabIndex={visibleItems(items, value, kept).length > 0 ? -1 : 0}\n                  className='relative flex min-h-64 flex-1 flex-col rounded-(--list-radius)'\n                >\n                  <NotificationList\n                    items={visibleItems(items, value, kept)}\n                    empty={empty[value]}\n                    row={row}\n                    focusNext={focusNext}\n                    onFocused={() => setFocusNext(null)}\n                  />\n                </TabsPanel>\n              ))}\n            </PopoverBody>\n          </Tabs>\n          {below}\n          {footer ? (\n            // From the start edge, as in the popover, not a dialog's buttons at the end.\n            <PopoverFooter className='@xs:justify-start'>{footer}</PopoverFooter>\n          ) : null}\n        </PopoverContent>\n      </Popover>\n    </CenterContext>\n  )\n}\n\n/**\n * Each item that moves in a list: a day's heading or a row. It glides to a\n * new place on `layout`. One that leaves folds up from its bottom edge as\n * the rows under it rise into its place, both on `layout`, fading on\n * `exit`; one that arrives unfolds as the rows under it make room, fading\n * in on `enter`. So no two rows ever show over each other. Its clip rests\n * a little past its edges, where a focus ring reaches.\n */\nconst flowItemClassName = cn(\n  // Under reduced motion one that arrives only fades in, and one that leaves goes at once, as\n  // the rows under it take its place at once.\n  '[clip-path:inset(-0.25rem)] [transition:translate_var(--motion-layout-duration)_var(--motion-layout-easing),clip-path_var(--motion-layout-duration)_var(--motion-layout-easing),opacity_var(--motion-enter-duration)_var(--motion-enter-easing)] group-data-mounted/notifications:starting:opacity-0 group-data-mounted/notifications:starting:[clip-path:inset(0_0_100%_0)] data-[flow=start]:[transition:opacity_var(--motion-enter-duration)_var(--motion-enter-easing)] motion-reduce:[clip-path:none]! motion-reduce:[transition:opacity_var(--motion-enter-duration)_var(--motion-enter-easing)]',\n  'data-leaving:opacity-0 data-leaving:[clip-path:inset(0_0_100%_0)] data-leaving:[transition:clip-path_var(--motion-layout-duration)_var(--motion-layout-easing),opacity_var(--motion-exit-duration)_var(--motion-exit-easing)] motion-reduce:data-leaving:[transition:none]',\n)\n\n/** One tab's notifications, under the days they fall on, or its empty state. */\nfunction NotificationList({\n  items,\n  empty,\n  row,\n  focusNext,\n  onFocused,\n}: {\n  items: NotificationItem[]\n  empty: { title: string; description: string }\n  row: (item: NotificationItem) => ReactNode\n  focusNext: { id: string | null; control: string } | null\n  onFocused: () => void\n}) {\n  const { locale, timeZone, now } = useCenter()\n  const { frame, row: list } = useFlow<HTMLDivElement, HTMLDivElement>(\n    '[data-slot=notification], [data-slot=notification-day]',\n    'data-flow-key',\n  )\n  const layerRef = useRef<HTMLSpanElement>(null)\n  useEffect(() => {\n    const area = list.current\n    if (!area || !layerRef.current) return\n    return followPointer(area, layerRef.current, {\n      itemOf: itemMatching(area, '[data-slot=notification][data-opens]'),\n      focus: true,\n    })\n  }, [list])\n\n  // Focus goes to the row that took the place of the one that left, or to\n  // the tab once none is left.\n  useLayoutEffect(() => {\n    if (!focusNext) return\n    const area = list.current\n    if (!area) return\n    const next = focusNext.id\n      ? area.querySelector<HTMLElement>(\n          `[data-notification-id=\"${CSS.escape(focusNext.id)}\"]:not([data-leaving])`,\n        )\n      : null\n    const target =\n      next?.querySelector<HTMLElement>(\n        `[data-notification-control=\"${CSS.escape(focusNext.control)}\"]`,\n      ) ??\n      next?.querySelector<HTMLElement>('[data-notification-control]') ??\n      area\n        .closest('[role=dialog]')\n        ?.querySelector<HTMLElement>('[role=tab][aria-selected=true]')\n    target?.focus()\n    onFocused()\n  }, [focusNext, list, onFocused])\n\n  const today = now === null ? null : wallClock(now, timeZone).slice(0, 10)\n  const groups = dayGroups(items, timeZone)\n  const listRef = useMemo(() => mergeRefs(list, markMounted), [list])\n  return (\n    <TooltipGroup>\n      <div\n        ref={frame}\n        className='[overflow-clip-margin:0.25rem] overflow-clip transition-[height] duration-(--motion-layout-duration) ease-(--motion-layout-easing) motion-reduce:transition-none'\n      >\n        <div\n          ref={listRef}\n          data-slot='notification-list'\n          className='group/notifications relative isolate flex flex-col'\n        >\n          {groups.flatMap((group) => [\n            <h3\n              key={`day-${group.day}`}\n              data-slot='notification-day'\n              data-flow-key={`day-${group.day}`}\n              className={cn(\n                'text-muted-foreground px-(--notification-inset) pt-3 pb-1 text-xs font-medium first:pt-1.5',\n                flowItemClassName,\n              )}\n            >\n              {today === null ? ' ' : dayHeading(group.day, today, locale)}\n            </h3>,\n            ...group.items.map((item) => row(item)),\n          ])}\n          <span ref={layerRef} aria-hidden className={rowHighlightClassName} />\n        </div>\n      </div>\n      {/* Over the list's place, so the rows leaving don't push it: it rises in once they've gone. */}\n      <Empty show={items.length === 0} className='absolute inset-0 [--empty-wait:1]'>\n        <EmptyHeader>\n          <EmptyMedia variant='icon'>\n            <IconPlaceholder\n              lucide='InboxIcon'\n              tabler='IconInbox'\n              phosphor='TrayIcon'\n              remixicon='RiInboxLine'\n              hugeicons='InboxIcon'\n              aria-hidden\n            />\n          </EmptyMedia>\n          {/* oxlint-disable-next-line jsx-a11y/heading-has-content -- the title's text goes in through the part's children. */}\n          <EmptyTitle render={<h3 />}>{empty.title}</EmptyTitle>\n          <EmptyDescription>{empty.description}</EmptyDescription>\n        </EmptyHeader>\n      </Empty>\n    </TooltipGroup>\n  )\n}\n\n/**\n * One notification: an article named by its title. It takes the rows' tint\n * under the pointer when it opens, and a ring when its title has focus. The\n * title, `NotificationOpen`, covers the whole row; the row's own buttons\n * sit above it.\n */\nfunction NotificationRow({\n  item,\n  className,\n  children,\n}: {\n  item: NotificationItem\n  className?: string\n  children: ReactNode\n}) {\n  const { opens } = useCenter()\n  const titleId = useId()\n  const context = useMemo(() => ({ item, titleId }), [item, titleId])\n  return (\n    <RowContext value={context}>\n      <article\n        data-slot='notification'\n        data-notification-id={item.id}\n        data-flow-key={item.id}\n        data-read={item.read ? '' : undefined}\n        data-opens={opens(item) ? '' : undefined}\n        aria-labelledby={titleId}\n        className={cn(\n          'group/notification relative flex min-w-0 gap-2.5 rounded-(--list-radius) text-sm',\n          // Muted text under the highlight's tint is darker, so it keeps 4.5:1 on it.\n          tintedRowTextClassName,\n          'has-[[data-notification-control=open]:focus-visible]:ring-ring/50 has-[[data-notification-control=open]:focus-visible]:ring-3 has-[[data-notification-control=open]:focus-visible]:ring-inset',\n          flowItemClassName,\n          className,\n        )}\n      >\n        {children}\n      </article>\n    </RowContext>\n  )\n}\n\n/**\n * The row's title, which opens it: a link to its `href`, or a button when\n * the app opens it. It covers the whole row, so the row opens wherever it is\n * pressed, except on its own buttons. \"Unread\" is read before it.\n */\nfunction NotificationOpen({\n  className,\n  children,\n}: {\n  className?: string\n  children: ReactNode\n}) {\n  const { open, opens } = useCenter()\n  const { item, titleId } = useRow()\n  const label = (\n    <>\n      {item.read ? null : <span className='sr-only'>Unread: </span>}\n      {children}\n    </>\n  )\n  // Unread shows by more than its colour, with no mark beside it: an unread\n  // title is in full colour and medium, a read one muted and regular, its\n  // names included. A title that changes weight may wrap differently, so\n  // the rows below glide to make room.\n  const textClassName = cn(\n    'min-w-0 transition-colors duration-(--motion-press-duration) ease-(--motion-press-fade-easing)',\n    item.read ? 'text-muted-foreground **:font-normal' : 'text-foreground font-medium',\n    className,\n  )\n  if (!opens(item)) {\n    return (\n      <span id={titleId} className={textClassName}>\n        {label}\n      </span>\n    )\n  }\n  const cover =\n    'focus-visible:outline-hidden after:absolute after:inset-0 after:rounded-[inherit] forced-colors:focus-visible:after:outline-2 forced-colors:focus-visible:after:outline-[Highlight]'\n  // Opening a row closes the panel. The app hears of it once the click has\n  // closed it, from the box around, so its `preventDefault()`, such as a\n  // router's, stops the link but never the close.\n  return (\n    // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- the click comes from the link or button inside, which answers the keys too.\n    <span className='contents' onClick={(event) => open(item, event)}>\n      {item.href !== undefined ? (\n        <PopoverClose\n          render={({ children, ...props }) => (\n            <a {...props} href={item.href}>\n              {children}\n            </a>\n          )}\n          id={titleId}\n          data-notification-control='open'\n          className={cn(textClassName, cover)}\n        >\n          {label}\n        </PopoverClose>\n      ) : (\n        <PopoverClose\n          id={titleId}\n          data-notification-control='open'\n          className={cn(textClassName, cover, 'text-start')}\n        >\n          {label}\n        </PopoverClose>\n      )}\n    </span>\n  )\n}\n\n/**\n * Who did it, or the app's icon, in an Icon tile of `size`: an Avatar fills\n * it as a circle, an icon sits on the neutral tint.\n */\nfunction NotificationMedia({\n  className,\n  size = 'sm',\n}: {\n  className?: string\n  size?: 'xs' | 'sm' | 'md'\n}) {\n  const { item } = useRow()\n  if (!item.media) return null\n  return (\n    <IconTile\n      data-notification-media=''\n      size={size}\n      className={cn(\n        // An avatar keeps its own round shape and fills the tile.\n        'has-data-[slot=avatar]:rounded-full *:data-[slot=avatar]:size-full',\n        className,\n      )}\n    >\n      {item.media}\n    </IconTile>\n  )\n}\n\n/** When it happened: how long ago today, the time of day before; the whole date and time on hover. */\nfunction NotificationTime({ className }: { className?: string }) {\n  const { locale, timeZone, now } = useCenter()\n  const { item } = useRow()\n  const today = now === null ? null : wallClock(now, timeZone).slice(0, 10)\n  const day = wallClock(item.at, timeZone).slice(0, 10)\n  const text =\n    now === null\n      ? ' '\n      : ((day === today ? timeAgo(item.at, now, locale) : null) ??\n        clockTime(item.at, locale, timeZone))\n  return (\n    <time\n      dateTime={item.at}\n      // Its words run the way the locale writes them, whatever the page's direction: 4:05 PM.\n      dir='auto'\n      title={now === null ? undefined : instantLabel(item.at, locale, timeZone)}\n      className={cn(\n        'text-muted-foreground shrink-0 text-xs whitespace-nowrap tabular-nums',\n        className,\n      )}\n    >\n      {text}\n    </time>\n  )\n}\n\n/** A row's own icon button, described by its title, with its name as a tooltip. */\nfunction NotificationButton({\n  label,\n  control,\n  onClick,\n  children,\n}: {\n  label: string\n  /** Which of the row's buttons it is, so focus lands on the same one in the next row. */\n  control: string\n  onClick: () => void\n  children: ReactNode\n}) {\n  const { titleId } = useRow()\n  return (\n    <Tooltip>\n      <TooltipTrigger\n        render={\n          <Button\n            variant='ghost'\n            size='icon-sm'\n            aria-label={label}\n            aria-describedby={titleId}\n            data-notification-control={control}\n            onClick={onClick}\n          />\n        }\n      >\n        {children}\n      </TooltipTrigger>\n      <TooltipContent>{label}</TooltipContent>\n    </Tooltip>\n  )\n}\n\n/** Marks the row read, or unread again. */\nfunction NotificationReadToggle() {\n  const { setRead } = useCenter()\n  const { item } = useRow()\n  return (\n    <NotificationButton\n      label={item.read ? 'Mark as unread' : 'Mark as read'}\n      control='read'\n      onClick={() => setRead(item, !item.read)}\n    >\n      {item.read ? (\n        <IconPlaceholder\n          lucide='MailIcon'\n          tabler='IconMail'\n          phosphor='EnvelopeIcon'\n          remixicon='RiMailLine'\n          hugeicons='Mail01Icon'\n          aria-hidden\n        />\n      ) : (\n        <IconPlaceholder\n          lucide='CheckIcon'\n          tabler='IconCheck'\n          phosphor='CheckIcon'\n          remixicon='RiCheckLine'\n          hugeicons='Tick02Icon'\n          aria-hidden\n        />\n      )}\n    </NotificationButton>\n  )\n}\n\n/** Takes the row out of the list, until undone. */\nfunction NotificationArchive() {\n  const { archive } = useCenter()\n  const { item } = useRow()\n  return (\n    <NotificationButton label='Archive' control='archive' onClick={() => archive([item])}>\n      <IconPlaceholder\n        lucide='ArchiveIcon'\n        tabler='IconArchive'\n        phosphor='ArchiveIcon'\n        remixicon='RiArchiveLine'\n        hugeicons='Archive02Icon'\n        aria-hidden\n      />\n    </NotificationButton>\n  )\n}\n\n/**\n * The row's buttons. With a pointer that hovers they float over the row's\n * end (place them with `className`) while the row is hovered or shows focus,\n * on the panel's colour, so they cover what's under them rather than\n * squeezing the row; on a touch screen they always show, in the row.\n */\nfunction NotificationActions({\n  className,\n  children,\n}: {\n  className?: string\n  children: ReactNode\n}) {\n  return (\n    <div\n      data-slot='notification-actions'\n      className={cn(\n        'relative z-10 flex shrink-0 items-center gap-0.5 transition-opacity duration-(--motion-enter-duration) ease-(--motion-enter-fade-easing)',\n        // A short fade on its start edge, so the words it covers trail off under it.\n        '[@media(hover:hover)]:bg-popover [@media(hover:hover)]:absolute [@media(hover:hover)]:rounded-(--control-radius) [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-has-[:focus-visible]/notification:opacity-100 [@media(hover:hover)]:group-hover/notification:opacity-100 [@media(hover:hover)]:before:from-popover [@media(hover:hover)]:before:pointer-events-none [@media(hover:hover)]:before:absolute [@media(hover:hover)]:before:inset-y-0 [@media(hover:hover)]:before:-start-4 [@media(hover:hover)]:before:w-4 [@media(hover:hover)]:before:bg-linear-to-l rtl:[@media(hover:hover)]:before:bg-linear-to-r',\n        className,\n      )}\n    >\n      {children}\n    </div>\n  )\n}\n\n/** Mark all as read, with its icon; held while none is unread. */\nfunction MarkAllRead({ unread, onClick }: { unread: number; onClick: () => void }) {\n  return (\n    <Button\n      variant='ghost'\n      size='sm'\n      disabled={unread === 0}\n      focusableWhenDisabled\n      onClick={onClick}\n      className='text-muted-foreground shrink-0'\n    >\n      <IconPlaceholder\n        lucide='CheckCheckIcon'\n        tabler='IconChecks'\n        phosphor='ChecksIcon'\n        remixicon='RiCheckDoubleLine'\n        hugeicons='TickDouble02Icon'\n        aria-hidden\n      />\n      Mark all as read\n    </Button>\n  )\n}\n\nexport {\n  MarkAllRead,\n  NotificationActions,\n  NotificationArchive,\n  NotificationButton,\n  NotificationMedia,\n  NotificationOpen,\n  NotificationReadToggle,\n  NotificationRow,\n  NotificationShell,\n  NotificationTime,\n  useCenter,\n  useRow,\n}\nexport type { Archived }\n",
      "type": "registry:component",
      "target": "@components/kino/notification-center/notification-parts.tsx"
    },
    {
      "path": "registry/components/kino/notification-center/notification-bell.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport { bellLabel } from '@/registry/components/kino/notification-center/notification-list'\nimport { PopoverTrigger } from '@/registry/components/kino/popover'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { CountBadge } from '@/registry/lib/count-badge'\n\nimport { cn } from '@/lib/utils'\n\n/**\n * The bell that opens the notifications, with how many are unread on its\n * corner. The count rolls to its new value; at none it shrinks away on\n * `exit`, and comes back on `enter`. A screen reader hears the count in the\n * bell's name, not from the badge.\n */\nfunction NotificationBell({\n  count,\n  title,\n  locale,\n  className,\n}: {\n  count: number\n  /** What the notifications are called, which names the bell: \"Notifications, 3 unread\". */\n  title: string\n  locale?: string\n  className?: string\n}) {\n  return (\n    <span data-slot='notification-bell' className={cn('relative inline-flex', className)}>\n      <PopoverTrigger\n        render={\n          <Button variant='ghost' size='icon' aria-label={bellLabel(title, count)} />\n        }\n      >\n        <IconPlaceholder\n          lucide='BellIcon'\n          tabler='IconBell'\n          phosphor='BellIcon'\n          remixicon='RiNotification3Line'\n          hugeicons='Notification03Icon'\n          aria-hidden\n        />\n      </PopoverTrigger>\n      <CountBadge count={count} locale={locale} />\n    </span>\n  )\n}\n\nexport { NotificationBell }\n",
      "type": "registry:component",
      "target": "@components/kino/notification-center/notification-bell.tsx"
    },
    {
      "path": "registry/components/kino/notification-center/notification-list.ts",
      "content": "import { compareInstants, wallClock } from '@/registry/lib/dates'\nimport type { ReactNode } from 'react'\n\n/*\n * What a notification center holds and works out, outside the DOM: the\n * notifications, which of them a tab shows, how many are unread, the days\n * they fall on, and where focus goes when one leaves.\n */\n\n/** A thing to do from the row itself, such as accepting an invite. */\nexport interface NotificationAction {\n  /** What the button says, such as \"Accept\". */\n  label: string\n  /** The button's look: the row's main action, or one beside it. */\n  variant?: 'primary' | 'secondary'\n  /** Runs when it's pressed; a promise holds the row's buttons until it settles. */\n  run: () => void | Promise<void>\n  /** What the row says once it has run, such as \"You joined Design review\". */\n  done: ReactNode\n}\n\nexport interface NotificationItem {\n  id: string\n  /** When it happened, as an ISO instant: `2026-11-17T09:42:00Z`. */\n  at: string\n  read: boolean\n  /** What happened, such as \"Maya Chen assigned you KIN-142\". It names the row. */\n  title: ReactNode\n  /** A line of detail under the title, such as a comment's first words. */\n  description?: ReactNode\n  /** Who did it, as an Avatar, or an icon for news from the app itself. */\n  media?: ReactNode\n  /** Where opening the row goes. Opening it marks it read. */\n  href?: string\n  /** Things to do from the row, where the direction shows them. */\n  actions?: NotificationAction[]\n  /** Which of its `actions` was taken, by index: the row shows that action's `done`. */\n  done?: number\n}\n\n/** Which notifications show: every one, or only those still unread. */\nexport type NotificationTab = 'all' | 'unread'\n\n/** What changed, so the app can tell its server. */\nexport interface NotificationChange {\n  reason: 'read' | 'unread' | 'action' | 'archive' | 'restore'\n  ids: string[]\n  /** With `action`: which of the row's actions was taken, by index. */\n  action?: number\n}\n\n/** How many are unread. */\nexport function unreadCount(items: readonly NotificationItem[]): number {\n  return items.reduce((count, item) => count + (item.read ? 0 : 1), 0)\n}\n\n/** A count as a badge shows it: up to `max`, then `max+`. */\nexport function countLabel(count: number, max = 99): string {\n  return count > max ? `${max}+` : String(count)\n}\n\n/** The bell's name, with how many are unread: \"Notifications, 3 unread\". */\nexport function bellLabel(title: string, count: number): string {\n  return count > 0 ? `${title}, ${count} unread` : title\n}\n\n/** The notifications `tab` shows, newest first; Unread also shows those `kept` there once read. */\nexport function visibleItems(\n  items: readonly NotificationItem[],\n  tab: NotificationTab,\n  kept: readonly string[] = [],\n): NotificationItem[] {\n  return items\n    .filter((item) => tab === 'all' || !item.read || kept.includes(item.id))\n    .sort((a, b) => compareInstants(b.at, a.at))\n}\n\n/** Notifications that fall on one day (`yyyy-mm-dd`), in the order given. */\nexport interface DayGroup {\n  day: string\n  items: NotificationItem[]\n}\n\n/** `items`, newest first, split into the days they fall on in `timeZone`. */\nexport function dayGroups(\n  items: readonly NotificationItem[],\n  timeZone?: string,\n): DayGroup[] {\n  const groups: DayGroup[] = []\n  for (const item of items) {\n    const day = wallClock(item.at, timeZone).slice(0, 10)\n    const last = groups.at(-1)\n    if (last?.day === day) last.items.push(item)\n    else groups.push({ day, items: [item] })\n  }\n  return groups\n}\n\n/** `items` with those in `ids` marked read, or unread. */\nexport function markRead(\n  items: readonly NotificationItem[],\n  ids: readonly string[],\n  read: boolean,\n): NotificationItem[] {\n  const marked = new Set(ids)\n  return items.map((item) =>\n    marked.has(item.id) && item.read !== read ? { ...item, read } : item,\n  )\n}\n\n/** `items` without those in `ids`. */\nexport function withoutItems(\n  items: readonly NotificationItem[],\n  ids: readonly string[],\n): NotificationItem[] {\n  const gone = new Set(ids)\n  return items.filter((item) => !gone.has(item.id))\n}\n\n/** What one archive took, and where each was in the list then, first to last. */\nexport interface Archived {\n  items: NotificationItem[]\n  at: number[]\n}\n\n/** The items each archive took out of `items`, `taken` in the order they were made, put back where they were. */\nexport function restoreItems(\n  items: readonly NotificationItem[],\n  taken: readonly Archived[],\n): NotificationItem[] {\n  const next = [...items]\n  for (const archived of [...taken].reverse()) {\n    archived.items.forEach((item, index) => {\n      next.splice(Math.min(archived.at[index] ?? next.length, next.length), 0, item)\n    })\n  }\n  return next\n}\n\n/**\n * The row focus goes to when the rows in `leaving` leave a list shown in\n * `order` while focus is on `from`: the next one that stays, else the one\n * before. Null when none stays, or focus wasn't on one that leaves.\n */\nexport function focusAfterLeaving(\n  order: readonly string[],\n  leaving: readonly string[],\n  from: string,\n): string | null {\n  const gone = new Set(leaving)\n  if (!gone.has(from)) return null\n  const at = order.indexOf(from)\n  if (at === -1) return null\n  const after = order.slice(at + 1).find((id) => !gone.has(id))\n  if (after) return after\n  return (\n    order\n      .slice(0, at)\n      .reverse()\n      .find((id) => !gone.has(id)) ?? null\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/kino/notification-center/notification-list.ts"
    }
  ],
  "type": "registry:block"
}