const fs = require('fs');
let html = fs.readFileSync('index.html', 'utf8');

const anchor = 'id="purchases-returns-project"></select></div>';
const injection = `
          <div class="flex-col"><label>الخزينة</label><select id="purchases-returns-treasury"></select></div>
          <div class="flex-col"><label>الإجمالي</label><input type="number" id="purchases-returns-total" readonly></div>
          <div class="flex-col"><label>ملاحظات</label><input type="text" id="purchases-returns-notes"></div>`;

if (html.includes(anchor) && !html.includes('id="purchases-returns-total"')) {
    html = html.replace(anchor, anchor + injection);
    html = html.replace(/v=\d+/g, 'v=' + Date.now());
    fs.writeFileSync('index.html', html, 'utf8');
    console.log('Purchases HTML patched successfully!');
} else {
    console.log('Anchor not found or already patched.');
}
