const DESKTOP_FW_SET = new Set(['electron', 'tauri', 'dotnet', 'qt']);
/**
 * Returns true if the project is a desktop app based on framework or category.
 */
export function isDesktopProject(knowledge) {
    if (knowledge.projectCategory === 'desktop') {
        return true;
    }
    return knowledge.framework !== null && DESKTOP_FW_SET.has(knowledge.framework);
}
/**
 * Generate a desktop UI contract with window management, menus, tray, and dialogs.
 */
export function generateDesktopUIContract(screens, knowledge) {
    const framework = knowledge.framework ?? 'electron';
    const frameworkTitle = framework.charAt(0).toUpperCase() + framework.slice(1);
    const components = buildDesktopComponents(screens, framework);
    const lines = [
        `## Desktop UI Contract — ${frameworkTitle}`,
        '',
        '### Window Management',
        ...buildWindowSection(framework),
        '',
        '### Menu Bar',
        ...buildMenuBarSection(),
        '',
        '### System Tray',
        ...buildSystemTraySection(),
        '',
        '### Native Dialogs',
        ...buildNativeDialogsSection(),
        '',
        '### Keyboard Shortcuts',
        ...buildShortcutsSection(framework),
        '',
        '### Component Tree',
        '```json',
        JSON.stringify(components, null, 2),
        '```',
    ];
    return lines.join('\n');
}
function buildWindowSection(framework) {
    const isTauri = framework === 'tauri';
    const titleBarLabel = isTauri ? 'Tauri' : 'Electron';
    return [
        '- **MainWindow**: primary app window (resizable, min-size: 800x600)',
        `- **TitleBar**: custom ${titleBarLabel} title bar with window controls (min/max/close)`,
        '- **StatusBar**: bottom bar with app status, progress indicators',
        '- **Sidebar**: collapsible navigation panel (width: 240px)',
        '- **ContentArea**: main scrollable content region',
    ];
}
function buildMenuBarSection() {
    return [
        '- **FileMenu**: New, Open, Save, Save As, Recent Files, Exit',
        '- **EditMenu**: Undo, Redo, Cut, Copy, Paste, Select All, Find',
        '- **ViewMenu**: Zoom In/Out, Reset Zoom, Toggle Sidebar, Full Screen',
        '- **HelpMenu**: Documentation, Check for Updates, About',
    ];
}
function buildSystemTraySection() {
    return [
        '- **TrayIcon**: app icon with color state (active/idle/error)',
        '- **TrayMenu**: Show/Hide Window, Quick Actions, Quit',
        '- **TrayBadge**: notification count overlay (optional)',
        '- **TrayTooltip**: status text on hover',
    ];
}
function buildNativeDialogsSection() {
    return [
        '- **FileOpenDialog**: filters (by extension), multi-select, last-used-path memory',
        '- **FileSaveDialog**: filename input, format selection, overwrite confirmation',
        '- **FolderSelectDialog**: directory tree, create folder button',
        '- **MessageBox**: info/warning/error/question with custom buttons',
        '- **ColorPicker**: native OS color picker integration',
        '- **FontPicker**: system font list, size, style selection',
    ];
}
function buildShortcutsSection(framework) {
    /* v8 ignore start */
    const modifier = process.platform === 'darwin' ? 'Cmd' : 'Ctrl';
    /* v8 ignore stop */
    const globalShortcutApi = framework === 'electron' ? 'globalShortcut.register()' : 'tauri global shortcut API';
    return [
        `- **File operations**: ${modifier}+N (New), ${modifier}+O (Open), ${modifier}+S (Save)`,
        `- **Edit operations**: ${modifier}+Z (Undo), ${modifier}+Y (Redo), ${modifier}+F (Find)`,
        `- **Navigation**: ${modifier}+W (Close Tab), ${modifier}+T (New Tab)`,
        `- **Global shortcut**: ${globalShortcutApi}`,
    ];
}
function buildDesktopComponents(screens, framework) {
    const menuChildren = [
        {
            name: 'FileMenu',
            type: 'client',
            justification: 'Native menu rendered by OS — requires client-side IPC handlers',
            props: [],
            children: [],
        },
        {
            name: 'EditMenu',
            type: 'client',
            justification: 'Edit commands trigger client-side undo/clipboard operations',
            props: [],
            children: [],
        },
        {
            name: 'ViewMenu',
            type: 'client',
            justification: 'View controls manipulate window state on the client',
            props: [],
            children: [],
        },
        {
            name: 'HelpMenu',
            type: 'client',
            justification: 'Help actions open external links or dialogs on the client',
            props: [],
            children: [],
        },
    ];
    const screenChildren = screens.map((s) => ({
        name: s,
        type: 'client',
        justification: 'Desktop screen rendered in the Electron/Tauri renderer process',
        props: [],
        children: [],
    }));
    return [
        {
            name: 'AppShell',
            type: 'client',
            justification: `Root desktop shell for ${framework} — all UI runs in the renderer process`,
            props: [
                {
                    name: 'framework',
                    type: 'string',
                    required: true,
                    description: 'Desktop framework identifier',
                },
                { name: 'platform', type: 'string', required: false, description: 'Target OS platform' },
            ],
            children: [
                {
                    name: 'MenuBar',
                    type: 'client',
                    justification: 'Native OS menu bar constructed via framework API',
                    props: [
                        {
                            name: 'native',
                            type: 'boolean',
                            required: false,
                            description: 'Use native OS menu rendering',
                        },
                    ],
                    children: menuChildren,
                },
                {
                    name: 'MainContent',
                    type: 'client',
                    justification: 'Flexible content area that hosts all app screens',
                    props: [
                        { name: 'flex', type: 'number', required: false, description: 'CSS flex grow value' },
                    ],
                    children: screenChildren,
                },
                {
                    name: 'StatusBar',
                    type: 'client',
                    justification: 'Bottom status bar showing app state and background task progress',
                    props: [],
                    children: [],
                },
                {
                    name: 'SystemTray',
                    type: 'client',
                    justification: 'OS system tray integration for background operation',
                    props: [
                        {
                            name: 'icon',
                            type: 'string',
                            required: true,
                            description: 'Tray icon asset path or name',
                        },
                    ],
                    children: [],
                },
            ],
        },
    ];
}
//# sourceMappingURL=desktop-contract.js.map