(function (root, factory) { if (typeof module === 'object' && module.exports) module.exports = factory; else root.createMobileStartDay = factory; })(typeof self !== 'undefined' ? self : this, function createMobileStartDay(options) { const reviewOrder = [ ['agenda', 'Agenda'], ['attention', 'Attention'], ['update', 'Updates'], ['filed', 'Filed'], ]; function count(value) { return Math.max(0, Number(value) || 0); } function briefing() { const counts = options.getCounts ? options.getCounts() : {}; const phases = reviewOrder .map(([name, label]) => ({name, label, count: count(counts[name])})) .filter(phase => phase.count > 0); const total = phases.reduce((sum, phase) => sum + phase.count, 0); const today = count(counts.today); const next = phases.length ? phases[0].name : (today ? 'today' : 'find'); const nextLabel = phases.length ? 'Review ' + phases[0].label : (today ? 'Continue Today' : 'Find Work'); return { total, next, label: nextLabel, summary: total ? total + ' items before Today · ' + today + ' planned' : (today ? 'Review clear · ' + today + ' planned' : 'Review clear · Today is empty'), phases, }; } function startNext() { const next = briefing().next; options.openQueue(next); return next; } function render() { const current = briefing(); if (!options.elements) return current; options.elements.summary.textContent = current.summary; options.elements.phases.textContent = current.phases.length ? current.phases.map(phase => phase.label + ' ' + phase.count).join(' · ') : 'All urgent queues reviewed'; options.elements.action.textContent = current.label; return current; } function start() { render(); if (options.elements) options.elements.action.addEventListener('click', startNext); } return {briefing, render, start, startNext}; });