jquery.inputmask.bundle.js 173 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665
  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-152
  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 (strict = !0, 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, stickyCaret) {
  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) && (result = opts.onBeforeWrite(keypress, getBuffer(), result.forwardPosition, opts),
  562. result && result.refreshFromBuffer)) {
  563. var refresh = result.refreshFromBuffer;
  564. refreshFromBuffer(refresh === !0 ? refresh : refresh.start, refresh.end, result.buffer),
  565. resetMaskSet(!0), result.caret && (getMaskSet().p = result.caret);
  566. }
  567. }
  568. }), writeOut) {
  569. var caretPos = undefined, lvp = getLastValidPosition();
  570. document.activeElement === input && (initiatingEvent || result) && (caretPos = caret(input).begin,
  571. initiatingEvent && result === !1 && (caretPos = seekNext(getLastValidPosition(caretPos))),
  572. result && stickyCaret !== !0 && (caretPos < lvp + 1 || lvp === -1) && (caretPos = opts.numericInput && result.caret === undefined ? seekPrevious(result.forwardPosition) : result.forwardPosition)),
  573. writeBuffer(input, getBuffer(), caretPos, initiatingEvent || new $.Event("checkval"));
  574. }
  575. }
  576. function unmaskedvalue(input) {
  577. if (input) {
  578. if (input.inputmask === undefined) return input.value;
  579. input.inputmask && input.inputmask.refreshValue && EventHandlers.setValueEvent.call(input);
  580. }
  581. var umValue = [], vps = getMaskSet().validPositions;
  582. for (var pndx in vps) vps[pndx].match && null != vps[pndx].match.fn && umValue.push(vps[pndx].input);
  583. var unmaskedValue = 0 === umValue.length ? "" : (isRTL ? umValue.reverse() : umValue).join("");
  584. if ($.isFunction(opts.onUnMask)) {
  585. var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
  586. unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts);
  587. }
  588. return unmaskedValue;
  589. }
  590. function caret(input, begin, end, notranslate) {
  591. function translatePosition(pos) {
  592. if (notranslate !== !0 && isRTL && "number" == typeof pos && (!opts.greedy || "" !== opts.placeholder)) {
  593. var bffrLght = getBuffer().join("").length;
  594. pos = bffrLght - pos;
  595. }
  596. return pos;
  597. }
  598. var range;
  599. if ("number" != typeof begin) return input.setSelectionRange ? (begin = input.selectionStart,
  600. end = input.selectionEnd) : window.getSelection ? (range = window.getSelection().getRangeAt(0),
  601. range.commonAncestorContainer.parentNode !== input && range.commonAncestorContainer !== input || (begin = range.startOffset,
  602. end = range.endOffset)) : document.selection && document.selection.createRange && (range = document.selection.createRange(),
  603. begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length),
  604. end = begin + range.text.length), {
  605. begin: translatePosition(begin),
  606. end: translatePosition(end)
  607. };
  608. begin = translatePosition(begin), end = translatePosition(end), end = "number" == typeof end ? end : begin;
  609. var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
  610. if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, mobile || opts.insertMode !== !1 || begin !== end || end++,
  611. input.setSelectionRange) input.selectionStart = begin, input.selectionEnd = end; else if (window.getSelection) {
  612. if (range = document.createRange(), input.firstChild === undefined || null === input.firstChild) {
  613. var textNode = document.createTextNode("");
  614. input.appendChild(textNode);
  615. }
  616. range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length),
  617. range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length),
  618. range.collapse(!0);
  619. var sel = window.getSelection();
  620. sel.removeAllRanges(), sel.addRange(range);
  621. } else input.createTextRange && (range = input.createTextRange(), range.collapse(!0),
  622. range.moveEnd("character", end), range.moveStart("character", begin), range.select());
  623. renderColorMask(input, undefined, {
  624. begin: begin,
  625. end: end
  626. });
  627. }
  628. function determineLastRequiredPosition(returnDefinition) {
  629. var pos, testPos, buffer = getBuffer(), bl = buffer.length, lvp = getLastValidPosition(), positions = {}, lvTest = getMaskSet().validPositions[lvp], ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined;
  630. for (pos = lvp + 1; pos < buffer.length; pos++) testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  631. ndxIntlzr = testPos.locator.slice(), positions[pos] = $.extend(!0, {}, testPos);
  632. var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
  633. 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--;
  634. return returnDefinition ? {
  635. l: bl,
  636. def: positions[bl] ? positions[bl].match : undefined
  637. } : bl;
  638. }
  639. function clearOptionalTail(buffer) {
  640. 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++;
  641. for (;(validPos = getTest(rl - 1)) && validPos.match.optionality && validPos.input === opts.skipOptionalPartCharacter; ) rl--;
  642. return buffer.splice(rl), buffer;
  643. }
  644. function isComplete(buffer) {
  645. if ($.isFunction(opts.isComplete)) return opts.isComplete(buffer, opts);
  646. if ("*" === opts.repeat) return undefined;
  647. var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
  648. if (lrp.def === undefined || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
  649. complete = !0;
  650. for (var i = 0; i <= aml; i++) {
  651. var test = getTestTemplate(i).match;
  652. if (null !== test.fn && getMaskSet().validPositions[i] === undefined && test.optionality !== !0 && test.optionalQuantifier !== !0 || null === test.fn && buffer[i] !== getPlaceholder(i, test)) {
  653. complete = !1;
  654. break;
  655. }
  656. }
  657. }
  658. return complete;
  659. }
  660. function handleRemove(input, k, pos, strict) {
  661. function generalize() {
  662. if (opts.keepStatic) {
  663. for (var validInputs = [], lastAlt = getLastValidPosition(-1, !0), positionsClone = $.extend(!0, {}, getMaskSet().validPositions), prevAltPos = getMaskSet().validPositions[lastAlt]; lastAlt >= 0; lastAlt--) {
  664. var altPos = getMaskSet().validPositions[lastAlt];
  665. if (altPos) {
  666. if (altPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(altPos.input) && validInputs.push(altPos.input),
  667. delete getMaskSet().validPositions[lastAlt], altPos.alternation !== undefined && altPos.locator[altPos.alternation] !== prevAltPos.locator[altPos.alternation]) break;
  668. prevAltPos = altPos;
  669. }
  670. }
  671. if (lastAlt > -1) for (getMaskSet().p = seekNext(getLastValidPosition(-1, !0)); validInputs.length > 0; ) {
  672. var keypress = new $.Event("keypress");
  673. keypress.which = validInputs.pop().charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !1, !1, getMaskSet().p);
  674. } else getMaskSet().validPositions = $.extend(!0, {}, positionsClone);
  675. }
  676. }
  677. if ((opts.numericInput || isRTL) && (k === Inputmask.keyCode.BACKSPACE ? k = Inputmask.keyCode.DELETE : k === Inputmask.keyCode.DELETE && (k = Inputmask.keyCode.BACKSPACE),
  678. isRTL)) {
  679. var pend = pos.end;
  680. pos.end = pos.begin, pos.begin = pend;
  681. }
  682. k === Inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || opts.insertMode === !1) ? (pos.begin = seekPrevious(pos.begin),
  683. 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,
  684. getMaskSet().validPositions[pos.begin] === undefined || getMaskSet().validPositions[pos.begin].input !== opts.groupSeparator && getMaskSet().validPositions[pos.begin].input !== opts.radixPoint || pos.end++),
  685. stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0 && generalize();
  686. var lvp = getLastValidPosition(pos.begin, !0);
  687. lvp < pos.begin ? getMaskSet().p = seekNext(lvp) : strict !== !0 && (getMaskSet().p = pos.begin);
  688. }
  689. function initializeColorMask(input) {
  690. function findCaretPos(clientx) {
  691. var caretPos, e = document.createElement("span");
  692. for (var style in computedStyle) isNaN(style) && style.indexOf("font") !== -1 && (e.style[style] = computedStyle[style]);
  693. e.style.textTransform = computedStyle.textTransform, e.style.letterSpacing = computedStyle.letterSpacing,
  694. e.style.position = "absolute", e.style.height = "auto", e.style.width = "auto",
  695. e.style.visibility = "hidden", e.style.whiteSpace = "nowrap", document.body.appendChild(e);
  696. var itl, inputText = input.inputmask._valueGet(), previousWidth = 0;
  697. for (caretPos = 0, itl = inputText.length; caretPos <= itl; caretPos++) {
  698. if (e.innerHTML += inputText.charAt(caretPos) || "_", e.offsetWidth >= clientx) {
  699. var offset1 = clientx - previousWidth, offset2 = e.offsetWidth - clientx;
  700. e.innerHTML = inputText.charAt(caretPos), offset1 -= e.offsetWidth / 3, caretPos = offset1 < offset2 ? caretPos - 1 : caretPos;
  701. break;
  702. }
  703. previousWidth = e.offsetWidth;
  704. }
  705. return document.body.removeChild(e), caretPos;
  706. }
  707. function position() {
  708. colorMask.style.position = "absolute", colorMask.style.top = offset.top + "px",
  709. 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",
  710. colorMask.style.height = parseInt(input.offsetHeight) - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom) - parseInt(computedStyle.borderTopWidth) - parseInt(computedStyle.borderBottomWidth) + "px",
  711. colorMask.style.lineHeight = colorMask.style.height, colorMask.style.zIndex = isNaN(computedStyle.zIndex) ? -1 : computedStyle.zIndex - 1,
  712. colorMask.style.webkitAppearance = "textfield", colorMask.style.mozAppearance = "textfield",
  713. colorMask.style.Appearance = "textfield";
  714. }
  715. var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
  716. input.parentNode;
  717. colorMask = document.createElement("div"), document.body.appendChild(colorMask);
  718. for (var style in computedStyle) isNaN(style) && "cssText" !== style && style.indexOf("webkit") == -1 && (colorMask.style[style] = computedStyle[style]);
  719. input.style.backgroundColor = "transparent", input.style.color = "transparent",
  720. input.style.webkitAppearance = "caret", input.style.mozAppearance = "caret", input.style.Appearance = "caret",
  721. position(), $(window).on("resize", function(e) {
  722. offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null),
  723. position();
  724. }), $(input).on("click", function(e) {
  725. return caret(input, findCaretPos(e.clientX)), EventHandlers.clickEvent.call(this, [ e ]);
  726. }), $(input).on("keydown", function(e) {
  727. e.shiftKey || opts.insertMode === !1 || setTimeout(function() {
  728. renderColorMask(input);
  729. }, 0);
  730. });
  731. }
  732. function renderColorMask(input, buffer, caretPos) {
  733. function handleStatic() {
  734. isStatic || null !== test.fn && testPos.input !== undefined ? isStatic && null !== test.fn && testPos.input !== undefined && (isStatic = !1,
  735. maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static''>");
  736. }
  737. if (colorMask !== undefined) {
  738. buffer = buffer || getBuffer(), caretPos === undefined ? caretPos = caret(input) : caretPos.begin === undefined && (caretPos = {
  739. begin: caretPos,
  740. end: caretPos
  741. });
  742. var maskTemplate = "", isStatic = !1;
  743. if ("" != buffer) {
  744. var ndxIntlzr, test, testPos, pos = 0, lvp = getLastValidPosition();
  745. do pos === caretPos.begin && document.activeElement === input && (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>"),
  746. getMaskSet().validPositions[pos] ? (testPos = getMaskSet().validPositions[pos],
  747. test = testPos.match, ndxIntlzr = testPos.locator.slice(), handleStatic(), maskTemplate += testPos.input) : (testPos = getTestTemplate(pos, ndxIntlzr, pos - 1),
  748. test = testPos.match, ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || pos < lvp || "number" == typeof opts.jitMasking && isFinite(opts.jitMasking) && opts.jitMasking > pos) && (handleStatic(),
  749. maskTemplate += getPlaceholder(pos, test))), pos++; while ((maxLength === undefined || pos < maxLength) && (null !== test.fn || "" !== test.def) || lvp > pos);
  750. }
  751. colorMask.innerHTML = maskTemplate;
  752. }
  753. }
  754. function mask(elem) {
  755. function isElementTypeSupported(input, opts) {
  756. function patchValueProperty(npt) {
  757. function patchValhook(type) {
  758. if ($.valHooks && ($.valHooks[type] === undefined || $.valHooks[type].inputmaskpatch !== !0)) {
  759. var valhookGet = $.valHooks[type] && $.valHooks[type].get ? $.valHooks[type].get : function(elem) {
  760. return elem.value;
  761. }, valhookSet = $.valHooks[type] && $.valHooks[type].set ? $.valHooks[type].set : function(elem, value) {
  762. return elem.value = value, elem;
  763. };
  764. $.valHooks[type] = {
  765. get: function(elem) {
  766. if (elem.inputmask) {
  767. if (elem.inputmask.opts.autoUnmask) return elem.inputmask.unmaskedvalue();
  768. var result = valhookGet(elem);
  769. return getLastValidPosition(undefined, undefined, elem.inputmask.maskset.validPositions) !== -1 || opts.nullable !== !0 ? result : "";
  770. }
  771. return valhookGet(elem);
  772. },
  773. set: function(elem, value) {
  774. var result, $elem = $(elem);
  775. return result = valhookSet(elem, value), elem.inputmask && $elem.trigger("setvalue"),
  776. result;
  777. },
  778. inputmaskpatch: !0
  779. };
  780. }
  781. }
  782. function getter() {
  783. 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);
  784. }
  785. function setter(value) {
  786. valueSet.call(this, value), this.inputmask && $(this).trigger("setvalue");
  787. }
  788. function installNativeValueSetFallback(npt) {
  789. EventRuler.on(npt, "mouseenter", function(event) {
  790. var $input = $(this), input = this, value = input.inputmask._valueGet();
  791. value !== getBuffer().join("") && $input.trigger("setvalue");
  792. });
  793. }
  794. var valueGet, valueSet;
  795. if (!npt.inputmask.__valueGet) {
  796. if (opts.noValuePatching !== !0) {
  797. if (Object.getOwnPropertyDescriptor) {
  798. "function" != typeof Object.getPrototypeOf && (Object.getPrototypeOf = "object" == typeof "test".__proto__ ? function(object) {
  799. return object.__proto__;
  800. } : function(object) {
  801. return object.constructor.prototype;
  802. });
  803. var valueProperty = Object.getPrototypeOf ? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(npt), "value") : undefined;
  804. valueProperty && valueProperty.get && valueProperty.set ? (valueGet = valueProperty.get,
  805. valueSet = valueProperty.set, Object.defineProperty(npt, "value", {
  806. get: getter,
  807. set: setter,
  808. configurable: !0
  809. })) : "INPUT" !== npt.tagName && (valueGet = function() {
  810. return this.textContent;
  811. }, valueSet = function(value) {
  812. this.textContent = value;
  813. }, Object.defineProperty(npt, "value", {
  814. get: getter,
  815. set: setter,
  816. configurable: !0
  817. }));
  818. } else document.__lookupGetter__ && npt.__lookupGetter__("value") && (valueGet = npt.__lookupGetter__("value"),
  819. valueSet = npt.__lookupSetter__("value"), npt.__defineGetter__("value", getter),
  820. npt.__defineSetter__("value", setter));
  821. npt.inputmask.__valueGet = valueGet, npt.inputmask.__valueSet = valueSet;
  822. }
  823. npt.inputmask._valueGet = function(overruleRTL) {
  824. return isRTL && overruleRTL !== !0 ? valueGet.call(this.el).split("").reverse().join("") : valueGet.call(this.el);
  825. }, npt.inputmask._valueSet = function(value, overruleRTL) {
  826. valueSet.call(this.el, null === value || value === undefined ? "" : overruleRTL !== !0 && isRTL ? value.split("").reverse().join("") : value);
  827. }, valueGet === undefined && (valueGet = function() {
  828. return this.value;
  829. }, valueSet = function(value) {
  830. this.value = value;
  831. }, patchValhook(npt.type), installNativeValueSetFallback(npt));
  832. }
  833. }
  834. var elementType = input.getAttribute("type"), isSupported = "INPUT" === input.tagName && $.inArray(elementType, opts.supportsInputType) !== -1 || input.isContentEditable || "TEXTAREA" === input.tagName;
  835. if (!isSupported) if ("INPUT" === input.tagName) {
  836. var el = document.createElement("input");
  837. el.setAttribute("type", elementType), isSupported = "text" === el.type, el = null;
  838. } else isSupported = "partial";
  839. return isSupported !== !1 && patchValueProperty(input), isSupported;
  840. }
  841. EventRuler.off(elem);
  842. var isSupported = isElementTypeSupported(elem, opts);
  843. if (isSupported !== !1 && (el = elem, $el = $(el), ("rtl" === el.dir || opts.rightAlign) && (el.style.textAlign = "right"),
  844. ("rtl" === el.dir || opts.numericInput) && (el.dir = "ltr", el.removeAttribute("dir"),
  845. el.inputmask.isRTL = !0, isRTL = !0), opts.colorMask === !0 && initializeColorMask(el),
  846. android && (el.hasOwnProperty("inputmode") && (el.inputmode = opts.inputmode, el.setAttribute("inputmode", opts.inputmode)),
  847. "rtfm" === opts.androidHack && (opts.colorMask !== !0 && initializeColorMask(el),
  848. el.type = "password")), isSupported === !0 && (EventRuler.on(el, "submit", EventHandlers.submitEvent),
  849. EventRuler.on(el, "reset", EventHandlers.resetEvent), EventRuler.on(el, "mouseenter", EventHandlers.mouseenterEvent),
  850. EventRuler.on(el, "blur", EventHandlers.blurEvent), EventRuler.on(el, "focus", EventHandlers.focusEvent),
  851. EventRuler.on(el, "mouseleave", EventHandlers.mouseleaveEvent), opts.colorMask !== !0 && EventRuler.on(el, "click", EventHandlers.clickEvent),
  852. EventRuler.on(el, "dblclick", EventHandlers.dblclickEvent), EventRuler.on(el, "paste", EventHandlers.pasteEvent),
  853. EventRuler.on(el, "dragdrop", EventHandlers.pasteEvent), EventRuler.on(el, "drop", EventHandlers.pasteEvent),
  854. EventRuler.on(el, "cut", EventHandlers.cutEvent), EventRuler.on(el, "complete", opts.oncomplete),
  855. EventRuler.on(el, "incomplete", opts.onincomplete), EventRuler.on(el, "cleared", opts.oncleared),
  856. android && opts.inputEventOnly === !0 || (EventRuler.on(el, "keydown", EventHandlers.keydownEvent),
  857. EventRuler.on(el, "keypress", EventHandlers.keypressEvent)), EventRuler.on(el, "compositionstart", $.noop),
  858. EventRuler.on(el, "compositionupdate", $.noop), EventRuler.on(el, "compositionend", $.noop),
  859. EventRuler.on(el, "keyup", $.noop), EventRuler.on(el, "input", EventHandlers.inputFallBackEvent),
  860. EventRuler.on(el, "beforeinput", $.noop)), EventRuler.on(el, "setvalue", EventHandlers.setValueEvent),
  861. getBufferTemplate(), "" !== el.inputmask._valueGet() || opts.clearMaskOnLostFocus === !1 || document.activeElement === el)) {
  862. var initialValue = $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(el.inputmask._valueGet(), opts) || el.inputmask._valueGet() : el.inputmask._valueGet();
  863. "" !== initialValue && checkVal(el, !0, !1, initialValue.split(""));
  864. var buffer = getBuffer().slice();
  865. undoValue = buffer.join(""), isComplete(buffer) === !1 && opts.clearIncomplete && resetMaskSet(),
  866. opts.clearMaskOnLostFocus && document.activeElement !== el && (getLastValidPosition() === -1 ? buffer = [] : clearOptionalTail(buffer)),
  867. writeBuffer(el, buffer), document.activeElement === el && caret(el, seekNext(getLastValidPosition()));
  868. }
  869. }
  870. maskset = maskset || this.maskset, opts = opts || this.opts;
  871. var undoValue, $el, maxLength, colorMask, valueBuffer, el = this.el, isRTL = this.isRTL, skipKeyPressEvent = !1, skipInputEvent = !1, ignorable = !1, mouseEnter = !1, EventRuler = {
  872. on: function(input, eventName, eventHandler) {
  873. var ev = function(e) {
  874. if (this.inputmask === undefined && "FORM" !== this.nodeName) {
  875. var imOpts = $.data(this, "_inputmask_opts");
  876. imOpts ? new Inputmask(imOpts).mask(this) : EventRuler.off(this);
  877. } else {
  878. 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))) {
  879. switch (e.type) {
  880. case "input":
  881. if (skipInputEvent === !0) return skipInputEvent = !1, e.preventDefault();
  882. break;
  883. case "keydown":
  884. skipKeyPressEvent = !1, skipInputEvent = !1;
  885. break;
  886. case "keypress":
  887. if (skipKeyPressEvent === !0) return e.preventDefault();
  888. skipKeyPressEvent = !0;
  889. break;
  890. case "click":
  891. if (iemobile || iphone) {
  892. var that = this, args = arguments;
  893. return setTimeout(function() {
  894. eventHandler.apply(that, args);
  895. }, 0), !1;
  896. }
  897. }
  898. var returnVal = eventHandler.apply(this, arguments);
  899. return returnVal === !1 && (e.preventDefault(), e.stopPropagation()), returnVal;
  900. }
  901. e.preventDefault();
  902. }
  903. };
  904. input.inputmask.events[eventName] = input.inputmask.events[eventName] || [], input.inputmask.events[eventName].push(ev),
  905. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).on(eventName, ev) : $(input).on(eventName, ev);
  906. },
  907. off: function(input, event) {
  908. if (input.inputmask && input.inputmask.events) {
  909. var events;
  910. event ? (events = [], events[event] = input.inputmask.events[event]) : events = input.inputmask.events,
  911. $.each(events, function(eventName, evArr) {
  912. for (;evArr.length > 0; ) {
  913. var ev = evArr.pop();
  914. $.inArray(eventName, [ "submit", "reset" ]) !== -1 ? null != input.form && $(input.form).off(eventName, ev) : $(input).off(eventName, ev);
  915. }
  916. delete input.inputmask.events[eventName];
  917. });
  918. }
  919. }
  920. }, EventHandlers = {
  921. keydownEvent: function(e) {
  922. function isInputEventSupported(eventName) {
  923. var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
  924. return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]),
  925. el = null, isSupported;
  926. }
  927. var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
  928. 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(),
  929. handleRemove(input, k, pos), writeBuffer(input, getBuffer(!0), getMaskSet().p, e, input.inputmask._valueGet() !== getBuffer().join("")),
  930. 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) {
  931. e.preventDefault();
  932. var caretPos = seekNext(getLastValidPosition());
  933. opts.insertMode || caretPos !== getMaskSet().maskLength || e.shiftKey || caretPos--,
  934. caret(input, e.shiftKey ? pos.begin : caretPos, caretPos, !0);
  935. } else k === Inputmask.keyCode.HOME && !e.shiftKey || k === Inputmask.keyCode.PAGE_UP ? (e.preventDefault(),
  936. 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("")),
  937. $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)),
  938. pos.end = seekPrevious(pos.begin, !0), pos.begin = seekPrevious(pos.end, !0)) : (pos.begin = seekNext(pos.begin, !0),
  939. pos.end = seekNext(pos.begin, !0), pos.end < getMaskSet().maskLength && pos.end--),
  940. pos.begin < getMaskSet().maskLength && (e.preventDefault(), caret(input, pos.begin, pos.end))) : e.shiftKey || opts.insertMode === !1 && (k === Inputmask.keyCode.RIGHT ? setTimeout(function() {
  941. var caretPos = caret(input);
  942. caret(input, caretPos.begin);
  943. }, 0) : k === Inputmask.keyCode.LEFT && setTimeout(function() {
  944. var caretPos = caret(input);
  945. caret(input, isRTL ? caretPos.begin + 1 : caretPos.begin - 1);
  946. }, 0)) : (opts.insertMode = !opts.insertMode, caret(input, opts.insertMode || pos.begin !== getMaskSet().maskLength ? pos.begin : pos.begin - 1));
  947. opts.onKeyDown.call(this, e, getBuffer(), caret(input).begin, opts), ignorable = $.inArray(k, opts.ignorables) !== -1;
  948. },
  949. keypressEvent: function(e, checkval, writeOut, strict, ndx) {
  950. var input = this, $input = $(input), k = e.which || e.charCode || e.keyCode;
  951. if (!(checkval === !0 || e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) return k === Inputmask.keyCode.ENTER && undoValue !== getBuffer().join("") && (undoValue = getBuffer().join(""),
  952. setTimeout(function() {
  953. $input.trigger("change");
  954. }, 0)), !0;
  955. if (k) {
  956. 46 === k && e.shiftKey === !1 && "" !== opts.radixPoint && (k = opts.radixPoint.charCodeAt(0));
  957. var forwardPosition, pos = checkval ? {
  958. begin: ndx,
  959. end: ndx
  960. } : caret(input), c = String.fromCharCode(k);
  961. getMaskSet().writeOutBuffer = !0;
  962. var valResult = isValid(pos, c, strict);
  963. if (valResult !== !1 && (resetMaskSet(!0), forwardPosition = valResult.caret !== undefined ? valResult.caret : checkval ? valResult.pos + 1 : seekNext(valResult.pos),
  964. getMaskSet().p = forwardPosition), writeOut !== !1) {
  965. var self = this;
  966. if (setTimeout(function() {
  967. opts.onKeyValidation.call(self, k, valResult, opts);
  968. }, 0), getMaskSet().writeOutBuffer && valResult !== !1) {
  969. var buffer = getBuffer();
  970. writeBuffer(input, buffer, opts.numericInput && valResult.caret === undefined ? seekPrevious(forwardPosition) : forwardPosition, e, checkval !== !0),
  971. checkval !== !0 && setTimeout(function() {
  972. isComplete(buffer) === !0 && $input.trigger("complete");
  973. }, 0);
  974. }
  975. }
  976. if (e.preventDefault(), checkval) return valResult.forwardPosition = forwardPosition,
  977. valResult;
  978. }
  979. },
  980. pasteEvent: function(e) {
  981. var tempValue, input = this, ev = e.originalEvent || e, $input = $(input), inputValue = input.inputmask._valueGet(!0), caretPos = caret(input);
  982. isRTL && (tempValue = caretPos.end, caretPos.end = caretPos.begin, caretPos.begin = tempValue);
  983. var valueBeforeCaret = inputValue.substr(0, caretPos.begin), valueAfterCaret = inputValue.substr(caretPos.end, inputValue.length);
  984. if (valueBeforeCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(0, caretPos.begin).join("") && (valueBeforeCaret = ""),
  985. valueAfterCaret === (isRTL ? getBufferTemplate().reverse() : getBufferTemplate()).slice(caretPos.end).join("") && (valueAfterCaret = ""),
  986. isRTL && (tempValue = valueBeforeCaret, valueBeforeCaret = valueAfterCaret, valueAfterCaret = tempValue),
  987. window.clipboardData && window.clipboardData.getData) inputValue = valueBeforeCaret + window.clipboardData.getData("Text") + valueAfterCaret; else {
  988. if (!ev.clipboardData || !ev.clipboardData.getData) return !0;
  989. inputValue = valueBeforeCaret + ev.clipboardData.getData("text/plain") + valueAfterCaret;
  990. }
  991. var pasteValue = inputValue;
  992. if ($.isFunction(opts.onBeforePaste)) {
  993. if (pasteValue = opts.onBeforePaste(inputValue, opts), pasteValue === !1) return e.preventDefault();
  994. pasteValue || (pasteValue = inputValue);
  995. }
  996. return checkVal(input, !1, !1, isRTL ? pasteValue.split("").reverse() : pasteValue.toString().split("")),
  997. writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, undoValue !== getBuffer().join("")),
  998. isComplete(getBuffer()) === !0 && $input.trigger("complete"), e.preventDefault();
  999. },
  1000. inputFallBackEvent: function(e) {
  1001. var input = this, inputValue = input.inputmask._valueGet();
  1002. if (getBuffer().join("") !== inputValue) {
  1003. var caretPos = caret(input);
  1004. if (inputValue = inputValue.replace(new RegExp("(" + Inputmask.escapeRegex(getBufferTemplate().join("")) + ")*"), ""),
  1005. iemobile) {
  1006. var inputChar = inputValue.replace(getBuffer().join(""), "");
  1007. if (1 === inputChar.length) {
  1008. var keypress = new $.Event("keypress");
  1009. return keypress.which = inputChar.charCodeAt(0), EventHandlers.keypressEvent.call(input, keypress, !0, !0, !1, getMaskSet().validPositions[caretPos.begin - 1] ? caretPos.begin : caretPos.begin - 1),
  1010. !1;
  1011. }
  1012. }
  1013. if (caretPos.begin > inputValue.length && (caret(input, inputValue.length), caretPos = caret(input)),
  1014. getBuffer().length - inputValue.length !== 1 || inputValue.charAt(caretPos.begin) === getBuffer()[caretPos.begin] || inputValue.charAt(caretPos.begin + 1) === getBuffer()[caretPos.begin] || isMask(caretPos.begin)) {
  1015. for (var lvp = getLastValidPosition() + 1, bufferTemplate = getBufferTemplate().join(""); null === inputValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  1016. inputValue = inputValue.replace(bufferTemplate, ""), inputValue = inputValue.split(""),
  1017. checkVal(input, !0, !1, inputValue, e, caretPos.begin < lvp), isComplete(getBuffer()) === !0 && $(input).trigger("complete");
  1018. } else e.keyCode = Inputmask.keyCode.BACKSPACE, EventHandlers.keydownEvent.call(input, e);
  1019. e.preventDefault();
  1020. }
  1021. },
  1022. setValueEvent: function(e) {
  1023. this.inputmask.refreshValue = !1;
  1024. var input = this, value = input.inputmask._valueGet(!0);
  1025. $.isFunction(opts.onBeforeMask) && (value = opts.onBeforeMask(value, opts) || value),
  1026. value = value.split(""), checkVal(input, !0, !1, isRTL ? value.reverse() : value),
  1027. undoValue = getBuffer().join(""), (opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate().join("") && input.inputmask._valueSet("");
  1028. },
  1029. focusEvent: function(e) {
  1030. var input = this, nptValue = input.inputmask._valueGet();
  1031. opts.showMaskOnFocus && (!opts.showMaskOnHover || opts.showMaskOnHover && "" === nptValue) && (input.inputmask._valueGet() !== getBuffer().join("") ? writeBuffer(input, getBuffer(), seekNext(getLastValidPosition())) : mouseEnter === !1 && caret(input, seekNext(getLastValidPosition()))),
  1032. opts.positionCaretOnTab === !0 && mouseEnter === !1 && EventHandlers.clickEvent.apply(input, [ e, !0 ]),
  1033. undoValue = getBuffer().join("");
  1034. },
  1035. mouseleaveEvent: function(e) {
  1036. var input = this;
  1037. if (mouseEnter = !1, opts.clearMaskOnLostFocus && document.activeElement !== input) {
  1038. var buffer = getBuffer().slice(), nptValue = input.inputmask._valueGet();
  1039. nptValue !== input.getAttribute("placeholder") && "" !== nptValue && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer),
  1040. writeBuffer(input, buffer));
  1041. }
  1042. },
  1043. clickEvent: function(e, tabbed) {
  1044. function doRadixFocus(clickPos) {
  1045. if ("" !== opts.radixPoint) {
  1046. var vps = getMaskSet().validPositions;
  1047. if (vps[clickPos] === undefined || vps[clickPos].input === getPlaceholder(clickPos)) {
  1048. if (clickPos < seekNext(-1)) return !0;
  1049. var radixPos = $.inArray(opts.radixPoint, getBuffer());
  1050. if (radixPos !== -1) {
  1051. for (var vp in vps) if (radixPos < vp && vps[vp].input !== getPlaceholder(vp)) return !1;
  1052. return !0;
  1053. }
  1054. }
  1055. }
  1056. return !1;
  1057. }
  1058. var input = this;
  1059. setTimeout(function() {
  1060. if (document.activeElement === input) {
  1061. var selectedCaret = caret(input);
  1062. if (tabbed && (isRTL ? selectedCaret.end = selectedCaret.begin : selectedCaret.begin = selectedCaret.end),
  1063. selectedCaret.begin === selectedCaret.end) switch (opts.positionCaretOnClick) {
  1064. case "none":
  1065. break;
  1066. case "radixFocus":
  1067. if (doRadixFocus(selectedCaret.begin)) {
  1068. var radixPos = $.inArray(opts.radixPoint, getBuffer().join(""));
  1069. caret(input, opts.numericInput ? seekNext(radixPos) : radixPos);
  1070. break;
  1071. }
  1072. default:
  1073. var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition, !0), lastPosition = seekNext(lvclickPosition);
  1074. if (clickPosition < lastPosition) caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)); else {
  1075. var placeholder = getPlaceholder(lastPosition);
  1076. ("" !== placeholder && getBuffer()[lastPosition] !== placeholder && getTest(lastPosition).match.optionalQuantifier !== !0 || !isMask(lastPosition) && getTest(lastPosition).match.def === placeholder) && (lastPosition = seekNext(lastPosition)),
  1077. caret(input, lastPosition);
  1078. }
  1079. }
  1080. }
  1081. }, 0);
  1082. },
  1083. dblclickEvent: function(e) {
  1084. var input = this;
  1085. setTimeout(function() {
  1086. caret(input, 0, seekNext(getLastValidPosition()));
  1087. }, 0);
  1088. },
  1089. cutEvent: function(e) {
  1090. 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);
  1091. clipboardData.setData("text", isRTL ? clipData.reverse().join("") : clipData.join("")),
  1092. document.execCommand && document.execCommand("copy"), handleRemove(input, Inputmask.keyCode.DELETE, pos),
  1093. writeBuffer(input, getBuffer(), getMaskSet().p, e, undoValue !== getBuffer().join("")),
  1094. input.inputmask._valueGet() === getBufferTemplate().join("") && $input.trigger("cleared");
  1095. },
  1096. blurEvent: function(e) {
  1097. var $input = $(this), input = this;
  1098. if (input.inputmask) {
  1099. var nptValue = input.inputmask._valueGet(), buffer = getBuffer().slice();
  1100. undoValue !== buffer.join("") && setTimeout(function() {
  1101. $input.trigger("change"), undoValue = buffer.join("");
  1102. }, 0), "" !== nptValue && (opts.clearMaskOnLostFocus && (getLastValidPosition() === -1 && nptValue === getBufferTemplate().join("") ? buffer = [] : clearOptionalTail(buffer)),
  1103. isComplete(buffer) === !1 && (setTimeout(function() {
  1104. $input.trigger("incomplete");
  1105. }, 0), opts.clearIncomplete && (resetMaskSet(), buffer = opts.clearMaskOnLostFocus ? [] : getBufferTemplate().slice())),
  1106. writeBuffer(input, buffer, undefined, e));
  1107. }
  1108. },
  1109. mouseenterEvent: function(e) {
  1110. var input = this;
  1111. mouseEnter = !0, document.activeElement !== input && opts.showMaskOnHover && input.inputmask._valueGet() !== getBuffer().join("") && writeBuffer(input, getBuffer());
  1112. },
  1113. submitEvent: function(e) {
  1114. undoValue !== getBuffer().join("") && $el.trigger("change"), opts.clearMaskOnLostFocus && getLastValidPosition() === -1 && el.inputmask._valueGet && el.inputmask._valueGet() === getBufferTemplate().join("") && el.inputmask._valueSet(""),
  1115. opts.removeMaskOnSubmit && (el.inputmask._valueSet(el.inputmask.unmaskedvalue(), !0),
  1116. setTimeout(function() {
  1117. writeBuffer(el, getBuffer());
  1118. }, 0));
  1119. },
  1120. resetEvent: function(e) {
  1121. el.inputmask.refreshValue = !0, setTimeout(function() {
  1122. $el.trigger("setvalue");
  1123. }, 0);
  1124. }
  1125. };
  1126. if (actionObj !== undefined) switch (actionObj.action) {
  1127. case "isComplete":
  1128. return el = actionObj.el, isComplete(getBuffer());
  1129. case "unmaskedvalue":
  1130. return el !== undefined && actionObj.value === undefined || (valueBuffer = actionObj.value,
  1131. valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(valueBuffer, opts) || valueBuffer : valueBuffer).split(""),
  1132. checkVal(undefined, !1, !1, isRTL ? valueBuffer.reverse() : valueBuffer), $.isFunction(opts.onBeforeWrite) && opts.onBeforeWrite(undefined, getBuffer(), 0, opts)),
  1133. unmaskedvalue(el);
  1134. case "mask":
  1135. mask(el);
  1136. break;
  1137. case "format":
  1138. return valueBuffer = ($.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(actionObj.value, opts) || actionObj.value : actionObj.value).split(""),
  1139. checkVal(undefined, !0, !1, isRTL ? valueBuffer.reverse() : valueBuffer), actionObj.metadata ? {
  1140. value: isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join(""),
  1141. metadata: maskScope.call(this, {
  1142. action: "getmetadata"
  1143. }, maskset, opts)
  1144. } : isRTL ? getBuffer().slice().reverse().join("") : getBuffer().join("");
  1145. case "isValid":
  1146. actionObj.value ? (valueBuffer = actionObj.value.split(""), checkVal(undefined, !0, !0, isRTL ? valueBuffer.reverse() : valueBuffer)) : actionObj.value = getBuffer().join("");
  1147. for (var buffer = getBuffer(), rl = determineLastRequiredPosition(), lmib = buffer.length - 1; lmib > rl && !isMask(lmib); lmib--) ;
  1148. return buffer.splice(rl, lmib + 1 - rl), isComplete(buffer) && actionObj.value === getBuffer().join("");
  1149. case "getemptymask":
  1150. return getBufferTemplate().join("");
  1151. case "remove":
  1152. if (el) {
  1153. $el = $(el), el.inputmask._valueSet(unmaskedvalue(el)), EventRuler.off(el);
  1154. var valueProperty;
  1155. Object.getOwnPropertyDescriptor && Object.getPrototypeOf ? (valueProperty = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), "value"),
  1156. valueProperty && el.inputmask.__valueGet && Object.defineProperty(el, "value", {
  1157. get: el.inputmask.__valueGet,
  1158. set: el.inputmask.__valueSet,
  1159. configurable: !0
  1160. })) : document.__lookupGetter__ && el.__lookupGetter__("value") && el.inputmask.__valueGet && (el.__defineGetter__("value", el.inputmask.__valueGet),
  1161. el.__defineSetter__("value", el.inputmask.__valueSet)), el.inputmask = undefined;
  1162. }
  1163. return el;
  1164. case "getmetadata":
  1165. if ($.isArray(maskset.metadata)) {
  1166. var maskTarget = getMaskTemplate(!0, 0, !1).join("");
  1167. return $.each(maskset.metadata, function(ndx, mtdt) {
  1168. if (mtdt.mask === maskTarget) return maskTarget = mtdt, !1;
  1169. }), maskTarget;
  1170. }
  1171. return maskset.metadata;
  1172. }
  1173. }
  1174. 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;
  1175. return Inputmask.prototype = {
  1176. dataAttribute: "data-inputmask",
  1177. defaults: {
  1178. placeholder: "_",
  1179. optionalmarker: {
  1180. start: "[",
  1181. end: "]"
  1182. },
  1183. quantifiermarker: {
  1184. start: "{",
  1185. end: "}"
  1186. },
  1187. groupmarker: {
  1188. start: "(",
  1189. end: ")"
  1190. },
  1191. alternatormarker: "|",
  1192. escapeChar: "\\",
  1193. mask: null,
  1194. oncomplete: $.noop,
  1195. onincomplete: $.noop,
  1196. oncleared: $.noop,
  1197. repeat: 0,
  1198. greedy: !0,
  1199. autoUnmask: !1,
  1200. removeMaskOnSubmit: !1,
  1201. clearMaskOnLostFocus: !0,
  1202. insertMode: !0,
  1203. clearIncomplete: !1,
  1204. alias: null,
  1205. onKeyDown: $.noop,
  1206. onBeforeMask: null,
  1207. onBeforePaste: function(pastedValue, opts) {
  1208. return $.isFunction(opts.onBeforeMask) ? opts.onBeforeMask(pastedValue, opts) : pastedValue;
  1209. },
  1210. onBeforeWrite: null,
  1211. onUnMask: null,
  1212. showMaskOnFocus: !0,
  1213. showMaskOnHover: !0,
  1214. onKeyValidation: $.noop,
  1215. skipOptionalPartCharacter: " ",
  1216. numericInput: !1,
  1217. rightAlign: !1,
  1218. undoOnEscape: !0,
  1219. radixPoint: "",
  1220. radixPointDefinitionSymbol: undefined,
  1221. groupSeparator: "",
  1222. keepStatic: null,
  1223. positionCaretOnTab: !0,
  1224. tabThrough: !1,
  1225. supportsInputType: [ "text", "tel", "password" ],
  1226. 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 ],
  1227. isComplete: null,
  1228. canClearPosition: $.noop,
  1229. preValidation: null,
  1230. postValidation: null,
  1231. staticDefinitionSymbol: undefined,
  1232. jitMasking: !1,
  1233. nullable: !0,
  1234. inputEventOnly: !1,
  1235. noValuePatching: !1,
  1236. positionCaretOnClick: "lvp",
  1237. casing: null,
  1238. inputmode: "verbatim",
  1239. colorMask: !1,
  1240. androidHack: !1
  1241. },
  1242. definitions: {
  1243. "9": {
  1244. validator: "[0-9]",
  1245. cardinality: 1,
  1246. definitionSymbol: "*"
  1247. },
  1248. a: {
  1249. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  1250. cardinality: 1,
  1251. definitionSymbol: "*"
  1252. },
  1253. "*": {
  1254. validator: function() {
  1255. return !0;
  1256. },
  1257. cardinality: 1
  1258. }
  1259. },
  1260. aliases: {},
  1261. masksCache: {},
  1262. mask: function(elems) {
  1263. function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
  1264. function importOption(option, optionData) {
  1265. optionData = optionData !== undefined ? optionData : npt.getAttribute(dataAttribute + "-" + option),
  1266. null !== optionData && ("string" == typeof optionData && (0 === option.indexOf("on") ? optionData = window[optionData] : "false" === optionData ? optionData = !1 : "true" === optionData && (optionData = !0)),
  1267. userOptions[option] = optionData);
  1268. }
  1269. var option, dataoptions, optionData, p, attrOptions = npt.getAttribute(dataAttribute);
  1270. if (attrOptions && "" !== attrOptions && (attrOptions = attrOptions.replace(new RegExp("'", "g"), '"'),
  1271. dataoptions = JSON.parse("{" + attrOptions + "}")), dataoptions) {
  1272. optionData = undefined;
  1273. for (p in dataoptions) if ("alias" === p.toLowerCase()) {
  1274. optionData = dataoptions[p];
  1275. break;
  1276. }
  1277. }
  1278. importOption("alias", optionData), userOptions.alias && resolveAlias(userOptions.alias, userOptions, opts);
  1279. for (option in opts) {
  1280. if (dataoptions) {
  1281. optionData = undefined;
  1282. for (p in dataoptions) if (p.toLowerCase() === option.toLowerCase()) {
  1283. optionData = dataoptions[p];
  1284. break;
  1285. }
  1286. }
  1287. importOption(option, optionData);
  1288. }
  1289. return $.extend(!0, opts, userOptions), opts;
  1290. }
  1291. var that = this;
  1292. return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)),
  1293. elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
  1294. var scopedOpts = $.extend(!0, {}, that.opts);
  1295. importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions), that.dataAttribute);
  1296. var maskset = generateMaskSet(scopedOpts, that.noMasksCache);
  1297. maskset !== undefined && (el.inputmask !== undefined && el.inputmask.remove(), el.inputmask = new Inputmask(undefined, undefined, (!0)),
  1298. el.inputmask.opts = scopedOpts, el.inputmask.noMasksCache = that.noMasksCache, el.inputmask.userOptions = $.extend(!0, {}, that.userOptions),
  1299. el.inputmask.isRTL = that.isRTL, el.inputmask.el = el, el.inputmask.maskset = maskset,
  1300. $.data(el, "_inputmask_opts", scopedOpts), maskScope.call(el.inputmask, {
  1301. action: "mask"
  1302. }));
  1303. }), elems && elems[0] ? elems[0].inputmask || this : this;
  1304. },
  1305. option: function(options, noremask) {
  1306. return "string" == typeof options ? this.opts[options] : "object" == typeof options ? ($.extend(this.userOptions, options),
  1307. this.el && noremask !== !0 && this.mask(this.el), this) : void 0;
  1308. },
  1309. unmaskedvalue: function(value) {
  1310. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1311. maskScope.call(this, {
  1312. action: "unmaskedvalue",
  1313. value: value
  1314. });
  1315. },
  1316. remove: function() {
  1317. return maskScope.call(this, {
  1318. action: "remove"
  1319. });
  1320. },
  1321. getemptymask: function() {
  1322. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1323. maskScope.call(this, {
  1324. action: "getemptymask"
  1325. });
  1326. },
  1327. hasMaskedValue: function() {
  1328. return !this.opts.autoUnmask;
  1329. },
  1330. isComplete: function() {
  1331. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1332. maskScope.call(this, {
  1333. action: "isComplete"
  1334. });
  1335. },
  1336. getmetadata: function() {
  1337. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1338. maskScope.call(this, {
  1339. action: "getmetadata"
  1340. });
  1341. },
  1342. isValid: function(value) {
  1343. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1344. maskScope.call(this, {
  1345. action: "isValid",
  1346. value: value
  1347. });
  1348. },
  1349. format: function(value, metadata) {
  1350. return this.maskset = this.maskset || generateMaskSet(this.opts, this.noMasksCache),
  1351. maskScope.call(this, {
  1352. action: "format",
  1353. value: value,
  1354. metadata: metadata
  1355. });
  1356. },
  1357. analyseMask: function(mask, opts) {
  1358. function MaskToken(isGroup, isOptional, isQuantifier, isAlternator) {
  1359. this.matches = [], this.openGroup = isGroup || !1, this.isGroup = isGroup || !1,
  1360. this.isOptional = isOptional || !1, this.isQuantifier = isQuantifier || !1, this.isAlternator = isAlternator || !1,
  1361. this.quantifier = {
  1362. min: 1,
  1363. max: 1
  1364. };
  1365. }
  1366. function insertTestDefinition(mtoken, element, position) {
  1367. var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
  1368. position = position !== undefined ? position : mtoken.matches.length;
  1369. var prevMatch = mtoken.matches[position - 1];
  1370. if (maskdef && !escaped) {
  1371. for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
  1372. var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
  1373. mtoken.matches.splice(position++, 0, {
  1374. fn: validator ? "string" == typeof validator ? new RegExp(validator) : new function() {
  1375. this.test = validator;
  1376. }() : new RegExp("."),
  1377. cardinality: cardinality ? cardinality : 1,
  1378. optionality: mtoken.isOptional,
  1379. newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
  1380. casing: maskdef.casing,
  1381. def: maskdef.definitionSymbol || element,
  1382. placeholder: maskdef.placeholder,
  1383. nativeDef: element
  1384. }), prevMatch = mtoken.matches[position - 1];
  1385. }
  1386. mtoken.matches.splice(position++, 0, {
  1387. fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator) : new function() {
  1388. this.test = maskdef.validator;
  1389. }() : new RegExp("."),
  1390. cardinality: maskdef.cardinality,
  1391. optionality: mtoken.isOptional,
  1392. newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
  1393. casing: maskdef.casing,
  1394. def: maskdef.definitionSymbol || element,
  1395. placeholder: maskdef.placeholder,
  1396. nativeDef: element
  1397. });
  1398. } else mtoken.matches.splice(position++, 0, {
  1399. fn: null,
  1400. cardinality: 0,
  1401. optionality: mtoken.isOptional,
  1402. newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
  1403. casing: null,
  1404. def: opts.staticDefinitionSymbol || element,
  1405. placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
  1406. nativeDef: element
  1407. }), escaped = !1;
  1408. }
  1409. function verifyGroupMarker(maskToken) {
  1410. maskToken && maskToken.matches && $.each(maskToken.matches, function(ndx, token) {
  1411. var nextToken = maskToken.matches[ndx + 1];
  1412. (nextToken === undefined || nextToken.matches === undefined || nextToken.isQuantifier === !1) && token && token.isGroup && (token.isGroup = !1,
  1413. insertTestDefinition(token, opts.groupmarker.start, 0), token.openGroup !== !0 && insertTestDefinition(token, opts.groupmarker.end)),
  1414. verifyGroupMarker(token);
  1415. });
  1416. }
  1417. function defaultCase() {
  1418. if (openenings.length > 0) {
  1419. if (currentOpeningToken = openenings[openenings.length - 1], insertTestDefinition(currentOpeningToken, m),
  1420. currentOpeningToken.isAlternator) {
  1421. alternator = openenings.pop();
  1422. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  1423. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1424. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  1425. }
  1426. } else insertTestDefinition(currentToken, m);
  1427. }
  1428. function reverseTokens(maskToken) {
  1429. function reverseStatic(st) {
  1430. 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),
  1431. st;
  1432. }
  1433. maskToken.matches = maskToken.matches.reverse();
  1434. for (var match in maskToken.matches) if (maskToken.matches.hasOwnProperty(match)) {
  1435. var intMatch = parseInt(match);
  1436. if (maskToken.matches[match].isQuantifier && maskToken.matches[intMatch + 1] && maskToken.matches[intMatch + 1].isGroup) {
  1437. var qt = maskToken.matches[match];
  1438. maskToken.matches.splice(match, 1), maskToken.matches.splice(intMatch + 1, 0, qt);
  1439. }
  1440. maskToken.matches[match].matches !== undefined ? maskToken.matches[match] = reverseTokens(maskToken.matches[match]) : maskToken.matches[match] = reverseStatic(maskToken.matches[match]);
  1441. }
  1442. return maskToken;
  1443. }
  1444. 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],
  1445. escaped) defaultCase(); else switch (m.charAt(0)) {
  1446. case opts.escapeChar:
  1447. escaped = !0;
  1448. break;
  1449. case opts.optionalmarker.end:
  1450. case opts.groupmarker.end:
  1451. if (openingToken = openenings.pop(), openingToken.openGroup = !1, openingToken !== undefined) if (openenings.length > 0) {
  1452. if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.push(openingToken),
  1453. currentOpeningToken.isAlternator) {
  1454. alternator = openenings.pop();
  1455. for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
  1456. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1457. currentOpeningToken.matches.push(alternator)) : currentToken.matches.push(alternator);
  1458. }
  1459. } else currentToken.matches.push(openingToken); else defaultCase();
  1460. break;
  1461. case opts.optionalmarker.start:
  1462. openenings.push(new MaskToken((!1), (!0)));
  1463. break;
  1464. case opts.groupmarker.start:
  1465. openenings.push(new MaskToken((!0)));
  1466. break;
  1467. case opts.quantifiermarker.start:
  1468. var quantifier = new MaskToken((!1), (!1), (!0));
  1469. m = m.replace(/[{}]/g, "");
  1470. 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]);
  1471. if ("*" !== mq1 && "+" !== mq1 || (mq0 = "*" === mq1 ? 0 : 1), quantifier.quantifier = {
  1472. min: mq0,
  1473. max: mq1
  1474. }, openenings.length > 0) {
  1475. var matches = openenings[openenings.length - 1].matches;
  1476. match = matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)), groupToken.matches.push(match),
  1477. match = groupToken), matches.push(match), matches.push(quantifier);
  1478. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new MaskToken((!0)),
  1479. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  1480. currentToken.matches.push(quantifier);
  1481. break;
  1482. case opts.alternatormarker:
  1483. openenings.length > 0 ? (currentOpeningToken = openenings[openenings.length - 1],
  1484. lastMatch = currentOpeningToken.matches.pop()) : lastMatch = currentToken.matches.pop(),
  1485. lastMatch.isAlternator ? openenings.push(lastMatch) : (alternator = new MaskToken((!1), (!1), (!1), (!0)),
  1486. alternator.matches.push(lastMatch), openenings.push(alternator));
  1487. break;
  1488. default:
  1489. defaultCase();
  1490. }
  1491. for (;openenings.length > 0; ) openingToken = openenings.pop(), currentToken.matches.push(openingToken);
  1492. return currentToken.matches.length > 0 && (verifyGroupMarker(currentToken), maskTokens.push(currentToken)),
  1493. opts.numericInput && reverseTokens(maskTokens[0]), maskTokens;
  1494. }
  1495. }, Inputmask.extendDefaults = function(options) {
  1496. $.extend(!0, Inputmask.prototype.defaults, options);
  1497. }, Inputmask.extendDefinitions = function(definition) {
  1498. $.extend(!0, Inputmask.prototype.definitions, definition);
  1499. }, Inputmask.extendAliases = function(alias) {
  1500. $.extend(!0, Inputmask.prototype.aliases, alias);
  1501. }, Inputmask.format = function(value, options, metadata) {
  1502. return Inputmask(options).format(value, metadata);
  1503. }, Inputmask.unmask = function(value, options) {
  1504. return Inputmask(options).unmaskedvalue(value);
  1505. }, Inputmask.isValid = function(value, options) {
  1506. return Inputmask(options).isValid(value);
  1507. }, Inputmask.remove = function(elems) {
  1508. $.each(elems, function(ndx, el) {
  1509. el.inputmask && el.inputmask.remove();
  1510. });
  1511. }, Inputmask.escapeRegex = function(str) {
  1512. var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
  1513. return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
  1514. }, Inputmask.keyCode = {
  1515. ALT: 18,
  1516. BACKSPACE: 8,
  1517. BACKSPACE_SAFARI: 127,
  1518. CAPS_LOCK: 20,
  1519. COMMA: 188,
  1520. COMMAND: 91,
  1521. COMMAND_LEFT: 91,
  1522. COMMAND_RIGHT: 93,
  1523. CONTROL: 17,
  1524. DELETE: 46,
  1525. DOWN: 40,
  1526. END: 35,
  1527. ENTER: 13,
  1528. ESCAPE: 27,
  1529. HOME: 36,
  1530. INSERT: 45,
  1531. LEFT: 37,
  1532. MENU: 93,
  1533. NUMPAD_ADD: 107,
  1534. NUMPAD_DECIMAL: 110,
  1535. NUMPAD_DIVIDE: 111,
  1536. NUMPAD_ENTER: 108,
  1537. NUMPAD_MULTIPLY: 106,
  1538. NUMPAD_SUBTRACT: 109,
  1539. PAGE_DOWN: 34,
  1540. PAGE_UP: 33,
  1541. PERIOD: 190,
  1542. RIGHT: 39,
  1543. SHIFT: 16,
  1544. SPACE: 32,
  1545. TAB: 9,
  1546. UP: 38,
  1547. WINDOWS: 91,
  1548. X: 88
  1549. }, Inputmask;
  1550. }), function(factory) {
  1551. factory(jQuery, window.Inputmask);
  1552. }(function($, Inputmask) {
  1553. return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  1554. var nptmask, input = this[0];
  1555. if (void 0 === options && (options = {}), "string" == typeof fn) switch (fn) {
  1556. case "unmaskedvalue":
  1557. return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  1558. case "remove":
  1559. return this.each(function() {
  1560. this.inputmask && this.inputmask.remove();
  1561. });
  1562. case "getemptymask":
  1563. return input && input.inputmask ? input.inputmask.getemptymask() : "";
  1564. case "hasMaskedValue":
  1565. return !(!input || !input.inputmask) && input.inputmask.hasMaskedValue();
  1566. case "isComplete":
  1567. return !input || !input.inputmask || input.inputmask.isComplete();
  1568. case "getmetadata":
  1569. return input && input.inputmask ? input.inputmask.getmetadata() : void 0;
  1570. case "setvalue":
  1571. $(input).val(options), input && void 0 === input.inputmask && $(input).triggerHandler("setvalue");
  1572. break;
  1573. case "option":
  1574. if ("string" != typeof options) return this.each(function() {
  1575. if (void 0 !== this.inputmask) return this.inputmask.option(options);
  1576. });
  1577. if (input && void 0 !== input.inputmask) return input.inputmask.option(options);
  1578. break;
  1579. default:
  1580. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  1581. nptmask.mask(this);
  1582. });
  1583. } else {
  1584. if ("object" == typeof fn) return nptmask = new Inputmask(fn), void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
  1585. return void 0 !== this.inputmask ? this.inputmask.option(fn) : void nptmask.mask(this);
  1586. }) : this.each(function() {
  1587. nptmask.mask(this);
  1588. });
  1589. if (void 0 === fn) return this.each(function() {
  1590. nptmask = new Inputmask(options), nptmask.mask(this);
  1591. });
  1592. }
  1593. }), $.fn.inputmask;
  1594. }), function($, Inputmask) {}(jQuery, Inputmask), function(factory) {
  1595. factory(window.dependencyLib || jQuery, window.Inputmask);
  1596. }(function($, Inputmask) {
  1597. function isLeapYear(year) {
  1598. return isNaN(year) || 29 === new Date(year, 2, 0).getDate();
  1599. }
  1600. return Inputmask.extendAliases({
  1601. "dd/mm/yyyy": {
  1602. mask: "1/2/y",
  1603. placeholder: "dd/mm/yyyy",
  1604. regex: {
  1605. val1pre: new RegExp("[0-3]"),
  1606. val1: new RegExp("0[1-9]|[12][0-9]|3[01]"),
  1607. val2pre: function(separator) {
  1608. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1609. return new RegExp("((0[1-9]|[12][0-9]|3[01])" + escapedSeparator + "[01])");
  1610. },
  1611. val2: function(separator) {
  1612. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1613. 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]))");
  1614. }
  1615. },
  1616. leapday: "29/02/",
  1617. separator: "/",
  1618. yearrange: {
  1619. minyear: 1900,
  1620. maxyear: 2099
  1621. },
  1622. isInYearRange: function(chrs, minyear, maxyear) {
  1623. if (isNaN(chrs)) return !1;
  1624. var enteredyear = parseInt(chrs.concat(minyear.toString().slice(chrs.length))), enteredyear2 = parseInt(chrs.concat(maxyear.toString().slice(chrs.length)));
  1625. return !isNaN(enteredyear) && (minyear <= enteredyear && enteredyear <= maxyear) || !isNaN(enteredyear2) && (minyear <= enteredyear2 && enteredyear2 <= maxyear);
  1626. },
  1627. determinebaseyear: function(minyear, maxyear, hint) {
  1628. var currentyear = new Date().getFullYear();
  1629. if (minyear > currentyear) return minyear;
  1630. if (maxyear < currentyear) {
  1631. for (var maxYearPrefix = maxyear.toString().slice(0, 2), maxYearPostfix = maxyear.toString().slice(2, 4); maxyear < maxYearPrefix + hint; ) maxYearPrefix--;
  1632. var maxxYear = maxYearPrefix + maxYearPostfix;
  1633. return minyear > maxxYear ? minyear : maxxYear;
  1634. }
  1635. if (minyear <= currentyear && currentyear <= maxyear) {
  1636. for (var currentYearPrefix = currentyear.toString().slice(0, 2); maxyear < currentYearPrefix + hint; ) currentYearPrefix--;
  1637. var currentYearAndHint = currentYearPrefix + hint;
  1638. return currentYearAndHint < minyear ? minyear : currentYearAndHint;
  1639. }
  1640. return currentyear;
  1641. },
  1642. onKeyDown: function(e, buffer, caretPos, opts) {
  1643. var $input = $(this);
  1644. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1645. var today = new Date();
  1646. $input.val(today.getDate().toString() + (today.getMonth() + 1).toString() + today.getFullYear().toString()),
  1647. $input.trigger("setvalue");
  1648. }
  1649. },
  1650. getFrontValue: function(mask, buffer, opts) {
  1651. for (var start = 0, length = 0, i = 0; i < mask.length && "2" !== mask.charAt(i); i++) {
  1652. var definition = opts.definitions[mask.charAt(i)];
  1653. definition ? (start += length, length = definition.cardinality) : length++;
  1654. }
  1655. return buffer.join("").substr(start, length);
  1656. },
  1657. postValidation: function(buffer, currentResult, opts) {
  1658. var dayMonthValue, year, bufferStr = buffer.join("");
  1659. return 0 === opts.mask.indexOf("y") ? (year = bufferStr.substr(0, 4), dayMonthValue = bufferStr.substr(4, 11)) : (year = bufferStr.substr(6, 11),
  1660. dayMonthValue = bufferStr.substr(0, 6)), currentResult && (dayMonthValue !== opts.leapday || isLeapYear(year));
  1661. },
  1662. definitions: {
  1663. "1": {
  1664. validator: function(chrs, maskset, pos, strict, opts) {
  1665. var isValid = opts.regex.val1.test(chrs);
  1666. 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",
  1667. {
  1668. refreshFromBuffer: {
  1669. start: pos - 1,
  1670. end: pos
  1671. },
  1672. pos: pos,
  1673. c: chrs.charAt(0)
  1674. });
  1675. },
  1676. cardinality: 2,
  1677. prevalidator: [ {
  1678. validator: function(chrs, maskset, pos, strict, opts) {
  1679. var pchrs = chrs;
  1680. isNaN(maskset.buffer[pos + 1]) || (pchrs += maskset.buffer[pos + 1]);
  1681. var isValid = 1 === pchrs.length ? opts.regex.val1pre.test(pchrs) : opts.regex.val1.test(pchrs);
  1682. if (!strict && !isValid) {
  1683. if (isValid = opts.regex.val1.test(chrs + "0")) return maskset.buffer[pos] = chrs,
  1684. maskset.buffer[++pos] = "0", {
  1685. pos: pos,
  1686. c: "0"
  1687. };
  1688. if (isValid = opts.regex.val1.test("0" + chrs)) return maskset.buffer[pos] = "0",
  1689. pos++, {
  1690. pos: pos
  1691. };
  1692. }
  1693. return isValid;
  1694. },
  1695. cardinality: 1
  1696. } ]
  1697. },
  1698. "2": {
  1699. validator: function(chrs, maskset, pos, strict, opts) {
  1700. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1701. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1702. var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
  1703. 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",
  1704. {
  1705. refreshFromBuffer: {
  1706. start: pos - 1,
  1707. end: pos
  1708. },
  1709. pos: pos,
  1710. c: chrs.charAt(0)
  1711. });
  1712. },
  1713. cardinality: 2,
  1714. prevalidator: [ {
  1715. validator: function(chrs, maskset, pos, strict, opts) {
  1716. isNaN(maskset.buffer[pos + 1]) || (chrs += maskset.buffer[pos + 1]);
  1717. var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
  1718. frontValue.indexOf(opts.placeholder[0]) !== -1 && (frontValue = "01" + opts.separator);
  1719. var isValid = 1 === chrs.length ? opts.regex.val2pre(opts.separator).test(frontValue + chrs) : opts.regex.val2(opts.separator).test(frontValue + chrs);
  1720. return strict || isValid || !(isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1721. pos++, {
  1722. pos: pos
  1723. });
  1724. },
  1725. cardinality: 1
  1726. } ]
  1727. },
  1728. y: {
  1729. validator: function(chrs, maskset, pos, strict, opts) {
  1730. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1731. },
  1732. cardinality: 4,
  1733. prevalidator: [ {
  1734. validator: function(chrs, maskset, pos, strict, opts) {
  1735. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1736. if (!strict && !isValid) {
  1737. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 1);
  1738. if (isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1739. {
  1740. pos: pos
  1741. };
  1742. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs + "0").toString().slice(0, 2),
  1743. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(0),
  1744. maskset.buffer[pos++] = yearPrefix.charAt(1), {
  1745. pos: pos
  1746. };
  1747. }
  1748. return isValid;
  1749. },
  1750. cardinality: 1
  1751. }, {
  1752. validator: function(chrs, maskset, pos, strict, opts) {
  1753. var isValid = opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1754. if (!strict && !isValid) {
  1755. var yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2);
  1756. if (isValid = opts.isInYearRange(chrs[0] + yearPrefix[1] + chrs[1], opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos++] = yearPrefix.charAt(1),
  1757. {
  1758. pos: pos
  1759. };
  1760. if (yearPrefix = opts.determinebaseyear(opts.yearrange.minyear, opts.yearrange.maxyear, chrs).toString().slice(0, 2),
  1761. isValid = opts.isInYearRange(yearPrefix + chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) return maskset.buffer[pos - 1] = yearPrefix.charAt(0),
  1762. maskset.buffer[pos++] = yearPrefix.charAt(1), maskset.buffer[pos++] = chrs.charAt(0),
  1763. {
  1764. refreshFromBuffer: {
  1765. start: pos - 3,
  1766. end: pos
  1767. },
  1768. pos: pos
  1769. };
  1770. }
  1771. return isValid;
  1772. },
  1773. cardinality: 2
  1774. }, {
  1775. validator: function(chrs, maskset, pos, strict, opts) {
  1776. return opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear);
  1777. },
  1778. cardinality: 3
  1779. } ]
  1780. }
  1781. },
  1782. insertMode: !1,
  1783. autoUnmask: !1
  1784. },
  1785. "mm/dd/yyyy": {
  1786. placeholder: "mm/dd/yyyy",
  1787. alias: "dd/mm/yyyy",
  1788. regex: {
  1789. val2pre: function(separator) {
  1790. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1791. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1792. },
  1793. val2: function(separator) {
  1794. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1795. 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)");
  1796. },
  1797. val1pre: new RegExp("[01]"),
  1798. val1: new RegExp("0[1-9]|1[012]")
  1799. },
  1800. leapday: "02/29/",
  1801. onKeyDown: function(e, buffer, caretPos, opts) {
  1802. var $input = $(this);
  1803. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1804. var today = new Date();
  1805. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1806. $input.trigger("setvalue");
  1807. }
  1808. }
  1809. },
  1810. "yyyy/mm/dd": {
  1811. mask: "y/1/2",
  1812. placeholder: "yyyy/mm/dd",
  1813. alias: "mm/dd/yyyy",
  1814. leapday: "/02/29",
  1815. onKeyDown: function(e, buffer, caretPos, opts) {
  1816. var $input = $(this);
  1817. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1818. var today = new Date();
  1819. $input.val(today.getFullYear().toString() + (today.getMonth() + 1).toString() + today.getDate().toString()),
  1820. $input.trigger("setvalue");
  1821. }
  1822. }
  1823. },
  1824. "dd.mm.yyyy": {
  1825. mask: "1.2.y",
  1826. placeholder: "dd.mm.yyyy",
  1827. leapday: "29.02.",
  1828. separator: ".",
  1829. alias: "dd/mm/yyyy"
  1830. },
  1831. "dd-mm-yyyy": {
  1832. mask: "1-2-y",
  1833. placeholder: "dd-mm-yyyy",
  1834. leapday: "29-02-",
  1835. separator: "-",
  1836. alias: "dd/mm/yyyy"
  1837. },
  1838. "mm.dd.yyyy": {
  1839. mask: "1.2.y",
  1840. placeholder: "mm.dd.yyyy",
  1841. leapday: "02.29.",
  1842. separator: ".",
  1843. alias: "mm/dd/yyyy"
  1844. },
  1845. "mm-dd-yyyy": {
  1846. mask: "1-2-y",
  1847. placeholder: "mm-dd-yyyy",
  1848. leapday: "02-29-",
  1849. separator: "-",
  1850. alias: "mm/dd/yyyy"
  1851. },
  1852. "yyyy.mm.dd": {
  1853. mask: "y.1.2",
  1854. placeholder: "yyyy.mm.dd",
  1855. leapday: ".02.29",
  1856. separator: ".",
  1857. alias: "yyyy/mm/dd"
  1858. },
  1859. "yyyy-mm-dd": {
  1860. mask: "y-1-2",
  1861. placeholder: "yyyy-mm-dd",
  1862. leapday: "-02-29",
  1863. separator: "-",
  1864. alias: "yyyy/mm/dd"
  1865. },
  1866. datetime: {
  1867. mask: "1/2/y h:s",
  1868. placeholder: "dd/mm/yyyy hh:mm",
  1869. alias: "dd/mm/yyyy",
  1870. regex: {
  1871. hrspre: new RegExp("[012]"),
  1872. hrs24: new RegExp("2[0-4]|1[3-9]"),
  1873. hrs: new RegExp("[01][0-9]|2[0-4]"),
  1874. ampm: new RegExp("^[a|p|A|P][m|M]"),
  1875. mspre: new RegExp("[0-5]"),
  1876. ms: new RegExp("[0-5][0-9]")
  1877. },
  1878. timeseparator: ":",
  1879. hourFormat: "24",
  1880. definitions: {
  1881. h: {
  1882. validator: function(chrs, maskset, pos, strict, opts) {
  1883. if ("24" === opts.hourFormat && 24 === parseInt(chrs, 10)) return maskset.buffer[pos - 1] = "0",
  1884. maskset.buffer[pos] = "0", {
  1885. refreshFromBuffer: {
  1886. start: pos - 1,
  1887. end: pos
  1888. },
  1889. c: "0"
  1890. };
  1891. var isValid = opts.regex.hrs.test(chrs);
  1892. 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",
  1893. maskset.buffer[pos] = chrs.charAt(0), pos++, {
  1894. refreshFromBuffer: {
  1895. start: pos - 2,
  1896. end: pos
  1897. },
  1898. pos: pos,
  1899. c: opts.timeseparator
  1900. };
  1901. if (isValid && "24" !== opts.hourFormat && opts.regex.hrs24.test(chrs)) {
  1902. var tmp = parseInt(chrs, 10);
  1903. return 24 === tmp ? (maskset.buffer[pos + 5] = "a", maskset.buffer[pos + 6] = "m") : (maskset.buffer[pos + 5] = "p",
  1904. maskset.buffer[pos + 6] = "m"), tmp -= 12, tmp < 10 ? (maskset.buffer[pos] = tmp.toString(),
  1905. maskset.buffer[pos - 1] = "0") : (maskset.buffer[pos] = tmp.toString().charAt(1),
  1906. maskset.buffer[pos - 1] = tmp.toString().charAt(0)), {
  1907. refreshFromBuffer: {
  1908. start: pos - 1,
  1909. end: pos + 6
  1910. },
  1911. c: maskset.buffer[pos]
  1912. };
  1913. }
  1914. return isValid;
  1915. },
  1916. cardinality: 2,
  1917. prevalidator: [ {
  1918. validator: function(chrs, maskset, pos, strict, opts) {
  1919. var isValid = opts.regex.hrspre.test(chrs);
  1920. return strict || isValid || !(isValid = opts.regex.hrs.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1921. pos++, {
  1922. pos: pos
  1923. });
  1924. },
  1925. cardinality: 1
  1926. } ]
  1927. },
  1928. s: {
  1929. validator: "[0-5][0-9]",
  1930. cardinality: 2,
  1931. prevalidator: [ {
  1932. validator: function(chrs, maskset, pos, strict, opts) {
  1933. var isValid = opts.regex.mspre.test(chrs);
  1934. return strict || isValid || !(isValid = opts.regex.ms.test("0" + chrs)) ? isValid : (maskset.buffer[pos] = "0",
  1935. pos++, {
  1936. pos: pos
  1937. });
  1938. },
  1939. cardinality: 1
  1940. } ]
  1941. },
  1942. t: {
  1943. validator: function(chrs, maskset, pos, strict, opts) {
  1944. return opts.regex.ampm.test(chrs + "m");
  1945. },
  1946. casing: "lower",
  1947. cardinality: 1
  1948. }
  1949. },
  1950. insertMode: !1,
  1951. autoUnmask: !1
  1952. },
  1953. datetime12: {
  1954. mask: "1/2/y h:s t\\m",
  1955. placeholder: "dd/mm/yyyy hh:mm xm",
  1956. alias: "datetime",
  1957. hourFormat: "12"
  1958. },
  1959. "mm/dd/yyyy hh:mm xm": {
  1960. mask: "1/2/y h:s t\\m",
  1961. placeholder: "mm/dd/yyyy hh:mm xm",
  1962. alias: "datetime12",
  1963. regex: {
  1964. val2pre: function(separator) {
  1965. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1966. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  1967. },
  1968. val2: function(separator) {
  1969. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  1970. 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)");
  1971. },
  1972. val1pre: new RegExp("[01]"),
  1973. val1: new RegExp("0[1-9]|1[012]")
  1974. },
  1975. leapday: "02/29/",
  1976. onKeyDown: function(e, buffer, caretPos, opts) {
  1977. var $input = $(this);
  1978. if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
  1979. var today = new Date();
  1980. $input.val((today.getMonth() + 1).toString() + today.getDate().toString() + today.getFullYear().toString()),
  1981. $input.trigger("setvalue");
  1982. }
  1983. }
  1984. },
  1985. "hh:mm t": {
  1986. mask: "h:s t\\m",
  1987. placeholder: "hh:mm xm",
  1988. alias: "datetime",
  1989. hourFormat: "12"
  1990. },
  1991. "h:s t": {
  1992. mask: "h:s t\\m",
  1993. placeholder: "hh:mm xm",
  1994. alias: "datetime",
  1995. hourFormat: "12"
  1996. },
  1997. "hh:mm:ss": {
  1998. mask: "h:s:s",
  1999. placeholder: "hh:mm:ss",
  2000. alias: "datetime",
  2001. autoUnmask: !1
  2002. },
  2003. "hh:mm": {
  2004. mask: "h:s",
  2005. placeholder: "hh:mm",
  2006. alias: "datetime",
  2007. autoUnmask: !1
  2008. },
  2009. date: {
  2010. alias: "dd/mm/yyyy"
  2011. },
  2012. "mm/yyyy": {
  2013. mask: "1/y",
  2014. placeholder: "mm/yyyy",
  2015. leapday: "donotuse",
  2016. separator: "/",
  2017. alias: "mm/dd/yyyy"
  2018. },
  2019. shamsi: {
  2020. regex: {
  2021. val2pre: function(separator) {
  2022. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2023. return new RegExp("((0[1-9]|1[012])" + escapedSeparator + "[0-3])");
  2024. },
  2025. val2: function(separator) {
  2026. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2027. 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)");
  2028. },
  2029. val1pre: new RegExp("[01]"),
  2030. val1: new RegExp("0[1-9]|1[012]")
  2031. },
  2032. yearrange: {
  2033. minyear: 1300,
  2034. maxyear: 1499
  2035. },
  2036. mask: "y/1/2",
  2037. leapday: "/12/30",
  2038. placeholder: "yyyy/mm/dd",
  2039. alias: "mm/dd/yyyy",
  2040. clearIncomplete: !0
  2041. },
  2042. "yyyy-mm-dd hh:mm:ss": {
  2043. mask: "y-1-2 h:s:s",
  2044. placeholder: "yyyy-mm-dd hh:mm:ss",
  2045. alias: "datetime",
  2046. separator: "-",
  2047. leapday: "-02-29",
  2048. regex: {
  2049. val2pre: function(separator) {
  2050. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2051. return new RegExp("((0[13-9]|1[012])" + escapedSeparator + "[0-3])|(02" + escapedSeparator + "[0-2])");
  2052. },
  2053. val2: function(separator) {
  2054. var escapedSeparator = Inputmask.escapeRegex.call(this, separator);
  2055. 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)");
  2056. },
  2057. val1pre: new RegExp("[01]"),
  2058. val1: new RegExp("0[1-9]|1[012]")
  2059. },
  2060. onKeyDown: function(e, buffer, caretPos, opts) {}
  2061. }
  2062. }), Inputmask;
  2063. }), function(factory) {
  2064. factory(window.dependencyLib || jQuery, window.Inputmask);
  2065. }(function($, Inputmask) {
  2066. return Inputmask.extendDefinitions({
  2067. A: {
  2068. validator: "[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2069. cardinality: 1,
  2070. casing: "upper"
  2071. },
  2072. "&": {
  2073. validator: "[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",
  2074. cardinality: 1,
  2075. casing: "upper"
  2076. },
  2077. "#": {
  2078. validator: "[0-9A-Fa-f]",
  2079. cardinality: 1,
  2080. casing: "upper"
  2081. }
  2082. }), Inputmask.extendAliases({
  2083. url: {
  2084. definitions: {
  2085. i: {
  2086. validator: ".",
  2087. cardinality: 1
  2088. }
  2089. },
  2090. mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
  2091. insertMode: !1,
  2092. autoUnmask: !1,
  2093. inputmode: "url"
  2094. },
  2095. ip: {
  2096. mask: "i[i[i]].i[i[i]].i[i[i]].i[i[i]]",
  2097. definitions: {
  2098. i: {
  2099. validator: function(chrs, maskset, pos, strict, opts) {
  2100. return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs,
  2101. chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs,
  2102. new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
  2103. },
  2104. cardinality: 1
  2105. }
  2106. },
  2107. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2108. return maskedValue;
  2109. },
  2110. inputmode: "numeric"
  2111. },
  2112. email: {
  2113. mask: "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]",
  2114. greedy: !1,
  2115. onBeforePaste: function(pastedValue, opts) {
  2116. return pastedValue = pastedValue.toLowerCase(), pastedValue.replace("mailto:", "");
  2117. },
  2118. definitions: {
  2119. "*": {
  2120. validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
  2121. cardinality: 1,
  2122. casing: "lower"
  2123. },
  2124. "-": {
  2125. validator: "[0-9A-Za-z-]",
  2126. cardinality: 1,
  2127. casing: "lower"
  2128. }
  2129. },
  2130. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2131. return maskedValue;
  2132. },
  2133. inputmode: "email"
  2134. },
  2135. mac: {
  2136. mask: "##:##:##:##:##:##"
  2137. },
  2138. vin: {
  2139. mask: "V{13}9{4}",
  2140. definitions: {
  2141. V: {
  2142. validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
  2143. cardinality: 1,
  2144. casing: "upper"
  2145. }
  2146. },
  2147. clearIncomplete: !0,
  2148. autoUnmask: !0
  2149. }
  2150. }), Inputmask;
  2151. }), function(factory) {
  2152. factory(window.dependencyLib || jQuery, window.Inputmask);
  2153. }(function($, Inputmask, undefined) {
  2154. function autoEscape(txt, opts) {
  2155. 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);
  2156. return escapedTxt;
  2157. }
  2158. return Inputmask.extendAliases({
  2159. numeric: {
  2160. mask: function(opts) {
  2161. if (0 !== opts.repeat && isNaN(opts.integerDigits) && (opts.integerDigits = opts.repeat),
  2162. opts.repeat = 0, opts.groupSeparator === opts.radixPoint && ("." === opts.radixPoint ? opts.groupSeparator = "," : "," === opts.radixPoint ? opts.groupSeparator = "." : opts.groupSeparator = ""),
  2163. " " === opts.groupSeparator && (opts.skipOptionalPartCharacter = undefined), opts.autoGroup = opts.autoGroup && "" !== opts.groupSeparator,
  2164. opts.autoGroup && ("string" == typeof opts.groupSize && isFinite(opts.groupSize) && (opts.groupSize = parseInt(opts.groupSize)),
  2165. isFinite(opts.integerDigits))) {
  2166. var seps = Math.floor(opts.integerDigits / opts.groupSize), mod = opts.integerDigits % opts.groupSize;
  2167. opts.integerDigits = parseInt(opts.integerDigits) + (0 === mod ? seps - 1 : seps),
  2168. opts.integerDigits < 1 && (opts.integerDigits = "*");
  2169. }
  2170. opts.placeholder.length > 1 && (opts.placeholder = opts.placeholder.charAt(0)),
  2171. "radixFocus" === opts.positionCaretOnClick && "" === opts.placeholder && opts.integerOptional === !1 && (opts.positionCaretOnClick = "lvp"),
  2172. opts.definitions[";"] = opts.definitions["~"], opts.definitions[";"].definitionSymbol = "~",
  2173. opts.numericInput === !0 && (opts.positionCaretOnClick = "radixFocus" === opts.positionCaretOnClick ? "lvp" : opts.positionCaretOnClick,
  2174. opts.digitsOptional = !1, isNaN(opts.digits) && (opts.digits = 2), opts.decimalProtect = !1);
  2175. var mask = "[+]";
  2176. if (mask += autoEscape(opts.prefix, opts), mask += opts.integerOptional === !0 ? "~{1," + opts.integerDigits + "}" : "~{" + opts.integerDigits + "}",
  2177. opts.digits !== undefined) {
  2178. opts.radixPointDefinitionSymbol = opts.decimalProtect ? ":" : opts.radixPoint;
  2179. var dq = opts.digits.toString().split(",");
  2180. 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 + "}");
  2181. }
  2182. return mask += autoEscape(opts.suffix, opts), mask += "[-]", opts.greedy = !1, mask;
  2183. },
  2184. placeholder: "",
  2185. greedy: !1,
  2186. digits: "*",
  2187. digitsOptional: !0,
  2188. radixPoint: ".",
  2189. positionCaretOnClick: "radixFocus",
  2190. groupSize: 3,
  2191. groupSeparator: "",
  2192. autoGroup: !1,
  2193. allowMinus: !0,
  2194. negationSymbol: {
  2195. front: "-",
  2196. back: ""
  2197. },
  2198. integerDigits: "+",
  2199. integerOptional: !0,
  2200. prefix: "",
  2201. suffix: "",
  2202. rightAlign: !0,
  2203. decimalProtect: !0,
  2204. min: null,
  2205. max: null,
  2206. step: 1,
  2207. insertMode: !0,
  2208. autoUnmask: !1,
  2209. unmaskAsNumber: !1,
  2210. inputmode: "numeric",
  2211. preValidation: function(buffer, pos, c, isSelection, opts) {
  2212. if ("-" === c || c == opts.negationSymbol.front) return opts.allowMinus === !0 && (opts.isNegative = opts.isNegative === undefined || !opts.isNegative,
  2213. "" === buffer.join("") || {
  2214. caret: pos,
  2215. dopost: !0
  2216. });
  2217. if (isSelection === !1 && opts.numericInput !== !0 && c === opts.radixPoint && opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
  2218. var radixPos = $.inArray(opts.radixPoint, buffer);
  2219. if (radixPos !== -1) return {
  2220. caret: radixPos + 1
  2221. };
  2222. }
  2223. return !0;
  2224. },
  2225. postValidation: function(buffer, currentResult, opts) {
  2226. function buildPostMask(buffer, opts) {
  2227. var postMask = "";
  2228. if (postMask += "(" + opts.groupSeparator + "*{" + opts.groupSize + "}){*}", "" !== opts.radixPoint) {
  2229. var radixSplit = buffer.join("").split(opts.radixPoint);
  2230. radixSplit[1] && (postMask += opts.radixPoint + "*{" + radixSplit[1].match(/^\d*\??\d*/)[0].length + "}");
  2231. }
  2232. return postMask;
  2233. }
  2234. var suffix = opts.suffix.split(""), prefix = opts.prefix.split("");
  2235. if (currentResult.pos == undefined && currentResult.caret !== undefined && currentResult.dopost !== !0) return currentResult;
  2236. var caretPos = currentResult.caret != undefined ? currentResult.caret : currentResult.pos, maskedValue = buffer.slice();
  2237. opts.numericInput && (caretPos = maskedValue.length - caretPos - 1, maskedValue = maskedValue.reverse());
  2238. var charAtPos = maskedValue[caretPos];
  2239. if (charAtPos === opts.groupSeparator && (caretPos += 1, charAtPos = maskedValue[caretPos]),
  2240. caretPos == maskedValue.length - opts.suffix.length - 1 && charAtPos === opts.radixPoint) return currentResult;
  2241. charAtPos !== undefined && charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back && (maskedValue[caretPos] = "?",
  2242. 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))] = "?")),
  2243. prefix = prefix.join(""), suffix = suffix.join("");
  2244. var processValue = maskedValue.join("").replace(prefix, "");
  2245. if (processValue = processValue.replace(suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2246. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  2247. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2248. isNaN(opts.placeholder) && (processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.placeholder), "g"), "")),
  2249. processValue.length > 1 && 1 !== $.inArray(opts.radixPoint, processValue) && ("0" == charAtPos && (processValue = processValue.replace(/^\?/g, "")),
  2250. processValue = processValue.replace(/^0/g, "")), processValue.charAt(0) === opts.radixPoint && opts.numericInput !== !0 && (processValue = "0" + processValue),
  2251. "" !== processValue) {
  2252. if (processValue = processValue.split(""), !opts.digitsOptional && isFinite(opts.digits)) {
  2253. var radixPosition = $.inArray(opts.radixPoint, processValue), rpb = $.inArray(opts.radixPoint, maskedValue);
  2254. radixPosition === -1 && (processValue.push(opts.radixPoint), radixPosition = processValue.length - 1);
  2255. 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);
  2256. }
  2257. opts.autoGroup !== !0 || "" === opts.groupSeparator || charAtPos === opts.radixPoint && currentResult.pos === undefined && !currentResult.dopost ? processValue = processValue.join("") : (processValue = Inputmask(buildPostMask(processValue, opts), {
  2258. numericInput: !0,
  2259. jitMasking: !0,
  2260. definitions: {
  2261. "*": {
  2262. validator: "[0-9?]",
  2263. cardinality: 1
  2264. }
  2265. }
  2266. }).format(processValue.join("")), processValue.charAt(0) === opts.groupSeparator && processValue.substr(1));
  2267. }
  2268. if (opts.isNegative && "blur" === currentResult.event && (opts.isNegative = "0" !== processValue),
  2269. processValue = prefix + processValue, processValue += suffix, opts.isNegative && (processValue = opts.negationSymbol.front + processValue,
  2270. processValue += opts.negationSymbol.back), processValue = processValue.split(""),
  2271. charAtPos !== undefined) if (charAtPos !== opts.radixPoint && charAtPos !== opts.negationSymbol.front && charAtPos !== opts.negationSymbol.back) caretPos = $.inArray("?", processValue),
  2272. caretPos > -1 ? processValue[caretPos] = charAtPos : caretPos = currentResult.caret || 0; else if (charAtPos === opts.radixPoint || charAtPos === opts.negationSymbol.front || charAtPos === opts.negationSymbol.back) {
  2273. var newCaretPos = $.inArray(charAtPos, processValue);
  2274. newCaretPos !== -1 && (caretPos = newCaretPos);
  2275. }
  2276. opts.numericInput && (caretPos = processValue.length - caretPos - 1, processValue = processValue.reverse());
  2277. var rslt = {
  2278. caret: charAtPos === undefined || currentResult.pos !== undefined ? caretPos + (opts.numericInput ? -1 : 1) : caretPos,
  2279. buffer: processValue,
  2280. refreshFromBuffer: currentResult.dopost || buffer.join("") !== processValue.join("")
  2281. };
  2282. return rslt.refreshFromBuffer ? rslt : currentResult;
  2283. },
  2284. onBeforeWrite: function(e, buffer, caretPos, opts) {
  2285. function parseMinMaxOptions(opts) {
  2286. opts.parseMinMaxOptions === undefined && (null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2287. "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, ".")),
  2288. opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN, isNaN(opts.min) && (opts.min = Number.MIN_VALUE)),
  2289. null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2290. "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, ".")),
  2291. opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN, isNaN(opts.max) && (opts.max = Number.MAX_VALUE)),
  2292. opts.parseMinMaxOptions = "done");
  2293. }
  2294. if (e) switch (e.type) {
  2295. case "keydown":
  2296. return opts.postValidation(buffer, {
  2297. caret: caretPos,
  2298. dopost: !0
  2299. }, opts);
  2300. case "blur":
  2301. case "checkval":
  2302. var unmasked;
  2303. if (parseMinMaxOptions(opts), null !== opts.min || null !== opts.max) {
  2304. if (unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, {
  2305. unmaskAsNumber: !0
  2306. })), null !== opts.min && unmasked < opts.min) return opts.isNegative = opts.min < 0,
  2307. opts.postValidation(opts.min.toString().replace(".", opts.radixPoint).split(""), {
  2308. caret: caretPos,
  2309. dopost: !0,
  2310. placeholder: "0"
  2311. }, opts);
  2312. if (null !== opts.max && unmasked > opts.max) return opts.isNegative = opts.max < 0,
  2313. opts.postValidation(opts.max.toString().replace(".", opts.radixPoint).split(""), {
  2314. caret: caretPos,
  2315. dopost: !0,
  2316. placeholder: "0"
  2317. }, opts);
  2318. }
  2319. return opts.postValidation(buffer, {
  2320. caret: caretPos,
  2321. dopost: !0,
  2322. placeholder: "0",
  2323. event: "blur"
  2324. }, opts);
  2325. }
  2326. },
  2327. regex: {
  2328. integerPart: function(opts, emptyCheck) {
  2329. return emptyCheck ? new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?") : new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "+]?\\d+");
  2330. },
  2331. integerNPart: function(opts) {
  2332. return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + Inputmask.escapeRegex(opts.placeholder.charAt(0)) + "]+");
  2333. }
  2334. },
  2335. definitions: {
  2336. "~": {
  2337. validator: function(chrs, maskset, pos, strict, opts, isSelection) {
  2338. var isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
  2339. if (isValid === !0) {
  2340. if (opts.numericInput !== !0 && maskset.validPositions[pos] !== undefined && "~" === maskset.validPositions[pos].match.def && !isSelection) {
  2341. var processValue = maskset.buffer.join("");
  2342. processValue = processValue.replace(new RegExp("[-" + Inputmask.escapeRegex(opts.negationSymbol.front) + "]", "g"), ""),
  2343. processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), ""),
  2344. processValue = processValue.replace(/0/g, opts.placeholder.charAt(0));
  2345. var bufferTemplate = maskset._buffer.join("");
  2346. for (processValue === opts.radixPoint && (processValue = bufferTemplate); null === processValue.match(Inputmask.escapeRegex(bufferTemplate) + "$"); ) bufferTemplate = bufferTemplate.slice(1);
  2347. processValue = processValue.replace(bufferTemplate, ""), processValue = processValue.split(""),
  2348. isValid = processValue[pos] === undefined ? {
  2349. pos: pos,
  2350. remove: pos
  2351. } : {
  2352. pos: pos
  2353. };
  2354. }
  2355. } else strict || chrs !== opts.radixPoint || maskset.validPositions[pos - 1] !== undefined || (maskset.buffer[pos] = "0",
  2356. isValid = {
  2357. pos: pos + 1
  2358. });
  2359. return isValid;
  2360. },
  2361. cardinality: 1
  2362. },
  2363. "+": {
  2364. validator: function(chrs, maskset, pos, strict, opts) {
  2365. return opts.allowMinus && ("-" === chrs || chrs === opts.negationSymbol.front);
  2366. },
  2367. cardinality: 1,
  2368. placeholder: ""
  2369. },
  2370. "-": {
  2371. validator: function(chrs, maskset, pos, strict, opts) {
  2372. return opts.allowMinus && chrs === opts.negationSymbol.back;
  2373. },
  2374. cardinality: 1,
  2375. placeholder: ""
  2376. },
  2377. ":": {
  2378. validator: function(chrs, maskset, pos, strict, opts) {
  2379. var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + "]";
  2380. return isValid = new RegExp(radix).test(chrs), isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint && (isValid = {
  2381. caret: pos + 1
  2382. }), isValid;
  2383. },
  2384. cardinality: 1,
  2385. placeholder: function(opts) {
  2386. return opts.radixPoint;
  2387. }
  2388. }
  2389. },
  2390. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2391. if ("" === unmaskedValue && opts.nullable === !0) return unmaskedValue;
  2392. var processValue = maskedValue.replace(opts.prefix, "");
  2393. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2394. "" !== opts.placeholder.charAt(0) && (processValue = processValue.replace(new RegExp(opts.placeholder.charAt(0), "g"), "0")),
  2395. opts.unmaskAsNumber ? ("" !== opts.radixPoint && processValue.indexOf(opts.radixPoint) !== -1 && (processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".")),
  2396. Number(processValue)) : processValue;
  2397. },
  2398. isComplete: function(buffer, opts) {
  2399. var maskedValue = buffer.join(""), bufClone = buffer.slice();
  2400. if (bufClone.join("") !== maskedValue) return !1;
  2401. var processValue = maskedValue.replace(opts.prefix, "");
  2402. return processValue = processValue.replace(opts.suffix, ""), processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), ""),
  2403. "," === opts.radixPoint && (processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".")),
  2404. isFinite(processValue);
  2405. },
  2406. onBeforeMask: function(initialValue, opts) {
  2407. if (opts.isNegative = undefined, initialValue = initialValue.toString().charAt(initialValue.length - 1) === opts.radixPoint ? initialValue.toString().substr(0, initialValue.length - 1) : initialValue.toString(),
  2408. "" !== opts.radixPoint && isFinite(initialValue)) {
  2409. var vs = initialValue.split("."), groupSize = "" !== opts.groupSeparator ? parseInt(opts.groupSize) : 0;
  2410. 2 === vs.length && (vs[0].length > groupSize || vs[1].length > groupSize) && (initialValue = initialValue.replace(".", opts.radixPoint));
  2411. }
  2412. var kommaMatches = initialValue.match(/,/g), dotMatches = initialValue.match(/\./g);
  2413. if (dotMatches && kommaMatches ? dotMatches.length > kommaMatches.length ? (initialValue = initialValue.replace(/\./g, ""),
  2414. initialValue = initialValue.replace(",", opts.radixPoint)) : kommaMatches.length > dotMatches.length ? (initialValue = initialValue.replace(/,/g, ""),
  2415. 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"), ""),
  2416. 0 === opts.digits && (initialValue.indexOf(".") !== -1 ? initialValue = initialValue.substring(0, initialValue.indexOf(".")) : initialValue.indexOf(",") !== -1 && (initialValue = initialValue.substring(0, initialValue.indexOf(",")))),
  2417. "" !== opts.radixPoint && isFinite(opts.digits) && initialValue.indexOf(opts.radixPoint) !== -1) {
  2418. var valueParts = initialValue.split(opts.radixPoint), decPart = valueParts[1].match(new RegExp("\\d*"))[0];
  2419. if (parseInt(opts.digits) < decPart.toString().length) {
  2420. var digitsFactor = Math.pow(10, parseInt(opts.digits));
  2421. initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), "."),
  2422. initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor,
  2423. initialValue = initialValue.toString().replace(".", opts.radixPoint);
  2424. }
  2425. }
  2426. return initialValue;
  2427. },
  2428. canClearPosition: function(maskset, position, lvp, strict, opts) {
  2429. 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;
  2430. return !canClear || "+" != vp.match.nativeDef && "-" != vp.match.nativeDef || (opts.isNegative = !1),
  2431. canClear;
  2432. },
  2433. onKeyDown: function(e, buffer, caretPos, opts) {
  2434. var $input = $(this);
  2435. if (e.ctrlKey) switch (e.keyCode) {
  2436. case Inputmask.keyCode.UP:
  2437. $input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step)), $input.trigger("setvalue");
  2438. break;
  2439. case Inputmask.keyCode.DOWN:
  2440. $input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step)), $input.trigger("setvalue");
  2441. }
  2442. }
  2443. },
  2444. currency: {
  2445. prefix: "$ ",
  2446. groupSeparator: ",",
  2447. alias: "numeric",
  2448. placeholder: "0",
  2449. autoGroup: !0,
  2450. digits: 2,
  2451. digitsOptional: !1,
  2452. clearMaskOnLostFocus: !1
  2453. },
  2454. decimal: {
  2455. alias: "numeric"
  2456. },
  2457. integer: {
  2458. alias: "numeric",
  2459. digits: 0,
  2460. radixPoint: ""
  2461. },
  2462. percentage: {
  2463. alias: "numeric",
  2464. digits: 2,
  2465. digitsOptional: !0,
  2466. radixPoint: ".",
  2467. placeholder: "0",
  2468. autoGroup: !1,
  2469. min: 0,
  2470. max: 100,
  2471. suffix: " %",
  2472. allowMinus: !1
  2473. }
  2474. }), Inputmask;
  2475. }), function(factory) {
  2476. factory(window.dependencyLib || jQuery, window.Inputmask);
  2477. }(function($, Inputmask) {
  2478. function maskSort(a, b) {
  2479. 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];
  2480. return 0 === maskbs.indexOf(maskas) ? -1 : 0 === maskas.indexOf(maskbs) ? 1 : maska.localeCompare(maskb);
  2481. }
  2482. var analyseMaskBase = Inputmask.prototype.analyseMask;
  2483. return Inputmask.prototype.analyseMask = function(mask, opts) {
  2484. function reduceVariations(masks, previousVariation, previousmaskGroup) {
  2485. previousVariation = previousVariation || "", previousmaskGroup = previousmaskGroup || maskGroups,
  2486. "" !== previousVariation && (previousmaskGroup[previousVariation] = {});
  2487. for (var variation = "", maskGroup = previousmaskGroup[previousVariation] || previousmaskGroup, i = masks.length - 1; i >= 0; i--) mask = masks[i].mask || masks[i],
  2488. variation = mask.substr(0, 1), maskGroup[variation] = maskGroup[variation] || [],
  2489. maskGroup[variation].unshift(mask.substr(1)), masks.splice(i, 1);
  2490. for (var ndx in maskGroup) maskGroup[ndx].length > 500 && reduceVariations(maskGroup[ndx].slice(), ndx, maskGroup);
  2491. }
  2492. function rebuild(maskGroup) {
  2493. var mask = "", submasks = [];
  2494. 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]));
  2495. return mask += 1 === submasks.length ? submasks[0] : opts.groupmarker.start + submasks.join(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start) + opts.groupmarker.end;
  2496. }
  2497. var maskGroups = {};
  2498. opts.phoneCodes && (opts.phoneCodes && opts.phoneCodes.length > 1e3 && (mask = mask.substr(1, mask.length - 2),
  2499. reduceVariations(mask.split(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start)),
  2500. mask = rebuild(maskGroups)), mask = mask.replace(/9/g, "\\9"));
  2501. var mt = analyseMaskBase.call(this, mask, opts);
  2502. return mt;
  2503. }, Inputmask.extendAliases({
  2504. abstractphone: {
  2505. groupmarker: {
  2506. start: "<",
  2507. end: ">"
  2508. },
  2509. countrycode: "",
  2510. phoneCodes: [],
  2511. mask: function(opts) {
  2512. return opts.definitions = {
  2513. "#": Inputmask.prototype.definitions[9]
  2514. }, opts.phoneCodes.sort(maskSort);
  2515. },
  2516. keepStatic: !0,
  2517. onBeforeMask: function(value, opts) {
  2518. var processedValue = value.replace(/^0{1,2}/, "").replace(/[\s]/g, "");
  2519. return (processedValue.indexOf(opts.countrycode) > 1 || processedValue.indexOf(opts.countrycode) === -1) && (processedValue = "+" + opts.countrycode + processedValue),
  2520. processedValue;
  2521. },
  2522. onUnMask: function(maskedValue, unmaskedValue, opts) {
  2523. return unmaskedValue;
  2524. },
  2525. inputmode: "tel"
  2526. }
  2527. }), Inputmask;
  2528. }), function(factory) {
  2529. factory(window.dependencyLib || jQuery, window.Inputmask);
  2530. }(function($, Inputmask) {
  2531. return Inputmask.extendAliases({
  2532. Regex: {
  2533. mask: "r",
  2534. greedy: !1,
  2535. repeat: "*",
  2536. regex: null,
  2537. regexTokens: null,
  2538. 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,
  2539. quantifierFilter: /[0-9]+[^,]/,
  2540. isComplete: function(buffer, opts) {
  2541. return new RegExp(opts.regex, opts.casing ? "i" : "").test(buffer.join(""));
  2542. },
  2543. definitions: {
  2544. r: {
  2545. validator: function(chrs, maskset, pos, strict, opts) {
  2546. function RegexToken(isGroup, isQuantifier) {
  2547. this.matches = [], this.isGroup = isGroup || !1, this.isQuantifier = isQuantifier || !1,
  2548. this.quantifier = {
  2549. min: 1,
  2550. max: 1
  2551. }, this.repeaterPart = void 0;
  2552. }
  2553. function analyseRegex() {
  2554. var match, m, currentToken = new RegexToken(), opengroups = [];
  2555. for (opts.regexTokens = []; match = opts.tokenizer.exec(opts.regex); ) switch (m = match[0],
  2556. m.charAt(0)) {
  2557. case "(":
  2558. opengroups.push(new RegexToken((!0)));
  2559. break;
  2560. case ")":
  2561. groupToken = opengroups.pop(), opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(groupToken) : currentToken.matches.push(groupToken);
  2562. break;
  2563. case "{":
  2564. case "+":
  2565. case "*":
  2566. var quantifierToken = new RegexToken((!1), (!0));
  2567. m = m.replace(/[{}]/g, "");
  2568. 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]);
  2569. if (quantifierToken.quantifier = {
  2570. min: mq0,
  2571. max: mq1
  2572. }, opengroups.length > 0) {
  2573. var matches = opengroups[opengroups.length - 1].matches;
  2574. match = matches.pop(), match.isGroup || (groupToken = new RegexToken((!0)), groupToken.matches.push(match),
  2575. match = groupToken), matches.push(match), matches.push(quantifierToken);
  2576. } else match = currentToken.matches.pop(), match.isGroup || (groupToken = new RegexToken((!0)),
  2577. groupToken.matches.push(match), match = groupToken), currentToken.matches.push(match),
  2578. currentToken.matches.push(quantifierToken);
  2579. break;
  2580. default:
  2581. opengroups.length > 0 ? opengroups[opengroups.length - 1].matches.push(m) : currentToken.matches.push(m);
  2582. }
  2583. currentToken.matches.length > 0 && opts.regexTokens.push(currentToken);
  2584. }
  2585. function validateRegexToken(token, fromGroup) {
  2586. var isvalid = !1;
  2587. fromGroup && (regexPart += "(", openGroupCount++);
  2588. for (var mndx = 0; mndx < token.matches.length; mndx++) {
  2589. var matchToken = token.matches[mndx];
  2590. if (matchToken.isGroup === !0) isvalid = validateRegexToken(matchToken, !0); else if (matchToken.isQuantifier === !0) {
  2591. var crrntndx = $.inArray(matchToken, token.matches), matchGroup = token.matches[crrntndx - 1], regexPartBak = regexPart;
  2592. if (isNaN(matchToken.quantifier.max)) {
  2593. for (;matchToken.repeaterPart && matchToken.repeaterPart !== regexPart && matchToken.repeaterPart.length > regexPart.length && !(isvalid = validateRegexToken(matchGroup, !0)); ) ;
  2594. isvalid = isvalid || validateRegexToken(matchGroup, !0), isvalid && (matchToken.repeaterPart = regexPart),
  2595. regexPart = regexPartBak + matchToken.quantifier.max;
  2596. } else {
  2597. for (var i = 0, qm = matchToken.quantifier.max - 1; i < qm && !(isvalid = validateRegexToken(matchGroup, !0)); i++) ;
  2598. regexPart = regexPartBak + "{" + matchToken.quantifier.min + "," + matchToken.quantifier.max + "}";
  2599. }
  2600. } else if (void 0 !== matchToken.matches) for (var k = 0; k < matchToken.length && !(isvalid = validateRegexToken(matchToken[k], fromGroup)); k++) ; else {
  2601. var testExp;
  2602. if ("[" == matchToken.charAt(0)) {
  2603. testExp = regexPart, testExp += matchToken;
  2604. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2605. var exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "");
  2606. isvalid = exp.test(bufferStr);
  2607. } else for (var l = 0, tl = matchToken.length; l < tl; l++) if ("\\" !== matchToken.charAt(l)) {
  2608. testExp = regexPart, testExp += matchToken.substr(0, l + 1), testExp = testExp.replace(/\|$/, "");
  2609. for (var j = 0; j < openGroupCount; j++) testExp += ")";
  2610. var exp = new RegExp("^(" + testExp + ")$", opts.casing ? "i" : "");
  2611. if (isvalid = exp.test(bufferStr)) break;
  2612. }
  2613. regexPart += matchToken;
  2614. }
  2615. if (isvalid) break;
  2616. }
  2617. return fromGroup && (regexPart += ")", openGroupCount--), isvalid;
  2618. }
  2619. var bufferStr, groupToken, cbuffer = maskset.buffer.slice(), regexPart = "", isValid = !1, openGroupCount = 0;
  2620. null === opts.regexTokens && analyseRegex(), cbuffer.splice(pos, 0, chrs), bufferStr = cbuffer.join("");
  2621. for (var i = 0; i < opts.regexTokens.length; i++) {
  2622. var regexToken = opts.regexTokens[i];
  2623. if (isValid = validateRegexToken(regexToken, regexToken.isGroup)) break;
  2624. }
  2625. return isValid;
  2626. },
  2627. cardinality: 1
  2628. }
  2629. }
  2630. }
  2631. }), Inputmask;
  2632. });