// AUTO-GENERATED from gstack/ios-qa/templates/DebugBridgeWiring.swift.template
//
// Wiring snippet for the app's @main entry. Users paste this into their
// App.swift inside the `init()` of the SwiftUI App struct, gated by
// #if DEBUG. The wiring is intentionally tiny; everything heavy lives in
// the DebugBridge target.

#if DEBUG
import DebugBridge

@MainActor
func startGstackDebugBridge(appState: AppState) {
    // Read --recording flag from launch arguments
    let recording = ProcessInfo.processInfo.arguments.contains("--gstack-recording")

    // Install accessibility + screenshot + mutation bridges before starting
    // the server so the first authenticated request can use them.
    ElementsBridge.resolver = { AccessibilityScanner.snapshot() }
    ScreenshotBridge.resolver = { SnapshotCapture.capturePNG() }
    MutationBridge.resolver = { op, payload in
        MutationDispatcher.shared.run(op: op, payload: payload)
    }

    DebugBridgeManager.shared.start(appState: appState, recording: recording)
}
#endif

// Example usage in the app's @main entry (paste this into App.swift):
//
//   @main
//   struct MyApp: App {
//       @State private var appState = MyAppState()
//
//       init() {
//           #if DEBUG
//           startGstackDebugBridge(appState: appState)
//           #endif
//       }
//
//       var body: some Scene {
//           WindowGroup { ContentView() }
//       }
//   }
