diff --git a/.travis.yml b/.travis.yml index b967aa4..3fe5984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ node_js: - "5" - "4" - "0.11" - - "0.10" before_install: - npm install -g bower diff --git a/bower.json b/bower.json index ca44308..6d4e2fc 100644 --- a/bower.json +++ b/bower.json @@ -25,6 +25,6 @@ "tests" ], "dependencies": { - "br-masks": "~0.4.1" + "br-masks": "~0.5.0" } } diff --git a/config/karma.conf.js b/config/karma.conf.js index 59817ed..38a424d 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -35,7 +35,7 @@ module.exports = function(config) { }, colors: true, autoWatch: false, - singleRun: false, + singleRun: true, browsers: ['Chrome'], customLaunchers: { Chrome_travis_ci: { diff --git a/gulpfile.js b/gulpfile.js index f96c58d..8fece18 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,13 +3,11 @@ var gulp = require('gulp'), browserify = require('browserify'), source = require('vinyl-source-stream'), buffer = require('vinyl-buffer'), - karma = require('karma').server, jshintReporter = require('jshint-stylish'), pkg = require(path.join(__dirname, 'package.json')), plugins = require('gulp-load-plugins')({ config: path.join(__dirname, 'package.json') - }), - fs = require('fs'); + }); var config = { src: { @@ -57,31 +55,3 @@ gulp.task('build', function() { gulp.task('default', ['jshint', 'build'], function() { gulp.watch(config.src.files, ['jshint', 'build']); }); - -gulp.task('test', function(done) { - var karmaConfig = { - singleRun: true, - configFile: __dirname + '/config/karma.conf.js' - }; - - karma.start(karmaConfig, done); -}); - -gulp.task('changelog', function(done) { - var changelog = require('conventional-changelog'); - - var options = { - repository: pkg.homepage, - version: pkg.version, - file: path.join(__dirname, 'CHANGELOG.md') - }; - - changelog(options, function(err, log) { - if (err) { - throw err; - } - - fs.writeFile(options.file, log, done); - }); -}); - diff --git a/package.json b/package.json index 44682b3..eda2fe1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "An Angular library of masks applicable to several Brazilian data.", "main": "src/filters.js", "scripts": { - "test": "gulp test" + "test": "karma start config/karma.conf.js", + "release": "conventional-changelog -p angular -i CHANGELOG.md -s" }, "repository": { "type": "git", @@ -28,31 +29,34 @@ }, "homepage": "https://github.com/the-darc/angular-br-filters", "dependencies": { - "br-masks": "^0.4.0" + "br-masks": "^0.5.0" }, "devDependencies": { - "angular": "^1.3.15", - "angular-mocks": "^1.3.15", - "browserify": "^11.0.1", - "browserify-istanbul": "^0.2.1", - "conventional-changelog": "0.0.17", + "angular": "~1.5.8", + "angular-mocks": "~1.5.8", + "browserify": "^13.1.1", + "browserify-istanbul": "^2.0.0", + "conventional-changelog": "1.1.0", "gulp": "^3.8.8", "gulp-concat": "^2.6.0", "gulp-footer": "^1.0.5", "gulp-header": "^1.1.1", - "gulp-jshint": "^1.9.0", - "gulp-load-plugins": "^0.6.0", + "gulp-jshint": "^2.0.2", + "gulp-load-plugins": "^1.4.0", "gulp-rename": "^1.2.2", - "gulp-uglify": "^1.0.1", + "gulp-uglify": "^2.0.0", + "istanbul": "^0.4.5", "jasmine-core": "^2.3.2", - "jshint-stylish": "^1.0.0", - "karma": "^0.12.31", - "karma-browserify": "^4.3.0", - "karma-chrome-launcher": "^0.1.10", - "karma-coverage": "^0.3.1", - "karma-coveralls": "^0.1.5", - "karma-jasmine": "^0.3.5", + "jshint": "^2.9.4", + "jshint-stylish": "^2.2.1", + "karma": "^1.3.0", + "karma-browserify": "^5.1.0", + "karma-chrome-launcher": "^2.0.0", + "karma-coverage": "^1.1.1", + "karma-coveralls": "^1.1.2", + "karma-jasmine": "^1.0.2", "vinyl-buffer": "^1.0.0", - "vinyl-source-stream": "^1.1.0" + "vinyl-source-stream": "^1.1.0", + "watchify": "^3.7.0" } } diff --git a/release/angular-br-filters.js b/release/angular-br-filters.js index 8f4b8ab..bc0adec 100644 --- a/release/angular-br-filters.js +++ b/release/angular-br-filters.js @@ -5,208 +5,268 @@ * @link https://github.com/the-darc/angular-br-filters * @license MIT */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0 && token && token.escape) { - token = tokens[pattern.charAt(i)]; - count += token && token.escape ? 1 : 0; - i--; - } - return count > 0 && count%2 === 1; - } - - function calcOptionalNumbersToUse(pattern, value) { - var numbersInP = pattern.replace(/[^0]/g,'').length; - var numbersInV = value.replace(/[^\d]/g,'').length; - return numbersInV - numbersInP; - } - - function concatChar(text, character, options, token) { - if (token && typeof token.transform === 'function') character = token.transform(character); - if (options.reverse) return character + text; - return text + character; - } - - function hasMoreTokens(pattern, pos, inc) { - var pc = pattern.charAt(pos); - var token = tokens[pc]; - if (pc === '') return false; - return token && !token.escape ? true : hasMoreTokens(pattern, pos + inc, inc); - } - - function insertChar(text, char, position) { - var t = text.split(''); - t.splice(position >= 0 ? position: 0, 0, char); - return t.join(''); - } - - function StringMask(pattern, opt) { - this.options = opt || {}; - this.options = { - reverse: this.options.reverse || false, - usedefaults: this.options.usedefaults || this.options.reverse - }; - this.pattern = pattern; - } - - StringMask.prototype.process = function proccess(value) { - if (!value) return ''; - value = value + ''; - var pattern2 = this.pattern; - var valid = true; - var formatted = ''; - var valuePos = this.options.reverse ? value.length - 1 : 0; - var optionalNumbersToUse = calcOptionalNumbersToUse(pattern2, value); - var escapeNext = false; - var recursive = []; - var inRecursiveMode = false; - - var steps = { - start: this.options.reverse ? pattern2.length - 1 : 0, - end: this.options.reverse ? -1 : pattern2.length, - inc: this.options.reverse ? -1 : 1 - }; - - function continueCondition(options) { - if (!inRecursiveMode && hasMoreTokens(pattern2, i, steps.inc)) { - return true; - } else if (!inRecursiveMode) { - inRecursiveMode = recursive.length > 0; - } - - if (inRecursiveMode) { - var pc = recursive.shift(); - recursive.push(pc); - if (options.reverse && valuePos >= 0) { - i++; - pattern2 = insertChar(pattern2, pc, i); - return true; - } else if (!options.reverse && valuePos < value.length) { - pattern2 = insertChar(pattern2, pc, i); - return true; - } - } - return i < pattern2.length && i >= 0; - } - - for (var i = steps.start; continueCondition(this.options); i = i + steps.inc) { - var pc = pattern2.charAt(i); - var vc = value.charAt(valuePos); - var token = tokens[pc]; - if (!inRecursiveMode || vc) { - if (this.options.reverse && isEscaped(pattern2, i)) { - formatted = concatChar(formatted, pc, this.options, token); - i = i + steps.inc; - continue; - } else if (!this.options.reverse && escapeNext) { - formatted = concatChar(formatted, pc, this.options, token); - escapeNext = false; - continue; - } else if (!this.options.reverse && token && token.escape) { - escapeNext = true; - continue; - } - } - - if (!inRecursiveMode && token && token.recursive) { - recursive.push(pc); - } else if (inRecursiveMode && !vc) { - if (!token || !token.recursive) formatted = concatChar(formatted, pc, this.options, token); - continue; - } else if (recursive.length > 0 && token && !token.recursive) { - // Recursive tokens most be the last tokens of the pattern - valid = false; - continue; - } else if (!inRecursiveMode && recursive.length > 0 && !vc) { - continue; - } - - if (!token) { - formatted = concatChar(formatted, pc, this.options, token); - if (!inRecursiveMode && recursive.length) { - recursive.push(pc); - } - } else if (token.optional) { - if (token.pattern.test(vc) && optionalNumbersToUse) { - formatted = concatChar(formatted, vc, this.options, token); - valuePos = valuePos + steps.inc; - optionalNumbersToUse--; - } else if (recursive.length > 0 && vc) { - valid = false; - break; - } - } else if (token.pattern.test(vc)) { - formatted = concatChar(formatted, vc, this.options, token); - valuePos = valuePos + steps.inc; - } else if (!vc && token._default && this.options.usedefaults) { - formatted = concatChar(formatted, token._default, this.options, token); - } else { - valid = false; - break; - } - } - - return {result: formatted, valid: valid}; - }; - - StringMask.prototype.apply = function(value) { - return this.process(value).result; - }; - - StringMask.prototype.validate = function(value) { - return this.process(value).valid; - }; - - StringMask.process = function(value, pattern, options) { - return new StringMask(pattern, options).process(value); - }; - - StringMask.apply = function(value, pattern, options) { - return new StringMask(pattern, options).apply(value); - }; - - StringMask.validate = function(value, pattern, options) { - return new StringMask(pattern, options).validate(value); - }; - - return StringMask; +(function(root, factory) { + /* istanbul ignore next */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.StringMask = factory(); + } +}(this, function() { + var tokens = { + '0': {pattern: /\d/, _default: '0'}, + '9': {pattern: /\d/, optional: true}, + '#': {pattern: /\d/, optional: true, recursive: true}, + 'A': {pattern: /[a-zA-Z0-9]/}, + 'S': {pattern: /[a-zA-Z]/}, + 'U': {pattern: /[a-zA-Z]/, transform: function(c) { return c.toLocaleUpperCase(); }}, + 'L': {pattern: /[a-zA-Z]/, transform: function(c) { return c.toLocaleLowerCase(); }}, + '$': {escape: true} + }; + + function isEscaped(pattern, pos) { + var count = 0; + var i = pos - 1; + var token = {escape: true}; + while (i >= 0 && token && token.escape) { + token = tokens[pattern.charAt(i)]; + count += token && token.escape ? 1 : 0; + i--; + } + return count > 0 && count % 2 === 1; + } + + function calcOptionalNumbersToUse(pattern, value) { + var numbersInP = pattern.replace(/[^0]/g,'').length; + var numbersInV = value.replace(/[^\d]/g,'').length; + return numbersInV - numbersInP; + } + + function concatChar(text, character, options, token) { + if (token && typeof token.transform === 'function') { + character = token.transform(character); + } + if (options.reverse) { + return character + text; + } + return text + character; + } + + function hasMoreTokens(pattern, pos, inc) { + var pc = pattern.charAt(pos); + var token = tokens[pc]; + if (pc === '') { + return false; + } + return token && !token.escape ? true : hasMoreTokens(pattern, pos + inc, inc); + } + + function hasMoreRecursiveTokens(pattern, pos, inc) { + var pc = pattern.charAt(pos); + var token = tokens[pc]; + if (pc === '') { + return false; + } + return token && token.recursive ? true : hasMoreRecursiveTokens(pattern, pos + inc, inc); + } + + function insertChar(text, char, position) { + var t = text.split(''); + t.splice(position, 0, char); + return t.join(''); + } + + function StringMask(pattern, opt) { + this.options = opt || {}; + this.options = { + reverse: this.options.reverse || false, + usedefaults: this.options.usedefaults || this.options.reverse + }; + this.pattern = pattern; + } + + StringMask.prototype.process = function proccess(value) { + if (!value) { + return {result: '', valid: false}; + } + value = value + ''; + var pattern2 = this.pattern; + var valid = true; + var formatted = ''; + var valuePos = this.options.reverse ? value.length - 1 : 0; + var patternPos = 0; + var optionalNumbersToUse = calcOptionalNumbersToUse(pattern2, value); + var escapeNext = false; + var recursive = []; + var inRecursiveMode = false; + + var steps = { + start: this.options.reverse ? pattern2.length - 1 : 0, + end: this.options.reverse ? -1 : pattern2.length, + inc: this.options.reverse ? -1 : 1 + }; + + function continueCondition(options) { + if (!inRecursiveMode && !recursive.length && hasMoreTokens(pattern2, patternPos, steps.inc)) { + // continue in the normal iteration + return true; + } else if (!inRecursiveMode && recursive.length && + hasMoreRecursiveTokens(pattern2, patternPos, steps.inc)) { + // continue looking for the recursive tokens + // Note: all chars in the patterns after the recursive portion will be handled as static string + return true; + } else if (!inRecursiveMode) { + // start to handle the recursive portion of the pattern + inRecursiveMode = recursive.length > 0; + } + + if (inRecursiveMode) { + var pc = recursive.shift(); + recursive.push(pc); + if (options.reverse && valuePos >= 0) { + patternPos++; + pattern2 = insertChar(pattern2, pc, patternPos); + return true; + } else if (!options.reverse && valuePos < value.length) { + pattern2 = insertChar(pattern2, pc, patternPos); + return true; + } + } + return patternPos < pattern2.length && patternPos >= 0; + } + + /** + * Iterate over the pattern's chars parsing/matching the input value chars + * until the end of the pattern. If the pattern ends with recursive chars + * the iteration will continue until the end of the input value. + * + * Note: The iteration must stop if an invalid char is found. + */ + for (patternPos = steps.start; continueCondition(this.options); patternPos = patternPos + steps.inc) { + // Value char + var vc = value.charAt(valuePos); + // Pattern char to match with the value char + var pc = pattern2.charAt(patternPos); + + var token = tokens[pc]; + if (recursive.length && token && !token.recursive) { + // In the recursive portion of the pattern: tokens not recursive must be seen as static chars + token = null; + } + + // 1. Handle escape tokens in pattern + // go to next iteration: if the pattern char is a escape char or was escaped + if (!inRecursiveMode || vc) { + if (this.options.reverse && isEscaped(pattern2, patternPos)) { + // pattern char is escaped, just add it and move on + formatted = concatChar(formatted, pc, this.options, token); + // skip escape token + patternPos = patternPos + steps.inc; + continue; + } else if (!this.options.reverse && escapeNext) { + // pattern char is escaped, just add it and move on + formatted = concatChar(formatted, pc, this.options, token); + escapeNext = false; + continue; + } else if (!this.options.reverse && token && token.escape) { + // mark to escape the next pattern char + escapeNext = true; + continue; + } + } + + // 2. Handle recursive tokens in pattern + // go to next iteration: if the value str is finished or + // if there is a normal token in the recursive portion of the pattern + if (!inRecursiveMode && token && token.recursive) { + // save it to repeat in the end of the pattern and handle the value char now + recursive.push(pc); + } else if (inRecursiveMode && !vc) { + // in recursive mode but value is finished. Add the pattern char if it is not a recursive token + formatted = concatChar(formatted, pc, this.options, token); + continue; + } else if (!inRecursiveMode && recursive.length > 0 && !vc) { + // recursiveMode not started but already in the recursive portion of the pattern + continue; + } + + // 3. Handle the value + // break iterations: if value is invalid for the given pattern + if (!token) { + // add char of the pattern + formatted = concatChar(formatted, pc, this.options, token); + if (!inRecursiveMode && recursive.length) { + // save it to repeat in the end of the pattern + recursive.push(pc); + } + } else if (token.optional) { + // if token is optional, only add the value char if it matchs the token pattern + // if not, move on to the next pattern char + if (token.pattern.test(vc) && optionalNumbersToUse) { + formatted = concatChar(formatted, vc, this.options, token); + valuePos = valuePos + steps.inc; + optionalNumbersToUse--; + } else if (recursive.length > 0 && vc) { + valid = false; + break; + } + } else if (token.pattern.test(vc)) { + // if token isn't optional the value char must match the token pattern + formatted = concatChar(formatted, vc, this.options, token); + valuePos = valuePos + steps.inc; + } else if (!vc && token._default && this.options.usedefaults) { + // if the token isn't optional and has a default value, use it if the value is finished + formatted = concatChar(formatted, token._default, this.options, token); + } else { + // the string value don't match the given pattern + valid = false; + break; + } + } + + return {result: formatted, valid: valid}; + }; + + StringMask.prototype.apply = function(value) { + return this.process(value).result; + }; + + StringMask.prototype.validate = function(value) { + return this.process(value).valid; + }; + + StringMask.process = function(value, pattern, options) { + return new StringMask(pattern, options).process(value); + }; + + StringMask.apply = function(value, pattern, options) { + return new StringMask(pattern, options).apply(value); + }; + + StringMask.validate = function(value, pattern, options) { + return new StringMask(pattern, options).validate(value); + }; + + return StringMask; })); },{}],2:[function(require,module,exports){ /** * br-masks * A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others - * @version v0.4.0 + * @version v0.5.0 * @link http://github.com/the-darc/br-masks * @license MIT */ (function (root, factory) { + /* istanbul ignore next */ if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['string-mask'], factory); @@ -220,6 +280,7 @@ root.BrM = factory(root.StringMask); } }(this, function (StringMask) { + /* istanbul ignore if */ if (!StringMask) { throw new Error('StringMask not found'); } @@ -233,6 +294,16 @@ var CEP = function(value) { return processed.result; }; +/*exported CNPJBASE */ +var CNPJBASE = function(value) { + if(!value) { + return value; + } + var cnpjBasePattern = new StringMask('00.000.000'); + var formatedValue = cnpjBasePattern.apply(value); + return formatedValue; +}; + /*exported CNPJ */ var CNPJ = function(value) { if(!value) { @@ -375,7 +446,8 @@ var NFEACCESSKEY = function(value) { /*exported PHONE */ var PHONE = function(value) { var phoneMask8D = new StringMask('(00) 0000-0000'), - phoneMask9D = new StringMask('(00) 00000-0000'); + phoneMask9D = new StringMask('(00) 00000-0000'), + phoneMask0800 = new StringMask('0000-000-0000'); if(!value) { return value; @@ -383,7 +455,9 @@ var PHONE = function(value) { var formatedValue; value = value + ''; - if(value.length < 11){ + if (value.indexOf('0800') === 0) { + formatedValue = phoneMask0800.apply(value); + }else if(value.length < 11){ formatedValue = phoneMask8D.apply(value); }else{ formatedValue = phoneMask9D.apply(value); @@ -396,6 +470,7 @@ var PHONE = function(value) { ie: IE, cpf: CPF, cnpj: CNPJ, + cnpjBase: CNPJBASE, phone: PHONE, cep: CEP, finance: FINANCE, diff --git a/release/angular-br-filters.min.js b/release/angular-br-filters.min.js index 5958cdd..5b009a5 100644 --- a/release/angular-br-filters.min.js +++ b/release/angular-br-filters.min.js @@ -1 +1 @@ -!function e(n,r,t){function i(o,a){if(!r[o]){if(!n[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[o]={exports:{}};n[o][0].call(c.exports,function(e){var r=n[o][1][e];return i(r?r:e)},c,c.exports,e,n,r,t)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o=0&&i&&i.escape;)i=o[e.charAt(t)],r+=i&&i.escape?1:0,t--;return r>0&&r%2===1}function n(e,n){var r=e.replace(/[^0]/g,"").length,t=n.replace(/[^\d]/g,"").length;return t-r}function r(e,n,r,t){return t&&"function"==typeof t.transform&&(n=t.transform(n)),r.reverse?n+e:e+n}function t(e,n,r){var i=e.charAt(n),s=o[i];return""===i?!1:s&&!s.escape?!0:t(e,n+r,r)}function i(e,n,r){var t=e.split("");return t.splice(r>=0?r:0,0,n),t.join("")}function s(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var o={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return s.prototype.process=function(s){function a(e){if(!w&&t(u,k,m.inc))return!0;if(w||(w=v.length>0),w){var n=v.shift();if(v.push(n),e.reverse&&p>=0)return k++,u=i(u,n,k),!0;if(!e.reverse&&p=0}if(!s)return"";s+="";for(var u=this.pattern,f=!0,c="",p=this.options.reverse?s.length-1:0,l=n(u,s),h=!1,v=[],w=!1,m={start:this.options.reverse?u.length-1:0,end:this.options.reverse?-1:u.length,inc:this.options.reverse?-1:1},k=m.start;a(this.options);k+=m.inc){var d=u.charAt(k),g=s.charAt(p),y=o[d];if(!w||g){if(this.options.reverse&&e(u,k)){c=r(c,d,this.options,y),k+=m.inc;continue}if(!this.options.reverse&&h){c=r(c,d,this.options,y),h=!1;continue}if(!this.options.reverse&&y&&y.escape){h=!0;continue}}if(!w&&y&&y.recursive)v.push(d);else{if(w&&!g){y&&y.recursive||(c=r(c,d,this.options,y));continue}if(v.length>0&&y&&!y.recursive){f=!1;continue}if(!w&&v.length>0&&!g)continue}if(y)if(y.optional){if(y.pattern.test(g)&&l)c=r(c,g,this.options,y),p+=m.inc,l--;else if(v.length>0&&g){f=!1;break}}else if(y.pattern.test(g))c=r(c,g,this.options,y),p+=m.inc;else{if(g||!y._default||!this.options.usedefaults){f=!1;break}c=r(c,y._default,this.options,y)}else c=r(c,d,this.options,y),!w&&v.length&&v.push(d)}return{result:c,valid:f}},s.prototype.apply=function(e){return this.process(e).result},s.prototype.validate=function(e){return this.process(e).valid},s.process=function(e,n,r){return new s(n,r).process(e)},s.apply=function(e,n,r){return new s(n,r).apply(e)},s.validate=function(e,n,r){return new s(n,r).validate(e)},s})},{}],2:[function(e,n,r){!function(t,i){"function"==typeof define&&define.amd?define(["string-mask"],i):"object"==typeof r?n.exports=i(e("string-mask")):t.BrM=i(t.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var r=new e("00000-000");if(!n)return n;var t=r.process(n);return t.result},r=function(n){if(!n)return n;var r=new e("00.000.000/0000-00"),t=r.apply(n);return t},t=function(e){return e&&e.length?e.length<=11?i(e):r(e):e},i=function(n){var r=new e("000.000.000-00");if(!n)return n;var t=r.apply(n);return t},s=function(n,r,t,i){r=!r&&0!==r||0>r?2:r,t=t||".",i=i||"";var s=r>0?t+new Array(r+1).join("0"):"",o="#"+i+"##0"+s;n=parseFloat(n),n||(n=0);var a=!1;0>n&&(n=-1*n,a=!0);var u=new e(o,{reverse:!0}),f=u.apply(n.toFixed(r).replace(/[^\d]+/g,""));return a?"("+f+")":f},o=function(n,r){function t(e){return e.replace(/[^0-9]/g,"")}function i(e,n){if(!e||!s[e])return void 0;var r=e.toUpperCase();if("SP"===r&&/^P/i.test(n))return s.SP[1].mask;for(var i=s[e],o=0;i[o].chars&&i[o].charsnew Date)return void 0;var i=Date.now()-t.getTime(),s=new Date(i);return Math.abs(s.getUTCFullYear()-1970)}})},{"br-masks":2}]},{},[3]); \ No newline at end of file +!function e(n,r,t){function i(a,o){if(!r[a]){if(!n[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};n[a][0].call(c.exports,function(e){var r=n[a][1][e];return i(r?r:e)},c,c.exports,e,n,r,t)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a=0&&i&&i.escape;)i=o[e.charAt(t)],r+=i&&i.escape?1:0,t--;return r>0&&r%2===1}function n(e,n){var r=e.replace(/[^0]/g,"").length,t=n.replace(/[^\d]/g,"").length;return t-r}function r(e,n,r,t){return t&&"function"==typeof t.transform&&(n=t.transform(n)),r.reverse?n+e:e+n}function t(e,n,r){var i=e.charAt(n),s=o[i];return""!==i&&(!(!s||s.escape)||t(e,n+r,r))}function i(e,n,r){var t=e.charAt(n),s=o[t];return""!==t&&(!(!s||!s.recursive)||i(e,n+r,r))}function s(e,n,r){var t=e.split("");return t.splice(r,0,n),t.join("")}function a(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var o={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return a.prototype.process=function(a){function u(e){if(!k&&!m.length&&t(f,h,d.inc))return!0;if(!k&&m.length&&i(f,h,d.inc))return!0;if(k||(k=m.length>0),k){var n=m.shift();if(m.push(n),e.reverse&&l>=0)return h++,f=s(f,n,h),!0;if(!e.reverse&&l=0}if(!a)return{result:"",valid:!1};a+="";var f=this.pattern,c=!0,p="",l=this.options.reverse?a.length-1:0,h=0,v=n(f,a),w=!1,m=[],k=!1,d={start:this.options.reverse?f.length-1:0,end:this.options.reverse?-1:f.length,inc:this.options.reverse?-1:1};for(h=d.start;u(this.options);h+=d.inc){var g=a.charAt(l),y=f.charAt(h),A=o[y];if(m.length&&A&&!A.recursive&&(A=null),!k||g){if(this.options.reverse&&e(f,h)){p=r(p,y,this.options,A),h+=d.inc;continue}if(!this.options.reverse&&w){p=r(p,y,this.options,A),w=!1;continue}if(!this.options.reverse&&A&&A.escape){w=!0;continue}}if(!k&&A&&A.recursive)m.push(y);else{if(k&&!g){p=r(p,y,this.options,A);continue}if(!k&&m.length>0&&!g)continue}if(A)if(A.optional){if(A.pattern.test(g)&&v)p=r(p,g,this.options,A),l+=d.inc,v--;else if(m.length>0&&g){c=!1;break}}else if(A.pattern.test(g))p=r(p,g,this.options,A),l+=d.inc;else{if(g||!A._default||!this.options.usedefaults){c=!1;break}p=r(p,A._default,this.options,A)}else p=r(p,y,this.options,A),!k&&m.length&&m.push(y)}return{result:p,valid:c}},a.prototype.apply=function(e){return this.process(e).result},a.prototype.validate=function(e){return this.process(e).valid},a.process=function(e,n,r){return new a(n,r).process(e)},a.apply=function(e,n,r){return new a(n,r).apply(e)},a.validate=function(e,n,r){return new a(n,r).validate(e)},a})},{}],2:[function(e,n,r){!function(t,i){"function"==typeof define&&define.amd?define(["string-mask"],i):"object"==typeof r?n.exports=i(e("string-mask")):t.BrM=i(t.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var r=new e("00000-000");if(!n)return n;var t=r.process(n);return t.result},r=function(n){if(!n)return n;var r=new e("00.000.000"),t=r.apply(n);return t},t=function(n){if(!n)return n;var r=new e("00.000.000/0000-00"),t=r.apply(n);return t},i=function(e){return e&&e.length?e.length<=11?s(e):t(e):e},s=function(n){var r=new e("000.000.000-00");if(!n)return n;var t=r.apply(n);return t},a=function(n,r,t,i){r=!r&&0!==r||r<0?2:r,t=t||".",i=i||"";var s=r>0?t+new Array(r+1).join("0"):"",a="#"+i+"##0"+s;n=parseFloat(n),n||(n=0);var o=!1;n<0&&(n*=-1,o=!0);var u=new e(a,{reverse:!0}),f=u.apply(n.toFixed(r).replace(/[^\d]+/g,""));return o?"("+f+")":f},o=function(n,r){function t(e){return e.replace(/[^0-9]/g,"")}function i(e,n){if(e&&s[e]){var r=e.toUpperCase();if("SP"===r&&/^P/i.test(n))return s.SP[1].mask;for(var i=s[e],a=0;i[a].chars&&i[a].charsnew Date)){var i=Date.now()-t.getTime(),s=new Date(i);return Math.abs(s.getUTCFullYear()-1970)}}}}})},{"br-masks":2}]},{},[3]); \ No newline at end of file