import SwiftData
import Foundation

@Model
public final class IrregularSpan {
    public var verbId: Int = 0
    public var tenseId: String = ""
    public var personIndex: Int = 0
    public var spanType: Int = 0
    public var pattern: Int = 0
    public var start: Int = 0
    public var end: Int = 0

    public var verbForm: VerbForm?

    public init(verbId: Int, tenseId: String, personIndex: Int, spanType: Int, pattern: Int, start: Int, end: Int) {
        self.verbId = verbId
        self.tenseId = tenseId
        self.personIndex = personIndex
        self.spanType = spanType
        self.pattern = pattern
        self.start = start
        self.end = end
    }

    public var category: SpanCategory {
        switch spanType {
        case 100..<200: return .spelling
        case 200..<300: return .stemChange
        case 300..<400: return .uniqueIrregular
        default: return .uniqueIrregular
        }
    }

    public enum SpanCategory: String, Sendable {
        case spelling = "Spelling Change"
        case stemChange = "Stem Change"
        case uniqueIrregular = "Unique Irregular"
    }
}
