import type { AppStateV1 } from './types'

function isoOffset(days: number): string {
  const value = new Date()
  value.setDate(value.getDate() + days)
  return value.toISOString().slice(0, 10)
}

export function createSampleData(): AppStateV1 {
  const createdAt = new Date().toISOString()
  return {
    version: 1,
    goals: [
      {
        id: 'goal-typescript',
        title: 'Master practical TypeScript patterns',
        description: 'Build confidence with typed state, validation and maintainable application architecture.',
        category: 'Engineering',
        targetDate: isoOffset(35),
        color: '#6257d9',
        createdAt,
      },
      {
        id: 'goal-accessibility',
        title: 'Design accessible digital products',
        description: 'Apply keyboard, semantic HTML and inclusive interaction practices to production interfaces.',
        category: 'Product design',
        targetDate: isoOffset(52),
        color: '#0b8f74',
        createdAt,
      },
      {
        id: 'goal-testing',
        title: 'Build a reliable browser testing workflow',
        description: 'Create repeatable checks across browsers, viewports and real devices.',
        category: 'Quality',
        targetDate: isoOffset(21),
        color: '#db6b35',
        createdAt,
      },
      {
        id: 'goal-communication',
        title: 'Communicate engineering decisions clearly',
        description: 'Capture concise evidence, trade-offs and outcomes for technical and non-technical readers.',
        category: 'Professional skills',
        targetDate: isoOffset(65),
        color: '#3973c7',
        createdAt,
      },
    ],
    tasks: [
      { id: 'task-1', goalId: 'goal-typescript', title: 'Model the learning domain', notes: 'Define stable interfaces and derived state.', dueDate: isoOffset(-5), priority: 'high', status: 'done', estimatedMinutes: 90, createdAt },
      { id: 'task-2', goalId: 'goal-typescript', title: 'Add safe import validation', notes: 'Reject malformed and unsupported backups.', dueDate: isoOffset(2), priority: 'high', status: 'in-progress', estimatedMinutes: 75, createdAt },
      { id: 'task-3', goalId: 'goal-typescript', title: 'Review state update patterns', notes: 'Document immutable updates and derived values.', dueDate: isoOffset(9), priority: 'medium', status: 'todo', estimatedMinutes: 45, createdAt },
      { id: 'task-4', goalId: 'goal-accessibility', title: 'Complete keyboard walkthrough', notes: 'Check focus order, dialogs and visible focus.', dueDate: isoOffset(4), priority: 'high', status: 'in-progress', estimatedMinutes: 60, createdAt },
      { id: 'task-5', goalId: 'goal-accessibility', title: 'Audit form labels and errors', notes: 'Confirm every control has a useful accessible name.', dueDate: isoOffset(12), priority: 'medium', status: 'todo', estimatedMinutes: 50, createdAt },
      { id: 'task-6', goalId: 'goal-testing', title: 'Create three-resolution test matrix', notes: 'Record expected layout at each required viewport.', dueDate: isoOffset(-2), priority: 'high', status: 'done', estimatedMinutes: 55, createdAt },
      { id: 'task-7', goalId: 'goal-testing', title: 'Run Firefox regression suite', notes: 'Compare the seeded core journey with Chromium.', dueDate: isoOffset(1), priority: 'high', status: 'todo', estimatedMinutes: 40, createdAt },
      { id: 'task-8', goalId: 'goal-testing', title: 'Capture Edge developer tools evidence', notes: 'Include browser version, console and storage.', dueDate: isoOffset(6), priority: 'medium', status: 'todo', estimatedMinutes: 35, createdAt },
      { id: 'task-9', goalId: 'goal-communication', title: 'Draft outcome and lessons learned', notes: 'Link statements to issue, test and screenshot IDs.', dueDate: isoOffset(14), priority: 'medium', status: 'todo', estimatedMinutes: 70, createdAt },
    ],
  }
}
