| 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														'use client' | 
														 | 
														 | 
														'use client' | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														import { useCallback, useRef, useState } from 'react' | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														import { useCallback, useEffect, useRef, useState } from 'react' | 
													
													
												
													
														 | 
														 | 
														import { useTranslation } from 'react-i18next' | 
														 | 
														 | 
														import { useTranslation } from 'react-i18next' | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														import { useRouter } from 'next/navigation' | 
														 | 
														 | 
														import { useRouter } from 'next/navigation' | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														  onSuccess: () => void | 
														 | 
														 | 
														  onSuccess: () => void | 
													
													
												
													
														 | 
														 | 
														  onClose: () => void | 
														 | 
														 | 
														  onClose: () => void | 
													
													
												
													
														 | 
														 | 
														  onCreateFromTemplate?: () => void | 
														 | 
														 | 
														  onCreateFromTemplate?: () => void | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														  defaultAppMode?: AppMode | 
													
													
												
													
														 | 
														 | 
														} | 
														 | 
														 | 
														} | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														function CreateApp({ onClose, onSuccess, onCreateFromTemplate }: CreateAppProps) { | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														function CreateApp({ onClose, onSuccess, onCreateFromTemplate, defaultAppMode }: CreateAppProps) { | 
													
													
												
													
														 | 
														 | 
														  const { t } = useTranslation() | 
														 | 
														 | 
														  const { t } = useTranslation() | 
													
													
												
													
														 | 
														 | 
														  const { push } = useRouter() | 
														 | 
														 | 
														  const { push } = useRouter() | 
													
													
												
													
														 | 
														 | 
														  const { notify } = useContext(ToastContext) | 
														 | 
														 | 
														  const { notify } = useContext(ToastContext) | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														  const [appMode, setAppMode] = useState<AppMode>('advanced-chat') | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														  const [appMode, setAppMode] = useState<AppMode>(defaultAppMode || 'advanced-chat') | 
													
													
												
													
														 | 
														 | 
														  const [appIcon, setAppIcon] = useState<AppIconSelection>({ type: 'emoji', icon: '🤖', background: '#FFEAD5' }) | 
														 | 
														 | 
														  const [appIcon, setAppIcon] = useState<AppIconSelection>({ type: 'emoji', icon: '🤖', background: '#FFEAD5' }) | 
													
													
												
													
														 | 
														 | 
														  const [showAppIconPicker, setShowAppIconPicker] = useState(false) | 
														 | 
														 | 
														  const [showAppIconPicker, setShowAppIconPicker] = useState(false) | 
													
													
												
													
														 | 
														 | 
														  const [name, setName] = useState('') | 
														 | 
														 | 
														  const [name, setName] = useState('') | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														  const isCreatingRef = useRef(false) | 
														 | 
														 | 
														  const isCreatingRef = useRef(false) | 
													
													
												
													
														 | 
														 | 
														
  | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														  useEffect(() => { | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														    if (appMode === 'chat' || appMode === 'agent-chat' || appMode === 'completion') | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														      setIsAppTypeExpanded(true) | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														  }, [appMode]) | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														
  | 
													
													
												
													
														 | 
														 | 
														  const onCreate = useCallback(async () => { | 
														 | 
														 | 
														  const onCreate = useCallback(async () => { | 
													
													
												
													
														 | 
														 | 
														    if (!appMode) { | 
														 | 
														 | 
														    if (!appMode) { | 
													
													
												
													
														 | 
														 | 
														      notify({ type: 'error', message: t('app.newApp.appTypeRequired') }) | 
														 | 
														 | 
														      notify({ type: 'error', message: t('app.newApp.appTypeRequired') }) | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														type CreateAppDialogProps = CreateAppProps & { | 
														 | 
														 | 
														type CreateAppDialogProps = CreateAppProps & { | 
													
													
												
													
														 | 
														 | 
														  show: boolean | 
														 | 
														 | 
														  show: boolean | 
													
													
												
													
														 | 
														 | 
														} | 
														 | 
														 | 
														} | 
													
													
												
													
														 | 
														 | 
														const CreateAppModal = ({ show, onClose, onSuccess, onCreateFromTemplate }: CreateAppDialogProps) => { | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														const CreateAppModal = ({ show, onClose, onSuccess, onCreateFromTemplate, defaultAppMode }: CreateAppDialogProps) => { | 
													
													
												
													
														 | 
														 | 
														  return ( | 
														 | 
														 | 
														  return ( | 
													
													
												
													
														 | 
														 | 
														    <FullScreenModal | 
														 | 
														 | 
														    <FullScreenModal | 
													
													
												
													
														 | 
														 | 
														      overflowVisible | 
														 | 
														 | 
														      overflowVisible | 
													
													
												
											
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														      open={show} | 
														 | 
														 | 
														      open={show} | 
													
													
												
													
														 | 
														 | 
														      onClose={onClose} | 
														 | 
														 | 
														      onClose={onClose} | 
													
													
												
													
														 | 
														 | 
														    > | 
														 | 
														 | 
														    > | 
													
													
												
													
														 | 
														 | 
														      <CreateApp onClose={onClose} onSuccess={onSuccess} onCreateFromTemplate={onCreateFromTemplate} /> | 
														 | 
														 | 
														 | 
													
													
												
													
														 | 
														 | 
														 | 
														 | 
														 | 
														      <CreateApp onClose={onClose} onSuccess={onSuccess} onCreateFromTemplate={onCreateFromTemplate} defaultAppMode={defaultAppMode} /> | 
													
													
												
													
														 | 
														 | 
														    </FullScreenModal> | 
														 | 
														 | 
														    </FullScreenModal> | 
													
													
												
													
														 | 
														 | 
														  ) | 
														 | 
														 | 
														  ) | 
													
													
												
													
														 | 
														 | 
														} | 
														 | 
														 | 
														} |