import { create } from "zustand"
import { persist } from "zustand/middleware"

interface VocabState {
  // Shell — filled during Vocab feature implementation
  knownWords: string[]
  markKnown: (wordId: string) => void
  markUnknown: (wordId: string) => void
  reset: () => void
}

export const useVocabStore = create<VocabState>()(
  persist(
    (set) => ({
      knownWords: [],
      markKnown: (wordId) =>
        set((state) => ({
          knownWords: [...new Set([...state.knownWords, wordId])],
        })),
      markUnknown: (wordId) =>
        set((state) => ({
          knownWords: state.knownWords.filter((id) => id !== wordId),
        })),
      reset: () => set({ knownWords: [] }),
    }),
    { name: "vocab-store" },
  ),
)
