const defaultParameters = {
  apiIns: [{
    name: 'start',
    desc: '',
    dataType: '',
    defaultValue: ''
  }],
  apiOuts: [{
    name: 'done',
    desc: '',
    dataType: '',
    defaultValue: ''
  }],
  dataIns: [],
  dataOuts: []
};
const json2strParameters = {
  apiIns: [{
    name: 'start',
    desc: 'JSON',
    dataType: 'JSON',
    defaultValue: ''
  }],
  apiOuts: [{
    name: 'done',
    desc: 'STR',
    dataType: 'STR',
    defaultValue: ''
  }],
  dataIns: [],
  dataOuts: []
};
const str2jsonParameters = {
  apiIns: [{
    name: 'start',
    desc: 'STR',
    dataType: 'STR',
    defaultValue: ''
  }],
  apiOuts: [{
    name: 'done',
    desc: 'JSON',
    dataType: 'JSON',
    defaultValue: ''
  }],
  dataIns: [],
  dataOuts: []
};

// 定义节点基本信息
const nodeDefinitions = [
  { nodeName: '条件选择', nodeType: 'CONDITION', nodeGroup: 'common', icon: 'IconBranch' },
  { nodeName: '与门', nodeType: 'AND', nodeGroup: 'common', icon: 'IconShareAlt' },
  { nodeName: '或门', nodeType: 'OR', nodeGroup: 'common', icon: 'IconPause' },
  { nodeName: '等待', nodeType: 'WAIT', nodeGroup: 'common', icon: 'IconClockCircle' },
  { nodeName: '循环', nodeType: 'LOOP', nodeGroup: 'common', icon: 'IconSync' },
  { nodeName: '周期', nodeType: 'CYCLE', nodeGroup: 'common', icon: 'IconSchedule' },
  { nodeName: '事件接收', nodeType: 'EVENTLISTENE', nodeGroup: 'common', icon: 'IconImport' },
  { nodeName: '事件发送', nodeType: 'EVENTSEND', nodeGroup: 'common', icon: 'IconExport' },
  { nodeName: 'JSON转字符串', nodeType: 'JSON2STR', nodeGroup: 'common', icon: 'IconCodeBlock' },
  { nodeName: '字符串转JSON', nodeType: 'STR2JSON', nodeGroup: 'common', icon: 'IconCodeSquare' },
  { nodeName: 'JSON封装', nodeType: 'JSONCONVERT', nodeGroup: 'common', icon: 'IconTranslate' },
  { nodeName: '结果展示', nodeType: 'RESULT', nodeGroup: 'common', icon: 'IconInteraction' },
  { nodeName: '图片展示', nodeType: 'IMAGE', nodeGroup: 'common', icon: 'IconImage' },
  { nodeName: '代码编辑器', nodeType: 'CODE', nodeGroup: 'common', icon: 'IconCode' },
  { nodeName: 'REST调用', nodeType: 'REST', nodeGroup: 'common', icon: 'IconCloudDownload' }
];

// 通过映射生成完整的节点数据数组
export const localNodeData = nodeDefinitions.map(({ nodeName, nodeType, nodeGroup, icon }) => {
  let parameters = defaultParameters;

  // 为特定节点类型使用特殊的参数配置
  if (nodeType === 'JSON2STR') {
    parameters = json2strParameters;
  }
  else if (nodeType === 'STR2JSON') {
    parameters = str2jsonParameters;
  }

  return {
    nodeName,
    nodeType,
    nodeGroup,
    icon,
    data: {
      parameters: { ...parameters }
    }
  };
});
