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

    <div class="space-y-2">
      <div class="rounded bg-amber-50 px-2 py-1.5 text-xs dark:bg-amber-950">
        <div class="mb-1 font-medium text-amber-700 dark:text-amber-300">
          {{
            data.title || $t('ai-platform.workflow.nodes.confirm.confirmText')
          }}
        </div>
        <div class="line-clamp-2 text-amber-600 dark:text-amber-400">
          {{
            data.content ||
            $t('ai-platform.workflow.nodes.confirm.configureContent')
          }}
        </div>
      </div>

      <div class="flex items-center gap-2 text-xs">
        <span
          class="rounded bg-green-100 px-2 py-0.5 text-green-700 dark:bg-green-900 dark:text-green-300"
        >
          {{
            data.confirm_text ||
            $t('ai-platform.workflow.nodes.confirm.confirmText')
          }}
        </span>
        <span class="bg-muted text-muted-foreground rounded px-2 py-0.5">
          {{
            data.cancel_text ||
            $t('ai-platform.workflow.nodes.confirm.cancelText')
          }}
        </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.variable_name || 'confirmed' }}</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
