/*
 jp-countdown 1.0.1 2021-07-29 
 */

!function o(i,r,s){function a(t,e){if(!r[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(n=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",n}n=r[t]={exports:{}},i[t][0].call(n.exports,function(e){return a(i[t][1][e]||e)},n,n.exports,o,i,r,s)}return r[t].exports}for(var u="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,n){"use strict";e=e("./jp-countdown");window.JPCountdown=e},{"./jp-countdown":2}],2:[function(e,t,n){"use strict";function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var r=function(){function o(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o);var n=e;if(!((e="string"==typeof e?document.querySelector(e):e)instanceof Element||e instanceof HTMLDocument))throw new Error("".concat(n," is not an HTML element or valid selector!"));if(!(t instanceof Date))throw new Error("".concat(t," is not a Date!"));t.setMilliseconds(Math.round(t.getMilliseconds()/1e3)),this.targetEl=e,this.endDate=t.getTime(),this.update=this.update.bind(this),this.start=this.start.bind(this),this.events=[],this.time=Date.now(),this.time>this.endDate&&console.warn("The countdown endDate has already passed!")}var e,t,n;return e=o,(t=[{key:"start",value:function(){this.timerRef=setInterval(this.update,1e3),this.update()}},{key:"on",value:function(e,t){if(s.indexOf(e)<0)throw new Error("".concat(e," is not a valid event!"));this.events.push({evt:e,func:t})}},{key:"update",value:function(){var t=new Date(this.endDate-this.time)/1e3,t=Math.max(0,t),n={},e=t/604800;n.wholeWeeks=Math.floor(e);e=7*(e-n.wholeWeeks);n.wholeDays=Math.floor(e);e=24*(e-n.wholeDays);n.wholeHours=Math.floor(e);e=60*(e-n.wholeHours);n.wholeMinutes=Math.floor(e),n.wholeSeconds=Math.floor(60*(e-n.wholeMinutes)),o.updateView(this.targetEl,n),this.events.forEach(function(e){e.evt===o.Event_Update&&e.func(n,t)}),0===Math.round(t)&&(this.events.forEach(function(e){e.evt===o.Event_Finished&&e.func(n)}),clearInterval(this.timerRef)),this.time+=1e3}}])&&i(e.prototype,t),n&&i(e,n),o}();r.updateView=function(n,o){"string"==typeof n&&(n=document.querySelector(n)),r.Fields.forEach(function(e){var t=n.querySelector(e);if(t)switch(e){case".jp-countdown-weeks":t.innerHTML=o.wholeWeeks;break;case".jp-countdown-days":t.innerHTML=o.wholeDays;break;case".jp-countdown-hours":t.innerHTML=o.wholeHours;break;case".jp-countdown-minutes":t.innerHTML=o.wholeMinutes;break;case".jp-countdown-seconds":t.innerHTML=o.wholeSeconds}})},r.Event_Update="update",r.Event_Finished="finished",r.Fields=[".jp-countdown-weeks",".jp-countdown-days",".jp-countdown-hours",".jp-countdown-minutes",".jp-countdown-seconds"];var s=[r.Event_Update,r.Event_Finished];t.exports=r},{}]},{},[1]);