import Foundation
#if canImport(UIKit)
import UIKit
#endif

@MainActor
enum HapticManager {
    static func impact(_ style: HapticStyle = .medium) {
        #if canImport(UIKit) && !os(macOS)
        let generator: UIImpactFeedbackGenerator
        switch style {
        case .light:
            generator = UIImpactFeedbackGenerator(style: .light)
        case .medium:
            generator = UIImpactFeedbackGenerator(style: .medium)
        case .heavy:
            generator = UIImpactFeedbackGenerator(style: .heavy)
        }
        generator.impactOccurred()
        #endif
    }

    static func notification(_ type: HapticNotification) {
        #if canImport(UIKit) && !os(macOS)
        let generator = UINotificationFeedbackGenerator()
        switch type {
        case .success:
            generator.notificationOccurred(.success)
        case .warning:
            generator.notificationOccurred(.warning)
        case .error:
            generator.notificationOccurred(.error)
        }
        #endif
    }
}

enum HapticStyle: Sendable {
    case light, medium, heavy
}

enum HapticNotification: Sendable {
    case success, warning, error
}
