import type { CatalogNodeEntry } from '../workflow-node-catalog'

export const LOGIC_NEW_NODES: CatalogNodeEntry[] = [
  {
    type: 'if_condition',
    label: 'If / Condition',
    description: 'Branch execution into true/false paths based on a condition expression.',
    category: 'logic',
    color: 'text-violet-500',
    iconName: 'GitBranch',
    inputs: [{ name: 'input', type: 'any', required: true, description: 'Value to evaluate' }],
    outputs: [
      { name: 'true', type: 'any', description: 'Output when condition is true' },
      { name: 'false', type: 'any', description: 'Output when condition is false' },
    ],
    requiredConfig: ['condition'],
    optionalConfig: ['inputPath'],
    exampleConfig: { condition: '{{n1.score}} > 7', inputPath: 'data' },
    acceptsInputTypes: ['text', 'json', 'number', 'boolean', 'any'],
    producesOutputType: 'any',
    n8nEquivalent: 'n8n-nodes-base.if',
  },
  {
    type: 'try_catch',
    label: 'Try / Catch',
    description: 'Wrap downstream execution in error handling with a recovery branch.',
    category: 'logic',
    color: 'text-violet-500',
    iconName: 'ShieldAlert',
    inputs: [{ name: 'input', type: 'any', description: 'Input to pass to the try branch' }],
    outputs: [
      { name: 'success', type: 'any', description: 'Output on success' },
      { name: 'error', type: 'error', description: 'Error details on failure' },
    ],
    requiredConfig: [],
    optionalConfig: ['maxRetries', 'retryDelayMs'],
    exampleConfig: { maxRetries: 2, retryDelayMs: 1000 },
    acceptsInputTypes: ['any'],
    producesOutputType: 'any',
    n8nEquivalent: 'n8n-nodes-base.errorTrigger',
  },
  {
    type: 'merge',
    label: 'Merge',
    description: 'Combine outputs from multiple upstream branches into a single output.',
    category: 'logic',
    color: 'text-violet-500',
    iconName: 'Merge',
    inputs: [
      { name: 'input1', type: 'any', required: true, description: 'First branch output' },
      { name: 'input2', type: 'any', required: true, description: 'Second branch output' },
    ],
    outputs: [{ name: 'merged', type: 'json', description: 'Combined output object' }],
    requiredConfig: ['mode'],
    optionalConfig: ['mergeKey'],
    exampleConfig: { mode: 'combine', mergeKey: 'id' },
    acceptsInputTypes: ['any'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.merge',
  },
  {
    type: 'split_in_batches',
    label: 'Split In Batches',
    description: 'Split an array into fixed-size batches for sequential processing.',
    category: 'logic',
    color: 'text-violet-500',
    iconName: 'LayoutGrid',
    inputs: [{ name: 'items', type: 'array', required: true, description: 'Array to split' }],
    outputs: [{ name: 'batch', type: 'array', description: 'Current batch of items' }],
    requiredConfig: ['batchSize'],
    optionalConfig: ['delayBetweenMs'],
    exampleConfig: { batchSize: 10, delayBetweenMs: 500 },
    acceptsInputTypes: ['array', 'json', 'any'],
    producesOutputType: 'array',
    n8nEquivalent: 'n8n-nodes-base.splitInBatches',
  },
  {
    type: 'stop_return',
    label: 'Stop / Return',
    description: 'Terminate workflow execution early and return a final value.',
    category: 'logic',
    color: 'text-violet-500',
    iconName: 'CircleStop',
    inputs: [{ name: 'input', type: 'any', description: 'Value to return as workflow output' }],
    outputs: [{ name: 'result', type: 'workflow_result', description: 'Final workflow output' }],
    requiredConfig: [],
    optionalConfig: ['message', 'status'],
    exampleConfig: { message: 'Processing complete', status: 'success' },
    acceptsInputTypes: ['text', 'json', 'any'],
    producesOutputType: 'workflow_result',
    n8nEquivalent: 'n8n-nodes-base.stopAndError',
  },
]
