export const CHECKLIST_KEY_V1 = 'magikarp-checklist-v1'; export const CHECKLIST_KEY_V2 = 'magikarp-checklist-v2'; export type VariantKey = 'base' | 'holofoil' | 'reverseHolofoil'; export type VariantState = Partial>; export type ChecklistV2 = Record; // cardId -> variant flags // Legacy loader (v1) export function loadChecklistV1(): Set { if (typeof window === 'undefined') return new Set(); try { const raw = localStorage.getItem(CHECKLIST_KEY_V1); if (!raw) return new Set(); const arr = JSON.parse(raw) as string[]; return new Set(arr); } catch { return new Set(); } } // New storage (v2) export function loadChecklist(): ChecklistV2 { if (typeof window === 'undefined') return {}; try { const v2 = localStorage.getItem(CHECKLIST_KEY_V2); if (v2) return JSON.parse(v2) as ChecklistV2; // migrate from v1 if present const v1 = loadChecklistV1(); if (v1.size === 0) return {}; const migrated: ChecklistV2 = {}; v1.forEach((id) => { migrated[id] = { base: true }; }); saveChecklist(migrated); return migrated; } catch { return {}; } } export function saveChecklist(state: ChecklistV2) { if (typeof window === 'undefined') return; try { localStorage.setItem(CHECKLIST_KEY_V2, JSON.stringify(state)); } catch { // ignore } }