'use client';

import {Navbar1} from "@/components/layouts/Navbar"
import {SideBarOld} from '@/components/layouts/SideBar/SideBarOld'
import '@/styles/globals.css'
import { ThemeProvider } from 'next-themes'
import { usePathname } from 'next/navigation'
import { Building2, Users, Cog, Activity, Mail, UserCircle, Database, Map, BarChart3, Cloud, TrendingUp, GitCompare, AlertTriangle, FileText, MapPin, Settings, User, Package, Navigation, Zap, Target, PieChart, Calendar, Shield, Tractor, Clipboard, ClipboardCheck, Brain, Droplets, Book, ShoppingCart } from 'lucide-react'

const navbarData = {
  logo: {
    url: "/",
    src: "https://deifkwefumgah.cloudfront.net/shadcnblocks/block/logos/shadcnblockscom-icon.svg",
    alt: "Crop-X Logo",
    title: "智慧农业生产管理系统",
  },
  menu: [
    {
      title: "智能农机管理系统",
      url: "/agricultural-machinery",
      description: "农机档案、实时监控、精准作业管理",
      icon: <Tractor className="size-5 shrink-0" />,
    },
    {
      title: "地块信息管理系统",
      url: "/land-information",
      description: "地块档案、地图管理、空间分析",
      icon: <Map className="size-5 shrink-0" />,
    },
    {
      title: "农事操作管理系统",
      url: "/farming-operation",
      description: "农事计划、任务管理、操作执行",
      icon: <Clipboard className="size-5 shrink-0" />,
    },
    {
      title: "农业资产管理系统",
      url: "/agricultural-asset",
      description: "基础信息、采购管理、库存管理",
      icon: <Package className="size-5 shrink-0" />,
    },
    {
      title: "AI作物模型精准决策系统",
      url: "/ai-crop-model",
      description: "数据感知、模型应用、智能决策",
      icon: <Brain className="size-5 shrink-0" />,
    },
    {
      title: "水肥一体化控制系统",
      url: "/water-fertilizer-control",
      description: "水肥机管理、智能灌溉、配方管理",
      icon: <Droplets className="size-5 shrink-0" />,
    },
    {
      title: "中心配置管理系统",
      url: "/central-config",
      description: "租户管理、用户管理、系统监控",
      icon: <Settings className="size-5 shrink-0" />,
    },
    {
      title: "API 测试示例",
      url: "/api-example",
      description: "测试和展示 OpenAPI 客户端调用",
      icon: <Brain className="size-5 shrink-0" />,
    },
  ],
  auth: {
    login: { title: "登录", url: "/login" },
    signup: { title: "注册", url: "/register" },
  },
};

const centralConfigData = {
  navMain: [
    {
      title: '个人中心',
      url: "/central-config/personal-center",
      icon: <UserCircle className="w-4 h-4" />,
      items: [
        {
          title: "个人信息",
          url: "/central-config/personal-center/personal-info",
          isActive: false
        },{
          title: "账户安全",
          url: "/central-config/personal-center/account-security",
          isActive: false
        },
      ]
    },
    {
      title: "租户管理",
      url: "/central-config/tenant",
      icon: <Building2 className="w-4 h-4" />,
      items: [
        {
          title: "企业管理",
          url: "/central-config/tenant/enterprise-management",
          isActive: false
        },
        {
          title: "企业审核",
          url: "/central-config/tenant/enterprise-audit",
          isActive: false
        },
        {
          title: "审核历史",
          url: "/central-config/tenant/audit-history",
          isActive: false
        },
        {
          title: "企业信息",
          url: "/central-config/tenant/enterprise-info",
          isActive: false
        },
        {
          title: "用户管理",
          url: "/central-config/tenant/user-management",
          isActive: false
        }
      ]
    },
    {
      title: "用户管理",
      url: "/central-config/user",
      icon: <Users className="w-4 h-4" />,
      items: [
        {
          title: "员工管理",
          url: "/central-config/user/employee",
          isActive: false
        },
        {
          title: "角色管理",
          url: "/central-config/user/role",
          isActive: false
        },
        {
          title: "菜单管理",
          url: "/central-config/user/menu",
          isActive: false
        },
        {
          title: "权限配置管理",
          url: "/central-config/user/permission",
          isActive: false
        }
      ]
    },
    {
      title: "系统参数",
      url: "/central-config/system",
      icon: <Cog className="w-4 h-4" />,
      items: [
        {
          title: "系统设置",
          url: "/central-config/system/settings",
          isActive: false
        },
        {
          title: "分类字典",
          url: "/central-config/system/category",
          isActive: false
        },
        {
          title: "数据字典",
          url: "/central-config/system/dictionary",
          isActive: false
        }
      ]
    },
    {
      title: "系统监控",
      url: "/central-config/monitor",
      icon: <Activity className="w-4 h-4" />,
      items: [
        {
          title: "登录日志",
          url: "/central-config/monitor/login-log",
          isActive: false
        },
        {
          title: "操作日志",
          url: "/central-config/monitor/operation-log",
          isActive: false
        },
        {
          title: "性能监控",
          url: "/central-config/monitor/performance",
          isActive: false
        },
        {
          title: "网络日志",
          url: "/central-config/monitor/network-log",
          isActive: false
        }
      ]
    },
    {
      title: "消息中心",
      url: "/central-config/message",
      icon: <Mail className="w-4 h-4" />,
      items: [
        {
          title: "消息发送",
          url: "/central-config/message/send",
          isActive: false
        },
        {
          title: "消息模版",
          url: "/central-config/message/template",
          isActive: false
        },
        {
          title: "消息日志",
          url: "/central-config/message/log",
          isActive: false
        }
      ]
    }
  ]
}
// 地块信息管理
const fieldMessageManagement = {
  navMain: [
    {
      title: "地块档案管理",
      url: "/land-information/archive",
      icon: <FileText className="w-4 h-4" />,
      items: [
        {
          title: "地块档案管理",
          url: "/land-information/archive/manage",
          isActive: false
        },
        {
          title: "地块分类与标签管理",
          url: "/land-information/archive/classification",
          isActive: false
        },
        {
          title: "统计分析",
          url: "/land-information/archive/statistics",
          isActive: false
        }
      ]
    },
    {
      title: "地块数字化与地图管理",
      url: "/land-information/map",
      icon: <Map className="w-4 h-4" />,
      items: [
        {
          title: "GIS地图管理",
          url: "/land-information/map/gis",
          isActive: false
        },
        {
          title: "数字化绘制与编辑",
          url: "/land-information/map/draw",
          isActive: false
        },
        {
          title: "空间数据管理",
          url: "/land-information/map/spatial-query",
          isActive: false
        },
        {
          title: "地块影像",
          url: "/land-information/map/satellite",
          isActive: false
        }
      ]
    },
    {
      title: "空间分析与决策支持",
      url: "/land-information/analysis",
      icon: <TrendingUp className="w-4 h-4" />,
      items: [
        {
          title: "土壤基础数据",
          url: "/land-information/analysis/soil-data",
          isActive: false
        },
        {
          title: "分层采样分析",
          url: "/land-information/analysis/layer-sampling",
          isActive: false
        },
        {
          title: "土壤质量评价",
          url: "/land-information/analysis/soil-quality",
          isActive: false
        }
      ]
    },
    {
      title: "地块环境监测",
      url: "/land-information/monitoring",
      icon: <Cloud className="w-4 h-4" />,
      items: [
        {
          title: "气象监测",
          url: "/land-information/monitoring/weather",
          isActive: false
        },
        {
          title: "环境监测",
          url: "/land-information/monitoring/environment",
          isActive: false
        }
      ]
    },
    {
      title: "地块适宜性评价",
      url: "/land-information/suitability",
      icon: <ClipboardCheck className="w-4 h-4" />,
      items: [
        {
          title: "多因子综合评价",
          url: "/land-information/suitability/comprehensive",
          isActive: false
        },
        {
          title: "自动化空间分析",
          url: "/land-information/suitability/batch",
          isActive: false
        },
        {
          title: "作物适配推荐",
          url: "/land-information/suitability/crop",
          isActive: false
        }
      ]
    },
    {
      title: "地块对比分析",
      url: "/land-information/comparison",
      icon: <GitCompare className="w-4 h-4" />,
      items: [
        {
          title: "多维度指标看板",
          url: "/land-information/comparison/indicator",
          isActive: false
        },
        {
          title: "可视化图表分析",
          url: "/land-information/comparison/chart",
          isActive: false
        },
        {
          title: "对比报告生成",
          url: "/land-information/comparison/report",
          isActive: false
        }
      ]
    },
    {
      title: "地块风险预警",
      url: "/land-information/risk",
      icon: <AlertTriangle className="w-4 h-4" />,
      items: [
        {
          title: "实时风险监测",
          url: "/land-information/risk/monitoring",
          isActive: false
        },
        {
          title: "预警推送管理",
          url: "/land-information/risk/push",
          isActive: false
        },
        {
          title: "预警处置跟踪",
          url: "/land-information/risk/disposal",
          isActive: false
        }
      ]
    }
  ]
}

// 农机管理
const machineryManagement = {
  navMain: [
    {
      title: "农机档案",
      url: "/agricultural-machinery/archive",
      icon: <Package className="w-4 h-4" />,
      items: [
        {
          title: "农机录入维护",
          url: "/agricultural-machinery/archive/entry",
          isActive: false
        },
        {
          title: "农机分类管理",
          url: "/agricultural-machinery/archive/classification",
          isActive: false
        },
        {
          title: "农机二维码管理",
          url: "/agricultural-machinery/archive/qrcode",
          isActive: false
        }
      ]
    },
    {
      title: "驾驶员档案",
      url: "/agricultural-machinery/driver-archive",
      icon: <User className="w-4 h-4" />,
      items: [
        {
          title: "驾驶员信息管理",
          url: "/agricultural-machinery/driver-archive/info",
          isActive: false
        },
        {
          title: "驾驶员任务管理",
          url: "/agricultural-machinery/driver-archive/task",
          isActive: false
        }
      ]
    },
    {
      title: "农机负载管理",
      url: "/agricultural-machinery/load-management",
      icon: <Settings className="w-4 h-4" />,
      items: [
        {
          title: "负载类型管理",
          url: "/agricultural-machinery/load-management/type",
          isActive: false
        },
        {
          title: "负载参数管理",
          url: "/agricultural-machinery/load-management/parameter",
          isActive: false
        },
        {
          title: "负载设备库",
          url: "/agricultural-machinery/load-management/library",
          isActive: false
        },
        {
          title: "负载设备管理",
          url: "/agricultural-machinery/load-management/device",
          isActive: false
        }
      ]
    },
    {
      title: "设备实时监控与定位",
      url: "/agricultural-machinery/monitoring",
      icon: <Navigation className="w-4 h-4" />,
      items: [
        {
          title: "实时定位监控",
          url: "/agricultural-machinery/monitoring/location",
          isActive: false
        },
        {
          title: "作业状态监控",
          url: "/agricultural-machinery/monitoring/status",
          isActive: false
        },
        {
          title: "作业数据监控",
          url: "/agricultural-machinery/monitoring/operation",
          isActive: false
        }
      ]
    },
    {
      title: "远程诊断与故障预警",
      url: "/agricultural-machinery/fault-diagnosis",
      icon: <Zap className="w-4 h-4" />,
      items: [
        {
          title: "故障预警规则",
          url: "/agricultural-machinery/fault-diagnosis/alert-rules",
          isActive: false
        },
        {
          title: "故障预警管理",
          url: "/agricultural-machinery/fault-diagnosis/warning",
          isActive: false
        },
        {
          title: "设备健康管理",
          url: "/agricultural-machinery/fault-diagnosis/health",
          isActive: false
        },
        {
          title: "设备参数监控",
          url: "/agricultural-machinery/fault-diagnosis/parameter",
          isActive: false
        }
      ]
    },
    {
      title: "精准作业管理与支持",
      url: "/agricultural-machinery/precision-operation",
      icon: <Target className="w-4 h-4" />,
      items: [
        {
          title: "作业记录管理",
          url: "/agricultural-machinery/precision-operation/record",
          isActive: false
        },
        {
          title: "路径规划管理",
          url: "/agricultural-machinery/precision-operation/route",
          isActive: false
        },
        {
          title: "作业计划调度",
          url: "/agricultural-machinery/precision-operation/dispatch",
          isActive: false
        },
        {
          title: "作业驾驶舱",
          url: "/agricultural-machinery/precision-operation/cockpit",
          isActive: false
        }
      ]
    },
    {
      title: "数据管理与分析报告",
      url: "/agricultural-machinery/data-analysis",
      icon: <PieChart className="w-4 h-4" />,
      items: [
        {
          title: "作业数据分析",
          url: "/agricultural-machinery/data-analysis/analysis",
          isActive: false
        },
        {
          title: "历史数据对比",
          url: "/agricultural-machinery/data-analysis/comparison",
          isActive: false
        }
      ]
    },
    {
      title: "农机管理与调度",
      url: "/agricultural-machinery/scheduling",
      icon: <Calendar className="w-4 h-4" />,
      items: [
        {
          title: "任务分配管理",
          url: "/agricultural-machinery/scheduling/assignment",
          isActive: false
        },
        {
          title: "实时调度管理",
          url: "/agricultural-machinery/scheduling/dispatch",
          isActive: false
        },
        {
          title: "轨迹回放管理",
          url: "/agricultural-machinery/scheduling/playback",
          isActive: false
        }
      ]
    },
    {
      title: "安全与安防",
      url: "/agricultural-machinery/security",
      icon: <Shield className="w-4 h-4" />,
      items: [
        {
          title: "地理围栏管理",
          url: "/agricultural-machinery/security/fence",
          isActive: false
        }
      ]
    }
  ]
}

// 农事操作管理系统
const farmingOperation = {
  navMain: [
    {
      title: "农事计划",
      url: "/farming-operation/planning",
      icon: <Calendar className="w-4 h-4" />,
      items: [
        {
          title: "农事计划创建",
          url: "/farming-operation/planning/creation",
          isActive: false
        },
        {
          title: "农事计划分配",
          url: "/farming-operation/planning/allocation",
          isActive: false
        },
        {
          title: "农事计划进度",
          url: "/farming-operation/planning/progress",
          isActive: false
        }
      ]
    },
    {
      title: "农事任务",
      url: "/farming-operation/task",
      icon: <FileText className="w-4 h-4" />,
      items: [
        {
          title: "任务管理",
          url: "/farming-operation/task/management",
          isActive: false
        },
        {
          title: "任务分配",
          url: "/farming-operation/task/assignment",
          isActive: false
        },
        {
          title: "任务监控",
          url: "/farming-operation/task/monitoring",
          isActive: false
        },
        {
          title: "任务统计",
          url: "/farming-operation/task/statistics",
          isActive: false
        }
      ]
    },
    {
      title: "农事执行",
      url: "/farming-operation/execution",
      icon: <Zap className="w-4 h-4" />,
      items: [
        {
          title: "执行类型",
          url: "/farming-operation/execution/type",
          isActive: false
        },
        {
          title: "执行记录",
          url: "/farming-operation/execution/record",
          isActive: false
        },
        {
          title: "执行日志",
          url: "/farming-operation/execution/log",
          isActive: false
        }
      ]
    },
    {
      title: "农事日历",
      url: "/farming-operation/calendar",
      icon: <Calendar className="w-4 h-4" />,
      items: [
        {
          title: "日历视图",
          url: "/farming-operation/calendar/view",
          isActive: false
        },
        {
          title: "甘特图",
          url: "/farming-operation/calendar/gantt",
          isActive: false
        },
        {
          title: "进度跟踪",
          url: "/farming-operation/calendar/progress",
          isActive: false
        }
      ]
    },
    {
      title: "农事档案",
      url: "/farming-operation/archive",
      icon: <Database className="w-4 h-4" />,
      items: [
        {
          title: "档案聚合",
          url: "/farming-operation/archive/aggregation",
          isActive: false
        },
        {
          title: "档案查看",
          url: "/farming-operation/archive/view",
          isActive: false
        },
        {
          title: "档案追溯",
          url: "/farming-operation/archive/trace",
          isActive: false
        }
      ]
    },
    {
      title: "农事知识库",
      url: "/farming-operation/knowledge",
      icon: <Book className="w-4 h-4" />,
      items: [
        {
          title: "知识管理",
          url: "/farming-operation/knowledge/management",
          isActive: false
        },
        {
          title: "知识分类",
          url: "/farming-operation/knowledge/category",
          isActive: false
        },
        {
          title: "知识搜索",
          url: "/farming-operation/knowledge/search",
          isActive: false
        }
      ]
    },
    {
      title: "绩效管理",
      url: "/farming-operation/performance",
      icon: <BarChart3 className="w-4 h-4" />,
      items: [
        {
          title: "员工绩效",
          url: "/farming-operation/performance/staff",
          isActive: false
        },
        {
          title: "工时统计",
          url: "/farming-operation/performance/hours",
          isActive: false
        },
        {
          title: "绩效统计",
          url: "/farming-operation/performance/statistics",
          isActive: false
        },
        {
          title: "绩效调度",
          url: "/farming-operation/performance/schedule",
          isActive: false
        }
      ]
    },
    {
      title: "农事问题协同",
      url: "/farming-operation/issue",
      icon: <Users className="w-4 h-4" />,
      items: [
        {
          title: "问题上报",
          url: "/farming-operation/issue/report",
          isActive: false
        },
        {
          title: "问题分配",
          url: "/farming-operation/issue/assign",
          isActive: false
        },
        {
          title: "问题协同",
          url: "/farming-operation/issue/collaborate",
          isActive: false
        }
      ]
    }
  ]
}

// 农业资产管理系统
const agricultureAsset = {
  navMain: [
    {
      title: "基础信息管理",
      url: "/agricultural-asset/basic",
      icon: <Database className="w-4 h-4" />,
      items: [
        {
          title: "物料信息",
          url: "/agricultural-asset/basic/materials",
          isActive: false
        },
        {
          title: "农具信息",
          url: "/agricultural-asset/basic/tools",
          isActive: false
        },
        {
          title: "供应商信息",
          url: "/agricultural-asset/basic/suppliers",
          isActive: false
        },
        {
          title: "客户信息",
          url: "/agricultural-asset/basic/customers",
          isActive: false
        }
      ]
    },
    {
      title: "采购管理",
      url: "/agricultural-asset/purchase",
      icon: <ShoppingCart className="w-4 h-4" />,
      items: [
        {
          title: "采购计划",
          url: "/agricultural-asset/purchase/plan",
          isActive: false
        },
        {
          title: "采购订单",
          url: "/agricultural-asset/purchase/order",
          isActive: false
        }
      ]
    },
    {
      title: "库存管理",
      url: "/agricultural-asset/inventory",
      icon: <Package className="w-4 h-4" />,
      items: [
        {
          title: "入库管理",
          url: "/agricultural-asset/inventory/in",
          isActive: false
        },
        {
          title: "出库管理",
          url: "/agricultural-asset/inventory/out",
          isActive: false
        },
        {
          title: "库存盘点",
          url: "/agricultural-asset/inventory/check",
          isActive: false
        },
        {
          title: "库存预警",
          url: "/agricultural-asset/inventory/warning",
          isActive: false
        },
        {
          title: "库存明细",
          url: "/agricultural-asset/inventory/detail",
          isActive: false
        },
        {
          title: "库位管理",
          url: "/agricultural-asset/inventory/location",
          isActive: false
        },
        {
          title: "补货建议",
          url: "/agricultural-asset/inventory/suggest",
          isActive: false
        }
      ]
    },
    {
      title: "物资领用",
      url: "/agricultural-asset/requisition",
      icon: <FileText className="w-4 h-4" />,
      items: [
        {
          title: "领用申请",
          url: "/agricultural-asset/requisition/apply",
          isActive: false
        },
        {
          title: "领用审批",
          url: "/agricultural-asset/requisition/approval",
          isActive: false
        },
        {
          title: "领用发放",
          url: "/agricultural-asset/requisition/checkout",
          isActive: false
        },
        {
          title: "领用记录",
          url: "/agricultural-asset/requisition/record",
          isActive: false
        }
      ]
    },
    {
      title: "物资归还",
      url: "/agricultural-asset/return",
      icon: <GitCompare className="w-4 h-4" />,
      items: [
        {
          title: "归还登记",
          url: "/agricultural-asset/return/register",
          isActive: false
        },
        {
          title: "归还处理",
          url: "/agricultural-asset/return/process",
          isActive: false
        },
        {
          title: "归还结算",
          url: "/agricultural-asset/return/settlement",
          isActive: false
        },
        {
          title: "归还历史",
          url: "/agricultural-asset/return/history",
          isActive: false
        }
      ]
    },
    {
      title: "农资农具管理",
      url: "/agricultural-asset/equipment",
      icon: <Tractor className="w-4 h-4" />,
      items: [
        {
          title: "设备档案",
          url: "/agricultural-asset/equipment/archive",
          isActive: false
        },
        {
          title: "设备调度",
          url: "/agricultural-asset/equipment/dispatch",
          isActive: false
        },
        {
          title: "设备维护",
          url: "/agricultural-asset/equipment/maintenance",
          isActive: false
        },
        {
          title: "设备折旧",
          url: "/agricultural-asset/equipment/depreciation",
          isActive: false
        },
        {
          title: "设备处置",
          url: "/agricultural-asset/equipment/disposal",
          isActive: false
        }
      ]
    },
    {
      title: "可视化报表",
      url: "/agricultural-asset/report",
      icon: <PieChart className="w-4 h-4" />,
      items: [
        {
          title: "总览报表",
          url: "/agricultural-asset/report/overview",
          isActive: false
        },
        {
          title: "库存报表",
          url: "/agricultural-asset/report/inventory",
          isActive: false
        },
        {
          title: "消耗报表",
          url: "/agricultural-asset/report/consumption",
          isActive: false
        }
      ]
    }
  ]
}

// AI作物模型精准决策系统
const aiCropModel = {
  navMain: [
    {
      title: "全域数据感知中心",
      url: "/ai-crop-model/data-center",
      icon: <Cloud className="w-4 h-4" />,
      items: [
        {
          title: "外部数据",
          url: "/ai-crop-model/data-center/external",
          isActive: false
        },
        {
          title: "IoT数据",
          url: "/ai-crop-model/data-center/iot",
          isActive: false
        }
      ]
    },
    {
      title: "模型接入集成",
      url: "/ai-crop-model/model-integration",
      icon: <Zap className="w-4 h-4" />,
      items: [
        {
          title: "模型接入",
          url: "/ai-crop-model/model-integration/access",
          isActive: false
        },
        {
          title: "模型管理",
          url: "/ai-crop-model/model-integration/management",
          isActive: false
        }
      ]
    },
    {
      title: "模型应用中心",
      url: "/ai-crop-model/model-application",
      icon: <Target className="w-4 h-4" />,
      items: [
        {
          title: "生成调度",
          url: "/ai-crop-model/model-application/generation",
          isActive: false
        },
        {
          title: "应用调度",
          url: "/ai-crop-model/model-application/scheduling",
          isActive: false
        }
      ]
    },
    {
      title: "智能决策生成",
      url: "/ai-crop-model/decision",
      icon: <Brain className="w-4 h-4" />,
      items: [
        {
          title: "融合决策",
          url: "/ai-crop-model/decision/fusion",
          isActive: false
        },
        {
          title: "决策仿真",
          url: "/ai-crop-model/decision/simulation",
          isActive: false
        },
        {
          title: "决策日志",
          url: "/ai-crop-model/decision/log",
          isActive: false
        }
      ]
    },
    {
      title: "智能决策支持",
      url: "/ai-crop-model/support",
      icon: <BarChart3 className="w-4 h-4" />,
      items: [
        {
          title: "决策仪表盘",
          url: "/ai-crop-model/support/dashboard",
          isActive: false
        },
        {
          title: "决策详情",
          url: "/ai-crop-model/support/detail",
          isActive: false
        }
      ]
    },
    {
      title: "决策应用",
      url: "/ai-crop-model/application",
      icon: <Settings className="w-4 h-4" />,
      items: [
        {
          title: "设备控制",
          url: "/ai-crop-model/application/device-control",
          isActive: false
        },
        {
          title: "外部系统",
          url: "/ai-crop-model/application/external-system",
          isActive: false
        }
      ]
    },
    {
      title: "AI知识库",
      url: "/ai-crop-model/knowledge",
      icon: <Book className="w-4 h-4" />,
      items: [
        {
          title: "知识生成",
          url: "/ai-crop-model/knowledge/generation",
          isActive: false
        }
      ]
    },
    {
      title: "监控中心",
      url: "/ai-crop-model/monitoring",
      icon: <AlertTriangle className="w-4 h-4" />,
      items: [
        {
          title: "模型监控",
          url: "/ai-crop-model/monitoring/model",
          isActive: false
        },
        {
          title: "审计监控",
          url: "/ai-crop-model/monitoring/audit",
          isActive: false
        },
        {
          title: "预警监控",
          url: "/ai-crop-model/monitoring/alert",
          isActive: false
        }
      ]
    }
  ]
}

// 水肥一体化控制系统
const waterFertilizerControl = {
  navMain: [
    {
      title: "水肥机管理",
      url: "/water-fertilizer-control/wf-management",
      icon: <Package className="w-4 h-4" />,
      items: [
        {
          title: "设备管理",
          url: "/water-fertilizer-control/wf-management/device",
          isActive: false
        },
        {
          title: "组件管理",
          url: "/water-fertilizer-control/wf-management/component",
          isActive: false
        },
        {
          title: "参数配置",
          url: "/water-fertilizer-control/wf-management/parameter",
          isActive: false
        },
        {
          title: "映射关系",
          url: "/water-fertilizer-control/wf-management/mapping",
          isActive: false
        }
      ]
    },
    {
      title: "智能灌溉",
      url: "/water-fertilizer-control/smart",
      icon: <TrendingUp className="w-4 h-4" />,
      items: [
        {
          title: "模型配置",
          url: "/water-fertilizer-control/smart/model-config",
          isActive: false
        },
        {
          title: "自动灌溉",
          url: "/water-fertilizer-control/smart/auto",
          isActive: false
        },
        {
          title: "手动灌溉",
          url: "/water-fertilizer-control/smart/manual",
          isActive: false
        },
        {
          title: "实时监控",
          url: "/water-fertilizer-control/smart/realtime",
          isActive: false
        },
        {
          title: "历史记录",
          url: "/water-fertilizer-control/smart/history",
          isActive: false
        }
      ]
    },
    {
      title: "施肥配方管理",
      url: "/water-fertilizer-control/fertilizer",
      icon: <Droplets className="w-4 h-4" />,
      items: [
        {
          title: "水量控制",
          url: "/water-fertilizer-control/fertilizer/water-control",
          isActive: false
        },
        {
          title: "液位设定",
          url: "/water-fertilizer-control/fertilizer/level-setting",
          isActive: false
        },
        {
          title: "搅拌控制",
          url: "/water-fertilizer-control/fertilizer/stirring-control",
          isActive: false
        },
        {
          title: "历史数据",
          url: "/water-fertilizer-control/fertilizer/history-data",
          isActive: false
        }
      ]
    },
    {
      title: "水肥控制",
      url: "/water-fertilizer-control/wf-control",
      icon: <Settings className="w-4 h-4" />,
      items: [
        {
          title: "参数设置",
          url: "/water-fertilizer-control/wf-control/params",
          isActive: false
        },
        {
          title: "水箱实时监控",
          url: "/water-fertilizer-control/wf-control/tank-realtime",
          isActive: false
        },
        {
          title: "阀门控制",
          url: "/water-fertilizer-control/wf-control/valve-control",
          isActive: false
        },
        {
          title: "阀门实时监控",
          url: "/water-fertilizer-control/wf-control/valve-realtime",
          isActive: false
        },
        {
          title: "施肥历史",
          url: "/water-fertilizer-control/wf-control/fertilizer-history",
          isActive: false
        },
        {
          title: "阀门历史",
          url: "/water-fertilizer-control/wf-control/valve-history",
          isActive: false
        }
      ]
    },
    {
      title: "实时监测与预警",
      url: "/water-fertilizer-control/monitoring",
      icon: <AlertTriangle className="w-4 h-4" />,
      items: [
        {
          title: "预警逻辑",
          url: "/water-fertilizer-control/monitoring/alert-logic",
          isActive: false
        },
        {
          title: "阈值预警",
          url: "/water-fertilizer-control/monitoring/threshold-alert",
          isActive: false
        },
        {
          title: "通知推送",
          url: "/water-fertilizer-control/monitoring/notification-push",
          isActive: false
        }
      ]
    }
  ]
}

function RootLayoutContent({
  children,
}: {
  children: React.ReactNode
}) {
  const pathname = usePathname();

  // 根据当前路径动态选择侧边栏数据
  const getSidebarData = () => {
    // 获取当前路径的一级路由
    const firstLevelPath = '/' + pathname.split('/')[1];

    switch (firstLevelPath) {
      case '/agricultural-machinery':
        return machineryManagement;
      case '/land-information':
        return fieldMessageManagement;
      case '/farming-operation':
        return farmingOperation;
      case '/agricultural-asset':
        return agricultureAsset;
      case '/ai-crop-model':
        return aiCropModel;
      case '/water-fertilizer-control':
        return waterFertilizerControl;
      case '/central-config':
        return centralConfigData;
      default:
        return machineryManagement; // 默认返回农机管理
    }
  };

  const sidebarData = getSidebarData();

  return (
    <div className="bodyFlexUpDown">
      <Navbar1 navbarData={navbarData} />
      <div className="bodySon2">
        <SideBarOld data={sidebarData}>
          {children}
        </SideBarOld>
      </div>
    </div>
  );
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="zh-CN" suppressHydrationWarning>
      <body suppressHydrationWarning>
        <ThemeProvider
          attribute="class"
          defaultTheme="system"
          enableSystem
          disableTransitionOnChange
        >
          <RootLayoutContent>{children}</RootLayoutContent>
        </ThemeProvider>
      </body>
    </html>
  )
}