/*
 Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Version: 3.1.1
*/
(function(f){"function"===typeof define&&define.amd?define(["jquery"],f):f(jQuery)})(function(f){if(void 0===f.fn.inputmask){var U=function(f){var d=document.createElement("input");f="on"+f;var c=f in d;c||(d.setAttribute(f,"return;"),c="function"==typeof d[f]);return c},D=function(b,d,c){return(b=c.aliases[b])?(b.alias&&D(b.alias,void 0,c),f.extend(!0,c,b),f.extend(!0,c,d),!0):!1},Q=function(b,d){function c(c){function f(c,d,b,g){this.matches=[];this.isGroup=c||!1;this.isOptional=d||!1;this.isQuantifier=
b||!1;this.isAlternator=g||!1;this.quantifier={min:1,max:1}}function d(c,f,g){var h=b.definitions[f],k=0==c.matches.length;g=void 0!=g?g:c.matches.length;if(h&&!p){for(var H=h.prevalidator,u=H?H.length:0,s=1;s<h.cardinality;s++){var w=u>=s?H[s-1]:[],q=w.validator,w=w.cardinality;c.matches.splice(g++,0,{fn:q?"string"==typeof q?RegExp(q):new function(){this.test=q}:/./,cardinality:w?w:1,optionality:c.isOptional,newBlockMarker:k,casing:h.casing,def:h.definitionSymbol||f,placeholder:h.placeholder,mask:f})}c.matches.splice(g++,
0,{fn:h.validator?"string"==typeof h.validator?RegExp(h.validator):new function(){this.test=h.validator}:/./,cardinality:h.cardinality,optionality:c.isOptional,newBlockMarker:k,casing:h.casing,def:h.definitionSymbol||f,placeholder:h.placeholder,mask:f})}else c.matches.splice(g++,0,{fn:null,cardinality:0,optionality:c.isOptional,newBlockMarker:k,casing:null,def:f,placeholder:void 0,mask:f}),p=!1}for(var k=/(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g,p=!1,s=new f,g,w=[],A=[],
u,h;g=k.exec(c);)switch(g=g[0],g.charAt(0)){case b.optionalmarker.end:case b.groupmarker.end:g=w.pop();if(0<w.length){if(u=w[w.length-1],u.matches.push(g),u.isAlternator){g=w.pop();for(u=0;u<g.matches.length;u++)g.matches[u].isGroup=!1;0<w.length?(u=w[w.length-1],u.matches.push(g)):s.matches.push(g)}}else s.matches.push(g);break;case b.optionalmarker.start:w.push(new f(!1,!0));break;case b.groupmarker.start:w.push(new f(!0));break;case b.quantifiermarker.start:u=new f(!1,!1,!0);g=g.replace(/[{}]/g,
"");h=g.split(",");g=isNaN(h[0])?h[0]:parseInt(h[0]);h=1==h.length?g:isNaN(h[1])?h[1]:parseInt(h[1]);if("*"==h||"+"==h)g="*"==h?0:1;u.quantifier={min:g,max:h};if(0<w.length){h=w[w.length-1].matches;g=h.pop();if(!g.isGroup){var y=new f(!0);y.matches.push(g);g=y}h.push(g);h.push(u)}else g=s.matches.pop(),g.isGroup||(y=new f(!0),y.matches.push(g),g=y),s.matches.push(g),s.matches.push(u);break;case b.escapeChar:p=!0;break;case b.alternatormarker:0<w.length?(u=w[w.length-1],h=u.matches.pop()):h=s.matches.pop();
h.isAlternator?w.push(h):(g=new f(!1,!1,!1,!0),g.matches.push(h),w.push(g));break;default:if(0<w.length){if(u=w[w.length-1],0<u.matches.length&&(h=u.matches[u.matches.length-1],h.isGroup&&(h.isGroup=!1,d(h,b.groupmarker.start,0),d(h,b.groupmarker.end))),d(u,g),u.isAlternator){g=w.pop();for(u=0;u<g.matches.length;u++)g.matches[u].isGroup=!1;0<w.length?(u=w[w.length-1],u.matches.push(g)):s.matches.push(g)}}else 0<s.matches.length&&(h=s.matches[s.matches.length-1],h.isGroup&&(h.isGroup=!1,d(h,b.groupmarker.start,
0),d(h,b.groupmarker.end))),d(s,g)}0<s.matches.length&&(h=s.matches[s.matches.length-1],h.isGroup&&(h.isGroup=!1,d(h,b.groupmarker.start,0),d(h,b.groupmarker.end)),A.push(s));return A}function y(d,k){if(b.numericInput&&!0!==b.multi){d=d.split("").reverse();for(var p=0;p<d.length;p++)d[p]==b.optionalmarker.start?d[p]=b.optionalmarker.end:d[p]==b.optionalmarker.end?d[p]=b.optionalmarker.start:d[p]==b.groupmarker.start?d[p]=b.groupmarker.end:d[p]==b.groupmarker.end&&(d[p]=b.groupmarker.start);d=d.join("")}if(void 0!=
d&&""!=d){if(0<b.repeat||"*"==b.repeat||"+"==b.repeat)d=b.groupmarker.start+d+b.groupmarker.end+b.quantifiermarker.start+("*"==b.repeat?0:"+"==b.repeat?1:b.repeat)+","+b.repeat+b.quantifiermarker.end;void 0==f.inputmask.masksCache[d]&&(f.inputmask.masksCache[d]={mask:d,maskToken:c(d),validPositions:{},_buffer:void 0,buffer:void 0,tests:{},metadata:k});return f.extend(!0,{},f.inputmask.masksCache[d])}}var A=[];f.isFunction(b.mask)&&(b.mask=b.mask.call(this,b));if(f.isArray(b.mask))if(d)f.each(b.mask,
function(c,d){void 0!=d.mask?A.push(y(d.mask.toString(),d)):A.push(y(d.toString()))});else{b.keepStatic=void 0==b.keepStatic?!0:b.keepStatic;var p=!1,k="(";f.each(b.mask,function(c,d){1<k.length&&(k+=")|(");void 0!=d.mask?(p=!0,k+=d.mask.toString()):k+=d.toString()});k+=")";A=y(k,p?b.mask:void 0)}else 1==b.mask.length&&!1==b.greedy&&0!=b.repeat&&(b.placeholder=""),A=void 0!=b.mask.mask?y(b.mask.mask.toString(),b.mask):y(b.mask.toString());return A},ja="function"===typeof ScriptEngineMajorVersion?
ScriptEngineMajorVersion():10<=(new Function("/*@cc_on return @_jscript_version; @*/"))(),x=navigator.userAgent,ka=null!==x.match(/iphone/i),la=null!==x.match(/android.*safari.*/i),ma=null!==x.match(/android.*chrome.*/i),na=null!==x.match(/android.*firefox.*/i),oa=/Kindle/i.test(x)||/Silk/i.test(x)||/KFTT/i.test(x)||/KFOT/i.test(x)||/KFJWA/i.test(x)||/KFJWI/i.test(x)||/KFSOWI/i.test(x)||/KFTHWA/i.test(x)||/KFTHWI/i.test(x)||/KFAPWA/i.test(x)||/KFAPWI/i.test(x),Z=U("paste")?"paste":U("input")?"input":
"propertychange",K=function(b,d,c){function y(a,e,t){e=e||0;var f=[],b,g=0,m;do{if(!0===a&&d.validPositions[g]){var l=d.validPositions[g];m=l.match;b=l.locator.slice();f.push(null==m.fn?m.def:!0===t?l.input:m.placeholder||c.placeholder.charAt(g%c.placeholder.length))}else b=e>g?L(g,b,g-1)[0]:x(g,b,g-1),m=b.match,b=b.locator.slice(),f.push(null==m.fn?m.def:void 0!=m.placeholder?m.placeholder:c.placeholder.charAt(g%c.placeholder.length));g++}while((void 0==M||g-1<M)&&null!=m.fn||null==m.fn&&""!=m.def||
e>=g);f.pop();return f}function A(a){var e=d;e.buffer=void 0;e.tests={};!0!==a&&(e._buffer=void 0,e.validPositions={},e.p=-1)}function p(a){var e=-1,c=d.validPositions;void 0==a&&(a=-1);var f=e,g;for(g in c){var b=parseInt(g);if(-1==a||null!=c[b].match.fn)b<a&&(f=b),b>=a&&(e=b)}return 1<a-f||e<a?f:e}function k(a,e,t){if(c.insertMode&&void 0!=d.validPositions[a]&&void 0==t){t=f.extend(!0,{},d.validPositions);var b=p(),g;for(g=a;g<=b;g++)delete d.validPositions[g];d.validPositions[a]=e;e=!0;for(g=a;g<=
b;g++){a=t[g];if(void 0!=a){var v=null==a.match.fn?g+1:C(g);e=K(v,a.match.def)?e&&!1!==u(v,a.input,!0,!0):!1}if(!e)break}if(!e)return d.validPositions=f.extend(!0,{},t),!1}else d.validPositions[a]=e;return!0}function H(a,e){var c,f=a;for(c=a;c<e;c++)delete d.validPositions[c];for(c=e;c<=p();){var g=d.validPositions[c],b=d.validPositions[f];void 0!=g&&void 0==b?(K(f,g.match.def)&&!1!==u(f,g.input,!0)&&(delete d.validPositions[c],c++),f++):c++}for(c=p();0<c&&(void 0==d.validPositions[c]||null==d.validPositions[c].match.fn);)delete d.validPositions[c],
c--;A(!0)}function x(a,e,t){a=L(a,e,t);var g;e=p();e=d.validPositions[e]||L(0)[0];t=void 0!=e.alternation?e.locator[e.alternation].split(","):[];for(var b=0;b<a.length&&(g=a[b],!c.greedy&&(!g.match||!1!==g.match.optionality&&!1!==g.match.newBlockMarker||!0===g.match.optionalQuantifier||void 0!=e.alternation&&(void 0==g.locator[e.alternation]||-1!=f.inArray(g.locator[e.alternation].toString(),t))));b++);return g}function D(a){return d.validPositions[a]?d.validPositions[a].match:L(a)[0].match}function K(a,
e){for(var c=!1,f=L(a),d=0;d<f.length;d++)if(f[d].match&&f[d].match.def==e){c=!0;break}return c}function L(a,e,t){function g(e,t,b,h){function r(b,h,k){if(1E4<v)return alert("jquery.inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. "+d.mask),!0;if(v==a&&void 0==b.matches)return m.push({match:b,locator:h.reverse()}),!0;if(void 0!=b.matches)if(b.isGroup&&!0!==k){if(b=r(e.matches[n+1],h))return!0}else if(b.isOptional){var p=
b;if(b=g(b,t,h,k))b=m[m.length-1].match,(b=0==f.inArray(b,p.matches))&&(l=!0),v=a}else if(b.isAlternator){var p=b,u=[],s,w=m.slice(),q=h.length,N=0<t.length?t.shift():-1;if(-1==N||"string"==typeof N){var A=v,ea=t.slice(),y;"string"==typeof N&&(y=N.split(","));for(var x=0;x<p.matches.length;x++){m=[];b=r(p.matches[x],[x].concat(h),k)||b;s=m.slice();v=A;m=[];for(var z=0;z<ea.length;z++)t[z]=ea[z];for(z=0;z<s.length;z++)for(var B=s[z],H=0;H<u.length;H++){var C=u[H];if(B.match.mask==C.match.mask&&("string"!=
typeof N||-1!=f.inArray(B.locator[q].toString(),y))){s.splice(z,1);C.locator[q]=C.locator[q]+","+B.locator[q];C.alternation=q;break}}u=u.concat(s)}"string"==typeof N&&(u=f.map(u,function(a,e){if(isFinite(e)){var c=a.locator[q].toString().split(","),t;a.locator[q]=void 0;a.alternation=void 0;for(var d=0;d<c.length;d++)if(t=-1!=f.inArray(c[d],y))void 0!=a.locator[q]?(a.locator[q]+=",",a.alternation=q,a.locator[q]+=c[d]):a.locator[q]=parseInt(c[d]);if(void 0!=a.locator[q])return a}}));m=w.concat(u);
l=!0}else b=r(p.matches[N],[N].concat(h),k);if(b)return!0}else if(b.isQuantifier&&!0!==k)for(p=b,c.greedy=c.greedy&&isFinite(p.quantifier.max),k=0<t.length&&!0!==k?t.shift():0;k<(isNaN(p.quantifier.max)?k+1:p.quantifier.max)&&v<=a;k++){if(u=e.matches[f.inArray(p,e.matches)-1],b=r(u,[k].concat(h),!0))if(b=m[m.length-1].match,b.optionalQuantifier=k>p.quantifier.min-1,b=0==f.inArray(b,u.matches))if(k>p.quantifier.min-1){l=!0;v=a;break}else return!0;else return!0}else{if(b=g(b,t,h,k))return!0}else v++}
for(var n=0<t.length?t.shift():0;n<e.matches.length;n++)if(!0!==e.matches[n].isQuantifier){var k=r(e.matches[n],[n].concat(b),h);if(k&&v==a)return k;if(v>a)break}}var b=d.maskToken,v=e?t:0;t=e||[0];var m=[],l=!1;if(void 0==e){e=a-1;for(var h;void 0==(h=d.validPositions[e])&&-1<e;)e--;if(void 0!=h&&-1<e)v=e,t=h.locator.slice();else{for(e=a-1;void 0==(h=d.tests[e])&&-1<e;)e--;void 0!=h&&-1<e&&(v=e,t=h[0].locator.slice())}}for(e=t.shift();e<b.length&&!(g(b[e],t,[e])&&v==a||v>a);e++);(0==m.length||l)&&
m.push({match:{fn:null,cardinality:0,optionality:!0,casing:null,def:""},locator:[]});d.tests[a]=f.extend(!0,[],m);return d.tests[a]}function s(){void 0==d._buffer&&(d._buffer=y(!1,1));return d._buffer}function g(){void 0==d.buffer&&(d.buffer=y(!0,p(),!0));return d.buffer}function w(a,e){var t=g().slice();if(!0===a)A(),a=0,e=t.length;else for(var f=a;f<e;f++)delete d.validPositions[f],delete d.tests[f];for(f=a;f<e;f++)t[f]!=c.skipOptionalPartCharacter&&u(f,t[f],!0,!0)}function Q(a,e){switch(e.casing){case "upper":a=
a.toUpperCase();break;case "lower":a=a.toLowerCase()}return a}function u(a,e,t,b){function r(a,e,t,b){var l=!1;f.each(L(a),function(m,h){var F=h.match,v=e?1:0,r="";g();for(var n=F.cardinality;n>v;n--)r+=void 0==d.validPositions[a-(n-1)]?W(a-(n-1)):d.validPositions[a-(n-1)].input;e&&(r+=e);l=null!=F.fn?F.fn.test(r,d,a,t,c):e!=F.def&&e!=c.skipOptionalPartCharacter||""==F.def?!1:{c:F.def,pos:a};if(!1!==l){v=void 0!=l.c?l.c:e;v=v==c.skipOptionalPartCharacter&&null===F.fn?F.def:v;r=a;void 0!=l.remove&&
H(l.remove,l.remove+1);if(l.refreshFromBuffer){r=l.refreshFromBuffer;t=!0;w(!0===r?r:r.start,r.end);if(void 0==l.pos&&void 0==l.c)return l.pos=p(),!1;r=void 0!=l.pos?l.pos:a;if(r!=a)return l=f.extend(l,u(r,v,!0)),!1}else if(!0!==l&&void 0!=l.pos&&l.pos!=a&&(r=l.pos,w(a,r),r!=a))return l=f.extend(l,u(r,v,!0)),!1;if(!0!=l&&void 0==l.pos&&void 0==l.c)return!1;0<m&&A(!0);k(r,f.extend({},h,{input:Q(v,F)}),b)||(l=!1);return!1}});return l}function v(a,e,t,b){if(c.keepStatic){var l=f.extend(!0,{},d.validPositions),
m,r;for(m=p();0<=m;m--)if(d.validPositions[m]&&void 0!=d.validPositions[m].alternation){r=d.validPositions[m].alternation;break}if(void 0!=r)for(var h in d.validPositions)if(parseInt(h)>parseInt(m)&&void 0===d.validPositions[h].alternation){var F=d.validPositions[h].locator[r];m=d.validPositions[m].locator[r].split(",");for(var v=0;v<m.length;v++)if(F<m[v]){for(var k,n,q=h-1;0<=q;q--)if(k=d.validPositions[q],void 0!=k){n=k.locator[r];k.locator[r]=m[v];break}if(F!=k.locator[r]){for(var q=g().slice(),
s=h;s<p()+1;s++)delete d.validPositions[s],delete d.tests[s];A(!0);c.keepStatic=!c.keepStatic;for(s=h;s<q.length;s++)q[s]!=c.skipOptionalPartCharacter&&u(p()+1,q[s],!1,!0);k.locator[r]=n;q=p()+1==a&&u(a,e,t,b);c.keepStatic=!c.keepStatic;if(q)return q;A();d.validPositions=f.extend(!0,{},l)}}break}}return!1}t=!0===t;for(var m=g(),l=a-1;-1<l&&(!d.validPositions[l]||null!=d.validPositions[l].match.fn);l--)void 0==d.validPositions[l]&&(!h(l)||m[l]!=W(l))&&1<L(l).length&&r(l,m[l],!0);m=a;if(m>=S())return v(a,
e,t,b);a=r(m,e,t,b);if(!t&&!1===a)if((l=d.validPositions[m])&&null==l.match.fn&&(l.match.def==e||e==c.skipOptionalPartCharacter))a={caret:C(m)};else if((c.insertMode||void 0==d.validPositions[C(m)])&&!h(m))for(var l=m+1,n=C(m);l<=n;l++)if(a=r(l,e,t,b),!1!==a){m=l;break}!0===a&&(a={pos:m});return a}function h(a){a=D(a);return null!=a.fn?a.fn:!1}function S(){var a;M=n.prop("maxLength");-1==M&&(M=void 0);if(!1==c.greedy){var e;e=p();a=d.validPositions[e];var f=void 0!=a?a.locator.slice():void 0;for(e+=
1;void 0==a||null!=a.match.fn||null==a.match.fn&&""!=a.match.def;e++)a=x(e,f,e-1),f=a.locator.slice();a=e}else a=g().length;return void 0==M||a<M?a:M}function C(a){var e=S();if(a>=e)return e;for(;++a<e&&!h(a)&&(!0!==c.nojumps||c.nojumpsThreshold>a););return a}function V(a){if(0>=a)return 0;for(;0<--a&&!h(a););return a}function E(a,e,c){a._valueSet(e.join(""));void 0!=c&&q(a,c)}function W(a,e){e=e||D(a);return e.placeholder||(null==e.fn?e.def:c.placeholder.charAt(a%c.placeholder.length))}function R(a,
e,t,b,r){b=void 0!=b?b.slice():ia(a._valueGet()).split("");A();e&&a._valueSet("");f.each(b,function(e,c){if(!0===r){var b=p(),g=-1==b?e:C(b);-1==f.inArray(c,s().slice(b+1,g))&&X.call(a,void 0,!0,c.charCodeAt(0),!1,t,e)}else X.call(a,void 0,!0,c.charCodeAt(0),!1,t,e),t=t||0<e&&e>d.p});e&&(e=c.onKeyPress.call(this,void 0,g(),0,c),$(a,e),E(a,g(),f(a).is(":focus")?C(p(0)):void 0))}function U(a){return f.inputmask.escapeRegex.call(this,a)}function ia(a){return a.replace(RegExp("("+U(s().join(""))+")*$"),
"")}function da(a){if(a.data("_inputmask")&&!a.hasClass("hasDatepicker")){var e=[],b=d.validPositions,h;for(h in b)b[h].match&&null!=b[h].match.fn&&e.push(b[h].input);e=(B?e.reverse():e).join("");b=(B?g().slice().reverse():g()).join("");f.isFunction(c.onUnMask)&&(e=c.onUnMask.call(a,b,e,c));return e}return a[0]._valueGet()}function P(a){!B||"number"!=typeof a||c.greedy&&""==c.placeholder||(a=g().length-a);return a}function q(a,e,b){a=a.jquery&&0<a.length?a[0]:a;if("number"==typeof e){e=P(e);b=P(b);
b="number"==typeof b?b:e;var d=f(a).data("_inputmask")||{};d.caret={begin:e,end:b};f(a).data("_inputmask",d);f(a).is(":visible")&&(a.scrollLeft=a.scrollWidth,!1==c.insertMode&&e==b&&b++,a.setSelectionRange?(a.selectionStart=e,a.selectionEnd=b):a.createTextRange&&(a=a.createTextRange(),a.collapse(!0),a.moveEnd("character",b),a.moveStart("character",e),a.select()))}else return d=f(a).data("_inputmask"),!f(a).is(":visible")&&d&&void 0!=d.caret?(e=d.caret.begin,b=d.caret.end):a.setSelectionRange?(e=a.selectionStart,
b=a.selectionEnd):document.selection&&document.selection.createRange&&(a=document.selection.createRange(),e=0-a.duplicate().moveStart("character",-1E5),b=e+a.text.length),e=P(e),b=P(b),{begin:e,end:b}}function ba(a){var e=g(),c=e.length,b,h=p(),v={},m=d.validPositions[h],l=void 0!=m?m.locator.slice():void 0,k;for(b=h+1;b<e.length;b++)k=x(b,l,b-1),l=k.locator.slice(),v[b]=f.extend(!0,{},k);l=m&&void 0!=m.alternation?m.locator[m.alternation].split(","):[];for(b=c-1;b>h;b--)if(k=v[b].match,(k.optionality||
k.optionalQuantifier||m&&void 0!=m.alternation&&void 0!=v[b].locator[m.alternation]&&-1!=f.inArray(v[b].locator[m.alternation].toString(),l))&&e[b]==W(b,k))c--;else break;return a?{l:c,def:v[c]?v[c].match:void 0}:c}function ca(a){var e=g().slice(),c=ba();e.length=c;E(a,e)}function T(a){if(f.isFunction(c.isComplete))return c.isComplete.call(n,a,c);if("*"!=c.repeat){var e=!1,b=ba(!0),d=V(b.l);if(p()==d&&(void 0==b.def||b.def.newBlockMarker||b.def.optionalQuantifier))for(e=!0,b=0;b<=d;b++){var g=h(b);
if(g&&(void 0==a[b]||a[b]==W(b))||!g&&a[b]!=W(b)){e=!1;break}}return e}}function pa(a){a=f._data(a).events;f.each(a,function(a,b){f.each(b,function(a,e){if("inputmask"==e.namespace&&"setvalue"!=e.type){var b=e.handler;e.handler=function(a){if(this.readOnly||this.disabled)a.preventDefault;else return b.apply(this,arguments)}}})})}function qa(a){function e(a){if(void 0==f.valHooks[a]||!0!=f.valHooks[a].inputmaskpatch){var e=f.valHooks[a]&&f.valHooks[a].get?f.valHooks[a].get:function(a){return a.value},
b=f.valHooks[a]&&f.valHooks[a].set?f.valHooks[a].set:function(a,e){a.value=e;return a};f.valHooks[a]={get:function(a){var b=f(a);if(b.data("_inputmask")){if(b.data("_inputmask").opts.autoUnmask)return b.inputmask("unmaskedvalue");a=e(a);b=(b=b.data("_inputmask").maskset._buffer)?b.join(""):"";return a!=b?a:""}return e(a)},set:function(a,e){var c=f(a),d=c.data("_inputmask");d?(d=b(a,f.isFunction(d.opts.onBeforeMask)?d.opts.onBeforeMask.call(z,e,d.opts):e),c.triggerHandler("setvalue.inputmask")):d=
b(a,e);return d},inputmaskpatch:!0}}}function b(){var a=f(this),e=f(this).data("_inputmask");return e?e.opts.autoUnmask?a.inputmask("unmaskedvalue"):h.call(this)!=s().join("")?h.call(this):"":h.call(this)}function c(a){var e=f(this).data("_inputmask");e?(m.call(this,f.isFunction(e.opts.onBeforeMask)?e.opts.onBeforeMask.call(z,a,e.opts):a),f(this).triggerHandler("setvalue.inputmask")):m.call(this,a)}function d(a){f(a).bind("mouseenter.inputmask",function(a){a=f(this);var e=this._valueGet();""!=e&&
e!=g().join("")&&a.trigger("setvalue")});if(a=f._data(a).events.mouseover){for(var e=a[a.length-1],b=a.length-1;0<b;b--)a[b]=a[b-1];a[0]=e}}var h,m;a._valueGet||(Object.getOwnPropertyDescriptor&&Object.getOwnPropertyDescriptor(a,"value"),document.__lookupGetter__&&a.__lookupGetter__("value")?(h=a.__lookupGetter__("value"),m=a.__lookupSetter__("value"),a.__defineGetter__("value",b),a.__defineSetter__("value",c)):(h=function(){return a.value},m=function(e){a.value=e},e(a.type),d(a)),a._valueGet=function(){return B?
h.call(this).split("").reverse().join(""):h.call(this)},a._valueSet=function(a){m.call(this,B?a.split("").reverse().join(""):a)})}function fa(a,e,b){if(c.numericInput||B)e==c.keyCode.BACKSPACE?e=c.keyCode.DELETE:e==c.keyCode.DELETE&&(e=c.keyCode.BACKSPACE),B&&(a=b.end,b.end=b.begin,b.begin=a);e==c.keyCode.BACKSPACE&&1>=b.end-b.begin?b.begin=V(b.begin):e==c.keyCode.DELETE&&b.begin==b.end&&b.end++;H(b.begin,b.end);e=p(b.begin);d.p=e<b.begin?C(e):b.begin}function $(a,b,c){if(b&&b.refreshFromBuffer){var d=
b.refreshFromBuffer;w(!0===d?d:d.start,d.end);A(!0);void 0!=c&&(E(a,g()),q(a,b.caret||c.begin,b.caret||c.end))}}function ga(a){Y=!1;var b=this,h=f(b),k=a.keyCode,r=q(b);k==c.keyCode.BACKSPACE||k==c.keyCode.DELETE||ka&&127==k||a.ctrlKey&&88==k?(a.preventDefault(),88==k&&(J=g().join("")),fa(b,k,r),E(b,g(),d.p),b._valueGet()==s().join("")&&h.trigger("cleared"),c.showTooltip&&h.prop("title",d.mask)):k==c.keyCode.END||k==c.keyCode.PAGE_DOWN?setTimeout(function(){var d=C(p());c.insertMode||d!=S()||a.shiftKey||
d--;q(b,a.shiftKey?r.begin:d,d)},0):k==c.keyCode.HOME&&!a.shiftKey||k==c.keyCode.PAGE_UP?q(b,0,a.shiftKey?r.begin:0):k==c.keyCode.ESCAPE||90==k&&a.ctrlKey?(R(b,!0,!1,J.split("")),h.click()):k!=c.keyCode.INSERT||a.shiftKey||a.ctrlKey?!1!=c.insertMode||a.shiftKey||(k==c.keyCode.RIGHT?setTimeout(function(){var a=q(b);q(b,a.begin)},0):k==c.keyCode.LEFT&&setTimeout(function(){var a=q(b);q(b,B?a.begin+1:a.begin-1)},0)):(c.insertMode=!c.insertMode,q(b,c.insertMode||r.begin!=S()?r.begin:r.begin-1));var h=
q(b),n=c.onKeyDown.call(this,a,g(),h.begin,c);$(b,n,h);aa=-1!=f.inArray(k,c.ignorables)}function X(a,b,h,n,r,v){if(void 0==h&&Y)return!1;Y=!0;var m=f(this);a=a||window.event;h=b?h:a.which||a.charCode||a.keyCode;if(!(!0===b||a.ctrlKey&&a.altKey)&&(a.ctrlKey||a.metaKey||aa))return!0;if(h){!0!==b&&46==h&&!1==a.shiftKey&&","==c.radixPoint&&(h=44);var l,s;h=String.fromCharCode(h);b?(v=r?v:p()+1,l={begin:v,end:v}):l=q(this);if(v=B?1<l.begin-l.end||1==l.begin-l.end&&c.insertMode:1<l.end-l.begin||1==l.end-
l.begin&&c.insertMode)d.undoPositions=f.extend(!0,{},d.validPositions),fa(this,c.keyCode.DELETE,l),c.insertMode||(c.insertMode=!c.insertMode,k(l.begin,r),c.insertMode=!c.insertMode),v=!c.multi;d.writeOutBuffer=!0;l=B&&!v?l.end:l.begin;var w=u(l,h,r);!1!==w&&(!0!==w&&(l=void 0!=w.pos?w.pos:l,h=void 0!=w.c?w.c:h),A(!0),void 0!=w.caret?s=w.caret:(r=d.validPositions,s=!c.keepStatic&&(void 0!=r[l+1]&&1<L(l+1,r[l].locator.slice(),l).length||void 0!=r[l].alternation)?l+1:C(l)),d.p=s);if(!1!==n){var z=this;
setTimeout(function(){c.onKeyValidation.call(z,w,c)},0);if(d.writeOutBuffer&&!1!==w){var y=g();E(this,y,b?void 0:c.numericInput?V(s):s);!0!==b&&setTimeout(function(){!0===T(y)&&m.trigger("complete");O=!0;m.trigger("input")},0)}else v&&(d.buffer=void 0,d.validPositions=d.undoPositions)}else v&&(d.buffer=void 0,d.validPositions=d.undoPositions);c.showTooltip&&m.prop("title",d.mask);a&&!0!=b&&(a.preventDefault?a.preventDefault():a.returnValue=!1,b=q(this),a=c.onKeyPress.call(this,a,g(),b.begin,c),$(this,
a,b))}}function ra(a){var b=f(this),d=a.keyCode,h=g(),k=q(this);a=c.onKeyUp.call(this,a,h,k.begin,c);$(this,a,k);d==c.keyCode.TAB&&c.showMaskOnFocus&&(b.hasClass("focus-inputmask")&&0==this._valueGet().length?(A(),h=g(),E(this,h),q(this,0),J=g().join("")):(E(this,h),q(this,P(0),P(S()))))}function ha(a){if(!0===O&&"input"==a.type)return O=!1,!0;var b=f(this),d=this._valueGet();if("propertychange"==a.type&&this._valueGet().length<=S())return!0;"paste"==a.type&&(window.clipboardData&&window.clipboardData.getData?
d=window.clipboardData.getData("Text"):a.originalEvent&&a.originalEvent.clipboardData&&a.originalEvent.clipboardData.getData&&(d=a.originalEvent.clipboardData.getData("text/plain")));a=f.isFunction(c.onBeforePaste)?c.onBeforePaste.call(this,d,c):d;R(this,!0,!1,a.split(""),!0);b.click();!0===T(g())&&b.trigger("complete");return!1}function sa(a){if(!0===O&&"input"==a.type)return O=!1,!0;var b=q(this),d=this._valueGet(),d=d.replace(RegExp("("+U(s().join(""))+")*"),"");b.begin>d.length&&(q(this,d.length),
b=q(this));1!=g().length-d.length||d.charAt(b.begin)==g()[b.begin]||d.charAt(b.begin+1)==g()[b.begin]||h(b.begin)||(a.keyCode=c.keyCode.BACKSPACE,ga.call(this,a));a.preventDefault()}function ta(a){if(!0===O&&"input"==a.type)return O=!1,!0;var b=q(this),h=this._valueGet();q(this,b.begin-1);var k=f.Event("keypress");k.which=h.charCodeAt(b.begin-1);aa=Y=!1;X.call(this,k,void 0,void 0,!1);b=d.p;E(this,g(),c.numericInput?V(b):b);a.preventDefault()}function ua(a){O=!0;var b=this;setTimeout(function(){q(b,
q(b).begin-1);var h=f.Event("keypress");h.which=a.originalEvent.data.charCodeAt(0);aa=Y=!1;X.call(b,h,void 0,void 0,!1);h=d.p;E(b,g(),c.numericInput?V(h):h)},0);return!1}function va(a){n=f(a);if(n.is(":input")&&"number"!=n.attr("type")){n.data("_inputmask",{maskset:d,opts:c,isRTL:!1});c.showTooltip&&n.prop("title",d.mask);("rtl"==a.dir||c.rightAlign)&&n.css("text-align","right");if("rtl"==a.dir||c.numericInput){a.dir="ltr";n.removeAttr("dir");var b=n.data("_inputmask");b.isRTL=!0;n.data("_inputmask",
b);B=!0}n.unbind(".inputmask");n.removeClass("focus-inputmask");n.closest("form").bind("submit",function(){J!=g().join("")?n.change():n[0]._valueGet()==s().join("")&&n[0]._valueSet("");c.autoUnmask&&c.removeMaskOnSubmit&&n.inputmask("remove")}).bind("reset",function(){setTimeout(function(){n.trigger("setvalue")},0)});n.bind("mouseenter.inputmask",function(){!f(this).hasClass("focus-inputmask")&&c.showMaskOnHover&&this._valueGet()!=g().join("")&&E(this,g())}).bind("blur.inputmask",function(){var a=
f(this);if(a.data("_inputmask")){var b=this._valueGet(),d=g();a.removeClass("focus-inputmask");J!=g().join("")&&a.change();c.clearMaskOnLostFocus&&""!=b&&(b==s().join("")?this._valueSet(""):ca(this));!1===T(d)&&(a.trigger("incomplete"),c.clearIncomplete&&(A(),c.clearMaskOnLostFocus?this._valueSet(""):(d=s().slice(),E(this,d))))}}).bind("focus.inputmask",function(){var a=f(this),b=this._valueGet();c.showMaskOnFocus&&!a.hasClass("focus-inputmask")&&(!c.showMaskOnHover||c.showMaskOnHover&&""==b)&&this._valueGet()!=
g().join("")&&E(this,g(),C(p()));a.addClass("focus-inputmask");J=g().join("")}).bind("mouseleave.inputmask",function(){var a=f(this);c.clearMaskOnLostFocus&&(a.hasClass("focus-inputmask")||this._valueGet()==a.attr("placeholder")||(this._valueGet()==s().join("")||""==this._valueGet()?this._valueSet(""):ca(this)))}).bind("click.inputmask",function(){var a=this;f(a).is(":focus")&&setTimeout(function(){var b=q(a);if(b.begin==b.end){var b=B?P(b.begin):b.begin,c=p(b),c=C(c);b<c?h(b)?q(a,b):q(a,C(b)):q(a,
c)}},0)}).bind("dblclick.inputmask",function(){var a=this;setTimeout(function(){q(a,0,C(p()))},0)}).bind(Z+".inputmask dragdrop.inputmask drop.inputmask",ha).bind("setvalue.inputmask",function(){R(this,!0,!1,void 0,!0);J=g().join("")}).bind("complete.inputmask",c.oncomplete).bind("incomplete.inputmask",c.onincomplete).bind("cleared.inputmask",c.oncleared);n.bind("keydown.inputmask",ga).bind("keypress.inputmask",X).bind("keyup.inputmask",ra).bind("compositionupdate.inputmask",ua);"paste"===Z&&n.bind("input.inputmask",
ta);if(la||na||ma||oa)"input"==Z&&n.unbind(Z+".inputmask"),n.bind("input.inputmask",sa);ja&&n.bind("input.inputmask",ha);qa(a);b=f.isFunction(c.onBeforeMask)?c.onBeforeMask.call(a,a._valueGet(),c):a._valueGet();R(a,!0,!1,b.split(""),!0);J=g().join("");var k;try{k=document.activeElement}catch(u){}!1===T(g())&&c.clearIncomplete&&A();c.clearMaskOnLostFocus?g().join("")==s().join("")?a._valueSet(""):ca(a):E(a,g());k===a&&(n.addClass("focus-inputmask"),q(a,C(p())));pa(a)}}var B=!1,J,n,Y=!1,O=!1,aa=!1,
M;if(void 0!=b)switch(b.action){case "isComplete":return n=f(b.el),d=n.data("_inputmask").maskset,c=n.data("_inputmask").opts,T(b.buffer);case "unmaskedvalue":return n=b.$input,d=n.data("_inputmask").maskset,c=n.data("_inputmask").opts,B=b.$input.data("_inputmask").isRTL,da(b.$input);case "mask":J=g().join("");va(b.el);break;case "format":n=f({});n.data("_inputmask",{maskset:d,opts:c,isRTL:c.numericInput});c.numericInput&&(B=!0);var G=(f.isFunction(c.onBeforeMask)?c.onBeforeMask.call(n,b.value,c):
b.value).split("");R(n,!1,!1,B?G.reverse():G,!0);c.onKeyPress.call(this,void 0,g(),0,c);return B?g().slice().reverse().join(""):g().join("");case "isValid":n=f({});n.data("_inputmask",{maskset:d,opts:c,isRTL:c.numericInput});c.numericInput&&(B=!0);G=b.value.split("");R(n,!1,!0,B?G.reverse():G);var G=g(),I=ba();G.length=I;return T(G)&&b.value==G.join("");case "getemptymask":return n=f(b.el),d=n.data("_inputmask").maskset,c=n.data("_inputmask").opts,s();case "remove":var z=b.el;n=f(z);d=n.data("_inputmask").maskset;
c=n.data("_inputmask").opts;z._valueSet(da(n));n.unbind(".inputmask");n.removeClass("focus-inputmask");n.removeData("_inputmask");Object.getOwnPropertyDescriptor&&(I=Object.getOwnPropertyDescriptor(z,"value"));I&&I.get?z._valueGet&&Object.defineProperty(z,"value",{get:z._valueGet,set:z._valueSet}):document.__lookupGetter__&&z.__lookupGetter__("value")&&z._valueGet&&(z.__defineGetter__("value",z._valueGet),z.__defineSetter__("value",z._valueSet));try{delete z._valueGet,delete z._valueSet}catch(wa){z._valueGet=
void 0,z._valueSet=void 0}break;case "getmetadata":n=f(b.el);d=n.data("_inputmask").maskset;c=n.data("_inputmask").opts;if(f.isArray(d.metadata)){for(I=b=p();0<=I;I--)if(d.validPositions[I]&&void 0!=d.validPositions[I].alternation){G=d.validPositions[I].alternation;break}return void 0!=G?d.metadata[d.validPositions[b].locator[G]]:d.metadata[0]}return d.metadata}};f.inputmask={defaults:{placeholder:"_",optionalmarker:{start:"[",end:"]"},quantifiermarker:{start:"{",end:"}"},groupmarker:{start:"(",end:")"},
alternatormarker:"|",escapeChar:"\\",mask:null,oncomplete:f.noop,onincomplete:f.noop,oncleared:f.noop,repeat:0,greedy:!0,autoUnmask:!1,removeMaskOnSubmit:!0,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,aliases:{},alias:null,onKeyUp:f.noop,onKeyPress:f.noop,onKeyDown:f.noop,onBeforeMask:void 0,onBeforePaste:void 0,onUnMask:void 0,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:f.noop,skipOptionalPartCharacter:" ",showTooltip:!1,numericInput:!1,rightAlign:!1,radixPoint:"",nojumps:!1,
nojumpsThreshold:0,keepStatic:void 0,definitions:{9:{validator:"[0-9]",cardinality:1,definitionSymbol:"*"},a:{validator:"[A-Za-z\u0410-\u044f\u0401\u0451\u00c0-\u00ff\u00b5]",cardinality:1,definitionSymbol:"*"},"*":{validator:"[0-9A-Za-z\u0410-\u044f\u0401\u0451\u00c0-\u00ff\u00b5]",cardinality:1}},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,
NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91},ignorables:[8,9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123],isComplete:void 0},masksCache:{},escapeRegex:function(b){return b.replace(RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","gim"),"\\$1")},format:function(b,d){var c=f.extend(!0,{},f.inputmask.defaults,d);D(c.alias,d,c);
return K({action:"format",value:b},Q(c),c)},isValid:function(b,d){var c=f.extend(!0,{},f.inputmask.defaults,d);D(c.alias,d,c);return K({action:"isValid",value:b},Q(c),c)}};f.fn.inputmask=function(b,d,c,y,A){function p(b,c){var d=f(b),k;for(k in c){var p=d.data("inputmask-"+k.toLowerCase());void 0!=p&&(c[k]=p)}return c}c=c||K;y=y||"_inputmask";var k=f.extend(!0,{},f.inputmask.defaults,d),x;if("string"===typeof b)switch(b){case "mask":return D(k.alias,d,k),x=Q(k,c!==K),0==x.length?this:this.each(function(){c({action:"mask",
el:this},f.extend(!0,{},x),p(this,k))});case "unmaskedvalue":return b=f(this),b.data(y)?c({action:"unmaskedvalue",$input:b}):b.val();case "remove":return this.each(function(){f(this).data(y)&&c({action:"remove",el:this})});case "getemptymask":return this.data(y)?c({action:"getemptymask",el:this}):"";case "hasMaskedValue":return this.data(y)?!this.data(y).opts.autoUnmask:!1;case "isComplete":return this.data(y)?c({action:"isComplete",buffer:this[0]._valueGet().split(""),el:this}):!0;case "getmetadata":if(this.data(y))return c({action:"getmetadata",
el:this});break;case "_detectScope":return D(k.alias,d,k),void 0==A||D(A,d,k)||-1!=f.inArray(A,"mask unmaskedvalue remove getemptymask hasMaskedValue isComplete getmetadata _detectScope".split(" "))||(k.mask=A),f.isFunction(k.mask)&&(k.mask=k.mask.call(this,k)),f.isArray(k.mask);default:return D(k.alias,d,k),D(b,d,k)||(k.mask=b),x=Q(k,c!==K),void 0==x?this:this.each(function(){c({action:"mask",el:this},f.extend(!0,{},x),p(this,k))})}else{if("object"==typeof b)return k=f.extend(!0,{},f.inputmask.defaults,
b),D(k.alias,b,k),x=Q(k,c!==K),void 0==x?this:this.each(function(){c({action:"mask",el:this},f.extend(!0,{},x),p(this,k))});if(void 0==b)return this.each(function(){var b=f(this).attr("data-inputmask");if(b&&""!=b)try{var b=b.replace(RegExp("'","g"),'"'),p=f.parseJSON("{"+b+"}");f.extend(!0,p,d);k=f.extend(!0,{},f.inputmask.defaults,p);D(k.alias,p,k);k.alias=void 0;f(this).inputmask("mask",k,c)}catch(x){}})}}}return f.fn.inputmask});
