jquery.inputmask.bundle.js 170 KB

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