<template>
  <div class="delay-node">
    <StandardNode
      :icon="definition.icon"
      :title="definition.title"
      :subtitle="definition.subtitle"
      :accent="definition.accent"
      :badge="badge"
      :status="status"
      :handles="definition.handles"
      :body-items="bodyItems"
      :selected="props.selected"
    />
  </div>
</template>

<script setup lang="ts">
import { Position } from '@vue-flow/core'
import StandardNode from '../shared/StandardNode.vue'
import { useStandardNode } from '../shared/useStandardNode'
import type { BaseNodeProps } from '../shared/types'
import type { DelayNodeData } from './types'

const props = defineProps<BaseNodeProps<DelayNodeData>>()

const { definition, bodyItems, badge, status } = useStandardNode(props, {
  icon: 'mdi:timer-sand',
  title: '延迟节点',
  subtitle: 'Wait / Backoff',
  accent: '#722ed1',
  handles: {
    inputs: [Position.Left],
    outputs: [Position.Right]
  },
  badge: ({ data }) => data.mode ?? '固定',
  status: ({ data }) => data.status ?? '排队',
  body: ({ data }) => [
    { label: '时长', value: `${data.duration ?? 0}s` },
    { label: '策略', value: data.mode ?? '固定' }
  ]
})
</script>

<style scoped lang="scss">
@use './index.scss' as *;
</style>
