<?php
$file = 'assets/js/app.js';
$content = file_get_contents($file);

// Map of corrupted byte sequences to correct emojis
$replacements = [
    // Already done - Toast icons
    chr(0xC3).chr(0xA2).chr(0xC5).chr(0x93).chr(0xE2).chr(0x80).chr(0x9C) => '✓',
    chr(0xC3).chr(0xA2).chr(0xC5).chr(0x93).chr(0xE2).chr(0x80).chr(0xA2) => '✕',
    
    // Popup icons that still need fixing
    chr(0xC3).chr(0xB0).chr(0xC5).chr(0xB8).chr(0xE2).chr(0x80).chr(0x9C).chr(0xC2).chr(0x8D) => '📍',  // ðŸ"
    chr(0xC3).chr(0xB0).chr(0xC5).chr(0xB8).chr(0xE2).chr(0x80).chr(0xBA).chr(0xC2).chr(0xA3).chr(0xC3).chr(0xAF).chr(0xC2).chr(0xB8).chr(0xC2).chr(0x8F) => '🛣️',  // ðŸ›£ï¸
    chr(0xC3).chr(0xA2).chr(0xE2).chr(0x80).chr(0xAC).chr(0xC2).chr(0xA0) => '⬜',  // â¬ 
    chr(0xC3).chr(0xB0).chr(0xC5).chr(0xB8).chr(0xE2).chr(0x80).chr(0x95).chr(0xC2).chr(0x8C) => '🏢',  // ðŸ•Œ
    chr(0xC3).chr(0xB0).chr(0xC5).chr(0xB8).chr(0xE2).chr(0x80).chr(0x91).chr(0xC2).chr(0xA4) => '👥',  // ðŸ'¤
    chr(0xC3).chr(0xB0).chr(0xC5).chr(0xB8).chr(0xE2).chr(0x80).chr(0x97).chr(0xC2).chr(0x91) => '🗑️',  // ðŸ—'
    chr(0xC3).chr(0xA2).chr(0xC2).chr(0x9A).chr(0xA0) => '⚠',  // âš 
    chr(0xC3).chr(0xA2).chr(0xE2).chr(0x80).chr(0x9E).chr(0xC2).chr(0xB9) => 'ⓘ',  // â„¹
];

foreach ($replacements as $old => $new) {
    $count = 0;
    $content = str_replace($old, $new, $content, $count);
    if ($count > 0) {
        echo "✓ Replaced → '$new' ($count times)\n";
    }
}

file_put_contents($file, $content);
echo "\n✓✓ File app.js sudah diperbaiki sepenuhnya!\n";
?>
