/* eslint-disable */
// @ts-nocheck
import fs from 'fs';

const filePath = 'C:/X/workspace/jumpa.id/vc/lib/xcu-quantum-decoder.ts';
let content = fs.readFileSync(filePath, 'utf-8');

// Fix 'any' in decoder and trackProcessor
content = content.replace(/e: any/g, 'e: unknown');
content = content.replace(/catch \(e\)/g, 'catch (_e)');
content = content.replace(/output: \(frame: any\)/g, 'output: (frame: unknown)');
content = content.replace(/output: async \(chunk: any, meta: any\)/g, 'output: async (chunk: unknown, meta: unknown)');
content = content.replace(/let iv = new Uint8Array\(12\);/g, 'const iv = new Uint8Array(12);');
content = content.replace(/const chunk = new \(window as any\).EncodedVideoChunk/g, 'const chunk = new (window as unknown as { EncodedVideoChunk: new(a:unknown)=>unknown }).EncodedVideoChunk');
content = content.replace(/const module = await WebAssembly\.instantiate/g, 'const _module = await WebAssembly.instantiate');
content = content.replace(/const jpegInterval = setInterval/g, 'const _jpegInterval = setInterval');

fs.writeFileSync(filePath, content, 'utf-8');

// Also fix xcuRoom.tsx unused variable
const roomPath = 'C:/X/workspace/jumpa.id/vc/components/xcuRoom.tsx';
let roomContent = fs.readFileSync(roomPath, 'utf-8');
roomContent = roomContent.replace(/const handleTogglePiP = async \(\) => \{[\s\S]*?alert\("Browser Anda tidak mendukung fitur Picture-in-Picture."\);\n      \}\n  \};\n/g, '');
fs.writeFileSync(roomPath, roomContent, 'utf-8');

console.log('Fixed typescript errors');
