(()=>{"use strict";document.addEventListener("DOMContentLoaded",function(){t.init()});const t={interval:[],isInitiated:!1,init:function(e){this.holder=document.querySelectorAll(".qi-block-countdown"),this.holder.length&&[...this.holder].map(l=>{t.initItem(l,e)})},getRealCurrentItem:function(t){return"string"==typeof t&&""!==t&&(t=qiBlocksEditor.qodefGetCurrentBlockElement.get(t)),t},initItem:function(e,l){const a=l?e:0;if(!(e=t.getRealCurrentItem(e)))return;let r=e.querySelector(".qodef-m-date"),i=t.generateOptions(e);t.initCountdown(r,i,l,a)},sanitizeAttributeValue:function(t){return t?t.replace(/[^\w\s%.-]/g,""):""},generateOptions:function(e){let l={};return l.date=void 0!==e.getAttribute("data-date")?e.getAttribute("data-date"):null,l.hide=void 0!==e.getAttribute("data-hide")?e.getAttribute("data-hide"):null,l.monthLabel=void 0!==e.getAttribute("data-month-label")?t.sanitizeAttributeValue(e.getAttribute("data-month-label")):"Month",l.monthLabelPlural=void 0!==e.getAttribute("data-month-label-plural")?t.sanitizeAttributeValue(e.getAttribute("data-month-label-plural")):"Months",l.dayLabel=void 0!==e.getAttribute("data-day-label")?t.sanitizeAttributeValue(e.getAttribute("data-day-label")):"Day",l.dayLabelPlural=void 0!==e.getAttribute("data-day-label-plural")?t.sanitizeAttributeValue(e.getAttribute("data-day-label-plural")):"Days",l.hourLabel=void 0!==e.getAttribute("data-hour-label")?t.sanitizeAttributeValue(e.getAttribute("data-hour-label")):"Hour",l.hourLabelPlural=void 0!==e.getAttribute("data-hour-label-plural")?t.sanitizeAttributeValue(e.getAttribute("data-hour-label-plural")):"Hours",l.minuteLabel=void 0!==e.getAttribute("data-minute-label")?t.sanitizeAttributeValue(e.getAttribute("data-minute-label")):"Minute",l.minuteLabelPlural=void 0!==e.getAttribute("data-minute-label-plural")?t.sanitizeAttributeValue(e.getAttribute("data-minute-label-plural")):"Minutes",l.secondLabel=void 0!==e.getAttribute("data-second-label")?t.sanitizeAttributeValue(e.getAttribute("data-second-label")):"Second",l.secondLabelPlural=void 0!==e.getAttribute("data-second-label-plural")?t.sanitizeAttributeValue(e.getAttribute("data-second-label-plural")):"Seconds",l},initCountdown:function(e,l,a,r){!t.isInitiated&&r&&(t.interval[r]=t.initInterval(e,l),t.isInitiated=!0),a&&t.isInitiated&&(clearInterval(t.interval[r]),t.interval[r]=t.initInterval(e,l)),r||t.initInterval(e,l)},initInterval:function(t,e){let l=new Date(e.date).getTime();return setInterval(function(){let a=(new Date).getTime(),r=l-a,i=Math.floor(r/2592e6),o=Math.floor(r%2592e6/864e5),n=Math.floor(r%864e5/36e5),u=Math.floor(r%36e5/6e4),d=Math.floor(r%6e4/1e3);const b="minsec"===e.hide,c="sec"===e.hide,q="mon"===e.hide;q&&(o=Math.floor(r/864e5));let s=t.querySelector(".qodef-months"),f=t.querySelector(".qodef-days"),g=t.querySelector(".qodef-hours"),h=t.querySelector(".qodef-minutes"),y=t.querySelector(".qodef-seconds");q||(s.querySelector(".qodef-label").textContent=1===i?e.monthLabel:e.monthLabelPlural),f.querySelector(".qodef-label").textContent=1===o?e.dayLabel:e.dayLabelPlural,g.querySelector(".qodef-label").textContent=1===n?e.hourLabel:e.hourLabelPlural,b||(h.querySelector(".qodef-label").textContent=1===u?e.minuteLabel:e.minuteLabelPlural),b||c||(y.querySelector(".qodef-label").textContent=1===d?e.secondLabel:e.secondLabelPlural),i=i<10?"0"+i:i,o=o<10?"0"+o:o,n=n<10?"0"+n:n,u=u<10?"0"+u:u,d=d<10?"0"+d:d,q||(s.querySelector(".qodef-digit").textContent=i),f.querySelector(".qodef-digit").textContent=o,g.querySelector(".qodef-digit").textContent=n,b||(h.querySelector(".qodef-digit").textContent=u),b||c||(y.querySelector(".qodef-digit").textContent=d),r<0&&(q||(s.querySelector(".qodef-label").textContent=e.monthLabelPlural),f.querySelector(".qodef-label").textContent=e.dayLabelPlural,g.querySelector(".qodef-label").textContent=e.hourLabelPlural,b||(h.querySelector(".qodef-label").textContent=e.minuteLabelPlural),b||c||(y.querySelector(".qodef-label").textContent=e.secondLabelPlural),q||(s.querySelector(".qodef-digit").textContent="00"),f.querySelector(".qodef-digit").textContent="00",g.querySelector(".qodef-digit").textContent="00",b||(h.querySelector(".qodef-digit").textContent="00"),b||c||(y.querySelector(".qodef-digit").textContent="00"))},1e3)}}})();