var ModeEnum={YEAR:0,MONTH:1,DATE:2};!function(){"use strict";function n(n,t,i,r,u){var f,e;for(t=t||[],Array.isArray(t)||(t=[t]),f=document.createElement(n),e=t.length;e--;f.classList.add(t[e]));return u&&(f.title=u),f.innerHTML=r||"",i instanceof Element&&i.appendChild(f),f}function r(n){return n=n||new Date,new Date(n.getFullYear(),n.getMonth(),n.getDate())}function e(u){function l(){var n=e.minDate;return n instanceof HTMLInputElement&&(n=n.DatePickerX.getValue(!0),n=n===null?e.minDate.DatePickerX.getMinDate():new Date(n),n.setDate(n.getDate()+1)),r(n)}function a(){var n=e.maxDate;return n instanceof HTMLInputElement&&(n=n.DatePickerX.getValue(!0),n=n===null?e.maxDate.DatePickerX.getMaxDate():new Date(n),n.setDate(n.getDate()-1)),r(n)}function p(){var t,i;f.container=n("div","date-picker-x");t=n("div","dpx-title-box",f.container);f.title=n("span","dpx-title",t);f.prevTitle=n("span","dpx-prev",t,"");f.nextTitle=n("span","dpx-next",t,"");f.content=n("div","dpx-content-box",f.container);u.nextElementSibling?u.parentNode.insertBefore(f.container,u.nextElementSibling):u.parentNode.appendChild(f.container);(e.todayButton||e.clearButton)&&(i=n("div","dpx-btns",f.container),e.todayButton&&(f.today=n("span",["dpx-item","dpx-today"],i,e.todayButtonLabel,e.todayButtonLabel)),e.clearButton&&(f.clear=n("span",["dpx-item","dpx-clear"],i,e.clearButtonLabel,e.clearButtonLabel)))}function y(n,t){var i={d:n.getDate(),dd:n.getDate(),D:n.getDay(),m:n.getMonth()+1,mm:n.getMonth()+1,M:n.getMonth(),MM:n.getMonth(),yy:n.getFullYear().toString().substr(-2),yyyy:n.getFullYear()};return i.dd<10&&(i.dd="0"+i.dd),i.mm<10&&(i.mm="0"+i.mm),i.D=e.weekDayLabels[i.D?i.D-1:6],i.M=e.shortMonthLabels[i.M],i.MM=e.singleMonthLabels[i.MM],t.replace(/(?:[dmM]{1,2}|D|yyyy|yy)/g,function(n){return typeof i[n]!="undefined"?i[n]:n})}function v(){return f.container.classList.contains("active")}function w(n){var s,i;e.isBlock&&(o=e.defaultMode,h(),f.container.classList.add("active"),f.container.classList.remove("to-top"),s=f.container.getBoundingClientRect(),s.bottom>window.innerHeight&&s.top>f.container.offsetHeight&&f.container.classList.add("to-top"),t=f.container);i=u.previousElementSibling;i&&i.classList.contains("date-picker-icon")?i.addEventListener("click",function(n){if(!v()){n.stopPropagation();o=e.defaultMode;h();f.container.classList.add("active");f.container.classList.remove("to-top");var i=f.container.getBoundingClientRect();i.bottom>window.innerHeight&&i.top>f.container.offsetHeight&&f.container.classList.add("to-top");t&&t!==f.container&&t.classList.remove("active");t=f.container}}):u.addEventListener("click",function(n){if(!v()){n.stopPropagation();o=e.defaultMode;h();f.container.classList.add("active");f.container.classList.remove("to-top");var i=f.container.getBoundingClientRect();i.bottom>window.innerHeight&&i.top>f.container.offsetHeight&&f.container.classList.add("to-top");t&&t!==f.container&&t.classList.remove("active");t=f.container}});window.addEventListener("click",function(){t&&!e.isBlock&&t.classList.remove("active")});f.container.addEventListener("click",function(n){n.stopPropagation();n.preventDefault()});f.content.addEventListener("click",function(t){if(o===2)t.target&&!t.target.classList.contains("dpx-disabled")&&n.setValue(t.target.dpxValue)&&!e.isBlock&&f.container.classList.remove("active");else{var i=l(),r=a();i.setDate(1);r.setDate(1);o||(i.setMonth(0),r.setMonth(0));t.target.dpxValue>=i.getTime()&&t.target.dpxValue<=r.getTime()&&++o&&h(t.target.dpxValue)}});f.prevTitle.addEventListener("click",function(){h(this.dpxValue)});f.nextTitle.addEventListener("click",function(){h(this.dpxValue)});f.title.addEventListener("click",function(){o&&o--&&h(this.dpxValue)});f.today&&f.today.addEventListener("click",function(){this.classList.contains("dpx-disabled")||!n.setValue(r())||e.isBlock||f.container.classList.remove("active")});f.clear&&f.clear.addEventListener("click",function(){n.setValue(null)&&!e.isBlock&&f.container.classList.remove("active")})}function h(t){var g,nt,w,k,y,u,d,tt,it;f.content.innerHTML="";var h=l(),c=a(),p=r();e.todayButton&&f.today.classList[p>=h&&p<=c?"remove":"add"]("dpx-disabled");o<2&&(h.setDate(1),c.setDate(1),o||(h.setMonth(0),c.setMonth(0)));h=h.getTime();c=c.getTime();t||s||(g=e.defaultSelectedYear);t=r(new Date(t||s||Date.now()));t.getTime()<h?t=new Date(h):t.getTime()>c&&(t=new Date(c));g&&(t=new Date(g,t.getMonth(),t.getDate()));var b=t.getMonth(),v=t.getFullYear(),i=Math.floor(v/10)*10-10;if(t=new Date(o?v:i,o<2?0:b),f.title.innerHTML=(o?(o===2?e.singleMonthLabels[b]+" ":"")+v:i+" - "+(i+19))+n("span",["dpx-arrow",o===2?"dpx-arrow-down":"dpx-arrow-up"]).outerHTML,f.title.dpxValue=t.getTime(),f.title.title=o===2?v:i+" - "+(i+19),f.prevTitle.classList[t.getTime()<=h?"add":"remove"]("dpx-disabled"),o===2?t.setMonth(b-1):t.setFullYear(o?v-1:i-10),f.prevTitle.title=o?(o===2?e.singleMonthLabels[t.getMonth()]+" ":"")+t.getFullYear():i-20+" - "+(i-1),f.prevTitle.dpxValue=t.getTime(),o===2?t.setMonth(t.getMonth()+2):t.setFullYear(o?v+1:i+30),f.nextTitle.classList[t.getTime()>c?"add":"remove"]("dpx-disabled"),f.nextTitle.title=o?(o===2?e.singleMonthLabels[t.getMonth()]+" ":"")+t.getFullYear():i+20+" - "+(i+39),f.nextTitle.dpxValue=t.getTime(),o===2?t.setMonth(t.getMonth()-1):t.setFullYear(o?v:i),o===2)for(nt=e.weekDayLabels.length,!e.mondayFirst&&--nt&&n("span",["dpx-item","dpx-weekday","dpx-weekend"],f.content,e.weekDayLabels[6]),w=0;w<nt;++w)u=["dpx-item","dpx-weekday"],w>4&&u.push("dpx-weekend"),n("span",u,f.content,e.weekDayLabels[w]);o===2?(k=t.getDay(),t.setDate(e.mondayFirst?-(k?k-2:5):-k+1)):o?t.setMonth(t.getMonth()-2):t.setFullYear(i);y=s;o<2&&(y!==null&&(y=new Date(y),y.setDate(1),o||y.setMonth(0),y=y.getTime()),p.setDate(1),o||p.setMonth(0));p=p.getTime();f.container.setAttribute("data-dpx-type",["year","month","day"][o]);for(var rt=["getFullYear","getMonth","getDate"][o],ut=["setFullYear","setMonth","setDate"][o],ft=o===2?42:o===1?16:20;ft--;t[ut](t[rt]()+1))u=["dpx-item"],d=o?e.singleMonthLabels[t.getMonth()]+" ":"",o===2&&(d+=t.getDate()+", "),d+=t.getFullYear(),(o?o===2?t.getMonth()!==b:t.getFullYear()!==v:t.getFullYear()<i||t.getFullYear()>i+19)&&u.push("dpx-out"),o===2&&(t.getDay()===6||t.getDay()===0)&&u.push("dpx-weekend"),t.getTime()===p&&u.push("dpx-current"),t.getTime()===s&&u.push("dpx-selected"),(t.getTime()<h||t.getTime()>c)&&u.push("dpx-disabled"),tt=o?o===2?t.getDate():e.shortMonthLabels[t.getMonth()]:t.getFullYear(),it=n("span",u,f.content,tt,d),it.dpxValue=t.getTime()}function b(n,t){if(typeof e[n]=="undefined")return console.error("DatePickerX, setOption: Option doesn't exist.")&&!1;if(n==="minDate"||n==="maxDate"){if(!(t instanceof HTMLInputElement)&&(t instanceof Date||(t=new Date(t)),isNaN(t)))return console.error("DatePickerX, setOption: Invalid date value.")&&!1}else{if(typeof e[n]!=typeof t)return console.error("DatePickerX, setOption: Option has invalid type.")&&!1;if(Array.isArray(e[n])){if(t.length<e[n].length)return console.warn("DatePickerX, setOption: Invalid option length.")&&!1;t=t.slice(0,e[n].length)}}e[n]=t}var e={},f={},c=!1,s=null,o=e.defaultMode;return{init:function(n){var t;if(n=n||{},c)return console.error("DatePickerX, init: Date picker have already inited.")&&!1;c=!0;e={};for(t in i)e[t]=i[t];if(typeof n!="object")console.error("DatePickerX, init: Initial options must be an object.");else for(t in n)b(t,n[t]);return u.parentNode.classList.add("date-picker-x-container"),u.classList.add("date-picker-x-input"),p(),w(this),!0},remove:function(){return c?(u.parentNode.removeChild(f.container),u.classList.remove("date-picker-x-input"),u.readOnly=c=!1,!0):console.error("DatePickerX, remove: Date picker doesn't init yet.")&&!1},setValue:function(n,t,i){if(!c)return console.error("DatePickerX, remove: Date picker doesn't init yet.")&&!1;if(n===null)s=null,u.value="";else{if(n instanceof Date||(n=new Date(n)),isNaN(n))return console.error("DatePickerX, setValue: Can't convert argument to date.")&&!1;if(!t&&(n.getTime()<l().getTime()||n.getTime()>a().getTime()))return console.error("DatePickerX, setValue: Date out of acceptable range.")&&!1;s=n.getTime();u.value=y(n,e.format)}if(!i){var r=document.createEvent("Event");r.initEvent("change",!0,!0);u.dispatchEvent(r)}return v()&&h(),!0},getValue:function(n){return c||console.error("DatePickerX, getValue: Date picker doesn't init yet."),n?s:s===null?"":y(new Date(s),e.format)},getMinDate:function(){var n=e.minDate;return n instanceof HTMLInputElement&&(n=n.DatePickerX.getMinDate()),r(n)},setMinDate:function(n){e.minDate=n},getMaxDate:function(){var n=e.maxDate;return n instanceof HTMLInputElement&&(n=n.DatePickerX.getMaxDate()),r(n)},setMaxDate:function(n){e.maxDate=n}}}var i={mondayFirst:!1,format:"dd/mm/yyyy",minDate:new Date(0,0),maxDate:new Date(9999,11,31),weekDayLabels:["ב","ג","ד","ה","ו","ז","א"],shortMonthLabels:["ינו","פבר","מרץ","אפר","מאי","יונ","יול","אוג","ספט","אוק","נוב","דצמ"],singleMonthLabels:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"],isBlock:!1,todayButton:!1,todayButtonLabel:"היום",clearButton:!1,clearButtonLabel:"נקה",defaultMode:ModeEnum.DATE,defaultSelectedYear:0},t=null,u=[],f=[];Object.defineProperty(HTMLInputElement.prototype,"DatePickerX",{get:function(){var n=u.indexOf(this);return n===-1&&(n=u.push(this)-1,f.push(new e(this))),f[n]},set:function(){}});window.DatePickerX={setDefaults:function(n){if(typeof n!="object")return console.error("DatePickerX, setDefaults: Invalid option type.")&&!1;for(var t in n)typeof n[t]==typeof i[t]&&(Array.isArray(i[t])?n[t].length>=i[t].length&&(i[t]=n[t].slice(0,i[t].length)):i[t]=n[t]);return!0}}}()