inputmask.js 94 KB

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