import type { AdapterStatus, Panel } from '../../src/lib/collector-types'
import type { FactoryPanelData, FactoryRunView } from '../../src/lib/factory-types'

const TS = '2026-08-05T12:00:00.000Z'
const REPO_ROOT = '/home/user/Projects/overdeck'

export const FACTORY_ADW_ID = 'adw-overdeck-live'

export const FACTORY_RUNNING_RUN: FactoryRunView = {
  adwId: FACTORY_ADW_ID,
  repo: REPO_ROOT,
  repoName: 'overdeck',
  adwName: 'adw_factory_accept',
  runSlug: 'wire-factory-acceptance-proof',
  request: 'wire factory acceptance proof',
  status: 'running',
  engineer: 'engineer',
  startedAt: '2026-08-05T11:00:00.000Z',
  endedAt: null,
  totalTokens: 4_200,
  totalCost: 0.18,
  phases: [
    {
      phaseId: 'phase-overdeck-implement',
      seq: 1,
      name: 'implement',
      kind: 'agent',
      owner: 'coder',
      description: null,
      status: 'running',
      attempt: 0,
      retries: 0,
      error: null,
      startedAt: '2026-08-05T11:00:00.000Z',
      endedAt: null,
      tokens: 4_200,
      spend: 0.18,
    },
  ],
  events: [
    {
      rowid: 1,
      eventId: 'evt-overdeck-boot',
      phaseId: 'phase-overdeck-implement',
      parentId: null,
      type: 'phase_start',
      name: 'session_boot',
      payloadJson: null,
      tokens: null,
      startedAt: '2026-08-05T11:00:00.000Z',
      endedAt: null,
    },
  ],
  decisions: [],
}

export const FACTORY_RUNS_PANEL: Panel = {
  id: 'factory-runs',
  ts: TS,
  data: {
    dbPath: '/tmp/sssf.db',
    dbPresent: true,
    runs: [FACTORY_RUNNING_RUN],
  } satisfies FactoryPanelData,
}

export const FACTORY_ADAPTER: AdapterStatus = {
  id: 'factory',
  interval: 5_000,
  lastAttempt: Date.parse(TS),
  lastSuccess: Date.parse(TS),
  lastPollDurationMs: 12,
  consecutiveErrors: 0,
  stale: false,
}
