// Seed data
const MAILS = [
  {
    id: 'm1',
    from: 'Anna Chen',
    fromEmail: 'anna.chen@linear.app',
    to: ['me@relay.mail'],
    subject: 'Q2 product roadmap — review by Friday',
    preview: 'Hi, attaching the updated roadmap doc. Key changes in the mobile track and a new AI block. Need your...',
    time: '14:32',
    date: '今天',
    unread: true,
    tags: ['work', 'priority'],
    avatar: '#7c3aed',
    initials: 'AC',
    agentActioned: false,
    summary: {
      bullets: [
        { text: 'Anna 分享了 Q2 路线图 v3 — <mark>Friday 前需要你的反馈</mark>', key: true },
        { text: '新增 <b>AI 工作流</b> 板块，预计影响移动端排期约两周' },
        { text: '需要你确认：是否将 <b>Dashboard v2</b> 推迟到 Q3' },
      ],
      actions: ['起草回复 · 同意推迟', '加入日历：Friday 4PM 评审', '转发给 Mira'],
    },
    body: `<p>Hi there,</p>
<p>Attaching the updated <strong>Q2 roadmap</strong> doc — we're closing in on v3 now. Main deltas from last week:</p>
<p><strong>Mobile track:</strong> shifting the gesture layer work into May so we can land the AI workflow block first. This pushes Dashboard v2 by ~2 weeks.</p>
<p><strong>AI workflows:</strong> new initiative. Marcus and I scoped it last Thursday. Rough spec attached.</p>
<p>Need your sign-off on the trade-off (Dashboard v2 → Q3) by <strong>Friday</strong>. Happy to walk you through on a call if easier.</p>
<p>— Anna</p>`,
    attachments: [
      { name: 'Roadmap_Q2_v3.pdf', size: '2.4 MB', kind: 'PDF' },
      { name: 'ai-workflow-scope.md', size: '18 KB', kind: 'MD' },
    ],
  },
  {
    id: 'm2',
    from: 'Stripe',
    fromEmail: 'receipts@stripe.com',
    subject: 'Payment received — $2,400.00',
    preview: 'Invoice #INV-2847 has been paid. Download the receipt or view details in your dashboard.',
    time: '13:08',
    date: '今天',
    unread: true,
    tags: ['receipt'],
    avatar: '#635bff',
    initials: 'S',
  },
  {
    id: 'm3',
    from: 'Marcus Fray',
    fromEmail: 'marcus@shortwave.dev',
    subject: 'Re: design sync next week?',
    preview: 'Thursday 3pm works for me. Agent auto-accepted on your calendar — let me know if you want me to move...',
    time: '11:47',
    date: '今天',
    unread: false,
    tags: ['agent'],
    avatar: '#0ea5e9',
    initials: 'MF',
    agentActioned: true,
  },
  {
    id: 'm4',
    from: 'GitHub',
    fromEmail: 'notifications@github.com',
    subject: '[relay/web] PR #412 ready for review',
    preview: 'jun-park opened a pull request: "feat: agent thread memory persistence". 14 files changed, +842/-203.',
    time: '10:22',
    date: '今天',
    unread: false,
    tags: ['code'],
    avatar: '#24292f',
    initials: 'GH',
  },
  {
    id: 'm5',
    from: 'Mira Osei',
    fromEmail: 'mira@studio.xyz',
    subject: '草稿反馈 — onboarding 流程',
    preview: '看了最新版本，有几个小问题。主要是第三步的过渡动画感觉有点仓促，还有...',
    time: '09:15',
    date: '今天',
    unread: true,
    tags: ['work'],
    avatar: '#f97316',
    initials: 'MO',
  },
  {
    id: 'm6',
    from: 'Figma',
    fromEmail: 'team@figma.com',
    subject: 'Weekly summary: 3 files updated',
    preview: 'Anna commented on Inbox v4. jun-park created Compose States. 12 new variants shipped.',
    time: '昨天',
    date: '昨天',
    unread: false,
    tags: ['digest'],
    avatar: '#ff4f27',
    initials: 'F',
  },
  {
    id: 'm7',
    from: 'Jun Park',
    fromEmail: 'jun@relay.mail',
    subject: '新同事的 onboarding 清单',
    preview: '我整理了一份给下周入职的两位设计师的清单，麻烦看一眼有没有遗漏。',
    time: '昨天',
    date: '昨天',
    unread: false,
    tags: ['work'],
    avatar: '#10b981',
    initials: 'JP',
  },
  {
    id: 'm8',
    from: 'Linear',
    fromEmail: 'no-reply@linear.app',
    subject: '6 issues assigned to you',
    preview: 'ENG-2847, DES-124, and 4 others are waiting on your input. Agent has auto-triaged 3.',
    time: '昨天',
    date: '昨天',
    unread: false,
    tags: ['digest', 'agent'],
    avatar: '#5e6ad2',
    initials: 'L',
  },
  {
    id: 'm9',
    from: 'Amelia Wright',
    fromEmail: 'amelia@press.co',
    subject: 'interview request — AI-native tooling',
    preview: '你好！我在 The Information 写关于 AI 原生工具的专题，想约个采访。20分钟就够。',
    time: '周一',
    date: '本周',
    unread: false,
    tags: ['press'],
    avatar: '#ec4899',
    initials: 'AW',
  },
  {
    id: 'm10',
    from: 'Notion',
    fromEmail: 'team@notion.so',
    subject: 'Your weekly digest',
    preview: '8 pages updated, 3 comments mentioned you. Top page: "Design Principles 2026".',
    time: '周一',
    date: '本周',
    unread: false,
    tags: ['digest'],
    avatar: '#000',
    initials: 'N',
  },
];

const CATEGORIES = [
  { id: 'priority', label: 'Priority', count: 3, kind: 'ai' },
  { id: 'all', label: 'All', count: 127 },
  { id: 'unread', label: 'Unread', count: 12 },
  { id: 'work', label: 'Work', count: 8 },
  { id: 'receipts', label: 'Receipts', count: 14 },
  { id: 'digest', label: 'Digests', count: 23 },
];

const NAV = [
  { id: 'inbox', label: 'Inbox', icon: 'inbox', count: 12, active: true },
  { id: 'starred', label: 'Starred', icon: 'star', count: 6 },
  { id: 'sent', label: 'Sent', icon: 'send' },
  { id: 'drafts', label: 'Drafts', icon: 'draft', count: 2 },
  { id: 'archive', label: 'Archive', icon: 'archive' },
  { id: 'trash', label: 'Trash', icon: 'trash' },
];

const LABELS = [
  { id: 'work', label: 'Work', color: '#7c3aed' },
  { id: 'personal', label: 'Personal', color: '#f97316' },
  { id: 'press', label: 'Press', color: '#ec4899' },
  { id: 'finance', label: 'Finance', color: '#10b981' },
];

const AGENT_TASKS = [
  {
    id: 't1',
    state: 'done',
    title: '阅读 Anna 的邮件和附件',
    meta: [{ label: 'tokens', value: '4.2k' }, { label: '0.8s' }],
  },
  {
    id: 't2',
    state: 'done',
    title: '查询日历可用时间',
    meta: [{ label: 'calendar.google' }, { label: '0.3s' }],
    output: 'Found 3 open slots → Thu 10:00, Fri 14:00, Fri 16:00',
  },
  {
    id: 't3',
    state: 'active',
    title: '起草回复并对齐 Friday 截止时间',
    meta: [{ label: 'composing' }],
    output: '"Hi Anna, agreed — let\'s push Dashboard v2 into Q3 so we can land AI workflows cleanly. I\'ll block Friday 4PM for the review…',
    stream: true,
  },
  {
    id: 't4',
    state: 'pending',
    title: '转发给 Mira 并附加上下文',
    meta: [{ label: 'pending' }],
  },
  {
    id: 't5',
    state: 'pending',
    title: '在 Linear 创建跟进任务',
    meta: [{ label: 'pending' }],
  },
];

const COMMAND_GROUPS = [
  {
    label: 'AI Actions',
    items: [
      { icon: 'sparkle', label: '总结这封邮件', hint: 'Anna Chen · Q2 roadmap', shortcut: ['↵'] },
      { icon: 'wand', label: '起草回复 — 同意推迟 Dashboard v2', hint: 'Agent', shortcut: ['⌘', '↵'] },
      { icon: 'calendar', label: '把 Friday review 加入日历', hint: 'Google Calendar', shortcut: [] },
    ],
  },
  {
    label: 'Navigate',
    items: [
      { icon: 'inbox', label: 'Inbox', shortcut: ['G', 'I'] },
      { icon: 'send', label: 'Sent', shortcut: ['G', 'T'] },
      { icon: 'star', label: 'Starred', shortcut: ['G', 'S'] },
    ],
  },
  {
    label: 'Actions',
    items: [
      { icon: 'send', label: 'Compose new', shortcut: ['C'] },
      { icon: 'archive', label: 'Archive selected', shortcut: ['E'] },
      { icon: 'search', label: 'Search all mail', shortcut: ['/'] },
    ],
  },
];

window.DATA = { MAILS, CATEGORIES, NAV, LABELS, AGENT_TASKS, COMMAND_GROUPS };
