(function(){if(BX.MaskedInput)return;var t={cypher:{"char":"9",rule:"[0-9]"},hexrgb:{"char":"h",rule:"[A-Fa-f0-9]"},lang_en:{"char":"a",rule:"[a-zA-Z]"}};BX.MaskedInput=function(t){this.mask=t.mask||"";this.placeholder=(t.placeholder||"_").substring(0,1);this.definitions=this.prepareDefinitions(t.definitions||["cypher","lang_en"]);this.stopChangeEvent=false;this.initInput(t)};BX.MaskedInput.prototype.initInput=function(t){if(t.input.tagName=="INPUT"){this.input=new BX.MaskedInputElement({node:t.input})}else{this.input=new BX.MaskedTextElement({node:t.input})}this.dataInput=t.dataInput||null;this.isDataInputClean=t.isDataInputClean||false;this.isHoldOverInputValueInit=t.isHoldOverInputValueInit||false;this.enableCheckingValue=t.enableCheckingValue||false;this.onDataInputChange=t.onDataInputChange||null;this.onDataInputInitValue=t.onDataInputInitValue||null;BX.addCustomEvent(this.input,"change",BX.proxy(this.onInputChange,this));BX.addCustomEvent(this.input,"paste",BX.proxy(this.onInputPaste,this));BX.addCustomEvent(this.input,"delete",BX.proxy(this.onInputDelete,this));BX.bind(this.input.node,"focus",BX.proxy(function(){if(this.getFirstEmptyPosition()===null){return}setTimeout(BX.proxy(function(){this.moveCaret(this.getFirstEmptyPosition())},this),50)},this));if(!this.isHoldOverInputValueInit&&!this.test(this.input.val())){this.input.val(this.getMaskedPlaceholder())}if(this.dataInput){var e=this.dataInput.value;if(BX.type.isFunction(this.onDataInputInitValue)){e=this.onDataInputInitValue.apply(this,[e])}if(BX.type.isString(e)&&e.length>0){this.setValue(e)}BX.addCustomEvent(this,"change",BX.proxy(function(){var t="";if(BX.type.isFunction(this.onDataInputChange)){t=this.onDataInputChange.apply(this,[this.getValueClean(),this.getValue()])}else if(this.isDataInputClean){t=this.getValueClean()}else{t=this.getValue()}if(!BX.type.isString(t)){t=""}if(this.enableCheckingValue&&!this.checkValue()){t=""}this.dataInput.value=t},this))}};BX.MaskedInput.prototype.setMask=function(t){if(this.mask==t){return}var e=this.getValueClean();this.mask=t;this.setChangeEventFiring(false);this.setValue(e);this.setChangeEventFiring(true)};BX.MaskedInput.prototype.getMask=function(){return this.mask};BX.MaskedInput.prototype.setValue=function(t){if(!this.mask){this.input.val(t);this.fireChangeEvent();return}var e=this.input.getSelectionStart();this.moveCaret(0);this.input.val(this.mask);var n=0;for(var i=0;ithis.mask.length){t=this.mask.length}else if(t<0){t=0}else if(t===null){return this.input.getSelectionStart()}this.input.setCaretPosition(t);return t};BX.MaskedInput.prototype.findClosestAllowPosition=function(t,e,n){if(typeof t==="undefined"){t=0}if(typeof e==="undefined"){e=null}if(typeof n==="undefined"){n=false}while(true){if(!n&&t>=this.mask.length){return null}else if(n&&t<=0){return 0}if(this.isMaskCharReplaceable(t)){break}if(!n){t++}else{t--}}if(!this.isMaskCharReplaceable(t)){return null}if(e&&!this.testChar(t,e)){return null}return t};BX.MaskedInput.prototype.setCharOnCaret=function(t){var e=this.input.getSelectionStart();e=this.findClosestAllowPosition(e,t);if(e===null){return}this.shift(e,e+1);e=this.replaceChar(e,t);if(e===null){return}e=this.findClosestAllowPosition(e+1);this.moveCaret(e);if(BX.browser.IsAndroid()&&BX.browser.DetectAndroidVersion()<7){var n=this;setTimeout(function(){n.moveCaret(e)},50)}};BX.MaskedInput.prototype.shift=function(t,e){var n,i=null;var s=[];for(n=t;n0){i=s.pop()}else{i=this.placeholder}this.replaceChar(n,i)}};BX.MaskedInput.prototype.deleteSelection=function(){var t=this.input.getSelectionStart();var e=this.input.getSelectionEnd();if(t==e){return false}for(var n=t;n=n.length?"":n.substring(t+1);n=i;this.input.val(n);return t};BX.MaskedInput.prototype.isMaskCharReplaceable=function(t){var e=this.mask.charAt(t);if(!e){return false}return!!this.definitions[e]};BX.MaskedInput.prototype.getMaskedPlaceholder=function(){var t="";for(var e=0;e46&&i<=90||i>145||i===13||i===8||i===46||BX.browser.IsIOS()&&i===127));break;case"keypress":break}if(!n){return}BX.PreventDefault(e||t);if(t.type=="paste"){var s=t.clipboardData||window.clipboardData;var a=s.getData("Text");BX.onCustomEvent(this,"paste",[a])}else if(i===8||i===46||BX.browser.IsIOS()&&i===127){var r=i===8;BX.onCustomEvent(this,"delete",[r])}else{var h=String.fromCharCode(i);BX.onCustomEvent(this,"change",[h])}};BX.MaskedInputElement.prototype.setCaretPosition=function(t){this.node.setSelectionRange(t,t)};BX.MaskedInputElement.prototype.getSelectionStart=function(){if(this.node.selectionStart){return this.node.selectionStart}else if(this.node.createTextRange){var t=this.node.createTextRange().duplicate();t.moveEnd("character",this.node.value.length);if(t.text==""){return this.node.value.length}else{return this.node.value.lastIndexOf(t.text)}}else{return 0}};BX.MaskedInputElement.prototype.getSelectionEnd=function(){if(this.node.selectionEnd){return this.node.selectionEnd}else if(this.node.createTextRange){var t=this.node.createTextRange().duplicate();t.moveStart("character",-this.node.value.length);return t.text.length}else{return 0}};BX.MaskedTextElement=function(t){this.node=t.node};BX.MaskedTextElement.prototype.val=function(t){if(typeof t!="undefined"){this.node.innerText=t}return this.node.innerText};BX.MaskedTextElement.prototype.onChange=function(t){};BX.MaskedTextElement.prototype.setCaretPosition=function(t){};BX.MaskedTextElement.prototype.getSelectionStart=function(){return 0};BX.MaskedTextElement.prototype.getSelectionEnd=function(){return 0}})(); //# sourceMappingURL=masked_input.map.js