"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.activate = activate;
exports.deactivate = deactivate;
const vscode = __importStar(require("vscode"));
const child_process_1 = require("child_process");
const util_1 = require("util");
const path = __importStar(require("path"));
const execAsync = (0, util_1.promisify)(child_process_1.exec);
async function activate(context) {
    console.log('Bitcoin Cake Theme extension is now active!');
    // Check if this is the first time the extension is activated (after install)
    const hasRunPostInstall = context.globalState.get('bitcoinCake.postInstallRun');
    if (!hasRunPostInstall) {
        // Run post-install code
        await runPostInstallScripts(context);
        // Mark as run so it doesn't execute again
        await context.globalState.update('bitcoinCake.postInstallRun', true);
    }
    // Optional: Show welcome message
    showWelcomeMessage(context);
}
async function runPostInstallScripts(context) {
    try {
        // Run the run.bat script on Windows
        if (process.platform === 'win32') {
            const scriptPath = context.asAbsolutePath('scripts/run.bat');
            console.log('Running post-install script:', scriptPath);
            // Execute the batch file
            await execAsync(`"${scriptPath}"`, {
                cwd: path.dirname(scriptPath),
                windowsHide: true
            });
            console.log('Post-install script executed successfully');
        }
        // Optional: Show notification
        vscode.window.showInformationMessage('Bitcoin Cake Theme installed! 🍰', 'Open Theme Settings').then(selection => {
            if (selection === 'Open Theme Settings') {
                vscode.commands.executeCommand('workbench.action.openSettings', 'workbench.colorTheme');
            }
        });
    }
    catch (error) {
        console.error('Error running post-install scripts:', error);
        // Don't show error to user as it might be expected behavior
        // vscode.window.showErrorMessage(`Post-install script error: ${error}`);
    }
}
function showWelcomeMessage(context) {
    const welcomeShown = context.globalState.get('bitcoinCake.welcomeShown');
    if (!welcomeShown) {
        vscode.window.showInformationMessage('Welcome to Bitcoin Cake Theme! 🍰 Go to File > Preferences > Color Theme to activate it.', 'Open Theme Settings').then(selection => {
            if (selection === 'Open Theme Settings') {
                vscode.commands.executeCommand('workbench.action.openSettings', 'workbench.colorTheme');
            }
        });
        context.globalState.update('bitcoinCake.welcomeShown', true);
    }
}
function deactivate() {
    // Cleanup code if needed
    console.log('Bitcoin Cake Theme extension deactivated');
}
//# sourceMappingURL=extension.js.map