// === SPEC-014b: WPF / Avalonia MVVM pattern section ===
/**
 * Returns true if the project uses WPF or Avalonia (MVVM-oriented .NET desktop frameworks).
 */
export function isWpfOrAvaloniaProject(knowledge) {
    const stack = knowledge.stack.map((s) => s.toLowerCase());
    return stack.some((s) => s.includes('wpf') || s.includes('avalonia'));
}
/**
 * Generate MVVM pattern section for WPF or Avalonia UI contracts.
 */
export function generateMvvmUIContract(screens, knowledge) {
    const isAvalonia = knowledge.stack.some((s) => s.toLowerCase().includes('avalonia'));
    const framework = isAvalonia ? 'Avalonia' : 'WPF';
    const observableBase = isAvalonia
        ? 'ReactiveUI.ReactiveObject'
        : 'CommunityToolkit.Mvvm.ObservableObject';
    const commandType = isAvalonia ? 'ReactiveCommand<Unit, Unit>' : 'RelayCommand';
    const collectionType = 'ObservableCollection<T>';
    const lines = [
        `## ${framework} MVVM UI Contract`,
        '',
        '### ViewModel Pattern',
        '',
        `- **Base class**: \`${observableBase}\``,
        `- **Commands**: \`${commandType}\` (auto-notifies CanExecute)`,
        `- **Collections**: \`${collectionType}\` (triggers UI refresh on Add/Remove)`,
        `- **Simple properties**: \`[ObservableProperty]\` attribute (CommunityToolkit) or \`RaiseAndSetIfChanged\` (ReactiveUI)`,
        '',
        '### XAML Binding Patterns',
        '',
        '```xml',
        '<!-- Simple property binding -->',
        '<TextBlock Text="{Binding UserName}" />',
        '',
        '<!-- Command binding -->',
        '<Button Command="{Binding SaveCommand}" Content="Save" />',
        '',
        '<!-- ObservableCollection binding -->',
        '<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" />',
        '',
        '<!-- Converter binding -->',
        '<TextBlock Text="{Binding Count, Converter={StaticResource CountToLabelConverter}}" />',
        '```',
        '',
        '### ViewModels per Screen',
        '',
    ];
    for (const screen of screens) {
        const vmName = screen.charAt(0).toUpperCase() + screen.slice(1).replace(/-/g, '') + 'ViewModel';
        lines.push(`#### ${vmName}`);
        lines.push('');
        lines.push(`- **Properties**: (list observable properties for ${screen})`);
        lines.push(`- **Commands**: (list ICommand instances for ${screen} actions)`);
        lines.push(`- **Collections**: (list ObservableCollection<T> for list views)`);
        lines.push('- **INotifyPropertyChanged**: auto via base class');
        lines.push('');
    }
    lines.push('### Design Guidelines');
    lines.push('');
    lines.push('- ViewModels must NOT reference UI elements (no Window/Control references)');
    lines.push('- Navigation via INavigationService, not direct Window instantiation');
    lines.push('- Dialogs via IDialogService to keep ViewModels testable');
    lines.push('- Use `[RelayCommand]` attribute for async commands with cancellation support');
    return lines.join('\n');
}
// === SPEC-014b: macOS native window pattern section ===
/**
 * Returns true if the project is a native macOS app (SwiftUI or AppKit).
 */
export function isMacOSNativeProject(knowledge) {
    const lang = knowledge.language.toLowerCase();
    const stack = knowledge.stack.map((s) => s.toLowerCase());
    return (lang === 'swift' ||
        stack.some((s) => s.includes('swiftui') || s.includes('appkit') || s.includes('nsapplication')));
}
/**
 * Generate macOS native window pattern UI contract.
 */
export function generateMacOSNativeUIContract(screens, knowledge) {
    const stack = knowledge.stack.map((s) => s.toLowerCase());
    const isMenuBar = stack.some((s) => s.includes('nsstatusitem') || s.includes('menubarextra'));
    const isSwiftUI = stack.some((s) => s.includes('swiftui')) || !stack.some((s) => s.includes('nsapplication'));
    const framework = isSwiftUI ? 'SwiftUI' : 'AppKit';
    const lines = [
        `## macOS Native UI Contract — ${framework}`,
        '',
        '### Window Patterns',
        '',
    ];
    if (isSwiftUI) {
        lines.push('- **WindowGroup**: primary app window (multi-instance, persists state via @SceneStorage)');
        lines.push('- **Settings { }**: preferences window (Cmd+,), separate scene');
        lines.push('- **Window**: single-instance auxiliary windows');
        if (isMenuBar) {
            lines.push('- **MenuBarExtra**: menu bar item with popover or menu (macOS 13+)');
            lines.push('  - Use `MenuBarExtra("App", systemImage: "icon")` for native behavior');
            lines.push('  - Content renders in popover or dropdown menu');
        }
        lines.push('');
        lines.push('### SwiftUI Scene Composition');
        lines.push('');
        lines.push('```swift');
        lines.push('@main');
        lines.push('struct MyApp: App {');
        lines.push('  var body: some Scene {');
        lines.push('    WindowGroup { ContentView() }');
        lines.push('    Settings { PreferencesView() }');
        if (isMenuBar) {
            lines.push('    MenuBarExtra("Status", systemImage: "circle.fill") { MenuView() }');
        }
        lines.push('  }');
        lines.push('}');
        lines.push('```');
    }
    else {
        lines.push('- **NSWindowController**: manages a single NSWindow + NSViewController pair');
        lines.push('- **NSViewController**: content controller, owns view hierarchy');
        lines.push('- **NSApplication.shared.mainWindow**: primary window reference');
        if (isMenuBar) {
            lines.push('- **NSStatusItem**: menu bar item (set button.image for icon)');
            lines.push('  - `NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)`');
            lines.push('  - Attach NSMenu or NSPopover for content');
        }
        lines.push('');
        lines.push('### AppKit Window Hierarchy');
        lines.push('');
        lines.push('```');
        lines.push('NSApplication');
        lines.push('  └── NSWindowController');
        lines.push('        └── NSWindow (resizable, min: 800x600)');
        lines.push('              └── NSViewController');
        lines.push('                    └── NSView hierarchy');
        lines.push('```');
    }
    lines.push('');
    lines.push('### Screens / Views');
    lines.push('');
    for (const screen of screens) {
        const viewName = screen.charAt(0).toUpperCase() + screen.slice(1).replace(/-/g, '') + 'View';
        lines.push(`- **${viewName}**: ${isSwiftUI ? 'SwiftUI View' : 'NSViewController + XIB/Storyboard'}`);
    }
    lines.push('');
    lines.push('### Navigation');
    lines.push('');
    if (isSwiftUI) {
        lines.push('- NavigationSplitView for sidebar-detail layout (macOS 13+)');
        lines.push('- NavigationStack for push navigation within a column');
        lines.push('- Sheets: `.sheet(isPresented:) { ... }` for modal dialogs');
        lines.push('- Inspectors: `.inspector(isPresented:) { ... }` for side panels (macOS 14+)');
    }
    else {
        lines.push('- NSSplitViewController for sidebar-detail layout');
        lines.push('- NSTabViewController for tabbed interfaces');
        lines.push('- presentAsModalWindow() for modal windows');
        lines.push('- presentAsSheet() for sheet attachments');
    }
    return lines.join('\n');
}
//# sourceMappingURL=native-contract.js.map