text: /**
   * jquery.meio.mask.js
   * @author: fabiomcosta
   * @version: 1.1.11
   *
   * Created by Fabio M. Costa on 2008-09-16. Please report any bug at http://www.meiocodigo.com
   *
   * Copyright (c) 2008 Fabio M. Costa http://www.meiocodigo.com
   *
   * The MIT License (http://www.opensource.org/licenses/mit-license.php)
   *
   * Permission is hereby granted, free of charge, to any person
   * obtaining a copy of this software and associated documentation
   * files (the "Software"), to deal in the Software without
   * restriction, including without limitation the rights to use,
   * copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the
   * Software is furnished to do so, subject to the following
   * conditions:
   *
   * The above copyright notice and this permission notice shall be
   * included in all copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
   * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   * OTHER DEALINGS IN THE SOFTWARE.
   */
  !function(e){if(!e.browser){var t=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return t[2]||"0"};e.browser={mozilla:/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),webkit:/webkit/.test(navigator.userAgent.toLowerCase()),opera:/opera/.test(navigator.userAgent.toLowerCase()),msie:/msie/.test(navigator.userAgent.toLowerCase()),android:navigator.userAgent.toLowerCase().indexOf("mozilla/5.0")>-1&&navigator.userAgent.toLowerCase().indexOf("android ")>-1&&navigator.userAgent.toLowerCase().indexOf("applewebkit")>-1,version:t(navigator.userAgent)}}var a=null!=window.orientation,n=e.browser.opera||e.browser.mozilla&&parseFloat(e.browser.version.substr(0,3))<1.9?"input":"paste",s=function(t){t=e.event.fix(t||window.event),t.type="paste";var a=t.target;setTimeout(function(){e.event.dispatch.call(a,t)},1)};e.event.special.paste={setup:function(){this.addEventListener?this.addEventListener(n,s,!1):this.attachEvent&&this.attachEvent("on"+n,s)},teardown:function(){this.removeEventListener?this.removeEventListener(n,s,!1):this.detachEvent&&this.detachEvent("on"+n,s)}},e.extend({mask:{rules:{z:/[a-z]/,Z:/[A-Z]/,a:/[a-zA-Z]/,"*":/[0-9a-zA-Z]/,"@":/[0-9a-zA-ZçÇáàãâéèêíìóòôõúùü]/},keyRepresentation:{8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"alt",27:"esc",33:"page up",34:"page down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",116:"f5",123:"f12",224:"command"},signals:{"+":"","-":"-"},options:{attr:"alt",mask:null,type:"fixed",maxLength:-1,defaultValue:"",signal:!1,textAlign:!0,selectCharsOnFocus:!0,autoTab:!0,setSize:!1,fixedChars:"[(),.:/ -]",onInvalid:function(){},onValid:function(){},onOverflow:function(){},onFocus:function(){},onBlur:function(){}},masks:{phone:{mask:"(99) 9999-9999"},"phone-us":{mask:"(999) 999-9999"},cpf:{mask:"999.999.999-99"},cnpj:{mask:"99.999.999/9999-99"},date:{mask:"39/19/9999"},"date-us":{mask:"19/39/9999"},cep:{mask:"99999-999"},time:{mask:"29:59"},cc:{mask:"9999 9999 9999 9999"},integer:{mask:"999.999.999.999",type:"reverse"},decimal:{mask:"99,999.999.999.999",type:"reverse",defaultValue:"000"},"decimal-us":{mask:"99.999,999,999,999",type:"reverse",defaultValue:"000"},"signed-decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"},"signed-decimal-us":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"}},init:function(){if(!this.hasInit){var t,a=this,n=this.keyRepresentation;for(this.ignore=!1,t=0;9>=t;t++)this.rules[t]=new RegExp("[0-"+t+"]");this.keyRep=n,this.ignoreKeys=[],e.each(n,function(e){a.ignoreKeys.push(parseInt(e,10))}),this.hasInit=!0}},set:function(t,a){var n=this,s=e(t),r="maxLength";return a=a||{},this.init(),s.each(function(){a.attr&&(n.options.attr=a.attr);var t=e(this),s=e.extend({},n.options),i=t.attr(s.attr),o="";if(o="string"==typeof a?a:""!==i?i:null,o&&(s.mask=o),n.masks[o]&&(s=e.extend(s,n.masks[o])),"object"==typeof a&&a.constructor!=Array&&(s=e.extend(s,a)),e.metadata&&(s=e.extend(s,t.metadata())),null!=s.mask){s.mask+="",t.data("mask")&&n.unset(t);var u=s.defaultValue,l="reverse"===s.type,h=new RegExp(s.fixedChars,"g");if(-1===s.maxLength&&(s.maxLength=t.attr(r)),s=e.extend({},s,{fixedCharsReg:new RegExp(s.fixedChars),fixedCharsRegG:h,maskArray:s.mask.split(""),maskNonFixedCharsArray:s.mask.replace(h,"").split("")}),"fixed"!=s.type&&!l||!s.setSize||t.attr("size")||t.attr("size",s.mask.length),l&&s.textAlign&&t.css("text-align","right"),""!==this.value||""!==u){var d=n.string(""!==this.value?this.value:u,s);this.defaultValue=d,t.val(d)}"infinite"==s.type&&(s.type="repeat"),t.data("mask",s),t.removeAttr(r),t.bind("keydown.mask",{func:n._onKeyDown,thisObj:n},n._onMask).bind("keypress.mask",{func:n._onKeyPress,thisObj:n},n._onMask).bind("keyup.mask",{func:n._onKeyUp,thisObj:n},n._onMask).bind("paste.mask",{func:n._onPaste,thisObj:n},n._onMask).bind("drop.mask",{func:n._onPaste,thisObj:n},n._onMask).bind("focus.mask",n._onFocus).bind("blur.mask",n._onBlur).bind("change.mask",n._onChange)}})},unset:function(t){var a=e(t);return a.each(function(){var t=e(this);if(t.data("mask")){var a=t.data("mask").maxLength;-1!=a&&t.attr("maxLength",a),t.unbind(".mask").removeData("mask")}})},string:function(t,a){this.init();var n={};switch("string"!=typeof t&&(t=String(t)),typeof a){case"string":this.masks[a]?n=e.extend(n,this.masks[a]):n.mask=a;break;case"object":n=a}n.fixedChars||(n.fixedChars=this.options.fixedChars);var s=new RegExp(n.fixedChars),r=new RegExp(n.fixedChars,"g");if("reverse"===n.type&&n.defaultValue&&"undefined"!=typeof this.signals[n.defaultValue.charAt(0)]){var i=t.charAt(0);n.signal="undefined"!=typeof this.signals[i]?this.signals[i]:this.signals[n.defaultValue.charAt(0)],n.defaultValue=n.defaultValue.substring(1)}return this.__maskArray(t.split(""),n.mask.replace(r,"").split(""),n.mask.split(""),n.type,n.maxLength,n.defaultValue,s,n.signal)},_onFocus:function(t){var a=e(this),n=a.data("mask");n.inputFocusValue=a.val(),n.changed=!1,n.selectCharsOnFocus&&a.select(),n.onFocus(this,t)},_onBlur:function(t){var a=e(this),n=a.data("mask");n.inputFocusValue==a.val()||n.changed||a.trigger("change"),n.onBlur(this,t)},_onChange:function(){e(this).data("mask").changed=!0},_onMask:function(t){var a=t.data.thisObj,n={};return n._this=t.target,n.$this=e(n._this),n.data=n.$this.data("mask"),n.$this.attr("readonly")||!n.data?!0:(n[n.data.type]=!0,n.value=n.$this.val(),n.nKey=a.__getKeyNumber(t),n.range=a.__getRange(n._this),n.valueArray=n.value.split(""),t.data.func.call(a,t,n))},_onKeyDown:function(t,n){if(this.ignore=e.inArray(n.nKey,this.ignoreKeys)>-1||t.ctrlKey||t.metaKey||t.altKey,this.ignore){var s=this.keyRep[n.nKey];n.data.onValid.call(n._this,s||"",n.nKey)}return a?this._onKeyPress(t,n):!0},_onKeyUp:function(e,t){return 9===t.nKey||16===t.nKey?!0:t.repeat?(this.__autoTab(t),!0):this._onPaste(e,t)},_onPaste:function(t,a){a.reverse&&this.__changeSignal(t.type,a);var n=this.__maskArray(a.valueArray,a.data.maskNonFixedCharsArray,a.data.maskArray,a.data.type,a.data.maxLength,a.data.defaultValue,a.data.fixedCharsReg,a.data.signal);return a.$this.val(n),!a.reverse&&a.data.defaultValue.length&&a.range.start===a.range.end&&this.__setRange(a._this,a.range.start,a.range.end),!e.browser.msie&&!e.browser.safari||a.reverse||this.__setRange(a._this,a.range.start,a.range.end),this.ignore?!0:(this.__autoTab(a),!0)},_onKeyPress:function(e,t){if(this.ignore)return!0;t.reverse&&this.__changeSignal(e.type,t);var a=String.fromCharCode(t.nKey),n=t.range.start,s=t.value,r=t.data.maskArray;if(t.reverse){var i=s.substr(0,n),o=s.substr(t.range.end,s.length);s=i+a+o,t.data.signal&&n-t.data.signal.length>0&&(n-=t.data.signal.length)}var u=s.replace(t.data.fixedCharsRegG,"").split(""),l=this.__extraPositionsTill(n,r,t.data.fixedCharsReg);if(t.rsEp=n+l,t.repeat&&(t.rsEp=0),!this.rules[r[t.rsEp]]||-1!=t.data.maxLength&&u.length>=t.data.maxLength&&t.repeat)return t.data.onOverflow.call(t._this,a,t.nKey),!1;if(!this.rules[r[t.rsEp]].test(a))return t.data.onInvalid.call(t._this,a,t.nKey),!1;t.data.onValid.call(t._this,a,t.nKey);var h=this.__maskArray(u,t.data.maskNonFixedCharsArray,r,t.data.type,t.data.maxLength,t.data.defaultValue,t.data.fixedCharsReg,t.data.signal,l);return t.repeat||t.$this.val(h),t.reverse?this._keyPressReverse(e,t):t.fixed?this._keyPressFixed(e,t):!0},_keyPressFixed:function(e,t){return t.range.start==t.range.end?(0===t.rsEp&&0===t.value.length||t.rsEp<t.value.length)&&this.__setRange(t._this,t.rsEp,t.rsEp+1):this.__setRange(t._this,t.range.start,t.range.end),!0},_keyPressReverse:function(t,a){return e.browser.msie&&(0===a.range.start&&0===a.range.end||a.range.start!=a.range.end)&&this.__setRange(a._this,a.value.length),!1},__autoTab:function(e){if(e.data.autoTab&&(e.$this.val().length>=e.data.maskArray.length&&!e.repeat||-1!=e.data.maxLength&&e.valueArray.length>=e.data.maxLength&&e.repeat)){var t=this.__getNextInput(e._this,e.data.autoTab);t&&(e.$this.trigger("blur"),t.focus().select())}},__changeSignal:function(e,t){if(t.data.signal!==!1){var a="paste"===e?t.value.charAt(0):String.fromCharCode(t.nKey);this.signals&&"undefined"!=typeof this.signals[a]&&(t.data.signal=this.signals[a])}},__getKeyNumber:function(e){return e.charCode||e.keyCode||e.which},__maskArray:function(e,t,a,n,s,r,i,o,u){switch("reverse"===n&&e.reverse(),e=this.__removeInvalidChars(e,t,"repeat"===n||"infinite"===n),r&&(e=this.__applyDefaultValue.call(e,r)),e=this.__applyMask(e,a,u,i),n){case"reverse":return e.reverse(),(o||"")+e.join("").substring(e.length-a.length);case"infinite":case"repeat":var l=e.join("");return-1!==s&&e.length>=s?l.substring(0,s):l;default:return e.join("").substring(0,a.length)}return""},__applyDefaultValue:function(e){var t,a=e.length,n=this.length;for(t=n-1;t>=0&&this[t]==e.charAt(0);t--)this.pop();for(t=0;a>t;t++)this[t]||(this[t]=e.charAt(t));return this},__removeInvalidChars:function(e,t,a){for(var n=0,s=0;n<e.length;n++)t[s]&&this.rules[t[s]]&&!this.rules[t[s]].test(e[n])&&(e.splice(n,1),a||s--,n--),a||s++;return e},__applyMask:function(e,t,a,n){"undefined"==typeof a&&(a=0);for(var s=0;s<e.length+a;s++)t[s]&&n.test(t[s])&&e.splice(s,0,t[s]);return e},__extraPositionsTill:function(e,t,a){for(var n=0;a.test(t[e++]);)n++;return n},__getNextInput:function(t,a){var n=t.form;if(null==n)return null;var s,r=n.elements,i=e.inArray(t,r)+1,o=r.length,u=null;for(s=i;o>s;s++)if(u=e(r[s]),this.__isNextInput(u,a))return u;var l,h,d=document.forms,g=e.inArray(t.form,d)+1,f=d.length;for(l=g;f>l;l++)for(h=d[l].elements,o=h.length,s=0;o>s;s++)if(u=e(h[s]),this.__isNextInput(u,a))return u;return null},__isNextInput:function(e,t){var a=e.get(0);return a&&(a.offsetWidth>0||a.offsetHeight>0)&&"FIELDSET"!=a.nodeName&&(t===!0||"string"==typeof t&&e.is(t))},__setRange:function(e,t,a){if("undefined"==typeof a&&(a=t),e.setSelectionRange)e.setSelectionRange(t,a);else{var n=e.createTextRange();n.collapse(),n.moveStart("character",t),n.moveEnd("character",a-t),n.select()}},__getRange:function(t){if(!e.browser.msie&&!e.browser.android)return{start:t.selectionStart,end:t.selectionEnd};var a={start:0,end:0},n=document.selection.createRange();return a.start=0-n.duplicate().moveStart("character",-1e5),a.end=a.start+n.text.length,a},unmaskedVal:function(t){return e(t).val().replace(e.mask.fixedCharsRegG,"")}}}),e.fn.extend({setMask:function(t){return e.mask.set(this,t)},unsetMask:function(){return e.mask.unset(this)},unmaskedVal:function(){return e.mask.unmaskedVal(this[0])}})}(jQuery);