const fs = require('fs');
const filePath = 'dist/assets/index-D9sWWWv_.js.bak-before-owner-mode-fix';
if (!fs.existsSync(filePath)) {
  console.error("Backup file not found!");
  process.exit(1);
}
const content = fs.readFileSync(filePath, 'utf8');

const targets = [
  '[ft,Is]=C.useState({name:"",duration:"5 Hours",price:5e3,speedLimit:"3Mbps/3Mbps"})',
  'C.useEffect(()=>{sr&&Is({name:sr.name,duration:sr.duration==="Unlimited"?"":sr.duration,price:sr.price,speedLimit:sr.speedLimit})},[sr]);',
  'Fi(null),Aa(!1),Is({name:"",duration:"5 Hours",price:5e3,speedLimit:"3Mbps/3Mbps"}),alert("Berhasil menyimpan perubahan profil hotspot!")',
  'Is({name:"",duration:"5 Hours",price:5e3,speedLimit:"3Mbps/3Mbps"}),Aa(!1),W(B=>[{id:`log-${Date.now()}`',
  'onClick:()=>{Fi(null),Aa(!1),Is({name:"",duration:"5 Hours",price:5e3,speedLimit:"3Mbps/3Mbps"})}',
  'const z=await(await fetch("/api/mikrotik/update-hotspot-profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:D.host,port:D.port,user:D.user,pass:D.pass,id:sr.id,name:ft.name,duration:b,price:Number(ft.price),speedLimit:ft.speedLimit})})).json();',
  'Kn(B=>B.map(z=>z.id===sr.id?{...z,name:ft.name,duration:b,price:Number(ft.price),speedLimit:ft.speedLimit}:z))',
  'const z=await(await fetch("/api/mikrotik/add-hotspot-profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({host:D.host,port:D.port,user:D.user,pass:D.pass,name:ft.name,duration:b,price:Number(ft.price),speedLimit:ft.speedLimit})})).json();',
  'else{const B={id:`prof-${Date.now().toString().slice(-4)}`,name:ft.name,duration:b,price:Number(ft.price),speedLimit:ft.speedLimit};Kn(z=>[...z,B])}',
  'a.jsxs("div",{children:[a.jsx("label",{className:"block font-semibold text-gray-400 uppercase tracking-wider mb-2",children:"Batas Kecepatan (Rate-Limit)"}),a.jsx("input",{type:"text",required:!0,placeholder:"e.g. 3Mbps/3Mbps, 5M/5M",value:ft.speedLimit,onChange:p=>Is({...ft,speedLimit:p.target.value}),className:"block w-full px-3 py-2.5 bg-[#0b1220] border border-emerald-950/40 rounded-xl focus:outline-none focus:ring-1 focus:ring-emerald-500 text-gray-200 font-mono"}),a.jsx("span",{className:"text-[10px] text-gray-500 mt-1 block",children:"Format: download/upload (e.g. 1M/1M, 5M/10M)"})]})',
  'a.jsx("th",{className:"p-3",children:"ID Paket"}),a.jsx("th",{className:"p-3",children:"Nama Paket"}),a.jsx("th",{className:"p-3",children:"Masa Aktif"}),a.jsx("th",{className:"p-3",children:"Batas Bandwidth"}),a.jsx("th",{className:"p-3",children:"Harga Jual"}),a.jsx("th",{className:"p-3 text-right",children:"Aksi"})',
  'a.jsx("td",{className:"p-3 font-mono text-gray-500 font-bold",children:p.id}),a.jsx("td",{className:"p-3 font-bold text-gray-200",children:p.name}),a.jsx("td",{className:"p-3 text-gray-400",children:p.duration}),a.jsx("td",{className:"p-3 font-mono text-emerald-400",children:p.speedLimit}),a.jsxs("td",{className:"p-3 font-semibold text-white",children:["Rp ",p.price.toLocaleString()]})'
];

targets.forEach((t, i) => {
  if (content.includes(t)) {
    console.log(`Target #${i + 1} is PRESENT!`);
  } else {
    console.warn(`Target #${i + 1} NOT FOUND!`);
  }
});
