use crate::DevelopmentType;
use rand::{prelude::*, rng};

pub fn generate_data_operation(dev_type: DevelopmentType) -> String {
    let operations = match dev_type {
        DevelopmentType::Backend => [
            "Processing batch transactions",
            "Syncing database replicas",
            "Aggregating analytics data",
            "Generating user activity reports",
            "Optimizing database indexes",
            "Compressing log archives",
            "Validating data integrity",
            "Processing webhook events",
            "Migrating legacy data",
            "Generating API documentation",
        ],
        DevelopmentType::Frontend => [
            "Processing user interaction events",
            "Optimizing rendering performance data",
            "Analyzing component render times",
            "Compressing asset bundles",
            "Processing form submission data",
            "Validating client-side data",
            "Generating localization files",
            "Analyzing user session flows",
            "Optimizing client-side caching",
            "Processing offline data sync",
        ],
        DevelopmentType::Fullstack => [
            "Synchronizing client-server data",
            "Processing distributed transactions",
            "Validating cross-system integrity",
            "Generating system topology maps",
            "Optimizing data transfer formats",
            "Analyzing API usage patterns",
            "Processing multi-tier cache data",
            "Generating integration test data",
            "Optimizing client-server protocols",
            "Validating end-to-end workflows",
        ],
        DevelopmentType::DataScience => [
            "Processing raw dataset",
            "Performing feature engineering",
            "Generating training batches",
            "Validating statistical significance",
            "Normalizing input features",
            "Generating cross-validation folds",
            "Analyzing feature importance",
            "Optimizing dimensionality reduction",
            "Processing time-series forecasts",
            "Generating data visualization assets",
        ],
        DevelopmentType::DevOps => [
            "Analyzing system log patterns",
            "Processing deployment metrics",
            "Generating infrastructure reports",
            "Validating security compliance",
            "Optimizing resource allocation",
            "Processing alert aggregation",
            "Analyzing performance bottlenecks",
            "Generating capacity planning models",
            "Validating configuration consistency",
            "Processing automated scaling events",
        ],
        DevelopmentType::Blockchain => [
            "Validating transaction blocks",
            "Processing consensus votes",
            "Generating merkle proofs",
            "Validating smart contract executions",
            "Analyzing gas optimization metrics",
            "Processing state transition deltas",
            "Generating network health reports",
            "Validating cross-chain transactions",
            "Optimizing storage proof generation",
            "Processing validator stake distribution",
        ],
        DevelopmentType::MachineLearning => [
            "Processing training batch",
            "Generating model embeddings",
            "Validating prediction accuracy",
            "Optimizing hyperparameters",
            "Processing inference requests",
            "Analyzing model sensitivity",
            "Generating feature importance maps",
            "Validating model robustness",
            "Optimizing model quantization",
            "Processing distributed training gradients",
        ],
        DevelopmentType::SystemsProgramming => [
            "Analyzing memory access patterns",
            "Processing thread scheduling metrics",
            "Generating heap fragmentation reports",
            "Validating lock contention patterns",
            "Optimizing cache utilization",
            "Processing syscall frequency analysis",
            "Analyzing I/O bottlenecks",
            "Generating performance flamegraphs",
            "Validating memory safety guarantees",
            "Processing interrupt handling metrics",
        ],
        DevelopmentType::GameDevelopment => [
            "Processing physics simulation batch",
            "Generating level of detail models",
            "Validating collision detection",
            "Optimizing rendering pipelines",
            "Processing animation blend trees",
            "Analyzing gameplay telemetry",
            "Generating procedural content",
            "Validating player progression data",
            "Optimizing asset streaming",
            "Processing particle system batches",
        ],
        DevelopmentType::Security => [
            "Analyzing threat intelligence data",
            "Processing security event logs",
            "Generating vulnerability reports",
            "Validating authentication patterns",
            "Optimizing encryption performance",
            "Processing network traffic analysis",
            "Analyzing anomaly detection signals",
            "Generating security compliance documentation",
            "Validating access control policies",
            "Processing certificate validation chains",
        ],
    };

    operations.choose(&mut rng()).unwrap().to_string()
}

pub fn generate_data_sub_operation(dev_type: DevelopmentType) -> String {
    let sub_operations = match dev_type {
        DevelopmentType::Backend | DevelopmentType::Fullstack => [
            "Applying data normalization rules",
            "Validating referential integrity",
            "Optimizing query execution plan",
            "Applying business rule validations",
            "Processing data transformation mappings",
            "Applying schema validation rules",
            "Executing incremental data updates",
            "Processing conditional logic branches",
            "Applying security filtering rules",
            "Executing transaction compensation logic",
        ],
        DevelopmentType::Frontend => [
            "Applying data binding transformations",
            "Validating input constraints",
            "Optimizing render tree calculations",
            "Processing event propagation",
            "Applying localization transforms",
            "Validating UI state consistency",
            "Processing animation frame calculations",
            "Applying accessibility transformations",
            "Executing conditional rendering logic",
            "Processing style calculation optimizations",
        ],
        DevelopmentType::DataScience | DevelopmentType::MachineLearning => [
            "Applying feature scaling transformations",
            "Validating statistical distributions",
            "Processing categorical encoding",
            "Executing outlier detection",
            "Applying missing value imputation",
            "Validating correlation significance",
            "Processing dimensionality reduction",
            "Applying cross-validation splits",
            "Executing feature selection algorithms",
            "Processing data augmentation transforms",
        ],
        _ => [
            "Applying transformation rules",
            "Validating integrity constraints",
            "Processing conditional logic",
            "Executing optimization algorithms",
            "Applying filtering criteria",
            "Validating consistency rules",
            "Processing batch operations",
            "Applying normalization steps",
            "Executing validation checks",
            "Processing incremental updates",
        ],
    };

    sub_operations.choose(&mut rng()).unwrap().to_string()
}

pub fn generate_data_details(dev_type: DevelopmentType) -> String {
    let details = match dev_type {
        DevelopmentType::Backend => [
            "Reduced database query time by 35% through index optimization",
            "Improved data integrity by implementing transaction boundaries",
            "Reduced API response size by 42% through selective field inclusion",
            "Optimized cache hit ratio increased to 87%",
            "Implemented sharded processing for 4.5x throughput improvement",
            "Reduced duplicate processing by implementing idempotency keys",
            "Applied compression resulting in 68% storage reduction",
            "Improved validation speed by 29% through optimized rule execution",
            "Reduced error rate from 2.3% to 0.5% with improved validation",
            "Implemented batch processing for 3.2x throughput improvement",
        ],
        DevelopmentType::Frontend => [
            "Reduced bundle size by 28% through tree-shaking optimization",
            "Improved render performance by 45% with memo optimization",
            "Reduced time-to-interactive by 1.2 seconds",
            "Implemented virtualized rendering for 5x scrolling performance",
            "Reduced network payload by 37% through selective data loading",
            "Improved animation smoothness with requestAnimationFrame optimization",
            "Reduced layout thrashing by 82% with optimized DOM operations",
            "Implemented progressive loading for 2.3s perceived performance improvement",
            "Improved form submission speed by 40% with optimized validation",
            "Reduced memory usage by 35% with proper cleanup of event listeners",
        ],
        DevelopmentType::DataScience | DevelopmentType::MachineLearning => [
            "Improved model accuracy by 3.7% through feature engineering",
            "Reduced training time by 45% with optimized batch processing",
            "Improved inference latency by 28% through model optimization",
            "Reduced dimensionality from 120 to 18 features while maintaining 98.5% variance",
            "Improved data throughput by 3.2x with parallel processing",
            "Reduced memory usage by 67% with sparse matrix representation",
            "Improved cross-validation speed by 2.8x with optimized splitting",
            "Reduced prediction variance by 18% with ensemble techniques",
            "Improved outlier detection precision from 82% to 96.5%",
            "Reduced training data requirements by 48% with data augmentation",
        ],
        DevelopmentType::DevOps => [
            "Reduced deployment time by 68% through pipeline optimization",
            "Improved resource utilization by 34% with optimized allocation",
            "Reduced error rate by 76% with improved validation checks",
            "Implemented auto-scaling resulting in 28% cost reduction",
            "Improved monitoring coverage to 98.5% of critical systems",
            "Reduced incident response time by 40% through automated alerting",
            "Improved configuration consistency to 99.8% across environments",
            "Reduced security vulnerabilities by 85% through automated scanning",
            "Improved backup reliability to 99.99% with verification",
            "Reduced network latency by 25% with optimized routing",
        ],
        DevelopmentType::Blockchain => [
            "Reduced transaction validation time by 35% with optimized algorithms",
            "Improved smart contract execution efficiency by 28% through gas optimization",
            "Reduced storage requirements by 47% with optimized data structures",
            "Implemented sharding for 4.2x throughput improvement",
            "Improved consensus time by 38% with optimized protocols",
            "Reduced network propagation delay by 42% with optimized peer selection",
            "Improved cryptographic verification speed by 30% with batch processing",
            "Reduced fork rate by 75% with improved synchronization",
            "Implemented state pruning for 68% storage reduction",
            "Improved validator participation rate to 97.8% with incentive optimization",
        ],
        _ => [
            "Reduced processing time by 40% through algorithm optimization",
            "Improved throughput by 3.5x with parallel processing",
            "Reduced error rate from 2.1% to 0.3% with improved validation",
            "Implemented batching for 2.8x performance improvement",
            "Reduced memory usage by 45% with optimized data structures",
            "Improved cache hit ratio to 92% with predictive loading",
            "Reduced latency by 65% with optimized processing paths",
            "Implemented incremental processing for 4.2x throughput on large datasets",
            "Improved consistency to 99.7% with enhanced validation",
            "Reduced resource contention by 80% with improved scheduling",
        ],
    };

    details.choose(&mut rng()).unwrap().to_string()
}
