jquery.inputmask.bundle.js 172 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723
  1. /*!
  2. * jquery.inputmask.bundle.js
  3. * https://github.com/RobinHerbots/jquery.inputmask
  4. * Copyright (c) 2010 - 2016 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 3.3.4-53
  7. */
  8. !function($) {
  9. function Inputmask(alias, options) {
  10. return this instanceof Inputmask ? ($.isPlainObject(alias) ? options = alias : (options = options || {},
  11. options.alias = alias), this.el = void 0, this.opts = $.extend(!0, {}, this.defaults, options),
  12. this.noMasksCache = options && void 0 !== options.definitions, this.userOptions = options || {},
  13. this.events = {}, void resolveAlias(this.opts.alias, options, this.opts)) : new Inputmask(alias, options);
  14. }
  15. function isInputEventSupported(eventName) {
  16. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  17. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  18. el = null, isSupported;
  19. }
  20. function isElementTypeSupported(input, opts) {
  21. var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || "TEXTAREA" === input.tagName;
  22. if (!isSupported && "INPUT" === input.tagName) {
  23. var el = document.createElement("input");
  24. el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
  25. }
  26. return isSupported;
  27. }
  28. function resolveAlias(aliasStr, options, opts) {
  29. var aliasDefinition = opts.aliases[aliasStr];
  30. return aliasDefinition ? (aliasDefinition.alias && resolveAlias(aliasDefinition.alias, void 0, opts),
  31. $.extend(!0, opts, aliasDefinition), $.extend(!0, opts, options), !0) : (null === opts.mask && (opts.mask = aliasStr),
  32. !1);
  33. }
  34. function importAttributeOptions(npt, opts, userOptions) {
  35. function importOption(option, optionData) {
  36. optionData = void 0 !== optionData ? optionData : npt.getAttribute("data-inputmask-" + option),
  37. null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  38. userOptions[option] = optionData);
  39. }
  40. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute("data-inputmask");
  41. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  42. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  43. optionData = void 0;
  44. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  45. optionData = dataoptions[p];
  46. break;
  47. }
  48. }
  49. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  50. for (option in opts) {
  51. if (dataoptions) {
  52. optionData = void 0;
  53. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  54. optionData = dataoptions[p];
  55. break;
  56. }
  57. }
  58. importOption(option, optionData);
  59. }
  60. return $.extend(!0, opts, userOptions), opts;
  61. }
  62. function generateMaskSet(opts, nocache) {
  63. function analyseMask(mask) {
  64. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  65. this.matches = [], this.isGroup = isGroup || !1, this.isOptional = isOptional || !1,
  66. this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  67. this.quantifier = {
  68. min: 1,
  69. max: 1
  70. };
  71. }
  72. function insertTestDefinition(mtoken, element, position) {
  73. var maskdef = opts.definitions[element];
  74. position = void 0 !== position ? position : mtoken.matches.length;
  75. var prevMatch = mtoken.matches[position - 1];
  76. if (maskdef && !escaped) {
  77. maskdef.placeholder = $.isFunction(maskdef.placeholder) ? maskdef.placeholder(opts) : maskdef.placeholder;
  78. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  79. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  80. mtoken.matches.splice(position++, 0, {
  81. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  82. this.test = validator;
  83. }() : new RegExp("."),
  84. cardinality: cardinality ? cardinality : 1,
  85. optionality: mtoken.isOptional,
  86. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  87. casing: maskdef.casing,
  88. def: maskdef.definitionSymbol || element,
  89. placeholder: maskdef.placeholder,
  90. nativeDef: element
  91. }), prevMatch = mtoken.matches[position - 1];
  92. }
  93. mtoken.matches.splice(position++, 0, {
  94. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  95. this.test = maskdef.validator;
  96. }() : new RegExp("."),
  97. cardinality: maskdef.cardinality,
  98. optionality: mtoken.isOptional,
  99. newBlockMarker: void 0 === prevMatch || prevMatch.def !== (maskdef.definitionSymbol || element),
  100. casing: maskdef.casing,
  101. def: maskdef.definitionSymbol || element,
  102. placeholder: maskdef.placeholder,
  103. nativeDef: element
  104. });
  105. } else mtoken.matches.splice(position++, 0, {
  106. fn: null,
  107. cardinality: 0,
  108. optionality: mtoken.isOptional,
  109. newBlockMarker: void 0 === prevMatch || prevMatch.def !== element,
  110. casing: null,
  111. def: opts.staticDefinitionSymbol || element,
  112. placeholder: void 0 !== opts.staticDefinitionSymbol ? element : void 0,
  113. nativeDef: element
  114. }), escaped = !1;
  115. }
  116. function verifyGroupMarker(lastMatch, isOpenGroup) {
  117. lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0),
  118. isOpenGroup !== !0 && insertTestDefinition(lastMatch, opts.groupmarker.end));
  119. }
  120. function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
  121. currentToken.matches.length > 0 && (void 0 === extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  122. verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
  123. }
  124. function defaultCase() {
  125. if (openenings.length > 0) {
  126. if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator),
  127. currentOpeningToken.isAlternator) {
  128. alternator = openenings.pop();
  129. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  130. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  131. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  132. }
  133. } else maskCurrentToken(m, currentToken, lastMatch);
  134. }
  135. function reverseTokens(maskToken) {
  136. function reverseStatic(st) {
  137. 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),
  138. st;
  139. }
  140. maskToken.matches = maskToken.matches.reverse();
  141. for (var match in maskToken.matches) {
  142. var intMatch = parseInt(match);
  143. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  144. var qt = maskToken.matches[match];
  145. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  146. }
  147. void 0 !== maskToken.matches[match].matches ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  148. }
  149. return maskToken;
  150. }
  151. 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],
  152. escaped) defaultCase(); else switch (m.charAt(0)) {
  153. case opts.escapeChar:
  154. escaped = !0;
  155. break;
  156. case opts.optionalmarker.end:
  157. case opts.groupmarker.end:
  158. if (openingToken = openenings.pop(), void 0 !== openingToken) if (openenings.length > 0) {
  159. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  160. currentOpeningToken.isAlternator) {
  161. alternator = openenings.pop();
  162. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  163. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  164. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  165. }
  166. } else currentToken.matches.push(openingToken); else defaultCase();
  167. break;
  168. case opts.optionalmarker.start:
  169. openenings.push(new MaskToken((!1), (!0)));
  170. break;
  171. case opts.groupmarker.start:
  172. openenings.push(new MaskToken((!0)));
  173. break;
  174. case opts.quantifiermarker.start:
  175. var quantifier = new MaskToken((!1), (!1), (!0));
  176. m = m.replace(/[{}]/g, "");
  177. 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]);
  178. if ("*" !== mq1 && "+" !== mq1 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  179. min: mq0,
  180. max: mq1
  181. }, openenings.length > 0) {
  182. var matches = openenings[openenings.length - 1].matches;
  183. match = matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)), groupToken.matches.push(match),
  184. match = groupToken), matches.push(match), matches.push(quantifier);
  185. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)),
  186. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  187. currentToken.matches.push(quantifier);
  188. break;
  189. case opts.alternatormarker:
  190. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  191. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  192. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken((!1), (!1), (!1), (!0)),
  193. alternator.matches.push(lastMatch), openenings.push(alternator));
  194. break;
  195. default:
  196. defaultCase();
  197. }
  198. for (;openenings.length > 0; ) openingToken = openenings.pop(), verifyGroupMarker(openingToken, !0),
  199. currentToken.matches.push(openingToken);
  200. return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1],
  201. verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), opts.numericInput && reverseTokens(maskTokens[0]),
  202. maskTokens;
  203. }
  204. function generateMask(mask, metadata) {
  205. if (null !== mask && "" !== mask) {
  206. if (1 === mask.length && opts.greedy === !1 && 0 !== opts.repeat && (opts.placeholder = ""),
  207. opts.repeat > 0 || "*" === opts.repeat || "+" === opts.repeat) {
  208. var repeatStart = "*" === opts.repeat ? 0 : "+" === opts.repeat ? 1 : opts.repeat;
  209. mask = opts.groupmarker.start + mask + opts.groupmarker.end + opts.quantifiermarker.start + repeatStart + "," + opts.repeat + opts.quantifiermarker.end;
  210. }
  211. var masksetDefinition;
  212. return void 0 === Inputmask.prototype.masksCache[mask] || nocache === !0 ? (masksetDefinition = {
  213. mask: mask,
  214. maskToken: analyseMask(mask),
  215. validPositions: {},
  216. _buffer: void 0,
  217. buffer: void 0,
  218. tests: {},
  219. metadata: metadata,
  220. maskLength: void 0
  221. }, nocache !== !0 && (Inputmask.prototype.masksCache[opts.numericInput ? mask.split("").reverse().join("") : mask] = masksetDefinition,
  222. 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]),
  223. masksetDefinition;
  224. }
  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 || 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, lvp = getLastValidPosition();
  247. maxLength = void 0 !== el ? el.maxLength : void 0, maxLength === -1 && (maxLength = void 0);
  248. do baseOnInput === !0 && getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
  249. test = testPos.match, ndxIntlzr = testPos.locator.slice(), maskTemplate.push(includeInput === !0 ? testPos.input : getPlaceholder(pos, test))) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  250. test = testPos.match, ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || pos < lvp || Number.isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(getPlaceholder(pos, test))),
  251. pos++; while ((void 0 === maxLength || pos < maxLength) && (null !== test.fn || "" !== test.def) || minimalPos > pos);
  252. return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), getMaskSet().maskLength = pos + 1,
  253. maskTemplate;
  254. }
  255. function getMaskSet() {
  256. return maskset;
  257. }
  258. function resetMaskSet(soft) {
  259. var maskset = getMaskSet();
  260. maskset.buffer = void 0, soft !== !0 && (maskset._buffer = void 0, maskset.validPositions = {},
  261. maskset.p = 0);
  262. }
  263. function getLastValidPosition(closestTo, strict, validPositions) {
  264. var before = -1, after = -1, valids = validPositions || getMaskSet().validPositions;
  265. void 0 === closestTo && (closestTo = -1);
  266. for (var posNdx in valids) {
  267. var psNdx = parseInt(posNdx);
  268. valids[psNdx] && (strict || null !== valids[psNdx].match.fn) && (psNdx <= closestTo && (before = psNdx),
  269. psNdx >= closestTo && (after = psNdx));
  270. }
  271. return before !== -1 && closestTo - before > 1 || after < closestTo ? before : after;
  272. }
  273. function stripValidPositions(start, end, nocheck, strict) {
  274. function IsEnclosedStatic(pos) {
  275. var posMatch = getMaskSet().validPositions[pos];
  276. if (void 0 !== posMatch && null === posMatch.match.fn) {
  277. var prevMatch = getMaskSet().validPositions[pos - 1], nextMatch = getMaskSet().validPositions[pos + 1];
  278. return void 0 !== prevMatch && void 0 !== nextMatch;
  279. }
  280. return !1;
  281. }
  282. var i, startPos = start, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), needsValidation = !1;
  283. for (getMaskSet().p = start, i = end - 1; i >= startPos; i--) void 0 !== getMaskSet().validPositions[i] && (nocheck === !0 || !IsEnclosedStatic(i) && opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts) !== !1) && delete getMaskSet().validPositions[i];
  284. for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
  285. for (;void 0 !== getMaskSet().validPositions[startPos]; ) startPos++;
  286. var s = getMaskSet().validPositions[startPos];
  287. if (i < startPos && (i = startPos + 1), void 0 === getMaskSet().validPositions[i] && isMask(i) || void 0 !== s) i++; else {
  288. var t = getTestTemplate(i);
  289. needsValidation === !1 && positionsClone[startPos] && positionsClone[startPos].match.def === t.match.def ? (getMaskSet().validPositions[startPos] = $.extend(!0, {}, positionsClone[startPos]),
  290. getMaskSet().validPositions[startPos].input = t.input, delete getMaskSet().validPositions[i],
  291. i++) : positionCanMatchDefinition(startPos, t.match.def) ? isValid(startPos, t.input || getPlaceholder(i), !0) !== !1 && (delete getMaskSet().validPositions[i],
  292. i++, needsValidation = !0) : isMask(i) || (i++, startPos--), startPos++;
  293. }
  294. }
  295. resetMaskSet(!0);
  296. }
  297. function determineTestTemplate(tests, guessNextBest) {
  298. for (var testPos, testPositions = tests, 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],
  299. !(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))) || guessNextBest === !0 && (null !== testPos.match.fn || /[0-9a-bA-Z]/.test(testPos.match.def))); ndx++) ;
  300. return testPos;
  301. }
  302. function getTestTemplate(pos, ndxIntlzr, tstPs) {
  303. return getMaskSet().validPositions[pos] || determineTestTemplate(getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
  304. }
  305. function getTest(pos) {
  306. return getMaskSet().validPositions[pos] ? getMaskSet().validPositions[pos] : getTests(pos)[0];
  307. }
  308. function positionCanMatchDefinition(pos, def) {
  309. for (var valid = !1, tests = getTests(pos), tndx = 0; tndx < tests.length; tndx++) if (tests[tndx].match && tests[tndx].match.def === def) {
  310. valid = !0;
  311. break;
  312. }
  313. return valid;
  314. }
  315. function selectBestMatch(pos, alternateNdx) {
  316. var bestMatch, indexPos;
  317. return (getMaskSet().tests[pos] || getMaskSet().validPositions[pos]) && $.each(getMaskSet().tests[pos] || [ getMaskSet().validPositions[pos] ], function(ndx, lmnt) {
  318. var ndxPos = lmnt.alternation ? lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) : -1;
  319. (void 0 === indexPos || ndxPos < indexPos) && ndxPos !== -1 && (bestMatch = lmnt,
  320. indexPos = ndxPos);
  321. }), bestMatch;
  322. }
  323. function getTests(pos, ndxIntlzr, tstPs) {
  324. function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
  325. function handleMatch(match, loopNdx, quantifierRecurse) {
  326. function isFirstMatch(latestMatch, tokenGroup) {
  327. var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
  328. return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
  329. if (match.isQuantifier === !0 && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]))) return !1;
  330. }), firstMatch;
  331. }
  332. function resolveNdxInitializer(pos, alternateNdx) {
  333. var bestMatch = selectBestMatch(pos, alternateNdx);
  334. return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : void 0;
  335. }
  336. function staticCanMatchDefinition(source, target) {
  337. return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
  338. }
  339. 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;
  340. if (testPos === pos && void 0 === match.matches) return matches.push({
  341. match: match,
  342. locator: loopNdx.reverse(),
  343. cd: cacheDependency
  344. }), !0;
  345. if (void 0 !== match.matches) {
  346. if (match.isGroup && quantifierRecurse !== match) {
  347. if (match = handleMatch(maskToken.matches[$.inArray(match, maskToken.matches) + 1], loopNdx)) return !0;
  348. } else if (match.isOptional) {
  349. var optionalToken = match;
  350. if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
  351. if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
  352. insertStop = !0, testPos = pos;
  353. }
  354. } else if (match.isAlternator) {
  355. var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
  356. if (altIndex === -1 || "string" == typeof altIndex) {
  357. var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
  358. if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
  359. for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
  360. if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx) || ndxInitializerClone.slice(),
  361. match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match,
  362. match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
  363. var ntndx = $.inArray(match, maskToken.matches) + 1;
  364. maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse),
  365. match && (altIndexArr.push(ntndx.toString()), $.each(matches, function(ndx, lmnt) {
  366. lmnt.alternation = loopNdx.length - 1;
  367. })));
  368. }
  369. maltMatches = matches.slice(), testPos = currentPos, matches = [];
  370. for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
  371. var altMatch = maltMatches[ndx1], hasMatch = !1;
  372. altMatch.alternation = altMatch.alternation || loopNdxCnt;
  373. for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
  374. var altMatch2 = malternateMatches[ndx2];
  375. if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2))) {
  376. hasMatch = altMatch.match.nativeDef === altMatch2.match.nativeDef, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation],
  377. altMatch2.alternation = altMatch.alternation, null == altMatch.match.fn && (altMatch2.na = altMatch2.na || altMatch.locator[altMatch.alternation].toString(),
  378. altMatch2.na.indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.na = altMatch2.na + "," + altMatch.locator[altMatch.alternation])));
  379. break;
  380. }
  381. }
  382. hasMatch || malternateMatches.push(altMatch);
  383. }
  384. }
  385. "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
  386. if (isFinite(ndx)) {
  387. var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
  388. lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
  389. for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1,
  390. mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",",
  391. lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]),
  392. lmnt.alternation = alternation);
  393. if (void 0 !== lmnt.locator[alternation]) return lmnt;
  394. }
  395. })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0,
  396. ndxInitializer = ndxInitializerClone.slice();
  397. } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
  398. if (match) return !0;
  399. } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && testPos <= pos; qndx++) {
  400. var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
  401. if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
  402. if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1,
  403. isFirstMatch(latestMatch, tokenGroup)) {
  404. if (qndx > qt.quantifier.min - 1) {
  405. insertStop = !0, testPos = pos;
  406. break;
  407. }
  408. return !0;
  409. }
  410. return !0;
  411. }
  412. } else if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) return !0;
  413. } else testPos++;
  414. }
  415. for (var tndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; tndx < maskToken.matches.length; tndx++) if (maskToken.matches[tndx].isQuantifier !== !0) {
  416. var match = handleMatch(maskToken.matches[tndx], [ tndx ].concat(loopNdx), quantifierRecurse);
  417. if (match && testPos === pos) return match;
  418. if (testPos > pos) break;
  419. }
  420. }
  421. function mergeLocators(tests) {
  422. var locator = [];
  423. return $.isArray(tests) || (tests = [ tests ]), tests.length > 0 && (void 0 === tests[0].alternation ? (locator = determineTestTemplate(tests.slice()).locator.slice(),
  424. 0 === locator.length && (locator = tests[0].locator.slice())) : $.each(tests, function(ndx, tst) {
  425. if ("" !== tst.def) if (0 === locator.length) locator = tst.locator.slice(); else for (var i = 0; i < locator.length; i++) tst.locator[i] && locator[i].toString().indexOf(tst.locator[i]) === -1 && (locator[i] += "," + tst.locator[i]);
  426. })), locator;
  427. }
  428. function filterTests(tests) {
  429. return opts.keepStatic && pos > 0 && tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0) && tests[0].match.optionality !== !0 && tests[0].match.optionalQuantifier !== !0 && null === tests[0].match.fn && !/[0-9a-bA-Z]/.test(tests[0].match.def) ? [ determineTestTemplate(tests) ] : tests;
  430. }
  431. var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr ? ndxIntlzr.slice() : [ 0 ], matches = [], insertStop = !1, cacheDependency = ndxIntlzr ? ndxIntlzr.join("") : "";
  432. if (pos > -1) {
  433. if (void 0 === ndxIntlzr) {
  434. for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos] || getMaskSet().tests[previousPos]) && previousPos > -1; ) previousPos--;
  435. void 0 !== test && previousPos > -1 && (ndxInitializer = mergeLocators(test), cacheDependency = ndxInitializer.join(""),
  436. testPos = previousPos);
  437. }
  438. if (getMaskSet().tests[pos] && getMaskSet().tests[pos][0].cd === cacheDependency) return filterTests(getMaskSet().tests[pos]);
  439. for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
  440. var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
  441. if (match && testPos === pos || testPos > pos) break;
  442. }
  443. }
  444. return (0 === matches.length || insertStop) && matches.push({
  445. match: {
  446. fn: null,
  447. cardinality: 0,
  448. optionality: !0,
  449. casing: null,
  450. def: "",
  451. placeholder: ""
  452. },
  453. locator: [],
  454. cd: cacheDependency
  455. }), void 0 !== ndxIntlzr && getMaskSet().tests[pos] ? filterTests($.extend(!0, [], matches)) : (getMaskSet().tests[pos] = $.extend(!0, [], matches),
  456. filterTests(getMaskSet().tests[pos]));
  457. }
  458. function getBufferTemplate() {
  459. return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1),
  460. void 0 === getMaskSet().buffer && getMaskSet()._buffer.slice()), getMaskSet()._buffer;
  461. }
  462. function getBuffer(noCache) {
  463. return void 0 !== getMaskSet().buffer && noCache !== !0 || (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)),
  464. getMaskSet().buffer;
  465. }
  466. function refreshFromBuffer(start, end, buffer) {
  467. var i;
  468. if (start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; i < end; i++) delete getMaskSet().validPositions[i];
  469. for (i = start; i < end; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
  470. }
  471. function casing(elem, test, pos) {
  472. switch (opts.casing || test.casing) {
  473. case "upper":
  474. elem = elem.toUpperCase();
  475. break;
  476. case "lower":
  477. elem = elem.toLowerCase();
  478. break;
  479. case "title":
  480. var posBefore = getMaskSet().validPositions[pos - 1];
  481. elem = 0 === pos || posBefore && posBefore.input === String.fromCharCode(Inputmask.keyCode.SPACE) ? elem.toUpperCase() : elem.toLowerCase();
  482. }
  483. return elem;
  484. }
  485. function checkAlternationMatch(altArr1, altArr2) {
  486. for (var altArrC = opts.greedy ? altArr2 : altArr2.slice(0, 1), isMatch = !1, alndx = 0; alndx < altArr1.length; alndx++) if ($.inArray(altArr1[alndx], altArrC) !== -1) {
  487. isMatch = !0;
  488. break;
  489. }
  490. return isMatch;
  491. }
  492. function isValid(pos, c, strict, fromSetValid, fromAlternate) {
  493. function isSelection(posObj) {
  494. var selection = isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end === 1 && opts.insertMode : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin === 1 && opts.insertMode;
  495. return selection && 0 === posObj.begin && posObj.end === getMaskSet().maskLength ? "full" : selection;
  496. }
  497. function _isValid(position, c, strict) {
  498. var rslt = !1;
  499. return $.each(getTests(position), function(ndx, tst) {
  500. for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
  501. if (c && (chrs += c), getBuffer(!0), rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
  502. c: test.placeholder || test.def,
  503. pos: position
  504. }, rslt !== !1) {
  505. var elem = void 0 !== rslt.c ? rslt.c : c;
  506. elem = elem === opts.skipOptionalPartCharacter && null === test.fn ? test.placeholder || test.def : elem;
  507. var validatedPos = position, possibleModifiedBuffer = getBuffer();
  508. if (void 0 !== rslt.remove && ($.isArray(rslt.remove) || (rslt.remove = [ rslt.remove ]),
  509. $.each(rslt.remove.sort(function(a, b) {
  510. return b - a;
  511. }), function(ndx, lmnt) {
  512. stripValidPositions(lmnt, lmnt + 1, !0);
  513. })), void 0 !== rslt.insert && ($.isArray(rslt.insert) || (rslt.insert = [ rslt.insert ]),
  514. $.each(rslt.insert.sort(function(a, b) {
  515. return a - b;
  516. }), function(ndx, lmnt) {
  517. isValid(lmnt.pos, lmnt.c, !0, fromSetValid);
  518. })), rslt.refreshFromBuffer) {
  519. var refresh = rslt.refreshFromBuffer;
  520. if (strict = !0, refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, possibleModifiedBuffer),
  521. void 0 === rslt.pos && void 0 === rslt.c) return rslt.pos = getLastValidPosition(),
  522. !1;
  523. if (validatedPos = void 0 !== rslt.pos ? rslt.pos : position, validatedPos !== position) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0, fromSetValid)),
  524. !1;
  525. } else if (rslt !== !0 && void 0 !== rslt.pos && rslt.pos !== position && (validatedPos = rslt.pos,
  526. refreshFromBuffer(position, validatedPos, getBuffer().slice()), validatedPos !== position)) return rslt = $.extend(rslt, isValid(validatedPos, elem, !0)),
  527. !1;
  528. return (rslt === !0 || void 0 !== rslt.pos || void 0 !== rslt.c) && (ndx > 0 && resetMaskSet(!0),
  529. setValidPosition(validatedPos, $.extend({}, tst, {
  530. input: casing(elem, test, validatedPos)
  531. }), fromSetValid, isSelection(pos)) || (rslt = !1), !1);
  532. }
  533. }), rslt;
  534. }
  535. function alternate(pos, c, strict) {
  536. var lastAlt, alternation, altPos, prevAltPos, i, validPos, altNdxs, decisionPos, validPsClone = $.extend(!0, {}, getMaskSet().validPositions), isValidRslt = !1, lAltPos = getLastValidPosition();
  537. for (prevAltPos = getMaskSet().validPositions[lAltPos]; lAltPos >= 0; lAltPos--) if (altPos = getMaskSet().validPositions[lAltPos],
  538. altPos && void 0 !== altPos.alternation) {
  539. if (lastAlt = lAltPos, alternation = getMaskSet().validPositions[lastAlt].alternation,
  540. prevAltPos.locator[altPos.alternation] !== altPos.locator[altPos.alternation]) break;
  541. prevAltPos = altPos;
  542. }
  543. if (void 0 !== alternation) {
  544. decisionPos = parseInt(lastAlt);
  545. var decisionTaker = void 0 !== prevAltPos.locator[prevAltPos.alternation || alternation] ? prevAltPos.locator[prevAltPos.alternation || alternation] : altNdxs[0];
  546. decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
  547. var possibilityPos = getMaskSet().validPositions[decisionPos], prevPos = getMaskSet().validPositions[decisionPos - 1];
  548. $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
  549. altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
  550. for (var mndx = 0; mndx < altNdxs.length; mndx++) {
  551. var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
  552. if (decisionTaker < altNdxs[mndx] && (void 0 === test.na || $.inArray(altNdxs[mndx], test.na.split(",")) === -1)) {
  553. getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
  554. var possibilities = getMaskSet().validPositions[decisionPos].locator;
  555. for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]),
  556. null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0,
  557. possibilityPos.generatedInput !== !0 && validInputs.push(possibilityPos.input)),
  558. staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !/[0-9a-bA-Z]/.test(test.match.def),
  559. getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input,
  560. i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i],
  561. validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++,
  562. delete getMaskSet().validPositions[i];
  563. for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(),
  564. resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
  565. var input = validInputs.shift();
  566. if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
  567. }
  568. if (isValidRslt) {
  569. getMaskSet().validPositions[decisionPos].locator = possibilities;
  570. var targetLvp = getLastValidPosition(pos) + 1;
  571. for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i],
  572. (void 0 === validPos || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
  573. pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
  574. }
  575. if (isValidRslt) return !1;
  576. resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
  577. }
  578. }
  579. });
  580. }
  581. return isValidRslt;
  582. }
  583. function trackbackAlternations(originalPos, newPos) {
  584. var vp = getMaskSet().validPositions[newPos];
  585. if (vp) for (var targetLocator = vp.locator, tll = targetLocator.length, ps = originalPos; ps < newPos; ps++) if (void 0 === getMaskSet().validPositions[ps] && !isMask(ps, !0)) {
  586. var tests = getTests(ps), bestMatch = tests[0], equality = -1;
  587. $.each(tests, function(ndx, tst) {
  588. for (var i = 0; i < tll && (void 0 !== tst.locator[i] && checkAlternationMatch(tst.locator[i].toString().split(","), targetLocator[i].toString().split(","))); i++) equality < i && (equality = i,
  589. bestMatch = tst);
  590. }), setValidPosition(ps, $.extend({}, bestMatch, {
  591. input: bestMatch.match.placeholder || bestMatch.match.def
  592. }), !0);
  593. }
  594. }
  595. function setValidPosition(pos, validTest, fromSetValid, isSelection) {
  596. if (isSelection || opts.insertMode && void 0 !== getMaskSet().validPositions[pos] && void 0 === fromSetValid) {
  597. var i, positionsClone = $.extend(!0, {}, getMaskSet().validPositions), lvp = getLastValidPosition(void 0, !0);
  598. for (i = pos; i <= lvp; i++) delete getMaskSet().validPositions[i];
  599. getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
  600. var j, valid = !0, vps = getMaskSet().validPositions, needsValidation = !1, initialLength = getMaskSet().maskLength;
  601. for (i = j = pos; i <= lvp; i++) {
  602. var t = positionsClone[i];
  603. if (void 0 !== t) for (var posMatch = j; posMatch < getMaskSet().maskLength && (null == t.match.fn && vps[i] && (vps[i].match.optionalQuantifier === !0 || vps[i].match.optionality === !0) || null != t.match.fn); ) {
  604. if (posMatch++, needsValidation === !1 && positionsClone[posMatch] && positionsClone[posMatch].match.def === t.match.def) getMaskSet().validPositions[posMatch] = $.extend(!0, {}, positionsClone[posMatch]),
  605. getMaskSet().validPositions[posMatch].input = t.input, fillMissingNonMask(posMatch),
  606. j = posMatch, valid = !0; else if (positionCanMatchDefinition(posMatch, t.match.def)) {
  607. var result = isValid(posMatch, t.input, !0, !0);
  608. valid = result !== !1, j = result.caret || result.insert ? getLastValidPosition() : posMatch,
  609. needsValidation = !0;
  610. } else valid = t.generatedInput === !0;
  611. if (getMaskSet().maskLength < initialLength && (getMaskSet().maskLength = initialLength),
  612. valid) break;
  613. }
  614. if (!valid) break;
  615. }
  616. if (!valid) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone),
  617. resetMaskSet(!0), !1;
  618. } else getMaskSet().validPositions[pos] = $.extend(!0, {}, validTest);
  619. return resetMaskSet(!0), !0;
  620. }
  621. function fillMissingNonMask(maskPos) {
  622. for (var pndx = maskPos - 1; pndx > -1 && !getMaskSet().validPositions[pndx]; pndx--) ;
  623. var testTemplate, testsFromPos;
  624. for (pndx++; pndx < maskPos; pndx++) void 0 === getMaskSet().validPositions[pndx] && (opts.jitMasking === !1 || opts.jitMasking > pndx) && (testsFromPos = getTests(pndx, getTestTemplate(pndx - 1).locator, pndx - 1).slice(),
  625. "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop(), testTemplate = determineTestTemplate(testsFromPos),
  626. testTemplate && (testTemplate.match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, !0) || $.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, !1, opts)) && (result = _isValid(pndx, testTemplate.match.placeholder || (null == testTemplate.match.fn ? testTemplate.match.def : "" !== getPlaceholder(pndx) ? getPlaceholder(pndx) : getBuffer()[pndx]), !0),
  627. result !== !1 && (getMaskSet().validPositions[result.pos || pndx].generatedInput = !0)));
  628. }
  629. strict = strict === !0;
  630. var maskPos = pos;
  631. void 0 !== pos.begin && (maskPos = isRTL && !isSelection(pos) ? pos.end : pos.begin);
  632. var result = !1, positionsClone = $.extend(!0, {}, getMaskSet().validPositions);
  633. if (fillMissingNonMask(maskPos), isSelection(pos) && (handleRemove(void 0, Inputmask.keyCode.DELETE, pos),
  634. maskPos = getMaskSet().p), maskPos < getMaskSet().maskLength && (result = _isValid(maskPos, c, strict),
  635. (!strict || fromSetValid === !0) && result === !1)) {
  636. var currentPosValid = getMaskSet().validPositions[maskPos];
  637. if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
  638. if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
  639. var testsFromPos = getTests(maskPos).slice();
  640. "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
  641. var staticChar = determineTestTemplate(testsFromPos, !0);
  642. staticChar && null === staticChar.match.fn && (staticChar = staticChar.match.placeholder || staticChar.match.def,
  643. _isValid(maskPos, staticChar, strict), getMaskSet().validPositions[maskPos].generatedInput = !0);
  644. for (var nPos = maskPos + 1, snPos = seekNext(maskPos); nPos <= snPos; nPos++) if (result = _isValid(nPos, c, strict),
  645. result !== !1) {
  646. trackbackAlternations(maskPos, void 0 !== result.pos ? result.pos : nPos), maskPos = nPos;
  647. break;
  648. }
  649. }
  650. } else result = {
  651. caret: seekNext(maskPos)
  652. };
  653. }
  654. return result === !1 && opts.keepStatic && !strict && fromAlternate !== !0 && (result = alternate(maskPos, c, strict)),
  655. result === !0 && (result = {
  656. pos: maskPos
  657. }), $.isFunction(opts.postValidation) && result !== !1 && !strict && fromSetValid !== !0 && (result = !!opts.postValidation(getBuffer(!0), result, opts) && result),
  658. void 0 === result.pos && (result.pos = maskPos), result === !1 && (resetMaskSet(!0),
  659. getMaskSet().validPositions = $.extend(!0, {}, positionsClone)), result;
  660. }
  661. function isMask(pos, strict) {
  662. var test;
  663. if (strict ? (test = getTestTemplate(pos).match, "" === test.def && (test = getTest(pos).match)) : test = getTest(pos).match,
  664. null != test.fn) return test.fn;
  665. if (strict !== !0 && pos > -1) {
  666. var tests = getTests(pos);
  667. return tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0);
  668. }
  669. return !1;
  670. }
  671. function seekNext(pos, newBlock) {
  672. var maskL = getMaskSet().maskLength;
  673. if (pos >= maskL) return maskL;
  674. for (var position = pos; ++position < maskL && (newBlock === !0 && (getTest(position).match.newBlockMarker !== !0 || !isMask(position)) || newBlock !== !0 && !isMask(position)); ) ;
  675. return position;
  676. }
  677. function seekPrevious(pos, newBlock) {
  678. var tests, position = pos;
  679. if (position <= 0) return 0;
  680. for (;--position > 0 && (newBlock === !0 && getTest(position).match.newBlockMarker !== !0 || newBlock !== !0 && !isMask(position) && (tests = getTests(position),
  681. tests.length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
  682. return position;
  683. }
  684. function getBufferElement(position) {
  685. return void 0 === getMaskSet().validPositions[position] ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
  686. }
  687. function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
  688. if (event && $.isFunction(opts.onBeforeWrite)) {
  689. var result = opts.onBeforeWrite(event, buffer, caretPos, opts);
  690. if (result) {
  691. if (result.refreshFromBuffer) {
  692. var refresh = result.refreshFromBuffer;
  693. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer || buffer),
  694. buffer = getBuffer(!0);
  695. }
  696. void 0 !== caretPos && (caretPos = void 0 !== result.caret ? result.caret : caretPos);
  697. }
  698. }
  699. input.inputmask._valueSet(buffer.join("")), void 0 === caretPos || void 0 !== event && "blur" === event.type ? renderColorMask(input, buffer, caretPos) : caret(input, caretPos),
  700. triggerInputEvent === !0 && (skipInputEvent = !0, $(input).trigger("input"));
  701. }
  702. function getPlaceholder(pos, test) {
  703. if (test = test || getTest(pos).match, void 0 !== test.placeholder) return test.placeholder;
  704. if (null === test.fn) {
  705. if (pos > -1 && void 0 === getMaskSet().validPositions[pos]) {
  706. var prevTest, tests = getTests(pos), staticAlternations = [];
  707. if (tests.length > 1 + ("" === tests[tests.length - 1].match.def ? 1 : 0)) 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.push(tests[i]),
  708. null === tests[i].match.fn && (prevTest = tests[i]), staticAlternations.length > 1 && /[0-9a-bA-Z]/.test(staticAlternations[0].match.def))) return opts.placeholder.charAt(pos % opts.placeholder.length);
  709. }
  710. return test.def;
  711. }
  712. return opts.placeholder.charAt(pos % opts.placeholder.length);
  713. }
  714. function checkVal(input, writeOut, strict, nptvl, initiatingEvent, stickyCaret) {
  715. function isTemplateMatch() {
  716. var isMatch = !1, charCodeNdx = getBufferTemplate().slice(initialNdx, seekNext(initialNdx)).join("").indexOf(charCodes);
  717. if (charCodeNdx !== -1 && !isMask(initialNdx)) {
  718. isMatch = !0;
  719. for (var bufferTemplateArr = getBufferTemplate().slice(initialNdx, initialNdx + charCodeNdx), i = 0; i < bufferTemplateArr.length; i++) if (" " !== bufferTemplateArr[i]) {
  720. isMatch = !1;
  721. break;
  722. }
  723. }
  724. return isMatch;
  725. }
  726. var inputValue = nptvl.slice(), charCodes = "", initialNdx = 0, result = void 0;
  727. if (resetMaskSet(), getMaskSet().p = seekNext(-1), !strict) if (opts.autoUnmask !== !0) {
  728. var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp("^" + Inputmask.escapeRegex(staticInput), "g"));
  729. matches && matches.length > 0 && (inputValue.splice(0, matches.length * staticInput.length),
  730. initialNdx = seekNext(initialNdx));
  731. } else initialNdx = seekNext(initialNdx);
  732. if ($.each(inputValue, function(ndx, charCode) {
  733. if (void 0 !== charCode) {
  734. var keypress = new $.Event("keypress");
  735. keypress.which = charCode.charCodeAt(0), charCodes += charCode;
  736. var lvp = getLastValidPosition(void 0, !0), lvTest = getMaskSet().validPositions[lvp], nextTest = getTestTemplate(lvp + 1, lvTest ? lvTest.locator.slice() : void 0, lvp);
  737. if (!isTemplateMatch() || strict || opts.autoUnmask) {
  738. var pos = strict ? ndx : null == nextTest.match.fn && nextTest.match.optionality && lvp + 1 < getMaskSet().p ? lvp + 1 : getMaskSet().p;
  739. result = keypressEvent.call(input, keypress, !0, !1, strict, pos), initialNdx = pos + 1,
  740. charCodes = "";
  741. } else result = keypressEvent.call(input, keypress, !0, !1, !0, lvp + 1);
  742. if (!strict && $.isFunction(opts.onBeforeWrite) && (result = opts.onBeforeWrite(keypress, getBuffer(), result.forwardPosition, opts),
  743. result && result.refreshFromBuffer)) {
  744. var refresh = result.refreshFromBuffer;
  745. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  746. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  747. }
  748. }
  749. }), writeOut) {
  750. var caretPos = void 0, lvp = getLastValidPosition();
  751. document.activeElement === input && (initiatingEvent || result) && (caretPos = caret(input).begin,
  752. initiatingEvent && result === !1 && (caretPos = seekNext(getLastValidPosition(caretPos))),
  753. result && stickyCaret !== !0 && (caretPos < lvp + 1 || lvp === -1) && (caretPos = opts.numericInput && void 0 === result.caret ? seekPrevious(result.forwardPosition) : result.forwardPosition)),
  754. writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"));
  755. }
  756. }
  757. function unmaskedvalue(input) {
  758. if (input && void 0 === input.inputmask) return input.value;
  759. var umValue = [], vps = getMaskSet().validPositions;
  760. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  761. var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join("");
  762. if ($.isFunction(opts.onUnMask)) {
  763. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  764. unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue;
  765. }
  766. return unmaskedValue;
  767. }
  768. function caret(input, begin, end, notranslate) {
  769. function translatePosition(pos) {
  770. if (notranslate !== !0 && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  771. var bffrLght = getBuffer().join("").length;
  772. pos = bffrLght - pos;
  773. }
  774. return pos;
  775. }
  776. var range;
  777. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  778. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  779. range.commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset,
  780. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  781. begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length),
  782. end = begin + range.text.length), {
  783. begin: translatePosition(begin),
  784. end: translatePosition(end)
  785. };
  786. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  787. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  788. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || opts.insertMode !== !1 || begin !== end || end++,
  789. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  790. if (range = document.createRange(), void 0 === input.firstChild || null === input.firstChild) {
  791. var textNode = document.createTextNode("");
  792. input.appendChild(textNode);
  793. }
  794. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  795. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  796. range.collapse(!0);
  797. var sel = window.getSelection();
  798. sel.removeAllRanges(), sel.addRange(range);
  799. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  800. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  801. renderColorMask(input, void 0, {
  802. begin: begin,
  803. end: end
  804. });
  805. }
  806. function determineLastRequiredPosition(returnDefinition) {
  807. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = void 0 !== lvTest ? lvTest.locator.slice() : void 0;
  808. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  809. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  810. var lvTestAlt = lvTest && void 0 !== lvTest.alternation ? lvTest.locator[lvTest.alternation] : void 0;
  811. 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--;
  812. return returnDefinition ? {
  813. l: bl,
  814. def: positions[bl] ? positions[bl].match : void 0
  815. } : bl;
  816. }
  817. function clearOptionalTail(buffer) {
  818. for (var rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  819. return buffer.splice(rl, lmib + 1 - rl), buffer;
  820. }
  821. function isComplete(buffer) {
  822. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  823. if ("*" !== opts.repeat) {
  824. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  825. if (void 0 === lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  826. complete = !0;
  827. for (var i = 0; i <= aml; i++) {
  828. var test = getTestTemplate(i).match;
  829. if (null !== test.fn && void 0 === getMaskSet().validPositions[i] && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  830. complete = !1;
  831. break;
  832. }
  833. }
  834. }
  835. return complete;
  836. }
  837. }
  838. function patchValueProperty(npt) {
  839. function patchValhook(type) {
  840. if ($.valHooks && (void 0 === $.valHooks[type] || $.valHooks[type].inputmaskpatch !== !0)) {
  841. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  842. return elem.value;
  843. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  844. return elem.value = value, elem;
  845. };
  846. $.valHooks[type] = {
  847. get: function(elem) {
  848. if (elem.inputmask) {
  849. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  850. var result = valhookGet(elem);
  851. return getLastValidPosition(void 0, void 0, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== !0 ? result : "";
  852. }
  853. return valhookGet(elem);
  854. },
  855. set: function(elem, value) {
  856. var result, $elem = $(elem);
  857. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  858. result;
  859. },
  860. inputmaskpatch: !0
  861. };
  862. }
  863. }
  864. function getter() {
  865. return this.inputmask ? this.inputmask.opts.autoUnmask ? this.inputmask.unmaskedvalue() : getLastValidPosition() !== -1 || opts.nullable !== !0 ? document.activeElement === this && opts.clearMaskOnLostFocus ? (isRTL ? clearOptionalTail(getBuffer().slice()).reverse() : clearOptionalTail(getBuffer().slice())).join("") : valueGet.call(this) : "" : valueGet.call(this);
  866. }
  867. function setter(value) {
  868. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  869. }
  870. function installNativeValueSetFallback(npt) {
  871. EventRuler.on(npt, "mouseenter", function(event) {
  872. var $input = $(this), input = this, value = input.inputmask._valueGet();
  873. value !== getBuffer().join("") && $input.trigger("setvalue");
  874. });
  875. }
  876. var valueGet, valueSet;
  877. if (!npt.inputmask.__valueGet) {
  878. if (opts.noValuePatching !== !0) {
  879. if (Object.getOwnPropertyDescriptor) {
  880. "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" == typeof "test".__proto__ ? function(object) {
  881. return object.__proto__;
  882. } : function(object) {
  883. return object.constructor.prototype;
  884. });
  885. var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : void 0;
  886. valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get,
  887. valueSet = valueProperty.set, Object.defineProperty(npt, "value", {
  888. get: getter,
  889. set: setter,
  890. configurable: !0
  891. })) : "INPUT" !== npt.tagName && (valueGet = function() {
  892. return this.textContent;
  893. }, valueSet = function(value) {
  894. this.textContent = value;
  895. }, Object.defineProperty(npt, "value", {
  896. get: getter,
  897. set: setter,
  898. configurable: !0
  899. }));
  900. } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"),
  901. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  902. npt.__defineSetter__("value", setter));
  903. npt.inputmask.__valueGet = valueGet, npt.inputmask.__valueSet = valueSet;
  904. }
  905. npt.inputmask._valueGet = function(overruleRTL) {
  906. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  907. }, npt.inputmask._valueSet = function(value, overruleRTL) {
  908. valueSet.call(this.el, null === value || void 0 === value ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  909. }, void 0 === valueGet && (valueGet = function() {
  910. return this.value;
  911. }, valueSet = function(value) {
  912. this.value = value;
  913. }, patchValhook(npt.type), installNativeValueSetFallback(npt));
  914. }
  915. }
  916. function handleRemove(input, k, pos, strict) {
  917. function generalize() {
  918. if (opts.keepStatic) {
  919. for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
  920. var altPos = getMaskSet().validPositions[lastAlt];
  921. if (altPos) {
  922. if (altPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(altPos.input) && validInputs.push(altPos.input),
  923. delete getMaskSet().validPositions[lastAlt], void 0 !== altPos.alternation && altPos.locator[altPos.alternation] !== prevAltPos.locator[altPos.alternation]) break;
  924. prevAltPos = altPos;
  925. }
  926. }
  927. if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
  928. var keypress = new $.Event("keypress");
  929. keypress.which = validInputs.pop().charCodeAt(0), keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  930. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  931. }
  932. }
  933. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  934. isRTL)) {
  935. var pend = pos.end;
  936. pos.end = pos.begin, pos.begin = pend;
  937. }
  938. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  939. 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, !0) ? pos.end + 1 : seekNext(pos.end) + 1,
  940. void 0 === getMaskSet().validPositions[pos.begin] || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  941. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  942. var lvp = getLastValidPosition(pos.begin, !0);
  943. lvp < pos.begin ? getMaskSet().p = seekNext(lvp) : strict !== !0 && (getMaskSet().p = pos.begin);
  944. }
  945. function keydownEvent(e) {
  946. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  947. if (k === Inputmask.keyCode.BACKSPACE || k === Inputmask.keyCode.DELETE || iphone && k === Inputmask.keyCode.BACKSPACE_SAFARI || e.ctrlKey && k === Inputmask.keyCode.X && !isInputEventSupported("cut")) e.preventDefault(),
  948. handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
  949. input.inputmask._valueGet() === getBufferTemplate().join("") ? $input.trigger("cleared") : isComplete(getBuffer()) === !0 && $input.trigger("complete"),
  950. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask); else if (k === Inputmask.keyCode.END || k === Inputmask.keyCode.PAGE_DOWN) {
  951. e.preventDefault();
  952. var caretPos = seekNext(getLastValidPosition());
  953. opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
  954. caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
  955. } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
  956. caret(input, 0, e.shiftKey ? pos.begin : 0, !0)) : (opts.undoOnEscape && k === Inputmask.keyCode.ESCAPE || 90 === k && e.ctrlKey) && e.altKey !== !0 ? (checkVal(input, !0, !1, undoValue.split("")),
  957. $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).match.fn && (pos.begin = seekNext(pos.begin)),
  958. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  959. pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
  960. pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || (opts.insertMode === !1 ? k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  961. var caretPos = caret(input);
  962. caret(input, caretPos.begin);
  963. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  964. var caretPos = caret(input);
  965. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  966. }, 0) : setTimeout(function() {
  967. renderColorMask(input);
  968. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
  969. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
  970. }
  971. function keypressEvent(e, checkval, writeOut, strict, ndx) {
  972. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  973. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  974. setTimeout(function() {
  975. $input.trigger("change");
  976. }, 0)), !0;
  977. if (k) {
  978. 46 === k && e.shiftKey === !1 && "," === opts.radixPoint && (k = 44);
  979. var forwardPosition, pos = checkval ? {
  980. begin: ndx,
  981. end: ndx
  982. } : caret(input), c = String.fromCharCode(k);
  983. getMaskSet().writeOutBuffer = !0;
  984. var valResult = isValid(pos, c, strict);
  985. if (valResult !== !1 && (resetMaskSet(!0), forwardPosition = void 0 !== valResult.caret ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
  986. getMaskSet().p = forwardPosition), writeOut !== !1) {
  987. var self = this;
  988. if (setTimeout(function() {
  989. opts.onKeyValidation.call(self, k, valResult, opts);
  990. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  991. var buffer = getBuffer();
  992. writeBuffer(input, buffer, opts.numericInput && void 0 === valResult.caret ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  993. checkval !== !0 && setTimeout(function() {
  994. isComplete(buffer) === !0 && $input.trigger("complete");
  995. }, 0);
  996. }
  997. }
  998. if (opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask), e.preventDefault(),
  999. checkval) return valResult.forwardPosition = forwardPosition, valResult;
  1000. }
  1001. }
  1002. function pasteEvent(e) {
  1003. var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  1004. isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
  1005. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  1006. if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  1007. valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
  1008. isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
  1009. window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
  1010. if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
  1011. inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
  1012. }
  1013. var pasteValue = inputValue;
  1014. if ($.isFunction(opts.onBeforePaste)) {
  1015. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault();
  1016. pasteValue || (pasteValue = inputValue);
  1017. }
  1018. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  1019. writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
  1020. isComplete(getBuffer()) === !0 && $input.trigger("complete"), e.preventDefault();
  1021. }
  1022. function inputFallBackEvent(e) {
  1023. var input = this, inputValue = input.inputmask._valueGet();
  1024. if (getBuffer().join("") !== inputValue) {
  1025. var caretPos = caret(input);
  1026. if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  1027. iemobile) {
  1028. var inputChar = inputValue.replace(getBuffer().join(""), "");
  1029. if (1 === inputChar.length) {
  1030. var keypress = new $.Event("keypress");
  1031. return keypress.which = inputChar.charCodeAt(0), keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
  1032. !1;
  1033. }
  1034. }
  1035. if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
  1036. getBuffer().length - inputValue.length !== 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
  1037. for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBuffer().slice(lvp).join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  1038. inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
  1039. checkVal(input, !0, !1, inputValue, e, caretPos.begin < lvp), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
  1040. } else e.keyCode = Inputmask.keyCode.BACKSPACE, keydownEvent.call(input, e);
  1041. e.preventDefault();
  1042. }
  1043. }
  1044. function setValueEvent(e) {
  1045. var input = this, value = input.inputmask._valueGet();
  1046. checkVal(input, !0, !1, ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(value, opts) || value : value).split("")),
  1047. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1048. }
  1049. function focusEvent(e) {
  1050. var input = this, nptValue = input.inputmask._valueGet();
  1051. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) ? input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition())),
  1052. opts.positionCaretOnTab === !0 && setTimeout(function() {
  1053. clickEvent.apply(this, [ e ]);
  1054. }, 0), undoValue = getBuffer().join("");
  1055. }
  1056. function mouseleaveEvent(e) {
  1057. var input = this;
  1058. if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
  1059. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1060. nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1061. writeBuffer(input, buffer));
  1062. }
  1063. }
  1064. function clickEvent(e) {
  1065. function doRadixFocus(clickPos) {
  1066. if ("" !== opts.radixPoint) {
  1067. var vps = getMaskSet().validPositions;
  1068. if (void 0 === vps[clickPos] || vps[clickPos].input === getPlaceholder(clickPos)) {
  1069. if (clickPos < seekNext(-1)) return !0;
  1070. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1071. if (radixPos !== -1) {
  1072. for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
  1073. return !0;
  1074. }
  1075. }
  1076. }
  1077. return !1;
  1078. }
  1079. var input = this;
  1080. setTimeout(function() {
  1081. if (document.activeElement === input) {
  1082. var selectedCaret = caret(input);
  1083. if (selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
  1084. case "none":
  1085. break;
  1086. case "radixFocus":
  1087. if (doRadixFocus(selectedCaret.begin)) {
  1088. var radixPos = $.inArray(opts.radixPoint, getBuffer().join(""));
  1089. caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
  1090. break;
  1091. }
  1092. default:
  1093. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
  1094. if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
  1095. var placeholder = getPlaceholder(lastPosition);
  1096. ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && getTest(lastPosition).match.optionalQuantifier !== !0 || !isMask(lastPosition, !0) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)),
  1097. caret(input, lastPosition);
  1098. }
  1099. }
  1100. }
  1101. }, 0);
  1102. }
  1103. function dblclickEvent(e) {
  1104. var input = this;
  1105. setTimeout(function() {
  1106. caret(input, 0, seekNext(getLastValidPosition()));
  1107. }, 0);
  1108. }
  1109. function cutEvent(e) {
  1110. 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);
  1111. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1112. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1113. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1114. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared"),
  1115. opts.showTooltip && (input.title = opts.tooltip || getMaskSet().mask);
  1116. }
  1117. function blurEvent(e) {
  1118. var $input = $(this), input = this;
  1119. if (input.inputmask) {
  1120. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1121. undoValue !== buffer.join("") && setTimeout(function() {
  1122. $input.trigger("change"), undoValue = buffer.join("");
  1123. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1124. isComplete(buffer) === !1 && (setTimeout(function() {
  1125. $input.trigger("incomplete");
  1126. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1127. writeBuffer(input, buffer, void 0, e));
  1128. }
  1129. }
  1130. function mouseenterEvent(e) {
  1131. var input = this;
  1132. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1133. }
  1134. function submitEvent(e) {
  1135. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1136. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1137. setTimeout(function() {
  1138. writeBuffer(el, getBuffer());
  1139. }, 0));
  1140. }
  1141. function resetEvent(e) {
  1142. setTimeout(function() {
  1143. $el.trigger("setvalue");
  1144. }, 0);
  1145. }
  1146. function initializeColorMask(input) {
  1147. function findCaretPos(clientx) {
  1148. var caretPos, e = document.createElement("span");
  1149. for (var style in computedStyle) isNaN(style) && style.indexOf("font") !== -1 && (e.style[style] = computedStyle[style]);
  1150. e.style.textTransform = computedStyle.textTransform, e.style.letterSpacing = computedStyle.letterSpacing,
  1151. e.style.position = "absolute", e.style.height = "auto", e.style.width = "auto",
  1152. e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", document.body.appendChild(e);
  1153. var itl, inputText = input.inputmask._valueGet(), previousWidth = 0;
  1154. for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) {
  1155. if (e.innerHTML += inputText.charAt(caretPos) || "_", e.offsetWidth >= clientx) {
  1156. var offset1 = clientx - previousWidth, offset2 = e.offsetWidth - clientx;
  1157. e.innerHTML = inputText.charAt(caretPos), offset1 -= e.offsetWidth / 3, caretPos = offset1 < offset2 ? caretPos - 1 : caretPos;
  1158. break;
  1159. }
  1160. previousWidth = e.offsetWidth;
  1161. }
  1162. return document.body.removeChild(e), caretPos;
  1163. }
  1164. function position() {
  1165. colorMask.style.position = "absolute", colorMask.style.top = offset.top + "px",
  1166. colorMask.style.left = offset.left + "px", colorMask.style.width = parseInt(input.offsetWidth) - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight) - parseInt(computedStyle.borderLeftWidth) - parseInt(computedStyle.borderRightWidth) + "px",
  1167. colorMask.style.height = parseInt(input.offsetHeight) - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom) - parseInt(computedStyle.borderTopWidth) - parseInt(computedStyle.borderBottomWidth) + "px",
  1168. colorMask.style.lineHeight = colorMask.style.height, colorMask.style.zIndex = isNaN(computedStyle.zIndex) ? -1 : computedStyle.zIndex - 1,
  1169. colorMask.style.webkitAppearance = "textfield", colorMask.style.mozAppearance = "textfield",
  1170. colorMask.style.Appearance = "textfield";
  1171. }
  1172. var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
  1173. input.parentNode;
  1174. colorMask = document.createElement("div"), document.body.appendChild(colorMask);
  1175. for (var style in computedStyle) isNaN(style) && "cssText" !== style && style.indexOf("webkit") == -1 && (colorMask.style[style] = computedStyle[style]);
  1176. input.style.backgroundColor = "transparent", input.style.color = "transparent",
  1177. input.style.webkitAppearance = "caret", input.style.mozAppearance = "caret", input.style.Appearance = "caret",
  1178. position(), $(window).on("resize", function(e) {
  1179. offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null),
  1180. position();
  1181. }), $(input).on("click", function(e) {
  1182. return caret(input, findCaretPos(e.clientX)), clickEvent.call(this, [ e ]);
  1183. });
  1184. }
  1185. function renderColorMask(input, buffer, caretPos) {
  1186. function handleStatic() {
  1187. static || null !== test.fn && void 0 !== testPos.input ? static && null !== test.fn && void 0 !== testPos.input && (static = !1,
  1188. maskTemplate += "</span>") : (static = !0, maskTemplate += "<span class='im-static''>");
  1189. }
  1190. if (void 0 !== colorMask) {
  1191. buffer = buffer || getBuffer(), void 0 === caretPos ? caretPos = caret(input) : void 0 === caretPos.begin && (caretPos = {
  1192. begin: caretPos,
  1193. end: caretPos
  1194. });
  1195. var maskTemplate = "", static = !1;
  1196. if ("" != buffer) {
  1197. var ndxIntlzr, test, testPos, pos = 0, lvp = getLastValidPosition();
  1198. do pos === caretPos.begin && document.activeElement === input && (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>"),
  1199. getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
  1200. test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  1201. test = testPos.match, ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || pos < lvp || Number.isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(),
  1202. maskTemplate += getPlaceholder(pos, test))), pos++; while ((void 0 === maxLength || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos);
  1203. }
  1204. colorMask.innerHTML = maskTemplate;
  1205. }
  1206. }
  1207. function mask(elem) {
  1208. if (el = elem, $el = $(el), opts.showTooltip && (el.title = opts.tooltip || getMaskSet().mask),
  1209. ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"), ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr",
  1210. el.removeAttribute("dir"), el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el),
  1211. android && (el.hasOwnProperty("inputmode") && (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)),
  1212. "rtfm" === opts.androidHack && (opts.colorMask !== !0 && initializeColorMask(el),
  1213. el.type = "password")), EventRuler.off(el), patchValueProperty(el), isElementTypeSupported(el, opts) && (EventRuler.on(el, "submit", submitEvent),
  1214. EventRuler.on(el, "reset", resetEvent), EventRuler.on(el, "mouseenter", mouseenterEvent),
  1215. EventRuler.on(el, "blur", blurEvent), EventRuler.on(el, "focus", focusEvent), EventRuler.on(el, "mouseleave", mouseleaveEvent),
  1216. opts.colorMask !== !0 && EventRuler.on(el, "click", clickEvent), EventRuler.on(el, "dblclick", dblclickEvent),
  1217. EventRuler.on(el, "paste", pasteEvent), EventRuler.on(el, "dragdrop", pasteEvent),
  1218. EventRuler.on(el, "drop", pasteEvent), EventRuler.on(el, "cut", cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  1219. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  1220. opts.inputEventOnly !== !0 && (EventRuler.on(el, "keydown", keydownEvent), EventRuler.on(el, "keypress", keypressEvent)),
  1221. EventRuler.on(el, "compositionstart", $.noop), EventRuler.on(el, "compositionupdate", $.noop),
  1222. EventRuler.on(el, "compositionend", $.noop), EventRuler.on(el, "keyup", $.noop),
  1223. EventRuler.on(el, "input", inputFallBackEvent)), EventRuler.on(el, "setvalue", setValueEvent),
  1224. getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el) {
  1225. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  1226. checkVal(el, !0, !1, initialValue.split(""));
  1227. var buffer = getBuffer().slice();
  1228. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  1229. opts.clearMaskOnLostFocus && document.activeElement !== el && (getLastValidPosition() === -1 ? buffer = [] : clearOptionalTail(buffer)),
  1230. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  1231. }
  1232. }
  1233. var undoValue, el, $el, maxLength, colorMask, valueBuffer, isRTL = !1, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !0, EventRuler = {
  1234. on: function(input, eventName, eventHandler) {
  1235. var ev = function(e) {
  1236. if (void 0 === this.inputmask && "FORM" !== this.nodeName) {
  1237. var imOpts = $.data(this, "_inputmask_opts");
  1238. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  1239. } else {
  1240. if ("setvalue" === e.type || !(this.disabled || this.readOnly && !("keydown" === e.type && e.ctrlKey && 67 === e.keyCode || opts.tabThrough === !1 && e.keyCode === Inputmask.keyCode.TAB))) {
  1241. switch (e.type) {
  1242. case "input":
  1243. if (skipInputEvent === !0) return skipInputEvent = !1, e.preventDefault();
  1244. break;
  1245. case "keydown":
  1246. skipKeyPressEvent = !1, skipInputEvent = !1;
  1247. break;
  1248. case "keypress":
  1249. if (skipKeyPressEvent === !0) return e.preventDefault();
  1250. skipKeyPressEvent = !0;
  1251. break;
  1252. case "click":
  1253. if (iemobile || iphone) {
  1254. var that = this, args = arguments;
  1255. return setTimeout(function() {
  1256. eventHandler.apply(that, args);
  1257. }, 0), !1;
  1258. }
  1259. }
  1260. var returnVal = eventHandler.apply(this, arguments);
  1261. return returnVal === !1 && (e.preventDefault(), e.stopPropagation()), returnVal;
  1262. }
  1263. e.preventDefault();
  1264. }
  1265. };
  1266. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  1267. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  1268. },
  1269. off: function(input, event) {
  1270. if (input.inputmask && input.inputmask.events) {
  1271. var events;
  1272. event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
  1273. $.each(events, function(eventName, evArr) {
  1274. for (;evArr.length > 0; ) {
  1275. var ev = evArr.pop();
  1276. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  1277. }
  1278. delete input.inputmask.events[eventName];
  1279. });
  1280. }
  1281. }
  1282. };
  1283. if (void 0 !== actionObj) switch (actionObj.action) {
  1284. case "isComplete":
  1285. return el = actionObj.el, isComplete(getBuffer());
  1286. case "unmaskedvalue":
  1287. return el = actionObj.el, void 0 !== el && void 0 !== el.inputmask ? (maskset = el.inputmask.maskset,
  1288. opts = el.inputmask.opts, isRTL = el.inputmask.isRTL) : (valueBuffer = actionObj.value,
  1289. opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1290. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts)),
  1291. unmaskedvalue(el);
  1292. case "mask":
  1293. el = actionObj.el, maskset = el.inputmask.maskset, opts = el.inputmask.opts, isRTL = el.inputmask.isRTL,
  1294. mask(el);
  1295. break;
  1296. case "format":
  1297. return opts.numericInput && (isRTL = !0), valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1298. checkVal(void 0, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(void 0, getBuffer(), 0, opts),
  1299. actionObj.metadata ? {
  1300. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1301. metadata: maskScope({
  1302. action: "getmetadata"
  1303. }, maskset, opts)
  1304. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1305. case "isValid":
  1306. opts.numericInput && (isRTL = !0), actionObj.value ? (valueBuffer = actionObj.value.split(""),
  1307. checkVal(void 0, !1, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1308. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1309. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1310. case "getemptymask":
  1311. return getBufferTemplate().join("");
  1312. case "remove":
  1313. el = actionObj.el, $el = $(el), maskset = el.inputmask.maskset, opts = el.inputmask.opts,
  1314. el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
  1315. var valueProperty;
  1316. Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? (valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"),
  1317. valueProperty && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1318. get: el.inputmask.__valueGet,
  1319. set: el.inputmask.__valueSet,
  1320. configurable: !0
  1321. })) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1322. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = void 0;
  1323. break;
  1324. case "getmetadata":
  1325. if ($.isArray(maskset.metadata)) {
  1326. for (var alternation, lvp = getLastValidPosition(void 0, !0), firstAlt = lvp; firstAlt >= 0; firstAlt--) if (getMaskSet().validPositions[firstAlt] && void 0 !== getMaskSet().validPositions[firstAlt].alternation) {
  1327. alternation = getMaskSet().validPositions[firstAlt].alternation;
  1328. break;
  1329. }
  1330. return void 0 !== alternation ? maskset.metadata[getMaskSet().validPositions[firstAlt].locator[alternation]] : [];
  1331. }
  1332. return maskset.metadata;
  1333. }
  1334. }
  1335. Inputmask.prototype = {
  1336. defaults: {
  1337. placeholder: "_",
  1338. optionalmarker: {
  1339. start: "[",
  1340. end: "]"
  1341. },
  1342. quantifiermarker: {
  1343. start: "{",
  1344. end: "}"
  1345. },
  1346. groupmarker: {
  1347. start: "(",
  1348. end: ")"
  1349. },
  1350. alternatormarker: "|",
  1351. escapeChar: "\\",
  1352. mask: null,
  1353. oncomplete: $.noop,
  1354. onincomplete: $.noop,
  1355. oncleared: $.noop,
  1356. repeat: 0,
  1357. greedy: !0,
  1358. autoUnmask: !1,
  1359. removeMaskOnSubmit: !1,
  1360. clearMaskOnLostFocus: !0,
  1361. insertMode: !0,
  1362. clearIncomplete: !1,
  1363. aliases: {},
  1364. alias: null,
  1365. onKeyDown: $.noop,
  1366. onBeforeMask: null,
  1367. onBeforePaste: function(pastedValue, opts) {
  1368. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1369. },
  1370. onBeforeWrite: null,
  1371. onUnMask: null,
  1372. showMaskOnFocus: !0,
  1373. showMaskOnHover: !0,
  1374. onKeyValidation: $.noop,
  1375. skipOptionalPartCharacter: " ",
  1376. showTooltip: !1,
  1377. tooltip: void 0,
  1378. numericInput: !1,
  1379. rightAlign: !1,
  1380. undoOnEscape: !0,
  1381. radixPoint: "",
  1382. radixPointDefinitionSymbol: void 0,
  1383. groupSeparator: "",
  1384. keepStatic: null,
  1385. positionCaretOnTab: !0,
  1386. tabThrough: !1,
  1387. supportsInputType: [ "text", "tel", "password" ],
  1388. definitions: {
  1389. "9": {
  1390. validator: "[0-9]",
  1391. cardinality: 1,
  1392. definitionSymbol: "*"
  1393. },
  1394. a: {
  1395. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1396. cardinality: 1,
  1397. definitionSymbol: "*"
  1398. },
  1399. "*": {
  1400. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1401. cardinality: 1
  1402. }
  1403. },
  1404. 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 ],
  1405. isComplete: null,
  1406. canClearPosition: $.noop,
  1407. postValidation: null,
  1408. staticDefinitionSymbol: void 0,
  1409. jitMasking: !1,
  1410. nullable: !0,
  1411. inputEventOnly: !1,
  1412. noValuePatching: !1,
  1413. positionCaretOnClick: "lvp",
  1414. casing: null,
  1415. inputmode: "verbatim",
  1416. colorMask: !1,
  1417. androidHack: !1
  1418. },
  1419. masksCache: {},
  1420. mask: function(elems) {
  1421. var that = this;
  1422. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1423. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1424. var scopedOpts = $.extend(!0, {}, that.opts);
  1425. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
  1426. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1427. void 0 !== maskset && (void 0 !== el.inputmask && el.inputmask.remove(), el.inputmask = new Inputmask(),
  1428. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1429. el.inputmask.el = el, el.inputmask.maskset = maskset, el.inputmask.isRTL = !1, $.data(el, "_inputmask_opts", scopedOpts),
  1430. maskScope({
  1431. action: "mask",
  1432. el: el
  1433. }));
  1434. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1435. },
  1436. option: function(options, noremask) {
  1437. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.userOptions, options),
  1438. this.el && noremask !== !0 && this.mask(this.el), this) : void 0;
  1439. },
  1440. unmaskedvalue: function(value) {
  1441. return maskScope({
  1442. action: "unmaskedvalue",
  1443. el: this.el,
  1444. value: value
  1445. }, this.el && this.el.inputmask ? this.el.inputmask.maskset : generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1446. },
  1447. remove: function() {
  1448. if (this.el) return maskScope({
  1449. action: "remove",
  1450. el: this.el
  1451. }), this.el.inputmask = void 0, this.el;
  1452. },
  1453. getemptymask: function() {
  1454. return maskScope({
  1455. action: "getemptymask"
  1456. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1457. },
  1458. hasMaskedValue: function() {
  1459. return !this.opts.autoUnmask;
  1460. },
  1461. isComplete: function() {
  1462. return maskScope({
  1463. action: "isComplete",
  1464. el: this.el
  1465. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1466. },
  1467. getmetadata: function() {
  1468. return maskScope({
  1469. action: "getmetadata"
  1470. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1471. },
  1472. isValid: function(value) {
  1473. return maskScope({
  1474. action: "isValid",
  1475. value: value
  1476. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1477. },
  1478. format: function(value, metadata) {
  1479. return maskScope({
  1480. action: "format",
  1481. value: value,
  1482. metadata: metadata
  1483. }, this.maskset || generateMaskSet(this.opts, this.noMasksCache), this.opts);
  1484. }
  1485. }, Inputmask.extendDefaults = function(options) {
  1486. $.extend(!0, Inputmask.prototype.defaults, options);
  1487. }, Inputmask.extendDefinitions = function(definition) {
  1488. $.extend(!0, Inputmask.prototype.defaults.definitions, definition);
  1489. }, Inputmask.extendAliases = function(alias) {
  1490. $.extend(!0, Inputmask.prototype.defaults.aliases, alias);
  1491. }, Inputmask.format = function(value, options, metadata) {
  1492. return Inputmask(options).format(value, metadata);
  1493. }, Inputmask.unmask = function(value, options) {
  1494. return Inputmask(options).unmaskedvalue(value);
  1495. }, Inputmask.isValid = function(value, options) {
  1496. return Inputmask(options).isValid(value);
  1497. }, Inputmask.remove = function(elems) {
  1498. $.each(elems, function(ndx, el) {
  1499. el.inputmask && el.inputmask.remove();
  1500. });
  1501. }, Inputmask.escapeRegex = function(str) {
  1502. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1503. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1504. }, Inputmask.keyCode = {
  1505. ALT: 18,
  1506. BACKSPACE: 8,
  1507. BACKSPACE_SAFARI: 127,
  1508. CAPS_LOCK: 20,
  1509. COMMA: 188,
  1510. COMMAND: 91,
  1511. COMMAND_LEFT: 91,
  1512. COMMAND_RIGHT: 93,
  1513. CONTROL: 17,
  1514. DELETE: 46,
  1515. DOWN: 40,
  1516. END: 35,
  1517. ENTER: 13,
  1518. ESCAPE: 27,
  1519. HOME: 36,
  1520. INSERT: 45,
  1521. LEFT: 37,
  1522. MENU: 93,
  1523. NUMPAD_ADD: 107,
  1524. NUMPAD_DECIMAL: 110,
  1525. NUMPAD_DIVIDE: 111,
  1526. NUMPAD_ENTER: 108,
  1527. NUMPAD_MULTIPLY: 106,
  1528. NUMPAD_SUBTRACT: 109,
  1529. PAGE_DOWN: 34,
  1530. PAGE_UP: 33,
  1531. PERIOD: 190,
  1532. RIGHT: 39,
  1533. SHIFT: 16,
  1534. SPACE: 32,
  1535. TAB: 9,
  1536. UP: 38,
  1537. WINDOWS: 91,
  1538. X: 88
  1539. };
  1540. var ua = navigator.userAgent, mobile = /mobile/i.test(ua), iemobile = /iemobile/i.test(ua), iphone = /iphone/i.test(ua) && !iemobile, android = /android/i.test(ua) && !iemobile;
  1541. return window.Inputmask = Inputmask, Inputmask;
  1542. }(jQuery), function($, Inputmask) {
  1543. return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  1544. var nptmask, input = this[0];
  1545. if (void 0 === options && (options = {}), "string" == typeof fn) switch (fn) {
  1546. case "unmaskedvalue":
  1547. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  1548. case "remove":
  1549. return this.each(function() {
  1550. this.inputmask && this.inputmask.remove();
  1551. });
  1552. case "getemptymask":
  1553. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  1554. case "hasMaskedValue":
  1555. return !(!input || !input.inputmask) && input.inputmask.hasMaskedValue();
  1556. case "isComplete":
  1557. return !input || !input.inputmask || input.inputmask.isComplete();
  1558. case "getmetadata":
  1559. return input && input.inputmask ? input.inputmask.getmetadata() : void 0;
  1560. case "setvalue":
  1561. $(input).val(options), input && void 0 === input.inputmask && $(input).triggerHandler("setvalue");
  1562. break;
  1563. case "option":
  1564. if ("string" != typeof options) return this.each(function() {
  1565. if (void 0 !== this.inputmask) return this.inputmask.option(options);
  1566. });
  1567. if (input && void 0 !== input.inputmask) return input.inputmask.option(options);
  1568. break;
  1569. default:
  1570. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  1571. nptmask.mask(this);
  1572. });
  1573. } else {
  1574. if ("object" == typeof fn) return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
  1575. return void 0 !== this.inputmask ? this.inputmask.option(fn) : void nptmask.mask(this);
  1576. }) : this.each(function() {
  1577. nptmask.mask(this);
  1578. });
  1579. if (void 0 === fn) return this.each(function() {
  1580. nptmask = new Inputmask(options), nptmask.mask(this);
  1581. });
  1582. }
  1583. }), $.fn.inputmask;
  1584. }(jQuery, Inputmask), function($, Inputmask) {
  1585. return Inputmask.extendDefinitions({
  1586. h: {
  1587. validator: "[01][0-9]|2[0-3]",
  1588. cardinality: 2,
  1589. prevalidator: [ {
  1590. validator: "[0-2]",
  1591. cardinality: 1
  1592. } ]
  1593. },
  1594. s: {
  1595. validator: "[0-5][0-9]",
  1596. cardinality: 2,
  1597. prevalidator: [ {
  1598. validator: "[0-5]",
  1599. cardinality: 1
  1600. } ]
  1601. },
  1602. d: {
  1603. validator: "0[1-9]|[12][0-9]|3[01]",
  1604. cardinality: 2,
  1605. prevalidator: [ {
  1606. validator: "[0-3]",
  1607. cardinality: 1
  1608. } ]
  1609. },
  1610. m: {
  1611. validator: "0[1-9]|1[012]",
  1612. cardinality: 2,
  1613. prevalidator: [ {
  1614. validator: "[01]",
  1615. cardinality: 1
  1616. } ]
  1617. },
  1618. y: {
  1619. validator: "(19|20)\\d{2}",
  1620. cardinality: 4,
  1621. prevalidator: [ {
  1622. validator: "[12]",
  1623. cardinality: 1
  1624. }, {
  1625. validator: "(19|20)",
  1626. cardinality: 2
  1627. }, {
  1628. validator: "(19|20)\\d",
  1629. cardinality: 3
  1630. } ]
  1631. }
  1632. }), Inputmask.extendAliases({
  1633. "dd/mm/yyyy": {
  1634. mask: "1/2/y",
  1635. placeholder: "dd/mm/yyyy",
  1636. regex: {
  1637. val1pre: new RegExp("[0-3]"),
  1638. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1639. val2pre: function(separator) {
  1640. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1641. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1642. },
  1643. val2: function(separator) {
  1644. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1645. return new RegExp("((0[1-9]|[12][0-9])" + escapedSeparator + "(0[1-9]|1[012]))|(30" + escapedSeparator + "(0[13-9]|1[012]))|(31" + escapedSeparator + "(0[13578]|1[02]))");
  1646. }
  1647. },
  1648. leapday: "29/02/",
  1649. separator: "/",
  1650. yearrange: {
  1651. minyear: 1900,
  1652. maxyear: 2099
  1653. },
  1654. isInYearRange: function(chrs, minyear, maxyear) {
  1655. if (isNaN(chrs)) return !1;
  1656. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1657. return !isNaN(enteredyear) && (minyear <= enteredyear && enteredyear <= maxyear) || !isNaN(enteredyear2) && (minyear <= enteredyear2 && enteredyear2 <= maxyear);
  1658. },
  1659. determinebaseyear: function(minyear, maxyear, hint) {
  1660. var currentyear = new Date().getFullYear();
  1661. if (minyear > currentyear) return minyear;
  1662. if (maxyear < currentyear) {
  1663. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxyear < maxYearPrefix + hint; ) maxYearPrefix--;
  1664. var maxxYear = maxYearPrefix + maxYearPostfix;
  1665. return minyear > maxxYear ? minyear : maxxYear;
  1666. }
  1667. if (minyear <= currentyear && currentyear <= maxyear) {
  1668. for (var currentYearPrefix = currentyear.toString().slice(0, 2); maxyear < currentYearPrefix + hint; ) currentYearPrefix--;
  1669. var currentYearAndHint = currentYearPrefix + hint;
  1670. return currentYearAndHint < minyear ? minyear : currentYearAndHint;
  1671. }
  1672. return currentyear;
  1673. },
  1674. onKeyDown: function(e, buffer, caretPos, opts) {
  1675. var $input = $(this);
  1676. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1677. var today = new Date();
  1678. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
  1679. $input.trigger("setvalue");
  1680. }
  1681. },
  1682. getFrontValue: function(mask, buffer, opts) {
  1683. for (var start = 0, length = 0, i = 0; i < mask.length && "2" !== mask.charAt(i); i++) {
  1684. var definition = opts.definitions[mask.charAt(i)];
  1685. definition ? (start += length, length = definition.cardinality) : length++;
  1686. }
  1687. return buffer.join("").substr(start, length);
  1688. },
  1689. definitions: {
  1690. "1": {
  1691. validator: function(chrs, maskset, pos, strict, opts) {
  1692. var isValid = opts.regex.val1.test(chrs);
  1693. return strict || isValid || chrs.charAt(1) !== opts.separator && "-./".indexOf(chrs.charAt(1)) === -1 || !(isValid = opts.regex.val1.test("0" + chrs.charAt(0))) ? isValid : (maskset.buffer[pos - 1] = "0",
  1694. {
  1695. refreshFromBuffer: {
  1696. start: pos - 1,
  1697. end: pos
  1698. },
  1699. pos: pos,
  1700. c: chrs.charAt(0)
  1701. });
  1702. },
  1703. cardinality: 2,
  1704. prevalidator: [ {
  1705. validator: function(chrs, maskset, pos, strict, opts) {
  1706. var pchrs = chrs;
  1707. isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
  1708. var isValid = 1 === pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
  1709. if (!strict && !isValid) {
  1710. if (isValid = opts.regex.val1.test(chrs + "0")) return maskset.buffer[pos] = chrs,
  1711. maskset.buffer[++pos] = "0", {
  1712. pos: pos,
  1713. c: "0"
  1714. };
  1715. if (isValid = opts.regex.val1.test("0" + chrs)) return maskset.buffer[pos] = "0",
  1716. pos++, {
  1717. pos: pos
  1718. };
  1719. }
  1720. return isValid;
  1721. },
  1722. cardinality: 1
  1723. } ]
  1724. },
  1725. "2": {
  1726. validator: function(chrs, maskset, pos, strict, opts) {
  1727. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1728. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1729. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1730. if (!strict && !isValid && (chrs.charAt(1) === opts.separator || "-./".indexOf(chrs.charAt(1)) !== -1) && (isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
  1731. {
  1732. refreshFromBuffer: {
  1733. start: pos - 1,
  1734. end: pos
  1735. },
  1736. pos: pos,
  1737. c: chrs.charAt(0)
  1738. };
  1739. if (opts.mask.indexOf("2") === opts.mask.length - 1 && isValid) {
  1740. var dayMonthValue = maskset.buffer.join("").substr(4, 4) + chrs;
  1741. if (dayMonthValue !== opts.leapday) return !0;
  1742. var year = parseInt(maskset.buffer.join("").substr(0, 4), 10);
  1743. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  1744. }
  1745. return isValid;
  1746. },
  1747. cardinality: 2,
  1748. prevalidator: [ {
  1749. validator: function(chrs, maskset, pos, strict, opts) {
  1750. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1751. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1752. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1753. var isValid = 1 === chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1754. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1755. pos++, {
  1756. pos: pos
  1757. });
  1758. },
  1759. cardinality: 1
  1760. } ]
  1761. },
  1762. y: {
  1763. validator: function(chrs, maskset, pos, strict, opts) {
  1764. if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1765. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1766. if (dayMonthValue !== opts.leapday) return !0;
  1767. var year = parseInt(chrs, 10);
  1768. return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  1769. }
  1770. return !1;
  1771. },
  1772. cardinality: 4,
  1773. prevalidator: [ {
  1774. validator: function(chrs, maskset, pos, strict, opts) {
  1775. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1776. if (!strict && !isValid) {
  1777. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1778. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1779. {
  1780. pos: pos
  1781. };
  1782. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1783. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1784. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1785. pos: pos
  1786. };
  1787. }
  1788. return isValid;
  1789. },
  1790. cardinality: 1
  1791. }, {
  1792. validator: function(chrs, maskset, pos, strict, opts) {
  1793. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1794. if (!strict && !isValid) {
  1795. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1796. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1797. {
  1798. pos: pos
  1799. };
  1800. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1801. opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
  1802. var dayMonthValue = maskset.buffer.join("").substr(0, 6);
  1803. if (dayMonthValue !== opts.leapday) isValid = !0; else {
  1804. var year = parseInt(chrs, 10);
  1805. isValid = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
  1806. }
  1807. } else isValid = !1;
  1808. if (isValid) return maskset.buffer[pos - 1] = yearPrefix.charAt(0), maskset.buffer[pos++] = yearPrefix.charAt(1),
  1809. maskset.buffer[pos++] = chrs.charAt(0), {
  1810. refreshFromBuffer: {
  1811. start: pos - 3,
  1812. end: pos
  1813. },
  1814. pos: pos
  1815. };
  1816. }
  1817. return isValid;
  1818. },
  1819. cardinality: 2
  1820. }, {
  1821. validator: function(chrs, maskset, pos, strict, opts) {
  1822. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1823. },
  1824. cardinality: 3
  1825. } ]
  1826. }
  1827. },
  1828. insertMode: !1,
  1829. autoUnmask: !1
  1830. },
  1831. "mm/dd/yyyy": {
  1832. placeholder: "mm/dd/yyyy",
  1833. alias: "dd/mm/yyyy",
  1834. regex: {
  1835. val2pre: function(separator) {
  1836. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1837. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1838. },
  1839. val2: function(separator) {
  1840. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1841. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  1842. },
  1843. val1pre: new RegExp("[01]"),
  1844. val1: new RegExp("0[1-9]|1[012]")
  1845. },
  1846. leapday: "02/29/",
  1847. onKeyDown: function(e, buffer, caretPos, opts) {
  1848. var $input = $(this);
  1849. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1850. var today = new Date();
  1851. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1852. $input.trigger("setvalue");
  1853. }
  1854. }
  1855. },
  1856. "yyyy/mm/dd": {
  1857. mask: "y/1/2",
  1858. placeholder: "yyyy/mm/dd",
  1859. alias: "mm/dd/yyyy",
  1860. leapday: "/02/29",
  1861. onKeyDown: function(e, buffer, caretPos, opts) {
  1862. var $input = $(this);
  1863. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1864. var today = new Date();
  1865. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
  1866. $input.trigger("setvalue");
  1867. }
  1868. }
  1869. },
  1870. "dd.mm.yyyy": {
  1871. mask: "1.2.y",
  1872. placeholder: "dd.mm.yyyy",
  1873. leapday: "29.02.",
  1874. separator: ".",
  1875. alias: "dd/mm/yyyy"
  1876. },
  1877. "dd-mm-yyyy": {
  1878. mask: "1-2-y",
  1879. placeholder: "dd-mm-yyyy",
  1880. leapday: "29-02-",
  1881. separator: "-",
  1882. alias: "dd/mm/yyyy"
  1883. },
  1884. "mm.dd.yyyy": {
  1885. mask: "1.2.y",
  1886. placeholder: "mm.dd.yyyy",
  1887. leapday: "02.29.",
  1888. separator: ".",
  1889. alias: "mm/dd/yyyy"
  1890. },
  1891. "mm-dd-yyyy": {
  1892. mask: "1-2-y",
  1893. placeholder: "mm-dd-yyyy",
  1894. leapday: "02-29-",
  1895. separator: "-",
  1896. alias: "mm/dd/yyyy"
  1897. },
  1898. "yyyy.mm.dd": {
  1899. mask: "y.1.2",
  1900. placeholder: "yyyy.mm.dd",
  1901. leapday: ".02.29",
  1902. separator: ".",
  1903. alias: "yyyy/mm/dd"
  1904. },
  1905. "yyyy-mm-dd": {
  1906. mask: "y-1-2",
  1907. placeholder: "yyyy-mm-dd",
  1908. leapday: "-02-29",
  1909. separator: "-",
  1910. alias: "yyyy/mm/dd"
  1911. },
  1912. datetime: {
  1913. mask: "1/2/y h:s",
  1914. placeholder: "dd/mm/yyyy hh:mm",
  1915. alias: "dd/mm/yyyy",
  1916. regex: {
  1917. hrspre: new RegExp("[012]"),
  1918. hrs24: new RegExp("2[0-4]|1[3-9]"),
  1919. hrs: new RegExp("[01][0-9]|2[0-4]"),
  1920. ampm: new RegExp("^[a|p|A|P][m|M]"),
  1921. mspre: new RegExp("[0-5]"),
  1922. ms: new RegExp("[0-5][0-9]")
  1923. },
  1924. timeseparator: ":",
  1925. hourFormat: "24",
  1926. definitions: {
  1927. h: {
  1928. validator: function(chrs, maskset, pos, strict, opts) {
  1929. if ("24" === opts.hourFormat && 24 === parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
  1930. maskset.buffer[pos] = "0", {
  1931. refreshFromBuffer: {
  1932. start: pos - 1,
  1933. end: pos
  1934. },
  1935. c: "0"
  1936. };
  1937. var isValid = opts.regex.hrs.test(chrs);
  1938. if (!strict && !isValid && (chrs.charAt(1) === opts.timeseparator || "-.:".indexOf(chrs.charAt(1)) !== -1) && (isValid = opts.regex.hrs.test("0" + chrs.charAt(0)))) return maskset.buffer[pos - 1] = "0",
  1939. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  1940. refreshFromBuffer: {
  1941. start: pos - 2,
  1942. end: pos
  1943. },
  1944. pos: pos,
  1945. c: opts.timeseparator
  1946. };
  1947. if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
  1948. var tmp = parseInt(chrs, 10);
  1949. return 24 === tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  1950. maskset.buffer[pos + 6] = "m"), tmp -= 12, tmp < 10 ? (maskset.buffer[pos] = tmp.toString(),
  1951. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  1952. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  1953. refreshFromBuffer: {
  1954. start: pos - 1,
  1955. end: pos + 6
  1956. },
  1957. c: maskset.buffer[pos]
  1958. };
  1959. }
  1960. return isValid;
  1961. },
  1962. cardinality: 2,
  1963. prevalidator: [ {
  1964. validator: function(chrs, maskset, pos, strict, opts) {
  1965. var isValid = opts.regex.hrspre.test(chrs);
  1966. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1967. pos++, {
  1968. pos: pos
  1969. });
  1970. },
  1971. cardinality: 1
  1972. } ]
  1973. },
  1974. s: {
  1975. validator: "[0-5][0-9]",
  1976. cardinality: 2,
  1977. prevalidator: [ {
  1978. validator: function(chrs, maskset, pos, strict, opts) {
  1979. var isValid = opts.regex.mspre.test(chrs);
  1980. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1981. pos++, {
  1982. pos: pos
  1983. });
  1984. },
  1985. cardinality: 1
  1986. } ]
  1987. },
  1988. t: {
  1989. validator: function(chrs, maskset, pos, strict, opts) {
  1990. return opts.regex.ampm.test(chrs + "m");
  1991. },
  1992. casing: "lower",
  1993. cardinality: 1
  1994. }
  1995. },
  1996. insertMode: !1,
  1997. autoUnmask: !1
  1998. },
  1999. datetime12: {
  2000. mask: "1/2/y h:s t\\m",
  2001. placeholder: "dd/mm/yyyy hh:mm xm",
  2002. alias: "datetime",
  2003. hourFormat: "12"
  2004. },
  2005. "mm/dd/yyyy hh:mm xm": {
  2006. mask: "1/2/y h:s t\\m",
  2007. placeholder: "mm/dd/yyyy hh:mm xm",
  2008. alias: "datetime12",
  2009. regex: {
  2010. val2pre: function(separator) {
  2011. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2012. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2013. },
  2014. val2: function(separator) {
  2015. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2016. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[13-9]|1[012])" + escapedSeparator + "30)|((0[13578]|1[02])" + escapedSeparator + "31)");
  2017. },
  2018. val1pre: new RegExp("[01]"),
  2019. val1: new RegExp("0[1-9]|1[012]")
  2020. },
  2021. leapday: "02/29/",
  2022. onKeyDown: function(e, buffer, caretPos, opts) {
  2023. var $input = $(this);
  2024. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  2025. var today = new Date();
  2026. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  2027. $input.trigger("setvalue");
  2028. }
  2029. }
  2030. },
  2031. "hh:mm t": {
  2032. mask: "h:s t\\m",
  2033. placeholder: "hh:mm xm",
  2034. alias: "datetime",
  2035. hourFormat: "12"
  2036. },
  2037. "h:s t": {
  2038. mask: "h:s t\\m",
  2039. placeholder: "hh:mm xm",
  2040. alias: "datetime",
  2041. hourFormat: "12"
  2042. },
  2043. "hh:mm:ss": {
  2044. mask: "h:s:s",
  2045. placeholder: "hh:mm:ss",
  2046. alias: "datetime",
  2047. autoUnmask: !1
  2048. },
  2049. "hh:mm": {
  2050. mask: "h:s",
  2051. placeholder: "hh:mm",
  2052. alias: "datetime",
  2053. autoUnmask: !1
  2054. },
  2055. date: {
  2056. alias: "dd/mm/yyyy"
  2057. },
  2058. "mm/yyyy": {
  2059. mask: "1/y",
  2060. placeholder: "mm/yyyy",
  2061. leapday: "donotuse",
  2062. separator: "/",
  2063. alias: "mm/dd/yyyy"
  2064. },
  2065. shamsi: {
  2066. regex: {
  2067. val2pre: function(separator) {
  2068. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2069. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "[0-3])");
  2070. },
  2071. val2: function(separator) {
  2072. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2073. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "(0[1-9]|[12][0-9]))|((0[1-9]|1[012])" + escapedSeparator + "30)|((0[1-6])" + escapedSeparator + "31)");
  2074. },
  2075. val1pre: new RegExp("[01]"),
  2076. val1: new RegExp("0[1-9]|1[012]")
  2077. },
  2078. yearrange: {
  2079. minyear: 1300,
  2080. maxyear: 1499
  2081. },
  2082. mask: "y/1/2",
  2083. leapday: "/12/30",
  2084. placeholder: "yyyy/mm/dd",
  2085. alias: "mm/dd/yyyy",
  2086. clearIncomplete: !0
  2087. }
  2088. }), Inputmask;
  2089. }(jQuery, Inputmask), function($, Inputmask) {
  2090. return Inputmask.extendDefinitions({
  2091. A: {
  2092. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2093. cardinality: 1,
  2094. casing: "upper"
  2095. },
  2096. "&": {
  2097. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2098. cardinality: 1,
  2099. casing: "upper"
  2100. },
  2101. "#": {
  2102. validator: "[0-9A-Fa-f]",
  2103. cardinality: 1,
  2104. casing: "upper"
  2105. }
  2106. }), Inputmask.extendAliases({
  2107. url: {
  2108. definitions: {
  2109. i: {
  2110. validator: ".",
  2111. cardinality: 1
  2112. }
  2113. },
  2114. mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
  2115. insertMode: !1,
  2116. autoUnmask: !1,
  2117. inputmode: "url"
  2118. },
  2119. ip: {
  2120. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  2121. definitions: {
  2122. i: {
  2123. validator: function(chrs, maskset, pos, strict, opts) {
  2124. return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
  2125. chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  2126. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  2127. },
  2128. cardinality: 1
  2129. }
  2130. },
  2131. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2132. return maskedValue;
  2133. },
  2134. inputmode: "numeric"
  2135. },
  2136. email: {
  2137. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
  2138. greedy: !1,
  2139. onBeforePaste: function(pastedValue, opts) {
  2140. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  2141. },
  2142. definitions: {
  2143. "*": {
  2144. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  2145. cardinality: 1,
  2146. casing: "lower"
  2147. },
  2148. "-": {
  2149. validator: "[0-9A-Za-z-]",
  2150. cardinality: 1,
  2151. casing: "lower"
  2152. }
  2153. },
  2154. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2155. return maskedValue;
  2156. },
  2157. inputmode: "email"
  2158. },
  2159. mac: {
  2160. mask: "##:##:##:##:##:##"
  2161. },
  2162. vin: {
  2163. mask: "V{13}9{4}",
  2164. definitions: {
  2165. V: {
  2166. validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
  2167. cardinality: 1,
  2168. casing: "upper"
  2169. }
  2170. },
  2171. clearIncomplete: !0,
  2172. autoUnmask: !0
  2173. }
  2174. }), Inputmask;
  2175. }(jQuery, Inputmask), function($, Inputmask) {
  2176. return Inputmask.extendAliases({
  2177. numeric: {
  2178. mask: function(opts) {
  2179. function autoEscape(txt) {
  2180. for (var escapedTxt = "", i = 0; i < txt.length; i++) escapedTxt += opts.definitions[txt.charAt(i)] || opts.optionalmarker.start === txt.charAt(i) || opts.optionalmarker.end === txt.charAt(i) || opts.quantifiermarker.start === txt.charAt(i) || opts.quantifiermarker.end === txt.charAt(i) || opts.groupmarker.start === txt.charAt(i) || opts.groupmarker.end === txt.charAt(i) || opts.alternatormarker === txt.charAt(i) ? "\\" + txt.charAt(i) : txt.charAt(i);
  2181. return escapedTxt;
  2182. }
  2183. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  2184. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  2185. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = void 0), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
  2186. opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  2187. isFinite(opts.integerDigits))) {
  2188. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  2189. opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
  2190. opts.integerDigits < 1 && (opts.integerDigits = "*");
  2191. }
  2192. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  2193. "radixFocus" === opts.positionCaretOnClick && "" === opts.placeholder && opts.integerOptional === !1 && (opts.positionCaretOnClick = "lvp"),
  2194. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  2195. opts.numericInput === !0 && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick,
  2196. opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
  2197. var mask = "[+]";
  2198. if (mask += autoEscape(opts.prefix), mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
  2199. void 0 !== opts.digits) {
  2200. opts.decimalProtect && (opts.radixPointDefinitionSymbol = ":");
  2201. var dq = opts.digits.toString().split(",");
  2202. isFinite(dq[0] && dq[1] && isFinite(dq[1])) ? mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}" : (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}");
  2203. }
  2204. return mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2205. "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, "."))),
  2206. null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2207. "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, "."))),
  2208. mask;
  2209. },
  2210. placeholder: "",
  2211. greedy: !1,
  2212. digits: "*",
  2213. digitsOptional: !0,
  2214. radixPoint: ".",
  2215. positionCaretOnClick: "radixFocus",
  2216. groupSize: 3,
  2217. groupSeparator: "",
  2218. autoGroup: !1,
  2219. allowPlus: !0,
  2220. allowMinus: !0,
  2221. negationSymbol: {
  2222. front: "-",
  2223. back: ""
  2224. },
  2225. integerDigits: "+",
  2226. integerOptional: !0,
  2227. prefix: "",
  2228. suffix: "",
  2229. rightAlign: !0,
  2230. decimalProtect: !0,
  2231. min: null,
  2232. max: null,
  2233. step: 1,
  2234. insertMode: !0,
  2235. autoUnmask: !1,
  2236. unmaskAsNumber: !1,
  2237. inputmode: "numeric",
  2238. postFormat: function(buffer, pos, opts) {
  2239. opts.numericInput === !0 && (buffer = buffer.reverse(), isFinite(pos) && (pos = buffer.join("").length - pos - 1));
  2240. var i, l;
  2241. pos = pos >= buffer.length ? buffer.length - 1 : pos < 0 ? 0 : pos;
  2242. var charAtPos = buffer[pos], cbuf = buffer.slice();
  2243. charAtPos === opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]);
  2244. var isNegative = cbuf.join("").match(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)));
  2245. isNegative = null !== isNegative && 1 === isNegative.length, pos > (isNegative ? opts.negationSymbol.front.length : 0) + opts.prefix.length && pos < cbuf.length - opts.suffix.length && (cbuf[pos] = "!");
  2246. var bufVal = cbuf.join(""), bufValOrigin = cbuf.join();
  2247. if (isNegative && (bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), ""),
  2248. bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "")),
  2249. bufVal = bufVal.replace(new RegExp(Inputmask.escapeRegex(opts.suffix) + "$"), ""),
  2250. bufVal = bufVal.replace(new RegExp("^" + Inputmask.escapeRegex(opts.prefix)), ""),
  2251. bufVal.length > 0 && opts.autoGroup || bufVal.indexOf(opts.groupSeparator) !== -1) {
  2252. var escapedGroupSeparator = Inputmask.escapeRegex(opts.groupSeparator);
  2253. bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), "");
  2254. var radixSplit = bufVal.split(charAtPos === opts.radixPoint ? "!" : opts.radixPoint);
  2255. if (bufVal = "" === opts.radixPoint ? bufVal : radixSplit[0], charAtPos !== opts.negationSymbol.front && (bufVal = bufVal.replace("!", "?")),
  2256. bufVal.length > opts.groupSize) for (var reg = new RegExp("([-+]?[\\d?]+)([\\d?]{" + opts.groupSize + "})"); reg.test(bufVal) && "" !== opts.groupSeparator; ) bufVal = bufVal.replace(reg, "$1" + opts.groupSeparator + "$2"),
  2257. bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
  2258. bufVal = bufVal.replace("?", "!"), "" !== opts.radixPoint && radixSplit.length > 1 && (bufVal += (charAtPos === opts.radixPoint ? "!" : opts.radixPoint) + radixSplit[1]);
  2259. }
  2260. bufVal = opts.prefix + bufVal + opts.suffix, isNegative && (bufVal = opts.negationSymbol.front + bufVal + opts.negationSymbol.back);
  2261. var needsRefresh = bufValOrigin !== bufVal.split("").join(), newPos = $.inArray("!", bufVal);
  2262. if (newPos === -1 && (newPos = pos), needsRefresh) {
  2263. for (buffer.length = bufVal.length, i = 0, l = bufVal.length; i < l; i++) buffer[i] = bufVal.charAt(i);
  2264. buffer[newPos] = charAtPos;
  2265. }
  2266. return newPos = opts.numericInput && isFinite(pos) ? buffer.join("").length - newPos - 1 : newPos,
  2267. opts.numericInput && (buffer = buffer.reverse(), $.inArray(opts.radixPoint, buffer) < newPos && buffer.join("").length - opts.suffix.length !== newPos && (newPos -= 1)),
  2268. {
  2269. pos: newPos,
  2270. refreshFromBuffer: needsRefresh,
  2271. buffer: buffer,
  2272. isNegative: isNegative
  2273. };
  2274. },
  2275. onBeforeWrite: function(e, buffer, caretPos, opts) {
  2276. var rslt;
  2277. if (e && ("blur" === e.type || "checkval" === e.type || "keydown" === e.type)) {
  2278. var maskedValue = opts.numericInput ? buffer.slice().reverse().join("") : buffer.join(""), processValue = maskedValue.replace(opts.prefix, "");
  2279. processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2280. "," === opts.radixPoint && (processValue = processValue.replace(opts.radixPoint, "."));
  2281. var isNegative = processValue.match(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"));
  2282. if (isNegative = null !== isNegative && 1 === isNegative.length, processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  2283. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2284. isNaN(opts.placeholder) && (processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "")),
  2285. processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue,
  2286. "" !== processValue && isFinite(processValue)) {
  2287. var floatValue = parseFloat(processValue), signedFloatValue = isNegative ? floatValue * -1 : floatValue;
  2288. if (null !== opts.min && isFinite(opts.min) && signedFloatValue < parseFloat(opts.min) ? (floatValue = Math.abs(opts.min),
  2289. isNegative = opts.min < 0, maskedValue = void 0) : null !== opts.max && isFinite(opts.max) && signedFloatValue > parseFloat(opts.max) && (floatValue = Math.abs(opts.max),
  2290. isNegative = opts.max < 0, maskedValue = void 0), processValue = floatValue.toString().replace(".", opts.radixPoint).split(""),
  2291. isFinite(opts.digits)) {
  2292. var radixPosition = $.inArray(opts.radixPoint, processValue), rpb = $.inArray(opts.radixPoint, maskedValue);
  2293. radixPosition === -1 && (processValue.push(opts.radixPoint), radixPosition = processValue.length - 1);
  2294. for (var i = 1; i <= opts.digits; i++) opts.digitsOptional || void 0 !== processValue[radixPosition + i] && processValue[radixPosition + i] !== opts.placeholder.charAt(0) ? rpb !== -1 && void 0 !== maskedValue[rpb + i] && (processValue[radixPosition + i] = processValue[radixPosition + i] || maskedValue[rpb + i]) : processValue[radixPosition + i] = "0";
  2295. processValue[processValue.length - 1] === opts.radixPoint && delete processValue[processValue.length - 1];
  2296. }
  2297. if (floatValue.toString() !== processValue && floatValue.toString() + "." !== processValue || isNegative) return processValue = (opts.prefix + processValue.join("")).split(""),
  2298. !isNegative || 0 === floatValue && "blur" === e.type || (processValue.unshift(opts.negationSymbol.front),
  2299. processValue.push(opts.negationSymbol.back)), opts.numericInput && (processValue = processValue.reverse()),
  2300. rslt = opts.postFormat(processValue, opts.numericInput ? caretPos : caretPos - 1, opts),
  2301. rslt.buffer && (rslt.refreshFromBuffer = rslt.buffer.join("") !== buffer.join("")),
  2302. rslt;
  2303. }
  2304. }
  2305. if (opts.autoGroup) return rslt = opts.postFormat(buffer, opts.numericInput ? caretPos : caretPos - 1, opts),
  2306. rslt.caret = caretPos < (rslt.isNegative ? opts.negationSymbol.front.length : 0) + opts.prefix.length || caretPos > rslt.buffer.length - (rslt.isNegative ? opts.negationSymbol.back.length : 0) ? rslt.pos : rslt.pos + 1,
  2307. rslt;
  2308. },
  2309. regex: {
  2310. integerPart: function(opts) {
  2311. return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  2312. },
  2313. integerNPart: function(opts) {
  2314. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+");
  2315. }
  2316. },
  2317. signHandler: function(chrs, maskset, pos, strict, opts) {
  2318. if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
  2319. var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2320. if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] === ("-" === chrs ? "+" : opts.negationSymbol.front) ? "-" === chrs ? "" !== opts.negationSymbol.back ? {
  2321. pos: 0,
  2322. c: opts.negationSymbol.front,
  2323. remove: 0,
  2324. caret: pos,
  2325. insert: {
  2326. pos: maskset.buffer.length - 1,
  2327. c: opts.negationSymbol.back
  2328. }
  2329. } : {
  2330. pos: 0,
  2331. c: opts.negationSymbol.front,
  2332. remove: 0,
  2333. caret: pos
  2334. } : "" !== opts.negationSymbol.back ? {
  2335. pos: 0,
  2336. c: "+",
  2337. remove: [ 0, maskset.buffer.length - 1 ],
  2338. caret: pos
  2339. } : {
  2340. pos: 0,
  2341. c: "+",
  2342. remove: 0,
  2343. caret: pos
  2344. } : maskset.buffer[0] === ("-" === chrs ? opts.negationSymbol.front : "+") ? "-" === chrs && "" !== opts.negationSymbol.back ? {
  2345. remove: [ 0, maskset.buffer.length - 1 ],
  2346. caret: pos - 1
  2347. } : {
  2348. remove: 0,
  2349. caret: pos - 1
  2350. } : "-" === chrs ? "" !== opts.negationSymbol.back ? {
  2351. pos: 0,
  2352. c: opts.negationSymbol.front,
  2353. caret: pos + 1,
  2354. insert: {
  2355. pos: maskset.buffer.length,
  2356. c: opts.negationSymbol.back
  2357. }
  2358. } : {
  2359. pos: 0,
  2360. c: opts.negationSymbol.front,
  2361. caret: pos + 1
  2362. } : {
  2363. pos: 0,
  2364. c: chrs,
  2365. caret: pos + 1
  2366. };
  2367. }
  2368. return !1;
  2369. },
  2370. radixHandler: function(chrs, maskset, pos, strict, opts) {
  2371. if (!strict && opts.numericInput !== !0 && chrs === opts.radixPoint && void 0 !== opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
  2372. var radixPos = $.inArray(opts.radixPoint, maskset.buffer), integerValue = maskset.buffer.join("").match(opts.regex.integerPart(opts));
  2373. if (radixPos !== -1 && maskset.validPositions[radixPos]) return maskset.validPositions[radixPos - 1] ? {
  2374. caret: radixPos + 1
  2375. } : {
  2376. pos: integerValue.index,
  2377. c: integerValue[0],
  2378. caret: radixPos + 1
  2379. };
  2380. if (!integerValue || "0" === integerValue[0] && integerValue.index + 1 !== pos) return maskset.buffer[integerValue ? integerValue.index : pos] = "0",
  2381. {
  2382. pos: (integerValue ? integerValue.index : pos) + 1,
  2383. c: opts.radixPoint
  2384. };
  2385. }
  2386. return !1;
  2387. },
  2388. leadingZeroHandler: function(chrs, maskset, pos, strict, opts, isSelection) {
  2389. if (!strict) {
  2390. var buffer = maskset.buffer.slice("");
  2391. if (buffer.splice(0, opts.prefix.length), buffer.splice(buffer.length - opts.suffix.length, opts.suffix.length),
  2392. opts.numericInput === !0) {
  2393. var buffer = buffer.reverse(), bufferChar = buffer[0];
  2394. if ("0" === bufferChar && void 0 === maskset.validPositions[pos - 1]) return {
  2395. pos: pos,
  2396. remove: buffer.length - 1
  2397. };
  2398. } else {
  2399. pos -= opts.prefix.length;
  2400. var radixPosition = $.inArray(opts.radixPoint, buffer), matchRslt = buffer.slice(0, radixPosition !== -1 ? radixPosition : void 0).join("").match(opts.regex.integerNPart(opts));
  2401. if (matchRslt && (radixPosition === -1 || pos <= radixPosition)) {
  2402. var decimalPart = radixPosition === -1 ? 0 : parseInt(buffer.slice(radixPosition + 1).join(""));
  2403. if (0 === matchRslt[0].indexOf("" !== opts.placeholder ? opts.placeholder.charAt(0) : "0") && (matchRslt.index + 1 === pos || isSelection !== !0 && 0 === decimalPart)) return maskset.buffer.splice(matchRslt.index + opts.prefix.length, 1),
  2404. {
  2405. pos: matchRslt.index + opts.prefix.length,
  2406. remove: matchRslt.index + opts.prefix.length
  2407. };
  2408. if ("0" === chrs && pos <= matchRslt.index && matchRslt[0] !== opts.groupSeparator) return !1;
  2409. }
  2410. }
  2411. }
  2412. return !0;
  2413. },
  2414. definitions: {
  2415. "~": {
  2416. validator: function(chrs, maskset, pos, strict, opts, isSelection) {
  2417. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2418. if (!isValid && (isValid = opts.radixHandler(chrs, maskset, pos, strict, opts),
  2419. !isValid && (isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs),
  2420. isValid === !0 && (isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts, isSelection),
  2421. isValid === !0)))) {
  2422. var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
  2423. isValid = radixPosition !== -1 && (opts.digitsOptional === !1 || maskset.validPositions[pos]) && opts.numericInput !== !0 && pos > radixPosition && !strict ? {
  2424. pos: pos,
  2425. remove: pos
  2426. } : {
  2427. pos: pos
  2428. };
  2429. }
  2430. return isValid;
  2431. },
  2432. cardinality: 1
  2433. },
  2434. "+": {
  2435. validator: function(chrs, maskset, pos, strict, opts) {
  2436. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2437. return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) && (isValid = !(!strict && "-" === chrs) || ("" !== opts.negationSymbol.back ? {
  2438. pos: pos,
  2439. c: "-" === chrs ? opts.negationSymbol.front : "+",
  2440. caret: pos + 1,
  2441. insert: {
  2442. pos: maskset.buffer.length,
  2443. c: opts.negationSymbol.back
  2444. }
  2445. } : {
  2446. pos: pos,
  2447. c: "-" === chrs ? opts.negationSymbol.front : "+",
  2448. caret: pos + 1
  2449. })), isValid;
  2450. },
  2451. cardinality: 1,
  2452. placeholder: ""
  2453. },
  2454. "-": {
  2455. validator: function(chrs, maskset, pos, strict, opts) {
  2456. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2457. return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0),
  2458. isValid;
  2459. },
  2460. cardinality: 1,
  2461. placeholder: ""
  2462. },
  2463. ":": {
  2464. validator: function(chrs, maskset, pos, strict, opts) {
  2465. var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
  2466. if (!isValid) {
  2467. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]";
  2468. isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  2469. caret: pos + 1
  2470. });
  2471. }
  2472. return isValid;
  2473. },
  2474. cardinality: 1,
  2475. placeholder: function(opts) {
  2476. return opts.radixPoint;
  2477. }
  2478. }
  2479. },
  2480. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2481. if ("" === unmaskedValue && opts.nullable === !0) return unmaskedValue;
  2482. var processValue = maskedValue.replace(opts.prefix, "");
  2483. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2484. opts.unmaskAsNumber ? ("" !== opts.radixPoint && processValue.indexOf(opts.radixPoint) !== -1 && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  2485. Number(processValue)) : processValue;
  2486. },
  2487. isComplete: function(buffer, opts) {
  2488. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  2489. if (opts.postFormat(bufClone, 0, opts), bufClone.join("") !== maskedValue) return !1;
  2490. var processValue = maskedValue.replace(opts.prefix, "");
  2491. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2492. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2493. isFinite(processValue);
  2494. },
  2495. onBeforeMask: function(initialValue, opts) {
  2496. if (opts.numericInput === !0 && (initialValue = initialValue.split("").reverse().join("")),
  2497. "" !== opts.radixPoint && isFinite(initialValue)) initialValue = initialValue.toString().replace(".", opts.radixPoint); else {
  2498. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  2499. dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  2500. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  2501. initialValue = initialValue.replace(".", opts.radixPoint)) : initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "") : initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
  2502. }
  2503. if (0 === opts.digits && (initialValue.indexOf(".") !== -1 ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : initialValue.indexOf(",") !== -1 && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  2504. "" !== opts.radixPoint && isFinite(opts.digits) && initialValue.indexOf(opts.radixPoint) !== -1) {
  2505. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  2506. if (parseInt(opts.digits) < decPart.toString().length) {
  2507. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  2508. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  2509. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  2510. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2511. }
  2512. }
  2513. return opts.numericInput === !0 && (initialValue = initialValue.split("").reverse().join("")),
  2514. initialValue.toString();
  2515. },
  2516. canClearPosition: function(maskset, position, lvp, strict, opts) {
  2517. var positionInput = maskset.validPositions[position].input, canClear = positionInput !== opts.radixPoint || null !== maskset.validPositions[position].match.fn && opts.decimalProtect === !1 || isFinite(positionInput) || position === lvp || positionInput === opts.groupSeparator || positionInput === opts.negationSymbol.front || positionInput === opts.negationSymbol.back;
  2518. return canClear;
  2519. },
  2520. onKeyDown: function(e, buffer, caretPos, opts) {
  2521. var $input = $(this);
  2522. if (e.ctrlKey) switch (e.keyCode) {
  2523. case Inputmask.keyCode.UP:
  2524. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  2525. break;
  2526. case Inputmask.keyCode.DOWN:
  2527. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  2528. }
  2529. }
  2530. },
  2531. currency: {
  2532. prefix: "$ ",
  2533. groupSeparator: ",",
  2534. alias: "numeric",
  2535. placeholder: "0",
  2536. autoGroup: !0,
  2537. digits: 2,
  2538. digitsOptional: !1,
  2539. clearMaskOnLostFocus: !1
  2540. },
  2541. decimal: {
  2542. alias: "numeric"
  2543. },
  2544. integer: {
  2545. alias: "numeric",
  2546. digits: 0,
  2547. radixPoint: ""
  2548. },
  2549. percentage: {
  2550. alias: "numeric",
  2551. digits: 2,
  2552. radixPoint: ".",
  2553. placeholder: "0",
  2554. autoGroup: !1,
  2555. min: 0,
  2556. max: 100,
  2557. suffix: " %",
  2558. allowPlus: !1,
  2559. allowMinus: !1
  2560. }
  2561. }), Inputmask;
  2562. }(jQuery, Inputmask), function($, Inputmask) {
  2563. return Inputmask.extendAliases({
  2564. abstractphone: {
  2565. countrycode: "",
  2566. phoneCodes: [],
  2567. mask: function(opts) {
  2568. opts.definitions = {
  2569. "#": opts.definitions[9]
  2570. };
  2571. var masks = opts.phoneCodes.sort(function(a, b) {
  2572. var maska = (a.mask || a).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""), maskb = (b.mask || b).replace(/#/g, "9").replace(/[\+\(\)#-]/g, ""), maskas = (a.mask || a).split("#")[0], maskbs = (b.mask || b).split("#")[0];
  2573. return 0 === maskbs.indexOf(maskas) ? -1 : 0 === maskas.indexOf(maskbs) ? 1 : maska.localeCompare(maskb);
  2574. });
  2575. return masks;
  2576. },
  2577. keepStatic: !0,
  2578. onBeforeMask: function(value, opts) {
  2579. var processedValue = value.replace(/^0{1,2}/, "").replace(/[\s]/g, "");
  2580. return (processedValue.indexOf(opts.countrycode) > 1 || processedValue.indexOf(opts.countrycode) === -1) && (processedValue = "+" + opts.countrycode + processedValue),
  2581. processedValue;
  2582. },
  2583. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2584. return unmaskedValue;
  2585. },
  2586. inputmode: "tel"
  2587. }
  2588. }), Inputmask;
  2589. }(jQuery, Inputmask), function($, Inputmask) {
  2590. return Inputmask.extendAliases({
  2591. Regex: {
  2592. mask: "r",
  2593. greedy: !1,
  2594. repeat: "*",
  2595. regex: null,
  2596. regexTokens: null,
  2597. tokenizer: /\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,
  2598. quantifierFilter: /[0-9]+[^,]/,
  2599. isComplete: function(buffer, opts) {
  2600. return new RegExp(opts.regex).test(buffer.join(""));
  2601. },
  2602. definitions: {
  2603. r: {
  2604. validator: function(chrs, maskset, pos, strict, opts) {
  2605. function RegexToken(isGroup, isQuantifier) {
  2606. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2607. this.quantifier = {
  2608. min: 1,
  2609. max: 1
  2610. }, this.repeaterPart = void 0;
  2611. }
  2612. function analyseRegex() {
  2613. var match, m, currentToken = new RegexToken(), opengroups = [];
  2614. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
  2615. m.charAt(0)) {
  2616. case "(":
  2617. opengroups.push(new RegexToken((!0)));
  2618. break;
  2619. case ")":
  2620. groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2621. break;
  2622. case "{":
  2623. case "+":
  2624. case "*":
  2625. var quantifierToken = new RegexToken((!1), (!0));
  2626. m = m.replace(/[{}]/g, "");
  2627. 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]);
  2628. if (quantifierToken.quantifier = {
  2629. min: mq0,
  2630. max: mq1
  2631. }, opengroups.length > 0) {
  2632. var matches = opengroups[opengroups.length - 1].matches;
  2633. match = matches.pop(), match.isGroup || (groupToken = new RegexToken((!0)), groupToken.matches.push(match),
  2634. match = groupToken), matches.push(match), matches.push(quantifierToken);
  2635. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken((!0)),
  2636. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  2637. currentToken.matches.push(quantifierToken);
  2638. break;
  2639. default:
  2640. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2641. }
  2642. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2643. }
  2644. function validateRegexToken(token, fromGroup) {
  2645. var isvalid = !1;
  2646. fromGroup && (regexPart += "(", openGroupCount++);
  2647. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2648. var matchToken = token.matches[mndx];
  2649. if (matchToken.isGroup === !0) isvalid = validateRegexToken(matchToken, !0); else if (matchToken.isQuantifier === !0) {
  2650. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2651. if (isNaN(matchToken.quantifier.max)) {
  2652. for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
  2653. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2654. regexPart = regexPartBak + matchToken.quantifier.max;
  2655. } else {
  2656. for (var i = 0, qm = matchToken.quantifier.max - 1; i < qm && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
  2657. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2658. }
  2659. } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
  2660. var testExp;
  2661. if ("[" == matchToken.charAt(0)) {
  2662. testExp = regexPart, testExp += matchToken;
  2663. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2664. var exp = new RegExp("^(" + testExp + ")$");
  2665. isvalid = exp.test(bufferStr);
  2666. } else for (var l = 0, tl = matchToken.length; l < tl; l++) if ("\\" !== matchToken.charAt(l)) {
  2667. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2668. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2669. var exp = new RegExp("^(" + testExp + ")$");
  2670. if (isvalid = exp.test(bufferStr)) break;
  2671. }
  2672. regexPart += matchToken;
  2673. }
  2674. if (isvalid) break;
  2675. }
  2676. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2677. }
  2678. var bufferStr, groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2679. null === opts.regexTokens && analyseRegex(), cbuffer.splice(pos, 0, chrs), bufferStr = cbuffer.join("");
  2680. for (var i = 0; i < opts.regexTokens.length; i++) {
  2681. var regexToken = opts.regexTokens[i];
  2682. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
  2683. }
  2684. return isValid;
  2685. },
  2686. cardinality: 1
  2687. }
  2688. }
  2689. }
  2690. }), Inputmask;
  2691. }(jQuery, Inputmask);