)
}
interface RecoveryWordItem {
id: string
position: number
word: string
}
function buildRecoveryWordItems(recoveryPhrase: readonly string[]): RecoveryWordItem[] {
const occurrences = new Map()
const items: RecoveryWordItem[] = []
let position = 1
for (const word of recoveryPhrase) {
const current = occurrences.get(word) ?? 0
const next = current + 1
occurrences.set(word, next)
items.push({ id: `${word}-${next}`, position, word })
position += 1
}
return items
}