//>>built
define("dojox/string/BidiComplex","dojo/_base/kernel,dojo/_base/lang,dojo/_base/array,dojo/_base/connect,dojo/_base/sniff,dojo/keys".split(","),function(o,p,m,k,j,i){o.experimental("dojox.string.BidiComplex");var c=p.getObject("string.BidiComplex",!0,dojox),n=[];c.attachInput=function(a,b){a.alt=b;k.connect(a,"onkeydown",this,"_ceKeyDown");k.connect(a,"onkeyup",this,"_ceKeyUp");k.connect(a,"oncut",this,"_ceCutText");k.connect(a,"oncopy",this,"_ceCopyText");a.value=c.createDisplayString(a.value,a.alt)};
c.createDisplayString=function(a,b){var a=c.stripSpecialCharacters(a),h=c._parse(a,b),d="\u202a"+a,g=1;m.forEach(h,function(a){if(null!=a){var b=d.substring(0,a+g),a=d.substring(a+g,d.length);d=b+"\u200e"+a;g++}});return d};c.stripSpecialCharacters=function(a){return a.replace(/[\u200E\u200F\u202A-\u202E]/g,"")};c._ceKeyDown=function(a){n=(j("ie")?a.srcElement:a.target).value};c._ceKeyUp=function(a){var b=j("ie")?a.srcElement:a.target,h=b.value,d=a.keyCode;if(!(d==i.HOME||d==i.END||d==i.SHIFT)){var g,
e;if(a=c._getCaretPos(a,b))g=a[0],e=a[1];if(j("ie")){var a=g,f=e;if(d==i.LEFT_ARROW){"\u200e"==h.charAt(e-1)&&g==e&&c._setSelectedRange(b,g-1,e-1);return}if(d==i.RIGHT_ARROW){"\u200e"==h.charAt(e-1)&&(f=e+1,g==e&&(a=g+1));c._setSelectedRange(b,a,f);return}}else{if(d==i.LEFT_ARROW){"\u200e"==h.charAt(e-1)&&c._setSelectedRange(b,g-1,e-1);return}if(d==i.RIGHT_ARROW){"\u200e"==h.charAt(e-1)&&c._setSelectedRange(b,g+1,e+1);return}}a=c.createDisplayString(h,b.alt);if(h!=a){window.status=h+" c="+e;b.value=
a;if(d==i.DELETE&&"\u200e"==a.charAt(e))b.value=a.substring(0,e)+a.substring(e+2,a.length);d==i.DELETE?c._setSelectedRange(b,g,e):d==i.BACKSPACE?n.length>=e&&"\u200e"==n.charAt(e-1)?c._setSelectedRange(b,g-1,e-1):c._setSelectedRange(b,g,e):"\u200e"!=b.value.charAt(e)&&c._setSelectedRange(b,g+1,e+1)}}};c._processCopy=function(a,b){null==b&&(b=j("ie")?document.selection.createRange().text:a.value.substring(a.selectionStart,a.selectionEnd));var h=c.stripSpecialCharacters(b);j("ie")&&window.clipboardData.setData("Text",
h);return!0};c._ceCopyText=function(a){if(j("ie"))a.returnValue=!1;return c._processCopy(a,null,!1)};c._ceCutText=function(a){if(!c._processCopy(a,null,!1))return!1;if(j("ie"))document.selection.clear();else{var b=a.selectionStart;a.value=a.value.substring(0,b)+a.value.substring(a.selectionEnd);a.setSelectionRange(b,b)}return!0};c._getCaretPos=function(a,b){if(j("ie")){var h=0,d=document.selection.createRange().duplicate(),c=d.duplicate(),e=d.text.length;for("textarea"==b.type?c.moveToElementText(b):
c.expand("textedit");0<d.compareEndPoints("StartToStart",c);)d.moveStart("character",-1),++h;return[h,h+e]}return[a.target.selectionStart,a.target.selectionEnd]};c._setSelectedRange=function(a,b,c){if(j("ie")){var d=a.createTextRange();d&&("textarea"==a.type?d.moveToElementText(a):d.expand("textedit"),d.collapse(),d.moveEnd("character",c),d.moveStart("character",b),d.select())}else a.selectionStart=b,a.selectionEnd=c};var l=function(a,b,c){for(;0<b&&!(b==c);){b--;var d=a.charAt(b);if("0"<=d&&"9">=
d||"\u00ff"<d)return!0;d=a.charAt(b);if("A"<=d&&"Z">=d||"a"<=d&&"z">=d)break}return!1};c._parse=function(a,b){var c=-1,d=[],g={FILE_PATH:"/\\:.",URL:"/:.?=&#",XPATH:"/\\:.<>=[]",EMAIL:"<>@.,;"}[b];switch(b){case "FILE_PATH":case "URL":case "XPATH":m.forEach(a,function(b,f){0<=g.indexOf(b)&&l(a,f,c)&&(c=f,d.push(f))});break;case "EMAIL":m.forEach(a,function(b,f){if('"'==b){l(a,f,c)&&(c=f,d.push(f));f++;var i=a.indexOf('"',f);i>=f&&(f=i);l(a,f,c)&&(c=f,d.push(f))}0<=g.indexOf(b)&&l(a,f,c)&&(c=f,d.push(f))})}return d};
return dojox.string.BidiComplex});