!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(o){"use strict";var n=[],e=[],i={precision:100,elapse:!1,defer:!1};e.push(/^[0-9]*$/.source),e.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),e.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source),e=new RegExp(e.join("|"));var g={Y:"years",m:"months",n:"daysToMonth",d:"daysToWeek",w:"weeks",W:"weeksToMonth",H:"hours",M:"minutes",S:"seconds",D:"totalDays",I:"totalHours",N:"totalMinutes",T:"totalSeconds"};var a=function(t,e,s){this.el=t,this.$el=o(t),this.interval=null,this.offset={},this.options=o.extend({},i),this.firstTick=!0,this.instanceNumber=n.length,n.push(this),this.$el.data("countdown-instance",this.instanceNumber),s&&("function"==typeof s?(this.$el.on("update.countdown",s),this.$el.on("stoped.countdown",s),this.$el.on("finish.countdown",s)):this.options=o.extend({},i,s)),this.setFinalDate(e),!1===this.options.defer&&this.start()};o.extend(a.prototype,{start:function(){null!==this.interval&&clearInterval(this.interval);var t=this;this.update(),this.interval=setInterval(function(){t.update.call(t)},this.options.precision)},stop:function(){clearInterval(this.interval),this.interval=null,this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this),n[this.instanceNumber]=null,delete this.$el.data().countdownInstance},setFinalDate:function(t){this.finalDate=function(t){if(t instanceof Date)return t;if(String(t).match(e))return String(t).match(/^[0-9]*$/)&&(t=Number(t)),String(t).match(/\-/)&&(t=String(t).replace(/\-/g,"/")),new Date(t);throw new Error("Couldn't cast `"+t+"` to a date object.")}(t)},update:function(){if(0!==this.$el.closest("html").length){var t,e=new Date;t=this.finalDate.getTime()-e.getTime(),t=Math.ceil(t/1e3),t=!this.options.elapse&&t<0?0:Math.abs(t),this.totalSecsLeft===t||this.firstTick?this.firstTick=!1:(this.totalSecsLeft=t,this.elapsed=e>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),weeksToMonth:Math.floor(this.totalSecsLeft/60/60/24/7)%4,months:Math.floor(this.totalSecsLeft/60/60/24/30.4368),years:Math.abs(this.finalDate.getFullYear()-e.getFullYear()),totalDays:Math.floor(this.totalSecsLeft/60/60/24),totalHours:Math.floor(this.totalSecsLeft/60/60),totalMinutes:Math.floor(this.totalSecsLeft/60),totalSeconds:this.totalSecsLeft},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish")))}else this.remove()},dispatchEvent:function(t){var v,e=o.Event(t+".countdown");e.finalDate=this.finalDate,e.elapsed=this.elapsed,e.offset=o.extend({},this.offset),e.strftime=(v=this.offset,function(t){var e,s,i,o,n,a,h=t.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(h)for(var l=0,r=h.length;l<r;++l){var c=h[l].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),f=(e=c[0],s=e.toString().replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),new RegExp(s)),u=c[1]||"",p=c[3]||"",d=null;c=c[2],g.hasOwnProperty(c)&&(d=g[c],d=Number(v[d])),null!==d&&("!"===u&&(o=d,a=n=void 0,n="s",a="",(i=p)&&(n=1===(i=i.replace(/(:|;|\s)/gi,"").split(/\,/)).length?i[0]:(a=i[0],i[1])),d=1<Math.abs(o)?n:a),""===u&&d<10&&(d="0"+d.toString()),t=t.replace(f,d.toString()))}return t=t.replace(/%%/,"%")}),this.$el.trigger(e)}}),o.fn.countdown=function(){var i=Array.prototype.slice.call(arguments,0);return this.each(function(){var t=o(this).data("countdown-instance");if(void 0!==t){var e=n[t],s=i[0];a.prototype.hasOwnProperty(s)?e[s].apply(e,i.slice(1)):null===String(s).match(/^[$A-Z_][0-9A-Z_$]*$/i)?(e.setFinalDate.call(e,s),e.start()):o.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi,s))}else new a(this,i[0],i[1])})}});