import Foundation
import SwiftData

@Model final class SnapshotDelta {
    var id: UUID = UUID()
    var fromSnapshotID: UUID = UUID()
    var toSnapshotID: UUID = UUID()
    var deviceID: String = ""
    var computedAt: Date = Date.now
    var checksumBefore: String = ""
    var checksumAfter: String = ""
    var isCloudKitImported: Bool = false
    @Relationship(deleteRule: .cascade, inverse: \TypeDelta.delta)
    var typeDeltas: [TypeDelta]? = []

    init(fromSnapshotID: UUID, toSnapshotID: UUID, deviceID: String) {
        self.id = UUID()
        self.fromSnapshotID = fromSnapshotID
        self.toSnapshotID = toSnapshotID
        self.deviceID = deviceID
    }
}
