formtastic-jquery_inputmask 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.bowerrc +3 -0
  3. data/bower.json +19 -0
  4. data/lib/formtastic/jquery_inputmask/engine.rb +1 -1
  5. data/lib/formtastic/jquery_inputmask/version.rb +1 -1
  6. data/vendor/inputmask/.bower.json +59 -0
  7. data/vendor/inputmask/bower.json +40 -0
  8. data/vendor/inputmask/dist/inputmask/bindings/inputmask.binding.js +21 -0
  9. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js +62 -0
  10. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js +13 -0
  11. data/vendor/inputmask/dist/inputmask/dependencyLibs/inputmask.dependencyLib.js +133 -0
  12. data/vendor/inputmask/dist/inputmask/global/document.js +11 -0
  13. data/vendor/inputmask/dist/inputmask/global/window.js +11 -0
  14. data/vendor/inputmask/dist/inputmask/inputmask.date.extensions.js +490 -0
  15. data/vendor/inputmask/dist/inputmask/inputmask.extensions.js +97 -0
  16. data/vendor/inputmask/dist/inputmask/inputmask.js +1643 -0
  17. data/vendor/inputmask/dist/inputmask/inputmask.numeric.extensions.js +347 -0
  18. data/vendor/inputmask/dist/inputmask/inputmask.phone.extensions.js +61 -0
  19. data/vendor/inputmask/dist/inputmask/inputmask.regex.extensions.js +115 -0
  20. data/vendor/inputmask/dist/inputmask/jquery.inputmask.js +62 -0
  21. data/vendor/inputmask/dist/inputmask/phone-codes/phone-be.js +244 -0
  22. data/vendor/inputmask/dist/inputmask/phone-codes/phone-nl.js +924 -0
  23. data/vendor/inputmask/dist/inputmask/phone-codes/phone-ru.js +19240 -0
  24. data/vendor/inputmask/dist/inputmask/phone-codes/phone-uk.js +1009 -0
  25. data/vendor/inputmask/dist/inputmask/phone-codes/phone.js +2111 -0
  26. data/vendor/inputmask/dist/jquery.inputmask.bundle.js +3085 -0
  27. data/vendor/inputmask/dist/min/inputmask/inputmask.date.extensions.min.js +9 -0
  28. data/vendor/inputmask/dist/min/inputmask/inputmask.extensions.min.js +9 -0
  29. data/vendor/inputmask/dist/min/inputmask/inputmask.min.js +10 -0
  30. data/vendor/inputmask/dist/min/inputmask/inputmask.numeric.extensions.min.js +9 -0
  31. data/vendor/inputmask/dist/min/inputmask/inputmask.phone.extensions.min.js +9 -0
  32. data/vendor/inputmask/dist/min/inputmask/inputmask.regex.extensions.min.js +9 -0
  33. data/vendor/inputmask/dist/min/inputmask/jquery.inputmask.min.js +9 -0
  34. data/vendor/inputmask/dist/min/jquery.inputmask.bundle.min.js +11 -0
  35. data/vendor/jquery/.bower.json +25 -0
  36. data/vendor/jquery/AUTHORS.txt +301 -0
  37. data/vendor/jquery/LICENSE.txt +36 -0
  38. data/vendor/jquery/README.md +67 -0
  39. data/vendor/jquery/bower.json +14 -0
  40. data/vendor/jquery/dist/core.js +476 -0
  41. data/vendor/jquery/dist/jquery.js +10253 -0
  42. data/vendor/jquery/dist/jquery.min.js +4 -0
  43. data/vendor/jquery/dist/jquery.min.map +1 -0
  44. data/vendor/jquery/dist/jquery.slim.js +8160 -0
  45. data/vendor/jquery/dist/jquery.slim.min.js +4 -0
  46. data/vendor/jquery/dist/jquery.slim.min.map +1 -0
  47. data/vendor/jquery/external/sizzle/LICENSE.txt +36 -0
  48. data/vendor/jquery/external/sizzle/dist/sizzle.js +2272 -0
  49. data/vendor/jquery/external/sizzle/dist/sizzle.min.js +3 -0
  50. data/vendor/jquery/external/sizzle/dist/sizzle.min.map +1 -0
  51. data/vendor/jquery/src/.eslintrc.json +5 -0
  52. data/vendor/jquery/src/ajax.js +855 -0
  53. data/vendor/jquery/src/ajax/jsonp.js +102 -0
  54. data/vendor/jquery/src/ajax/load.js +76 -0
  55. data/vendor/jquery/src/ajax/parseXML.js +30 -0
  56. data/vendor/jquery/src/ajax/script.js +77 -0
  57. data/vendor/jquery/src/ajax/var/location.js +5 -0
  58. data/vendor/jquery/src/ajax/var/nonce.js +7 -0
  59. data/vendor/jquery/src/ajax/var/rquery.js +5 -0
  60. data/vendor/jquery/src/ajax/xhr.js +169 -0
  61. data/vendor/jquery/src/attributes.js +13 -0
  62. data/vendor/jquery/src/attributes/attr.js +141 -0
  63. data/vendor/jquery/src/attributes/classes.js +174 -0
  64. data/vendor/jquery/src/attributes/prop.js +143 -0
  65. data/vendor/jquery/src/attributes/support.js +33 -0
  66. data/vendor/jquery/src/attributes/val.js +190 -0
  67. data/vendor/jquery/src/callbacks.js +234 -0
  68. data/vendor/jquery/src/core.js +476 -0
  69. data/vendor/jquery/src/core/DOMEval.js +16 -0
  70. data/vendor/jquery/src/core/access.js +70 -0
  71. data/vendor/jquery/src/core/init.js +128 -0
  72. data/vendor/jquery/src/core/nodeName.js +13 -0
  73. data/vendor/jquery/src/core/parseHTML.js +65 -0
  74. data/vendor/jquery/src/core/ready-no-deferred.js +96 -0
  75. data/vendor/jquery/src/core/ready.js +86 -0
  76. data/vendor/jquery/src/core/readyException.js +13 -0
  77. data/vendor/jquery/src/core/stripAndCollapse.js +14 -0
  78. data/vendor/jquery/src/core/support.js +20 -0
  79. data/vendor/jquery/src/core/var/rsingleTag.js +6 -0
  80. data/vendor/jquery/src/css.js +438 -0
  81. data/vendor/jquery/src/css/addGetHookIf.js +26 -0
  82. data/vendor/jquery/src/css/adjustCSS.js +71 -0
  83. data/vendor/jquery/src/css/curCSS.js +65 -0
  84. data/vendor/jquery/src/css/hiddenVisibleSelectors.js +15 -0
  85. data/vendor/jquery/src/css/showHide.js +105 -0
  86. data/vendor/jquery/src/css/support.js +89 -0
  87. data/vendor/jquery/src/css/var/cssExpand.js +5 -0
  88. data/vendor/jquery/src/css/var/getStyles.js +17 -0
  89. data/vendor/jquery/src/css/var/isHiddenWithinTree.js +34 -0
  90. data/vendor/jquery/src/css/var/rmargin.js +5 -0
  91. data/vendor/jquery/src/css/var/rnumnonpx.js +7 -0
  92. data/vendor/jquery/src/css/var/swap.js +26 -0
  93. data/vendor/jquery/src/data.js +179 -0
  94. data/vendor/jquery/src/data/Data.js +161 -0
  95. data/vendor/jquery/src/data/var/acceptData.js +19 -0
  96. data/vendor/jquery/src/data/var/dataPriv.js +7 -0
  97. data/vendor/jquery/src/data/var/dataUser.js +7 -0
  98. data/vendor/jquery/src/deferred.js +391 -0
  99. data/vendor/jquery/src/deferred/exceptionHook.js +21 -0
  100. data/vendor/jquery/src/deprecated.js +40 -0
  101. data/vendor/jquery/src/dimensions.js +56 -0
  102. data/vendor/jquery/src/effects.js +699 -0
  103. data/vendor/jquery/src/effects/Tween.js +123 -0
  104. data/vendor/jquery/src/effects/animatedSelector.js +15 -0
  105. data/vendor/jquery/src/event.js +746 -0
  106. data/vendor/jquery/src/event/ajax.js +22 -0
  107. data/vendor/jquery/src/event/alias.js +29 -0
  108. data/vendor/jquery/src/event/focusin.js +55 -0
  109. data/vendor/jquery/src/event/support.js +11 -0
  110. data/vendor/jquery/src/event/trigger.js +185 -0
  111. data/vendor/jquery/src/exports/amd.js +26 -0
  112. data/vendor/jquery/src/exports/global.js +34 -0
  113. data/vendor/jquery/src/jquery.js +41 -0
  114. data/vendor/jquery/src/manipulation.js +488 -0
  115. data/vendor/jquery/src/manipulation/_evalUrl.js +23 -0
  116. data/vendor/jquery/src/manipulation/buildFragment.js +104 -0
  117. data/vendor/jquery/src/manipulation/getAll.js +32 -0
  118. data/vendor/jquery/src/manipulation/setGlobalEval.js +22 -0
  119. data/vendor/jquery/src/manipulation/support.js +35 -0
  120. data/vendor/jquery/src/manipulation/var/rcheckableType.js +5 -0
  121. data/vendor/jquery/src/manipulation/var/rscriptType.js +5 -0
  122. data/vendor/jquery/src/manipulation/var/rtagName.js +5 -0
  123. data/vendor/jquery/src/manipulation/wrapMap.js +29 -0
  124. data/vendor/jquery/src/offset.js +229 -0
  125. data/vendor/jquery/src/queue.js +145 -0
  126. data/vendor/jquery/src/queue/delay.js +24 -0
  127. data/vendor/jquery/src/selector-native.js +237 -0
  128. data/vendor/jquery/src/selector-sizzle.js +19 -0
  129. data/vendor/jquery/src/selector.js +3 -0
  130. data/vendor/jquery/src/serialize.js +130 -0
  131. data/vendor/jquery/src/traversing.js +191 -0
  132. data/vendor/jquery/src/traversing/findFilter.js +106 -0
  133. data/vendor/jquery/src/traversing/var/dir.js +22 -0
  134. data/vendor/jquery/src/traversing/var/rneedsContext.js +8 -0
  135. data/vendor/jquery/src/traversing/var/siblings.js +17 -0
  136. data/vendor/jquery/src/var/ObjectFunctionString.js +7 -0
  137. data/vendor/jquery/src/var/arr.js +5 -0
  138. data/vendor/jquery/src/var/class2type.js +6 -0
  139. data/vendor/jquery/src/var/concat.js +7 -0
  140. data/vendor/jquery/src/var/document.js +5 -0
  141. data/vendor/jquery/src/var/documentElement.js +7 -0
  142. data/vendor/jquery/src/var/fnToString.js +7 -0
  143. data/vendor/jquery/src/var/getProto.js +5 -0
  144. data/vendor/jquery/src/var/hasOwn.js +7 -0
  145. data/vendor/jquery/src/var/indexOf.js +7 -0
  146. data/vendor/jquery/src/var/pnum.js +5 -0
  147. data/vendor/jquery/src/var/push.js +7 -0
  148. data/vendor/jquery/src/var/rcssNum.js +9 -0
  149. data/vendor/jquery/src/var/rnothtmlwhite.js +8 -0
  150. data/vendor/jquery/src/var/slice.js +7 -0
  151. data/vendor/jquery/src/var/support.js +6 -0
  152. data/vendor/jquery/src/var/toString.js +7 -0
  153. data/vendor/jquery/src/wrap.js +77 -0
  154. metadata +152 -3
  155. data/.gitmodules +0 -3
@@ -0,0 +1,97 @@
1
+ /*!
2
+ * inputmask.extensions.js
3
+ * https://github.com/RobinHerbots/Inputmask
4
+ * Copyright (c) 2010 - 2017 Robin Herbots
5
+ * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
6
+ * Version: 3.3.9
7
+ */
8
+
9
+ !function(factory) {
10
+ "function" == typeof define && define.amd ? define([ "./dependencyLibs/inputmask.dependencyLib", "./inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./dependencyLibs/inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
11
+ }(function($, Inputmask) {
12
+ return Inputmask.extendDefinitions({
13
+ A: {
14
+ validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
15
+ cardinality: 1,
16
+ casing: "upper"
17
+ },
18
+ "&": {
19
+ validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
20
+ cardinality: 1,
21
+ casing: "upper"
22
+ },
23
+ "#": {
24
+ validator: "[0-9A-Fa-f]",
25
+ cardinality: 1,
26
+ casing: "upper"
27
+ }
28
+ }), Inputmask.extendAliases({
29
+ url: {
30
+ definitions: {
31
+ i: {
32
+ validator: ".",
33
+ cardinality: 1
34
+ }
35
+ },
36
+ mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
37
+ insertMode: !1,
38
+ autoUnmask: !1,
39
+ inputmode: "url"
40
+ },
41
+ ip: {
42
+ mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
43
+ definitions: {
44
+ i: {
45
+ validator: function(chrs, maskset, pos, strict, opts) {
46
+ return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
47
+ chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
48
+ new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
49
+ },
50
+ cardinality: 1
51
+ }
52
+ },
53
+ onUnMask: function(maskedValue, unmaskedValue, opts) {
54
+ return maskedValue;
55
+ },
56
+ inputmode: "numeric"
57
+ },
58
+ email: {
59
+ mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
60
+ greedy: !1,
61
+ onBeforePaste: function(pastedValue, opts) {
62
+ return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
63
+ },
64
+ definitions: {
65
+ "*": {
66
+ validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
67
+ cardinality: 1,
68
+ casing: "lower"
69
+ },
70
+ "-": {
71
+ validator: "[0-9A-Za-z-]",
72
+ cardinality: 1,
73
+ casing: "lower"
74
+ }
75
+ },
76
+ onUnMask: function(maskedValue, unmaskedValue, opts) {
77
+ return maskedValue;
78
+ },
79
+ inputmode: "email"
80
+ },
81
+ mac: {
82
+ mask: "##:##:##:##:##:##"
83
+ },
84
+ vin: {
85
+ mask: "V{13}9{4}",
86
+ definitions: {
87
+ V: {
88
+ validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
89
+ cardinality: 1,
90
+ casing: "upper"
91
+ }
92
+ },
93
+ clearIncomplete: !0,
94
+ autoUnmask: !0
95
+ }
96
+ }), Inputmask;
97
+ });
@@ -0,0 +1,1643 @@
1
+ /*!
2
+ * inputmask.js
3
+ * https://github.com/RobinHerbots/Inputmask
4
+ * Copyright (c) 2010 - 2017 Robin Herbots
5
+ * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
6
+ * Version: 3.3.9
7
+ */
8
+
9
+ !function(factory) {
10
+ "function" == typeof define && define.amd ? define([ "./dependencyLibs/inputmask.dependencyLib", "./global/window", "./global/document" ], factory) : "object" == typeof exports ? module.exports = factory(require("./dependencyLibs/inputmask.dependencyLib"), require("./global/window"), require("./global/document")) : window.Inputmask = factory(window.dependencyLib || jQuery, window, document);
11
+ }(function($, window, document, undefined) {
12
+ function Inputmask(alias, options, internal) {
13
+ if (!(this instanceof Inputmask)) return new Inputmask(alias, options, internal);
14
+ this.el = undefined, this.events = {}, this.maskset = undefined, this.refreshValue = !1,
15
+ !0 !== internal && ($.isPlainObject(alias) ? options = alias : (options = options || {},
16
+ options.alias = alias), this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && options.definitions !== undefined,
17
+ this.userOptions = options || {}, this.isRTL = this.opts.numericInput, resolveAlias(this.opts.alias, options, this.opts));
18
+ }
19
+ function resolveAlias(aliasStr, options, opts) {
20
+ var aliasDefinition = Inputmask.prototype.aliases[aliasStr];
21
+ return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, undefined, opts),
22
+ $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
23
+ !1);
24
+ }
25
+ function generateMaskSet(opts, nocache) {
26
+ function generateMask(mask, metadata, opts) {
27
+ var regexMask = !1;
28
+ if (null !== mask && "" !== mask || (regexMask = null !== opts.regex, regexMask ? (mask = opts.regex,
29
+ mask = mask.replace(/^(\^)(.*)(\$)$/, "$2")) : (regexMask = !0, mask = ".*")), 1 === mask.length && !1 === opts.greedy && 0 !== opts.repeat && (opts.placeholder = ""),
30
+ opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
31
+ var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
32
+ mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
33
+ }
34
+ var masksetDefinition, maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask;
35
+ return Inputmask.prototype.masksCache[maskdefKey] === undefined || !0 === nocache ? (masksetDefinition = {
36
+ mask: mask,
37
+ maskToken: Inputmask.prototype.analyseMask(mask, regexMask, opts),
38
+ validPositions: {},
39
+ _buffer: undefined,
40
+ buffer: undefined,
41
+ tests: {},
42
+ metadata: metadata,
43
+ maskLength: undefined
44
+ }, !0 !== nocache && (Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition,
45
+ masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[maskdefKey]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[maskdefKey]),
46
+ masksetDefinition;
47
+ }
48
+ if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
49
+ if (opts.mask.length > 1) {
50
+ opts.keepStatic = null === opts.keepStatic || opts.keepStatic;
51
+ var altMask = opts.groupmarker.start;
52
+ return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
53
+ altMask.length > 1 && (altMask += opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start),
54
+ msk.mask === undefined || $.isFunction(msk.mask) ? altMask += msk : altMask += msk.mask;
55
+ }), altMask += opts.groupmarker.end, generateMask(altMask, opts.mask, opts);
56
+ }
57
+ opts.mask = opts.mask.pop();
58
+ }
59
+ return opts.mask && opts.mask.mask !== undefined && !$.isFunction(opts.mask.mask) ? generateMask(opts.mask.mask, opts.mask, opts) : generateMask(opts.mask, opts.mask, opts);
60
+ }
61
+ function maskScope(actionObj, maskset, opts) {
62
+ function getMaskTemplate(baseOnInput, minimalPos, includeMode) {
63
+ minimalPos = minimalPos || 0;
64
+ var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0, lvp = getLastValidPosition();
65
+ do {
66
+ !0 === baseOnInput && getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
67
+ test = testPos.match, ndxIntlzr = testPos.locator.slice(), maskTemplate.push(!0 === includeMode ? testPos.input : !1 === includeMode ? test.nativeDef : getPlaceholder(pos, test))) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
68
+ test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(!1 === includeMode ? test.nativeDef : getPlaceholder(pos, test))),
69
+ pos++;
70
+ } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || minimalPos > pos);
71
+ return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), getMaskSet().maskLength = pos + 1,
72
+ maskTemplate;
73
+ }
74
+ function getMaskSet() {
75
+ return maskset;
76
+ }
77
+ function resetMaskSet(soft) {
78
+ var maskset = getMaskSet();
79
+ maskset.buffer = undefined, !0 !== soft && (maskset.validPositions = {}, maskset.p = 0);
80
+ }
81
+ function getLastValidPosition(closestTo, strict, validPositions) {
82
+ var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions;
83
+ closestTo === undefined && (closestTo = -1);
84
+ for (var posNdx in valids) {
85
+ var psNdx = parseInt(posNdx);
86
+ valids[psNdx] && (strict || !0 !== valids[psNdx].generatedInput) && (psNdx <= closestTo && (before = psNdx),
87
+ psNdx >= closestTo && (after = psNdx));
88
+ }
89
+ return -1 !== before && closestTo - before > 1 || after < closestTo ? before : after;
90
+ }
91
+ function stripValidPositions(start, end, nocheck, strict) {
92
+ var i, startPos = start, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), needsValidation = !1;
93
+ for (getMaskSet().p = start, i = end - 1; i >= startPos; i--) getMaskSet().validPositions[i] !== undefined && (!0 !== nocheck && (!getMaskSet().validPositions[i].match.optionality && function(pos) {
94
+ var posMatch = getMaskSet().validPositions[pos];
95
+ if (posMatch !== undefined && null === posMatch.match.fn) {
96
+ var prevMatch = getMaskSet().validPositions[pos - 1], nextMatch = getMaskSet().validPositions[pos + 1];
97
+ return prevMatch !== undefined && nextMatch !== undefined;
98
+ }
99
+ return !1;
100
+ }(i) || !1 === opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts)) || delete getMaskSet().validPositions[i]);
101
+ for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
102
+ for (;getMaskSet().validPositions[startPos] !== undefined; ) startPos++;
103
+ if (i < startPos && (i = startPos + 1), getMaskSet().validPositions[i] === undefined && isMask(i)) i++; else {
104
+ var t = getTestTemplate(i);
105
+ !1 === needsValidation && positionsClone[startPos] && positionsClone[startPos].match.def === t.match.def ? (getMaskSet().validPositions[startPos] = $.extend(!0, {}, positionsClone[startPos]),
106
+ getMaskSet().validPositions[startPos].input = t.input, delete getMaskSet().validPositions[i],
107
+ i++) : positionCanMatchDefinition(startPos, t.match.def) ? !1 !== isValid(startPos, t.input || getPlaceholder(i), !0) && (delete getMaskSet().validPositions[i],
108
+ i++, needsValidation = !0) : isMask(i) || (i++, startPos--), startPos++;
109
+ }
110
+ }
111
+ resetMaskSet(!0);
112
+ }
113
+ function determineTestTemplate(tests, guessNextBest) {
114
+ for (var testPos, testPositions = tests, lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation].toString().split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
115
+ !(testPos.match && (opts.greedy && !0 !== testPos.match.optionalQuantifier || (!1 === testPos.match.optionality || !1 === testPos.match.newBlockMarker) && !0 !== testPos.match.optionalQuantifier) && (lvTest.alternation === undefined || lvTest.alternation !== testPos.alternation || testPos.locator[lvTest.alternation] !== undefined && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr))) || !0 === guessNextBest && (null !== testPos.match.fn || /[0-9a-bA-Z]/.test(testPos.match.def))); ndx++) ;
116
+ return testPos;
117
+ }
118
+ function getTestTemplate(pos, ndxIntlzr, tstPs) {
119
+ return getMaskSet().validPositions[pos] || determineTestTemplate(getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
120
+ }
121
+ function getTest(pos) {
122
+ return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos] : getTests(pos)[0];
123
+ }
124
+ function positionCanMatchDefinition(pos, def) {
125
+ for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
126
+ valid = !0;
127
+ break;
128
+ }
129
+ return valid;
130
+ }
131
+ function getTests(pos, ndxIntlzr, tstPs) {
132
+ function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
133
+ function handleMatch(match, loopNdx, quantifierRecurse) {
134
+ function isFirstMatch(latestMatch, tokenGroup) {
135
+ var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
136
+ return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
137
+ if (!0 === match.isQuantifier && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]))) return !1;
138
+ }), firstMatch;
139
+ }
140
+ function resolveNdxInitializer(pos, alternateNdx, targetAlternation) {
141
+ var bestMatch, indexPos;
142
+ if (getMaskSet().validPositions[pos - 1] && targetAlternation && getMaskSet().tests[pos]) for (var vpAlternation = getMaskSet().validPositions[pos - 1].locator, tpAlternation = getMaskSet().tests[pos][0].locator, i = 0; i < targetAlternation; i++) if (vpAlternation[i] !== tpAlternation[i]) return vpAlternation.slice(targetAlternation + 1);
143
+ return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
144
+ var alternation = targetAlternation !== undefined ? targetAlternation : lmnt.alternation, ndxPos = lmnt.locator[alternation] !== undefined ? lmnt.locator[alternation].toString().indexOf(alternateNdx) : -1;
145
+ (indexPos === undefined || ndxPos < indexPos) && -1 !== ndxPos && (bestMatch = lmnt,
146
+ indexPos = ndxPos);
147
+ }), bestMatch ? bestMatch.locator.slice((targetAlternation !== undefined ? targetAlternation : bestMatch.alternation) + 1) : targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined;
148
+ }
149
+ if (testPos > 1e4) throw "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. " + getMaskSet().mask;
150
+ if (testPos === pos && match.matches === undefined) return matches.push({
151
+ match: match,
152
+ locator: loopNdx.reverse(),
153
+ cd: cacheDependency
154
+ }), !0;
155
+ if (match.matches !== undefined) {
156
+ if (match.isGroup && quantifierRecurse !== match) {
157
+ if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
158
+ } else if (match.isOptional) {
159
+ var optionalToken = match;
160
+ if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
161
+ if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
162
+ insertStop = !0, testPos = pos;
163
+ }
164
+ } else if (match.isAlternator) {
165
+ var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
166
+ if (-1 === altIndex || "string" == typeof altIndex) {
167
+ var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
168
+ if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
169
+ for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
170
+ if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice(),
171
+ !0 !== (match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match) && match !== undefined && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
172
+ var ntndx = $.inArray(match, maskToken.matches) + 1;
173
+ maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse)) && (altIndexArr.push(ntndx.toString()),
174
+ $.each(matches, function(ndx, lmnt) {
175
+ lmnt.alternation = loopNdx.length - 1;
176
+ }));
177
+ }
178
+ maltMatches = matches.slice(), testPos = currentPos, matches = [];
179
+ for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
180
+ var altMatch = maltMatches[ndx1], dropMatch = !1;
181
+ altMatch.alternation = altMatch.alternation || loopNdxCnt;
182
+ for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
183
+ var altMatch2 = malternateMatches[ndx2];
184
+ if ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr)) {
185
+ if (function(source, target) {
186
+ return source.match.nativeDef === target.match.nativeDef || source.match.def === target.match.nativeDef || source.match.nativeDef === target.match.def;
187
+ }(altMatch, altMatch2)) {
188
+ dropMatch = !0, altMatch.alternation === altMatch2.alternation && -1 === altMatch2.locator[altMatch2.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch2.alternation] = altMatch2.locator[altMatch2.alternation] + "," + altMatch.locator[altMatch.alternation],
189
+ altMatch2.alternation = altMatch.alternation), altMatch.match.nativeDef === altMatch2.match.def && (altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation],
190
+ malternateMatches.splice(malternateMatches.indexOf(altMatch2), 1, altMatch));
191
+ break;
192
+ }
193
+ if (altMatch.match.def === altMatch2.match.def) {
194
+ dropMatch = !1;
195
+ break;
196
+ }
197
+ if (function(source, target) {
198
+ return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
199
+ }(altMatch, altMatch2) || function(source, target) {
200
+ return null !== source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def.replace(/[\[\]]/g, ""), getMaskSet(), pos, !1, opts, !1);
201
+ }(altMatch, altMatch2)) {
202
+ altMatch.alternation === altMatch2.alternation && -1 === altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na || altMatch.locator[altMatch.alternation].toString(),
203
+ -1 === altMatch.na.indexOf(altMatch.locator[altMatch.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na + "," + altMatch.locator[altMatch2.alternation].toString().split("")[0]),
204
+ dropMatch = !0, altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation].toString().split("")[0] + "," + altMatch.locator[altMatch.alternation],
205
+ malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch));
206
+ break;
207
+ }
208
+ }
209
+ }
210
+ dropMatch || malternateMatches.push(altMatch);
211
+ }
212
+ }
213
+ "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
214
+ if (isFinite(ndx)) {
215
+ var alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
216
+ lmnt.locator[alternation] = undefined, lmnt.alternation = undefined;
217
+ for (var alndx = 0; alndx < altLocArr.length; alndx++) -1 !== $.inArray(altLocArr[alndx], altIndexArr) && (lmnt.locator[alternation] !== undefined ? (lmnt.locator[alternation] += ",",
218
+ lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
219
+ lmnt.alternation = alternation);
220
+ if (lmnt.locator[alternation] !== undefined) return lmnt;
221
+ }
222
+ })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0,
223
+ match = malternateMatches.length > 0, ndxInitializer = ndxInitializerClone.slice();
224
+ } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
225
+ if (match) return !0;
226
+ } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) {
227
+ var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
228
+ if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
229
+ if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
230
+ isFirstMatch(latestMatch, tokenGroup)) {
231
+ if (qndx > qt.quantifier.min - 1) {
232
+ insertStop = !0, testPos = pos;
233
+ break;
234
+ }
235
+ return !0;
236
+ }
237
+ return !0;
238
+ }
239
+ } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
240
+ } else testPos++;
241
+ }
242
+ for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (!0 !== maskToken.matches[tndx].isQuantifier) {
243
+ var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
244
+ if (match && testPos === pos) return match;
245
+ if (testPos > pos) break;
246
+ }
247
+ }
248
+ function filterTests(tests) {
249
+ if (opts.keepStatic && pos > 0 && tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0) && !0 !== tests[0].match.optionality && !0 !== tests[0].match.optionalQuantifier && null === tests[0].match.fn && !/[0-9a-bA-Z]/.test(tests[0].match.def)) {
250
+ if (getMaskSet().validPositions[pos - 1] === undefined) return [ determineTestTemplate(tests) ];
251
+ if (getMaskSet().validPositions[pos - 1].alternation === tests[0].alternation) return [ determineTestTemplate(tests) ];
252
+ if (getMaskSet().validPositions[pos - 1]) return [ determineTestTemplate(tests) ];
253
+ }
254
+ return tests;
255
+ }
256
+ var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
257
+ if (pos > -1) {
258
+ if (ndxIntlzr === undefined) {
259
+ for (var test, previousPos = pos - 1; (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) === undefined && previousPos > -1; ) previousPos--;
260
+ test !== undefined && previousPos > -1 && (ndxInitializer = function(tests) {
261
+ var locator = [];
262
+ return $.isArray(tests) || (tests = [ tests ]), tests.length > 0 && (tests[0].alternation === undefined ? (locator = determineTestTemplate(tests.slice()).locator.slice(),
263
+ 0 === locator.length && (locator = tests[0].locator.slice())) : $.each(tests, function(ndx, tst) {
264
+ if ("" !== tst.def) if (0 === locator.length) locator = tst.locator.slice(); else for (var i = 0; i < locator.length; i++) tst.locator[i] && -1 === locator[i].toString().indexOf(tst.locator[i]) && (locator[i] += "," + tst.locator[i]);
265
+ })), locator;
266
+ }(test), cacheDependency = ndxInitializer.join(""), testPos = previousPos);
267
+ }
268
+ if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return filterTests(getMaskSet().tests[pos]);
269
+ for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
270
+ if (resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]) && testPos === pos || testPos > pos) break;
271
+ }
272
+ }
273
+ return (0 === matches.length || insertStop) && matches.push({
274
+ match: {
275
+ fn: null,
276
+ cardinality: 0,
277
+ optionality: !0,
278
+ casing: null,
279
+ def: "",
280
+ placeholder: ""
281
+ },
282
+ locator: [],
283
+ cd: cacheDependency
284
+ }), ndxIntlzr !== undefined && getMaskSet().tests[pos] ? filterTests($.extend(!0, [], matches)) : (getMaskSet().tests[pos] = $.extend(!0, [], matches),
285
+ filterTests(getMaskSet().tests[pos]));
286
+ }
287
+ function getBufferTemplate() {
288
+ return getMaskSet()._buffer === undefined && (getMaskSet()._buffer = getMaskTemplate(!1, 1),
289
+ getMaskSet().buffer === undefined && (getMaskSet().buffer = getMaskSet()._buffer.slice())),
290
+ getMaskSet()._buffer;
291
+ }
292
+ function getBuffer(noCache) {
293
+ return getMaskSet().buffer !== undefined && !0 !== noCache || (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)),
294
+ getMaskSet().buffer;
295
+ }
296
+ function refreshFromBuffer(start, end, buffer) {
297
+ var i, p;
298
+ if (!0 === start) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; i < end; i++) delete getMaskSet().validPositions[i];
299
+ for (p = start, i = start; i < end; i++) if (resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter) {
300
+ var valResult = isValid(p, buffer[i], !0, !0);
301
+ !1 !== valResult && (resetMaskSet(!0), p = valResult.caret !== undefined ? valResult.caret : valResult.pos + 1);
302
+ }
303
+ }
304
+ function casing(elem, test, pos) {
305
+ switch (opts.casing || test.casing) {
306
+ case "upper":
307
+ elem = elem.toUpperCase();
308
+ break;
309
+
310
+ case "lower":
311
+ elem = elem.toLowerCase();
312
+ break;
313
+
314
+ case "title":
315
+ var posBefore = getMaskSet().validPositions[pos - 1];
316
+ elem = 0 === pos || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE) ? elem.toUpperCase() : elem.toLowerCase();
317
+ break;
318
+
319
+ default:
320
+ if ($.isFunction(opts.casing)) {
321
+ var args = Array.prototype.slice.call(arguments);
322
+ args.push(getMaskSet().validPositions), elem = opts.casing.apply(this, args);
323
+ }
324
+ }
325
+ return elem;
326
+ }
327
+ function checkAlternationMatch(altArr1, altArr2, na) {
328
+ for (var naNdx, altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, naArr = na !== undefined ? na.split(",") : [], i = 0; i < naArr.length; i++) -1 !== (naNdx = altArr1.indexOf(naArr[i])) && altArr1.splice(naNdx, 1);
329
+ for (var alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
330
+ isMatch = !0;
331
+ break;
332
+ }
333
+ return isMatch;
334
+ }
335
+ function isValid(pos, c, strict, fromSetValid, fromAlternate, validateOnly) {
336
+ function isSelection(posObj) {
337
+ var selection = isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end == 1 : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin == 1;
338
+ return selection && 0 === posObj.begin && posObj.end === getMaskSet().maskLength ? "full" : selection;
339
+ }
340
+ function _isValid(position, c, strict) {
341
+ var rslt = !1;
342
+ return $.each(getTests(position), function(ndx, tst) {
343
+ for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
344
+ if (c && (chrs += c), getBuffer(!0), !1 !== (rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
345
+ c: getPlaceholder(position, test, !0) || test.def,
346
+ pos: position
347
+ })) {
348
+ var elem = rslt.c !== undefined ? rslt.c : c;
349
+ elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? getPlaceholder(position, test, !0) || test.def : elem;
350
+ var validatedPos = position, possibleModifiedBuffer = getBuffer();
351
+ if (rslt.remove !== undefined && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
352
+ $.each(rslt.remove.sort(function(a, b) {
353
+ return b - a;
354
+ }), function(ndx, lmnt) {
355
+ stripValidPositions(lmnt, lmnt + 1, !0);
356
+ })), rslt.insert !== undefined && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
357
+ $.each(rslt.insert.sort(function(a, b) {
358
+ return a - b;
359
+ }), function(ndx, lmnt) {
360
+ isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
361
+ })), rslt.refreshFromBuffer) {
362
+ var refresh = rslt.refreshFromBuffer;
363
+ if (refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
364
+ rslt.pos === undefined && rslt.c === undefined) return rslt.pos = getLastValidPosition(),
365
+ !1;
366
+ if ((validatedPos = rslt.pos !== undefined ? rslt.pos : position) !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)),
367
+ !1;
368
+ } else if (!0 !== rslt && rslt.pos !== undefined && rslt.pos !== position && (validatedPos = rslt.pos,
369
+ refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
370
+ !1;
371
+ return (!0 === rslt || rslt.pos !== undefined || rslt.c !== undefined) && (ndx > 0 && resetMaskSet(!0),
372
+ setValidPosition(validatedPos, $.extend({}, tst, {
373
+ input: casing(elem, test, validatedPos)
374
+ }), fromSetValid, isSelection(pos)) || (rslt = !1), !1);
375
+ }
376
+ }), rslt;
377
+ }
378
+ function setValidPosition(pos, validTest, fromSetValid, isSelection) {
379
+ if (isSelection || opts.insertMode && getMaskSet().validPositions[pos] !== undefined && fromSetValid === undefined) {
380
+ var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition(undefined, !0);
381
+ for (i = pos; i <= lvp; i++) delete getMaskSet().validPositions[i];
382
+ getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
383
+ var j, valid = !0, vps = getMaskSet().validPositions, needsValidation = !1, initialLength = getMaskSet().maskLength;
384
+ for (i = j = pos; i <= lvp; i++) {
385
+ var t = positionsClone[i];
386
+ if (t !== undefined) for (var posMatch = j; posMatch < getMaskSet().maskLength && (null === t.match.fn && vps[i] && (!0 === vps[i].match.optionalQuantifier || !0 === vps[i].match.optionality) || null != t.match.fn); ) {
387
+ if (posMatch++, !1 === needsValidation && positionsClone[posMatch] && positionsClone[posMatch].match.def === t.match.def) getMaskSet().validPositions[posMatch] = $.extend(!0, {}, positionsClone[posMatch]),
388
+ getMaskSet().validPositions[posMatch].input = t.input, fillMissingNonMask(posMatch),
389
+ j = posMatch, valid = !0; else if (positionCanMatchDefinition(posMatch, t.match.def)) {
390
+ var result = isValid(posMatch, t.input, !0, !0);
391
+ valid = !1 !== result, j = result.caret || result.insert ? getLastValidPosition() : posMatch,
392
+ needsValidation = !0;
393
+ } else if (!(valid = !0 === t.generatedInput) && posMatch >= getMaskSet().maskLength - 1) break;
394
+ if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength),
395
+ valid) break;
396
+ }
397
+ if (!valid) break;
398
+ }
399
+ if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
400
+ resetMaskSet(!0), !1;
401
+ } else getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
402
+ return resetMaskSet(!0), !0;
403
+ }
404
+ function fillMissingNonMask(maskPos) {
405
+ for (var pndx = maskPos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
406
+ var testTemplate, testsFromPos;
407
+ for (pndx++; pndx < maskPos; pndx++) getMaskSet().validPositions[pndx] === undefined && (!1 === opts.jitMasking || opts.jitMasking > pndx) && (testsFromPos = getTests(pndx, getTestTemplate(pndx - 1).locator, pndx - 1).slice(),
408
+ "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop(), (testTemplate = determineTestTemplate(testsFromPos)) && (testTemplate.match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, !0) || $.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, !1, opts)) && !1 !== (result = _isValid(pndx, getPlaceholder(pndx, testTemplate.match, !0) || (null == testTemplate.match.fn ? testTemplate.match.def : "" !== getPlaceholder(pndx) ? getPlaceholder(pndx) : getBuffer()[pndx]), !0)) && (getMaskSet().validPositions[result.pos || pndx].generatedInput = !0));
409
+ }
410
+ strict = !0 === strict;
411
+ var maskPos = pos;
412
+ pos.begin !== undefined && (maskPos = isRTL && !isSelection(pos) ? pos.end : pos.begin);
413
+ var result = !0, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
414
+ if ($.isFunction(opts.preValidation) && !strict && !0 !== fromSetValid && !0 !== validateOnly && (result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts)),
415
+ !0 === result) {
416
+ if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(undefined, Inputmask.keyCode.DELETE, pos, !0, !0),
417
+ maskPos = getMaskSet().p), maskPos < getMaskSet().maskLength && (maxLength === undefined || maskPos < maxLength) && (result = _isValid(maskPos, c, strict),
418
+ (!strict || !0 === fromSetValid) && !1 === result && !0 !== validateOnly)) {
419
+ var currentPosValid = getMaskSet().validPositions[maskPos];
420
+ if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
421
+ if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (!1 !== (result = _isValid(nPos, c, strict))) {
422
+ !function(originalPos, newPos) {
423
+ var vp = getMaskSet().validPositions[newPos];
424
+ if (vp) for (var targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (getMaskSet().validPositions[ps] === undefined && !isMask(ps, !0)) {
425
+ var tests = getTests(ps).slice(), bestMatch = determineTestTemplate(tests, !0), equality = -1;
426
+ "" === tests[tests.length - 1].match.def && tests.pop(), $.each(tests, function(ndx, tst) {
427
+ for (var i = 0; i < tll; i++) {
428
+ if (tst.locator[i] === undefined || !checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","), tst.na)) {
429
+ var targetAI = targetLocator[i], bestMatchAI = bestMatch.locator[i], tstAI = tst.locator[i];
430
+ targetAI - bestMatchAI > Math.abs(targetAI - tstAI) && (bestMatch = tst);
431
+ break;
432
+ }
433
+ equality < i && (equality = i, bestMatch = tst);
434
+ }
435
+ }), bestMatch = $.extend({}, bestMatch, {
436
+ input: getPlaceholder(ps, bestMatch.match, !0) || bestMatch.match.def
437
+ }), bestMatch.generatedInput = !0, setValidPosition(ps, bestMatch, !0), getMaskSet().validPositions[newPos] = undefined,
438
+ _isValid(newPos, vp.input, !0);
439
+ }
440
+ }(maskPos, result.pos !== undefined ? result.pos : nPos), maskPos = nPos;
441
+ break;
442
+ }
443
+ } else result = {
444
+ caret: seekNext(maskPos)
445
+ };
446
+ }
447
+ !1 === result && opts.keepStatic && !strict && !0 !== fromAlternate && (result = function(pos, c, strict) {
448
+ var lastAlt, alternation, altPos, prevAltPos, i, validPos, altNdxs, decisionPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), isValidRslt = !1, lAltPos = getLastValidPosition();
449
+ for (prevAltPos = getMaskSet().validPositions[lAltPos]; lAltPos >= 0; lAltPos--) if ((altPos = getMaskSet().validPositions[lAltPos]) && altPos.alternation !== undefined) {
450
+ if (lastAlt = lAltPos, alternation = getMaskSet().validPositions[lastAlt].alternation,
451
+ prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) break;
452
+ prevAltPos = altPos;
453
+ }
454
+ if (alternation !== undefined) {
455
+ decisionPos = parseInt(lastAlt);
456
+ var decisionTaker = prevAltPos.locator[prevAltPos.alternation || alternation] !== undefined ? prevAltPos.locator[prevAltPos.alternation || alternation] : altNdxs[0];
457
+ decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
458
+ var possibilityPos = getMaskSet().validPositions[decisionPos], prevPos = getMaskSet().validPositions[decisionPos - 1];
459
+ $.each(getTests(decisionPos, prevPos ? prevPos.locator : undefined, decisionPos - 1), function(ndx, test) {
460
+ altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
461
+ for (var mndx = 0; mndx < altNdxs.length; mndx++) {
462
+ var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
463
+ if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")) || -1 === $.inArray(decisionTaker.toString(), altNdxs))) {
464
+ getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
465
+ var possibilities = getMaskSet().validPositions[decisionPos].locator;
466
+ for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]),
467
+ null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0,
468
+ !0 !== possibilityPos.generatedInput && validInputs.push(possibilityPos.input)),
469
+ staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !/[0-9a-bA-Z]/.test(test.match.def),
470
+ getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input,
471
+ i = decisionPos + 1; i < getLastValidPosition(undefined, !0) + 1; i++) validPos = getMaskSet().validPositions[i],
472
+ validPos && !0 !== validPos.generatedInput && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++,
473
+ delete getMaskSet().validPositions[i];
474
+ for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(),
475
+ resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
476
+ var input = validInputs.shift();
477
+ if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(undefined, !0) + 1, input, !1, fromSetValid, !0))) break;
478
+ }
479
+ if (isValidRslt) {
480
+ getMaskSet().validPositions[decisionPos].locator = possibilities;
481
+ var targetLvp = getLastValidPosition(pos) + 1;
482
+ for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) ((validPos = getMaskSet().validPositions[i]) === undefined || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
483
+ pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
484
+ }
485
+ if (isValidRslt) return !1;
486
+ resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
487
+ }
488
+ }
489
+ });
490
+ }
491
+ return isValidRslt;
492
+ }(maskPos, c, strict)), !0 === result && (result = {
493
+ pos: maskPos
494
+ });
495
+ }
496
+ if ($.isFunction(opts.postValidation) && !1 !== result && !strict && !0 !== fromSetValid && !0 !== validateOnly) {
497
+ var postResult = opts.postValidation(getBuffer(!0), result, opts);
498
+ if (postResult.refreshFromBuffer && postResult.buffer) {
499
+ var refresh = postResult.refreshFromBuffer;
500
+ refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, postResult.buffer);
501
+ }
502
+ result = !0 === postResult ? result : postResult;
503
+ }
504
+ return result && result.pos === undefined && (result.pos = maskPos), !1 !== result && !0 !== validateOnly || (resetMaskSet(!0),
505
+ getMaskSet().validPositions = $.extend(!0, {}, positionsClone)), result;
506
+ }
507
+ function isMask(pos, strict) {
508
+ var test = getTestTemplate(pos).match;
509
+ if ("" === test.def && (test = getTest(pos).match), null != test.fn) return test.fn;
510
+ if (!0 !== strict && pos > -1) {
511
+ var tests = getTests(pos);
512
+ return tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0);
513
+ }
514
+ return !1;
515
+ }
516
+ function seekNext(pos, newBlock) {
517
+ var maskL = getMaskSet().maskLength;
518
+ if (pos >= maskL) return maskL;
519
+ var position = pos;
520
+ for (getTests(maskL + 1).length > 1 && (getMaskTemplate(!0, maskL + 1, !0), maskL = getMaskSet().maskLength); ++position < maskL && (!0 === newBlock && (!0 !== getTest(position).match.newBlockMarker || !isMask(position)) || !0 !== newBlock && !isMask(position)); ) ;
521
+ return position;
522
+ }
523
+ function seekPrevious(pos, newBlock) {
524
+ var tests, position = pos;
525
+ if (position <= 0) return 0;
526
+ for (;--position > 0 && (!0 === newBlock && !0 !== getTest(position).match.newBlockMarker || !0 !== newBlock && !isMask(position) && (tests = getTests(position),
527
+ tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
528
+ return position;
529
+ }
530
+ function getBufferElement(position) {
531
+ return getMaskSet().validPositions[position] === undefined ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
532
+ }
533
+ function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
534
+ if (event && $.isFunction(opts.onBeforeWrite)) {
535
+ var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts);
536
+ if (result) {
537
+ if (result.refreshFromBuffer) {
538
+ var refresh = result.refreshFromBuffer;
539
+ refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, result.buffer || buffer),
540
+ buffer = getBuffer(!0);
541
+ }
542
+ caretPos !== undefined && (caretPos = result.caret !== undefined ? result.caret : caretPos);
543
+ }
544
+ }
545
+ input !== undefined && (input.inputmask._valueSet(buffer.join("")), caretPos === undefined || event !== undefined && "blur" === event.type ? renderColorMask(input, caretPos, 0 === buffer.length) : android && event && "input" === event.type ? setTimeout(function() {
546
+ caret(input, caretPos);
547
+ }, 0) : caret(input, caretPos), !0 === triggerInputEvent && (skipInputEvent = !0,
548
+ $(input).trigger("input")));
549
+ }
550
+ function getPlaceholder(pos, test, returnPL) {
551
+ if (test = test || getTest(pos).match, test.placeholder !== undefined || !0 === returnPL) return $.isFunction(test.placeholder) ? test.placeholder(opts) : test.placeholder;
552
+ if (null === test.fn) {
553
+ if (pos > -1 && getMaskSet().validPositions[pos] === undefined) {
554
+ var prevTest, tests = getTests(pos), staticAlternations = [];
555
+ if (tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0)) for (var i = 0; i < tests.length; i++) if (!0 !== tests[i].match.optionality && !0 !== tests[i].match.optionalQuantifier && (null === tests[i].match.fn || prevTest === undefined || !1 !== tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts)) && (staticAlternations.push(tests[i]),
556
+ null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations.length > 1 && /[0-9a-bA-Z]/.test(staticAlternations[0].match.def))) return opts.placeholder.charAt(pos % opts.placeholder.length);
557
+ }
558
+ return test.def;
559
+ }
560
+ return opts.placeholder.charAt(pos % opts.placeholder.length);
561
+ }
562
+ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
563
+ function isTemplateMatch(ndx, charCodes) {
564
+ return -1 !== getBufferTemplate().slice(ndx, seekNext(ndx)).join("").indexOf(charCodes) && !isMask(ndx) && getTest(ndx).match.nativeDef === charCodes.charAt(charCodes.length - 1);
565
+ }
566
+ var inputValue = nptvl.slice(), charCodes = "", initialNdx = -1, result = undefined;
567
+ if (resetMaskSet(), strict || !0 === opts.autoUnmask) initialNdx = seekNext(initialNdx); else {
568
+ var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
569
+ matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
570
+ initialNdx = seekNext(initialNdx));
571
+ }
572
+ if (-1 === initialNdx ? (getMaskSet().p = seekNext(initialNdx), initialNdx = 0) : getMaskSet().p = initialNdx,
573
+ $.each(inputValue, function(ndx, charCode) {
574
+ if (charCode !== undefined) if (getMaskSet().validPositions[ndx] === undefined && inputValue[ndx] === getPlaceholder(ndx) && isMask(ndx, !0) && !1 === isValid(ndx, inputValue[ndx], !0, undefined, undefined, !0)) getMaskSet().p++; else {
575
+ var keypress = new $.Event("_checkval");
576
+ keypress.which = charCode.charCodeAt(0), charCodes += charCode;
577
+ var lvp = getLastValidPosition(undefined, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : undefined, lvp);
578
+ if (!isTemplateMatch(initialNdx, charCodes) || strict || opts.autoUnmask) {
579
+ var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
580
+ result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, strict, pos),
581
+ initialNdx = pos + 1, charCodes = "";
582
+ } else result = EventHandlers.keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
583
+ if (!1 !== result && !strict && $.isFunction(opts.onBeforeWrite)) {
584
+ var origResult = result;
585
+ if (result = opts.onBeforeWrite.call(inputmask, keypress, getBuffer(), result.forwardPosition, opts),
586
+ (result = $.extend(origResult, result)) && result.refreshFromBuffer) {
587
+ var refresh = result.refreshFromBuffer;
588
+ refreshFromBuffer(!0 === refresh ? refresh : refresh.start, refresh.end, result.buffer),
589
+ resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret, result.forwardPosition = result.caret);
590
+ }
591
+ }
592
+ }
593
+ }), writeOut) {
594
+ var caretPos = undefined;
595
+ document.activeElement === input && result && (caretPos = opts.numericInput ? seekPrevious(result.forwardPosition) : result.forwardPosition),
596
+ writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"), initiatingEvent && "input" === initiatingEvent.type);
597
+ }
598
+ }
599
+ function unmaskedvalue(input) {
600
+ if (input) {
601
+ if (input.inputmask === undefined) return input.value;
602
+ input.inputmask && input.inputmask.refreshValue && EventHandlers.setValueEvent.call(input);
603
+ }
604
+ var umValue = [], vps = getMaskSet().validPositions;
605
+ for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
606
+ var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join("");
607
+ if ($.isFunction(opts.onUnMask)) {
608
+ var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
609
+ unmaskedValue = opts.onUnMask.call(inputmask, bufferValue, unmaskedValue, opts);
610
+ }
611
+ return unmaskedValue;
612
+ }
613
+ function caret(input, begin, end, notranslate) {
614
+ function translatePosition(pos) {
615
+ if (!0 !== notranslate && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
616
+ pos = getBuffer().join("").length - pos;
617
+ }
618
+ return pos;
619
+ }
620
+ var range;
621
+ if (begin === undefined) return input.setSelectionRange ? (begin = input.selectionStart,
622
+ end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
623
+ range.commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset,
624
+ end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
625
+ begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length),
626
+ end = begin + range.text.length), {
627
+ begin: translatePosition(begin),
628
+ end: translatePosition(end)
629
+ };
630
+ if (begin.begin !== undefined && (end = begin.end, begin = begin.begin), "number" == typeof begin) {
631
+ begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
632
+ var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
633
+ if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || !1 !== opts.insertMode || begin !== end || end++,
634
+ input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
635
+ if (range = document.createRange(), input.firstChild === undefined || null === input.firstChild) {
636
+ var textNode = document.createTextNode("");
637
+ input.appendChild(textNode);
638
+ }
639
+ range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
640
+ range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
641
+ range.collapse(!0);
642
+ var sel = window.getSelection();
643
+ sel.removeAllRanges(), sel.addRange(range);
644
+ } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
645
+ range.moveEnd("character", end), range.moveStart("character", begin), range.select());
646
+ renderColorMask(input, {
647
+ begin: begin,
648
+ end: end
649
+ });
650
+ }
651
+ }
652
+ function determineLastRequiredPosition(returnDefinition) {
653
+ var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined;
654
+ for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
655
+ ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
656
+ var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
657
+ for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier && testPos.match.newBlockMarker || lvTestAlt && (lvTestAlt !== positions[pos].locator[lvTest.alternation] && null != testPos.match.fn || null === testPos.match.fn && testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) && "" !== getTests(pos)[0].def)) && buffer[pos] === getPlaceholder(pos, testPos.match)); pos--) bl--;
658
+ return returnDefinition ? {
659
+ l: bl,
660
+ def: positions[bl] ? positions[bl].match : undefined
661
+ } : bl;
662
+ }
663
+ function clearOptionalTail(buffer) {
664
+ for (var validPos, rl = determineLastRequiredPosition(), bl = buffer.length, lv = getMaskSet().validPositions[getLastValidPosition()]; rl < bl && !isMask(rl, !0) && (validPos = lv !== undefined ? getTestTemplate(rl, lv.locator.slice(""), lv) : getTest(rl)) && !0 !== validPos.match.optionality && (!0 !== validPos.match.optionalQuantifier && !0 !== validPos.match.newBlockMarker || rl + 1 === bl && "" === (lv !== undefined ? getTestTemplate(rl + 1, lv.locator.slice(""), lv) : getTest(rl + 1)).match.def); ) rl++;
665
+ for (;(validPos = getMaskSet().validPositions[rl - 1]) && validPos && validPos.match.optionality && validPos.input === opts.skipOptionalPartCharacter; ) rl--;
666
+ return buffer.splice(rl), buffer;
667
+ }
668
+ function isComplete(buffer) {
669
+ if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
670
+ if ("*" === opts.repeat) return undefined;
671
+ var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
672
+ if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
673
+ complete = !0;
674
+ for (var i = 0; i <= aml; i++) {
675
+ var test = getTestTemplate(i).match;
676
+ if (null !== test.fn && getMaskSet().validPositions[i] === undefined && !0 !== test.optionality && !0 !== test.optionalQuantifier || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
677
+ complete = !1;
678
+ break;
679
+ }
680
+ }
681
+ }
682
+ return complete;
683
+ }
684
+ function handleRemove(input, k, pos, strict, fromIsValid) {
685
+ if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
686
+ isRTL)) {
687
+ var pend = pos.end;
688
+ pos.end = pos.begin, pos.begin = pend;
689
+ }
690
+ k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || !1 === opts.insertMode) ? (pos.begin = seekPrevious(pos.begin),
691
+ getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end, !0) && getMaskSet().validPositions[pos.end] && getMaskSet().validPositions[pos.end].input !== opts.radixPoint ? pos.end + 1 : seekNext(pos.end) + 1,
692
+ getMaskSet().validPositions[pos.begin] !== undefined && getMaskSet().validPositions[pos.begin].input === opts.groupSeparator && pos.end++),
693
+ stripValidPositions(pos.begin, pos.end, !1, strict), !0 !== strict && function() {
694
+ if (opts.keepStatic) {
695
+ for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
696
+ var altPos = getMaskSet().validPositions[lastAlt];
697
+ if (altPos) {
698
+ if (!0 !== altPos.generatedInput && /[0-9a-bA-Z]/.test(altPos.input) && validInputs.push(altPos.input),
699
+ delete getMaskSet().validPositions[lastAlt], altPos.alternation !== undefined && altPos.locator[altPos.alternation] !== prevAltPos.locator[altPos.alternation]) break;
700
+ prevAltPos = altPos;
701
+ }
702
+ }
703
+ if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
704
+ var keypress = new $.Event("keypress");
705
+ keypress.which = validInputs.pop().charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
706
+ } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
707
+ }
708
+ }();
709
+ var lvp = getLastValidPosition(pos.begin, !0);
710
+ if (lvp < pos.begin) getMaskSet().p = seekNext(lvp); else if (!0 !== strict && (getMaskSet().p = pos.begin,
711
+ !0 !== fromIsValid)) for (;getMaskSet().p < lvp && getMaskSet().validPositions[getMaskSet().p] === undefined; ) getMaskSet().p++;
712
+ }
713
+ function initializeColorMask(input) {
714
+ function findCaretPos(clientx) {
715
+ var caretPos, e = document.createElement("span");
716
+ for (var style in computedStyle) isNaN(style) && -1 !== style.indexOf("font") && (e.style[style] = computedStyle[style]);
717
+ e.style.textTransform = computedStyle.textTransform, e.style.letterSpacing = computedStyle.letterSpacing,
718
+ e.style.position = "absolute", e.style.height = "auto", e.style.width = "auto",
719
+ e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", document.body.appendChild(e);
720
+ var itl, inputText = input.inputmask._valueGet(), previousWidth = 0;
721
+ for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) {
722
+ if (e.innerHTML += inputText.charAt(caretPos) || "_", e.offsetWidth >= clientx) {
723
+ var offset1 = clientx - previousWidth, offset2 = e.offsetWidth - clientx;
724
+ e.innerHTML = inputText.charAt(caretPos), offset1 -= e.offsetWidth / 3, caretPos = offset1 < offset2 ? caretPos - 1 : caretPos;
725
+ break;
726
+ }
727
+ previousWidth = e.offsetWidth;
728
+ }
729
+ return document.body.removeChild(e), caretPos;
730
+ }
731
+ var computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null), template = document.createElement("div");
732
+ template.style.width = computedStyle.width, template.style.textAlign = computedStyle.textAlign,
733
+ colorMask = document.createElement("div"), colorMask.className = "im-colormask",
734
+ input.parentNode.insertBefore(colorMask, input), input.parentNode.removeChild(input),
735
+ colorMask.appendChild(template), colorMask.appendChild(input), input.style.left = template.offsetLeft + "px",
736
+ $(input).on("click", function(e) {
737
+ return caret(input, findCaretPos(e.clientX)), EventHandlers.clickEvent.call(input, [ e ]);
738
+ }), $(input).on("keydown", function(e) {
739
+ e.shiftKey || !1 === opts.insertMode || setTimeout(function() {
740
+ renderColorMask(input);
741
+ }, 0);
742
+ });
743
+ }
744
+ function renderColorMask(input, caretPos, clear) {
745
+ function handleStatic() {
746
+ isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && (null !== test.fn && testPos.input !== undefined || "" === test.def) && (isStatic = !1,
747
+ maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
748
+ }
749
+ function handleCaret(force) {
750
+ !0 !== force && pos !== caretPos.begin || document.activeElement !== input || (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>");
751
+ }
752
+ var test, testPos, ndxIntlzr, maskTemplate = "", isStatic = !1, pos = 0;
753
+ if (colorMask !== undefined) {
754
+ var buffer = getBuffer();
755
+ if (caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
756
+ begin: caretPos,
757
+ end: caretPos
758
+ }), !0 !== clear) {
759
+ var lvp = getLastValidPosition();
760
+ do {
761
+ handleCaret(), getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
762
+ test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += buffer[pos]) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
763
+ test = testPos.match, ndxIntlzr = testPos.locator.slice(), (!1 === opts.jitMasking || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(),
764
+ maskTemplate += getPlaceholder(pos, test))), pos++;
765
+ } while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos || isStatic);
766
+ -1 === maskTemplate.indexOf("im-caret") && handleCaret(!0), isStatic && handleStatic();
767
+ }
768
+ var template = colorMask.getElementsByTagName("div")[0];
769
+ template.innerHTML = maskTemplate, input.inputmask.positionColorMask(input, template);
770
+ }
771
+ }
772
+ maskset = maskset || this.maskset, opts = opts || this.opts;
773
+ var undoValue, $el, maxLength, colorMask, inputmask = this, el = this.el, isRTL = this.isRTL, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1, EventRuler = {
774
+ on: function(input, eventName, eventHandler) {
775
+ var ev = function(e) {
776
+ if (this.inputmask === undefined && "FORM" !== this.nodeName) {
777
+ var imOpts = $.data(this, "_inputmask_opts");
778
+ imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
779
+ } else {
780
+ if ("setvalue" === e.type || "FORM" === this.nodeName || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || !1 === opts.tabThrough && e.keyCode === Inputmask.keyCode.TAB))) {
781
+ switch (e.type) {
782
+ case "input":
783
+ if (!0 === skipInputEvent) return skipInputEvent = !1, e.preventDefault();
784
+ break;
785
+
786
+ case "keydown":
787
+ skipKeyPressEvent = !1, skipInputEvent = !1;
788
+ break;
789
+
790
+ case "keypress":
791
+ if (!0 === skipKeyPressEvent) return e.preventDefault();
792
+ skipKeyPressEvent = !0;
793
+ break;
794
+
795
+ case "click":
796
+ if (iemobile || iphone) {
797
+ var that = this, args = arguments;
798
+ return setTimeout(function() {
799
+ eventHandler.apply(that, args);
800
+ }, 0), !1;
801
+ }
802
+ }
803
+ var returnVal = eventHandler.apply(this, arguments);
804
+ return !1 === returnVal && (e.preventDefault(), e.stopPropagation()), returnVal;
805
+ }
806
+ e.preventDefault();
807
+ }
808
+ };
809
+ input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
810
+ -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null !== input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
811
+ },
812
+ off: function(input, event) {
813
+ if (input.inputmask && input.inputmask.events) {
814
+ var events;
815
+ event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
816
+ $.each(events, function(eventName, evArr) {
817
+ for (;evArr.length > 0; ) {
818
+ var ev = evArr.pop();
819
+ -1 !== $.inArray(eventName, [ "submit", "reset" ]) ? null !== input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
820
+ }
821
+ delete input.inputmask.events[eventName];
822
+ });
823
+ }
824
+ }
825
+ }, EventHandlers = {
826
+ keydownEvent: function(e) {
827
+ var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
828
+ if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !function(eventName) {
829
+ var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
830
+ return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
831
+ el = null, isSupported;
832
+ }("cut")) e.preventDefault(), handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
833
+ input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : !0 === isComplete(getBuffer()) && $input.trigger("complete"); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
834
+ e.preventDefault();
835
+ var caretPos = seekNext(getLastValidPosition());
836
+ opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
837
+ caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
838
+ } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
839
+ caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && !0 !== e.altKey ? (checkVal(input, !0, !1, undoValue.split("")),
840
+ $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? !0 === opts.tabThrough && k === Inputmask.keyCode.TAB ? (!0 === e.shiftKey ? (null === getTest(pos.begin).match.fn && (pos.begin = seekNext(pos.begin)),
841
+ pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
842
+ pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
843
+ pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || !1 === opts.insertMode && (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
844
+ var caretPos = caret(input);
845
+ caret(input, caretPos.begin);
846
+ }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
847
+ var caretPos = caret(input);
848
+ caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
849
+ }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
850
+ opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
851
+ },
852
+ keypressEvent: function(e, checkval, writeOut, strict, ndx) {
853
+ var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
854
+ if (!(!0 === checkval || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
855
+ setTimeout(function() {
856
+ $input.trigger("change");
857
+ }, 0)), !0;
858
+ if (k) {
859
+ 46 === k && !1 === e.shiftKey && "" !== opts.radixPoint && (k = opts.radixPoint.charCodeAt(0));
860
+ var forwardPosition, pos = checkval ? {
861
+ begin: ndx,
862
+ end: ndx
863
+ } : caret(input), c = String.fromCharCode(k);
864
+ getMaskSet().writeOutBuffer = !0;
865
+ var valResult = isValid(pos, c, strict);
866
+ if (!1 !== valResult && (resetMaskSet(!0), forwardPosition = valResult.caret !== undefined ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
867
+ getMaskSet().p = forwardPosition), !1 !== writeOut && (setTimeout(function() {
868
+ opts.onKeyValidation.call(input, k, valResult, opts);
869
+ }, 0), getMaskSet().writeOutBuffer && !1 !== valResult)) {
870
+ var buffer = getBuffer();
871
+ writeBuffer(input, buffer, opts.numericInput && valResult.caret === undefined ? seekPrevious(forwardPosition) : forwardPosition, e, !0 !== checkval),
872
+ !0 !== checkval && setTimeout(function() {
873
+ !0 === isComplete(buffer) && $input.trigger("complete");
874
+ }, 0);
875
+ }
876
+ if (e.preventDefault(), checkval) return !1 !== valResult && (valResult.forwardPosition = forwardPosition),
877
+ valResult;
878
+ }
879
+ },
880
+ pasteEvent: function(e) {
881
+ var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
882
+ isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
883
+ var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
884
+ if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
885
+ valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
886
+ isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
887
+ window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
888
+ if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
889
+ inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
890
+ }
891
+ var pasteValue = inputValue;
892
+ if ($.isFunction(opts.onBeforePaste)) {
893
+ if (!1 === (pasteValue = opts.onBeforePaste.call(inputmask, inputValue, opts))) return e.preventDefault();
894
+ pasteValue || (pasteValue = inputValue);
895
+ }
896
+ return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
897
+ writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
898
+ !0 === isComplete(getBuffer()) && $input.trigger("complete"), e.preventDefault();
899
+ },
900
+ inputFallBackEvent: function(e) {
901
+ var input = this, inputValue = input.inputmask._valueGet();
902
+ if (getBuffer().join("") !== inputValue) {
903
+ var caretPos = caret(input);
904
+ if (!1 === function(input, inputValue, caretPos) {
905
+ if ("." === inputValue.charAt(caretPos.begin - 1) && "" !== opts.radixPoint && (inputValue = inputValue.split(""),
906
+ inputValue[caretPos.begin - 1] = opts.radixPoint.charAt(0), inputValue = inputValue.join("")),
907
+ inputValue.charAt(caretPos.begin - 1) === opts.radixPoint && inputValue.length > getBuffer().length) {
908
+ var keypress = new $.Event("keypress");
909
+ return keypress.which = opts.radixPoint.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, caretPos.begin - 1),
910
+ !1;
911
+ }
912
+ }(input, inputValue, caretPos)) return !1;
913
+ if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
914
+ !1 === function(input, inputValue, caretPos) {
915
+ if (iemobile) {
916
+ var inputChar = inputValue.replace(getBuffer().join(""), "");
917
+ if (1 === inputChar.length) {
918
+ var keypress = new $.Event("keypress");
919
+ return keypress.which = inputChar.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
920
+ !1;
921
+ }
922
+ }
923
+ }(input, inputValue, caretPos)) return !1;
924
+ caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input));
925
+ var buffer = getBuffer().join(""), frontPart = inputValue.substr(0, caretPos.begin), backPart = inputValue.substr(caretPos.begin), frontBufferPart = buffer.substr(0, caretPos.begin), backBufferPart = buffer.substr(caretPos.begin), selection = caretPos, entries = "", isEntry = !1;
926
+ if (frontPart !== frontBufferPart) {
927
+ selection.begin = 0;
928
+ for (var fpl = (isEntry = frontPart.length >= frontBufferPart.length) ? frontPart.length : frontBufferPart.length, i = 0; frontPart.charAt(i) === frontBufferPart.charAt(i) && i < fpl; i++) selection.begin++;
929
+ isEntry && (entries += frontPart.slice(selection.begin, selection.end));
930
+ }
931
+ backPart !== backBufferPart && (backPart.length > backBufferPart.length ? isEntry && (selection.end = selection.begin) : backPart.length < backBufferPart.length ? selection.end += backBufferPart.length - backPart.length : backPart.charAt(0) !== backBufferPart.charAt(0) && selection.end++),
932
+ writeBuffer(input, getBuffer(), selection), entries.length > 0 ? $.each(entries.split(""), function(ndx, entry) {
933
+ var keypress = new $.Event("keypress");
934
+ keypress.which = entry.charCodeAt(0), ignorable = !1, EventHandlers.keypressEvent.call(input, keypress);
935
+ }) : (selection.begin === selection.end - 1 && caret(input, seekPrevious(selection.begin + 1), selection.end),
936
+ e.keyCode = Inputmask.keyCode.DELETE, EventHandlers.keydownEvent.call(input, e)),
937
+ e.preventDefault();
938
+ }
939
+ },
940
+ setValueEvent: function(e) {
941
+ this.inputmask.refreshValue = !1;
942
+ var input = this, value = input.inputmask._valueGet(!0);
943
+ $.isFunction(opts.onBeforeMask) && (value = opts.onBeforeMask.call(inputmask, value, opts) || value),
944
+ value = value.split(""), checkVal(input, !0, !1, isRTL ? value.reverse() : value),
945
+ undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
946
+ },
947
+ focusEvent: function(e) {
948
+ var input = this, nptValue = input.inputmask._valueGet();
949
+ opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (input.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : !1 === mouseEnter && caret(input, seekNext(getLastValidPosition()))),
950
+ !0 === opts.positionCaretOnTab && !1 === mouseEnter && "" !== nptValue && (writeBuffer(input, getBuffer(), caret(input)),
951
+ EventHandlers.clickEvent.apply(input, [ e, !0 ])), undoValue = getBuffer().join("");
952
+ },
953
+ mouseleaveEvent: function(e) {
954
+ var input = this;
955
+ if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
956
+ var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
957
+ nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
958
+ writeBuffer(input, buffer));
959
+ }
960
+ },
961
+ clickEvent: function(e, tabbed) {
962
+ function doRadixFocus(clickPos) {
963
+ if ("" !== opts.radixPoint) {
964
+ var vps = getMaskSet().validPositions;
965
+ if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) {
966
+ if (clickPos < seekNext(-1)) return !0;
967
+ var radixPos = $.inArray(opts.radixPoint, getBuffer());
968
+ if (-1 !== radixPos) {
969
+ for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
970
+ return !0;
971
+ }
972
+ }
973
+ }
974
+ return !1;
975
+ }
976
+ var input = this;
977
+ setTimeout(function() {
978
+ if (document.activeElement === input) {
979
+ var selectedCaret = caret(input);
980
+ if (tabbed && (isRTL ? selectedCaret.end = selectedCaret.begin : selectedCaret.begin = selectedCaret.end),
981
+ selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
982
+ case "none":
983
+ break;
984
+
985
+ case "radixFocus":
986
+ if (doRadixFocus(selectedCaret.begin)) {
987
+ var radixPos = getBuffer().join("").indexOf(opts.radixPoint);
988
+ caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
989
+ break;
990
+ }
991
+
992
+ default:
993
+ var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
994
+ if (clickPosition < lastPosition) caret(input, isMask(clickPosition, !0) || isMask(clickPosition - 1, !0) ? clickPosition : seekNext(clickPosition)); else {
995
+ var lvp = getMaskSet().validPositions[lvclickPosition], tt = getTestTemplate(lastPosition, lvp ? lvp.match.locator : undefined, lvp), placeholder = getPlaceholder(lastPosition, tt.match);
996
+ if ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && !0 !== tt.match.optionalQuantifier && !0 !== tt.match.newBlockMarker || !isMask(lastPosition, !0) && tt.match.def === placeholder) {
997
+ var newPos = seekNext(lastPosition);
998
+ (clickPosition >= newPos || clickPosition === lastPosition) && (lastPosition = newPos);
999
+ }
1000
+ caret(input, lastPosition);
1001
+ }
1002
+ }
1003
+ }
1004
+ }, 0);
1005
+ },
1006
+ dblclickEvent: function(e) {
1007
+ var input = this;
1008
+ setTimeout(function() {
1009
+ caret(input, 0, seekNext(getLastValidPosition()));
1010
+ }, 0);
1011
+ },
1012
+ cutEvent: function(e) {
1013
+ var input = this, $input = $(input), pos = caret(input), ev = e.originalEvent || e, clipboardData = window.clipboardData || ev.clipboardData, clipData = isRTL ? getBuffer().slice(pos.end, pos.begin) : getBuffer().slice(pos.begin, pos.end);
1014
+ clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
1015
+ document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
1016
+ writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
1017
+ input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared");
1018
+ },
1019
+ blurEvent: function(e) {
1020
+ var $input = $(this), input = this;
1021
+ if (input.inputmask) {
1022
+ var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
1023
+ "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
1024
+ !1 === isComplete(buffer) && (setTimeout(function() {
1025
+ $input.trigger("incomplete");
1026
+ }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
1027
+ writeBuffer(input, buffer, undefined, e)), undoValue !== getBuffer().join("") && (undoValue = buffer.join(""),
1028
+ $input.trigger("change"));
1029
+ }
1030
+ },
1031
+ mouseenterEvent: function(e) {
1032
+ var input = this;
1033
+ mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
1034
+ },
1035
+ submitEvent: function(e) {
1036
+ undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
1037
+ opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
1038
+ setTimeout(function() {
1039
+ writeBuffer(el, getBuffer());
1040
+ }, 0));
1041
+ },
1042
+ resetEvent: function(e) {
1043
+ el.inputmask.refreshValue = !0, setTimeout(function() {
1044
+ $el.trigger("setvalue");
1045
+ }, 0);
1046
+ }
1047
+ };
1048
+ Inputmask.prototype.positionColorMask = function(input, template) {
1049
+ input.style.left = template.offsetLeft + "px";
1050
+ };
1051
+ var valueBuffer;
1052
+ if (actionObj !== undefined) switch (actionObj.action) {
1053
+ case "isComplete":
1054
+ return el = actionObj.el, isComplete(getBuffer());
1055
+
1056
+ case "unmaskedvalue":
1057
+ return el !== undefined && actionObj.value === undefined || (valueBuffer = actionObj.value,
1058
+ valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
1059
+ checkVal(undefined, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite.call(inputmask, undefined, getBuffer(), 0, opts)),
1060
+ unmaskedvalue(el);
1061
+
1062
+ case "mask":
1063
+ !function(elem) {
1064
+ EventRuler.off(elem);
1065
+ var isSupported = function(input, opts) {
1066
+ var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && -1 !== $.inArray(elementType, opts.supportsInputType) || input.isContentEditable || "TEXTAREA" === input.tagName;
1067
+ if (!isSupported) if ("INPUT" === input.tagName) {
1068
+ var el = document.createElement("input");
1069
+ el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
1070
+ } else isSupported = "partial";
1071
+ return !1 !== isSupported ? function(npt) {
1072
+ function getter() {
1073
+ return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : -1 !== getLastValidPosition() || !0 !== opts.nullable ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
1074
+ }
1075
+ function setter(value) {
1076
+ valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
1077
+ }
1078
+ var valueGet, valueSet;
1079
+ if (!npt.inputmask.__valueGet) {
1080
+ if (!0 !== opts.noValuePatching) {
1081
+ if (Object.getOwnPropertyDescriptor) {
1082
+ "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" == typeof "test".__proto__ ? function(object) {
1083
+ return object.__proto__;
1084
+ } : function(object) {
1085
+ return object.constructor.prototype;
1086
+ });
1087
+ var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
1088
+ valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get,
1089
+ valueSet = valueProperty.set, Object.defineProperty(npt, "value", {
1090
+ get: getter,
1091
+ set: setter,
1092
+ configurable: !0
1093
+ })) : "INPUT" !== npt.tagName && (valueGet = function() {
1094
+ return this.textContent;
1095
+ }, valueSet = function(value) {
1096
+ this.textContent = value;
1097
+ }, Object.defineProperty(npt, "value", {
1098
+ get: getter,
1099
+ set: setter,
1100
+ configurable: !0
1101
+ }));
1102
+ } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"),
1103
+ valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
1104
+ npt.__defineSetter__("value", setter));
1105
+ npt.inputmask.__valueGet = valueGet, npt.inputmask.__valueSet = valueSet;
1106
+ }
1107
+ npt.inputmask._valueGet = function(overruleRTL) {
1108
+ return isRTL && !0 !== overruleRTL ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
1109
+ }, npt.inputmask._valueSet = function(value, overruleRTL) {
1110
+ valueSet.call(this.el, null === value || value === undefined ? "" : !0 !== overruleRTL && isRTL ? value.split("").reverse().join("") : value);
1111
+ }, valueGet === undefined && (valueGet = function() {
1112
+ return this.value;
1113
+ }, valueSet = function(value) {
1114
+ this.value = value;
1115
+ }, function(type) {
1116
+ if ($.valHooks && ($.valHooks[type] === undefined || !0 !== $.valHooks[type].inputmaskpatch)) {
1117
+ var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
1118
+ return elem.value;
1119
+ }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
1120
+ return elem.value = value, elem;
1121
+ };
1122
+ $.valHooks[type] = {
1123
+ get: function(elem) {
1124
+ if (elem.inputmask) {
1125
+ if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
1126
+ var result = valhookGet(elem);
1127
+ return -1 !== getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) || !0 !== opts.nullable ? result : "";
1128
+ }
1129
+ return valhookGet(elem);
1130
+ },
1131
+ set: function(elem, value) {
1132
+ var result, $elem = $(elem);
1133
+ return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
1134
+ result;
1135
+ },
1136
+ inputmaskpatch: !0
1137
+ };
1138
+ }
1139
+ }(npt.type), function(npt) {
1140
+ EventRuler.on(npt, "mouseenter", function(event) {
1141
+ var $input = $(this);
1142
+ this.inputmask._valueGet() !== getBuffer().join("") && $input.trigger("setvalue");
1143
+ });
1144
+ }(npt));
1145
+ }
1146
+ }(input) : input.inputmask = undefined, isSupported;
1147
+ }(elem, opts);
1148
+ if (!1 !== isSupported && (el = elem, $el = $(el), maxLength = el !== undefined ? el.maxLength : undefined,
1149
+ -1 === maxLength && (maxLength = undefined), !0 === opts.colorMask && initializeColorMask(el),
1150
+ android && (el.hasOwnProperty("inputmode") && (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)),
1151
+ "rtfm" === opts.androidHack && (!0 !== opts.colorMask && initializeColorMask(el),
1152
+ el.type = "password")), !0 === isSupported && (EventRuler.on(el, "submit", EventHandlers.submitEvent),
1153
+ EventRuler.on(el, "reset", EventHandlers.resetEvent), EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent),
1154
+ EventRuler.on(el, "blur", EventHandlers.blurEvent), EventRuler.on(el, "focus", EventHandlers.focusEvent),
1155
+ EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent), !0 !== opts.colorMask && EventRuler.on(el, "click", EventHandlers.clickEvent),
1156
+ EventRuler.on(el, "dblclick", EventHandlers.dblclickEvent), EventRuler.on(el, "paste", EventHandlers.pasteEvent),
1157
+ EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent),
1158
+ EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
1159
+ EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
1160
+ android || !0 === opts.inputEventOnly ? el.removeAttribute("maxLength") : (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
1161
+ EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop),
1162
+ EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop),
1163
+ EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
1164
+ EventRuler.on(el, "beforeinput", $.noop)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent),
1165
+ undoValue = getBufferTemplate().join(""), "" !== el.inputmask._valueGet(!0) || !1 === opts.clearMaskOnLostFocus || document.activeElement === el)) {
1166
+ var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, el.inputmask._valueGet(!0), opts) || el.inputmask._valueGet(!0) : el.inputmask._valueGet(!0);
1167
+ "" !== initialValue && checkVal(el, !0, !1, isRTL ? initialValue.split("").reverse() : initialValue.split(""));
1168
+ var buffer = getBuffer().slice();
1169
+ undoValue = buffer.join(""), !1 === isComplete(buffer) && opts.clearIncomplete && resetMaskSet(),
1170
+ opts.clearMaskOnLostFocus && document.activeElement !== el && (-1 === getLastValidPosition() ? buffer = [] : clearOptionalTail(buffer)),
1171
+ writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
1172
+ }
1173
+ }(el);
1174
+ break;
1175
+
1176
+ case "format":
1177
+ return valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(inputmask, actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
1178
+ checkVal(undefined, !0, !1, isRTL ? valueBuffer.reverse() : valueBuffer), actionObj.metadata ? {
1179
+ value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
1180
+ metadata: maskScope.call(this, {
1181
+ action: "getmetadata"
1182
+ }, maskset, opts)
1183
+ } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
1184
+
1185
+ case "isValid":
1186
+ actionObj.value ? (valueBuffer = actionObj.value.split(""), checkVal(undefined, !0, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
1187
+ for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
1188
+ return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
1189
+
1190
+ case "getemptymask":
1191
+ return getBufferTemplate().join("");
1192
+
1193
+ case "remove":
1194
+ if (el && el.inputmask) {
1195
+ $el = $(el), el.inputmask._valueSet(opts.autoUnmask ? unmaskedvalue(el) : el.inputmask._valueGet(!0)),
1196
+ EventRuler.off(el);
1197
+ Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value") && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
1198
+ get: el.inputmask.__valueGet,
1199
+ set: el.inputmask.__valueSet,
1200
+ configurable: !0
1201
+ }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
1202
+ el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = undefined;
1203
+ }
1204
+ return el;
1205
+
1206
+ case "getmetadata":
1207
+ if ($.isArray(maskset.metadata)) {
1208
+ var maskTarget = getMaskTemplate(!0, 0, !1).join("");
1209
+ return $.each(maskset.metadata, function(ndx, mtdt) {
1210
+ if (mtdt.mask === maskTarget) return maskTarget = mtdt, !1;
1211
+ }), maskTarget;
1212
+ }
1213
+ return maskset.metadata;
1214
+ }
1215
+ }
1216
+ var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile, android = /android/i.test(ua) && !iemobile;
1217
+ return Inputmask.prototype = {
1218
+ dataAttribute: "data-inputmask",
1219
+ defaults: {
1220
+ placeholder: "_",
1221
+ optionalmarker: {
1222
+ start: "[",
1223
+ end: "]"
1224
+ },
1225
+ quantifiermarker: {
1226
+ start: "{",
1227
+ end: "}"
1228
+ },
1229
+ groupmarker: {
1230
+ start: "(",
1231
+ end: ")"
1232
+ },
1233
+ alternatormarker: "|",
1234
+ escapeChar: "\\",
1235
+ mask: null,
1236
+ regex: null,
1237
+ oncomplete: $.noop,
1238
+ onincomplete: $.noop,
1239
+ oncleared: $.noop,
1240
+ repeat: 0,
1241
+ greedy: !0,
1242
+ autoUnmask: !1,
1243
+ removeMaskOnSubmit: !1,
1244
+ clearMaskOnLostFocus: !0,
1245
+ insertMode: !0,
1246
+ clearIncomplete: !1,
1247
+ alias: null,
1248
+ onKeyDown: $.noop,
1249
+ onBeforeMask: null,
1250
+ onBeforePaste: function(pastedValue, opts) {
1251
+ return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue;
1252
+ },
1253
+ onBeforeWrite: null,
1254
+ onUnMask: null,
1255
+ showMaskOnFocus: !0,
1256
+ showMaskOnHover: !0,
1257
+ onKeyValidation: $.noop,
1258
+ skipOptionalPartCharacter: " ",
1259
+ numericInput: !1,
1260
+ rightAlign: !1,
1261
+ undoOnEscape: !0,
1262
+ radixPoint: "",
1263
+ radixPointDefinitionSymbol: undefined,
1264
+ groupSeparator: "",
1265
+ keepStatic: null,
1266
+ positionCaretOnTab: !0,
1267
+ tabThrough: !1,
1268
+ supportsInputType: [ "text", "tel", "password" ],
1269
+ 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, 0, 229 ],
1270
+ isComplete: null,
1271
+ canClearPosition: $.noop,
1272
+ preValidation: null,
1273
+ postValidation: null,
1274
+ staticDefinitionSymbol: undefined,
1275
+ jitMasking: !1,
1276
+ nullable: !0,
1277
+ inputEventOnly: !1,
1278
+ noValuePatching: !1,
1279
+ positionCaretOnClick: "lvp",
1280
+ casing: null,
1281
+ inputmode: "verbatim",
1282
+ colorMask: !1,
1283
+ androidHack: !1,
1284
+ importDataAttributes: !0
1285
+ },
1286
+ definitions: {
1287
+ "9": {
1288
+ validator: "[0-9\uff11-\uff19]",
1289
+ cardinality: 1,
1290
+ definitionSymbol: "*"
1291
+ },
1292
+ a: {
1293
+ validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
1294
+ cardinality: 1,
1295
+ definitionSymbol: "*"
1296
+ },
1297
+ "*": {
1298
+ validator: "[0-9\uff11-\uff19A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
1299
+ cardinality: 1
1300
+ }
1301
+ },
1302
+ aliases: {},
1303
+ masksCache: {},
1304
+ mask: function(elems) {
1305
+ function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
1306
+ function importOption(option, optionData) {
1307
+ null !== (optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option)) && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
1308
+ userOptions[option] = optionData);
1309
+ }
1310
+ if (!0 === opts.importDataAttributes) {
1311
+ var option, dataoptions, optionData, p, attrOptions = npt.getAttribute(dataAttribute);
1312
+ if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
1313
+ dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
1314
+ optionData = undefined;
1315
+ for (p in dataoptions) if ("alias" === p.toLowerCase()) {
1316
+ optionData = dataoptions[p];
1317
+ break;
1318
+ }
1319
+ }
1320
+ importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
1321
+ for (option in opts) {
1322
+ if (dataoptions) {
1323
+ optionData = undefined;
1324
+ for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
1325
+ optionData = dataoptions[p];
1326
+ break;
1327
+ }
1328
+ }
1329
+ importOption(option, optionData);
1330
+ }
1331
+ }
1332
+ return $.extend(!0, opts, userOptions), ("rtl" === npt.dir || opts.rightAlign) && (npt.style.textAlign = "right"),
1333
+ ("rtl" === npt.dir || opts.numericInput) && (npt.dir = "ltr", npt.removeAttribute("dir"),
1334
+ opts.isRTL = !0), opts;
1335
+ }
1336
+ var that = this;
1337
+ return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
1338
+ elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
1339
+ var scopedOpts = $.extend(!0, {}, that.opts);
1340
+ importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute);
1341
+ var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
1342
+ maskset !== undefined && (el.inputmask !== undefined && (el.inputmask.opts.autoUnmask = !0,
1343
+ el.inputmask.remove()), el.inputmask = new Inputmask(undefined, undefined, !0),
1344
+ el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
1345
+ el.inputmask.isRTL = scopedOpts.isRTL || scopedOpts.numericInput, el.inputmask.el = el,
1346
+ el.inputmask.maskset = maskset, $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, {
1347
+ action: "mask"
1348
+ }));
1349
+ }), elems && elems[0] ? elems[0].inputmask || this : this;
1350
+ },
1351
+ option: function(options, noremask) {
1352
+ return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.userOptions, options),
1353
+ this.el && !0 !== noremask && this.mask(this.el), this) : void 0;
1354
+ },
1355
+ unmaskedvalue: function(value) {
1356
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1357
+ maskScope.call(this, {
1358
+ action: "unmaskedvalue",
1359
+ value: value
1360
+ });
1361
+ },
1362
+ remove: function() {
1363
+ return maskScope.call(this, {
1364
+ action: "remove"
1365
+ });
1366
+ },
1367
+ getemptymask: function() {
1368
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1369
+ maskScope.call(this, {
1370
+ action: "getemptymask"
1371
+ });
1372
+ },
1373
+ hasMaskedValue: function() {
1374
+ return !this.opts.autoUnmask;
1375
+ },
1376
+ isComplete: function() {
1377
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1378
+ maskScope.call(this, {
1379
+ action: "isComplete"
1380
+ });
1381
+ },
1382
+ getmetadata: function() {
1383
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1384
+ maskScope.call(this, {
1385
+ action: "getmetadata"
1386
+ });
1387
+ },
1388
+ isValid: function(value) {
1389
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1390
+ maskScope.call(this, {
1391
+ action: "isValid",
1392
+ value: value
1393
+ });
1394
+ },
1395
+ format: function(value, metadata) {
1396
+ return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
1397
+ maskScope.call(this, {
1398
+ action: "format",
1399
+ value: value,
1400
+ metadata: metadata
1401
+ });
1402
+ },
1403
+ analyseMask: function(mask, regexMask, opts) {
1404
+ function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
1405
+ this.matches = [], this.openGroup = isGroup || !1, this.alternatorGroup = !1, this.isGroup = isGroup || !1,
1406
+ this.isOptional = isOptional || !1, this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
1407
+ this.quantifier = {
1408
+ min: 1,
1409
+ max: 1
1410
+ };
1411
+ }
1412
+ function insertTestDefinition(mtoken, element, position) {
1413
+ position = position !== undefined ? position : mtoken.matches.length;
1414
+ var prevMatch = mtoken.matches[position - 1];
1415
+ if (regexMask) 0 === element.indexOf("[") || escaped && /\\d|\\s|\\w]/i.test(element) || "." === element ? mtoken.matches.splice(position++, 0, {
1416
+ fn: new RegExp(element, opts.casing ? "i" : ""),
1417
+ cardinality: 1,
1418
+ optionality: mtoken.isOptional,
1419
+ newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
1420
+ casing: null,
1421
+ def: element,
1422
+ placeholder: undefined,
1423
+ nativeDef: element
1424
+ }) : (escaped && (element = element[element.length - 1]), $.each(element.split(""), function(ndx, lmnt) {
1425
+ prevMatch = mtoken.matches[position - 1], mtoken.matches.splice(position++, 0, {
1426
+ fn: null,
1427
+ cardinality: 0,
1428
+ optionality: mtoken.isOptional,
1429
+ newBlockMarker: prevMatch === undefined || prevMatch.def !== lmnt && null !== prevMatch.fn,
1430
+ casing: null,
1431
+ def: opts.staticDefinitionSymbol || lmnt,
1432
+ placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined,
1433
+ nativeDef: lmnt
1434
+ });
1435
+ })), escaped = !1; else {
1436
+ var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
1437
+ if (maskdef && !escaped) {
1438
+ for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
1439
+ var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
1440
+ mtoken.matches.splice(position++, 0, {
1441
+ fn: validator ? "string" == typeof validator ? new RegExp(validator, opts.casing ? "i" : "") : new function() {
1442
+ this.test = validator;
1443
+ }() : new RegExp("."),
1444
+ cardinality: cardinality || 1,
1445
+ optionality: mtoken.isOptional,
1446
+ newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
1447
+ casing: maskdef.casing,
1448
+ def: maskdef.definitionSymbol || element,
1449
+ placeholder: maskdef.placeholder,
1450
+ nativeDef: element
1451
+ }), prevMatch = mtoken.matches[position - 1];
1452
+ }
1453
+ mtoken.matches.splice(position++, 0, {
1454
+ fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() {
1455
+ this.test = maskdef.validator;
1456
+ }() : new RegExp("."),
1457
+ cardinality: maskdef.cardinality,
1458
+ optionality: mtoken.isOptional,
1459
+ newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
1460
+ casing: maskdef.casing,
1461
+ def: maskdef.definitionSymbol || element,
1462
+ placeholder: maskdef.placeholder,
1463
+ nativeDef: element
1464
+ });
1465
+ } else mtoken.matches.splice(position++, 0, {
1466
+ fn: null,
1467
+ cardinality: 0,
1468
+ optionality: mtoken.isOptional,
1469
+ newBlockMarker: prevMatch === undefined || prevMatch.def !== element && null !== prevMatch.fn,
1470
+ casing: null,
1471
+ def: opts.staticDefinitionSymbol || element,
1472
+ placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
1473
+ nativeDef: element
1474
+ }), escaped = !1;
1475
+ }
1476
+ }
1477
+ function verifyGroupMarker(maskToken) {
1478
+ maskToken && maskToken.matches && $.each(maskToken.matches, function(ndx, token) {
1479
+ var nextToken = maskToken.matches[ndx + 1];
1480
+ (nextToken === undefined || nextToken.matches === undefined || !1 === nextToken.isQuantifier) && token && token.isGroup && (token.isGroup = !1,
1481
+ regexMask || (insertTestDefinition(token, opts.groupmarker.start, 0), !0 !== token.openGroup && insertTestDefinition(token, opts.groupmarker.end))),
1482
+ verifyGroupMarker(token);
1483
+ });
1484
+ }
1485
+ function defaultCase() {
1486
+ if (openenings.length > 0) {
1487
+ if (currentOpeningToken = openenings[openenings.length - 1], insertTestDefinition(currentOpeningToken, m),
1488
+ currentOpeningToken.isAlternator) {
1489
+ alternator = openenings.pop();
1490
+ for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
1491
+ openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
1492
+ currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
1493
+ }
1494
+ } else insertTestDefinition(currentToken, m);
1495
+ }
1496
+ function reverseTokens(maskToken) {
1497
+ maskToken.matches = maskToken.matches.reverse();
1498
+ for (var match in maskToken.matches) if (maskToken.matches.hasOwnProperty(match)) {
1499
+ var intMatch = parseInt(match);
1500
+ if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
1501
+ var qt = maskToken.matches[match];
1502
+ maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
1503
+ }
1504
+ maskToken.matches[match].matches !== undefined ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = function(st) {
1505
+ return st === opts.optionalmarker.start ? st = opts.optionalmarker.end : st === opts.optionalmarker.end ? st = opts.optionalmarker.start : st === opts.groupmarker.start ? st = opts.groupmarker.end : st === opts.groupmarker.end && (st = opts.groupmarker.start),
1506
+ st;
1507
+ }(maskToken.matches[match]);
1508
+ }
1509
+ return maskToken;
1510
+ }
1511
+ var match, m, openingToken, currentOpeningToken, alternator, lastMatch, groupToken, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, regexTokenizer = /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g, escaped = !1, currentToken = new MaskToken(), openenings = [], maskTokens = [];
1512
+ for (regexMask && (opts.optionalmarker.start = undefined, opts.optionalmarker.end = undefined); match = regexMask ? regexTokenizer.exec(mask) : tokenizer.exec(mask); ) {
1513
+ if (m = match[0], regexMask) switch (m.charAt(0)) {
1514
+ case "?":
1515
+ m = "{0,1}";
1516
+ break;
1517
+
1518
+ case "+":
1519
+ case "*":
1520
+ m = "{" + m + "}";
1521
+ }
1522
+ if (escaped) defaultCase(); else switch (m.charAt(0)) {
1523
+ case opts.escapeChar:
1524
+ escaped = !0, regexMask && defaultCase();
1525
+ break;
1526
+
1527
+ case opts.optionalmarker.end:
1528
+ case opts.groupmarker.end:
1529
+ if (openingToken = openenings.pop(), openingToken.openGroup = !1, openingToken !== undefined) if (openenings.length > 0) {
1530
+ if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
1531
+ currentOpeningToken.isAlternator) {
1532
+ alternator = openenings.pop();
1533
+ for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1,
1534
+ alternator.matches[mndx].alternatorGroup = !1;
1535
+ openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
1536
+ currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
1537
+ }
1538
+ } else currentToken.matches.push(openingToken); else defaultCase();
1539
+ break;
1540
+
1541
+ case opts.optionalmarker.start:
1542
+ openenings.push(new MaskToken(!1, !0));
1543
+ break;
1544
+
1545
+ case opts.groupmarker.start:
1546
+ openenings.push(new MaskToken(!0));
1547
+ break;
1548
+
1549
+ case opts.quantifiermarker.start:
1550
+ var quantifier = new MaskToken(!1, !1, !0);
1551
+ m = m.replace(/[{}]/g, "");
1552
+ var mq = m.split(","), mq0 = isNaN(mq[0]) ? mq[0] : parseInt(mq[0]), mq1 = 1 === mq.length ? mq0 : isNaN(mq[1]) ? mq[1] : parseInt(mq[1]);
1553
+ if ("*" !== mq1 && "+" !== mq1 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
1554
+ min: mq0,
1555
+ max: mq1
1556
+ }, openenings.length > 0) {
1557
+ var matches = openenings[openenings.length - 1].matches;
1558
+ match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
1559
+ match = groupToken), matches.push(match), matches.push(quantifier);
1560
+ } else match = currentToken.matches.pop(), match.isGroup || (regexMask && null === match.fn && "." === match.def && (match.fn = new RegExp(match.def, opts.casing ? "i" : "")),
1561
+ groupToken = new MaskToken(!0), groupToken.matches.push(match), match = groupToken),
1562
+ currentToken.matches.push(match), currentToken.matches.push(quantifier);
1563
+ break;
1564
+
1565
+ case opts.alternatormarker:
1566
+ if (openenings.length > 0) {
1567
+ currentOpeningToken = openenings[openenings.length - 1];
1568
+ var subToken = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
1569
+ lastMatch = currentOpeningToken.openGroup && (subToken.matches === undefined || !1 === subToken.isGroup && !1 === subToken.isAlternator) ? openenings.pop() : currentOpeningToken.matches.pop();
1570
+ } else lastMatch = currentToken.matches.pop();
1571
+ if (lastMatch.isAlternator) openenings.push(lastMatch); else if (lastMatch.alternatorGroup ? (alternator = openenings.pop(),
1572
+ lastMatch.alternatorGroup = !1) : alternator = new MaskToken(!1, !1, !1, !0), alternator.matches.push(lastMatch),
1573
+ openenings.push(alternator), lastMatch.openGroup) {
1574
+ lastMatch.openGroup = !1;
1575
+ var alternatorGroup = new MaskToken(!0);
1576
+ alternatorGroup.alternatorGroup = !0, openenings.push(alternatorGroup);
1577
+ }
1578
+ break;
1579
+
1580
+ default:
1581
+ defaultCase();
1582
+ }
1583
+ }
1584
+ for (;openenings.length > 0; ) openingToken = openenings.pop(), currentToken.matches.push(openingToken);
1585
+ return currentToken.matches.length > 0 && (verifyGroupMarker(currentToken), maskTokens.push(currentToken)),
1586
+ (opts.numericInput || opts.isRTL) && reverseTokens(maskTokens[0]), maskTokens;
1587
+ }
1588
+ }, Inputmask.extendDefaults = function(options) {
1589
+ $.extend(!0, Inputmask.prototype.defaults, options);
1590
+ }, Inputmask.extendDefinitions = function(definition) {
1591
+ $.extend(!0, Inputmask.prototype.definitions, definition);
1592
+ }, Inputmask.extendAliases = function(alias) {
1593
+ $.extend(!0, Inputmask.prototype.aliases, alias);
1594
+ }, Inputmask.format = function(value, options, metadata) {
1595
+ return Inputmask(options).format(value, metadata);
1596
+ }, Inputmask.unmask = function(value, options) {
1597
+ return Inputmask(options).unmaskedvalue(value);
1598
+ }, Inputmask.isValid = function(value, options) {
1599
+ return Inputmask(options).isValid(value);
1600
+ }, Inputmask.remove = function(elems) {
1601
+ $.each(elems, function(ndx, el) {
1602
+ el.inputmask && el.inputmask.remove();
1603
+ });
1604
+ }, Inputmask.escapeRegex = function(str) {
1605
+ var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
1606
+ return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
1607
+ }, Inputmask.keyCode = {
1608
+ ALT: 18,
1609
+ BACKSPACE: 8,
1610
+ BACKSPACE_SAFARI: 127,
1611
+ CAPS_LOCK: 20,
1612
+ COMMA: 188,
1613
+ COMMAND: 91,
1614
+ COMMAND_LEFT: 91,
1615
+ COMMAND_RIGHT: 93,
1616
+ CONTROL: 17,
1617
+ DELETE: 46,
1618
+ DOWN: 40,
1619
+ END: 35,
1620
+ ENTER: 13,
1621
+ ESCAPE: 27,
1622
+ HOME: 36,
1623
+ INSERT: 45,
1624
+ LEFT: 37,
1625
+ MENU: 93,
1626
+ NUMPAD_ADD: 107,
1627
+ NUMPAD_DECIMAL: 110,
1628
+ NUMPAD_DIVIDE: 111,
1629
+ NUMPAD_ENTER: 108,
1630
+ NUMPAD_MULTIPLY: 106,
1631
+ NUMPAD_SUBTRACT: 109,
1632
+ PAGE_DOWN: 34,
1633
+ PAGE_UP: 33,
1634
+ PERIOD: 190,
1635
+ RIGHT: 39,
1636
+ SHIFT: 16,
1637
+ SPACE: 32,
1638
+ TAB: 9,
1639
+ UP: 38,
1640
+ WINDOWS: 91,
1641
+ X: 88
1642
+ }, Inputmask;
1643
+ });