<script setup lang="ts">
import { Combine } 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.merge.label')"
    :inputs="[{ id: 'target' }]"
    :outputs="[{ id: 'source' }]"
    :node-id="id"
    node-type="merge"
  >
    <template #icon><Combine class="size-5" /></template>
    <template #desc>{{ $t('ai-platform.workflow.nodes.merge.desc') }}</template>

    <div class="space-y-2">
      <div
        class="flex items-center justify-between rounded bg-purple-50 px-2 py-1 text-purple-700 dark:bg-purple-950 dark:text-purple-300"
      >
        <span class="text-xs font-medium">{{
          $t('ai-platform.workflow.nodes.merge.mergeMode')
        }}</span>
        <span class="text-xs">{{
          data.merge_mode === 'array'
            ? $t('ai-platform.workflow.nodes.merge.array')
            : data.merge_mode === 'concat'
              ? $t('ai-platform.workflow.nodes.merge.concat')
              : data.merge_mode === 'first'
                ? $t('ai-platform.workflow.nodes.merge.first')
                : $t('ai-platform.workflow.nodes.merge.object')
        }}</span>
      </div>

      <!-- 输出变量 -->
      <div class="rounded bg-green-50 px-2 py-1 text-xs dark:bg-green-950">
        <div
          class="flex items-center justify-between text-green-700 dark:text-green-300"
        >
          <span>{{
            $t('ai-platform.workflow.nodes.common.outputVariable')
          }}</span>
          <span class="font-mono">{{
            data.output_variable || 'merged_result'
          }}</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
