/**
 * Switch & Router Seed Data — Comprehensive global catalog
 *
 * Hand-curated seed data for major switch/router models from all vendors.
 * This provides the baseline that scrapers then enrich with live data.
 * Sources: Public datasheets, vendor product pages, OCP specs.
 */
import { pool, ensureVendor, findOrCreateSwitch } from "../utils/db";

interface SwitchSeed {
  vendor: string;
  vendorType: string;
  vendorWebsite: string;
  model: string;
  series: string;
  category: "DataCenter" | "Campus" | "Edge" | "Core" | "SP" | "Industrial";
  layer: "L2" | "L3" | "L2/L3";
  portsConfig: Record<string, number>;
  totalPorts: number;
  uplinkSpeedGbps?: number;
  maxSpeedGbps: number;
  switchingCapacityTbps?: number;
  forwardingRateMpps?: number;
  asicVendor?: string;
  asicModel?: string;
  rackUnits?: number;
  maxPowerW?: number;
  poeSupport?: string;
  stackingSupport?: boolean;
  vxlanSupport?: boolean;
  evpnSupport?: boolean;
  bgpSupport?: boolean;
  mplsSupport?: boolean;
  openconfigSupport?: boolean;
  sonicCompatible?: boolean;
  macsecSupport?: boolean;
  lifecycleStatus?: string;
  tags?: string[];
}

// ═══════════════════════════════════════════════════════
// ARISTA NETWORKS
// ═══════════════════════════════════════════════════════
const ARISTA: SwitchSeed[] = [
  // 7800R4 Series — Chassis (800G/400G spine)
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7800R4-36D2-LC", series: "7800R4", category: "DataCenter", layer: "L3",
    portsConfig: { "800G_OSFP": 36, "400G_QSFP-DD": 72 }, totalPorts: 36,
    maxSpeedGbps: 800, switchingCapacityTbps: 57.6, forwardingRateMpps: 36000,
    asicVendor: "Broadcom", asicModel: "Memory Tomahawk 5",
    rackUnits: 7, maxPowerW: 6000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    macsecSupport: true, sonicCompatible: false,
    tags: ["800G", "spine", "AI-fabric", "chassis"],
  },
  // 7060X6 Series — 800G fixed
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7060X6-64PE", series: "7060X6", category: "DataCenter", layer: "L3",
    portsConfig: { "800G_OSFP": 64 }, totalPorts: 64,
    maxSpeedGbps: 800, switchingCapacityTbps: 51.2, forwardingRateMpps: 30000,
    asicVendor: "Broadcom", asicModel: "Tomahawk 5",
    rackUnits: 2, maxPowerW: 3200,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    macsecSupport: true,
    tags: ["800G", "spine", "AI-fabric", "leaf"],
  },
  // 7060X5 Series — 400G spine/leaf
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7060X5-64S", series: "7060X5", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 64 }, totalPorts: 64,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6, forwardingRateMpps: 16000,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 2, maxPowerW: 2200,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    macsecSupport: true,
    tags: ["400G", "spine", "leaf"],
  },
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7060X5-32QS", series: "7060X5", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32, "100G_QSFP28": 2 }, totalPorts: 34,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 1, maxPowerW: 1200,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["400G", "leaf", "ToR"],
  },
  // 7050X4 Series — 100G/400G leaf
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7050X4-32S", series: "7050X4", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 32 }, totalPorts: 32,
    maxSpeedGbps: 100, switchingCapacityTbps: 6.4, forwardingRateMpps: 4760,
    asicVendor: "Broadcom", asicModel: "Memory Memory",
    rackUnits: 1, maxPowerW: 750,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    stackingSupport: true,
    tags: ["100G", "leaf", "ToR"],
  },
  // 7280R3 Series — Universal routing
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7280R3-48YC6", series: "7280R3", category: "Core", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 6 }, totalPorts: 54,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.6,
    asicVendor: "Broadcom", asicModel: "Jericho2",
    rackUnits: 1, maxPowerW: 950,
    bgpSupport: true, mplsSupport: true, evpnSupport: true, openconfigSupport: true,
    tags: ["routing", "peering", "DCI"],
  },
  // 7020R Series — Campus
  {
    vendor: "Arista Networks", vendorType: "oem", vendorWebsite: "https://www.arista.com",
    model: "7020R-48YM", series: "7020R", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 6 }, totalPorts: 54,
    maxSpeedGbps: 10, switchingCapacityTbps: 0.176,
    rackUnits: 1, maxPowerW: 450,
    poeSupport: "PoE++", stackingSupport: true,
    bgpSupport: true, macsecSupport: true,
    tags: ["campus", "PoE", "access"],
  },
];

// ═══════════════════════════════════════════════════════
// CISCO SYSTEMS
// ═══════════════════════════════════════════════════════
const CISCO: SwitchSeed[] = [
  // Nexus 9000 Series
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "N9K-C93600CD-GX", series: "Nexus 9300", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 28, "100G_QSFP28": 8 }, totalPorts: 36,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8, forwardingRateMpps: 8900,
    asicVendor: "Cisco", asicModel: "Cloud Scale",
    rackUnits: 1, maxPowerW: 2000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    openconfigSupport: true, macsecSupport: true,
    tags: ["400G", "ACI", "spine", "VXLAN"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "N9K-C9364D-GX2A", series: "Nexus 9300", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 64 }, totalPorts: 64,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6,
    asicVendor: "Cisco", asicModel: "Cloud Scale G2",
    rackUnits: 2, maxPowerW: 3000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["400G", "ACI", "spine"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "N9K-C9332D-GX2B", series: "Nexus 9300", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32, "100G_QSFP28": 2 }, totalPorts: 34,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Cisco", asicModel: "Cloud Scale G2",
    rackUnits: 1, maxPowerW: 1500,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["400G", "leaf", "ToR"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "N9K-C93108TC-FX3P", series: "Nexus 9300", category: "DataCenter", layer: "L3",
    portsConfig: { "10G_RJ45": 48, "100G_QSFP28": 6 }, totalPorts: 54,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.6,
    asicVendor: "Cisco", asicModel: "Cloud Scale",
    rackUnits: 1, maxPowerW: 1100,
    poeSupport: "PoE+", vxlanSupport: true, evpnSupport: true,
    tags: ["access", "ToR", "PoE"],
  },
  // Nexus 9500 Chassis
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "N9K-C9508", series: "Nexus 9500", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 576 }, totalPorts: 576,
    maxSpeedGbps: 400, switchingCapacityTbps: 172.8,
    asicVendor: "Cisco", asicModel: "Cloud Scale G2",
    rackUnits: 13, maxPowerW: 24000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["chassis", "spine", "modular", "ACI"],
  },
  // Catalyst 9000 — Campus
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "C9300-48UXM", series: "Catalyst 9300", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 36, "mGig_RJ45": 12, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10, switchingCapacityTbps: 0.480,
    rackUnits: 1, maxPowerW: 1100,
    poeSupport: "UPOE+", stackingSupport: true, macsecSupport: true,
    tags: ["campus", "PoE", "SD-Access", "DNA"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "C9300X-24Y", series: "Catalyst 9300X", category: "Campus", layer: "L3",
    portsConfig: { "25G_SFP28": 24, "100G_QSFP28": 2 }, totalPorts: 26,
    maxSpeedGbps: 100, switchingCapacityTbps: 1.2,
    rackUnits: 1, maxPowerW: 750,
    stackingSupport: true, vxlanSupport: true, macsecSupport: true,
    tags: ["campus", "distribution", "25G"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "C9500-48Y4C", series: "Catalyst 9500", category: "Campus", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 4 }, totalPorts: 52,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.2,
    rackUnits: 1, maxPowerW: 750,
    bgpSupport: true, vxlanSupport: true, evpnSupport: true, macsecSupport: true,
    tags: ["campus", "core", "SD-Access"],
  },
  // NCS 5500 — Service Provider
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "NCS-5504", series: "NCS 5500", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 288 }, totalPorts: 288,
    maxSpeedGbps: 400, switchingCapacityTbps: 57.6,
    asicVendor: "Cisco", asicModel: "Silicon One",
    rackUnits: 7, maxPowerW: 15000,
    bgpSupport: true, mplsSupport: true, evpnSupport: true,
    tags: ["SP", "core", "routing", "chassis", "MPLS"],
  },
  // Cisco 8000 — Silicon One
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "8101-32FH", series: "Cisco 8000", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Cisco", asicModel: "Silicon One Q200",
    rackUnits: 1, maxPowerW: 1800,
    bgpSupport: true, mplsSupport: true, evpnSupport: true, openconfigSupport: true,
    tags: ["SP", "peering", "core", "Silicon-One"],
  },
  {
    vendor: "Cisco Systems", vendorType: "oem", vendorWebsite: "https://www.cisco.com",
    model: "8111-32EH", series: "Cisco 8000", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Cisco", asicModel: "Silicon One G100",
    rackUnits: 1, maxPowerW: 1800,
    bgpSupport: true, mplsSupport: true, evpnSupport: true,
    tags: ["SP", "peering", "400G"],
  },
];

// ═══════════════════════════════════════════════════════
// JUNIPER NETWORKS
// ═══════════════════════════════════════════════════════
const JUNIPER: SwitchSeed[] = [
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "QFX5130-32CD", series: "QFX5130", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 1, maxPowerW: 1500,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["400G", "leaf", "spine"],
  },
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "QFX5220-32CD", series: "QFX5220", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32, "100G_QSFP28": 2 }, totalPorts: 34,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 3",
    rackUnits: 1, maxPowerW: 1400,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["400G", "leaf"],
  },
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "QFX5120-48Y", series: "QFX5120", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 8 }, totalPorts: 56,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.2,
    asicVendor: "Broadcom", asicModel: "Memory",
    rackUnits: 1, maxPowerW: 550,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["25G", "leaf", "ToR"],
  },
  // PTX Series — Core routing
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "PTX10004", series: "PTX10000", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 576 }, totalPorts: 576,
    maxSpeedGbps: 400, switchingCapacityTbps: 172.8,
    asicVendor: "Juniper", asicModel: "Express5",
    rackUnits: 8, maxPowerW: 18000,
    bgpSupport: true, mplsSupport: true, evpnSupport: true, openconfigSupport: true,
    tags: ["SP", "core", "chassis", "MPLS", "400G"],
  },
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "PTX10001-36MR", series: "PTX10000", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 36 }, totalPorts: 36,
    maxSpeedGbps: 400, switchingCapacityTbps: 14.4,
    asicVendor: "Juniper", asicModel: "Express5",
    rackUnits: 2, maxPowerW: 2500,
    bgpSupport: true, mplsSupport: true, evpnSupport: true,
    tags: ["SP", "peering", "400G"],
  },
  // EX Series — Campus
  {
    vendor: "Juniper Networks", vendorType: "oem", vendorWebsite: "https://www.juniper.net",
    model: "EX4400-48T", series: "EX4400", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4, "25G_SFP28": 2 }, totalPorts: 54,
    maxSpeedGbps: 25, switchingCapacityTbps: 0.200,
    rackUnits: 1, maxPowerW: 600,
    poeSupport: "PoE++", stackingSupport: true, macsecSupport: true,
    tags: ["campus", "access", "PoE"],
  },
];

// ═══════════════════════════════════════════════════════
// NOKIA (ex-Alcatel-Lucent)
// ═══════════════════════════════════════════════════════
const NOKIA: SwitchSeed[] = [
  {
    vendor: "Nokia", vendorType: "oem", vendorWebsite: "https://www.nokia.com",
    model: "7220 IXR-D3L", series: "7220 IXR", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32, "10G_SFP+": 2 }, totalPorts: 34,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 1, maxPowerW: 1400,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    sonicCompatible: true,
    tags: ["400G", "SR-Linux", "leaf"],
  },
  {
    vendor: "Nokia", vendorType: "oem", vendorWebsite: "https://www.nokia.com",
    model: "7750 SR-1e", series: "7750 SR", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 36 }, totalPorts: 36,
    maxSpeedGbps: 400, switchingCapacityTbps: 14.4,
    asicVendor: "Nokia", asicModel: "FP5",
    rackUnits: 2, maxPowerW: 3500,
    bgpSupport: true, mplsSupport: true, evpnSupport: true, openconfigSupport: true,
    tags: ["SP", "routing", "MPLS", "SR-OS"],
  },
  {
    vendor: "Nokia", vendorType: "oem", vendorWebsite: "https://www.nokia.com",
    model: "7750 SR-14s", series: "7750 SR", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 672 }, totalPorts: 672,
    maxSpeedGbps: 400, switchingCapacityTbps: 268.8,
    asicVendor: "Nokia", asicModel: "FP5",
    rackUnits: 22, maxPowerW: 38000,
    bgpSupport: true, mplsSupport: true, evpnSupport: true,
    tags: ["SP", "core", "chassis", "MPLS"],
  },
];

// ═══════════════════════════════════════════════════════
// HUAWEI
// ═══════════════════════════════════════════════════════
const HUAWEI: SwitchSeed[] = [
  {
    vendor: "Huawei", vendorType: "oem", vendorWebsite: "https://e.huawei.com",
    model: "CloudEngine 16800-X32", series: "CloudEngine 16800", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 768 }, totalPorts: 768,
    maxSpeedGbps: 400, switchingCapacityTbps: 230.4,
    asicVendor: "Huawei", asicModel: "Solar 6.0",
    rackUnits: 22, maxPowerW: 40000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["chassis", "spine", "AI-fabric"],
  },
  {
    vendor: "Huawei", vendorType: "oem", vendorWebsite: "https://e.huawei.com",
    model: "CloudEngine 8850-32CQ", series: "CloudEngine 8850", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 32 }, totalPorts: 32,
    maxSpeedGbps: 100, switchingCapacityTbps: 6.4,
    rackUnits: 1, maxPowerW: 950,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["100G", "leaf", "spine"],
  },
  {
    vendor: "Huawei", vendorType: "oem", vendorWebsite: "https://e.huawei.com",
    model: "NetEngine 8000 F8", series: "NetEngine 8000", category: "SP", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 192 }, totalPorts: 192,
    maxSpeedGbps: 400, switchingCapacityTbps: 57.6,
    asicVendor: "Huawei", asicModel: "Solar 6.0",
    rackUnits: 9, maxPowerW: 12000,
    bgpSupport: true, mplsSupport: true, evpnSupport: true,
    tags: ["SP", "core", "MPLS"],
  },
  {
    vendor: "Huawei", vendorType: "oem", vendorWebsite: "https://e.huawei.com",
    model: "S5731-H48T4XC", series: "S5700", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10, switchingCapacityTbps: 0.176,
    rackUnits: 1, maxPowerW: 600,
    poeSupport: "PoE++", stackingSupport: true,
    tags: ["campus", "access", "PoE"],
  },
];

// ═══════════════════════════════════════════════════════
// HPE / ARUBA
// ═══════════════════════════════════════════════════════
const HPE: SwitchSeed[] = [
  {
    vendor: "HPE Aruba", vendorType: "oem", vendorWebsite: "https://www.arubanetworks.com",
    model: "CX 10000-48Y6C", series: "CX 10000", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 6 }, totalPorts: 54,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.2,
    asicVendor: "AMD/Pensando", asicModel: "Elba",
    rackUnits: 1, maxPowerW: 950,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["DPU", "stateful", "microsegmentation"],
  },
  {
    vendor: "HPE Aruba", vendorType: "oem", vendorWebsite: "https://www.arubanetworks.com",
    model: "CX 9300-32D", series: "CX 9300", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 1, maxPowerW: 1500,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    tags: ["400G", "spine", "leaf"],
  },
  {
    vendor: "HPE Aruba", vendorType: "oem", vendorWebsite: "https://www.arubanetworks.com",
    model: "CX 6300-48G-4SFP56", series: "CX 6300", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "50G_SFP56": 4 }, totalPorts: 52,
    maxSpeedGbps: 50, switchingCapacityTbps: 0.296,
    rackUnits: 1, maxPowerW: 800,
    poeSupport: "PoE++", stackingSupport: true,
    tags: ["campus", "access", "PoE"],
  },
];

// ═══════════════════════════════════════════════════════
// NVIDIA / MELLANOX
// ═══════════════════════════════════════════════════════
const NVIDIA: SwitchSeed[] = [
  {
    vendor: "NVIDIA Networking", vendorType: "oem", vendorWebsite: "https://www.nvidia.com/networking",
    model: "SN5600", series: "Spectrum-4", category: "DataCenter", layer: "L3",
    portsConfig: { "800G_OSFP": 64 }, totalPorts: 64,
    maxSpeedGbps: 800, switchingCapacityTbps: 51.2, forwardingRateMpps: 33000,
    asicVendor: "NVIDIA", asicModel: "Spectrum-4",
    rackUnits: 2, maxPowerW: 3000,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    sonicCompatible: true,
    tags: ["800G", "AI-fabric", "Cumulus", "SONiC"],
  },
  {
    vendor: "NVIDIA Networking", vendorType: "oem", vendorWebsite: "https://www.nvidia.com/networking",
    model: "SN5400", series: "Spectrum-4", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 64 }, totalPorts: 64,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6,
    asicVendor: "NVIDIA", asicModel: "Spectrum-4",
    rackUnits: 2, maxPowerW: 2400,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    sonicCompatible: true,
    tags: ["400G", "spine", "Cumulus", "SONiC"],
  },
  {
    vendor: "NVIDIA Networking", vendorType: "oem", vendorWebsite: "https://www.nvidia.com/networking",
    model: "SN4700", series: "Spectrum-3", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "NVIDIA", asicModel: "Spectrum-3",
    rackUnits: 1, maxPowerW: 1200,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, openconfigSupport: true,
    sonicCompatible: true,
    tags: ["400G", "leaf", "SONiC"],
  },
  {
    vendor: "NVIDIA Networking", vendorType: "oem", vendorWebsite: "https://www.nvidia.com/networking",
    model: "SN2201", series: "Spectrum-1", category: "DataCenter", layer: "L2/L3",
    portsConfig: { "1G_RJ45": 48, "100G_QSFP28": 4 }, totalPorts: 52,
    maxSpeedGbps: 100, switchingCapacityTbps: 0.496,
    asicVendor: "NVIDIA", asicModel: "Spectrum-1",
    rackUnits: 1, maxPowerW: 400,
    sonicCompatible: true,
    tags: ["management", "OOB", "SONiC"],
  },
];

// ═══════════════════════════════════════════════════════
// EDGECORE / WHITEBOX
// ═══════════════════════════════════════════════════════
const EDGECORE: SwitchSeed[] = [
  {
    vendor: "Edgecore Networks", vendorType: "oem", vendorWebsite: "https://www.edge-core.com",
    model: "DCS810", series: "DCS800", category: "DataCenter", layer: "L3",
    portsConfig: { "800G_OSFP": 64 }, totalPorts: 64,
    maxSpeedGbps: 800, switchingCapacityTbps: 51.2,
    asicVendor: "Broadcom", asicModel: "Tomahawk 5",
    rackUnits: 2, maxPowerW: 3500,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["800G", "whitebox", "SONiC", "OCP"],
  },
  {
    vendor: "Edgecore Networks", vendorType: "oem", vendorWebsite: "https://www.edge-core.com",
    model: "DCS510", series: "DCS500", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 64 }, totalPorts: 64,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 2, maxPowerW: 2200,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["400G", "whitebox", "SONiC", "OCP"],
  },
  {
    vendor: "Edgecore Networks", vendorType: "oem", vendorWebsite: "https://www.edge-core.com",
    model: "DCS204", series: "DCS200", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 32, "10G_SFP+": 2 }, totalPorts: 34,
    maxSpeedGbps: 100, switchingCapacityTbps: 6.4,
    asicVendor: "Broadcom", asicModel: "Tomahawk 3",
    rackUnits: 1, maxPowerW: 750,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["100G", "whitebox", "SONiC"],
  },
];

// ═══════════════════════════════════════════════════════
// DELL TECHNOLOGIES
// ═══════════════════════════════════════════════════════
const DELL: SwitchSeed[] = [
  {
    vendor: "Dell Technologies", vendorType: "oem", vendorWebsite: "https://www.dell.com",
    model: "PowerSwitch Z9664F-ON", series: "Z9664F", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 64 }, totalPorts: 64,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 2, maxPowerW: 2500,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["400G", "spine", "SONiC", "OS10"],
  },
  {
    vendor: "Dell Technologies", vendorType: "oem", vendorWebsite: "https://www.dell.com",
    model: "PowerSwitch Z9332F-ON", series: "Z9332F", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32, "10G_SFP+": 2 }, totalPorts: 34,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 3",
    rackUnits: 1, maxPowerW: 1200,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, sonicCompatible: true,
    tags: ["400G", "leaf", "SONiC", "OS10"],
  },
  {
    vendor: "Dell Technologies", vendorType: "oem", vendorWebsite: "https://www.dell.com",
    model: "PowerSwitch S5248F-ON", series: "S5248F", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 4, "100G_QSFP-DD": 2 }, totalPorts: 54,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.2,
    asicVendor: "Broadcom", asicModel: "Trident 3",
    rackUnits: 1, maxPowerW: 550,
    vxlanSupport: true, evpnSupport: true, sonicCompatible: true,
    tags: ["25G", "leaf", "ToR"],
  },
];

// ═══════════════════════════════════════════════════════
// EXTREME NETWORKS
// ═══════════════════════════════════════════════════════
const EXTREME: SwitchSeed[] = [
  {
    vendor: "Extreme Networks", vendorType: "oem", vendorWebsite: "https://www.extremenetworks.com",
    model: "SLX 9740-40C", series: "SLX 9740", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 40 }, totalPorts: 40,
    maxSpeedGbps: 100, switchingCapacityTbps: 8.0,
    rackUnits: 1, maxPowerW: 1100,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true,
    tags: ["100G", "spine", "EVPN"],
  },
  {
    vendor: "Extreme Networks", vendorType: "oem", vendorWebsite: "https://www.extremenetworks.com",
    model: "X695-48Y-8C", series: "ExtremeSwitching X695", category: "DataCenter", layer: "L3",
    portsConfig: { "25G_SFP28": 48, "100G_QSFP28": 8 }, totalPorts: 56,
    maxSpeedGbps: 100, switchingCapacityTbps: 3.2,
    rackUnits: 1, maxPowerW: 750,
    vxlanSupport: true, evpnSupport: true, bgpSupport: true, stackingSupport: true,
    tags: ["25G", "leaf", "fabric"],
  },
  {
    vendor: "Extreme Networks", vendorType: "oem", vendorWebsite: "https://www.extremenetworks.com",
    model: "5520-48T", series: "ExtremeSwitching 5520", category: "Campus", layer: "L3",
    portsConfig: { "1G_RJ45": 48, "10G_SFP+": 4 }, totalPorts: 52,
    maxSpeedGbps: 10, switchingCapacityTbps: 0.176,
    rackUnits: 1, maxPowerW: 500,
    poeSupport: "PoE++", stackingSupport: true,
    tags: ["campus", "access", "PoE", "ExtremeCloud"],
  },
];

// ═══════════════════════════════════════════════════════
// UFISPACE (OCP-focused whitebox)
// ═══════════════════════════════════════════════════════
const UFISPACE: SwitchSeed[] = [
  {
    vendor: "UfiSpace", vendorType: "oem", vendorWebsite: "https://www.ufispace.com",
    model: "S9710-76D", series: "S9710", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 76 }, totalPorts: 76,
    maxSpeedGbps: 400, switchingCapacityTbps: 25.6,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 2, maxPowerW: 2800,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["400G", "whitebox", "OCP", "SONiC"],
  },
  {
    vendor: "UfiSpace", vendorType: "oem", vendorWebsite: "https://www.ufispace.com",
    model: "S9600-72XC", series: "S9600", category: "DataCenter", layer: "L3",
    portsConfig: { "100G_QSFP28": 72 }, totalPorts: 72,
    maxSpeedGbps: 100, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 3",
    rackUnits: 2, maxPowerW: 1500,
    sonicCompatible: true,
    tags: ["100G", "whitebox", "SONiC"],
  },
];

// ═══════════════════════════════════════════════════════
// CELESTICA (OCP whitebox)
// ═══════════════════════════════════════════════════════
const CELESTICA: SwitchSeed[] = [
  {
    vendor: "Celestica", vendorType: "oem", vendorWebsite: "https://www.celestica.com",
    model: "DS5000", series: "DS5000", category: "DataCenter", layer: "L3",
    portsConfig: { "800G_OSFP": 64 }, totalPorts: 64,
    maxSpeedGbps: 800, switchingCapacityTbps: 51.2,
    asicVendor: "Broadcom", asicModel: "Tomahawk 5",
    rackUnits: 2, maxPowerW: 3500,
    sonicCompatible: true, openconfigSupport: true,
    tags: ["800G", "whitebox", "OCP", "SONiC"],
  },
  {
    vendor: "Celestica", vendorType: "oem", vendorWebsite: "https://www.celestica.com",
    model: "DS4000", series: "DS4000", category: "DataCenter", layer: "L3",
    portsConfig: { "400G_QSFP-DD": 32 }, totalPorts: 32,
    maxSpeedGbps: 400, switchingCapacityTbps: 12.8,
    asicVendor: "Broadcom", asicModel: "Tomahawk 4",
    rackUnits: 1, maxPowerW: 1400,
    sonicCompatible: true,
    tags: ["400G", "whitebox", "SONiC"],
  },
];

// Combine all vendors
const ALL_SWITCHES: SwitchSeed[] = [
  ...ARISTA,
  ...CISCO,
  ...JUNIPER,
  ...NOKIA,
  ...HUAWEI,
  ...HPE,
  ...NVIDIA,
  ...EDGECORE,
  ...DELL,
  ...EXTREME,
  ...UFISPACE,
  ...CELESTICA,
];

export async function seedSwitches(): Promise<void> {
  console.log("=== Switch & Router Seed Data ===\n");
  console.log(`Seeding ${ALL_SWITCHES.length} switches from ${new Set(ALL_SWITCHES.map(s => s.vendor)).size} vendors...\n`);

  const vendorCache = new Map<string, string>();
  let created = 0;
  let updated = 0;

  for (const sw of ALL_SWITCHES) {
    try {
      let vendorId = vendorCache.get(sw.vendor);
      if (!vendorId) {
        vendorId = await ensureVendor(sw.vendor, sw.vendorType, sw.vendorWebsite);
        vendorCache.set(sw.vendor, vendorId);
      }

      const existing = await pool.query(
        `SELECT id FROM switches WHERE model = $1 AND vendor_id = $2`,
        [sw.model, vendorId]
      );

      await findOrCreateSwitch({
        model: sw.model,
        vendorId,
        series: sw.series,
        category: sw.category,
        layer: sw.layer,
        portsConfig: sw.portsConfig,
        totalPorts: sw.totalPorts,
        uplinkSpeedGbps: sw.uplinkSpeedGbps,
        maxSpeedGbps: sw.maxSpeedGbps,
        switchingCapacityTbps: sw.switchingCapacityTbps,
        forwardingRateMpps: sw.forwardingRateMpps,
        asicVendor: sw.asicVendor,
        asicModel: sw.asicModel,
        rackUnits: sw.rackUnits,
        maxPowerW: sw.maxPowerW,
        poeSupport: sw.poeSupport,
        stackingSupport: sw.stackingSupport,
        vxlanSupport: sw.vxlanSupport,
        evpnSupport: sw.evpnSupport,
        bgpSupport: sw.bgpSupport,
        mplsSupport: sw.mplsSupport,
        openconfigSupport: sw.openconfigSupport,
        sonicCompatible: sw.sonicCompatible,
        macsecSupport: sw.macsecSupport,
        tags: sw.tags,
      });

      if (existing.rows.length > 0) {
        updated++;
      } else {
        created++;
      }
    } catch (err) {
      console.error(`  Error [${sw.vendor} ${sw.model}]: ${(err as Error).message.slice(0, 100)}`);
    }
  }

  console.log(`\n=== Seed Complete: ${created} created, ${updated} updated ===`);
}

if (require.main === module) {
  seedSwitches()
    .then(() => pool.end())
    .catch((err) => { console.error("Fatal:", err); pool.end(); process.exit(1); });
}
