/**
 * Input Node Component
 *
 * Node for defining workflow input variables.
 */

import React, { memo } from 'react';
import { Handle, Position, NodeProps } from '@xyflow/react';
import type { InputNodeData } from '../../../lib/workflow-builder/types';

export const InputNode = memo(({ data, selected }: NodeProps<InputNodeData>) => {
  return (
    <div
      className={`
        px-4 py-3 rounded-lg border-2 min-w-[180px]
        bg-emerald-50 border-emerald-300
        ${selected ? 'border-emerald-500 shadow-lg shadow-emerald-200' : ''}
      `}
    >
      {/* Output Handle */}
      <Handle
        type="source"
        position={Position.Right}
        className="w-3 h-3 bg-emerald-500 border-2 border-white"
      />

      {/* Header */}
      <div className="flex items-center gap-2 mb-2">
        <span className="text-lg">📥</span>
        <span className="font-medium text-emerald-800">{data.label}</span>
      </div>

      {/* Variable Name */}
      <div className="text-sm text-emerald-600">
        <span className="font-mono bg-emerald-100 px-1.5 py-0.5 rounded">
          {data.variableName}
        </span>
      </div>

      {/* Default Value Indicator */}
      {data.defaultValue !== undefined && (
        <div className="text-xs text-emerald-500 mt-1">
          default: {typeof data.defaultValue === 'string'
            ? `"${data.defaultValue}"`
            : JSON.stringify(data.defaultValue)}
        </div>
      )}
    </div>
  );
});

InputNode.displayName = 'InputNode';

export default InputNode;
