import { memo, useMemo, } from 'react' import { useTranslation } from 'react-i18next' import cn from '@/utils/classnames' import { VarBlockIcon } from '@/app/components/workflow/block-icon' import { Line3 } from '@/app/components/base/icons/src/public/common' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import Badge from '@/app/components/base/badge' import type { Node, ValueSelector } from '@/app/components/workflow/types' import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import { InputField } from '@/app/components/base/icons/src/vender/pipeline' type NodeVariableItemProps = { node: Node variable: ValueSelector writeMode?: string showBorder?: boolean className?: string isException?: boolean } const i18nPrefix = 'workflow.nodes.assigner' const NodeVariableItem = ({ node, variable, writeMode, showBorder, className, isException, }: NodeVariableItemProps) => { const { t } = useTranslation() const isSystem = isSystemVar(variable) const isEnv = isENV(variable) const isChatVar = isConversationVar(variable) const isRagVar = isRagVariableVar(variable) const varName = useMemo(() => { if(isSystem) return `sys.${variable[variable.length - 1]}` if(isRagVar) return variable[variable.length - 1] return variable.slice(1).join('.') }, [isRagVar, isSystem, variable]) const VariableIcon = useMemo(() => { if (isEnv) { return ( ) } if (isChatVar) { return ( ) } if(isRagVar) { return ( ) } return ( ) }, [isEnv, isChatVar, isRagVar, isException]) const VariableName = useMemo(() => { return (
{varName}
) }, [isEnv, isChatVar, varName, isException]) return (
{ node && ( <>
{node?.data.title}
) } {VariableIcon} {VariableName}
{writeMode && }
) } export default memo(NodeVariableItem)