{"version":3,"file":"ChannelDetail.mjs","names":[],"sources":["../../../../src/plugins/ChannelDetail/ChannelDetail.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { useState } from 'react';\nimport type { Channel } from 'stream-chat';\n\nimport {\n  SECTION_NAVIGATOR_LAYOUT,\n  SectionNavigator,\n  type SectionNavigatorLayout,\n  type SectionNavigatorNavButtonProps,\n  type SectionNavigatorProps,\n  type SectionNavigatorSection,\n} from './SectionNavigator';\nimport { ChannelDetailNavButton } from './ChannelDetailNavButton';\nimport {\n  ChannelDetailProvider,\n  type ChannelDetailProviderProps,\n} from './ChannelDetailContext';\nimport { ChannelFilesView } from './Views/ChannelFilesView';\nimport { ChannelManagementView } from './Views/ChannelManagementView';\nimport { ChannelMediaView } from './Views/ChannelMediaView';\nimport { ChannelMembersView } from './Views/ChannelMembersView';\nimport { PinnedMessagesView } from './Views/PinnedMessagesView';\nimport { Prompt } from '../../components/Dialog';\nimport { useComponentContextIcons } from '../../context';\nimport { useStableCallback } from '../../utils';\n\nconst ChannelManagementNavButtonIcon = () => {\n  const { IconInfo } = useComponentContextIcons();\n\n  return <IconInfo className='str-chat__channel-detail__action-icon' />;\n};\n\nconst ChannelMembersNavButtonIcon = () => {\n  const { IconUser } = useComponentContextIcons();\n\n  return <IconUser className='str-chat__channel-detail__action-icon' />;\n};\n\nconst PinnedMessagesNavButtonIcon = () => {\n  const { IconPin } = useComponentContextIcons();\n\n  return <IconPin className='str-chat__channel-detail__action-icon' />;\n};\n\nconst ChannelMediaNavButtonIcon = () => {\n  const { IconImage } = useComponentContextIcons();\n\n  return <IconImage className='str-chat__channel-detail__action-icon' />;\n};\n\nconst ChannelFilesNavButtonIcon = () => {\n  const { IconFolder } = useComponentContextIcons();\n\n  return <IconFolder className='str-chat__channel-detail__action-icon' />;\n};\n\nexport const ChannelManagementNavButton = (props: SectionNavigatorNavButtonProps) => (\n  <ChannelDetailNavButton\n    {...props}\n    LeadingIcon={ChannelManagementNavButtonIcon}\n    title='Channel info'\n  />\n);\n\nexport const ChannelMembersNavButton = (props: SectionNavigatorNavButtonProps) => (\n  <ChannelDetailNavButton\n    {...props}\n    LeadingIcon={ChannelMembersNavButtonIcon}\n    title='Members'\n  />\n);\n\nexport const PinnedMessagesNavButton = (props: SectionNavigatorNavButtonProps) => (\n  <ChannelDetailNavButton\n    {...props}\n    LeadingIcon={PinnedMessagesNavButtonIcon}\n    title='Pinned messages'\n  />\n);\n\nexport const ChannelMediaNavButton = (props: SectionNavigatorNavButtonProps) => (\n  <ChannelDetailNavButton\n    {...props}\n    LeadingIcon={ChannelMediaNavButtonIcon}\n    title='Photos & videos'\n  />\n);\n\nexport const ChannelFilesNavButton = (props: SectionNavigatorNavButtonProps) => (\n  <ChannelDetailNavButton\n    {...props}\n    LeadingIcon={ChannelFilesNavButtonIcon}\n    title='Files'\n  />\n);\n\nexport const defaultChannelDetailSections: SectionNavigatorSection[] = [\n  {\n    id: 'channel-info',\n    NavButton: ChannelManagementNavButton,\n    SectionContent: ChannelManagementView,\n  },\n  {\n    id: 'channel-members',\n    NavButton: ChannelMembersNavButton,\n    SectionContent: ChannelMembersView,\n  },\n  {\n    id: 'pinned-messages',\n    NavButton: PinnedMessagesNavButton,\n    SectionContent: PinnedMessagesView,\n  },\n  {\n    id: 'channel-media',\n    NavButton: ChannelMediaNavButton,\n    SectionContent: ChannelMediaView,\n  },\n  {\n    id: 'channel-files',\n    NavButton: ChannelFilesNavButton,\n    SectionContent: ChannelFilesView,\n  },\n];\n\nexport type ChannelDetailProps = Omit<SectionNavigatorProps, 'sections'> & {\n  channel: Channel;\n  /** Closes the channel detail. See `ChannelDetailProviderProps.onClose`. */\n  onClose?: ChannelDetailProviderProps['onClose'];\n  sections?: SectionNavigatorSection[];\n};\n\nexport const ChannelDetail = ({\n  channel,\n  className,\n  defaultLayout = SECTION_NAVIGATOR_LAYOUT.tabs,\n  onClose,\n  onLayoutChange,\n  sections = defaultChannelDetailSections,\n  ...props\n}: ChannelDetailProps) => {\n  const [layout, setLayout] = useState<SectionNavigatorLayout>(defaultLayout);\n\n  // The layout drives the inline-layout class here, and the caller gets every change too. Stable, so\n  // SectionNavigator reports a layout once, even when the caller passes a new `onLayoutChange` on\n  // every render.\n  const handleLayoutChange = useStableCallback((nextLayout: SectionNavigatorLayout) => {\n    setLayout(nextLayout);\n    onLayoutChange?.(nextLayout);\n  });\n\n  return (\n    <ChannelDetailProvider channel={channel} onClose={onClose}>\n      <Prompt.Root\n        className={clsx(\n          'str-chat__channel-detail',\n          {\n            'str-chat__channel-detail--inline':\n              layout === SECTION_NAVIGATOR_LAYOUT.inline,\n          },\n          className,\n        )}\n      >\n        <SectionNavigator\n          {...props}\n          defaultLayout={defaultLayout}\n          onLayoutChange={handleLayoutChange}\n          sections={sections}\n        />\n      </Prompt.Root>\n    </ChannelDetailProvider>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAM,uCAAuC;CAC3C,MAAM,EAAE,aAAa,yBAAyB;CAE9C,OAAO,oBAAC,UAAD,EAAU,WAAU,wCAAyC,CAAA;AACtE;AAEA,IAAM,oCAAoC;CACxC,MAAM,EAAE,aAAa,yBAAyB;CAE9C,OAAO,oBAAC,UAAD,EAAU,WAAU,wCAAyC,CAAA;AACtE;AAEA,IAAM,oCAAoC;CACxC,MAAM,EAAE,YAAY,yBAAyB;CAE7C,OAAO,oBAAC,SAAD,EAAS,WAAU,wCAAyC,CAAA;AACrE;AAEA,IAAM,kCAAkC;CACtC,MAAM,EAAE,cAAc,yBAAyB;CAE/C,OAAO,oBAAC,WAAD,EAAW,WAAU,wCAAyC,CAAA;AACvE;AAEA,IAAM,kCAAkC;CACtC,MAAM,EAAE,eAAe,yBAAyB;CAEhD,OAAO,oBAAC,YAAD,EAAY,WAAU,wCAAyC,CAAA;AACxE;AAEA,IAAa,8BAA8B,UACzC,oBAAC,wBAAD;CACE,GAAI;CACJ,aAAa;CACb,OAAM;AACP,CAAA;AAGH,IAAa,2BAA2B,UACtC,oBAAC,wBA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