const fs = require('fs');
const bundlePath = String.raw`C:\Users\Variet-Worker\AppData\Local\Programs\Antigravity\resources\app\out\jetskiAgent\main.js`;
const content = fs.readFileSync(bundlePath, 'utf-8');

// 1. Find Put component definition (trajectory step list renderer)
console.log('=== Put component definition ===');
let idx = content.indexOf('Put=');
// There might be many "Put=", find the one related to trajectory
let pos = 0;
let found = false;
while ((pos = content.indexOf('Put=', pos)) >= 0) {
    const ctx = content.substring(pos, pos + 200);
    if (ctx.includes('trajectory') || ctx.includes('steps') || ctx.includes('Step') || ctx.includes('queue')) {
        console.log(`@${pos}: ${ctx}`);
        console.log('\nFull definition:');
        console.log(content.substring(pos, pos + 2000));
        found = true;
        break;
    }
    pos += 4;
}
if (!found) {
    // Try function Put
    idx = content.indexOf('function Put');
    if (idx >= 0) {
        console.log(content.substring(idx, idx + 2000));
    }
}

// 2. Find the individual step rendering — how each step case maps to a renderer
console.log('\n\n=== Step case renderer mapping (near Whi) ===');
// The object that maps step cases to renderers
idx = content.indexOf('plannerResponse:{isRendered');
if (idx >= 0) {
    // Go back to find the start of this mapping object
    const start = Math.max(0, idx - 3000);
    const section = content.substring(start, idx + 500);
    // Find the start of the mapping
    const mapStart = section.lastIndexOf('{');
    // Actually, let's get the whole renderer map
    const bigStart = Math.max(0, idx - 4000);
    console.log(content.substring(bigStart, idx + 800));
}

// 3. Find <a> (markdown renderer) and how it renders children
console.log('\n\n=== Markdown "a" component (renders AI text) ===');
// From Whi, we know it uses n.markdown which is {a}
// The key line is: v(a,{animate:t!==la.DONE,children:e.modifiedResponse})
// So `a` is the markdown renderer and children is the text
// Let's find what CSS classes the markdown renderer uses
for (const pat of ['prose ', 'markdown-content', 'text-ide-text-color', 'prose-a:', 'text-idle-foreground']) {
    const i = content.indexOf(pat);
    if (i >= 0) {
        const ctx = content.substring(Math.max(0, i - 100), i + 200);
        if (ctx.includes('className')) {
            console.log(`\n--- "${pat}" @${i} ---`);
            console.log(ctx.substring(0, 300));
        }
    }
}

// 4. Find the "thinking" component rendering (Klt)
console.log('\n\n=== Klt (thinking component) ===');
idx = content.indexOf('Klt=');
if (idx < 0) idx = content.indexOf('function Klt');
if (idx >= 0) {
    console.log(content.substring(idx, idx + 800));
}

// 5. Find the lHr component wrapper classes (Allow/Deny bar)
console.log('\n\n=== lHr surrounding context ===');
idx = content.indexOf('lHr,{');
let cnt = 0;
while (idx >= 0 && cnt < 3) {
    console.log(`\n--- lHr usage @${idx} ---`);
    console.log(content.substring(Math.max(0, idx - 300), idx + 200).substring(0, 500));
    idx = content.indexOf('lHr,{', idx + 5);
    cnt++;
}
