import SwiftUI
import ComposeApp

/// SwiftUI `@Environment` mirror of Compose's `LocalDataManager` ambient.
///
/// Production views resolve `@Environment(\.dataManager)` to
/// `DataManagerObservable.shared` — the existing Swift-side mirror of the
/// shared Kotlin `DataManager` singleton. Tests, previews, and the
/// parity-gallery override via:
///
/// ```swift
/// MyView()
///     .environment(\.dataManager, FakeDataManagerObservable())
/// ```
///
/// This key is intentionally introduced without migrating any SwiftUI
/// screens yet. Views continue to access `DataManagerObservable.shared`
/// directly; the actual view-level migration lands when parity-gallery
/// fixtures arrive (P1), at which point ViewModels will gain an optional
/// init param that accepts a `DataManagerObservable` resolved from this
/// environment key.
struct DataManagerEnvironmentKey: EnvironmentKey {
    static let defaultValue: DataManagerObservable = DataManagerObservable.shared
}

extension EnvironmentValues {
    var dataManager: DataManagerObservable {
        get { self[DataManagerEnvironmentKey.self] }
        set { self[DataManagerEnvironmentKey.self] = newValue }
    }
}
