'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { DeploymentState } from '../../../../../../packages/core/src/domain/generated/output.js';
import { cn } from '../../../lib/utils.js';
import { TerminalTab } from '../../features/application-page/terminal-tab.js';
import { IdeTab } from '../../features/application-page/ide-tab/index.js';
import { WebPreviewTab } from '../../features/application-page/web-preview-tab.js';
/**
 * Right-pane view body.
 *
 * The Terminal tab is kept mounted (just hidden) when not active so its
 * PTY session, scrollback, and running processes survive tab switches.
 * Other views are placeholders until implemented.
 */
export function ViewBody({ activeView, applicationId, terminalCwd, deploy, isBuilding = false, }) {
    // Mount the Web iframe as soon as there's a URL — even if the user
    // is currently on IDE / Terminal — so the preview session doesn't
    // tear down when switching tabs. Once the app has been Previewed
    // at least once, the iframe stays alive in the background.
    //
    // While the app is still being built we also want the WebPreviewTab
    // mounted so its "Building your app…" stub renders — treat `isBuilding`
    // as meaningful deploy state for mount purposes.
    const hasWebContent = deploy.status === DeploymentState.Ready ||
        deploy.status === DeploymentState.Booting ||
        deploy.deployLoading ||
        !!deploy.deployError ||
        isBuilding;
    return (_jsxs("div", { className: "relative flex min-h-0 flex-1", children: [_jsx("div", { className: cn('absolute inset-0 flex min-h-0 flex-col', activeView === 'terminal' ? 'visible' : 'pointer-events-none invisible'), "aria-hidden": activeView !== 'terminal', children: _jsx(TerminalTab, { cwd: terminalCwd }) }), _jsx("div", { className: cn('absolute inset-0 flex min-h-0 flex-col', activeView === 'ide' ? 'visible' : 'pointer-events-none invisible'), "aria-hidden": activeView !== 'ide', children: _jsx(IdeTab, { applicationId: applicationId }) }), hasWebContent ? (_jsx("div", { className: cn('absolute inset-0 flex min-h-0 flex-col', activeView === 'web' ? 'visible' : 'pointer-events-none invisible'), "aria-hidden": activeView !== 'web', children: _jsx(WebPreviewTab, { deploy: deploy, isBuilding: isBuilding }) })) : (activeView === 'web' && _jsx(WebPreviewTab, { deploy: deploy, isBuilding: isBuilding }))] }));
}
