//
//  TSRandomTextPicker.swift
//  AIEmoji
//
//  Created by 100Years on 2025/2/20.
//

class TSRandomTextPicker {
    private var texts: [String]
    private var lastIndex: Int?

    init(texts: [String]) {
        self.texts = texts
    }
    
    func getRandomText() -> String? {
        guard !texts.isEmpty else { return nil }
        
        var randomIndex: Int
        repeat {
            randomIndex = Int.random(in: 0..<texts.count)
        } while randomIndex == lastIndex
        
        lastIndex = randomIndex
        return texts[randomIndex]
    }
}
