inputmask.js 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. /*!
  2. * inputmask.js
  3. * http://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2015 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.2.5
  7. */
  8. !function(factory) {
  9. "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
  10. }(function($) {
  11. function Inputmask(alias, options) {
  12. return this instanceof Inputmask ? ("object" == typeof alias ? options = alias : (options = options || {},
  13. options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
  14. this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
  15. void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
  16. }
  17. function isInputEventSupported(eventName) {
  18. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  19. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  20. el = null, isSupported;
  21. }
  22. function isInputTypeSupported(inputType) {
  23. var isSupported = "text" === inputType || "tel" === inputType || "password" === inputType;
  24. if (!isSupported) {
  25. var el = document.createElement("input");
  26. el.setAttribute("type", inputType), isSupported = "text" === el.type, el = null;
  27. }
  28. return isSupported;
  29. }
  30. function resolveAlias(aliasStr, options, opts) {
  31. var aliasDefinition = opts.aliases[aliasStr];
  32. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  33. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
  34. !1);
  35. }
  36. function importAttributeOptions(npt, opts, userOptions) {
  37. function importOption(option, optionData) {
  38. optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option),
  39. null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  40. userOptions[option] = optionData);
  41. }
  42. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
  43. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  44. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  45. optionData = void 0;
  46. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  47. optionData = dataoptions[p];
  48. break;
  49. }
  50. }
  51. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  52. for (option in opts) {
  53. if (dataoptions) {
  54. optionData = void 0;
  55. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  56. optionData = dataoptions[p];
  57. break;
  58. }
  59. }
  60. importOption(option, optionData);
  61. }
  62. return $.extend(!0, opts, userOptions), opts;
  63. }
  64. function generateMaskSet(opts, nocache) {
  65. function analyseMask(mask) {
  66. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  67. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  68. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  69. this.quantifier = {
  70. min: 1,
  71. max: 1
  72. };
  73. }
  74. function insertTestDefinition(mtoken, element, position) {
  75. var maskdef = opts.definitions[element];
  76. position = void 0 !== position ? position : mtoken.matches.length;
  77. var prevMatch = mtoken.matches[position - 1];
  78. if (maskdef && !escaped) {
  79. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
  80. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  81. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  82. mtoken.matches.splice(position++, 0, {
  83. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  84. this.test = validator;
  85. }() : new RegExp("."),
  86. cardinality: cardinality ? cardinality : 1,
  87. optionality: mtoken.isOptional,
  88. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  89. casing: maskdef.casing,
  90. def: maskdef.definitionSymbol || element,
  91. placeholder: maskdef.placeholder,
  92. mask: element
  93. }), prevMatch = mtoken.matches[position - 1];
  94. }
  95. mtoken.matches.splice(position++, 0, {
  96. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  97. this.test = maskdef.validator;
  98. }() : new RegExp("."),
  99. cardinality: maskdef.cardinality,
  100. optionality: mtoken.isOptional,
  101. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  102. casing: maskdef.casing,
  103. def: maskdef.definitionSymbol || element,
  104. placeholder: maskdef.placeholder,
  105. mask: element
  106. });
  107. } else mtoken.matches.splice(position++, 0, {
  108. fn: null,
  109. cardinality: 0,
  110. optionality: mtoken.isOptional,
  111. newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
  112. casing: null,
  113. def: element,
  114. placeholder: void 0,
  115. mask: element
  116. }), escaped = !1;
  117. }
  118. function verifyGroupMarker(lastMatch, isOpenGroup) {
  119. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  120. isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
  121. }
  122. function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
  123. currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  124. verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
  125. }
  126. function defaultCase() {
  127. if (openenings.length > 0) {
  128. if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator),
  129. currentOpeningToken.isAlternator) {
  130. alternator = openenings.pop();
  131. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  132. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  133. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  134. }
  135. } else maskCurrentToken(m, currentToken, lastMatch);
  136. }
  137. function reverseTokens(maskToken) {
  138. function reverseStatic(st) {
  139. 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),
  140. st;
  141. }
  142. maskToken.matches = maskToken.matches.reverse();
  143. for (var match in maskToken.matches) {
  144. var intMatch = parseInt(match);
  145. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  146. var qt = maskToken.matches[match];
  147. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  148. }
  149. void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  150. }
  151. return maskToken;
  152. }
  153. for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, groupToken, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new MaskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) if (m = match[0],
  154. escaped) defaultCase(); else switch (m.charAt(0)) {
  155. case opts.escapeChar:
  156. escaped = !0;
  157. break;
  158. case opts.optionalmarker.end:
  159. case opts.groupmarker.end:
  160. if (openingToken = openenings.pop(), void 0 !== openingToken) if (openenings.length > 0) {
  161. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  162. currentOpeningToken.isAlternator) {
  163. alternator = openenings.pop();
  164. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  165. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  166. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  167. }
  168. } else currentToken.matches.push(openingToken); else defaultCase();
  169. break;
  170. case opts.optionalmarker.start:
  171. openenings.push(new MaskToken(!1, !0));
  172. break;
  173. case opts.groupmarker.start:
  174. openenings.push(new MaskToken(!0));
  175. break;
  176. case opts.quantifiermarker.start:
  177. var quantifier = new MaskToken(!1, !1, !0);
  178. m = m.replace(/[{}]/g, "");
  179. 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]);
  180. if (("*" === mq1 || "+" === mq1) && (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  181. min: mq0,
  182. max: mq1
  183. }, openenings.length > 0) {
  184. var matches = openenings[openenings.length - 1].matches;
  185. match = matches.pop(), match.isGroup || (groupToken = new MaskToken(!0), groupToken.matches.push(match),
  186. match = groupToken), matches.push(match), matches.push(quantifier);
  187. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken(!0),
  188. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  189. currentToken.matches.push(quantifier);
  190. break;
  191. case opts.alternatormarker:
  192. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  193. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  194. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken(!1, !1, !1, !0),
  195. alternator.matches.push(lastMatch), openenings.push(alternator));
  196. break;
  197. default:
  198. defaultCase();
  199. }
  200. for (;openenings.length > 0; ) openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0),
  201. currentToken.matches.push(openingToken);
  202. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  203. verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
  204. maskTokens;
  205. }
  206. function generateMask(mask, metadata) {
  207. if (null === mask || "" === mask) return void 0;
  208. if (1 === mask.length && opts.greedy === !1 && 0 !== opts.repeat && (opts.placeholder = ""),
  209. opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
  210. var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
  211. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  212. }
  213. var masksetDefinition;
  214. return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
  215. mask: mask,
  216. maskToken: analyseMask(mask),
  217. validPositions: {},
  218. _buffer: void 0,
  219. buffer: void 0,
  220. tests: {},
  221. metadata: metadata
  222. }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  223. masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]))) : masksetDefinition = $.extend(!0, {}, Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask]),
  224. masksetDefinition;
  225. }
  226. function preProcessMask(mask) {
  227. return mask = mask.toString();
  228. }
  229. var ms;
  230. if ($.isFunction(opts.mask) && (opts.mask = opts.mask(opts)), $.isArray(opts.mask)) {
  231. if (opts.mask.length > 1) {
  232. opts.keepStatic = null === opts.keepStatic ? !0 : opts.keepStatic;
  233. var altMask = "(";
  234. return $.each(opts.numericInput ? opts.mask.reverse() : opts.mask, function(ndx, msk) {
  235. altMask.length > 1 && (altMask += ")|("), altMask += preProcessMask(void 0 === msk.mask || $.isFunction(msk.mask) ? msk : msk.mask);
  236. }), altMask += ")", generateMask(altMask, opts.mask);
  237. }
  238. opts.mask = opts.mask.pop();
  239. }
  240. return opts.mask && (ms = void 0 === opts.mask.mask || $.isFunction(opts.mask.mask) ? generateMask(preProcessMask(opts.mask), opts.mask) : generateMask(preProcessMask(opts.mask.mask), opts.mask)),
  241. ms;
  242. }
  243. function maskScope(actionObj, maskset, opts) {
  244. function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
  245. minimalPos = minimalPos || 0;
  246. var ndxIntlzr, test, testPos, maskTemplate = [], pos = 0;
  247. do {
  248. if (baseOnInput === !0 && getMaskSet().validPositions[pos]) {
  249. var validPos = getMaskSet().validPositions[pos];
  250. test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
  251. } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match,
  252. ndxIntlzr = testPos.locator.slice(), maskTemplate.push(getPlaceholder(pos, test));
  253. pos++;
  254. } while ((void 0 === maxLength || maxLength > pos - 1) && null !== test.fn || null === test.fn && "" !== test.def || minimalPos >= pos);
  255. return maskTemplate.pop(), maskTemplate;
  256. }
  257. function getMaskSet() {
  258. return maskset;
  259. }
  260. function resetMaskSet(soft) {
  261. var maskset = getMaskSet();
  262. maskset.buffer = void 0, maskset.tests = {}, soft !== !0 && (maskset._buffer = void 0,
  263. maskset.validPositions = {}, maskset.p = 0);
  264. }
  265. function getLastValidPosition(closestTo, strict) {
  266. var maskset = getMaskSet(), lastValidPosition = -1, valids = maskset.validPositions;
  267. void 0 === closestTo && (closestTo = -1);
  268. var before = lastValidPosition, after = lastValidPosition;
  269. for (var posNdx in valids) {
  270. var psNdx = parseInt(posNdx);
  271. valids[psNdx] && (strict || null !== valids[psNdx].match.fn) && (closestTo >= psNdx && (before = psNdx),
  272. psNdx >= closestTo && (after = psNdx));
  273. }
  274. return lastValidPosition = -1 !== before && closestTo - before > 1 || closestTo > after ? before : after;
  275. }
  276. function setValidPosition(pos, validTest, fromSetValid) {
  277. if (opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
  278. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition();
  279. for (i = pos; lvp >= i; i++) delete getMaskSet().validPositions[i];
  280. getMaskSet().validPositions[pos] = validTest;
  281. var j, valid = !0, vps = getMaskSet().validPositions;
  282. for (i = j = pos; lvp >= i; i++) {
  283. var t = positionsClone[i];
  284. if (void 0 !== t) for (var posMatch = j, prevPosMatch = -1; posMatch < getMaskLength() && (null == t.match.fn && vps[i] && (vps[i].match.optionalQuantifier === !0 || vps[i].match.optionality === !0) || null != t.match.fn); ) {
  285. if (null === t.match.fn || !opts.keepStatic && vps[i] && (void 0 !== vps[i + 1] && getTests(i + 1, vps[i].locator.slice(), i).length > 1 || void 0 !== vps[i].alternation) ? posMatch++ : posMatch = seekNext(j),
  286. positionCanMatchDefinition(posMatch, t.match.def)) {
  287. valid = isValid(posMatch, t.input, !0, !0) !== !1, j = posMatch;
  288. break;
  289. }
  290. if (valid = null == t.match.fn, prevPosMatch === posMatch) break;
  291. prevPosMatch = posMatch;
  292. }
  293. if (!valid) break;
  294. }
  295. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  296. resetMaskSet(!0), !1;
  297. } else getMaskSet().validPositions[pos] = validTest;
  298. return resetMaskSet(!0), !0;
  299. }
  300. function stripValidPositions(start, end, nocheck, strict) {
  301. var i, startPos = start;
  302. for (getMaskSet().p = start, i = startPos; end > i; i++) void 0 !== getMaskSet().validPositions[i] && (nocheck === !0 || opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts) !== !1) && delete getMaskSet().validPositions[i];
  303. for (i = startPos + 1; i <= getLastValidPosition(); ) {
  304. for (;void 0 !== getMaskSet().validPositions[startPos]; ) startPos++;
  305. var s = getMaskSet().validPositions[startPos];
  306. if (startPos > i && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) i++; else {
  307. var t = getTestTemplate(i);
  308. positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i],
  309. i++) : isMask(i) || (i++, startPos--), startPos++;
  310. }
  311. }
  312. var lvp = getLastValidPosition(), ml = getMaskLength();
  313. for (strict !== !0 && nocheck !== !0 && void 0 !== getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input === opts.radixPoint && delete getMaskSet().validPositions[lvp],
  314. i = lvp + 1; ml >= i; i++) getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
  315. resetMaskSet(!0);
  316. }
  317. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  318. var testPos = getMaskSet().validPositions[pos];
  319. if (void 0 === testPos) for (var testPositions = getTests(pos, ndxIntlzr, tstPs), lvp = getLastValidPosition(), lvTest = getMaskSet().validPositions[lvp] || getTests(0)[0], lvTestAltArr = void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation].toString().split(",") : [], ndx = 0; ndx < testPositions.length && (testPos = testPositions[ndx],
  320. !(testPos.match && (opts.greedy && testPos.match.optionalQuantifier !== !0 || (testPos.match.optionality === !1 || testPos.match.newBlockMarker === !1) && testPos.match.optionalQuantifier !== !0) && (void 0 === lvTest.alternation || lvTest.alternation !== testPos.alternation || void 0 !== testPos.locator[lvTest.alternation] && checkAlternationMatch(testPos.locator[lvTest.alternation].toString().split(","), lvTestAltArr)))); ndx++) ;
  321. return testPos;
  322. }
  323. function getTest(pos) {
  324. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos].match : getTests(pos)[0].match;
  325. }
  326. function positionCanMatchDefinition(pos, def) {
  327. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
  328. valid = !0;
  329. break;
  330. }
  331. return valid;
  332. }
  333. function getTests(pos, ndxIntlzr, tstPs, cacheable) {
  334. function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  335. function handleMatch(match, loopNdx, quantifierRecurse) {
  336. function resolveNdxInitializer(pos, alternateNdx) {
  337. var previousMatch = getMaskSet().validPositions[pos];
  338. return void 0 === previousMatch && getMaskSet().tests[pos] && $.each(getMaskSet().tests[pos], function(ndx, lmnt) {
  339. return lmnt.alternation && -1 !== lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) ? (previousMatch = lmnt,
  340. !1) : void 0;
  341. }), previousMatch ? previousMatch.locator.slice(previousMatch.alternation + 1) : [];
  342. }
  343. 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;
  344. if (testPos === pos && void 0 === match.matches) return matches.push({
  345. match: match,
  346. locator: loopNdx.reverse()
  347. }), !0;
  348. if (void 0 !== match.matches) {
  349. if (match.isGroup && quantifierRecurse !== match) {
  350. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
  351. } else if (match.isOptional) {
  352. var optionalToken = match;
  353. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  354. if (latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 === $.inArray(latestMatch, optionalToken.matches),
  355. !isFirstMatch) return !0;
  356. insertStop = !0, testPos = pos;
  357. }
  358. } else if (match.isAlternator) {
  359. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  360. if (-1 === altIndex || "string" == typeof altIndex) {
  361. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  362. if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
  363. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  364. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx),
  365. match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  366. match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  367. var ntndx = maskToken.matches.indexOf(match) + 1;
  368. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse),
  369. match && (altIndexArr.push(ntndx.toString()), $.each(matches, function(ndx, lmnt) {
  370. lmnt.alternation = loopNdx.length - 1;
  371. })));
  372. }
  373. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  374. for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
  375. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  376. var altMatch = maltMatches[ndx1];
  377. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  378. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  379. var altMatch2 = malternateMatches[ndx2];
  380. if (altMatch.match.def === altMatch2.match.def && ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr))) {
  381. altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--),
  382. -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation],
  383. altMatch2.alternation = altMatch.alternation);
  384. break;
  385. }
  386. }
  387. }
  388. malternateMatches = malternateMatches.concat(maltMatches);
  389. }
  390. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  391. if (isFinite(ndx)) {
  392. var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  393. lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
  394. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = -1 !== $.inArray(altLocArr[alndx], altIndexArr),
  395. mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",",
  396. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  397. lmnt.alternation = alternation);
  398. if (void 0 !== lmnt.locator[alternation]) return lmnt;
  399. }
  400. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
  401. } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  402. if (match) return !0;
  403. } 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) && pos >= testPos; qndx++) {
  404. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  405. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  406. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  407. isFirstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches)) {
  408. if (qndx > qt.quantifier.min - 1) {
  409. insertStop = !0, testPos = pos;
  410. break;
  411. }
  412. return !0;
  413. }
  414. return !0;
  415. }
  416. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  417. } else testPos++;
  418. }
  419. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  420. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  421. if (match && testPos === pos) return match;
  422. if (testPos > pos) break;
  423. }
  424. }
  425. var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
  426. if (pos > -1) {
  427. if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
  428. if (void 0 === ndxIntlzr) {
  429. for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
  430. void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
  431. }
  432. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  433. var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  434. if (match && testPos === pos || testPos > pos) break;
  435. }
  436. return (0 === matches.length || insertStop) && matches.push({
  437. match: {
  438. fn: null,
  439. cardinality: 0,
  440. optionality: !0,
  441. casing: null,
  442. def: ""
  443. },
  444. locator: []
  445. }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
  446. }
  447. }
  448. function getBufferTemplate() {
  449. return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)),
  450. getMaskSet()._buffer;
  451. }
  452. function getBuffer(noCache) {
  453. return (void 0 === getMaskSet().buffer || noCache === !0) && (noCache === !0 && (getMaskSet().tests = {}),
  454. getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)), getMaskSet().buffer;
  455. }
  456. function refreshFromBuffer(start, end, buffer) {
  457. var i;
  458. if (buffer = buffer, start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i],
  459. delete getMaskSet().tests[i];
  460. for (i = start; end > i; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  461. }
  462. function casing(elem, test) {
  463. switch (test.casing) {
  464. case "upper":
  465. elem = elem.toUpperCase();
  466. break;
  467. case "lower":
  468. elem = elem.toLowerCase();
  469. }
  470. return elem;
  471. }
  472. function checkAlternationMatch(altArr1, altArr2) {
  473. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if (-1 !== $.inArray(altArr1[alndx], altArrC)) {
  474. isMatch = !0;
  475. break;
  476. }
  477. return isMatch;
  478. }
  479. function isValid(pos, c, strict, fromSetValid) {
  480. function _isValid(position, c, strict, fromSetValid) {
  481. var rslt = !1;
  482. return $.each(getTests(position), function(ndx, tst) {
  483. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  484. if (c && (chrs += c), getBuffer(!0), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts) : c !== test.def && c !== opts.skipOptionalPartCharacter || "" === test.def ? !1 : {
  485. c: test.def,
  486. pos: position
  487. }, rslt !== !1) {
  488. var elem = void 0 !== rslt.c ? rslt.c : c;
  489. elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.def : elem;
  490. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  491. if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  492. $.each(rslt.remove.sort(function(a, b) {
  493. return b - a;
  494. }), function(ndx, lmnt) {
  495. stripValidPositions(lmnt, lmnt + 1, !0);
  496. })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  497. $.each(rslt.insert.sort(function(a, b) {
  498. return a - b;
  499. }), function(ndx, lmnt) {
  500. isValid(lmnt.pos, lmnt.c, !0);
  501. })), rslt.refreshFromBuffer) {
  502. var refresh = rslt.refreshFromBuffer;
  503. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  504. void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(),
  505. !1;
  506. if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  507. !1;
  508. } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
  509. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  510. !1;
  511. return rslt !== !0 && void 0 === rslt.pos && void 0 === rslt.c ? !1 : (ndx > 0 && resetMaskSet(!0),
  512. setValidPosition(validatedPos, $.extend({}, tst, {
  513. input: casing(elem, test)
  514. }), fromSetValid) || (rslt = !1), !1);
  515. }
  516. }), rslt;
  517. }
  518. function alternate(pos, c, strict, fromSetValid) {
  519. for (var lastAlt, alternation, isValidRslt, altPos, i, validPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), lAlt = getLastValidPosition(); lAlt >= 0 && (altPos = getMaskSet().validPositions[lAlt],
  520. !altPos || void 0 === altPos.alternation || (lastAlt = lAlt, alternation = getMaskSet().validPositions[lastAlt].alternation,
  521. getTestTemplate(lastAlt).locator[altPos.alternation] === altPos.locator[altPos.alternation])); lAlt--) ;
  522. if (void 0 !== alternation) {
  523. lastAlt = parseInt(lastAlt);
  524. for (var decisionPos in getMaskSet().validPositions) if (decisionPos = parseInt(decisionPos),
  525. altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
  526. var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
  527. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  528. for (var mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
  529. for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp],
  530. void 0 !== possibilityPos) {
  531. possibilities = possibilityPos.locator[alternation], possibilityPos.locator[alternation] = parseInt(altNdxs[mndx]);
  532. break;
  533. }
  534. if (decisionTaker !== possibilityPos.locator[alternation]) {
  535. var validInputs = [], staticInputsBeforePos = 0;
  536. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  537. validPos && null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++,
  538. delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
  539. for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
  540. var input = validInputs.shift();
  541. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition() + 1, input, !1, !0))) break;
  542. }
  543. if (possibilityPos.alternation = alternation, possibilityPos.locator[alternation] = possibilities,
  544. isValidRslt) {
  545. var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0;
  546. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  547. (void 0 === validPos || null == validPos.match.fn) && pos > i && staticInputsBeforePosAlternate++;
  548. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
  549. }
  550. if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
  551. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  552. }
  553. }
  554. break;
  555. }
  556. }
  557. return !1;
  558. }
  559. function trackbackAlternations(originalPos, newPos) {
  560. for (var vp = getMaskSet().validPositions[newPos], targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; newPos > ps; ps++) if (!isMask(ps, !0)) {
  561. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  562. $.each(tests, function(ndx, tst) {
  563. for (var i = 0; tll > i; i++) tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(",")) && i > equality && (equality = i,
  564. bestMatch = tst);
  565. }), setValidPosition(ps, $.extend({}, bestMatch, {
  566. input: bestMatch.match.def
  567. }), !0);
  568. }
  569. }
  570. strict = strict === !0;
  571. for (var buffer = getBuffer(), pndx = pos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  572. for (pndx++; pos > pndx; pndx++) void 0 === getMaskSet().validPositions[pndx] && ((!isMask(pndx) || buffer[pndx] !== getPlaceholder(pndx)) && getTests(pndx).length > 1 || buffer[pndx] === opts.radixPoint || "0" === buffer[pndx] && $.inArray(opts.radixPoint, buffer) < pndx) && _isValid(pndx, buffer[pndx], !0);
  573. var maskPos = pos, result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  574. if (maskPos < getMaskLength() && (result = _isValid(maskPos, c, strict, fromSetValid),
  575. (!strict || fromSetValid) && result === !1)) {
  576. var currentPosValid = getMaskSet().validPositions[maskPos];
  577. if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  578. if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) for (var nPos = maskPos + 1, snPos = seekNext(maskPos); snPos >= nPos; nPos++) if (result = _isValid(nPos, c, strict, fromSetValid),
  579. result !== !1) {
  580. trackbackAlternations(maskPos, nPos), maskPos = nPos;
  581. break;
  582. }
  583. } else result = {
  584. caret: seekNext(maskPos)
  585. };
  586. }
  587. if (result === !1 && opts.keepStatic && (result = alternate(pos, c, strict, fromSetValid)),
  588. result === !0 && (result = {
  589. pos: maskPos
  590. }), $.isFunction(opts.postValidation) && result !== !1 && !strict) {
  591. var postValidResult = opts.postValidation(getBuffer(!0), opts);
  592. if (postValidResult) {
  593. if (postValidResult.refreshFromBuffer) {
  594. var refresh = postValidResult.refreshFromBuffer;
  595. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, postValidResult.buffer),
  596. resetMaskSet(!0), result = postValidResult;
  597. }
  598. } else resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  599. result = !1;
  600. }
  601. return result;
  602. }
  603. function isMask(pos, strict) {
  604. var test = getTest(pos);
  605. if (null != test.fn) return test.fn;
  606. if (strict !== !0 && pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  607. var tests = getTests(pos, void 0, void 0, !0);
  608. return tests.length > 2;
  609. }
  610. return !1;
  611. }
  612. function getMaskLength() {
  613. var maskLength;
  614. maxLength = void 0 !== el ? el.maxLength : void 0, -1 === maxLength && (maxLength = void 0);
  615. var pos, lvp = getLastValidPosition(), testPos = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== testPos ? testPos.locator.slice() : void 0;
  616. for (pos = lvp + 1; void 0 === testPos || null !== testPos.match.fn || null === testPos.match.fn && "" !== testPos.match.def; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  617. ndxIntlzr = testPos.locator.slice();
  618. var lastTest = getTest(pos - 1);
  619. return maskLength = "" !== lastTest.def ? pos : pos - 1, void 0 === maxLength || maxLength > maskLength ? maskLength : maxLength;
  620. }
  621. function seekNext(pos, newBlock) {
  622. var maskL = getMaskLength();
  623. if (pos >= maskL) return maskL;
  624. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position) && (opts.nojumps !== !0 || opts.nojumpsThreshold > position)); ) ;
  625. return position;
  626. }
  627. function seekPrevious(pos, newBlock) {
  628. var position = pos;
  629. if (0 >= position) return 0;
  630. for (;--position > 0 && (newBlock === !0 && getTest(position).newBlockMarker !== !0 || newBlock !== !0 && !isMask(position)); ) ;
  631. return position;
  632. }
  633. function getBufferElement(position) {
  634. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  635. }
  636. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  637. if (event && $.isFunction(opts.onBeforeWrite)) {
  638. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  639. if (result) {
  640. if (result.refreshFromBuffer) {
  641. var refresh = result.refreshFromBuffer;
  642. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  643. buffer = getBuffer(!0);
  644. }
  645. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  646. }
  647. }
  648. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type || caret(input, caretPos),
  649. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  650. }
  651. function getPlaceholder(pos, test) {
  652. if (test = test || getTest(pos), void 0 !== test.placeholder) return test.placeholder;
  653. if (null === test.fn) {
  654. if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
  655. var prevTest, tests = getTests(pos), staticAlternations = 0;
  656. if (tests.length > 2) for (var i = 0; i < tests.length; i++) if (tests[i].match.optionality !== !0 && tests[i].match.optionalQuantifier !== !0 && (null === tests[i].match.fn || void 0 === prevTest || tests[i].match.fn.test(prevTest.match.def, getMaskSet(), pos, !0, opts) !== !1) && (staticAlternations++,
  657. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations > 1)) return opts.placeholder.charAt(pos % opts.placeholder.length);
  658. }
  659. return test.def;
  660. }
  661. return opts.placeholder.charAt(pos % opts.placeholder.length);
  662. }
  663. function checkVal(input, writeOut, strict, nptvl) {
  664. function isTemplateMatch() {
  665. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  666. if (-1 !== charCodeNdx && !isMask(initialNdx)) {
  667. isMatch = !0;
  668. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
  669. isMatch = !1;
  670. break;
  671. }
  672. }
  673. return isMatch;
  674. }
  675. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0;
  676. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
  677. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  678. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  679. initialNdx = seekNext(initialNdx));
  680. } else initialNdx = seekNext(initialNdx);
  681. $.each(inputValue, function(ndx, charCode) {
  682. var keypress = $.Event("keypress");
  683. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  684. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  685. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  686. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  687. keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  688. charCodes = "";
  689. } else keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  690. }), writeOut && writeBuffer(input, getBuffer(), document.activeElement === input ? seekNext(getLastValidPosition(0)) : void 0, $.Event("checkval"));
  691. }
  692. function unmaskedvalue(input) {
  693. if (input && void 0 === input.inputmask) return input.value;
  694. var umValue = [], vps = getMaskSet().validPositions;
  695. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  696. var unmaskedValue = 0 === umValue.length ? null : (isRTL ? umValue.reverse() : umValue).join("");
  697. if (null !== unmaskedValue) {
  698. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  699. $.isFunction(opts.onUnMask) && (unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
  700. }
  701. return unmaskedValue;
  702. }
  703. function caret(input, begin, end) {
  704. function translatePosition(pos) {
  705. if (isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  706. var bffrLght = getBuffer().join("").length;
  707. pos = bffrLght - pos;
  708. }
  709. return pos;
  710. }
  711. var range;
  712. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  713. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  714. (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) && (begin = range.startOffset,
  715. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  716. begin = 0 - range.duplicate().moveStart("character", -1e5), end = begin + range.text.length),
  717. {
  718. begin: translatePosition(begin),
  719. end: translatePosition(end)
  720. };
  721. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  722. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  723. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, androidchrome || opts.insertMode !== !1 || begin !== end || end++,
  724. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  725. if (range = document.createRange(), void 0 === input.firstChild) {
  726. var textNode = document.createTextNode("");
  727. input.appendChild(textNode);
  728. }
  729. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  730. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  731. range.collapse(!0);
  732. var sel = window.getSelection();
  733. sel.removeAllRanges(), sel.addRange(range);
  734. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  735. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  736. }
  737. function determineLastRequiredPosition(returnDefinition) {
  738. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  739. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  740. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  741. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  742. for (pos = bl - 1; pos > lvp && (testPos = positions[pos], (testPos.match.optionality || testPos.match.optionalQuantifier || 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--;
  743. return returnDefinition ? {
  744. l: bl,
  745. def: positions[bl] ? positions[bl].match : void 0
  746. } : bl;
  747. }
  748. function clearOptionalTail(buffer) {
  749. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  750. return buffer.splice(rl, lmib + 1 - rl), buffer;
  751. }
  752. function isComplete(buffer) {
  753. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  754. if ("*" === opts.repeat) return void 0;
  755. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  756. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  757. complete = !0;
  758. for (var i = 0; aml >= i; i++) {
  759. var test = getTestTemplate(i).match;
  760. if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  761. complete = !1;
  762. break;
  763. }
  764. }
  765. }
  766. return complete;
  767. }
  768. function isSelection(begin, end) {
  769. return isRTL ? begin - end > 1 || begin - end === 1 && opts.insertMode : end - begin > 1 || end - begin === 1 && opts.insertMode;
  770. }
  771. function wrapEventRuler(eventHandler) {
  772. return function(e) {
  773. var inComposition = !1, keydownPressed = !1;
  774. if (void 0 === this.inputmask) {
  775. var imOpts = $.data(this, "_inputmask_opts");
  776. imOpts ? new Inputmask(imOpts).mask(this) : $(this).off(".inputmask");
  777. } else {
  778. if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  779. switch (e.type) {
  780. case "input":
  781. if (skipInputEvent === !0 || inComposition === !0) return skipInputEvent = !1, e.preventDefault();
  782. keydownPressed = !1;
  783. break;
  784. case "keydown":
  785. skipKeyPressEvent = !1, inComposition = !1, keydownPressed = !0;
  786. break;
  787. case "keypress":
  788. if (skipKeyPressEvent === !0) return e.preventDefault();
  789. skipKeyPressEvent = !0;
  790. break;
  791. case "compositionstart":
  792. inComposition = !0;
  793. break;
  794. case "compositionupdate":
  795. skipInputEvent = keydownPressed;
  796. break;
  797. case "compositionend":
  798. inComposition = !1, keydownPressed = !1;
  799. break;
  800. case "cut":
  801. skipInputEvent = !0;
  802. }
  803. return eventHandler.apply(this, arguments);
  804. }
  805. e.preventDefault();
  806. }
  807. };
  808. }
  809. function patchValueProperty(npt) {
  810. function patchValhook(type) {
  811. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  812. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  813. return elem.value;
  814. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  815. return elem.value = value, elem;
  816. };
  817. $.valHooks[type] = {
  818. get: function(elem) {
  819. if (elem.inputmask) {
  820. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  821. var result = valhookGet(elem), maskset = elem.inputmask.maskset, bufferTemplate = maskset._buffer;
  822. return bufferTemplate = bufferTemplate ? bufferTemplate.join("") : "", result !== bufferTemplate ? result : "";
  823. }
  824. return valhookGet(elem);
  825. },
  826. set: function(elem, value) {
  827. var result, $elem = $(elem);
  828. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue.inputmask"),
  829. result;
  830. },
  831. inputmaskpatch: !0
  832. };
  833. }
  834. }
  835. function getter() {
  836. return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : valueGet.call(this) !== getBufferTemplate().join("") ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
  837. }
  838. function setter(value) {
  839. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue.inputmask");
  840. }
  841. function installNativeValueSetFallback(npt) {
  842. $(npt).on("mouseenter.inputmask", wrapEventRuler(function(event) {
  843. var $input = $(this), input = this, value = input.inputmask._valueGet();
  844. "" !== value && value !== getBuffer().join("") && $input.trigger("setvalue.inputmask");
  845. }));
  846. }
  847. var valueGet, valueSet;
  848. npt.inputmask.__valueGet || (Object.getOwnPropertyDescriptor && void 0 === npt.value ? (valueGet = function() {
  849. return this.textContent;
  850. }, valueSet = function(value) {
  851. this.textContent = value;
  852. }, Object.defineProperty(npt, "value", {
  853. get: getter,
  854. set: setter
  855. })) : document.__lookupGetter__ && npt.__lookupGetter__("value") ? (valueGet = npt.__lookupGetter__("value"),
  856. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  857. npt.__defineSetter__("value", setter)) : (valueGet = function() {
  858. return npt.value;
  859. }, valueSet = function(value) {
  860. npt.value = value;
  861. }, patchValhook(npt.type), installNativeValueSetFallback(npt)), npt.inputmask.__valueGet = valueGet,
  862. npt.inputmask._valueGet = function(overruleRTL) {
  863. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  864. }, npt.inputmask.__valueSet = valueSet, npt.inputmask._valueSet = function(value, overruleRTL) {
  865. valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  866. });
  867. }
  868. function handleRemove(input, k, pos, strict) {
  869. function generalize() {
  870. if (opts.keepStatic) {
  871. resetMaskSet(!0);
  872. var lastAlt, validInputs = [], positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  873. for (lastAlt = getLastValidPosition(); lastAlt >= 0; lastAlt--) {
  874. var validPos = getMaskSet().validPositions[lastAlt];
  875. if (validPos && (null != validPos.match.fn && validInputs.push(validPos.input),
  876. delete getMaskSet().validPositions[lastAlt], void 0 !== validPos.alternation && validPos.locator[validPos.alternation] === getTestTemplate(lastAlt).locator[validPos.alternation])) break;
  877. }
  878. if (lastAlt > -1) for (;validInputs.length > 0; ) {
  879. getMaskSet().p = seekNext(getLastValidPosition());
  880. var keypress = $.Event("keypress");
  881. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  882. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  883. }
  884. }
  885. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  886. isRTL)) {
  887. var pend = pos.end;
  888. pos.end = pos.begin, pos.begin = pend;
  889. }
  890. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  891. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.begin--) : k === Inputmask.keyCode.DELETE && pos.begin === pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1,
  892. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  893. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  894. var lvp = getLastValidPosition(pos.begin);
  895. lvp < pos.begin ? (-1 === lvp && resetMaskSet(), getMaskSet().p = seekNext(lvp)) : strict !== !0 && (getMaskSet().p = pos.begin);
  896. }
  897. function keydownEvent(e) {
  898. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  899. k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && 127 === k || e.ctrlKey && 88 === k && !isInputEventSupported("cut") ? (e.preventDefault(),
  900. 88 === k && (undoValue = getBuffer().join("")), handleRemove(input, k, pos), writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  901. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  902. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask)) : k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN ? setTimeout(function() {
  903. var caretPos = seekNext(getLastValidPosition());
  904. opts.insertMode || caretPos !== getMaskLength() || e.shiftKey || caretPos--, caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
  905. }, 0) : k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? caret(input, 0, e.shiftKey ? pos.begin : 0) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
  906. $input.trigger("click")) : k !== Inputmask.keyCode.INSERT || e.shiftKey || e.ctrlKey ? opts.tabThrough === !0 && k === Inputmask.keyCode.TAB ? (e.shiftKey === !0 ? (null === getTest(pos.begin).fn && (pos.begin = seekNext(pos.begin)),
  907. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  908. pos.end = seekNext(pos.begin, !0), pos.end < getMaskLength() && pos.end--), pos.begin < getMaskLength() && (e.preventDefault(),
  909. caret(input, pos.begin, pos.end))) : opts.insertMode !== !1 || e.shiftKey || (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  910. var caretPos = caret(input);
  911. caret(input, caretPos.begin);
  912. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  913. var caretPos = caret(input);
  914. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  915. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskLength() ? pos.begin : pos.begin - 1)),
  916. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = -1 !== $.inArray(k, opts.ignorables);
  917. }
  918. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  919. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  920. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  921. e.preventDefault(), setTimeout(function() {
  922. $input.trigger("change");
  923. }, 0)), !0;
  924. if (k) {
  925. 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
  926. var forwardPosition, pos = checkval ? {
  927. begin: ndx,
  928. end: ndx
  929. } : caret(input), c = String.fromCharCode(k), isSlctn = isSelection(pos.begin, pos.end);
  930. isSlctn && (getMaskSet().undoPositions = $.extend(!0, {}, getMaskSet().validPositions),
  931. handleRemove(input, Inputmask.keyCode.DELETE, pos, !0), pos.begin = getMaskSet().p,
  932. opts.insertMode || (opts.insertMode = !opts.insertMode, setValidPosition(pos.begin, strict),
  933. opts.insertMode = !opts.insertMode), isSlctn = !opts.multi), getMaskSet().writeOutBuffer = !0;
  934. var p = isRTL && !isSlctn ? pos.end : pos.begin, valResult = isValid(p, c, strict);
  935. if (valResult !== !1) {
  936. if (valResult !== !0 && (p = void 0 !== valResult.pos ? valResult.pos : p, c = void 0 !== valResult.c ? valResult.c : c),
  937. resetMaskSet(!0), void 0 !== valResult.caret) forwardPosition = valResult.caret; else {
  938. var vps = getMaskSet().validPositions;
  939. forwardPosition = !opts.keepStatic && (void 0 !== vps[p + 1] && getTests(p + 1, vps[p].locator.slice(), p).length > 1 || void 0 !== vps[p].alternation) ? p + 1 : seekNext(p);
  940. }
  941. getMaskSet().p = forwardPosition;
  942. }
  943. if (writeOut !== !1) {
  944. var self = this;
  945. if (setTimeout(function() {
  946. opts.onKeyValidation.call(self, k, valResult, opts);
  947. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  948. var buffer = getBuffer();
  949. writeBuffer(input, buffer, checkval ? void 0 : opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  950. checkval !== !0 && setTimeout(function() {
  951. isComplete(buffer) === !0 && $input.trigger("complete");
  952. }, 0);
  953. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  954. } else isSlctn && (getMaskSet().buffer = void 0, getMaskSet().validPositions = getMaskSet().undoPositions);
  955. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), checkval && $.isFunction(opts.onBeforeWrite)) {
  956. var result = opts.onBeforeWrite(e, getBuffer(), forwardPosition, opts);
  957. if (result && result.refreshFromBuffer) {
  958. var refresh = result.refreshFromBuffer;
  959. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  960. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  961. }
  962. }
  963. if (e.preventDefault(), checkval) return valResult;
  964. }
  965. }
  966. function pasteEvent(e) {
  967. var input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  968. if ("propertychange" === e.type && input.inputmask._valueGet().length <= getMaskLength()) return !0;
  969. if ("paste" === e.type) {
  970. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  971. valueBeforeCaret === getBufferTemplate().slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  972. valueAfterCaret === getBufferTemplate().slice(caretPos.end).join("") && (valueAfterCaret = ""),
  973. window.clipboardData && window.clipboardData.getData ? inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret : ev.clipboardData && ev.clipboardData.getData && (inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret);
  974. }
  975. var pasteValue = inputValue;
  976. if ($.isFunction(opts.onBeforePaste)) {
  977. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault(),
  978. !1;
  979. pasteValue || (pasteValue = inputValue);
  980. }
  981. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  982. writeBuffer(input, getBuffer(), void 0, e, !0), $input.trigger("click"), isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  983. !1;
  984. }
  985. function inputFallBackEvent(e) {
  986. var input = this;
  987. checkVal(input, !0, !1, input.inputmask._valueGet().split("")), isComplete(getBuffer()) === !0 && $(input).trigger("complete"),
  988. e.preventDefault();
  989. }
  990. function mobileInputEvent(e) {
  991. var input = this, caretPos = caret(input), currentValue = input._valueGet();
  992. currentValue = currentValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  993. caretPos.begin > currentValue.length && (caret(input, currentValue.length), caretPos = caret(input)),
  994. getBuffer().length - currentValue.length !== 1 || currentValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || currentValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin) ? inputFallBackEvent.call(this, e) : (e.keyCode = opts.keyCode.BACKSPACE,
  995. keydownEvent.call(input, e)), e.preventDefault();
  996. }
  997. function compositionStartEvent(e) {
  998. var ev = e.originalEvent || e;
  999. undoValue = getBuffer().join(""), "" === compositionData || 0 !== ev.data.indexOf(compositionData);
  1000. }
  1001. function compositionUpdateEvent(e) {
  1002. var input = this, ev = e.originalEvent || e;
  1003. 0 === ev.data.indexOf(compositionData) && (resetMaskSet(), getMaskSet().p = seekNext(-1),
  1004. skipInputEvent = !0);
  1005. for (var newData = ev.data, i = 0; i < newData.length; i++) {
  1006. var keypress = $.Event("keypress");
  1007. keypress.which = newData.charCodeAt(i), skipKeyPressEvent = !1, ignorable = !1,
  1008. keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  1009. }
  1010. setTimeout(function() {
  1011. var forwardPosition = getMaskSet().p;
  1012. writeBuffer(input, getBuffer(), opts.numericInput ? seekPrevious(forwardPosition) : forwardPosition);
  1013. }, 0), compositionData = ev.data;
  1014. }
  1015. function compositionEndEvent(e) {}
  1016. function setValueEvent(e) {
  1017. var input = this, value = input.inputmask._valueGet();
  1018. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  1019. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1020. }
  1021. function focusEvent(e) {
  1022. var input = this, nptValue = input.inputmask._valueGet();
  1023. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1024. opts.positionCaretOnTab === !0 && setTimeout(function() {
  1025. caret(input, seekNext(getLastValidPosition()));
  1026. }, 0), undoValue = getBuffer().join("");
  1027. }
  1028. function mouseleaveEvent(e) {
  1029. var input = this;
  1030. if (mouseEnter = !1, opts.clearMaskOnLostFocus) {
  1031. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1032. document.activeElement !== input && nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1033. writeBuffer(input, buffer));
  1034. }
  1035. }
  1036. function clickEvent(e) {
  1037. function doRadixFocus(clickPos) {
  1038. if (opts.radixFocus && "" !== opts.radixPoint) {
  1039. var vps = getMaskSet().validPositions;
  1040. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1041. if (clickPos < seekNext(-1)) return !0;
  1042. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1043. if (-1 !== radixPos) {
  1044. for (var vp in vps) if (vp > radixPos && vps[vp].input !== getPlaceholder(vp)) return !1;
  1045. return !0;
  1046. }
  1047. }
  1048. }
  1049. return !1;
  1050. }
  1051. var input = this;
  1052. if (document.activeElement === input) {
  1053. var selectedCaret = caret(input);
  1054. if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
  1055. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
  1056. lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : ((getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || !isMask(lastPosition, !0) && getTest(lastPosition).def === getPlaceholder(lastPosition)) && (lastPosition = seekNext(lastPosition)),
  1057. caret(input, opts.numericInput ? 0 : lastPosition));
  1058. }
  1059. }
  1060. }
  1061. function dblclickEvent(e) {
  1062. var input = this;
  1063. setTimeout(function() {
  1064. caret(input, 0, seekNext(getLastValidPosition()));
  1065. }, 0);
  1066. }
  1067. function cutEvent(e) {
  1068. 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);
  1069. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1070. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1071. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1072. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1073. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1074. }
  1075. function blurEvent(e) {
  1076. var $input = $(this), input = this;
  1077. if (input.inputmask) {
  1078. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1079. undoValue !== buffer.join("") && setTimeout(function() {
  1080. $input.trigger("change"), undoValue = buffer.join("");
  1081. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (-1 === getLastValidPosition() && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1082. isComplete(buffer) === !1 && (setTimeout(function() {
  1083. $input.trigger("incomplete");
  1084. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1085. writeBuffer(input, buffer, void 0, e));
  1086. }
  1087. }
  1088. function mouseenterEvent(e) {
  1089. var input = this;
  1090. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1091. }
  1092. function submitEvent(e) {
  1093. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && -1 === getLastValidPosition() && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1094. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1095. setTimeout(function() {
  1096. writeBuffer(el, getBuffer());
  1097. }, 0));
  1098. }
  1099. function resetEvent(e) {
  1100. setTimeout(function() {
  1101. $el.trigger("setvalue.inputmask");
  1102. }, 0);
  1103. }
  1104. function mask(elem) {
  1105. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1106. ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
  1107. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), $el.off(".inputmask"),
  1108. patchValueProperty(el), ("INPUT" === el.tagName && isInputTypeSupported(el.getAttribute("type")) || el.isContentEditable) && ($(el.form).on("submit.inputmask", submitEvent).on("reset.inputmask", resetEvent),
  1109. $el.on("mouseenter.inputmask", wrapEventRuler(mouseenterEvent)).on("blur.inputmask", wrapEventRuler(blurEvent)).on("focus.inputmask", wrapEventRuler(focusEvent)).on("mouseleave.inputmask", wrapEventRuler(mouseleaveEvent)).on("click.inputmask", wrapEventRuler(clickEvent)).on("dblclick.inputmask", wrapEventRuler(dblclickEvent)).on(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", wrapEventRuler(pasteEvent)).on("cut.inputmask", wrapEventRuler(cutEvent)).on("complete.inputmask", wrapEventRuler(opts.oncomplete)).on("incomplete.inputmask", wrapEventRuler(opts.onincomplete)).on("cleared.inputmask", wrapEventRuler(opts.oncleared)).on("keydown.inputmask", wrapEventRuler(keydownEvent)).on("keypress.inputmask", wrapEventRuler(keypressEvent)),
  1110. androidfirefox || $el.on("compositionstart.inputmask", wrapEventRuler(compositionStartEvent)).on("compositionupdate.inputmask", wrapEventRuler(compositionUpdateEvent)).on("compositionend.inputmask", wrapEventRuler(compositionEndEvent)),
  1111. "paste" === PasteEventType && $el.on("input.inputmask", wrapEventRuler(inputFallBackEvent)),
  1112. (android || androidfirefox || androidchrome || kindle) && ($el.off("input.inputmask"),
  1113. $el.on("input.inputmask", wrapEventRuler(mobileInputEvent)))), $el.on("setvalue.inputmask", wrapEventRuler(setValueEvent)),
  1114. "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1) {
  1115. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1116. checkVal(el, !0, !1, initialValue.split(""));
  1117. var buffer = getBuffer().slice();
  1118. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1119. opts.clearMaskOnLostFocus && (buffer.join("") === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1120. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1121. }
  1122. }
  1123. var undoValue, compositionData, el, $el, maxLength, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0;
  1124. if (void 0 !== actionObj) switch (actionObj.action) {
  1125. case "isComplete":
  1126. return el = actionObj.el, isComplete(getBuffer());
  1127. case "unmaskedvalue":
  1128. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1129. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1130. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1131. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1132. unmaskedvalue(el);
  1133. case "mask":
  1134. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1135. undoValue = getBuffer().join(""), mask(el);
  1136. break;
  1137. case "format":
  1138. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1139. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1140. actionObj.metadata ? {
  1141. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1142. metadata: maskScope({
  1143. action: "getmetadata"
  1144. }, maskset, opts)
  1145. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1146. case "isValid":
  1147. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1148. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1149. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1150. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1151. case "getemptymask":
  1152. return getBufferTemplate();
  1153. case "remove":
  1154. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1155. el.inputmask._valueSet(unmaskedvalue(el)), $el.off(".inputmask");
  1156. var valueProperty;
  1157. Object.getOwnPropertyDescriptor && (valueProperty = Object.getOwnPropertyDescriptor(el, "value")),
  1158. valueProperty && valueProperty.get ? el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1159. get: el.inputmask.__valueGet,
  1160. set: el.inputmask.__valueSet
  1161. }) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1162. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1163. break;
  1164. case "getmetadata":
  1165. if ($.isArray(maskset.metadata)) {
  1166. for (var alternation, lvp = getLastValidPosition(), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1167. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1168. break;
  1169. }
  1170. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[lvp].locator[alternation]] : maskset.metadata[0];
  1171. }
  1172. return maskset.metadata;
  1173. }
  1174. }
  1175. Inputmask.prototype = {
  1176. defaults: {
  1177. placeholder: "_",
  1178. optionalmarker: {
  1179. start: "[",
  1180. end: "]"
  1181. },
  1182. quantifiermarker: {
  1183. start: "{",
  1184. end: "}"
  1185. },
  1186. groupmarker: {
  1187. start: "(",
  1188. end: ")"
  1189. },
  1190. alternatormarker: "|",
  1191. escapeChar: "\\",
  1192. mask: null,
  1193. oncomplete: $.noop,
  1194. onincomplete: $.noop,
  1195. oncleared: $.noop,
  1196. repeat: 0,
  1197. greedy: !0,
  1198. autoUnmask: !1,
  1199. removeMaskOnSubmit: !1,
  1200. clearMaskOnLostFocus: !0,
  1201. insertMode: !0,
  1202. clearIncomplete: !1,
  1203. aliases: {},
  1204. alias: null,
  1205. onKeyDown: $.noop,
  1206. onBeforeMask: null,
  1207. onBeforePaste: function(pastedValue, opts) {
  1208. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1209. },
  1210. onBeforeWrite: null,
  1211. onUnMask: null,
  1212. showMaskOnFocus: !0,
  1213. showMaskOnHover: !0,
  1214. onKeyValidation: $.noop,
  1215. skipOptionalPartCharacter: " ",
  1216. showTooltip: !1,
  1217. tooltip: void 0,
  1218. numericInput: !1,
  1219. rightAlign: !1,
  1220. undoOnEscape: !0,
  1221. radixPoint: "",
  1222. groupSeparator: "",
  1223. radixFocus: !1,
  1224. nojumps: !1,
  1225. nojumpsThreshold: 0,
  1226. keepStatic: null,
  1227. positionCaretOnTab: !1,
  1228. tabThrough: !1,
  1229. supportsInputType: [],
  1230. definitions: {
  1231. "9": {
  1232. validator: "[0-9]",
  1233. cardinality: 1,
  1234. definitionSymbol: "*"
  1235. },
  1236. a: {
  1237. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1238. cardinality: 1,
  1239. definitionSymbol: "*"
  1240. },
  1241. "*": {
  1242. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1243. cardinality: 1
  1244. }
  1245. },
  1246. 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 ],
  1247. isComplete: null,
  1248. canClearPosition: $.noop,
  1249. postValidation: null
  1250. },
  1251. masksCache: {},
  1252. mask: function(elems) {
  1253. var that = this;
  1254. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1255. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1256. var scopedOpts = $.extend(!0, {}, that.opts);
  1257. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1258. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1259. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1260. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1261. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1262. maskScope({
  1263. action: "mask",
  1264. el: el
  1265. }));
  1266. }), elems ? elems[0].inputmask || this : this;
  1267. },
  1268. option: function(options) {
  1269. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.opts, options),
  1270. $.extend(this.userOptions, options), this.el && (void 0 !== options.mask || void 0 !== options.alias ? this.mask(this.el) : ($.data(this.el, "_inputmask_opts", this.opts),
  1271. maskScope({
  1272. action: "mask",
  1273. el: this.el
  1274. }))), this) : void 0;
  1275. },
  1276. unmaskedvalue: function(value) {
  1277. return maskScope({
  1278. action: "unmaskedvalue",
  1279. el: this.el,
  1280. value: value
  1281. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1282. },
  1283. remove: function() {
  1284. return this.el ? (maskScope({
  1285. action: "remove",
  1286. el: this.el
  1287. }), this.el.inputmask = void 0, this.el) : void 0;
  1288. },
  1289. getemptymask: function() {
  1290. return maskScope({
  1291. action: "getemptymask"
  1292. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1293. },
  1294. hasMaskedValue: function() {
  1295. return !this.opts.autoUnmask;
  1296. },
  1297. isComplete: function() {
  1298. return maskScope({
  1299. action: "isComplete",
  1300. el: this.el
  1301. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1302. },
  1303. getmetadata: function() {
  1304. return maskScope({
  1305. action: "getmetadata"
  1306. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1307. },
  1308. isValid: function(value) {
  1309. return maskScope({
  1310. action: "isValid",
  1311. value: value
  1312. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1313. },
  1314. format: function(value, metadata) {
  1315. return maskScope({
  1316. action: "format",
  1317. value: value,
  1318. metadata: metadata
  1319. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1320. }
  1321. }, Inputmask.extendDefaults = function(options) {
  1322. $.extend(!0, Inputmask.prototype.defaults, options);
  1323. }, Inputmask.extendDefinitions = function(definition) {
  1324. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1325. }, Inputmask.extendAliases = function(alias) {
  1326. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1327. }, Inputmask.format = function(value, options, metadata) {
  1328. return Inputmask(options).format(value, metadata);
  1329. }, Inputmask.unmask = function(value, options) {
  1330. return Inputmask(options).unmaskedvalue(value);
  1331. }, Inputmask.isValid = function(value, options) {
  1332. return Inputmask(options).isValid(value);
  1333. }, Inputmask.remove = function(elems) {
  1334. $.each(elems, function(ndx, el) {
  1335. el.inputmask && el.inputmask.remove();
  1336. });
  1337. }, Inputmask.escapeRegex = function(str) {
  1338. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1339. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1340. }, Inputmask.keyCode = {
  1341. ALT: 18,
  1342. BACKSPACE: 8,
  1343. CAPS_LOCK: 20,
  1344. COMMA: 188,
  1345. COMMAND: 91,
  1346. COMMAND_LEFT: 91,
  1347. COMMAND_RIGHT: 93,
  1348. CONTROL: 17,
  1349. DELETE: 46,
  1350. DOWN: 40,
  1351. END: 35,
  1352. ENTER: 13,
  1353. ESCAPE: 27,
  1354. HOME: 36,
  1355. INSERT: 45,
  1356. LEFT: 37,
  1357. MENU: 93,
  1358. NUMPAD_ADD: 107,
  1359. NUMPAD_DECIMAL: 110,
  1360. NUMPAD_DIVIDE: 111,
  1361. NUMPAD_ENTER: 108,
  1362. NUMPAD_MULTIPLY: 106,
  1363. NUMPAD_SUBTRACT: 109,
  1364. PAGE_DOWN: 34,
  1365. PAGE_UP: 33,
  1366. PERIOD: 190,
  1367. RIGHT: 39,
  1368. SHIFT: 16,
  1369. SPACE: 32,
  1370. TAB: 9,
  1371. UP: 38,
  1372. WINDOWS: 91
  1373. };
  1374. var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), android = null !== ua.match(new RegExp("android.*safari.*", "i")), androidchrome = null !== ua.match(new RegExp("android.*chrome.*", "i")), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), kindle = /Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), PasteEventType = isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange";
  1375. return window.Inputmask = Inputmask, Inputmask;
  1376. });