export function showCountryModal(countryData) { document.getElementById("country-modal-title").textContent = countryData.country; document.getElementById("country-modal-body").innerHTML = `
Prison Population: ${_fmt(countryData.pop, "pop")}
Rate per 100,000 Citizens: ${_fmt(countryData.rate, "rate")}
Females: ${_fmt(countryData.females, "pct")}
Juveniles: ${_fmt(countryData.juveniles, "pct")}
Occupancy: ${_fmt(countryData.occupancy, "pct")}
Government: ${_fmtGov(countryData.government)}
`; const el = document.getElementById("countryModal"); (bootstrap.Modal.getInstance(el) || new bootstrap.Modal(el)).show(); } function _fmt(val, type) { if (val === "--" || val === null || val === undefined || (typeof val === "number" && isNaN(val))) { return "Information not available."; } if (type === "pop") return Number(val).toLocaleString("en"); if (type === "rate") return String(val); if (type === "pct") return (val * 100).toFixed(2) + " %"; return String(val); } function _fmtGov(val) { return (!val || val === "--") ? "Information not available." : val; }