const fs = require('fs');
let html = fs.readFileSync('d:/Easy ERP/ready_mix.html', 'utf8');

// Remove pumps tab
html = html.replace(/<a href="#" class="nav-link" onclick="window\.RMApp\.switchTab\('pumps', this\)">[\s\S]*?<\/a>/, '');

// Remove equipments tab
html = html.replace(/<a href="#" class="nav-link" onclick="window\.RMApp\.switchTab\('equipments', this\)">[\s\S]*?<\/a>/, '');

// Removing views and modals can be tricky with simple regex if there are nested divs. 
// A safer way is to just set display:none !important on the tabs and hide them from the user, 
// OR just leave the HTML elements but they are never shown because the tabs are removed.
// Since the user said "تحذف صفحة البامبات والمعدات", removing the tabs is effectively deleting the pages from the user's view.
// But to be thorough, I will remove the specific sections.

// It's safer to just remove the tabs and let the views remain hidden in DOM since they won't cause harm and removing nested divs with regex is error-prone.
// Let's also remove 'pumps' and 'equipments' from ready_mix.js so they aren't loaded or rendered.
fs.writeFileSync('d:/Easy ERP/ready_mix.html', html, 'utf8');
console.log("ready_mix.html tabs removed");

let js = fs.readFileSync('d:/Easy ERP/ready_mix.js', 'utf8');
// Remove pumps and equipments logic where they render
js = js.replace(/window\.RMApp\.renderPumpsTable = function\(\) \{[\s\S]*?\}\;/g, 'window.RMApp.renderPumpsTable = function() {};');
js = js.replace(/window\.RMApp\.renderEquipmentsTable = function\(\) \{[\s\S]*?\}\;/g, 'window.RMApp.renderEquipmentsTable = function() {};');
fs.writeFileSync('d:/Easy ERP/ready_mix.js', js, 'utf8');
console.log("ready_mix.js updated");
