// timeline-data.jsx — roadmap-level epic date ranges + sprint timeline data.
// Dates are expressed as "Q2-W1" style week coordinates tied to WEEKS below,
// so the timeline is deterministic without needing real Date math.

// 26 weeks: 2 quarters. Q2 = Apr–Jun (weeks 0–12), Q3 = Jul–Sep (weeks 13–25).
const TL_WEEKS = (() => {
  const out = [];
  const starts = [
    // Q2 (Apr–Jun) — 13 weeks
    ["Apr", 1], ["Apr", 8], ["Apr", 15], ["Apr", 22], ["Apr", 29],
    ["May", 6], ["May", 13], ["May", 20], ["May", 27],
    ["Jun", 3], ["Jun", 10], ["Jun", 17], ["Jun", 24],
    // Q3 (Jul–Sep) — 13 weeks
    ["Jul", 1], ["Jul", 8], ["Jul", 15], ["Jul", 22], ["Jul", 29],
    ["Aug", 5], ["Aug", 12], ["Aug", 19], ["Aug", 26],
    ["Sep", 2], ["Sep", 9], ["Sep", 16], ["Sep", 23],
  ];
  starts.forEach(([m, d], i) => {
    const q = i < 13 ? "Q2" : "Q3";
    out.push({ idx: i, month: m, day: d, label: `${m} ${d}`, quarter: q });
  });
  return out;
})();

// Today sits at week 3 (Apr 22 area) — matches the rest of the prototype.
const TL_TODAY_WEEK = 3;

// Month headers — auto-derived from TL_WEEKS
const TL_MONTHS = (() => {
  const out = [];
  let cur = null;
  TL_WEEKS.forEach(w => {
    if (!cur || cur.month !== w.month) {
      cur = { month: w.month, quarter: w.quarter, start: w.idx, span: 1 };
      out.push(cur);
    } else {
      cur.span += 1;
    }
  });
  return out;
})();

const TL_QUARTERS = (() => {
  const out = [];
  let cur = null;
  TL_WEEKS.forEach(w => {
    if (!cur || cur.q !== w.quarter) {
      cur = { q: w.quarter, label: `${w.quarter} ${w.quarter === "Q2" ? "2026" : "2026"}`, start: w.idx, span: 1 };
      out.push(cur);
    } else cur.span += 1;
  });
  return out;
})();

// Timeline epics — each belongs to a project and has a week range.
// These extend the task-board EPICS with start/end + project + owner.
// `start` and `end` are week indices (inclusive start, exclusive end).
const TL_EPICS = [
  // Checkout v2 — multi-epic flagship
  { id: "tl-guest",    project: "checkout", title: "Guest Checkout Flow",      color: "var(--epic-1)", owner: "ay", start: 0,  end: 6,  progress: 0.72, status: "on-track",
    milestones: [{ week: 5, label: "Beta launch" }] },
  { id: "tl-pay",      project: "checkout", title: "Payment Providers",         color: "var(--epic-2)", owner: "ts", start: 1,  end: 8,  progress: 0.48, status: "at-risk",
    milestones: [{ week: 7, label: "Klarna GA" }] },
  { id: "tl-ckmob",    project: "checkout", title: "Mobile Checkout",           color: "var(--epic-4)", owner: "pr", start: 4,  end: 11, progress: 0.31, status: "on-track" },
  { id: "tl-tax",      project: "checkout", title: "Tax & Compliance",          color: "var(--epic-3)", owner: "nk", start: 2,  end: 9,  progress: 0.55, status: "on-track",
    milestones: [{ week: 8, label: "EU filing" }] },

  // Mobile App — its own lane
  { id: "tl-mob-nav",  project: "mobile",   title: "New Navigation Shell",      color: "var(--epic-4)", owner: "pr", start: 0,  end: 4,  progress: 0.92, status: "on-track",
    milestones: [{ week: 3, label: "App Store" }] },
  { id: "tl-mob-push", project: "mobile",   title: "Push Notification Engine",  color: "var(--epic-4)", owner: "ro", start: 3,  end: 10, progress: 0.40, status: "on-track" },
  { id: "tl-mob-off",  project: "mobile",   title: "Offline-first Cart",        color: "var(--epic-4)", owner: "ro", start: 8,  end: 16, progress: 0.08, status: "on-track" },

  // Growth 2026 — private project
  { id: "tl-gr-exp",   project: "growth",   title: "Experimentation Platform",  color: "var(--epic-3)", owner: "ay", start: 2,  end: 12, progress: 0.35, status: "at-risk",
    milestones: [{ week: 10, label: "10 concurrent tests" }] },
  { id: "tl-gr-ref",   project: "growth",   title: "Referral Program v2",       color: "var(--epic-3)", owner: "nk", start: 6,  end: 13, progress: 0.20, status: "on-track" },

  // Platform
  { id: "tl-pf-auth",  project: "platform", title: "SSO & SAML Migration",      color: "var(--epic-5)", owner: "hl", start: 0,  end: 8,  progress: 0.65, status: "on-track",
    milestones: [{ week: 7, label: "Cutover" }] },
  { id: "tl-pf-obs",   project: "platform", title: "Observability Rewrite",     color: "var(--epic-5)", owner: "df", start: 5,  end: 14, progress: 0.28, status: "off-track",
    milestones: [{ week: 11, label: "Datadog decom" }] },
  { id: "tl-pf-ci",    project: "platform", title: "CI Pipeline Overhaul",      color: "var(--epic-5)", owner: "mj", start: 10, end: 17, progress: 0,    status: "on-track" },

  // Research
  { id: "tl-re-di",    project: "research", title: "Discovery Interviews Q3",   color: "var(--epic-2)", owner: "ay", start: 12, end: 20, progress: 0,    status: "on-track" },
];

// Dependencies (arrows between epic bars). `from` finishes → `to` starts.
const TL_DEPS = [
  { from: "tl-guest",   to: "tl-pay" },
  { from: "tl-pay",     to: "tl-ckmob" },
  { from: "tl-mob-nav", to: "tl-mob-push" },
  { from: "tl-mob-push",to: "tl-mob-off" },
  { from: "tl-pf-auth", to: "tl-pf-obs" },
  { from: "tl-pf-obs",  to: "tl-pf-ci" },
];

// Sprint markers along the timeline (web team cadence)
const TL_SPRINTS = [
  { id: "s23", label: "S23", team: "Web",     start: -1, end: 1,  color: "#c4c7d0" }, // past
  { id: "s24", label: "S24", team: "Web",     start: 1,  end: 3,  color: "#0073ea", active: true },
  { id: "s25", label: "S25", team: "Web",     start: 3,  end: 5 },
  { id: "s26", label: "S26", team: "Web",     start: 5,  end: 7 },
  { id: "s27", label: "S27", team: "Web",     start: 7,  end: 9 },
  { id: "s28", label: "S28", team: "Web",     start: 9,  end: 11 },
];

Object.assign(window, { TL_WEEKS, TL_MONTHS, TL_QUARTERS, TL_EPICS, TL_DEPS, TL_SPRINTS, TL_TODAY_WEEK });
