// Force a specific mitra OFFLINE via the dev-only
// /internal/_test/force-mitra-offline endpoint. Used by Maestro flows that
// need the bestie-history-list row for a particular mitra to render in its
// offline (dimmed) state — see TS-02 / TS-03 in
// requirement/phase4-customer-flow.md.
//
// Reads MITRA_ID from env (typically `${output.MITRA_ID}` from a prior
// seed_history_session.js run) and BACKEND_INTERNAL_URL.
const mitraId = MITRA_ID
const url = BACKEND_INTERNAL_URL || 'http://localhost:3001'
if (!mitraId) {
  throw new Error('MITRA_ID env not set — pass output.MITRA_ID from seed_history_session.js')
}
const resp = http.post(`${url}/internal/_test/force-mitra-offline`, {
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ mitra_id: mitraId }),
})
if (resp.status !== 200) {
  throw new Error(`force-mitra-offline failed (${resp.status}): ${resp.body}`)
}
