/******/ (() => { // webpackBootstrap
/*!*********************************************!*\
  !*** ./assets/src/blocks/countdown/view.js ***!
  \*********************************************/
document.addEventListener('DOMContentLoaded', () => {
  const timers = document.querySelectorAll('.countdown-timer');
  timers.forEach(el => {
    const target = el.dataset.target;
    if (!target) return;
    const endTime = new Date(target).getTime();
    if (isNaN(endTime)) return;
    const getPartEl = className => el.querySelector(`.countdown-${className} .countdown-value`);
    const update = () => {
      const now = new Date().getTime();
      const distance = endTime - now;
      if (distance <= 0) {
        ['days', 'hours', 'minutes', 'seconds'].forEach(part => {
          const partEl = getPartEl(part);
          if (partEl) partEl.textContent = '00';
        });
        clearInterval(timer);
        return;
      }
      const days = Math.floor(distance / (1000 * 60 * 60 * 24));
      const hours = Math.floor(distance % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
      const minutes = Math.floor(distance % (1000 * 60 * 60) / (1000 * 60));
      const seconds = Math.floor(distance % (1000 * 60) / 1000);
      if (getPartEl('days')) getPartEl('days').textContent = String(days).padStart(2, '0');
      if (getPartEl('hours')) getPartEl('hours').textContent = String(hours).padStart(2, '0');
      if (getPartEl('minutes')) getPartEl('minutes').textContent = String(minutes).padStart(2, '0');
      if (getPartEl('seconds')) getPartEl('seconds').textContent = String(seconds).padStart(2, '0');
    };
    update();
    const timer = setInterval(update, 1000);
  });
});
/******/ })()
;
//# sourceMappingURL=view.js.map