jquery.inputmask.bundle.js 174 KB

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