(function(){const SELECTOR=".cs-announcement-timer",INIT_ATTR="data-timer-initialized",pad=n=>n<10?"0"+n:""+n,decompose=ms=>{if(ms<=0)return null;const total=Math.floor(ms/1e3),d=Math.floor(total/86400),h=Math.floor(total%86400/3600),m=Math.floor(total%3600/60),s=total%60;return{d,h,m,s}};function initOne(el){if(el.getAttribute(INIT_ATTR)==="1")return;const endStr=el.getAttribute("data-timer-end"),startStr=el.getAttribute("data-timer-start"),cont=String(el.getAttribute("data-timer-continue"))==="true",valueEl=el.querySelector(".cs-announcement-timer__value");if(!endStr||!valueEl)return;const rawD=el.getAttribute("data-label-d")||"",rawH=el.getAttribute("data-label-h")||"",rawM=el.getAttribute("data-label-m")||"",rawS=el.getAttribute("data-label-s")||"",L={d:typeof rawD=="string"?rawD.trim():"",h:typeof rawH=="string"?rawH.trim():"",m:typeof rawM=="string"?rawM.trim():"",s:typeof rawS=="string"?rawS.trim():""},end=new Date(endStr).getTime();if(startStr&&!cont){const start=new Date(startStr).getTime();if(Date.now(){const p=decompose(ms);if(!p)return null;const parts=[];return p.d>0&&parts.push(p.d+L.d),parts.push(pad(p.h)+L.h),parts.push(pad(p.m)+L.m),parts.push(pad(p.s)+L.s),parts.join(" ")},tick=()=>{const left=end-Date.now(),out=formatLabeled(left);if(!out){el.style.display="none";return}valueEl.textContent=out};tick();const id=setInterval(()=>{if(!document.body.contains(el))return clearInterval(id);tick()},1e3);el.setAttribute(INIT_ATTR,"1")}function initAll(){document.querySelectorAll(SELECTOR).forEach(initOne)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initAll):initAll(),window.addEventListener("load",initAll),document.addEventListener("shopify:section:load",initAll),document.addEventListener("shopify:section:unload",initAll),setTimeout(initAll,0),setTimeout(initAll,500),setTimeout(initAll,1500)})(); //# sourceMappingURL=/cdn/shop/t/1716/assets/announcement-countdown.js.map?v=26974144306032382131761551788