{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notification-inbox",
  "title": "Notification Inbox",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/notification-inbox/NotificationInbox.tsx",
      "content": "import * as React from 'react'\nimport { ActivityIndicator, FlatList, View, useWindowDimensions, type ViewProps } from 'react-native'\nimport { Alert, AlertDescription } from '@/components/ui/alert'\nimport { Button } from '@/components/ui/button'\nimport { ListItem, ListItemContent, ListItemDescription, ListItemTitle, ListSeparator } from '@/components/ui/list'\nimport { SegmentedControl, SegmentedControlItem } from '@/components/ui/segmented-control'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { useThemeColors } from '@/lib/theme'\nimport { cn } from '@/lib/utils'\n\nexport interface NotificationInboxEntry {\n  id: string\n  title: string\n  message?: string\n  source?: string\n  /** A caller-localized timestamp or relative time. */\n  time?: string\n  read: boolean\n}\n\nexport type NotificationInboxFilter = 'all' | 'unread'\n\nconst defaultLabels = {\n  filters: 'Notification filter',\n  all: 'All',\n  unread: 'Unread',\n  read: 'Read',\n  unreadCount: (count: number) => `${count} unread`,\n  empty: 'No notifications yet.',\n  caughtUp: 'You’re caught up.',\n  loading: 'Loading notifications…',\n  reload: 'Try loading again',\n  markAll: 'Mark all as read',\n  markingAll: 'Marking as read…',\n  markAllFailed: 'Could not mark notifications as read. Try again.',\n}\n\nexport interface NotificationInboxProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  /** Display order and read status come from the caller. IDs must be unique. */\n  entries?: readonly NotificationInboxEntry[]\n  filter?: NotificationInboxFilter\n  onFilterChange?: (filter: NotificationInboxFilter) => void\n  onOpen?: (id: string) => void\n  /** Receives the unread IDs shown in the inbox when the action starts. */\n  onMarkAllRead?: (ids: string[]) => void | boolean | Promise<void | boolean>\n  loading?: boolean\n  loadError?: string\n  onRetryLoad?: () => void\n  labels?: Partial<typeof defaultLabels>\n  header?: React.ReactNode\n}\n\nexport function NotificationInbox({\n  className,\n  entries = [],\n  filter,\n  onFilterChange,\n  onOpen,\n  onMarkAllRead,\n  loading = false,\n  loadError,\n  onRetryLoad,\n  labels,\n  header,\n  ...props\n}: NotificationInboxProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const colors = useThemeColors()\n  const { width, fontScale } = useWindowDimensions()\n  const stackMeta = width < 360 || fontScale >= 1.4\n  const [internalFilter, setInternalFilter] = React.useState<NotificationInboxFilter>('all')\n  const shownFilter = filter ?? internalFilter\n  const unread = entries.filter((item) => !item.read)\n  const visible = shownFilter === 'unread' ? unread : entries\n  const [marking, setMarking] = React.useState(false)\n  const [markFailed, setMarkFailed] = React.useState(false)\n  const markRequest = React.useRef(false)\n  const markUnavailable = loading || !!loadError || unread.length === 0\n  const markError = markFailed && !markUnavailable\n  const caughtUp = shownFilter === 'unread' && entries.length > 0 && unread.length === 0\n  useAnnouncement(\n    loading ? copy.loading : loadError || (markError ? copy.markAllFailed : caughtUp ? copy.caughtUp : undefined),\n  )\n\n  async function markAll() {\n    if (!onMarkAllRead || markUnavailable || markRequest.current) return\n    markRequest.current = true\n    setMarking(true)\n    setMarkFailed(false)\n    try {\n      if ((await onMarkAllRead(unread.map(({ id }) => id))) === false) setMarkFailed(true)\n    } catch {\n      setMarkFailed(true)\n    } finally {\n      markRequest.current = false\n      setMarking(false)\n    }\n  }\n\n  return (\n    <View {...props} className={cn('min-h-0 flex-1', className)}>\n      <FlatList\n        data={visible}\n        keyExtractor={(item) => item.id}\n        ItemSeparatorComponent={ListSeparator}\n        contentContainerStyle={{ paddingBottom: 16 }}\n        ListHeaderComponent={\n          <View className=\"gap-3 pb-3\">\n            {header}\n            <SegmentedControl\n              accessibilityLabel={copy.filters}\n              value={shownFilter}\n              onValueChange={(next) => {\n                if (next !== 'all' && next !== 'unread') return\n                if (filter === undefined) setInternalFilter(next)\n                onFilterChange?.(next)\n              }}\n            >\n              <SegmentedControlItem value=\"all\">{copy.all}</SegmentedControlItem>\n              <SegmentedControlItem value=\"unread\">{copy.unread}</SegmentedControlItem>\n            </SegmentedControl>\n            {entries.length ? (\n              <View className=\"flex-row flex-wrap items-center justify-between gap-x-2\">\n                <Text size=\"sm\" variant=\"muted\">\n                  {copy.unreadCount(unread.length)}\n                </Text>\n                {onMarkAllRead ? (\n                  <Button\n                    variant=\"ghost\"\n                    accessibilityLabel={marking ? copy.markingAll : copy.markAll}\n                    loading={marking}\n                    disabled={markUnavailable}\n                    onPress={() => {\n                      void markAll()\n                    }}\n                  >\n                    {marking ? copy.markingAll : copy.markAll}\n                  </Button>\n                ) : null}\n              </View>\n            ) : null}\n            {loadError && !loading ? (\n              <Alert accessibilityRole=\"none\">\n                <AlertDescription>{loadError}</AlertDescription>\n                {onRetryLoad ? (\n                  <Button\n                    variant=\"outline\"\n                    className=\"self-start\"\n                    accessibilityLabel={copy.reload}\n                    onPress={onRetryLoad}\n                  >\n                    {copy.reload}\n                  </Button>\n                ) : null}\n              </Alert>\n            ) : null}\n            {markError ? (\n              <Alert accessibilityRole=\"none\" variant=\"destructive\">\n                <AlertDescription>{copy.markAllFailed}</AlertDescription>\n              </Alert>\n            ) : null}\n            {loading ? (\n              <View className=\"flex-row flex-wrap items-center gap-2\">\n                <ActivityIndicator color={colors.primary} accessible={false} />\n                <Text size=\"sm\" variant=\"muted\">\n                  {copy.loading}\n                </Text>\n              </View>\n            ) : null}\n          </View>\n        }\n        ListEmptyComponent={\n          loading || loadError ? undefined : (\n            <Text className=\"rounded-xl border border-border px-4 py-6 text-center\">\n              {caughtUp ? copy.caughtUp : copy.empty}\n            </Text>\n          )\n        }\n        renderItem={({ item }) => {\n          const context = [item.source, item.time].filter(Boolean).join(' · ')\n          return (\n            <ListItem\n              accessible\n              accessibilityLabel={[\n                item.title,\n                item.message,\n                item.source,\n                item.time,\n                item.read ? copy.read : copy.unread,\n              ]\n                .filter(Boolean)\n                .join(', ')}\n              onPress={onOpen ? () => onOpen(item.id) : undefined}\n              className=\"items-start px-0 py-4\"\n            >\n              <View aria-hidden className={cn('mt-2 size-2 rounded-full', !item.read && 'bg-primary')} />\n              <ListItemContent>\n                {context ? <ListItemDescription>{context}</ListItemDescription> : null}\n                <ListItemTitle className={item.read ? undefined : 'font-semibold'}>{item.title}</ListItemTitle>\n                {item.message ? (\n                  <ListItemDescription numberOfLines={stackMeta || !onOpen ? undefined : 3}>\n                    {item.message}\n                  </ListItemDescription>\n                ) : null}\n              </ListItemContent>\n            </ListItem>\n          )\n        }}\n      />\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/notification-inbox/NotificationInbox.tsx"
    },
    {
      "path": "packages/registry-native/blocks/notification-inbox/index.ts",
      "content": "export {\n  NotificationInbox,\n  type NotificationInboxEntry,\n  type NotificationInboxFilter,\n  type NotificationInboxProps,\n} from './NotificationInbox'\n",
      "type": "registry:block",
      "target": "~/components/blocks/notification-inbox/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/alert.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/list.json",
    "https://native.uipkge.dev/r/native/segmented-control.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/theme.json"
  ],
  "description": "An in-app inbox with all and unread filters, caller-owned read status, and a bulk read action.",
  "categories": [
    "activity",
    "messaging"
  ]
}