(function(e,t,n){typeof define=="function"&&define.amd?define(["jquery"],e):typeof exports=="object"&&typeof Meteor=="undefined"?module.exports=e(require("jquery")):e(t||n)})(function(e){"use strict";var t=function(t,n,r){var i={invalid:[],getCaret:function(){try{var e,n=0,r=t.get(0),s=document.selection,o=r.selectionStart;if(s&&navigator.appVersion.indexOf("MSIE 10")===-1)e=s.createRange(),e.moveStart("character",-i.val().length),n=e.text.length;else if(o||o==="0")n=o;return n}catch(u){}},setCaret:function(e){try{if(t.is(":focus")){var n,r=t.get(0);r.setSelectionRange?r.setSelectionRange(e,e):(n=r.createTextRange(),n.collapse(!0),n.moveEnd("character",e),n.moveStart("character",e),n.select())}}catch(i){}},events:function(){t.on("keydown.mask",function(e){t.data("mask-keycode",e.keyCode||e.which),t.data("mask-previus-value",t.val()),t.data("mask-previus-caret-pos",i.getCaret()),i.maskDigitPosMapOld=i.maskDigitPosMap}).on(e.jMaskGlobals.useInput?"input.mask":"keyup.mask",i.behaviour).on("paste.mask drop.mask",function(){setTimeout(function(){t.keydown().keyup()},100)}).on("change.mask",function(){t.data("changed",!0)}).on("blur.mask",function(){o!==i.val()&&!t.data("changed")&&t.trigger("change"),t.data("changed",!1)}).on("blur.mask",function(){o=i.val()}).on("focus.mask",function(t){r.selectOnFocus===!0&&e(t.target).select()}).on("focusout.mask",function(){r.clearIfNotMatch&&!u.test(i.val())&&i.val("")})},getRegexMask:function(){var e=[],t,r,i,o,u,a;for(var f=0;f0?(t[r]()!==e&&t[r](e),i=t):i=t[r](),i},calculateCaretPosition:function(e){var n=i.getMasked(),r=i.getCaret();if(e!==n){var s=t.data("mask-previus-caret-pos")||0,o=n.length,u=e.length,a=0,f=0,l=0,c=0,h=0;for(h=r;h=0;h--){if(!i.maskDigitPosMap[h])break;a++}for(h=r-1;h>=0;h--)i.maskDigitPosMap[h]&&l++;for(h=s-1;h>=0;h--)i.maskDigitPosMapOld[h]&&c++;if(r>u)r=o*10;else if(s>=r&&s!==u){if(!i.maskDigitPosMapOld[r]){var d=r;r-=c-l,r-=a,i.maskDigitPosMap[r]&&(r=d)}}else r>s&&(r+=l-c,r+=f)}return r},behaviour:function(n){n=n||window.event,i.invalid=[];var r=t.data("mask-keycode");if(e.inArray(r,s.byPassKeys)===-1){var o=i.getMasked(),u=i.getCaret(),a=t.data("mask-previus-value")||"";return setTimeout(function(){i.setCaret(i.calculateCaretPosition(a))},e.jMaskGlobals.keyStrokeCompensation),i.val(o),i.setCaret(u),i.callbacks(n)}},getMasked:function(e,t){var o=[],u=t===undefined?i.val():t+"",a=0,f=n.length,l=0,c=u.length,h=1,d="push",v=-1,m=0,g=[],y,b;r.reverse?(d="unshift",h=-1,y=0,a=f-1,l=c-1,b=function(){return a>-1&&l>-1}):(y=f-1,b=function(){return a0,[s,e,t,i.invalid,r])}};t=e(t);var s=this,o=i.val(),u;n=typeof n=="function"?n(i.val(),undefined,t,r):n,s.mask=n,s.options=r,s.remove=function(){var e=i.getCaret();return s.options.placeholder&&t.removeAttr("placeholder"),t.data("mask-maxlength")&&t.removeAttr("maxlength"),i.destroyEvents(),i.val(s.getCleanVal()),i.setCaret(e),t},s.getCleanVal=function(){return i.getMasked(!0)},s.getMaskedVal=function(e){return i.getMasked(!1,e)},s.init=function(o){o=o||!1,r=r||{},s.clearIfNotMatch=e.jMaskGlobals.clearIfNotMatch,s.byPassKeys=e.jMaskGlobals.byPassKeys,s.translation=e.extend({},e.jMaskGlobals.translation,r.translation),s=e.extend(!0,{},s,r),u=i.getRegexMask();if(o)i.events(),i.val(i.getMasked());else{r.placeholder&&t.attr("placeholder",r.placeholder),t.data("mask")&&t.attr("autocomplete","off");for(var a=0,f=!0;a