import { getBreakMessage } from './message.js';
import { loadStatus, updateTimer, startTime, setBreakActiveUntil } from './timer.js';
import { drawChart } from './chart.js';

export function setupResetButton() {
  const resetBtn = document.getElementById("resetBtn");
  const messageEl = document.getElementById("message");

  resetBtn.addEventListener("click", () => {
    const now = new Date();
    const seconds = Math.floor((now - startTime) / 1000);

    // Update history
    const history = JSON.parse(localStorage.getItem("victorytimer_history") || "[]");
    history.push(seconds);
    localStorage.setItem("victorytimer_history", JSON.stringify(history));

    // Reset start time
    localStorage.setItem("victorytimer_start", now.toISOString());

    // Break-Text setzen
    messageEl.textContent = getBreakMessage(seconds);
    setBreakActiveUntil(Date.now() + 3000);

    loadStatus();
    updateTimer();
    drawChart();
  });
}

