<script setup lang="ts">
import { ref, watch } from 'vue';

import { $t } from '@vben/locales';

import { ElForm, ElFormItem, ElInput } from 'element-plus';

import SmartInput from '../components/SmartInput.vue';

const props = defineProps<{ data: any; nodeId: string }>();
const emit = defineEmits(['update']);

const form = ref({
  label: $t('ai-platform.workflow.panels.message.label'),
  content: '',
  ...props.data,
});

watch(
  form,
  (val) => {
    emit('update', val);
  },
  { deep: true },
);
</script>

<template>
  <ElForm label-position="top" size="small" class="space-y-4">
    <ElFormItem :label="$t('ai-platform.workflow.panels.common.nodeName')">
      <ElInput
        v-model="form.label"
        :placeholder="$t('ai-platform.workflow.panels.message.placeholder')"
      />
    </ElFormItem>

    <ElFormItem>
      <template #label>
        <span>{{ $t('ai-platform.workflow.panels.message.content') }}</span>
        <span class="text-destructive ml-1">*</span>
      </template>
      <SmartInput
        v-model="form.content"
        :current-node-id="nodeId"
        type="textarea"
        :rows="6"
        :placeholder="
          $t('ai-platform.workflow.panels.message.contentPlaceholder')
        "
      />
      <div class="text-muted-foreground mt-1 text-xs">
        {{ $t('ai-platform.workflow.panels.message.contentHint') }}
      </div>
    </ElFormItem>
  </ElForm>
</template>
