import fs from 'fs';

const files = [
    'src/app/(public)/konten/kinetik/kinetik-client.tsx',
    'src/app/(public)/konten/bearr/bearr-client.tsx',
    'src/app/(public)/konten/link-shortener/page.tsx',
];

files.forEach(file => {
    if (!fs.existsSync(file)) return;
    let content = fs.readFileSync(file, 'utf-8');

    // Remove overlapping duplicated replace from previous script
    content = content.replace(/bg-white\/5 backdrop-blur-md border border-white\/10\/10/g, 'bg-white/5 backdrop-blur-md border border-white/10');
    content = content.replace(/border border-white\/10 shadow-lg border border-gray-100\/80/g, 'border border-white/10 shadow-lg');
    content = content.replace(/bg-gray-100\/50/g, 'bg-white/5');
    content = content.replace(/text-blue-700/g, 'text-blue-400');
    content = content.replace(/hover:text-gray-700/g, 'hover:text-white');
    content = content.replace(/border-gray-100\/80/g, 'border-white/10');
    content = content.replace(/border-gray-100/g, 'border-white/10');
    content = content.replace(/border-slate-100/g, 'border-white/10');
    content = content.replace(/text-blue-800/g, 'text-blue-300');
    content = content.replace(/bg-blue-50 /g, 'bg-blue-500/10 ');
    content = content.replace(/bg-blue-50/g, 'bg-blue-500/10');
    content = content.replace(/text-blue-600/g, 'text-blue-400');
    content = content.replace(/border-blue-200/g, 'border-blue-500/20');
    content = content.replace(/bg-red-50/g, 'bg-red-500/10');
    content = content.replace(/text-red-600/g, 'text-red-400');
    content = content.replace(/text-emerald-700/g, 'text-emerald-400');
    content = content.replace(/bg-emerald-50/g, 'bg-emerald-500/10');
    content = content.replace(/border-emerald-200/g, 'border-emerald-500/20');
    
    // For background patterns to ensure consistency
    if (content.includes('bg-[#07090f]') && !content.includes('grainy-gradients')) {
        const pattern = `
            {/* Background elements */}
            <div className="fixed inset-0 z-0 pointer-events-none">
            </div>

            {/* Grid Pattern Background */}
            <div className="fixed inset-0 bg-[url('https://grainy-gradients.vercel.app/noise.svg')] opacity-20 pointer-events-none z-0 mix-blend-overlay"></div>
            <div className="fixed inset-0 bg-[linear-gradient(to_right,#80808012_1px,transparent_1px),linear-gradient(to_bottom,#80808012_1px,transparent_1px)] bg-[size:24px_24px] z-0"></div>
`;
        content = content.replace(/<div className="min-h-screen bg-\[#07090f\].*?">/, `$&${pattern}`);
    }

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