//! Package component definitions
//!
//! Catalog of available package (processing node) components.

use super::{CargoDependency, Component, ComponentCatalog, ComponentType, CustomNodeConfig, Mecha10Config};

/// Add all package components to the catalog
pub fn add_packages(catalog: &mut ComponentCatalog) {
    // Speaker node - references monorepo binary directly
    catalog.insert(Component {
        id: "speaker".to_string(),
        name: "speaker".to_string(),
        description: "Example node that publishes greeting messages to /example/greetings topic".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec!["pubsub".to_string(), "example".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-speaker".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![
            // No wrapper files - use monorepo binary directly via cargo run -p mecha10-nodes-speaker
        ],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "speaker".to_string(),
                path: "mecha10-nodes-speaker".to_string(), // Package name for monorepo
                config: None,
                description: "Example speaker node from monorepo (cargo run -p mecha10-nodes-speaker)".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Listener node - references monorepo binary directly
    catalog.insert(Component {
        id: "listener".to_string(),
        name: "listener".to_string(),
        description: "Example node that subscribes to /example/greetings topic and prints messages".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec!["pubsub".to_string(), "example".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-listener".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![
            // No wrapper files - use monorepo binary directly via cargo run -p mecha10-nodes-listener
        ],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "listener".to_string(),
                path: "mecha10-nodes-listener".to_string(), // Package name for monorepo
                config: None,
                description: "Example listener node from monorepo (cargo run -p mecha10-nodes-listener)".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Motor node - manages motor driver with configuration for fake/real
    catalog.insert(Component {
        id: "motor".to_string(),
        name: "motor".to_string(),
        description: "Motor node with differential drive kinematics and odometry (configurable fake/real driver)"
            .to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec!["motor".to_string(), "actuator".to_string(), "odometry".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-motor".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "motor".to_string(),
                path: "mecha10-nodes-motor".to_string(), // Package name for monorepo
                config: None,
                description: "Motor node from monorepo (cargo run -p mecha10-nodes-motor)".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            behavior: None,
        },
    });

    // IMU node - manages IMU driver with configuration for fake/real
    catalog.insert(Component {
        id: "imu".to_string(),
        name: "imu".to_string(),
        description: "IMU node providing orientation and acceleration data (configurable fake/real driver)".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec!["imu".to_string(), "sensor".to_string(), "orientation".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-imu".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "imu".to_string(),
                path: "mecha10-nodes-imu".to_string(), // Package name for monorepo
                config: None,
                description: "IMU node from monorepo (cargo run -p mecha10-nodes-imu)".to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Teleop node - keyboard-based control for development
    catalog.insert(Component {
        id: "teleop".to_string(),
        name: "teleop".to_string(),
        description: "Teleoperation node for keyboard-based robot control (WASD controls)".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec!["teleop".to_string(), "control".to_string(), "development".to_string()],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-teleop".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "teleop".to_string(),
                path: "mecha10-nodes-teleop".to_string(), // Package name for monorepo
                config: None,
                description: "Teleop node from monorepo (cargo run -p mecha10-nodes-teleop)".to_string(),
                run_target: "dev".to_string(), // Only for development
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Simulation bridge node - connects framework to Godot RL Agents
    catalog.insert(Component {
        id: "simulation-bridge".to_string(),
        name: "simulation-bridge".to_string(),
        description: "Simulation bridge that translates between Redis pub/sub and Godot RL Agents protocol".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "simulation".to_string(),
            "godot".to_string(),
            "rl".to_string(),
            "bridge".to_string(),
        ],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-simulation-bridge".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "simulation-bridge".to_string(),
                path: "mecha10-nodes-simulation-bridge".to_string(), // Package name for monorepo
                config: None,
                description: "Simulation bridge node from monorepo (cargo run -p mecha10-nodes-simulation-bridge)"
                    .to_string(),
                run_target: "dev".to_string(), // Only for development/simulation
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Image classifier node - AI-powered image classification using ONNX models
    catalog.insert(Component {
        id: "image-classifier".to_string(),
        name: "image-classifier".to_string(),
        description: "Image classification node using ONNX models (MobileNet, ResNet) from model catalog".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "ai".to_string(),
            "vision".to_string(),
            "classification".to_string(),
            "onnx".to_string(),
            "ml".to_string(),
        ],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-image-classifier".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "image-classifier".to_string(),
                path: "mecha10-nodes-image-classifier".to_string(), // Package name for monorepo
                config: None,
                description: "AI image classification node from monorepo (cargo run -p mecha10-nodes-image-classifier)"
                    .to_string(),
                run_target: "robot".to_string(), // Can run on robot or remotely
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Object detector node - Real-time object detection using YOLO
    catalog.insert(Component {
        id: "object-detector".to_string(),
        name: "object-detector".to_string(),
        description: "Real-time object detection node using YOLO and ONNX Runtime with bounding box visualization"
            .to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "ai".to_string(),
            "vision".to_string(),
            "detection".to_string(),
            "yolo".to_string(),
            "onnx".to_string(),
            "ml".to_string(),
        ],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-object-detector".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "object-detector".to_string(),
                path: "mecha10-nodes-object-detector".to_string(), // Package name for monorepo
                config: None,
                description: "Object detection node from monorepo (cargo run -p mecha10-nodes-object-detector)"
                    .to_string(),
                run_target: "robot".to_string(), // Can run on robot or remotely
                enabled: true,
            }),
            behavior: None,
        },
    });

    // LLM Command node - Natural language command parsing via LLM APIs
    catalog.insert(Component {
        id: "llm-command".to_string(),
        name: "llm-command".to_string(),
        description: "Natural language command parsing via LLM APIs (OpenAI, Claude, Ollama) with dashboard control"
            .to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "ai".to_string(),
            "llm".to_string(),
            "reasoning".to_string(),
            "nlp".to_string(),
            "command".to_string(),
        ],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-nodes-llm-command".to_string(),
                version: Some("0.1".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "mecha10-ai-llm".to_string(),
                version: Some("0.1".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "llm-command".to_string(),
                path: "mecha10-nodes-llm-command".to_string(), // Package name for monorepo
                config: None,
                description: "LLM command node from monorepo (cargo run -p mecha10-nodes-llm-command)".to_string(),
                run_target: "robot".to_string(), // Can run on robot or remotely
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Diagnostics node - System diagnostics (Docker + system metrics)
    catalog.insert(Component {
        id: "diagnostics-node".to_string(),
        name: "diagnostics-node".to_string(),
        description: "System diagnostics node that publishes Docker container and system resource metrics".to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "diagnostics".to_string(),
            "monitoring".to_string(),
            "docker".to_string(),
            "system".to_string(),
            "metrics".to_string(),
        ],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-diagnostics".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "diagnostics-node".to_string(),
                path: "mecha10-nodes-diagnostics".to_string(), // Package name for monorepo
                config: None,
                description: "System diagnostics node from monorepo (cargo run -p mecha10-nodes-diagnostics)"
                    .to_string(),
                run_target: "remote".to_string(), // Runs as service/remote node
                enabled: true,
            }),
            behavior: None,
        },
    });

    // WebSocket Bridge node - Forwards Redis pub/sub to WebSocket clients
    catalog.insert(Component {
        id: "websocket-bridge".to_string(),
        name: "websocket-bridge".to_string(),
        description:
            "WebSocket bridge node that forwards Redis pub/sub messages to WebSocket clients for browser consumption"
                .to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "websocket".to_string(),
            "bridge".to_string(),
            "pubsub".to_string(),
            "dashboard".to_string(),
        ],
        cargo_dependencies: vec![CargoDependency {
            name: "mecha10-nodes-websocket-bridge".to_string(),
            version: Some("0.1".to_string()),
            path: None,
            features: vec![],
            optional: false,
        }],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "websocket-bridge".to_string(),
                path: "mecha10-nodes-websocket-bridge".to_string(), // Package name for monorepo
                config: None,
                description: "WebSocket bridge node from monorepo (cargo run -p mecha10-nodes-websocket-bridge)"
                    .to_string(),
                run_target: "robot".to_string(), // Runs on robot to forward Redis messages
                enabled: true,
            }),
            behavior: None,
        },
    });

    // Behavior Executor node - Executes behavior trees for autonomous control
    catalog.insert(Component {
        id: "behavior-executor".to_string(),
        name: "behavior-executor".to_string(),
        description: "Behavior tree executor node for autonomous robot behaviors (idle_wander, patrol, navigation)"
            .to_string(),
        component_type: ComponentType::Package,
        version: "0.1.0".to_string(),
        category: "nodes".to_string(),
        tags: vec![
            "behavior".to_string(),
            "autonomous".to_string(),
            "ai".to_string(),
            "navigation".to_string(),
        ],
        cargo_dependencies: vec![
            CargoDependency {
                name: "mecha10-nodes-behavior-executor".to_string(),
                version: Some("0.1".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
            CargoDependency {
                name: "mecha10-behavior-runtime".to_string(),
                version: Some("0.1".to_string()),
                path: None,
                features: vec![],
                optional: false,
            },
        ],
        files: vec![],
        mecha10_config: Mecha10Config {
            driver: None,
            custom_node: Some(CustomNodeConfig {
                name: "behavior-executor".to_string(),
                path: "mecha10-nodes-behavior-executor".to_string(),
                config: None, // Config loaded from configs/nodes/@mecha10/behavior-executor/config.json
                description: "Behavior executor node from monorepo (cargo run -p mecha10-nodes-behavior-executor)"
                    .to_string(),
                run_target: "robot".to_string(),
                enabled: true,
            }),
            behavior: None,
        },
    });
}
