import { Memori as MemoriOriginal, Tenant, Venue, User, } from '@memori.ai/memori-api-client/src/types'; import React, { useState, useEffect } from 'react'; import { getResourceUrl } from '../../helpers/media'; import { useTranslation } from 'react-i18next'; import Tooltip from '../ui/Tooltip'; import { getTranslation } from '../../helpers/translations'; import Button from '../ui/Button'; import Translation from '../icons/Translation'; import { getGroupedChatLanguages } from '../../helpers/constants'; import BlockedMemoriBadge from '../BlockedMemoriBadge/BlockedMemoriBadge'; import AI from '../icons/AI'; import Group from '../icons/Group'; import DeepThought from '../icons/DeepThought'; import CompletionProviderStatus, { Props as CPSProps, } from '../CompletionProviderStatus/CompletionProviderStatus'; import MapMarker from '../icons/MapMarker'; import UserIcon from '../icons/User'; import QuestionHelp from '../icons/QuestionHelp'; import Expandable from '../ui/Expandable'; interface Memori extends MemoriOriginal { requireLoginToken?: boolean; } export interface Props { memori: Memori; tenant?: Tenant; language?: string; userLang?: string; setUserLang: (lang: string) => void; baseUrl?: string; apiUrl?: string; position?: Venue; openPositionDrawer: () => void; integrationConfig?: { [key: string]: any }; instruct?: boolean; sessionId?: string; hasInitialSession?: boolean; clickedStart?: boolean; onClickStart?: () => void; initializeTTS?: () => void; _TEST_forceProviderStatus?: CPSProps['forceStatus']; isUserLoggedIn?: boolean; user?: User; showLogin?: boolean; setShowLoginDrawer: (show: boolean) => void; notEnoughCredits?: boolean; isMultilanguageEnabled?: boolean | undefined; } const StartPanel: React.FC = ({ memori, tenant, language, userLang, setUserLang, baseUrl, apiUrl, position, openPositionDrawer, instruct = false, hasInitialSession = false, clickedStart, onClickStart, initializeTTS, _TEST_forceProviderStatus, isUserLoggedIn = false, user, showLogin = false, setShowLoginDrawer, notEnoughCredits = false, isMultilanguageEnabled, }) => { const { t, i18n } = useTranslation(); const [translatedDescription, setTranslatedDescription] = useState( memori.description ); const [showTranslation, setShowTranslation] = useState(true); const toggleTranslations = () => { setShowTranslation(show => !show); }; useEffect(() => { if ( ((i18n.language?.toUpperCase() ?? 'IT') !== (language?.toUpperCase() ?? 'IT') || translatedDescription !== memori.description) && !!memori.description?.length ) { getTranslation( memori.description, i18n.language?.toUpperCase() ?? 'IT', language, baseUrl ) .then(value => { setTranslatedDescription(value.text); }) .catch(console.error); } }, [i18n.language, language, memori.description, baseUrl]); return (
{!!memori.enableBoardOfExperts && (
)} {!!memori.nsfw && (
🔞
)}
{memori.name} 0 ? getResourceUrl({ type: 'avatar', tenantID: tenant?.name, resourceURI: memori.avatarURL, baseURL: baseUrl, apiURL: apiUrl, }) : getResourceUrl({ type: 'avatar', tenantID: tenant?.name, baseURL: baseUrl, apiURL: apiUrl, }) } />

{memori.name}

{memori.needsPosition && !position && (

{t('write_and_speak.requirePositionHelp', { name: memori.name })}

)} {((memori.needsPosition && position) || !memori.needsPosition) && !!memori.requireLoginToken && !isUserLoggedIn && (

{t('write_and_speak.requirePositionHelp', { name: memori.name })}

)} {((memori.needsPosition && position) || !memori.needsPosition) && (!memori.requireLoginToken || (memori.requireLoginToken && isUserLoggedIn)) && (

{translatedDescription && showTranslation ? translatedDescription : memori.description} {translatedDescription !== memori.description && ( )}

{isMultilanguageEnabled && !instruct && (
)}

{t('write_and_speak.pagePrivacyExplanation')}

{' '} {t( 'write_and_speak.pagePrivacyExplanationList.allConversations' )}

    {isUserLoggedIn ? (
  • {t( 'write_and_speak.pagePrivacyExplanationList.contentAndUsername' )}
  • ) : (
  • {t( 'write_and_speak.pagePrivacyExplanationList.contentAndIpAddress' )}
  • )}

{t( 'write_and_speak.pagePrivacyExplanationList.authorUsesInfo' )}

{tenant?.privacyPolicyURL ?? t('privacyPolicy')}
} >

{instruct ? t('write_and_speak.pageInstructExplanation') : t('write_and_speak.pageTryMeExplanation')}

{(memori.blockedUntil || notEnoughCredits) && ( )} {!!memori.enableDeepThought && !instruct && (

{isUserLoggedIn && !!user?.pAndCUAccepted ? t('deepThoughtDisclaimerTitle') : t('deepThought')}

{isUserLoggedIn && !user?.pAndCUAccepted && (

{t('deepThoughtPreDisclaimerNotAllowed')}

)} {!isUserLoggedIn && (

{t('deepThoughtPreDisclaimerUnlogged')}

)} {!isUserLoggedIn && showLogin && (

)}

{t('deepThoughtDisclaimer')}

)}
)} ); }; export default StartPanel;