(function(h){h.extend(h.inputmask.defaults.definitions,{h:{validator:"[01][0-9]|2[0-3]",cardinality:2,prevalidator:[{validator:"[0-2]",cardinality:1}]},s:{validator:"[0-5][0-9]",cardinality:2,prevalidator:[{validator:"[0-5]",cardinality:1}]},d:{validator:"0[1-9]|[12][0-9]|3[01]",cardinality:2,prevalidator:[{validator:"[0-3]",cardinality:1}]},m:{validator:"0[1-9]|1[012]",cardinality:2,prevalidator:[{validator:"[01]",cardinality:1}]},y:{validator:"(19|20)\\d{2}",cardinality:4,prevalidator:[{validator:"[12]",
cardinality:1},{validator:"(19|20)",cardinality:2},{validator:"(19|20)\\d",cardinality:3}]}});h.extend(h.inputmask.defaults.aliases,{"dd/mm/yyyy":{mask:"1/2/y",placeholder:"dd/mm/yyyy",regex:{val1pre:/[0-3]/,val1:/0[1-9]|[12][0-9]|3[01]/,val2pre:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|[12][0-9]|3[01])"+a+"[01])")},val2:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|[12][0-9])"+a+"(0[1-9]|1[012]))|(30"+a+"(0[13-9]|1[012]))|(31"+a+"(0[13578]|1[02]))")}},
leapday:"29/02/",separator:"/",yearrange:{minyear:1900,maxyear:2099},isInYearRange:function(a,d,c){var e=parseInt(a.concat(d.toString().slice(a.length))),a=parseInt(a.concat(c.toString().slice(a.length)));return(NaN!=e?d<=e&&e<=c:!1)||(NaN!=a?d<=a&&a<=c:!1)},determinebaseyear:function(a,d){var c=(new Date).getFullYear();return a>c?a:d<c?d:c},onKeyUp:function(a,d,c){d=h(this);a.ctrlKey&&a.keyCode==c.keyCode.RIGHT&&(a=new Date,d.val(a.getDate().toString()+(a.getMonth()+1).toString()+a.getFullYear().toString()))},
definitions:{1:{validator:function(a,d,c,e,b){var f=b.regex.val1.test(a);if(!e&&!f&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(f=b.regex.val1.test("0"+a.charAt(0)))return d[c-1]="0",{pos:c,c:a.charAt(0)};return f},cardinality:2,prevalidator:[{validator:function(a,d,c,e,b){var f=b.regex.val1pre.test(a);return!e&&!f&&(f=b.regex.val1.test("0"+a))?(d[c]="0",c++,{pos:c}):f},cardinality:1}]},2:{validator:function(a,d,c,e,b){var f=d.join("").substr(0,3),g=b.regex.val2(b.separator).test(f+
a);if(!e&&!g&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(g=b.regex.val2(b.separator).test(f+"0"+a.charAt(0)))return d[c-1]="0",{pos:c,c:a.charAt(0)};return g},cardinality:2,prevalidator:[{validator:function(a,d,c,e,b){var f=d.join("").substr(0,3),g=b.regex.val2pre(b.separator).test(f+a);return!e&&!g&&(g=b.regex.val2(b.separator).test(f+"0"+a))?(d[c]="0",c++,{pos:c}):g},cardinality:1}]},y:{validator:function(a,d,c,e,b){if(b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear)){if(d.join("").substr(0,
6)!=b.leapday)return!0;a=parseInt(a,10);return 0===a%4?0===a%100?0===a%400?!0:!1:!0:!1}return!1},cardinality:4,prevalidator:[{validator:function(a,d,c,e,b){var f=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!f){e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,1);if(f=b.isInYearRange(e+a,b.yearrange.minyear,b.yearrange.maxyear))return d[c++]=e[0],{pos:c};e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);if(f=b.isInYearRange(e+
a,b.yearrange.minyear,b.yearrange.maxyear))return d[c++]=e[0],d[c++]=e[1],{pos:c}}return f},cardinality:1},{validator:function(a,d,c,e,b){var f=b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear);if(!e&&!f){e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);if(f=b.isInYearRange(a[0]+e[1]+a[1],b.yearrange.minyear,b.yearrange.maxyear))return d[c++]=e[1],{pos:c};e=b.determinebaseyear(b.yearrange.minyear,b.yearrange.maxyear).toString().slice(0,2);b.isInYearRange(e+
a,b.yearrange.minyear,b.yearrange.maxyear)?d.join("").substr(0,6)!=b.leapday?f=!0:(b=parseInt(a,10),f=0===b%4?0===b%100?0===b%400?!0:!1:!0:!1):f=!1;if(f)return d[c-1]=e[0],d[c++]=e[1],d[c++]=a[0],{pos:c}}return f},cardinality:2},{validator:function(a,d,c,e,b){return b.isInYearRange(a,b.yearrange.minyear,b.yearrange.maxyear)},cardinality:3}]}},insertMode:!1,autoUnmask:!1},"mm/dd/yyyy":{placeholder:"mm/dd/yyyy",alias:"dd/mm/yyyy",regex:{val2pre:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[13-9]|1[012])"+
a+"[0-3])|(02"+a+"[0-2])")},val2:function(a){a=h.inputmask.escapeRegex.call(this,a);return RegExp("((0[1-9]|1[012])"+a+"(0[1-9]|[12][0-9]))|((0[13-9]|1[012])"+a+"30)|((0[13578]|1[02])"+a+"31)")},val1pre:/[01]/,val1:/0[1-9]|1[012]/},leapday:"02/29/",onKeyUp:function(a,d,c){d=h(this);a.ctrlKey&&a.keyCode==c.keyCode.RIGHT&&(a=new Date,d.val((a.getMonth()+1).toString()+a.getDate().toString()+a.getFullYear().toString()))}},"yyyy/mm/dd":{mask:"y/1/2",placeholder:"yyyy/mm/dd",alias:"mm/dd/yyyy",leapday:"/02/29",
onKeyUp:function(a,d,c){d=h(this);a.ctrlKey&&a.keyCode==c.keyCode.RIGHT&&(a=new Date,d.val(a.getFullYear().toString()+(a.getMonth()+1).toString()+a.getDate().toString()))},definitions:{2:{validator:function(a,d,c,e,b){var f=d.join("").substr(5,3),g=b.regex.val2(b.separator).test(f+a);if(!e&&!g&&(a.charAt(1)==b.separator||-1!="-./".indexOf(a.charAt(1))))if(g=b.regex.val2(b.separator).test(f+"0"+a.charAt(0)))return d[c-1]="0",{pos:c,c:a.charAt(0)};if(g){if(d.join("").substr(4,4)+a!=b.leapday)return!0;
a=parseInt(d.join("").substr(0,4),10);return 0===a%4?0===a%100?0===a%400?!0:!1:!0:!1}return g},cardinality:2,prevalidator:[{validator:function(a,d,c,e,b){var f=d.join("").substr(5,3),g=b.regex.val2pre(b.separator).test(f+a);return!e&&!g&&(g=b.regex.val2(b.separator).test(f+"0"+a))?(d[c]="0",c++,{pos:c}):g},cardinality:1}]}}},"dd.mm.yyyy":{mask:"1.2.y",placeholder:"dd.mm.yyyy",leapday:"29.02.",separator:".",alias:"dd/mm/yyyy"},"dd-mm-yyyy":{mask:"1-2-y",placeholder:"dd-mm-yyyy",leapday:"29-02-",separator:"-",
alias:"dd/mm/yyyy"},"mm.dd.yyyy":{mask:"1.2.y",placeholder:"mm.dd.yyyy",leapday:"02.29.",separator:".",alias:"mm/dd/yyyy"},"mm-dd-yyyy":{mask:"1-2-y",placeholder:"mm-dd-yyyy",leapday:"02-29-",separator:"-",alias:"mm/dd/yyyy"},"yyyy.mm.dd":{mask:"y.1.2",placeholder:"yyyy.mm.dd",leapday:".02.29",separator:".",alias:"yyyy/mm/dd"},"yyyy-mm-dd":{mask:"y-1-2",placeholder:"yyyy-mm-dd",leapday:"-02-29",separator:"-",alias:"yyyy/mm/dd"},datetime:{mask:"1/2/y h:s",placeholder:"dd/mm/yyyy hh:mm",alias:"dd/mm/yyyy",
regex:{hrspre:/[012]/,hrs24:/2[0-9]|1[3-9]/,hrs:/[01][0-9]|2[0-3]/,ampmpre:/[apAP]/,ampm:/^[a|p|A|P][m|M]/},timeseparator:":",hourFormat:"24",definitions:{h:{validator:function(a,d,c,e,b){var f=b.regex.hrs.test(a);if(!e&&!f&&(a.charAt(1)==b.timeseparator||-1!="-.:".indexOf(a.charAt(1))))if(f=b.regex.hrs.test("0"+a.charAt(0)))return d[c-1]="0",d[c]=a.charAt(0),c++,{pos:c};return f&&"24"!==b.hourFormat&&b.regex.hrs24.test(a)?(a=parseInt(a,10),d[c+5]=24==a?"a":"p",d[c+6]="m",a-=12,10>a?(d[c]=a.toString(),
d[c-1]="0"):(d[c]=a.toString().charAt(1),d[c-1]=a.toString().charAt(0)),{pos:c,c:d[c]}):f},cardinality:2,prevalidator:[{validator:function(a,d,c,e,b){var f=b.regex.hrspre.test(a);return!e&&!f&&(f=b.regex.hrs.test("0"+a))?(d[c]="0",c++,{pos:c}):f},cardinality:1}]},t:{validator:function(a,d,c,e,b){var f=b.regex.ampm.test(a);return!e&&!f&&(f=b.regex.ampm.test(a+"m"))?(d[c-1]=a.charAt(0),d[c]="m",c++,c):f},casing:"lower",cardinality:2,prevalidator:[{validator:function(a,d,c,e,b){if(e=b.regex.ampmpre.test(a))if(e=
b.regex.ampm.test(a+"m"))return d[c]=a,d[c+1]="m",c;return e},cardinality:1}]}},insertMode:!1,autoUnmask:!1},datetime12:{mask:"1/2/y h:s t",placeholder:"dd/mm/yyyy hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm t":{mask:"h:s t",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"h:s t":{mask:"h:s t",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm:ss":{mask:"h:s:s",autoUnmask:!1},"hh:mm":{mask:"h:s",autoUnmask:!1},date:{alias:"dd/mm/yyyy"}})})(jQuery);
