{"version":3,"file":"useSystemNotifications.mjs","names":[],"sources":["../../../../../src/components/Notifications/hooks/useSystemNotifications.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport type { Notification, NotificationManagerState } from 'stream-chat';\n\nimport { useChatContext } from '../../../context';\nimport { useStateStore } from '../../../store';\n\nimport { hasSystemNotificationTag } from './useNotificationApi';\n\nexport type UseSystemNotificationsFilter = (notification: Notification) => boolean;\n\nexport type UseSystemNotificationsOptions = {\n  /** Applied after the built-in filter for system-tagged notifications. */\n  filter?: UseSystemNotificationsFilter;\n};\n\n/**\n * Subscribes to `client.notifications` and returns the system banner notifications, which\n * `NotificationList` leaves out of its toasts.\n *\n * @param options.filter - Narrows the system notifications further.\n */\nexport const useSystemNotifications = (\n  options?: UseSystemNotificationsOptions,\n): Notification[] => {\n  const { client } = useChatContext();\n  const selector = useCallback(\n    (state: NotificationManagerState) => {\n      const withSystemTag = state.notifications.filter(hasSystemNotificationTag);\n      const notifications = options?.filter\n        ? withSystemTag.filter(options.filter)\n        : withSystemTag;\n\n      return { notifications };\n    },\n    [options?.filter],\n  );\n\n  const { notifications } = useStateStore(client.notifications.store, selector);\n\n  return notifications;\n};\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,0BACX,YACmB;CACnB,MAAM,EAAE,WAAW,eAAe;CAClC,MAAM,WAAW,aACd,UAAoC;EACnC,MAAM,gBAAgB,MAAM,cAAc,OAAO,wBAAwB;EAKzE,OAAO,EAAE,eAJa,SAAS,SAC3B,cAAc,OAAO,QAAQ,MAAM,IACnC,cAEmB;CACzB,GACA,CAAC,SAAS,MAAM,CAClB;CAEA,MAAM,EAAE,kBAAkB,cAAc,OAAO,cAAc,OAAO,QAAQ;CAE5E,OAAO;AACT"}