let localStorageAvailable;function initializeNewCounter(e){let t=buildEndDate(e),i;i=setInterval(()=>showRemaining(e,t,()=>clearInterval(i)),1e3)}function showRemaining(e,t,i){let a=new Date,r=t-a,n,l,o,$,g=36e5,c=24*g;r<0&&(i(),n=0,l=0,o=0,$=0),r>=0&&(n=Math.floor(r/c),l=Math.floor(r%c/g),o=Math.floor(r%g/6e4),$=Math.floor(r%6e4/1e3)),e.querySelectorAll(".widget-text[data-format]").forEach(function(e){e.textContent=calculateWidgetValue(e,n,l,o,$)})}function calculateWidgetValue(e,t,i,a,r){return t>99&&"%dd"===e.getAttribute("data-format")&&e.setAttribute("data-format","%ddd"),e.getAttribute("data-format").replace("%ddd",("00"+t).slice(-3)).replace("%dd",("0"+t).slice(-2)).replace("%d",t).replace("%hh",("0"+i).slice(-2)).replace("%mm",("0"+a).slice(-2)).replace("%ss",("0"+r).slice(-2)).replace("%h",i).replace("%m",a).replace("%s",r)}function buildEndDate(e){let t=e.getAttribute("data-strategy"),i="1"===e.getAttribute("data-full-js"),a=new Date;if("evergreen_counter"===t){let{days:r=0,hours:n=0,minutes:l=0,seconds:o=0}=getParsedAttribute(e,"data-intervals");a.setTime(a.getTime()+864e5*r),a.setTime(a.getTime()+36e5*n),a.setTime(a.getTime()+6e4*l),a.setTime(a.getTime()+1e3*o)}else if(i&&"repeat_every_week"===t){let $=parseInt(e.getAttribute("data-week-cycle-start-day-of-week")),g=parseInt(e.getAttribute("data-week-cycle-end-day-of-week")),c=e.getAttribute("data-week-cycle-start-time"),u=parseInt(c.split(":")[0]),s=parseInt(c.split(":")[1]),d=e.getAttribute("data-week-cycle-end-time"),m=parseInt(d.split(":")[0]),f=parseInt(d.split(":")[1]),w=e.getAttribute("data-timezone");7===$&&($=0),7===g&&(g=0);let T;T=w?new Date(new Date().toLocaleString("en-US",{timeZone:w})):new Date;let p=Math.round((new Date().getTime()-T.getTime())/1e3/60),A=T.getDay(),b=new Date(T.getTime());b.setHours(u,s,0,0),b.setDate(b.getDate()+($-A)),(a=new Date(T.getTime())).setHours(m,f,0,0),a.setDate(a.getDate()+(g-A));let y=b.getTime()>T.getTime(),S=function(e){return e.setMinutes(e.getMinutes()+p),new Date(e.getTime())};return $b.getTime()&&a.setTime(a.getTime()-6048e5),S(a)):(a.getTime()E.getHours()||x===E.getHours()&&L>E.getMinutes())return a;a.setHours(M,C,0,0)}return a.setMinutes(a.getMinutes()+h),new Date(a.getTime())}else{let I=e.getAttribute("data-date");a=new Date(I)}if("evergreen_counter"===t){let H=e.getAttribute("id"),R=getEndDateFromLocalStorage(e),O=getEndDateFromCookies(e);window&&window.location&&!window.location.href.includes("editor.landingi")&&(R?a=R:O?a=O:saveEndDate(a,H))}return a}function isLocalStorageAvailable(){let e,t="__storage_test__";if(void 0!==localStorageAvailable)return localStorageAvailable;try{if(!window||!window.localStorage)return!1}catch{return!1}try{return(e=window.localStorage).setItem(t,t),e.removeItem(t),!0}catch(i){return i instanceof DOMException&&([22,1014].includes(i.code)||["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"].includes(i.name))&&e&&0!==e.length}}function getEndDateFromCookies(e){let t=e.getAttribute("id"),i=document.cookie?document.cookie.split(";"):[],a={};for(let r in i)if(i.hasOwnProperty(r)&&"string"==typeof r){let n=i[r].split("=");a[n[0].replace(/\s/g,"")]=n[1]}return a[`count-${t}`]?new Date(a[`count-${t}`]):null}function getEndDateFromLocalStorage(e){if(isLocalStorageAvailable()){let t=e.getAttribute("id"),i=window.localStorage.getItem(`count-${t}`);if(i)try{let a=JSON.parse(i);if(!localStorageIsExpired(a))return new Date(a.value);window.localStorage.removeItem(`count-${t}`)}catch(r){}}return null}function localStorageIsExpired(e){if(!e.value||!e.expires)return!0;let t=new Date,i=new Date(e.expires);return t.getTime()>i.getTime()}function saveEndDate(e,t){let i=new Date;if(i.setMonth(i.getMonth()+1),isLocalStorageAvailable()){let a={value:e.getTime(),expires:new Date(i).getTime()};window.localStorage.setItem(`count-${t}`,JSON.stringify(a));return}document.cookie=`count-${t}=${e};expires=${new Date(i)};path=${window.location.pathname}`}function getParsedAttribute(e,t){let i=e.getAttribute(t);return i?JSON.parse(i):{}}document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".widget-counterv2").forEach(e=>initializeNewCounter(e))});