/** 无代码设计器左侧积木目录（对齐设计文档 §4） */

export type WcsNodeType =
  | 'trigger'
  | 'binding'
  | 'filter'
  | 'score'
  | 'allocate'
  | 'action'
  | 'policy'
  | 'end'

export interface WcsPaletteItem {
  type: WcsNodeType
  label: string
  category: string
  description: string
  color: string
  /** 拖入后默认侧（过滤/打分） */
  defaultSide?: 'source' | 'target'
}

export const WCS_CATEGORY_ORDER = ['触发与参数', '库位策略', '任务与策略', '流程'] as const

export const WCS_NODE_CATALOG: WcsPaletteItem[] = [
  {
    type: 'trigger',
    label: '触发',
    category: '触发与参数',
    description: '事件 / 人工触发',
    color: '#67c23a'
  },
  {
    type: 'binding',
    label: '参数绑定',
    category: '触发与参数',
    description: '从 MES/APS/WMS 引入字段',
    color: '#409eff'
  },
  {
    type: 'filter',
    label: '过滤条件',
    category: '库位策略',
    description: '硬性/弹性筛选库位',
    color: '#e6a23c',
    defaultSide: 'source'
  },
  {
    type: 'score',
    label: '打分偏好',
    category: '库位策略',
    description: 'FIFO / 距离等排序',
    color: '#f56c6c',
    defaultSide: 'source'
  },
  {
    type: 'allocate',
    label: '成对预占',
    category: '库位策略',
    description: '源+宿同时占位',
    color: '#9b59b6'
  },
  {
    type: 'action',
    label: '任务动作',
    category: '任务与策略',
    description: '生成搬运并派车',
    color: '#13c2c2'
  },
  {
    type: 'policy',
    label: '运行策略',
    category: '任务与策略',
    description: '超时、重试、无候选',
    color: '#909399'
  },
  {
    type: 'end',
    label: '结束',
    category: '流程',
    description: '流水线终点',
    color: '#606266'
  }
]

export const WCS_NODE_MAP = Object.fromEntries(WCS_NODE_CATALOG.map((n) => [n.type, n])) as Record<
  WcsNodeType,
  WcsPaletteItem
>
