import Cocoa
import FlutterMacOS

class MainFlutterWindow: NSWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController()
    self.contentViewController = flutterViewController

    // 桌面默认窗口 920×600（对齐设计稿 ui_kits/desktop），最小 720×560。
    let defaultSize = NSSize(width: 920, height: 600)
    self.setContentSize(defaultSize)
    self.contentMinSize = NSSize(width: 720, height: 560)
    self.center()

    RegisterGeneratedPlugins(registry: flutterViewController)

    // P1 方案B:VPN 原生控制通道(NETunnelProviderManager 启停 PacketTunnel)。
    // 需 VpnChannel.swift 已加入 Runner target 的 Compile Sources。
    VpnChannel.register(with: flutterViewController.registrar(forPlugin: "VpnChannel"))

    super.awakeFromNib()
  }
}
