{"version":3,"file":"UnreadMessagesSeparator.mjs","names":[],"sources":["../../../../src/components/MessageList/UnreadMessagesSeparator.tsx"],"sourcesContent":["import React from 'react';\nimport {\n  useChannel,\n  useChatContext,\n  useComponentContextIcons,\n  useTranslationContext,\n} from '../../context';\nimport { Button } from '../Button';\nimport { useMessagePaginator } from '../../hooks';\n\nexport const UNREAD_MESSAGE_SEPARATOR_CLASS = 'str-chat__unread-messages-separator';\n\nexport type UnreadMessagesSeparatorProps = {\n  /** Whether to show the unread count. Defaults to `true`. */\n  showCount?: boolean;\n  /** Unread count shown when `showCount` is enabled. */\n  unreadCount?: number;\n};\n\nexport const UnreadMessagesSeparator = ({\n  showCount = true,\n  unreadCount,\n}: UnreadMessagesSeparatorProps) => {\n  const { IconXmark } = useComponentContextIcons();\n  const { t } = useTranslationContext();\n  const channel = useChannel();\n  const { client } = useChatContext();\n  const messagePaginator = useMessagePaginator();\n  return (\n    <div\n      className={UNREAD_MESSAGE_SEPARATOR_CLASS}\n      data-testid='unread-messages-separator'\n    >\n      <div className={'str-chat__unread-messages-separator__text'}>\n        {unreadCount && showCount\n          ? t('messageList.unreadMessagesNotification.unread.text', {\n              count: unreadCount,\n              defaultValue_one: '{{count}} unread',\n              defaultValue_other: '{{count}} unread',\n            })\n          : t(\n              'messageList.unreadMessagesNotification.unreadMessages.text',\n              'Unread messages',\n            )}\n      </div>\n      <Button\n        appearance='ghost'\n        aria-label={t(\n          'messageList.unreadMessagesNotification.markMessagesRead.ariaLabel',\n          'Mark messages as read',\n        )}\n        circular\n        onClick={() => {\n          client.messageDeliveryReporter.throttledMarkRead(channel);\n          messagePaginator.clearUnreadSnapshot();\n        }}\n        size='sm'\n        variant='secondary'\n      >\n        <IconXmark />\n      </Button>\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;AAUA,IAAa,iCAAiC;AAS9C,IAAa,2BAA2B,EACtC,YAAY,MACZ,kBACkC;CAClC,MAAM,EAAE,cAAc,yBAAyB;CAC/C,MAAM,EAAE,MAAM,sBAAsB;CACpC,MAAM,UAAU,WAAW;CAC3B,MAAM,EAAE,WAAW,eAAe;CAClC,MAAM,mBAAmB,oBAAoB;CAC7C,OACE,qBAAC,OAAD;EACE,WAAW;EACX,eAAY;YAFd,CAIE,oBAAC,OAAD;GAAK,WAAW;aACb,eAAe,YACZ,EAAE,sDAAsD;IACtD,OAAO;IACP,kBAAkB;IAClB,oBAAoB;GACtB,CAAC,IACD,EACE,8DACA,iBACF;EACD,CAAA,GACL,oBAAC,QAAD;GACE,YAAW;GACX,cAAY,EACV,qEACA,uBACF;GACA,UAAA;GACA,eAAe;IACb,OAAO,wBAAwB,kBAAkB,OAAO;IACxD,iBAAiB,oBAAoB;GACvC;GACA,MAAK;GACL,SAAQ;aAER,oBAAC,WAAD,CAAY,CAAA;EACN,CAAA,CACL;;AAET"}