// Pilot deadline — single source of truth.
// Pinned to a date (June 1, 2026) so urgency is concrete, not generic.
// When the date passes, you can edit this one constant and the whole site updates.
const PILOT_DEADLINE = new Date("2026-06-01T23:59:59+07:00"); // Bangkok time
const PILOT_TOTAL_SLOTS = 500;
const PILOT_CLAIMED = 153;
const PILOT_PRICE_AFTER = 1290; // post-pilot lowest monthly equivalent

function usePilotCountdown() {
  const [now, setNow] = React.useState(() => new Date());
  React.useEffect(() => {
    const id = setInterval(() => setNow(new Date()), 60 * 1000); // tick every minute
    return () => clearInterval(id);
  }, []);
  const ms = PILOT_DEADLINE.getTime() - now.getTime();
  const totalMin = Math.max(0, Math.floor(ms / 60000));
  const days = Math.floor(totalMin / (60 * 24));
  const hours = Math.floor((totalMin % (60 * 24)) / 60);
  const passed = ms <= 0;
  const dateLabel = PILOT_DEADLINE.toLocaleDateString("en-GB", {
    day: "numeric", month: "long", year: "numeric",
  });
  const shortLabel = PILOT_DEADLINE.toLocaleDateString("en-GB", {
    day: "numeric", month: "short",
  });
  return { days, hours, passed, dateLabel, shortLabel, claimed: PILOT_CLAIMED, total: PILOT_TOTAL_SLOTS, priceAfter: PILOT_PRICE_AFTER };
}

Object.assign(window, { PILOT_DEADLINE, PILOT_TOTAL_SLOTS, PILOT_CLAIMED, PILOT_PRICE_AFTER, usePilotCountdown });
