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

    <div class="space-y-2">
      <div class="text-muted-foreground space-y-1 text-xs">
        <div v-if="data.summary_title" class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.system_summary.title')
          }}</span>
          <span class="max-w-[120px] truncate">{{ data.summary_title }}</span>
        </div>
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.system_summary.showStatistics')
          }}</span>
          <span>{{
            data.show_statistics !== false
              ? $t('ai-platform.workflow.nodes.common.yes')
              : $t('ai-platform.workflow.nodes.common.no')
          }}</span>
        </div>
        <div v-if="data.app_info" class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.system_summary.appInfo')
          }}</span>
          <span class="text-green-600 dark:text-green-400">{{
            $t('ai-platform.workflow.nodes.common.configured')
          }}</span>
        </div>
        <div v-if="data.form_results" class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.system_summary.formResult')
          }}</span>
          <span class="text-green-600 dark:text-green-400">{{
            $t('ai-platform.workflow.nodes.common.configured')
          }}</span>
        </div>
        <div v-if="data.dashboard_info" class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.system_summary.dashboard')
          }}</span>
          <span class="text-green-600 dark:text-green-400">{{
            $t('ai-platform.workflow.nodes.common.configured')
          }}</span>
        </div>
      </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.output') }}</span>
          <span class="font-mono">summary</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
