UNPKG

liveinput

Version:
8 lines 20.6 kB
/** * liveinput - Input text auto changer * @version v1.0.8 * @link https://github.com/vahpetr/liveinput/ * @license Apache-2.0 */ var liveinput=new function(){var e,r,t,n,o,a,f,u,i,c,s,l,p,d,h,v=function(){return new function(){var e=Math.random,r=Function.prototype.bind?function(e,r){return e.bind(r)}:function(e,r){var t=Array.prototype.slice,n=t.call(arguments,2);return function(){return e.apply(r,n.concat(t.call(arguments)))}},t=function(e){return r(Function.prototype.call,e)},n=Array.prototype.filter?t(Array.prototype.filter):function(e,r){var t,n,o=[];for(t=0,n=e.length;n>t;t++)r(e[t],t,e)&&o.push(e[t]);return o},o=Array.prototype.map?t(Array.prototype.map):function(e,r){var t,n,o=[];for(t=0,n=e.length;n>t;t++)o.push(r(e[t],t,e));return o},a=Array.prototype.forEach?t(Array.prototype.forEach):function(e,r){for(var t=0,n=e.length;n>t;t++)r(e[t],t,e)},f=Array.prototype.indexOf?t(Array.prototype.indexOf):function(e,r){var t,n;for(t=0,n=e.length;n>t;t++)if(e[t]==r)return t;return-1},u=function(e,r){return n(e,function(e){return-1==f(r,e)})},i=function(e){return e.charCodeAt()},c=function(e){return o(e.split(""),i)},s=function(e){return String.fromCharCode.apply(void 0,e)},l=function(e,r,t){return e.addEventListener?e.addEventListener(r,t,!0):e.attachEvent("on"+r,t)},p=function(e,r,t){return e.removeEventListener?e.removeEventListener(r,t,!0):e.detachEvent("on"+r,t)},d=function(){return(16*e()|0).toString(16)},h=function(){return"00000000-0000-0000-0000-000000000000".replace(/0/g,d)},v=function(e,r){for(var t=0,n=r.length;n>t;t++)e=e.replace(new RegExp("\\{"+t+"\\}","g"),r[t]);return e},g=function(e,r){var t,n=[];for(t=0;e>t;t++)n.push(r(t,e,n));return n},m=function(e){var r,t,n,o,a,f;return void 0!=e.selectionEnd?e.selectionStart:(r=document.selection.createRange(),t=e.createTextRange(),t.moveToBookmark(r.getBookmark()),n=e.createTextRange(),n.collapse(!1),o=e.value.length,t.compareEndPoints("StartToEnd",n)>-1?o:(a=-t.moveStart("character",-o),f=e.value.replace(/\r\n/g,"\n"),a+=f.slice(0,a).split("\n").length-1))},y=function(e){var r,t,n,o,a,f;return void 0!=e.selectionEnd?e.selectionEnd:(r=document.selection.createRange(),t=e.createTextRange(),t.moveToBookmark(r.getBookmark()),n=e.createTextRange(),n.collapse(!1),o=e.value.length,t.compareEndPoints("StartToEnd",n)>-1?o:(a=e.value.replace(/\r\n/g,"\n"),f=-t.moveEnd("character",-o),f+=a.slice(0,f).split("\n").length-1))},x=function(e,r){if(e.setSelectionRange)return e.setSelectionRange(r.start,r.end);var t=e.createTextRange();t.collapse(!0),t.moveStart("character",r.start),t.moveEnd("character",r.end-r.start),t.select()},k=function(e){var r,t=[];for(r in e)e.hasOwnProperty(r)&&t.push(r);return t},w=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},b=function(e,r){if(r)for(var t in r)e[t]=r[t]},E=function(e,r,t){var n;return document.createEvent?(n=document.createEvent("HTMLEvents"),b(n,t),n.initEvent(r,!1,!1),e.dispatchEvent(n)):(n=document.createEventObject(),b(n,t),void setTimeout(function(){try{e.fireEvent("on"+r,n)}catch(t){}},0))},C=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},O=function(e){return JSON.parse(JSON.stringify(e))};return{charToCode:i,textToCodes:c,codesToText:s,GUID:h,format:v,fill:g,getSelectionStart:m,getSelectionEnd:y,setCaretPosition:x,getOwnPropertyNames:k,bind:r,filter:n,map:o,forEach:a,except:u,indexOf:f,isArray:w,event:{add:l,remove:p,call:E},preventDefault:C,copy:O}}}(),g=function(e){var r,t=this,n=Math.max,o=Math.min;return t.start=0,t.end=0,t.range=!1,t.moveBack=!1,t.press=function(){t.range||(t.end=t.start=v.getSelectionStart(e))},t.release=function(){t.end=v.getSelectionEnd(e)},t.change=function(){t.start=v.getSelectionStart(e),t.end=v.getSelectionEnd(e)},t.move=function(a){return t.range?(t.restore(),void(t.range=!1)):(r=(t.moveBack?o:n)(t.start-a,t.end-a),v.setCaretPosition(e,{start:r,end:r}),t.press(),void(t.moveBack=!1))},t.selectAll=function(){v.setCaretPosition(e,{start:0,end:e.value.length}),t.change()},t.restore=function(){v.setCaretPosition(e,{start:t.start,end:t.end})},t},m=["ru","en"],y=[192,49,50,51,52,53,54,55,56,57,48,189,187,81,87,69,82,84,89,85,73,79,80,219,221,65,83,68,70,71,72,74,75,76,186,222,220,226,90,88,67,86,66,78,77,188,190,191,111,106,109,107,12],x={keyCodes:[32,13],charCodes:[32,10,8]};return y.push.apply(y,x.keyCodes),e={control:{50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",222:"'"},shift:{ru:{192:"ё",50:'"',51:"№",52:";",54:":",55:"?",219:"х",221:"ъ",186:"ж",222:"э",220:"/",188:"б",190:"ю",191:",",226:"/"},en:{192:"~",50:"@",51:"#",52:"$",54:"^",55:"&",186:":",222:'"',220:"|",188:"<",190:">",191:"?",226:"|"}}},r=function(e){return Number(e)},t=function(e){var t=v.getOwnPropertyNames(e);return v.map(t,r)},n={control:t(e.control),shift:{ru:t(e.shift.ru),en:t(e.shift.en)}},o={},o.layout=function(e,r){var t,n,o,a,f,u,i,c,s,l,p,d,h,g,y,k,w,b=this;b.type=r,t=e.lang,n={ru:[1105,1081,1094,1091,1082,1077,1085,1075,1096,1097,1079,1092,1099,1074,1072,1087,1088,1086,1083,1076,1103,1095,1089,1084,1080,1090,1100,1025,1049,1062,1059,1050,1045,1053,1043,1064,1065,1047,1060,1067,1042,1040,1055,1056,1054,1051,1044,1071,1063,1057,1052,1048,1058,1068,1093,1098,92,49,51,53,56,57,48,45,61,1061,1066,47,33,8470,37,42,40,41,95,43],en:[96,113,119,101,114,116,121,117,105,111,112,97,115,100,102,103,104,106,107,108,122,120,99,118,98,110,109,126,81,87,69,82,84,89,85,73,79,80,65,83,68,70,71,72,74,75,76,90,88,67,86,66,78,77,91,93,92,49,51,53,56,57,48,45,61,123,125,124,33,35,37,42,40,41,95,43]};for(o in n)n[o].push.apply(n[o],x.charCodes);a={50:[[50,34],[50,64]],52:[[52,59],[52,36]],54:[[54,58],[54,94]],55:[[55,63],[55,38]],186:[[1078,1046],[59,58]],222:[[1101,1069],[39,34]],188:[[1073,1041],[44,60]],190:[[1102,1070],[46,62]],191:[[46,44],[47,63]]},f={50:64,51:35,52:36,53:37,54:94,222:39},u={};for(i in a)u[i]={};for(c=0,s=m.length;s>c;c++)for(i in a)u[i][m[c]]=a[i][c];return l=t?v.except(m,[t]):m,w=l.length,b.exec=function(e,r){if(!r.keydown.length)return e;d=e.diff,k=d.length;var o=[];for(c=0,s=d.length;s>c;c++)if(h=d[c],y=!1,g=v.indexOf(n[t],h),-1==g){for(p=0;w>p;p++)if(g=v.indexOf(n[l[p]],h),-1!=g){o.push(n[t][g]),y=!0;break}if(!y)if(r.keydown[c].ctrlKey&&f[r.keydown[c].keyCode]==h)o.push(h);else{if(!u[r.keydown[c].keyCode])break;if(g=v.indexOf(u[r.keydown[c].keyCode][t],h),-1==g){for(p=0;w>p;p++)if(g=v.indexOf(u[r.keydown[c].keyCode][l[p]],h),-1!=g){o.push(u[r.keydown[c].keyCode][t][g]),y=!0;break}y||r.keydown.splice(c,1)}else o.push(h)}}else o.push(h);return e.diff=o,e.offset+=k-e.diff.length,e},b.get=function(){return{type:r,enabled:e.lang?!0:!1,config:e}},b},o.include=function(e,r){var t,n,o,a,f,u,i,c,s,l,p,d,h,g=this;for(g.type=r,t=e.lang||"",n=[],v.forEach(["numbers","symbols"],function(r){e[r]&&n.push(r)}),o=e.special||"",i=t?[t]:m,a=0,f=i.length;f>a;a++)u=v.indexOf(n,i[a]),-1==u&&n.push(i[a]);return o=v.textToCodes(o),o.length&&-1==v.indexOf(n,"special")&&n.push("special"),e.chars||v.forEach(m,function(e){u=v.indexOf(n,e),-1!=u&&n.splice(u,1)}),c={ru:[1092,1099,1074,1072,1087,1088,1086,1083,1076,1081,1094,1091,1082,1077,1085,1075,1096,1097,1079,1103,1095,1089,1084,1080,1090,1100,1093,1098,1078,1101,1073,1102,1105,1060,1067,1042,1040,1055,1056,1054,1051,1044,1049,1062,1059,1050,1045,1053,1043,1064,1065,1047,1071,1063,1057,1052,1048,1058,1068,1061,1066,1046,1069,1041,1070,1025],en:[97,115,100,102,103,104,106,107,108,113,119,101,114,116,121,117,105,111,112,122,120,99,118,98,110,109,65,83,68,70,71,72,74,75,76,81,87,69,82,84,89,85,73,79,80,90,88,67,86,66,78,77],numbers:[48,49,50,51,52,53,54,55,56,57],symbols:[32,10,96,45,61,126,33,64,35,36,37,94,38,42,40,41,95,43,91,93,59,39,92,44,46,47,123,125,58,34,124,60,62,63,8470],special:o},h=n.length,g.exec=function(e,r){l=e.diff,p=l.length;var t=[];for(a=0,f=l.length;f>a;a++){for(d=!1,s=0;h>s;s++)if(u=v.indexOf(c[n[s]],l[a]),-1!=u){t.push(l[a]),d=!0;break}d||r.keydown.splice(a,1)}return e.diff=t,e.offset+=p-e.diff.length,e},g.get=function(){return{type:r,enabled:n.length||o.length?!0:!1,config:e}},g},o.exclude=function(e,r){var t,n,o,a,f,u,i;return delete e.lang,t=this,t.type=r,n=e.special||"",n=v.textToCodes(n),t.exec=function(e){u=e.diff,i=u.length;var r=[];for(o=0,a=u.length;a>o;o++)f=v.indexOf(n,u[o]),-1==f&&r.push(u[o]);return e.diff=r,e.offset+=i-e.diff.length,e},t.get=function(){return{type:r,enabled:n.length?!0:!1,config:e}},t},o.input=function(e,r){var t,n,o,a,f,u,i,c,s,l,p,d,h,g,y,x,k,w,b,E,C=this;return C.type=r,t=e.lang,n=e.register,o=e.capslock,a={ru:{lower:[1092,1099,1074,1072,1087,1088,1086,1083,1076,1078,1101,1081,1094,1091,1082,1077,1085,1075,1096,1097,1079,1093,1098,1103,1095,1089,1084,1080,1090,1100,1073,1102,1105],upper:[1060,1067,1042,1040,1055,1056,1054,1051,1044,1046,1069,1049,1062,1059,1050,1045,1053,1043,1064,1065,1047,1061,1066,1071,1063,1057,1052,1048,1058,1068,1041,1070,1025]},en:{lower:[97,115,100,102,103,104,106,107,108,113,119,101,114,116,121,117,105,111,112,122,120,99,118,98,110,109],upper:[65,83,68,70,71,72,74,75,76,81,87,69,82,84,89,85,73,79,80,90,88,67,86,66,78,77]}},f=t?[t]:m,u=v.except(v.getOwnPropertyNames(a[f[0]]),[n])[0],i=["register","capslock"],w=f.length,b=i.length,E={},E.register=function(e){d=e.diff,x=d.length;var r=[];for(c=0,s=d.length;s>c;c++){for(h=!1,l=0;w>l;l++)if(p=v.indexOf(a[f[l]][u],d[c]),-1!=p){r.push(a[f[l]][n][p]),h=!0;break}h||r.push(d[c])}return e.diff=r,e.offset+=x-e.diff.length,e},E.capslock=function(e,r){if(!r.keydown.length)return e;d=e.diff,x=d.length;var t=[];for(c=0,s=d.length;s>c;c++){for(h=!1,g=n||(r.keydown[c].shiftKey?"upper":"lower"),n&&r.keydown[c].shiftKey&&(g="upper"==g?"lower":"upper"),y="upper"==g?"lower":"upper",l=0;w>l;l++)if(p=v.indexOf(a[f[l]][g],d[c]),-1==p&&(p=v.indexOf(a[f[l]][y],d[c]),-1!=p)){t.push(a[f[l]][g][p]),h=!0;break}h||t.push(d[c])}return e.diff=t,e.offset+=x-e.diff.length,e},C.exec=function(r,t){var n=r;for(k=0;b>k;k++)e[i[k]]&&(n=E[i[k]](n,t));return n},C.get=function(){return{type:r,enabled:n||o?!0:!1,config:e}},C},o.regexulator=function(e,r){var t,n,o,a,f,u,i,c,s,l,p,d,h,g,m,y,x,k,w,b,E,C,O,T=this;T.type=r,delete e.lang,t={"after-chars-remove-chars":"((?:{0})+)(?:{1})+","after-term-remove-chars":"((?:^|\\s)+{0}\\s+)(?:{1})+","after-chars-remove-term":"((?:{0})+)\\s+{1}\\s+","after-term-remove-term":"((?:^|\\s)+{0}\\s+){1}\\s+","before-chars-remove-chars":"(?:{1})+((?:{0})+)","before-term-remove-chars":"(?:{1})+(\\s+{0}\\s+)","before-chars-remove-term":"(?:^|\\s)+{1}\\s+((?:{0})+)","before-term-remove-term":"(?:^|\\s)+{1}\\s+({0}\\s+)","after-char-remove-repeat":"({0}){1}+","after-char-replace-expr":"({0}{1})","after-term-replace-expr":"(?:^|\\s)+({0}\\s+{1})","after-char-upper-char":"({0}[a-zа-яё])"},n={"[":"\\[","]":"\\]","\\":"\\\\","/":"\\/","^":"\\^",$:"\\$",".":"\\.","|":"\\|","?":"\\?","*":"\\*","+":"\\+","(":"\\(",")":"\\)","{":"\\{","}":"\\}","'":"\\'","":"^"},i={},c={},s=[],l=[],p=function(e){return n[e]||e},d=function(e){var r=e.split("");return r.length||r.push(""),v.map(r,p)},h=function(e){return[d(e).join("|")]},g=function(e){return[d(e).join("")]},m=function(e,r){return v.format(t[e],r)},y={},y["after-chars-remove-chars"]=function(e,r,t){for(var n in e)v.forEach(h(n),function(o){v.forEach(h(e[n]),function(e){i[t].push(m(r,[o,e]))})})},y["after-chars-remove-term"]=function(e,r,t){for(var n in e)v.forEach(h(n),function(o){v.forEach(g(e[n]),function(e){i[t].push(m(r,[o,e]))})})},y["after-term-remove-chars"]=function(e,r,t){for(var n in e)v.forEach(g(n),function(o){v.forEach(h(e[n]),function(e){i[t].push(m(r,[o,e]))})})},y["after-term-remove-term"]=function(e,r,t){for(var n in e)v.forEach(g(n),function(o){v.forEach(g(e[n]),function(e){i[t].push(m(r,[o,e]))})})},y["after-char-remove-repeat"]=function(e,r,t){v.forEach(d(e),function(e){i[t].push(m(r,[e,e]))})},y["before-chars-remove-chars"]=y["after-chars-remove-chars"],y["before-chars-remove-term"]=y["after-chars-remove-term"],y["before-term-remove-chars"]=y["after-term-remove-chars"],y["before-term-remove-term"]=y["after-term-remove-term"],y["after-char-replace-expr"]=function(e,r,t){for(var n in e)v.forEach(d(n),function(o){c[t].push({expr:m(r,[o,e[n].expr]),replacer:e[n].replacer})})},y["after-char-upper-char"]=function(e,r,t){var n,o,a={},f=v.isArray(e)?e:[e];for(n=0,o=f.length;o>n;n++)a[f[n]]={expr:"[a-zа-яё]",replacer:function(e,r,t,n,o,a){return n=1==e.length?"":e.charAt(0),o.keydown.length&&o.keydown[a].shiftKey?n+e.charAt(e.length-1).toLowerCase():n+e.charAt(e.length-1).toLocaleUpperCase()}};y["after-char-replace-expr"](a,"after-char-replace-expr",t)},y["after-term-replace-expr"]=function(e,r,t){for(var n in e)v.forEach(g(n),function(o){c[t].push({expr:m(r,[o,e[n].expr]),replacer:e[n].replacer})})};for(x in e){if(/[^igm]/g.test(x))throw new Error("Command regexulator can not support flag "+x);x=x.split("").sort().join(""),i[x]=i[x]||[],c[x]=c[x]||[],v.forEach(["after-chars-remove-chars","after-term-remove-chars","after-chars-remove-term","after-term-remove-term","before-chars-remove-chars","before-term-remove-chars","before-chars-remove-term","before-term-remove-term","after-char-replace-expr","after-term-replace-expr","after-char-remove-repeat","after-char-upper-char"],function(r){void 0!=e[x][r]&&y[r](e[x][r],r,x)})}for(x in i)i[x].length&&s.push({expr:new RegExp(i[x].join("|"),x),replacer:v.fill(i[x].length,function(e){return"$"+(e+1)}).join("")});k=function(e){return e.expr};for(x in c)c[x].length&&l.push({expr:new RegExp(v.map(c[x],k).join("|"),x),replacer:c[x][0].replacer});return O=function(e){for(w=e[0],E=e[e.length-2],C=e[e.length-1],f=1,u=e.length-2;u>f;f++)if(void 0!=e[f]){b=e[f];break}},T.exec=function(e,r){for(o=0,a=s.length;a>o;o++)e=e.replace(s[o].expr,s[o].replacer);for(o=0,a=l.length;a>o;o++)e=e.replace(l[o].expr,function(){return O(arguments),r.cursor.start<=E+1&&E+1<=r.cursor.end?(u=r.before.length+r.diff.length-E-w.length,r.keydown[u]||(u=0),l[o].replacer(w,b,E,C,r,u)):w});return e},T.get=function(){return{type:r,enabled:s.length||l.length?!0:!1,config:e}},T},a=function(e){var r,t,n,a,f=this,u=[],i=["layout","include","exclude","input"];for(r=0,t=i.length;t>r;r++)e[i[r]]&&(!0===e[i[r]]&&(e[i[r]]={}),u.push(new o[i[r]](e[i[r]],i[r])));for(a=0;a<u.length;a++)u[a].get().enabled||u.splice(a--,1);return t=u.length,f.pass=function(e,o){for(n=e,r=0,a=o.keydown.length;a>r;r++)o.keydown[r]&&8==o.keydown[r].keyCode&&(o.keydown.splice(r,1),n.diff.splice(r,1));for(r=0;t>r;r++)n=u[r].exec(n,o);return n.before=v.codesToText(n.before),n.diff=v.codesToText(n.diff),n.after=v.codesToText(n.after),n.offset=e.offset,n},f.config=function(){var e,n={};for(r=0;t>r;r++)e=u[r].get(),n[e.type]=e.config;return n},f},f=function(e){var r,t,n,a,f,u=this,i=[],c=["regexulator"];for(r=0,t=c.length;t>r;r++)e[c[r]]&&(!0===e[c[r]]&&(e[c[r]]={}),i.push(new o[c[r]](e[c[r]],c[r])));for(f=0;f<i.length;f++)i[f].get().enabled||i.splice(f--,1);return t=i.length,u.pass=function(e,o){for(n=e,a=n.length,r=0;t>r;r++)n=i[r].exec(n,o);return o.result.offset+=a-n.length,n},u.config=function(){var e,n={};for(r=0;t>r;r++)e=i[r].get(),n[e.type]=e.config;return n},u},u=function(r){var t,o,u,i=this,c=r.lang,l=r.interval,p=new a(r),d=new f(r),h={},m=function(e,r,t){t.old!=e.value&&(t.value=e.value,v.event.call(e,"liveinput",t))},x=function(e,r,n,a,f){if(r[n])for(t=r[n],o=0,u=t.length;u>o;o++)t[o].apply(a,f)},k=function(r,t,n,o,a,f){return o.release(),8==r.keyCode?(n.before=t.value.substring(0,o.end),n.diff="",n.after=t.value.substring(o.end)):(n.before=t.value.substring(0,o.start),n.diff=t.value.substring(o.start,o.end),n.after=t.value.substring(o.end)),n.result.offset=r.ctrlKey?-n.diff.length:8==r.keyCode&&o.start==o.end+1?1:0,r.ctrlKey&&e.control[r.keyCode]&&(n.diff+=e.control[r.keyCode],n.result.offset--),r.shiftKey&&e.shift[c]&&e.shift[c][r.keyCode]&&(n.diff+=e.shift[c][r.keyCode],n.result.offset--),n.result=p.pass({before:v.textToCodes(n.before),diff:v.textToCodes(n.diff),after:v.textToCodes(n.after),offset:n.result.offset},n),n.result.value=n.result.before+n.result.diff+n.result.after,n.result.value=d.pass(n.result.value,n),t.value=n.result.value,x(t,a,"change",f,[n.result.value,n.old,c]),m(t,"liveinput",f.event),f.event.old=n.old=t.value,o.move(n.result.offset),n.keydown=[],f.timer=null,!0},w=function(e){if(e.value.length&&r.refresh){var t=h[e.GUID];clearTimeout(t.timer),t.timer||t.cursor.selectAll(),k({keyCode:0},e,t.data,t.cursor,t.events,t)}},b=function(e,r,t,o,a,f){if(e.ctrlKey)switch(e.keyCode){case 90:case 67:return!1;case 89:return v.preventDefault(e),!1;case 65:o.selectAll(),o.range=!0;break;case 8:o.moveBack=!0}return t.mousedown?(v.preventDefault(e),!1):-1==v.indexOf(y,e.keyCode)?(f.timer&&w(r),!1):(clearTimeout(f.timer),t.keydown.push({keyCode:e.keyCode,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey}),f.timer||o.press(),f.timer=setTimeout(function(){k(t.keydown[t.keydown.length-1],r,t,o,a,f)},l),e.ctrlKey&&-1!=v.indexOf(n.control,e.keyCode)?(v.preventDefault(e),!1):e.shiftKey&&n.shift[c]&&-1!=v.indexOf(n.shift[c],e.keyCode)?(v.preventDefault(e),!1):!0)},E=function(e){var r,t,n,o;e.GUID||(e.GUID=v.GUID()),r=h[e.GUID]={},r.el=e,r.event={old:""},r.data={keydown:[],result:{},old:""},r.cursor=new g(e),t=r.data,n=r.data.cursor=r.cursor,o=r.events={},r.keydown=function(a){b(a,e,t,n,o,r)},r.paste=function(){return t.keydown=[],!0},r.dragover=function(e){return v.preventDefault(e),!1},r.mousedown=function(){r.data.mousedown=!0,w(e)},r.mouseup=function(){r.data.mousedown=!1},r.mouseleave=function(){r.data.mousedown=!1},r.blur=function(){w(e)},window.ptr=r,v.event.add(e,"keydown",r.keydown),v.event.add(e,"paste",r.paste),v.event.add(e,"mousedown",r.mousedown),v.event.add(e,"mouseup",r.mouseup),v.event.add(e,"mouseleave",r.mouseleave),v.event.add(e,"dragover",r.dragover),v.event.add(e,"blur",r.blur),w(e)},C=function(e){var t,n,o,a,f,u;if(e.GUID&&h[e.GUID]){t=h[e.GUID],v.event.remove(e,"keydown",t.keydown),v.event.remove(e,"paste",t.paste),v.event.remove(e,"mousedown",t.mousedown),v.event.remove(e,"mouseup",t.mouseup),v.event.remove(e,"mouseleave",t.mouseleave),v.event.remove(e,"dragover",t.dragover),v.event.remove(e,"blur",t.blur),n=t.events;for(o in n)n[o].length=0,delete n[o];a=v.getOwnPropertyNames(t);for(f in a)delete t[f];delete h[e.GUID],v.getOwnPropertyNames(h).length||(u=JSON.stringify(r),delete s[u])}};return i.bind=function(){for(var e=0,r=arguments.length;r>e;e++)E(arguments[e]);return i},i.unbind=function(){for(var e=0,r=arguments.length;r>e;e++)C(arguments[e]);return i},i.on=function(e,r,t){if(!r.GUID||!h[r.GUID])return i;switch(h[r.GUID].events[e]=h[r.GUID].events[e]||[],h[r.GUID].events[e].push(t),e){case"change":r.value.length&&w(r)}return i},i.off=function(e,r,t){return r.GUID&&h[r.GUID]?(o=v.indexOf(h[r.GUID].events[e],t),-1==o?i:(h[r.GUID].events[e].splice(o,1),i)):i},i.refresh=function(e){h[e.GUID]&&w(e)},i},i=function(e){var r,t;if("undefined"!=typeof e.lang){r=e.lang;for(t in e)e[t]&&(1==e[t]&&(e[t]={}),e[t].lang=r)}},c=function(e,r){if(!r)return e;for(var t in r)e[t]="object"==typeof e[t]?c(e[t],r[t]):r[t];return e},s={},l={"default":{lang:"",interval:1e3/24,refresh:!0,layout:!0,include:{chars:!0,numbers:!0,symbols:!0,special:""},exclude:{special:"{}[]"},input:{register:"",capslock:!1},regexulator:{g:{}}},fio:function(){var e=" '-";return{include:{numbers:!1,symbols:!1,special:e},regexulator:{g:{"after-char-remove-repeat":e,"after-char-upper-char":["'",""],"after-chars-remove-chars":{"":e}}}}}(),numeric:{include:{chars:!1,numbers:!0,symbols:!1,special:""}},address:function(){var e="-/";return{lang:"",include:{symbols:!1,special:e},input:{register:"upper",capslock:!0},regexulator:{g:{"after-char-remove-repeat":e,"after-chars-remove-chars":{"":e}}}}}(),month:{interval:700,include:{numbers:!0,symbols:!1},input:{capslock:!1},regexulator:{g:{"after-char-remove-repeat":"0","after-char-upper-char":""}}}},p=function(e){c(l,e)},p.get=function(e){return v.copy(l[e])},p.merge=function(){var e,r,t,n=p.get("default");for(e=0,r=arguments.length;r>e;e++)if("default"!=arguments[e]){if(t=arguments[e],"string"==typeof t){if(!l[t])throw new Error("Can not find liveinput type "+t);t=l[t]}c(n,t)}return n},p.add=function(e,r){if(l[e])throw new Error("Can not add exist liveinput type "+e);l[e]=r},d=function(e,r){var t,n,o;return("object"==typeof e||"undefined"==typeof e)&&(r=e,e="default"),t=p.merge(e,r),i(t),n=JSON.stringify(t),o=s[n]||(s[n]=new u(t))},h=function(e,r){e.value=r;for(var t in s)s[t].refresh(e)},{init:d,configuration:p,set:h}};"undefined"!=typeof module?module.exports=liveinput:window&&(window.liveinput=liveinput); //# sourceMappingURL=liveinput.min.js.map