// Seeded data for Agent Jobs pipeline
const JOBS = [
  // ===== Triage (Discovered) =====
  {
    id: 'j_disc_01',
    title: 'Cross-system follow-through',
    state: 'discovered',
    function_tags: ['customer', 'sales'],
    source: { kind: 'discovered', label: 'Discovered by Membrane' },
    description: 'Track conversations and commitments across email, Slack, and tickets, and revive threads that have gone cold past their commitment window.',
    why: '~340 threads/mo are going cold across Gmail, Slack, and Linear, with an average recovery time of 9 days and ~14% never recovered.',
    people: ['MA', 'JD', 'DS', 'PR', 'AL', 'TH', 'RY', 'SA', 'LI', 'KE', 'NI', 'BR'],
    tools: ['Gmail', 'Slack', 'Linear', 'HubSpot', 'Salesforce'],
    value: {
      headline: '~340 cold threads/mo recovered or routed',
    },
    last_updated: '2 days ago',
  },
  {
    id: 'j_disc_02',
    title: 'Customer data reconciliation between systems',
    state: 'discovered',
    function_tags: ['ops', 'customer'],
    source: { kind: 'discovered', label: 'Discovered by Membrane' },
    description: 'Detect customer record mismatches across CRM, billing, support, and analytics, and reconcile or surface conflicts with evidence.',
    why: '~1,800 of ~14,000 customer records show mismatches across HubSpot, Stripe, Zendesk, and Mixpanel, with ~70 new mismatches accumulating weekly.',
    people: ['RV', 'OP', 'CX', 'LD', 'RM'],
    tools: ['HubSpot', 'Stripe', 'Zendesk', 'Mixpanel', 'Salesforce'],
    value: {
      headline: 'Drift held below 2% of active customer records',
    },
    last_updated: '5 days ago',
  },
  {
    id: 'j_disc_03',
    title: 'Infrastructure incident triage',
    state: 'discovered',
    function_tags: ['ops'],
    source: { kind: 'discovered', label: 'Discovered by Membrane' },
    description: 'Gather signals from monitoring, deploys, and recent changes when PagerDuty fires, then auto-resolve known patterns or page on-call with a complete briefing.',
    why: 'On-call engineers spend 6–8 min per page on context-gathering across Datadog, GitHub, and Slack, and ~30% of ~140 weekly pages are recurrences of known transient issues.',
    people: ['EN', 'PT', 'JK', 'MO', 'DV', 'SR', 'TY', 'WL'],
    tools: ['PagerDuty', 'Datadog', 'GitHub', 'Linear', 'Slack'],
    value: {
      headline: '~170 false pages/mo auto-resolved',
    },
    last_updated: '1 day ago',
  },

  // ===== Job Setup (Scoping) =====
  {
    id: 'j_scope_01',
    title: 'AP three-way match',
    state: 'scoping',
    function_tags: ['finance'],
    unit_label: 'invoice',
    setup_status: 'drafting', // drafting | awaiting_input | ready
    setup_description: 'Connecting NetSuite and Slack, identifying triggers for invoice exceptions, assigning reviewers, and defining what the agent can and can\'t approve.',
    setup_progress: {
      tools: { done: 1, total: 2 },           // NetSuite connected, Slack pending
      triggers: { done: 0, total: 2 },         // exception triggers being defined
      people: { done: 1, total: 3 },           // 1 of 3 reviewers assigned
      boundaries: 'Drafting',
    },
    setup_updated_at: '4h ago',
  },
  {
    id: 'j_scope_02',
    title: 'Refund eligibility triage',
    state: 'scoping',
    function_tags: ['customer', 'finance'],
    unit_label: 'request',
    setup_status: 'awaiting_input',
    setup_description: 'Setting up Zendesk and Stripe access, defining triggers for refund requests, assigning approvers, and bounding which refunds can be auto-approved.',
    setup_needs: 'Need admin credentials for Zendesk to set up the trigger.',
    setup_progress: {
      tools: { done: 1, total: 2 },            // Stripe connected, Zendesk blocked
      triggers: { done: 0, total: 1 },
      people: { done: 2, total: 3 },
      boundaries: 'Drafting',
    },
    setup_updated_at: '2 days ago',
  },
  {
    id: 'j_scope_03',
    title: 'CSAT escalation routing',
    state: 'scoping',
    function_tags: ['customer'],
    unit_label: 'ticket',
    setup_status: 'ready',
    setup_description: 'Connecting Zendesk and Slack, identifying triggers for negative-sentiment tickets, assigning the CX leads who\'ll review escalations, and defining when the agent can re-route vs. when it must surface.',
    setup_progress: {
      tools: { done: 2, total: 2 },
      triggers: { done: 3, total: 3 },
      people: { done: 4, total: 4 },
      boundaries: 'Defined',
    },
    setup_updated_at: '1d ago',
  },

  // ===== Onboarding =====
  {
    id: 'j_onb_01',
    title: 'Vendor onboarding intake',
    state: 'onboarding',
    function_tags: ['finance', 'ops'],
    unit_label: 'vendor',
    integrations: [
      { name: 'NetSuite', status: 'connected' },
      { name: 'DocuSign', status: 'connected' },
      { name: 'Slack', status: 'connecting' },
      { name: 'Google Drive', status: 'pending' },
    ],
    loaded_context: ['Vendor policy', 'Approval matrix', '6mo history'],
    permissions_summary: 'Read invoices · Write reconciliation · No payments',
    onboarding_status: 'loading_context',
    onboarding_description: 'Connecting tools, ingesting your vendor policy and approval matrix, and configuring the bounded permissions defined during setup.',
    onboarding_updated_at: '20m ago',
  },
  {
    id: 'j_onb_02',
    title: 'Order-status replies',
    state: 'onboarding',
    function_tags: ['customer'],
    unit_label: 'reply',
    integrations: [
      { name: 'Shopify', status: 'connected' },
      { name: 'Zendesk', status: 'connected' },
      { name: 'ShipBob', status: 'connected' },
    ],
    loaded_context: ['Brand voice guide', 'SLA matrix', 'Refund policy'],
    permissions_summary: 'Read orders · Draft replies · No discounts',
    onboarding_status: 'ready_for_trial',
    onboarding_description: 'All systems connected, brand voice and SLA context loaded, draft-only permissions configured. Agent is ready to begin its 14-day trial.',
    onboarding_updated_at: '1h ago',
    ready_for_trial: true,
  },
  {
    id: 'j_onb_03',
    title: 'Contract clause extraction',
    state: 'onboarding',
    function_tags: ['legal', 'ops'],
    unit_label: 'contract',
    integrations: [
      { name: 'DocuSign', status: 'connected' },
      { name: 'Salesforce', status: 'connecting' },
      { name: 'Google Drive', status: 'connecting' },
      { name: 'Slack', status: 'pending' },
    ],
    loaded_context: ['Playbook v3', 'Risk taxonomy'],
    permissions_summary: 'Read contracts · Tag clauses · No edits',
    onboarding_status: 'connecting_integrations',
    onboarding_description: 'Establishing read access across DocuSign, Salesforce, and Drive so the agent can pull executed contracts and prior-version comparisons.',
    onboarding_updated_at: '5m ago',
  },

  // ===== Production (formerly In trial + On the job) =====
  {
    id: 'j_trial_01',
    title: 'Expense policy review',
    state: 'on_the_job',
    trial_period: true,
    function_tags: ['finance'],
    unit_label: 'report',
    integrations: [
      { name: 'NetSuite' }, { name: 'Concur' }, { name: 'Slack' },
    ],
    trial_day: 12,
    trial_duration_days: 14,
    cases_handled: 47,
    cases_expected: 50,
    monthly_cases: 47,
    resolution_rate: 0.94,
    monthly_resolution_rate: 0.94,
    human_corrections: 2,
    avg_resolution_minutes: 3.2,
    monthly_cost_usd: 0,
    operational_status: 'running',
    last_updated: '20m ago',
  },
  {
    id: 'j_trial_02',
    title: 'Lead qualification scoring',
    state: 'on_the_job',
    trial_period: true,
    function_tags: ['sales'],
    unit_label: 'lead',
    integrations: [
      { name: 'Salesforce' }, { name: 'HubSpot' }, { name: 'Slack' },
    ],
    trial_day: 14,
    trial_duration_days: 14,
    cases_handled: 312,
    cases_expected: 300,
    monthly_cases: 312,
    resolution_rate: 0.91,
    monthly_resolution_rate: 0.91,
    human_corrections: 0,
    avg_resolution_minutes: 0.6,
    monthly_cost_usd: 0,
    operational_status: 'running',
    decision_ready: true,
    last_updated: '1h ago',
  },
  {
    id: 'j_trial_03',
    title: 'PO acknowledgement parsing',
    state: 'on_the_job',
    trial_period: true,
    function_tags: ['ops'],
    unit_label: 'PO',
    integrations: [
      { name: 'NetSuite' }, { name: 'Gmail' }, { name: 'Drive' },
    ],
    trial_day: 6,
    trial_duration_days: 14,
    cases_handled: 88,
    cases_expected: 200,
    monthly_cases: 88,
    resolution_rate: 0.83,
    monthly_resolution_rate: 0.83,
    human_corrections: 7,
    avg_resolution_minutes: 1.4,
    monthly_cost_usd: 0,
    operational_status: 'anomaly',
    anomaly: true,
    anomaly_note: 'Resolution rate -3.2% over 48h',
    last_updated: '5m ago',
  },

  // ===== On the job (live) =====
  {
    id: 'j_run_01',
    title: 'Invoice exception handling',
    state: 'on_the_job',
    function_tags: ['finance', 'ops'],
    unit_label: 'case',
    integrations: [
      { name: 'NetSuite' }, { name: 'Slack' }, { name: 'Gmail' }, { name: 'Snowflake' }, { name: 'Drive' },
    ],
    started_at: 'Mar 14',
    monthly_cases: 312,
    monthly_resolution_rate: 0.96,
    monthly_cost_usd: 2480,
    operational_status: 'running',
    last_updated: '2h ago',
  },
  {
    id: 'j_run_02',
    title: 'Refund eligibility triage',
    state: 'on_the_job',
    function_tags: ['customer'],
    unit_label: 'refund',
    integrations: [
      { name: 'Zendesk' }, { name: 'Shopify' }, { name: 'Stripe' },
    ],
    started_at: 'Feb 02',
    monthly_cases: 1840,
    monthly_resolution_rate: 0.94,
    monthly_cost_usd: 1920,
    operational_status: 'running',
    last_updated: '12m ago',
  },
  {
    id: 'j_run_03',
    title: 'Subscription dunning replies',
    state: 'on_the_job',
    function_tags: ['customer', 'finance'],
    unit_label: 'reply',
    integrations: [
      { name: 'Stripe' }, { name: 'Zendesk' }, { name: 'HubSpot' },
    ],
    started_at: 'Jan 21',
    monthly_cases: 980,
    monthly_resolution_rate: 0.92,
    monthly_cost_usd: 1140,
    operational_status: 'anomaly',
    anomaly_note: 'Resolution rate -3.2% over 48h',
    last_updated: '3m ago',
  },
  {
    id: 'j_run_04',
    title: 'Renewal risk surfacing',
    state: 'on_the_job',
    function_tags: ['sales'],
    unit_label: 'account',
    integrations: [
      { name: 'Salesforce' }, { name: 'Gong' }, { name: 'Snowflake' }, { name: 'Slack' },
    ],
    started_at: 'Dec 11',
    monthly_cases: 214,
    monthly_resolution_rate: 0.97,
    monthly_cost_usd: 1450,
    operational_status: 'running',
    last_updated: '40m ago',
  },
  {
    id: 'j_run_05',
    title: 'Sales coaching summaries',
    state: 'on_the_job',
    function_tags: ['sales'],
    unit_label: 'call',
    integrations: [
      { name: 'Gong' }, { name: 'Salesforce' }, { name: 'Slack' },
    ],
    started_at: 'Nov 28',
    monthly_cases: 642,
    monthly_resolution_rate: 0.99,
    monthly_cost_usd: 720,
    operational_status: 'paused',
    last_updated: '6h ago',
  },
  {
    id: 'j_run_06',
    title: 'Inbound contract redlines',
    state: 'on_the_job',
    function_tags: ['legal', 'sales'],
    unit_label: 'contract',
    integrations: [
      { name: 'Ironclad' }, { name: 'DocuSign' }, { name: 'Salesforce' },
    ],
    started_at: 'Oct 03',
    monthly_cases: 138,
    monthly_resolution_rate: 0.91,
    monthly_cost_usd: 690,
    operational_status: 'running',
    last_updated: '1h ago',
  },
];

const STAGES = [
  {
    n: 1, id: 'discovered', name: 'Triage', sub: 'Reviewing fit and value',
    desc: 'Membrane observes your operations to surface candidate jobs that AI agents could take on. Review each candidate to decide whether to move it into scoping.',
    empty: 'Membrane is observing your operations to surface candidate jobs. First candidates typically appear within 2–3 weeks of integration.',
  },
  {
    n: 2, id: 'scoping', name: 'Job setup', sub: 'Preparing the job for an agent',
    desc: 'Membrane translates each approved candidate into a precise contract: what the agent will do, what it won’t, and what success looks like. You approve the contract before onboarding begins.',
    empty: 'No jobs in scoping. Once a candidate is approved from Triage, Membrane scopes it into a precise contract before onboarding.',
  },
  {
    n: 3, id: 'onboarding', name: 'Agent onboarding', sub: 'Bringing an agent into the job',
    desc: 'Membrane connects the agent to your systems, loads your policies, and configures the rules and permissions for the job. Like onboarding a new hire to your environment.',
    empty: 'No jobs onboarding. After scope approval, Membrane connects the agent to your systems and loads your context and rules before trial.',
  },
  {
    n: 4, id: 'on_the_job', name: 'Production', sub: 'Doing the job',
    desc: 'Agents running in production. New hires spend their first 14 days under a trial period — every action reviewed by a human — before graduating to autonomous operation. Measured, governed, and accountable for real outcomes throughout.',
    empty: 'No jobs in production yet. Once an agent finishes onboarding, it runs in trial for 14 days before being hired into autonomous production.',
  },
];

window.JOBS = JOBS;
window.STAGES = STAGES;
