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 how the main conversation content is rendered
// Look around "ConversationView" component
console.log('=== ConversationView component ===');
let idx = content.indexOf('ConversationView');
if (idx >= 0) {
    console.log(content.substring(Math.max(0, idx - 300), idx + 1500));
}

// 2. Find the PlannerResponse rendering (this is the AI text response)
console.log('\n\n=== PLANNER_RESPONSE rendering ===');
idx = content.indexOf('PLANNER_RESPONSE');
while (idx >= 0 && idx < content.length) {
    const ctx = content.substring(Math.max(0, idx - 200), idx + 500);
    if (ctx.includes('case') || ctx.includes('render') || ctx.includes('className')) {
        console.log(`\n--- @${idx} ---`);
        console.log(ctx.substring(0, 700));
    }
    idx = content.indexOf('PLANNER_RESPONSE', idx + 16);
}

// 3. Find plannerResponse rendering
console.log('\n\n=== "plannerResponse" patterns ===');
for (const pat of ['plannerResponse', 'planner_response', 'PlannerResponse']) {
    let pos = 0;
    let c = 0;
    while ((pos = content.indexOf(pat, pos)) >= 0 && c < 3) {
        console.log(`\n--- "${pat}" @${pos} ---`);
        console.log(content.substring(Math.max(0, pos - 200), pos + 400).substring(0, 600));
        pos += pat.length;
        c++;
    }
}

// 4. Find step.case rendering logic (how each step type renders)
console.log('\n\n=== step.case rendering logic ===');
idx = content.indexOf('step.case');
let cnt = 0;
while (idx >= 0 && cnt < 5) {
    const ctx = content.substring(Math.max(0, idx - 100), idx + 300);
    console.log(`\n--- step.case @${idx} ---`);
    console.log(ctx.substring(0, 400));
    idx = content.indexOf('step.case', idx + 9);
    cnt++;
}

// 5. Find the MarkdownRenderer usage (how AI text gets rendered)
console.log('\n\n=== MarkdownRenderer usage ===');
idx = content.indexOf('MarkdownRenderer');
cnt = 0;
while (idx >= 0 && cnt < 5) {
    const ctx = content.substring(Math.max(0, idx - 200), idx + 300);
    if (ctx.includes('children') || ctx.includes('content') || ctx.includes('text')) {
        console.log(`\n--- MarkdownRenderer @${idx} ---`);
        console.log(ctx.substring(0, 500));
    }
    idx = content.indexOf('MarkdownRenderer', idx + 16);
    cnt++;
}

// 6. Find what lHr component is (the Allow/Deny dialog)
console.log('\n\n=== lHr component (Allow/Deny dialog) ===');
idx = content.indexOf('lHr');
if (idx >= 0) {
    // Search for its definition
    const defIdx = content.indexOf('function lHr');
    const def2 = content.indexOf('lHr=');
    const targetIdx = defIdx >= 0 ? defIdx : def2;
    if (targetIdx >= 0) {
        console.log(content.substring(targetIdx, targetIdx + 600));
    }
}
