// data.jsx — Atlas mock dataset
// Realistic-looking but invented data for the prototype.

const TEAMS = [
  { id: 'platform',   name: 'Platform',          size: 18, lead: 'M. Tan' },
  { id: 'payments',   name: 'Payments',          size: 14, lead: 'A. Iyer' },
  { id: 'web',        name: 'Web Experience',    size: 22, lead: 'S. Chen' },
  { id: 'mobile',     name: 'Mobile',            size: 16, lead: 'J. Park' },
  { id: 'data',       name: 'Data & ML',         size: 12, lead: 'R. Okafor' },
  { id: 'infra',      name: 'Infrastructure',    size: 10, lead: 'L. Volkov' },
  { id: 'security',   name: 'Security',          size:  6, lead: 'D. Mendes' },
];

const TOOLS = [
  { id: 'claude-code', name: 'Claude Code',  vendor: 'Anthropic',  color: 'var(--cat-1)' },
  { id: 'cursor',      name: 'Cursor',       vendor: 'Anysphere',  color: 'var(--cat-2)' },
  { id: 'copilot',     name: 'GitHub Copilot',vendor: 'GitHub',    color: 'var(--cat-3)' },
  { id: 'windsurf',    name: 'Windsurf',     vendor: 'Codeium',    color: 'var(--cat-4)' },
  { id: 'chatgpt',     name: 'ChatGPT',      vendor: 'OpenAI',     color: 'var(--cat-5)' },
  { id: 'internal',    name: 'Internal Agents',vendor:'Atlas',     color: 'var(--cat-6)' },
];

// Adoption time series — 18 weeks of weekly active users (out of 98 engineers)
const ADOPTION_SERIES = [
  31, 34, 38, 41, 47, 52, 55, 58, 61, 63, 64, 68, 71, 75, 78, 81, 84, 87
];

// Per-team adoption (weekly active / size)
const TEAM_ADOPTION = [
  { team: 'platform',   active: 17, prs: 41, score: 86 },
  { team: 'web',        active: 21, prs: 58, score: 82 },
  { team: 'mobile',     active: 13, prs: 29, score: 71 },
  { team: 'data',       active: 11, prs: 22, score: 79 },
  { team: 'infra',      active:  8, prs: 14, score: 64 },
  { team: 'payments',   active:  9, prs: 18, score: 52 },
  { team: 'security',   active:  3, prs:  4, score: 38 },
];

// Use case classification (org-wide share of AI sessions)
const USE_CASES = [
  { name: 'Code generation',   share: 28 },
  { name: 'Debugging',         share: 22 },
  { name: 'Refactoring',       share: 14 },
  { name: 'Test generation',   share: 11 },
  { name: 'Architecture',      share:  9 },
  { name: 'SQL & data',        share:  7 },
  { name: 'Documentation',     share:  5 },
  { name: 'Incident triage',   share:  4 },
];

// Workflow chains — sequences of tools/actions, with outcome metrics
// Each "chain" is a sequence of stages observed over many sessions.
const WORKFLOWS = [
  {
    id: 'arch-gen-test-merge',
    label: 'Architecture → Generation → Tests → Merge',
    stages: ['Architecture', 'Code gen', 'Test gen', 'PR review', 'Merge'],
    sessions: 1284,
    merge_rate: 0.91, defect_rate: 0.03, cost_idx: 1.6, velocity_idx: 1.42,
    rank: 'best',
  },
  {
    id: 'gen-review-merge',
    label: 'Generation → Review → Merge',
    stages: ['Code gen', 'PR review', 'Merge'],
    sessions: 3142,
    merge_rate: 0.83, defect_rate: 0.07, cost_idx: 0.9, velocity_idx: 1.21,
    rank: 'good',
  },
  {
    id: 'debug-loop',
    label: 'Debug loop (repeat)',
    stages: ['Debug', 'Code gen', 'Debug', 'Code gen', 'Merge'],
    sessions: 942,
    merge_rate: 0.62, defect_rate: 0.18, cost_idx: 2.4, velocity_idx: 0.71,
    rank: 'waste',
  },
  {
    id: 'refactor-campaign',
    label: 'Refactor campaign',
    stages: ['Refactor', 'Test gen', 'PR review', 'Merge'],
    sessions: 412,
    merge_rate: 0.88, defect_rate: 0.05, cost_idx: 1.1, velocity_idx: 1.18,
    rank: 'good',
  },
  {
    id: 'rewrite-spiral',
    label: 'Rewrite spiral (no merge)',
    stages: ['Code gen', 'Code gen', 'Code gen', 'Abandon'],
    sessions: 287,
    merge_rate: 0.04, defect_rate: 0.00, cost_idx: 1.8, velocity_idx: 0.0,
    rank: 'waste',
  },
  {
    id: 'sql-quick',
    label: 'SQL quick-shot',
    stages: ['SQL', 'Verify', 'Done'],
    sessions: 718,
    merge_rate: 0.95, defect_rate: 0.01, cost_idx: 0.2, velocity_idx: 1.05,
    rank: 'good',
  },
];

// Tool comparison: outcome-weighted metrics
const TOOL_METRICS = [
  { tool: 'claude-code', users: 64, sessions: 4218, merge: 0.86, retention: 0.79, velocity: 1.32, cost_per_pr: 4.20, share: 0.34 },
  { tool: 'cursor',      users: 71, sessions: 5921, merge: 0.81, retention: 0.74, velocity: 1.24, cost_per_pr: 1.80, share: 0.39 },
  { tool: 'copilot',     users: 48, sessions: 3104, merge: 0.74, retention: 0.62, velocity: 1.08, cost_per_pr: 0.90, share: 0.18 },
  { tool: 'windsurf',    users: 12, sessions:  482, merge: 0.78, retention: 0.69, velocity: 1.14, cost_per_pr: 1.40, share: 0.04 },
  { tool: 'chatgpt',     users: 53, sessions: 2210, merge: 0.66, retention: 0.51, velocity: 0.92, cost_per_pr: 0.60, share: 0.04 },
  { tool: 'internal',    users: 22, sessions:  610, merge: 0.84, retention: 0.81, velocity: 1.18, cost_per_pr: 2.10, share: 0.01 },
];

// Tool overlap matrix (% of users who use both)
const TOOL_OVERLAP = {
  'claude-code-cursor': 0.62,
  'claude-code-copilot': 0.31,
  'claude-code-chatgpt': 0.48,
  'cursor-copilot': 0.27,
  'cursor-chatgpt': 0.51,
  'copilot-chatgpt': 0.42,
  'cursor-windsurf': 0.18,
  'claude-code-internal': 0.41,
};

// Efficiency Score components per team
const EFFICIENCY = [
  { team: 'platform', score: 86, delivery: 88, quality: 91, retention: 84, cost: 79, rework: 88 },
  { team: 'web',      score: 82, delivery: 84, quality: 86, retention: 80, cost: 78, rework: 82 },
  { team: 'data',     score: 79, delivery: 76, quality: 82, retention: 78, cost: 81, rework: 78 },
  { team: 'mobile',   score: 71, delivery: 70, quality: 74, retention: 68, cost: 72, rework: 71 },
  { team: 'infra',    score: 64, delivery: 62, quality: 70, retention: 60, cost: 68, rework: 60 },
  { team: 'payments', score: 52, delivery: 51, quality: 58, retention: 48, cost: 49, rework: 54 },
  { team: 'security', score: 38, delivery: 41, quality: 45, retention: 32, cost: 42, rework: 30 },
];

// ROI / cost
const SPEND = {
  monthly_total: 18420,           // USD this month
  monthly_prev: 17110,
  per_pr: 2.42,
  per_engineer: 188,
  annualized: 221040,
};

// Optimization findings (Tool Replacement engine)
const OPTIMIZATIONS = [
  {
    title: 'Downgrade 72% of Opus calls to Sonnet',
    saving: '$3,840 / mo',
    rationale: 'No measurable outcome degradation in 18 weeks of paired traces. Affects Web & Platform.',
    severity: 'high',
  },
  {
    title: 'Cursor overlaps 81% of Copilot usage on Frontend',
    saving: '$1,210 / mo',
    rationale: 'Frontend engineers using both tools show identical outcome metrics. Sunset one license set.',
    severity: 'med',
  },
  {
    title: 'ChatGPT usage drifting outside policy on Payments',
    saving: 'Risk',
    rationale: '14 sessions last week routed through unmanaged provider. Route via gateway.',
    severity: 'risk',
  },
  {
    title: 'Test-gen workflow under-adopted on Mobile',
    saving: '+0.8 PR/day est.',
    rationale: 'Mobile defect rate 2.3× org median; test-gen workflow available but only 19% adoption.',
    severity: 'med',
  },
];

Object.assign(window, {
  TEAMS, TOOLS, ADOPTION_SERIES, TEAM_ADOPTION, USE_CASES,
  WORKFLOWS, TOOL_METRICS, TOOL_OVERLAP, EFFICIENCY, SPEND, OPTIMIZATIONS,
});
