import { Brain, Landmark, Eye, EyeOff, Copy, Check, } from 'lucide-react' import type { AIModel, Exchange, ExchangeAccountState } from '../../types' import type { Language } from '../../i18n/translations' import { t } from '../../i18n/translations' import { getModelIcon } from '../common/ModelIcons' import { getExchangeIcon } from '../common/ExchangeIcons' import { getShortName, AI_PROVIDER_CONFIG, truncateAddress, } from './model-constants' interface UsageInfo { runningCount: number totalCount: number } interface ConfigStatusGridProps { configuredModels: AIModel[] configuredExchanges: Exchange[] exchangeAccountStates?: Record isExchangeAccountStatesLoading?: boolean visibleExchangeAddresses: Set copiedId: string | null language: Language isModelInUse: (modelId: string) => boolean | undefined getModelUsageInfo: (modelId: string) => UsageInfo isExchangeInUse: (exchangeId: string) => boolean | undefined getExchangeUsageInfo: (exchangeId: string) => UsageInfo onModelClick: (modelId: string) => void onExchangeClick: (exchangeId: string) => void onToggleExchangeAddress: (exchangeId: string) => void onCopyAddress: (id: string, address: string) => void } export function ConfigStatusGrid({ configuredModels, configuredExchanges, exchangeAccountStates, isExchangeAccountStatesLoading, visibleExchangeAddresses, copiedId, language, isModelInUse, getModelUsageInfo, isExchangeInUse, getExchangeUsageInfo, onModelClick, onExchangeClick, onToggleExchangeAddress, onCopyAddress, }: ConfigStatusGridProps) { const getExchangeStateMeta = (state: ExchangeAccountState | undefined) => { if (!state) { return { label: language === 'zh' ? '未检查' : 'NOT CHECKED', className: 'text-zinc-400 border-zinc-700/80 bg-zinc-900/40', } } switch (state.status) { case 'ok': return { label: state.display_balance || '0', className: 'text-emerald-300 border-emerald-500/20 bg-emerald-500/10', } case 'disabled': return { label: language === 'zh' ? '已禁用' : 'DISABLED', className: 'text-zinc-400 border-zinc-700/80 bg-zinc-900/40', } case 'missing_credentials': return { label: language === 'zh' ? '配置不完整' : 'INCOMPLETE', className: 'text-amber-300 border-amber-500/20 bg-amber-500/10', } case 'invalid_credentials': return { label: language === 'zh' ? '密钥无效' : 'INVALID KEYS', className: 'text-rose-300 border-rose-500/20 bg-rose-500/10', } case 'permission_denied': return { label: language === 'zh' ? '无余额权限' : 'NO PERMISSION', className: 'text-orange-300 border-orange-500/20 bg-orange-500/10', } default: return { label: language === 'zh' ? '暂时无法获取' : 'UNAVAILABLE', className: 'text-zinc-300 border-zinc-600/60 bg-zinc-800/50', } } } return (
{/* AI Models Card */}

{t('aiModels', language)}

{configuredModels.map((model) => { const inUse = isModelInUse(model.id) const usageInfo = getModelUsageInfo(model.id) return (
onModelClick(model.id)} >
{getModelIcon(model.provider || model.id, { width: 20, height: 20 }) || ( {getShortName(model.name)[0]} )}
{getShortName(model.name)}
{model.customModelName || AI_PROVIDER_CONFIG[model.provider]?.defaultModel || ''}
{model.provider === 'claw402' && (model.balanceUsdc || model.walletAddress) ? (
{model.balanceUsdc ? ( {model.balanceUsdc} USDC ) : null} {model.walletAddress ? ( {truncateAddress(model.walletAddress)} ) : null}
) : null}
{usageInfo.totalCount > 0 ? ( 0 ? 'bg-green-500/10 border-green-500/30 text-green-400' : 'bg-yellow-500/10 border-yellow-500/30 text-yellow-400' }`}> {usageInfo.runningCount}/{usageInfo.totalCount} ACTIVE ) : ( {language === 'zh' ? '就绪' : 'STANDBY'} )}
) })} {configuredModels.length === 0 && (
{t('noModelsConfigured', language)}
)}
{/* Exchanges Card */}

{t('exchanges', language)}

{configuredExchanges.map((exchange) => { const inUse = isExchangeInUse(exchange.id) const usageInfo = getExchangeUsageInfo(exchange.id) const state = exchangeAccountStates?.[exchange.id] const stateMeta = getExchangeStateMeta(state) return (
onExchangeClick(exchange.id)} >
{getExchangeIcon(exchange.exchange_type || exchange.id, { width: 20, height: 20 })}
{exchange.exchange_type?.toUpperCase() || getShortName(exchange.name)} {exchange.account_name || 'DEFAULT'}
{exchange.type?.toUpperCase() || 'CEX'}
{isExchangeAccountStatesLoading && !state ? (language === 'zh' ? '检查中...' : 'CHECKING...') : stateMeta.label} {state?.status !== 'ok' && state?.error_message ? ( {state.error_message} ) : null}
{/* Wallet Address Display Logic */} {(() => { const walletAddr = exchange.hyperliquidWalletAddr || exchange.asterUser || exchange.lighterWalletAddr if (exchange.type !== 'dex' || !walletAddr) return null const isVisible = visibleExchangeAddresses.has(exchange.id) const isCopied = copiedId === `exchange-${exchange.id}` return (
e.stopPropagation()}> {isVisible ? walletAddr : truncateAddress(walletAddr)}
) })()} {usageInfo.totalCount > 0 ? ( 0 ? 'bg-green-500/10 border-green-500/30 text-green-400' : 'bg-yellow-500/10 border-yellow-500/30 text-yellow-400' }`}> {usageInfo.runningCount}/{usageInfo.totalCount} ACTIVE ) : ( {language === 'zh' ? '就绪' : 'STANDBY'} )}
) })} {configuredExchanges.length === 0 && (
{t('noExchangesConfigured', language)}
)}
) }