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

    <div class="space-y-2">
      <div
        class="flex items-center justify-between rounded bg-blue-50 px-2 py-1 text-blue-700 dark:bg-blue-950 dark:text-blue-300"
      >
        <span class="font-medium">{{
          $t('ai-platform.workflow.nodes.form_db_design.database')
        }}</span>
        <span>{{ data.db_config || 'default' }}</span>
      </div>

      <div class="text-muted-foreground space-y-1 text-xs">
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_db_design.mainTable')
          }}</span>
          <span>{{
            data.main_table
              ? $t('ai-platform.workflow.nodes.common.configured')
              : $t('ai-platform.workflow.nodes.common.notConfigured')
          }}</span>
        </div>
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_db_design.subTable')
          }}</span>
          <span>{{
            data.sub_tables
              ? $t('ai-platform.workflow.nodes.common.configured')
              : $t('ai-platform.workflow.nodes.form_db_design.noSubTable')
          }}</span>
        </div>
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_db_design.systemFields')
          }}</span>
          <span>{{
            data.auto_add_system_fields !== false
              ? $t('ai-platform.workflow.nodes.form_db_design.autoAdd')
              : $t('ai-platform.workflow.nodes.form_db_design.noAdd')
          }}</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">database_design</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
