);
}
function BurstLauncher() {
const { state, startBurst, pauseBurst, tickBurst, closeBurst, toggleTask, setBurstLength } = useStore();
const b = state.burst;
// tick the timer when running (header is always mounted, so this is the
// single source of truth for the timer regardless of which view you're in)
React.useEffect(() => {
if (!b.running) return;
const id = setInterval(tickBurst, 1000);
return () => clearInterval(id);
}, [b.running, tickBurst]);
// find the active task, or the next suggested one if idle
let priority = state.priorities.find((p) => p.id === b.priorityId);
let task = priority?.tasks.find((t) => t.id === b.taskId);
if (!b.active || !task) {
for (const p of state.priorities) {
for (const t of p.tasks) { if (!t.done) { priority = p; task = t; break; } }
if (task) break;
}
}
const startNext = () => {
if (priority && task) startBurst(priority.id, task.id, b.length);
};
const mins = Math.floor(b.remaining / 60);
const secs = b.remaining % 60;
const showSecs = b.active && b.running;
const time = b.active
? `${String(mins).padStart(2, '0')}:${String(secs).padStart(2, '0')}`
: `${b.length / 60}:00`;
const pct = b.length > 0 && b.active ? 1 - b.remaining / b.length : 0;
const r = 11;
const C = 2 * Math.PI * r;
const finished = b.active && b.remaining === 0;
const openFullscreen = () => {
// surface the fullscreen takeover by activating it (if not already)
if (b.active) return; // already active — overlay's already there in Desktop
startNext();
};
return (