!function(n,t){"use strict";var i;if("object"==typeof exports){try{i=require("moment")}catch(n){}module.exports=t(i)}else"function"==typeof define&&define.amd?define(function(n){try{i=n("moment")}catch(n){}return t(i)}):n.Pikaday=t(n.moment)}(this,function(n){"use strict";var o="function"==typeof n,l=!!window.addEventListener,t=window.document,a=window.setTimeout,u=function(n,t,i,r){l?n.addEventListener(t,i,!!r):n.attachEvent("on"+t,i)},e=function(n,t,i,r){l?n.removeEventListener(t,i,!!r):n.detachEvent("on"+t,i)},i=function(n,t){return-1!==(" "+n.className+" ").indexOf(" "+t+" ")},v=function(n,t){i(n,t)||(n.className=""===n.className?t:n.className+" "+t)},y=function(n,t){var i;n.className=(i=(" "+n.className+" ").replace(" "+t+" "," ")).trim?i.trim():i.replace(/^\s+|\s+$/g,"")},p=function(n){return/Array/.test(Object.prototype.toString.call(n))},r=function(n){return/Date/.test(Object.prototype.toString.call(n))&&!isNaN(n.getTime())},w=function(n,t){return[31,(i=n,i%4==0&&i%100!=0||i%400==0?29:28),31,30,31,30,31,31,30,31,30,31][t];var i},h=function(n){r(n)&&n.setHours(0,0,0,0)},c=function(n,t){return n.getTime()===t.getTime()},s=function(n,t,i){var u,f;for(u in t)(f=void 0!==n[u])&&"object"==typeof t[u]&&null!==t[u]&&void 0===t[u].nodeName?r(t[u])?i&&(n[u]=new Date(t[u].getTime())):p(t[u])?i&&(n[u]=t[u].slice(0)):n[u]=s({},t[u],i):!i&&f||(n[u]=t[u]);return n},b=function(n,i,r){var u;t.createEvent?((u=t.createEvent("HTMLEvents")).initEvent(i,!0,!1),u=s(u,r),n.dispatchEvent(u)):t.createEventObject&&(u=t.createEventObject(),u=s(u,r),n.fireEvent("on"+i,u))},k=function(n){return n.month<0&&(n.year-=Math.ceil(Math.abs(n.month)/12),n.month+=12),n.month>11&&(n.year+=Math.floor(Math.abs(n.month)/12),n.month-=12),n},f={field:null,bound:void 0,ariaLabel:"Use the arrow keys to pick a date",position:"bottom left",reposition:!0,format:"YYYY-MM-DD",toString:null,parse:null,defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,pickWholeWeek:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,enableSelectionDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,blurFieldOnSelect:!0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},theme:null,events:[],onSelect:null,onOpen:null,onClose:null,onDraw:null,keyboardInput:!0},d=function(n,t,i){for(t+=n.firstDay;t>=7;)t-=7;return i?n.i18n.weekdaysShort[t]:n.i18n.weekdays[t]},nt=function(n){var t=[],i="false";if(n.isEmpty){if(!n.showDaysInNextAndPreviousMonths)return'<td class="is-empty"><\/td>';t.push("is-outside-current-month");n.enableSelectionDaysInNextAndPreviousMonths||t.push("is-selection-disabled")}return n.isDisabled&&t.push("is-disabled"),n.isToday&&t.push("is-today"),n.isSelected&&(t.push("is-selected"),i="true"),n.hasEvent&&t.push("has-event"),n.isInRange&&t.push("is-inrange"),n.isStartRange&&t.push("is-startrange"),n.isEndRange&&t.push("is-endrange"),'<td data-day="'+n.day+'" class="'+t.join(" ")+'" aria-selected="'+i+'"><button class="pika-button pika-day" type="button" data-pika-year="'+n.year+'" data-pika-month="'+n.month+'" data-pika-day="'+n.day+'">'+n.day+"<\/button><\/td>"},tt=function(t,i,r){var u=new Date(r,i,t);return'<td class="pika-week">'+(o?n(u).isoWeek():function(n){var t,r;n.setHours(0,0,0,0);var u=n.getDate(),f=n.getDay(),i=function(n){return(n+7-1)%7};return n.setDate(u+3-i(f)),t=new Date(n.getFullYear(),0,4),r=(n.getTime()-t.getTime())/864e5,1+Math.round((r-3+i(t.getDay()))/7)}(u))+"<\/td>"},it=function(n,t,i,r,u,f){for(var c,l,a,e=n._o,v=i===e.minYear,y=i===e.maxYear,h='<div id="'+f+'" class="pika-title" role="heading" aria-live="assertive">',w=!0,b=!0,s=[],o=0;o<12;o++)s.push('<option value="'+(i===u?o-t:12+o-t)+'"'+(o===r?' selected="selected"':"")+(v&&o<e.minMonth||y&&o>e.maxMonth?' disabled="disabled"':"")+">"+e.i18n.months[o]+"<\/option>");for(l='<div class="pika-label">'+e.i18n.months[r]+'<select class="pika-select pika-select-month" tabindex="-1">'+s.join("")+"<\/select><\/div>",p(e.yearRange)?(o=e.yearRange[0],c=e.yearRange[1]+1):(o=i-e.yearRange,c=1+i+e.yearRange),s=[];o<c&&o<=e.maxYear;o++)o>=e.minYear&&s.push('<option value="'+o+'"'+(o===i?' selected="selected"':"")+">"+o+"<\/option>");return a='<div class="pika-label">'+i+e.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+s.join("")+"<\/select><\/div>",h+=e.showMonthAfterYear?a+l:l+a,v&&(0===r||e.minMonth>=r)&&(w=!1),y&&(11===r||e.maxMonth<=r)&&(b=!1),0===t&&(h+='<button class="pika-prev'+(w?"":" is-disabled")+'" type="button">'+e.i18n.previousMonth+"<\/button>"),t===n._o.numberOfMonths-1&&(h+='<button class="pika-next'+(b?"":" is-disabled")+'" type="button">'+e.i18n.nextMonth+"<\/button>"),h+"<\/div>"},rt=function(n,t,i){return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+i+'">'+function(n){var t,i=[];for(n.showWeekNumber&&i.push("<th><\/th>"),t=0;t<7;t++)i.push('<th scope="col"><abbr title="'+d(n,t)+'">'+d(n,t,!0)+"<\/abbr><\/th>");return"<thead><tr>"+(n.isRTL?i.reverse():i).join("")+"<\/tr><\/thead>"}(n)+("<tbody>"+t.join("")+"<\/tbody>")+"<\/table>"},g=function(f){var e=this,s=e.config(f),h;e._onMouseDown=function(n){if(e._v){var t=(n=n||window.event).target||n.srcElement;if(t)if(i(t,"is-disabled")||(!i(t,"pika-button")||i(t,"is-empty")||i(t.parentNode,"is-disabled")?i(t,"pika-prev")?e.prevMonth():i(t,"pika-next")&&e.nextMonth():(e.setDate(new Date(t.getAttribute("data-pika-year"),t.getAttribute("data-pika-month"),t.getAttribute("data-pika-day"))),s.bound&&a(function(){e.hide();s.blurFieldOnSelect&&s.field&&s.field.blur()},100))),i(t,"pika-select"))e._c=!0;else{if(!n.preventDefault)return n.returnValue=!1,!1;n.preventDefault()}}};e._onChange=function(n){var t=(n=n||window.event).target||n.srcElement;t&&(i(t,"pika-select-month")?e.gotoMonth(t.value):i(t,"pika-select-year")&&e.gotoYear(t.value))};e._onKeyChange=function(n){if(n=n||window.event,e.isVisible())switch(n.keyCode){case 13:case 27:s.field&&s.field.blur();break;case 37:e.adjustDate("subtract",1);break;case 38:e.adjustDate("subtract",7);break;case 39:e.adjustDate("add",1);break;case 40:e.adjustDate("add",7);break;case 8:case 46:e.setDate(null)}};e._parseFieldValue=function(){if(s.parse)return s.parse(s.field.value,s.format);if(o){var t=n(s.field.value,s.format,s.formatStrict);return t&&t.isValid()?t.toDate():null}return new Date(Date.parse(s.field.value))};e._onInputChange=function(n){var t;n.firedBy!==e&&(t=e._parseFieldValue(),r(t)&&e.setDate(t),e._v||e.show())};e._onInputFocus=function(){e.show()};e._onInputClick=function(){e.show()};e._onInputBlur=function(){var n=t.activeElement;do if(i(n,"pika-single"))return;while(n=n.parentNode);e._c||(e._b=a(function(){e.hide()},50));e._c=!1};e._onClick=function(n){var t=(n=n||window.event).target||n.srcElement,r=t;if(t){!l&&i(t,"pika-select")&&(t.onchange||(t.setAttribute("onchange","return;"),u(t,"change",e._onChange)));do if(i(r,"pika-single")||r===s.trigger)return;while(r=r.parentNode);e._v&&t!==s.trigger&&r!==s.trigger&&e.hide()}};e.el=t.createElement("div");e.el.className="pika-single"+(s.isRTL?" is-rtl":"")+(s.theme?" "+s.theme:"");u(e.el,"mousedown",e._onMouseDown,!0);u(e.el,"touchend",e._onMouseDown,!0);u(e.el,"change",e._onChange);s.keyboardInput&&u(t,"keydown",e._onKeyChange);s.field&&(s.container?s.container.appendChild(e.el):s.bound?t.body.appendChild(e.el):s.field.parentNode.insertBefore(e.el,s.field.nextSibling),u(s.field,"change",e._onInputChange),s.defaultDate||(s.defaultDate=e._parseFieldValue(),s.setDefaultDate=!0));h=s.defaultDate;r(h)?s.setDefaultDate?e.setDate(h,!0):e.gotoDate(h):e.gotoDate(new Date);s.bound?(this.hide(),e.el.className+=" is-bound",u(s.trigger,"click",e._onInputClick),u(s.trigger,"focus",e._onInputFocus),u(s.trigger,"blur",e._onInputBlur)):this.show()};return g.prototype={config:function(n){var t,i,u;return this._o||(this._o=s({},f,!0)),t=s(this._o,n,!0),t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.theme="string"==typeof t.theme&&t.theme?t.theme:null,t.bound=!!(void 0!==t.bound?t.field&&t.bound:t.field),t.trigger=t.trigger&&t.trigger.nodeName?t.trigger:t.field,t.disableWeekends=!!t.disableWeekends,t.disableDayFn="function"==typeof t.disableDayFn?t.disableDayFn:null,i=parseInt(t.numberOfMonths,10)||1,(t.numberOfMonths=i>4?4:i,r(t.minDate)||(t.minDate=!1),r(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate<t.minDate&&(t.maxDate=t.minDate=!1),t.minDate&&this.setMinDate(t.minDate),t.maxDate&&this.setMaxDate(t.maxDate),p(t.yearRange))?(u=(new Date).getFullYear()-10,t.yearRange[0]=parseInt(t.yearRange[0],10)||u,t.yearRange[1]=parseInt(t.yearRange[1],10)||u):(t.yearRange=Math.abs(parseInt(t.yearRange,10))||f.yearRange,t.yearRange>100&&(t.yearRange=100)),t},toString:function(t){return t=t||this._o.format,r(this._d)?this._o.toString?this._o.toString(this._d,t):o?n(this._d).format(t):this._d.toDateString():""},getMoment:function(){return o?n(this._d):null},setMoment:function(t,i){o&&n.isMoment(t)&&this.setDate(t.toDate(),i)},getDate:function(){return r(this._d)?new Date(this._d.getTime()):null},setDate:function(n,t){if(!n)return this._d=null,this._o.field&&(this._o.field.value="",b(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof n&&(n=new Date(Date.parse(n))),r(n)){var i=this._o.minDate,u=this._o.maxDate;r(i)&&n<i?n=i:r(u)&&n>u&&(n=u);this._d=new Date(n.getTime());h(this._d);this.gotoDate(this._d);this._o.field&&(this._o.field.value=this.toString(),b(this._o.field,"change",{firedBy:this}));t||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},clear:function(){this.setDate(null)},gotoDate:function(n){var i=!0;if(r(n)){if(this.calendars){var f=new Date(this.calendars[0].year,this.calendars[0].month,1),t=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),u=n.getTime();t.setMonth(t.getMonth()+1);t.setDate(t.getDate()-1);i=u<f.getTime()||t.getTime()<u}i&&(this.calendars=[{month:n.getMonth(),year:n.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths));this.adjustCalendars()}},adjustDate:function(n,t){var i,r=this.getDate()||new Date,u=864e5*parseInt(t);"add"===n?i=new Date(r.valueOf()+u):"subtract"===n&&(i=new Date(r.valueOf()-u));this.setDate(i)},adjustCalendars:function(){this.calendars[0]=k(this.calendars[0]);for(var n=1;n<this._o.numberOfMonths;n++)this.calendars[n]=k({month:this.calendars[0].month+n,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(n){isNaN(n)||(this.calendars[0].month=parseInt(n,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++;this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--;this.adjustCalendars()},gotoYear:function(n){isNaN(n)||(this.calendars[0].year=parseInt(n,10),this.adjustCalendars())},setMinDate:function(n){n instanceof Date?(h(n),this._o.minDate=n,this._o.minYear=n.getFullYear(),this._o.minMonth=n.getMonth()):(this._o.minDate=f.minDate,this._o.minYear=f.minYear,this._o.minMonth=f.minMonth,this._o.startRange=f.startRange);this.draw()},setMaxDate:function(n){n instanceof Date?(h(n),this._o.maxDate=n,this._o.maxYear=n.getFullYear(),this._o.maxMonth=n.getMonth()):(this._o.maxDate=f.maxDate,this._o.maxYear=f.maxYear,this._o.maxMonth=f.maxMonth,this._o.endRange=f.endRange);this.draw()},setStartRange:function(n){this._o.startRange=n},setEndRange:function(n){this._o.endRange=n},draw:function(n){var i;if(this._v||n){var r,t=this._o,e=t.minYear,o=t.maxYear,u=t.minMonth,f=t.maxMonth,s="";for(this._y<=e&&(this._y=e,!isNaN(u)&&this._m<u&&(this._m=u)),this._y>=o&&(this._y=o,!isNaN(f)&&this._m>f&&(this._m=f)),i=0;i<t.numberOfMonths;i++)r="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2),s+='<div class="pika-lendar">'+it(this,i,this.calendars[i].year,this.calendars[i].month,this.calendars[0].year,r)+this.render(this.calendars[i].year,this.calendars[i].month,r)+"<\/div>";this.el.innerHTML=s;t.bound&&"hidden"!==t.field.type&&a(function(){t.trigger.focus()},1);"function"==typeof this._o.onDraw&&this._o.onDraw(this);t.bound&&t.field.setAttribute("aria-label",t.ariaLabel)}},adjustPosition:function(){var u,n,f,e,h,c,l,i,r,a,o,s;if(!this._o.container){if(this.el.style.position="absolute",n=u=this._o.trigger,f=this.el.offsetWidth,e=this.el.offsetHeight,h=window.innerWidth||t.documentElement.clientWidth,c=window.innerHeight||t.documentElement.clientHeight,l=window.pageYOffset||t.body.scrollTop||t.documentElement.scrollTop,o=!0,s=!0,"function"==typeof u.getBoundingClientRect)i=(a=u.getBoundingClientRect()).left+window.pageXOffset,r=a.bottom+window.pageYOffset;else for(i=n.offsetLeft,r=n.offsetTop+n.offsetHeight;n=n.offsetParent;)i+=n.offsetLeft,r+=n.offsetTop;(this._o.reposition&&i+f>h||this._o.position.indexOf("right")>-1&&i-f+u.offsetWidth>0)&&(i=i-f+u.offsetWidth,o=!1);(this._o.reposition&&r+e>c+l||this._o.position.indexOf("top")>-1&&r-e-u.offsetHeight>0)&&(r=r-e-u.offsetHeight,s=!1);this.el.style.left=i+"px";this.el.style.top=r+"px";v(this.el,o?"left-aligned":"right-aligned");v(this.el,s?"bottom-aligned":"top-aligned");y(this.el,o?"right-aligned":"left-aligned");y(this.el,s?"top-aligned":"bottom-aligned")}},render:function(n,t,i){var u=this._o,g=new Date,a=w(n,t),e=new Date(n,t,1).getDay(),it=[],s=[],lt;h(g);u.firstDay>0&&(e-=u.firstDay)<0&&(e+=7);for(var ut=0===t?11:t-1,at=11===t?0:t+1,ft=0===t?n-1:n,vt=11===t?n+1:n,yt=w(ft,ut),v=a+e,y=v;y>7;)y-=7;v+=7-y;for(var p,et,ot,b=!1,o=0,st=0;o<v;o++){var f=new Date(n,t,o-e+1),ht=!!r(this._d)&&c(f,this._d),pt=c(f,g),wt=-1!==u.events.indexOf(f.toDateString()),ct=o<e||o>=a+e,l=o-e+1,k=t,d=n,bt=u.startRange&&c(u.startRange,f),kt=u.endRange&&c(u.endRange,f),dt=u.startRange&&u.endRange&&u.startRange<f&&f<u.endRange,gt=u.minDate&&f<u.minDate||u.maxDate&&f>u.maxDate||u.disableWeekends&&(void 0,0===(ot=f.getDay())||6===ot)||u.disableDayFn&&u.disableDayFn(f);ct&&(o<e?(l=yt+l,k=ut,d=ft):(l-=a,k=at,d=vt));lt={day:l,month:k,year:d,hasEvent:wt,isSelected:ht,isToday:pt,isDisabled:gt,isEmpty:ct,isStartRange:bt,isEndRange:kt,isInRange:dt,showDaysInNextAndPreviousMonths:u.showDaysInNextAndPreviousMonths,enableSelectionDaysInNextAndPreviousMonths:u.enableSelectionDaysInNextAndPreviousMonths};u.pickWholeWeek&&ht&&(b=!0);s.push(nt(lt));7==++st&&(u.showWeekNumber&&s.unshift(tt(o-e,t,n)),it.push((p=s,et=u.isRTL,'<tr class="pika-row'+(u.pickWholeWeek?" pick-whole-week":"")+(b?" is-selected":"")+'">'+(et?p.reverse():p).join("")+"<\/tr>")),s=[],st=0,b=!1)}return rt(u,it,i)},isVisible:function(){return this._v},show:function(){this.isVisible()||(this._v=!0,this.draw(),y(this.el,"is-hidden"),this._o.bound&&(u(t,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var n=this._v;!1!==n&&(this._o.bound&&e(t,"click",this._onClick),this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto",v(this.el,"is-hidden"),this._v=!1,void 0!==n&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){var n=this._o;this.hide();e(this.el,"mousedown",this._onMouseDown,!0);e(this.el,"touchend",this._onMouseDown,!0);e(this.el,"change",this._onChange);n.keyboardInput&&e(t,"keydown",this._onKeyChange);n.field&&(e(n.field,"change",this._onInputChange),n.bound&&(e(n.trigger,"click",this._onInputClick),e(n.trigger,"focus",this._onInputFocus),e(n.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},g})