// TerminalViewRepresentable.swift
// SwiftUI bridge that wraps TerminalViewController for use inside SwiftUI view trees.
//
// Usage:
//   let controller = TerminalViewController()
//   TerminalViewRepresentable(controller: controller)
//       .ignoresSafeArea()

import SwiftUI

/// A SwiftUI-compatible wrapper around `TerminalViewController`.
///
/// The `controller` is created and owned externally (typically by a
/// parent view or view-model) so that its `feed(data:)` and
/// `apply(theme:)` APIs remain accessible outside the SwiftUI tree.
public struct TerminalViewRepresentable: UIViewControllerRepresentable {

    // MARK: Properties

    /// The controller to host.  Must be created before this representable is inserted.
    public let controller: TerminalViewController

    // MARK: Init

    public init(controller: TerminalViewController) {
        self.controller = controller
    }

    // MARK: UIViewControllerRepresentable

    public func makeUIViewController(context: Context) -> TerminalViewController {
        controller
    }

    public func updateUIViewController(_ uiViewController: TerminalViewController,
                                       context: Context) {
        // No-op for now: theme and font updates are applied imperatively via
        // controller.apply(theme:) and controller.apply(font:).
    }
}
