jquery.inputmask.bundle.js 163 KB

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