<script setup lang="ts">
import { BookOpen } from '@vben/icons';
import { $t } from '@vben/locales';

import BaseNode from './BaseNode.vue';

defineProps(['selected', 'data', 'id']);
</script>

<template>
  <BaseNode
    :selected="selected"
    :execution-status="data.executionStatus"
    :execution-result="data.executionResult"
    :label="
      data.label ||
      $t('ai-platform.workflow.nodes.knowledge_retrieval_node.label')
    "
    :inputs="[{ id: 'target' }]"
    :outputs="[{ id: 'source' }]"
    :node-id="id"
    node-type="knowledge_retrieval"
  >
    <template #icon><BookOpen class="size-5" /></template>
    <template #desc>
      {{ $t('ai-platform.workflow.nodes.knowledge_retrieval_node.desc') }}
    </template>

    <div class="space-y-1.5">
      <div
        v-if="data.knowledge_base_ids?.length"
        class="text-muted-foreground text-xs"
      >
        {{
          $t('ai-platform.workflow.nodes.knowledge_retrieval_node.kbCount', {
            count: data.knowledge_base_ids.length,
          })
        }}
      </div>
      <div v-if="data.top_k" class="text-muted-foreground text-xs">
        {{
          $t(
            'ai-platform.workflow.nodes.knowledge_retrieval_node.topKThreshold',
            { topK: data.top_k, threshold: data.score_threshold || 0.5 },
          )
        }}
      </div>
      <div
        v-if="data.retrieval_mode"
        class="text-muted-foreground text-xs capitalize"
      >
        {{
          data.retrieval_mode === 'vector'
            ? $t('ai-platform.workflow.nodes.knowledge_retrieval_node.vector')
            : data.retrieval_mode === 'fulltext'
              ? $t(
                  'ai-platform.workflow.nodes.knowledge_retrieval_node.fulltext',
                )
              : $t('ai-platform.workflow.nodes.knowledge_retrieval_node.hybrid')
        }}
      </div>
    </div>
  </BaseNode>
</template>
