/* Demo data — all names/companies fictional. */

// IDs we reference from the timeline
const ID_NORTHSTREAM = '2026-05-19-northstream-reschedule';
const ID_CATALYST    = '2026-05-19-catalyst-oauth-signoff';

window.TRIAGE_DATA_INITIAL = {
  counts: { open: 5, snoozed: 2, handled_recent: 8 },
  last_updated_at: 'just now',
  actions: [
    {
      id: 'webhook-errors-prod',
      title: 'Production webhook errors firing every 3 min',
      summary: 'Workflow runner auto-alert: "Update billing account" has failed 41× since 14:02 UTC.',
      priority: 'high',
      reason_class: 'risk',
      source: 'workflows',
      due_by: null,
      overdue: false,
      kind: 'investigate',
      suggested_actions: [
        { label: 'Investigate', primary: true },
        { label: 'Page on-call' },
      ],
    },
    {
      id: ID_CATALYST,
      title: 'Catalyst API v2 → v3 migration sign-off',
      summary: 'Erin Walsh is blocked on your approval for the Sept 1 cutover plan.',
      priority: 'high',
      reason_class: 'response-needed',
      source: 'gmail',
      due_by: 'Tomorrow',
      overdue: false,
      kind: 'gmail-reply',
      why_matters: 'Catalyst is the auth provider for ~38% of partner traffic. Pushing the cutover past Sept 1 forces an extra dev-month of dual-stack maintenance and a re-test cycle with three downstream partners.',
      personalization: 'Matches "decisions waiting on you" — Erin escalated this on 2026-05-07 and again on 2026-05-19. You are the named approver in the migration RFC.',
      related: ['team/platform', 'vendor/catalyst-api'],
      suggested_actions: [
        { label: 'Draft a reply', primary: true, kind: 'gmail' },
        { label: 'Snooze 24h' },
      ],
    },
    {
      id: ID_NORTHSTREAM,
      title: 'Reschedule Northstream investor sync',
      summary: 'Robin Hayes (covering for Priya) needs to move Thursday\u2019s call. Tue/Wed both work.',
      priority: 'medium',
      reason_class: 'deal-movement',
      source: 'slack',
      due_by: 'Fri May 22',
      overdue: false,
      kind: 'slack-reply',
      suggested_actions: [
        { label: 'Draft a reply', primary: true, kind: 'slack' },
        { label: 'Snooze 24h' },
      ],
    },
    {
      id: 'q2-docs-input',
      title: 'Q2 planning doc awaiting your comments',
      summary: 'Tomas flagged 2 docs needing review "from many of you" — comments due Friday.',
      priority: 'medium',
      reason_class: 'response-needed',
      source: 'docs',
      due_by: 'Fri May 22',
      overdue: false,
      suggested_actions: [
        { label: 'Open doc', primary: true },
        { label: 'Snooze 24h' },
      ],
    },
    {
      id: 'vendor-update',
      title: 'Skyforge account team update',
      summary: 'Karen Wells emailed: new SE Adam Park taking over the account, intro call requested.',
      priority: 'low',
      reason_class: 'knowledge-update',
      source: 'gmail',
      due_by: null,
      overdue: false,
      suggested_actions: [
        { label: 'Mark read', primary: true },
        { label: 'Reply' },
      ],
    },
  ],
};

/* For the second triage render, Northstream is already handled —
   drop it from the visible list, decrement the open count, and move
   the Catalyst row to the top so the cursor's next target is well-anchored. */
window.TRIAGE_DATA_AFTER_SLACK = (() => {
  const base = window.TRIAGE_DATA_INITIAL;
  const remaining = base.actions.filter((a) => a.id !== ID_NORTHSTREAM);
  return {
    counts: { ...base.counts, open: base.counts.open - 1, handled_recent: base.counts.handled_recent + 1 },
    last_updated_at: '2 min ago',
    actions: remaining,
  };
})();

/* ── Slack compose payload (for Northstream reschedule) ───────── */
window.SLACK_DATA = {
  action_id: ID_NORTHSTREAM,
  channel: { id: 'C0AB12CDE', name: 'partner-success', is_dm: false },
  thread: {
    parent_author_real_name: 'Robin Hayes',
    parent_excerpt: "Hey \u2014 Priya\u2019s OOO this week so I\u2019m covering the Northstream sync. Any chance we could move Thursday\u2019s call to next Tue or Wed? Either day works on our end.",
    last_reply_author_real_name: 'Sam Cole',
    last_reply_excerpt: 'Happy to flex on our side too — looping in to confirm timing.',
    total_replies: 2,
    parent_ts: '1779256000.001200',
  },
  draft_body: "Hi Robin \u2014 thanks for the heads up, totally understand. Tuesday at 2pm ET works great on our end. I\u2019ll send a calendar invite once you confirm.",
  appended_text: ' Looking forward to it!',
  personalization: [
    'Tone: brief and direct \u2014 first message in this thread',
    'Sign-off: skip \u2014 short reply, already greeted',
    'Action taken: pin a specific time so we move forward',
  ],
};

/* ── Gmail compose payload (for Catalyst OAuth migration) ─────── */
window.GMAIL_DATA = {
  action_id: ID_CATALYST,
  thread: {
    subject: 'Re: v2 → v3 migration timeline — partner sign-off',
    parent_author_real_name: 'Erin Walsh (Catalyst API)',
    parent_excerpt: "Following up on the deprecation timeline doc \u2014 we need partner sign-off on the Sept 1 cutover by EOW. Two things we\u2019d love your read on: (a) the client-migration window we\u2019re proposing (Aug 1\u201315) and (b) whether you want the dual-stack window extended past Sept 30.",
    last_author_real_name: 'Erin Walsh (Catalyst API)',
    last_excerpt: "Bumping this \u2014 happy to jump on a call if easier than email.",
    total_messages: 3,
    reply_to_message_id: '19e3b4d3dfbc1694',
  },
  recipients: {
    to: ['erin.walsh@catalyst-api.example'],
    cc: ['platform-leads@yourco.example'],
    bcc: [],
  },
  subject: 'Re: v2 \u2192 v3 migration timeline \u2014 partner sign-off',
  draft_body: "Hi Erin \u2014\n\nConfirmed on Sept 1. The Aug 1\u201315 client-migration window works for us; we\u2019ll lock partner migrations by Aug 15 and start the dual-stack drain on Aug 22. No need to extend the dual-stack window past Sept 30 from our side.\n\nThanks,",
  appended_text: '\n\nHappy to hop on a call before then if helpful.',
  personalization: [
    'Tone: warm-professional \u2014 ongoing external thread, previous emails were friendly',
    'Sign-off: name only \u2014 matches Erin\u2019s register',
    'Action taken: answer both questions in (a)/(b) order so nothing\u2019s left open',
  ],
};

/* ── Prompt strings that fill the host composer ──────────────── */
/* These are abbreviated versions of the real envelopes for readability;
   the real ones include the "do NOT render the connector UI" directive. */
window.PROMPTS = {
  triage_command: '/agntux triage',
  open_slack: `ux: Use the agntux-slack plugin to open the reply composer for action ${ID_NORTHSTREAM}.`,
  open_gmail: `ux: Use the agntux-gmail plugin to open the reply composer for action ${ID_CATALYST}.`,
  send_slack: `Use the Slack Connector to send a Slack message as a thread reply. channel_id: C0AB12CDE (#partner-success), thread_ts: 1779256000.001200. Reply in-thread. Body: \u00abHi Robin \u2014 thanks for the heads up, totally understand. Tuesday at 2pm ET works great on our end. I\u2019ll send a calendar invite once you confirm. Looking forward to it!\u00bb. (action_id: ${ID_NORTHSTREAM})`,
  save_gmail: `Use the Gmail Connector in two steps:\n1. Call create_draft with replyToMessageId: 19e3b4d3dfbc1694, to: [erin.walsh@catalyst-api.example], cc: [platform-leads@yourco.example], subject: \u00abRe: v2 \u2192 v3 migration timeline \u2014 partner sign-off\u00bb, body: \u00abHi Erin \u2014 ... Happy to hop on a call before then if helpful.\u00bb.\n2. After the draft is created, reply in chat with a clickable link labeled "Open draft in Gmail to review and send \u2192". (action_id: ${ID_CATALYST})`,
};

window.ACTION_IDS = { ID_NORTHSTREAM, ID_CATALYST };
