// Hatchway CLI - Built with Rollup
import { execSync } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { j as jsxRuntimeExports, B as Box, T as Text, c as colors } from './theme-NAQBkisB.js';
import 'node:stream';
import 'node:process';
import 'chalk';
import 'node:events';

/**
 * Version and git commit info utilities
 */
const __filename$1 = fileURLToPath(import.meta.url);
const __dirname$1 = dirname(__filename$1);
/**
 * Find the package root directory (apps/runner).
 * Works in both development (src/cli/utils/) and production (dist/cli/utils/) modes.
 */
function findPackageRoot() {
    // Try multiple possible locations
    const possiblePaths = [
        // Development: src/cli/utils/ -> apps/runner (3 levels up)
        join(__dirname$1, '..', '..', '..'),
        // Production from dist/cli/utils/: -> apps/runner (3 levels up, same structure)
        join(__dirname$1, '..', '..', '..'),
    ];
    for (const path of possiblePaths) {
        const packageJsonPath = join(path, 'package.json');
        if (existsSync(packageJsonPath)) {
            try {
                const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
                // Verify this is the runner package
                if (pkg.name === '@hatchway/cli') {
                    return path;
                }
            }
            catch {
                // Continue to next path
            }
        }
    }
    // Fallback to the standard path
    return join(__dirname$1, '..', '..', '..');
}
// Cache the package root
const packageRoot = findPackageRoot();
/**
 * Get the package version from package.json
 */
function getPackageVersion() {
    try {
        const packageJsonPath = join(packageRoot, 'package.json');
        if (existsSync(packageJsonPath)) {
            const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
            return packageJson.version || '0.0.0';
        }
    }
    catch {
        // Ignore errors
    }
    return '0.0.0';
}
/**
 * Get the short git commit hash
 */
function getGitCommit() {
    try {
        // Try to get commit from git command
        const commit = execSync('git rev-parse --short HEAD', {
            cwd: packageRoot,
            encoding: 'utf-8',
            stdio: ['pipe', 'pipe', 'pipe'],
        }).trim();
        return commit || null;
    }
    catch {
        // Git not available or not a git repo
        return null;
    }
}
/**
 * Get all version info
 */
function getVersionInfo() {
    const version = getPackageVersion();
    const commit = getGitCommit();
    return {
        version,
        commit,
        display: commit ? `v${version} (${commit})` : `v${version}`,
    };
}

/**
 * ASCII art banner component - centered with cyan/purple gradient
 * Each line is padded to exactly the same width for perfect alignment
 */
function Banner() {
    // Full banner lines - HATCH in cyan, WAY in purple
    // All lines padded to same total width for consistent centering
    const lines = [
        { hatch: '██╗  ██╗ █████╗ ████████╗ ██████╗██╗  ██╗', way: '██╗    ██╗ █████╗ ██╗   ██╗' },
        { hatch: '██║  ██║██╔══██╗╚══██╔══╝██╔════╝██║  ██║', way: '██║    ██║██╔══██╗╚██╗ ██╔╝' },
        { hatch: '███████║███████║   ██║   ██║     ███████║', way: '██║ █╗ ██║███████║ ╚████╔╝ ' },
        { hatch: '██╔══██║██╔══██║   ██║   ██║     ██╔══██║', way: '██║███╗██║██╔══██║  ╚██╔╝  ' },
        { hatch: '██║  ██║██║  ██║   ██║   ╚██████╗██║  ██║', way: '╚███╔███╔╝██║  ██║   ██║   ' },
        { hatch: '╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝    ╚═════╝╚═╝  ╚═╝', way: ' ╚══╝╚══╝ ╚═╝  ╚═╝   ╚═╝   ' },
    ];
    return (jsxRuntimeExports.jsx(Box, { flexDirection: "column", alignItems: "center", children: lines.map((line, index) => (jsxRuntimeExports.jsxs(Box, { children: [jsxRuntimeExports.jsx(Text, { color: colors.cyan, children: line.hatch }), jsxRuntimeExports.jsx(Text, { color: colors.brightPurple, children: line.way })] }, index))) }));
}

export { Banner as B, getVersionInfo as g };
//# sourceMappingURL=Banner-DL1Fpz_g.js.map
