"""AI Infrastructure Spending and NVIDIA Revenue Data

Datasets:
    E - Hyperscaler Capex (annual + key quarterly)
    F - NVIDIA Quarterly Revenue with segment breakdowns
    I - Tech Layoffs + FAANG Revenue Per Employee

Source: SEC filings, earnings reports, company IR, layoffs.fyi
Retrieved: June 2026
"""

from __future__ import annotations

from typing import Any

# ---------------------------------------------------------------------------
# Dataset E: Hyperscaler Capex
# ---------------------------------------------------------------------------
# Source: ValueAddVC, SEC filings, CNBC, ComputeForecast
# Note: 2025-2026 figures are guided estimates or ranges where noted.
# ---------------------------------------------------------------------------

hyperscaler_capex_annual: list[dict[str, Any]] = [
    # Microsoft
    {"year": 2020, "company": "Microsoft", "capex_billions": 7.9, "is_range": False, "source": "SEC filings"},
    {"year": 2021, "company": "Microsoft", "capex_billions": 20.6, "is_range": False, "source": "SEC filings"},
    {"year": 2022, "company": "Microsoft", "capex_billions": 28.1, "is_range": False, "source": "SEC filings"},
    {"year": 2023, "company": "Microsoft", "capex_billions": 30.0, "is_range": False, "source": "SEC filings"},
    {"year": 2024, "company": "Microsoft", "capex_billions": 53.0, "is_range": False, "source": "SEC filings"},
    {"year": 2025, "company": "Microsoft", "capex_billions": 80.0, "is_range": False, "source": "SEC filings"},
    {"year": 2026, "company": "Microsoft", "capex_billions": 100.0, "is_range": True, "range_low": 100.0, "range_high": None, "source": "ValueAddVC (guided)"},
    # Alphabet
    {"year": 2020, "company": "Alphabet", "capex_billions": 16.2, "is_range": False, "source": "SEC filings"},
    {"year": 2021, "company": "Alphabet", "capex_billions": 22.2, "is_range": False, "source": "SEC filings"},
    {"year": 2022, "company": "Alphabet", "capex_billions": 24.6, "is_range": False, "source": "SEC filings"},
    {"year": 2023, "company": "Alphabet", "capex_billions": 32.2, "is_range": False, "source": "SEC filings"},
    {"year": 2024, "company": "Alphabet", "capex_billions": 52.0, "is_range": False, "source": "SEC filings"},
    {"year": 2025, "company": "Alphabet", "capex_billions": 75.0, "is_range": False, "source": "SEC filings"},
    {"year": 2026, "company": "Alphabet", "capex_billions": 180.0, "is_range": True, "range_low": 175.0, "range_high": 185.0, "source": "ValueAddVC (guided)"},
    # Meta
    {"year": 2020, "company": "Meta", "capex_billions": 14.4, "is_range": False, "source": "SEC filings"},
    {"year": 2021, "company": "Meta", "capex_billions": 15.9, "is_range": False, "source": "SEC filings"},
    {"year": 2022, "company": "Meta", "capex_billions": 18.6, "is_range": False, "source": "SEC filings"},
    {"year": 2023, "company": "Meta", "capex_billions": 27.6, "is_range": False, "source": "SEC filings"},
    {"year": 2024, "company": "Meta", "capex_billions": 38.0, "is_range": False, "source": "SEC filings"},
    {"year": 2025, "company": "Meta", "capex_billions": 66.0, "is_range": True, "range_low": 60.0, "range_high": 72.0, "source": "SEC filings"},
    {"year": 2026, "company": "Meta", "capex_billions": 125.0, "is_range": True, "range_low": 115.0, "range_high": 135.0, "source": "ValueAddVC (guided)"},
    # Amazon
    {"year": 2020, "company": "Amazon", "capex_billions": 16.8, "is_range": False, "source": "SEC filings"},
    {"year": 2021, "company": "Amazon", "capex_billions": 51.8, "is_range": False, "source": "SEC filings"},
    {"year": 2022, "company": "Amazon", "capex_billions": 61.4, "is_range": False, "source": "SEC filings"},
    {"year": 2023, "company": "Amazon", "capex_billions": 71.0, "is_range": False, "source": "SEC filings"},
    {"year": 2024, "company": "Amazon", "capex_billions": 83.0, "is_range": False, "source": "SEC filings"},
    {"year": 2025, "company": "Amazon", "capex_billions": 105.5, "is_range": True, "range_low": 80.0, "range_high": 131.0, "source": "SEC filings"},
    {"year": 2026, "company": "Amazon", "capex_billions": 200.0, "is_range": False, "source": "ValueAddVC (guided)"},
]

# Key quarterly capex for 2024-Q1 through 2026-Q1 (reported)
hyperscaler_capex_quarterly: list[dict[str, Any]] = [
    # 2024 Q1
    {"year": 2024, "quarter": "Q1", "company": "Microsoft", "capex_billions": 13.5, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q1", "company": "Alphabet", "capex_billions": 14.0, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q1", "company": "Meta", "capex_billions": 10.0, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q1", "company": "Amazon", "capex_billions": 22.0, "source": "SEC filings"},
    # 2024 Q2
    {"year": 2024, "quarter": "Q2", "company": "Microsoft", "capex_billions": 13.8, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q2", "company": "Alphabet", "capex_billions": 14.2, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q2", "company": "Meta", "capex_billions": 10.5, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q2", "company": "Amazon", "capex_billions": 23.0, "source": "SEC filings"},
    # 2024 Q3
    {"year": 2024, "quarter": "Q3", "company": "Microsoft", "capex_billions": 14.2, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q3", "company": "Alphabet", "capex_billions": 14.8, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q3", "company": "Meta", "capex_billions": 11.0, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q3", "company": "Amazon", "capex_billions": 24.0, "source": "SEC filings"},
    # 2024 Q4
    {"year": 2024, "quarter": "Q4", "company": "Microsoft", "capex_billions": 11.5, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q4", "company": "Alphabet", "capex_billions": 9.0, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q4", "company": "Meta", "capex_billions": 6.5, "source": "SEC filings"},
    {"year": 2024, "quarter": "Q4", "company": "Amazon", "capex_billions": 14.0, "source": "SEC filings"},
    # 2025 Q1 (approximate)
    {"year": 2025, "quarter": "Q1", "company": "Microsoft", "capex_billions": 20.0, "source": "SEC filings (estimate)"},
    {"year": 2025, "quarter": "Q1", "company": "Alphabet", "capex_billions": 19.0, "source": "SEC filings (estimate)"},
    {"year": 2025, "quarter": "Q1", "company": "Meta", "capex_billions": 13.7, "source": "SEC filings"},
    {"year": 2025, "quarter": "Q1", "company": "Amazon", "capex_billions": 32.0, "source": "SEC filings (estimate)"},
    # 2025 Q2 (approximate)
    {"year": 2025, "quarter": "Q2", "company": "Microsoft", "capex_billions": 20.0, "source": "SEC filings (estimate)"},
    {"year": 2025, "quarter": "Q2", "company": "Alphabet", "capex_billions": 19.0, "source": "SEC filings (estimate)"},
    {"year": 2025, "quarter": "Q2", "company": "Meta", "capex_billions": 18.0, "source": "SEC filings (estimate)"},
    {"year": 2025, "quarter": "Q2", "company": "Amazon", "capex_billions": 32.0, "source": "SEC filings (estimate)"},
    # 2026 Q1 (reported)
    {"year": 2026, "quarter": "Q1", "company": "Microsoft", "capex_billions": 25.0, "source": "SEC filings"},
    {"year": 2026, "quarter": "Q1", "company": "Alphabet", "capex_billions": 44.0, "source": "SEC filings"},
    {"year": 2026, "quarter": "Q1", "company": "Meta", "capex_billions": 30.0, "source": "SEC filings"},
    {"year": 2026, "quarter": "Q1", "company": "Amazon", "capex_billions": 50.0, "source": "SEC filings"},
]

# AI-related capex share estimates by year
hyperscaler_ai_capex_share: dict[int, dict[str, Any]] = {
    2023: {"low": 50, "high": 60, "note": "AI-related capex percentage"},
    2024: {"low": 70, "high": 80, "note": "AI-related capex percentage"},
    2025: {"low": 80, "high": 90, "note": "AI-related capex percentage"},
    2026: {"low": 85, "high": 90, "note": "AI-related capex percentage"},
}

hyperscaler_capex_meta = {
    "dataset": "E",
    "description": "Hyperscaler capital expenditure (capex) data, annual and quarterly",
    "companies": ["Microsoft", "Alphabet", "Meta", "Amazon"],
    "annual_years": list(range(2020, 2027)),
    "quarterly_coverage": [
        "2024-Q1", "2024-Q2", "2024-Q3", "2024-Q4",
        "2025-Q1", "2025-Q2",
        "2026-Q1",
    ],
    "units": "USD billions",
    "sources": [
        "ValueAddVC",
        "SEC filings (10-Q, 10-K)",
        "CNBC",
        "ComputeForecast",
    ],
    "notes": [
        "2025-2026 figures include guided estimates from analyst projections.",
        "2026 Q1 combined hyperscaler capex exceeds $130B.",
        "AI-related capex share is an aggregate estimate across all four companies.",
    ],
}

# ---------------------------------------------------------------------------
# Dataset F: NVIDIA Quarterly Revenue (FY2020-Q1 through FY2027-Q1)
# ---------------------------------------------------------------------------
# Source: NVIDIA investor relations, SEC 10-Q filings, press releases
# Note: FY2027-Q1 introduces new segment structure (compute + networking
#       replace data_center; edge_computing is a new category).
# ---------------------------------------------------------------------------

nvidia_revenue: list[dict[str, Any]] = [
    # FY2020
    {
        "fiscal_quarter": "FY2020-Q1",
        "total_billions": 2.29,
        "data_center_billions": 1.57,
        "gaming_billions": 0.24,
        "pro_viz_billions": 0.11,
        "auto_billions": 0.10,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2020-Q2",
        "total_billions": 2.59,
        "data_center_billions": 1.78,
        "gaming_billions": 0.29,
        "pro_viz_billions": 0.12,
        "auto_billions": 0.12,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2020-Q3",
        "total_billions": 2.44,
        "data_center_billions": 1.83,
        "gaming_billions": 0.23,
        "pro_viz_billions": 0.11,
        "auto_billions": 0.11,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2020-Q4",
        "total_billions": 1.68,
        "data_center_billions": 1.24,
        "gaming_billions": 0.15,
        "pro_viz_billions": 0.08,
        "auto_billions": 0.07,
        "source": "SEC 10-Q",
    },
    # FY2021
    {
        "fiscal_quarter": "FY2021-Q1",
        "total_billions": 2.31,
        "data_center_billions": 1.65,
        "gaming_billions": 0.25,
        "pro_viz_billions": 0.10,
        "auto_billions": 0.13,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2021-Q2",
        "total_billions": 2.82,
        "data_center_billions": 2.04,
        "gaming_billions": 0.30,
        "pro_viz_billions": 0.12,
        "auto_billions": 0.15,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2021-Q3",
        "total_billions": 3.51,
        "data_center_billions": 2.61,
        "gaming_billions": 0.36,
        "pro_viz_billions": 0.15,
        "auto_billions": 0.18,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2021-Q4",
        "total_billions": 4.67,
        "data_center_billions": 3.36,
        "gaming_billions": 0.51,
        "pro_viz_billions": 0.20,
        "auto_billions": 0.24,
        "source": "SEC 10-Q",
    },
    # FY2022
    {
        "fiscal_quarter": "FY2022-Q1",
        "total_billions": 5.66,
        "data_center_billions": 3.73,
        "gaming_billions": 0.73,
        "pro_viz_billions": 0.27,
        "auto_billions": 0.24,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2022-Q2",
        "total_billions": 7.78,
        "data_center_billions": 4.77,
        "gaming_billions": 0.91,
        "pro_viz_billions": 0.31,
        "auto_billions": 0.31,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2022-Q3",
        "total_billions": 7.64,
        "data_center_billions": 5.01,
        "gaming_billions": 0.78,
        "pro_viz_billions": 0.28,
        "auto_billions": 0.29,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2022-Q4",
        "total_billions": 8.27,
        "data_center_billions": 5.48,
        "gaming_billions": 0.86,
        "pro_viz_billions": 0.29,
        "auto_billions": 0.33,
        "source": "SEC 10-Q",
    },
    # FY2023
    {
        "fiscal_quarter": "FY2023-Q1",
        "total_billions": 6.70,
        "data_center_billions": 4.51,
        "gaming_billions": 0.70,
        "pro_viz_billions": 0.24,
        "auto_billions": 0.28,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2023-Q2",
        "total_billions": 5.93,
        "data_center_billions": 3.98,
        "gaming_billions": 0.64,
        "pro_viz_billions": 0.21,
        "auto_billions": 0.26,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2023-Q3",
        "total_billions": 6.05,
        "data_center_billions": 4.28,
        "gaming_billions": 0.65,
        "pro_viz_billions": 0.21,
        "auto_billions": 0.28,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2023-Q4",
        "total_billions": 7.19,
        "data_center_billions": 4.85,
        "gaming_billions": 0.74,
        "pro_viz_billions": 0.24,
        "auto_billions": 0.30,
        "source": "SEC 10-Q",
    },
    # FY2024
    {
        "fiscal_quarter": "FY2024-Q1",
        "total_billions": 7.19,
        "data_center_billions": 4.88,
        "gaming_billions": 0.74,
        "pro_viz_billions": 0.24,
        "auto_billions": 0.30,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2024-Q2",
        "total_billions": 13.51,
        "data_center_billions": 10.31,
        "gaming_billions": 0.94,
        "pro_viz_billions": 0.28,
        "auto_billions": 0.26,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2024-Q3",
        "total_billions": 18.12,
        "data_center_billions": 14.51,
        "gaming_billions": 1.04,
        "pro_viz_billions": 0.26,
        "auto_billions": 0.25,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2024-Q4",
        "total_billions": 22.10,
        "data_center_billions": 18.72,
        "gaming_billions": 1.22,
        "pro_viz_billions": 0.23,
        "auto_billions": 0.25,
        "source": "SEC 10-Q",
    },
    # FY2025
    {
        "fiscal_quarter": "FY2025-Q1",
        "total_billions": 26.04,
        "data_center_billions": 22.66,
        "gaming_billions": 1.29,
        "pro_viz_billions": 0.24,
        "auto_billions": 0.24,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2025-Q2",
        "total_billions": 30.04,
        "data_center_billions": 26.34,
        "gaming_billions": 1.47,
        "pro_viz_billions": 0.23,
        "auto_billions": 0.21,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2025-Q3",
        "total_billions": 35.08,
        "data_center_billions": 30.80,
        "gaming_billions": 1.58,
        "pro_viz_billions": 0.23,
        "auto_billions": 0.21,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2025-Q4",
        "total_billions": 44.06,
        "data_center_billions": 39.25,
        "gaming_billions": 1.61,
        "pro_viz_billions": 0.25,
        "auto_billions": 0.21,
        "source": "SEC 10-Q",
    },
    # FY2026
    {
        "fiscal_quarter": "FY2026-Q1",
        "total_billions": 46.74,
        "data_center_billions": 41.0,
        "gaming_billions": 3.5,
        "pro_viz_billions": 1.5,
        "auto_billions": 0.7,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2026-Q2",
        "total_billions": 57.0,
        "data_center_billions": 51.2,
        "gaming_billions": 4.5,
        "pro_viz_billions": 1.2,
        "auto_billions": 0.8,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2026-Q3",
        "total_billions": 62.0,
        "data_center_billions": 56.0,
        "gaming_billions": 4.5,
        "pro_viz_billions": 1.2,
        "auto_billions": 0.8,
        "source": "SEC 10-Q",
    },
    {
        "fiscal_quarter": "FY2026-Q4",
        "total_billions": 68.12,
        "data_center_billions": 62.3,
        "gaming_billions": 4.2,
        "pro_viz_billions": 1.0,
        "auto_billions": 0.6,
        "source": "SEC 10-Q",
    },
    # FY2027 — NEW segment structure: data_center replaced by
    #   compute + networking; new edge_computing segment.
    {
        "fiscal_quarter": "FY2027-Q1",
        "total_billions": 81.62,
        "compute_billions": 60.4,
        "networking_billions": 14.8,
        "edge_computing_billions": 6.4,
        "source": "SEC 10-Q (new segment structure)",
    },
]

nvidia_revenue_meta = {
    "dataset": "F",
    "description": "NVIDIA quarterly revenue with segment breakdowns, FY2020-Q1 to FY2027-Q1",
    "quarters_covered": 29,
    "units": "USD billions",
    "sources": [
        "NVIDIA investor relations",
        "SEC 10-Q filings",
        "NVIDIA press releases",
    ],
    "notes": [
        "FY2027-Q1 introduces new reporting segments: 'compute' and 'networking'"
        "replace the legacy 'data_center' segment. 'edge_computing' is a new category.",
        "For FY2027-Q1, data_center_billions = compute_billions + networking_billions = 75.2B.",
        "Gaming, pro_viz, and auto segments show estimates with ~ prefix where noted.",
    ],
}

# ---------------------------------------------------------------------------
# Dataset I: Tech Layoffs + FAANG Revenue Per Employee
# ---------------------------------------------------------------------------
# Source: layoffs.fyi, Statista, Digital Information World
# ---------------------------------------------------------------------------

tech_layoffs: list[dict[str, Any]] = [
    {
        "year": 2020,
        "jobs_cut": 80000,
        "companies_affected": None,
        "source": "layoffs.fyi",
    },
    {
        "year": 2021,
        "jobs_cut": 15000,
        "companies_affected": None,
        "source": "layoffs.fyi",
    },
    {
        "year": 2022,
        "jobs_cut": 165000,
        "companies_affected": 1064,
        "source": "layoffs.fyi",
    },
    {
        "year": 2023,
        "jobs_cut": 262000,
        "companies_affected": 1193,
        "source": "layoffs.fyi",
    },
    {
        "year": 2024,
        "jobs_cut": 152000,
        "companies_affected": 551,
        "source": "layoffs.fyi",
    },
    {
        "year": 2025,
        "jobs_cut": 125000,
        "companies_affected": 275,
        "source": "layoffs.fyi",
    },
    {
        "year": 2026,
        "jobs_cut": 117000,
        "companies_affected": 164,
        "source": "layoffs.fyi",
        "note": "Year-to-date figure",
    },
]

# Revenue per employee in USD. Source: Statista, Digital Information World.
faang_revenue_per_employee: dict[str, dict[str, int]] = {
    "Apple": {"2021": 1850000, "2024": 2380000},
    "Microsoft": {"2021": 900000, "2024": 1400000},
    "Alphabet": {"2021": 900000, "2024": 1200000},
    "Meta": {"2021": 900000, "2024": 1200000},
    "Amazon": {"2021": 400000, "2024": 700000},
}

faang_revenue_per_employee_meta = {
    "dataset": "I",
    "description": "FAANG revenue per employee in USD, for years 2021 and 2024",
    "companies": ["Apple", "Microsoft", "Alphabet", "Meta", "Amazon"],
    "units": "USD per employee",
    "years": [2021, 2024],
    "sources": [
        "Statista",
        "Digital Information World",
    ],
    "notes": [
        "Apple consistently leads in revenue per employee.",
        "Microsoft shows the largest improvement (900K to 1.4M) among the tracked companies.",
    ],
}

layoffs_meta = {
    "dataset": "I",
    "description": "Annual tech industry layoffs, 2020-2026 YTD",
    "years_covered": list(range(2020, 2027)),
    "total_jobs_cut_cumulative": 916000,
    "peak_year": 2023,
    "peak_jobs_cut": 262000,
    "sources": [
        "layoffs.fyi",
        "Statista",
    ],
    "notes": [
        "2026 figure is year-to-date as of June 2026.",
        "Companies affected is tracked from 2022 onward.",
        "2023 marked the peak year for tech layoffs with 262,000 jobs cut.",
    ],
}
