/* /friday status strip (Marty, 2026-09-25). External file on purpose: the site's CSP blocks
inline scripts, which is how the first deploy shipped a strip stuck on "Checking". */
(function () {
var el = document.getElementById('frState');
if (!el) return;
function n(x) { return Number(x || 0).toLocaleString('en-US'); }
// the minute (Central) when the next Friday starts, found by scanning rather than assumed,
// so a daylight-saving change cannot put the countdown an hour out
function startsAt(dayKey) {
var now = Date.now();
for (var m = 0; m < 8 * 1440; m++) {
var t = now + m * 60000;
var d = new Date(t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
if (d === dayKey) return t;
}
return null;
}
function render(f) {
if (!f || !f.on) { el.innerHTML = 'PausedFive Dollar Friday is not running right now. Join free and you will hear when it is back.'; return; }
if (f.live) {
var t = f.today || {};
el.className = 'fr-state live';
el.innerHTML = 'Live nowIt is Five Dollar Friday. Bonus runs until midnight Central.'
+ '' + n(t.packs) + ' pack' + (t.packs === 1 ? '' : 's') + ' so far today'
+ '' + n(t.bonusCredits) + ' bonus credits issued';
return;
}
var at = f.nextFriday ? startsAt(f.nextFriday) : null;
var left = at ? Math.max(0, at - Date.now()) : 0;
var hrs = Math.floor(left / 3600000), mins = Math.floor((left % 3600000) / 60000), days = Math.floor(hrs / 24);
var when = at ? (days >= 1 ? days + ' day' + (days === 1 ? '' : 's') + ' ' + (hrs % 24) + 'h' : hrs + 'h ' + mins + 'm') : '';
el.className = 'fr-state';
el.innerHTML = 'NextNext Five Dollar Friday: ' + (f.nextLabel || f.nextFriday || 'soon') + '. Starts at midnight Central' + (when ? ', in ' + when : '') + '.'
+ 'Join now so your account is ready before it starts.';
}
fetch('/api/friday').then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; }).then(render);
})();