import type { VehicleAlarm } from '@/types/alarm'

function minsAgo(m: number): string {
  return new Date(Date.now() - m * 60_000).toISOString()
}

export async function mockAlarms(): Promise<VehicleAlarm[]> {
  await new Promise((r) => setTimeout(r, 60))
  return [
    {
      id: 'a1', carId: 309, carName: 'AGV-309', info: '导航失联', level: 2,
      status: 'active', firstAt: minsAgo(6), lastAt: minsAgo(0), resolvedAt: null, durationSecs: null, acknowledged: false
    },
    {
      id: 'a2', carId: 415, carName: 'Kiva-415', info: '急停触发', level: 3,
      status: 'active', firstAt: minsAgo(2), lastAt: minsAgo(0), resolvedAt: null, durationSecs: null, acknowledged: false
    },
    {
      id: 'a3', carId: 572, carName: 'AGV-572', info: '电量低', level: 1,
      status: 'cleared', firstAt: minsAgo(120), lastAt: minsAgo(95), resolvedAt: minsAgo(95), durationSecs: 1500, acknowledged: false
    },
    {
      id: 'a4', carId: 888, carName: 'Kiva-888', info: '放货点被占用', level: 1,
      status: 'cleared', firstAt: minsAgo(1440), lastAt: minsAgo(1420), resolvedAt: minsAgo(1420), durationSecs: 1200, acknowledged: false
    }
  ]
}
