jquery.inputmask.bundle.js 189 KB

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