<?php

namespace Database\Seeders;

use App\Models\Bot;
use App\Models\BotSetting;
use Illuminate\Database\Seeder;

class BotSeeder extends Seeder
{
    public function run(): void
    {
        $botsData = [
            [
                'name' => 'BullWave AI',
                'bot_type' => 'grid_ai',
                'trading_pair' => 'BTC/USDT',
                'status' => 'active',
                'min_amount' => 100.00,
                'max_amount' => 10000.00,
                'supported_pairs' => [
                    'BTC/USDT', 'ETH/USDT', 'SOL/USDT', 'XRP/USDT',
                    'ADA/USDT', 'LTC/USDT', 'BNB/USDT', 'DOGE/USDT'
                ],
                'duration_options' => [
                    '5 Minutes', '10 Minutes', '15 Minutes', '30 Minutes',
                    '1 Hour', '4 Hours', '12 Hours', '24 Hours',
                    '3 Days', '7 Days', '30 Days'
                ],
                'parameters' => [
                    'grid_levels' => 10,
                    'lower_limit' => 0.95,
                    'upper_limit' => 1.05,
                    'risk_level' => 'Medium',
                    'featured' => true,
                    'description' => 'BullWave AI is an advanced AI-powered grid trading bot that automatically buys low and sells high within predefined price ranges. It is designed for stable and sideways markets while minimizing risk through intelligent order placement.'
                ]
            ],
            [
                'name' => 'Nexus Trader',
                'bot_type' => 'trend_ai',
                'trading_pair' => 'BTC/USDT',
                'status' => 'active',
                'min_amount' => 250.00,
                'max_amount' => 50000.00,
                'supported_pairs' => [
                    'BTC/USDT', 'ETH/USDT', 'SOL/USDT', 'ADA/USDT',
                    'XRP/USDT', 'LTC/USDT', 'BNB/USDT'
                ],
                'duration_options' => [
                    '30 Minutes', '1 Hour', '4 Hours', '12 Hours',
                    '24 Hours', '3 Days', '7 Days', '30 Days'
                ],
                'parameters' => [
                    'grid_levels' => 20,
                    'lower_limit' => 0.90,
                    'upper_limit' => 1.10,
                    'risk_level' => 'Low',
                    'featured' => true,
                    'description' => 'Nexus Trader is an intelligent trend-following trading bot that analyzes market momentum using AI algorithms to identify profitable bullish and bearish opportunities. It is optimized for medium- and long-term automated trading.'
                ]
            ]
        ];

        foreach ($botsData as $data) {
            // Update or Create Bot record
            Bot::updateOrCreate(
                ['name' => $data['name']],
                [
                    'bot_type' => $data['bot_type'],
                    'trading_pair' => $data['trading_pair'],
                    'status' => $data['status'],
                    'min_amount' => $data['min_amount'],
                    'max_amount' => $data['max_amount'],
                ]
            );

            // Update or Create BotSetting record
            BotSetting::updateOrCreate(
                ['bot_type' => $data['bot_type']],
                [
                    'name' => $data['name'],
                    'is_active' => true,
                    'supported_pairs' => $data['supported_pairs'],
                    'duration_options' => $data['duration_options'],
                    'parameters' => $data['parameters'],
                ]
            );
        }
    }
}
