>this.DB+n-h));for(p=f;0==(t&1);)t>>=1,--p;0>(n-=p)&&(n+=this.DB,--q);if(v)m[t].copyTo(d),v=!1;else{for(;1--n&&(n=this.DB-1,--q)}return c.revert(d)};b.prototype.modInverse=function(c){var a=c.isEven();if(this.isEven()&&a||0==c.signum())return b.ZERO;for(var e=
-c.clone(),g=this.clone(),k=l(1),n=l(0),d=l(0),f=l(1);0!=e.signum();){for(;e.isEven();)e.rShiftTo(1,e),a?(k.isEven()&&n.isEven()||(k.addTo(this,k),n.subTo(c,n)),k.rShiftTo(1,k)):n.isEven()||n.subTo(c,n),n.rShiftTo(1,n);for(;g.isEven();)g.rShiftTo(1,g),a?(d.isEven()&&f.isEven()||(d.addTo(this,d),f.subTo(c,f)),d.rShiftTo(1,d)):f.isEven()||f.subTo(c,f),f.rShiftTo(1,f);0<=e.compareTo(g)?(e.subTo(g,e),a&&k.subTo(d,k),n.subTo(f,n)):(g.subTo(e,g),a&&d.subTo(k,d),f.subTo(n,f))}if(0!=g.compareTo(b.ONE))return b.ZERO;
-if(0<=f.compareTo(c))return f.subtract(c);if(0>f.signum())f.addTo(c,f);else return f;return 0>f.signum()?f.add(c):f};b.prototype.pow=function(b){return this.exp(b,new r)};b.prototype.gcd=function(b){var c=0>this.s?this.negate():this.clone();b=0>b.s?b.negate():b.clone();if(0>c.compareTo(b)){var a=c;c=b;b=a}a=c.getLowestSetBit();var e=b.getLowestSetBit();if(0>e)return c;a>5]|=128<<24-h%32;a[(h+64>>>9<<4)+15]=h;for(h=0;hq;q++){if(16>q)b[q]=a[h+q];else{var r=b[q-3]^b[q-8]^b[q-14]^b[q-16];b[q]=r<<1|r>>>31}r=(d<<5|d>>>27)+k+(b[q]>>>0)+(20>q?(f&m|~f&l)+1518500249:40>q?(f^m^l)+1859775393:60>q?(f&m|f&l|m&l)-1894007588:(f^m^l)-899497514);
-k=l;l=m;m=f<<30|f>>>2;f=d;d=r}d+=e;f+=g;m+=c;l+=n;k+=p}return fromByteArray(wordsToBytes([d,f,m,l,k]))}};SSHyClient.hash.SHA256=function(b){this.data=b||"";this.digest_size=32};
-SSHyClient.hash.SHA256.prototype={digest:function(){var b=toByteArray(this.data),a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,
-2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],h=bytesToWords(b),d=8*b.length;b=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];var f=[],m,l;h[d>>5]|=128<<24-d%32;h[(d+64>>9<<4)+15]=d;for(m=0;ml;l++){if(16>l)f[l]=h[l+m];else{var r=f[l-15];var t=f[l-2];f[l]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+(f[l-7]>>>0)+((t<<15|t>>>17)^(t<<13|t>>>19)^t>>>10)+(f[l-16]>>>0)}t=d&k^d&e^k&e;var y=(d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22);r=(q>>>0)+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&n^~c&p)+a[l]+(f[l]>>>0);t=y+t;q=p;p=n;n=c;c=g+r>>>0;g=e;e=k;k=d;d=r+t>>>0}b[0]+=d;b[1]+=k;b[2]+=e;b[3]+=g;b[4]+=c;b[5]+=n;b[6]+=p;b[7]+=q}return fromByteArray(wordsToBytes(b))}};
-SSHyClient.hash.HMAC=function(b,a,h){h=digestmod="SHA-1"==h?SSHyClient.hash.SHA1:SSHyClient.hash.SHA256;var d=new h,f=new h;64m;++m)h[m]^=92,b[m]^=54;d.data+=fromByteArray(h);f.data+=fromByteArray(b);f.data+=a;d.data+=f.digest();return d.digest()};
-SSHyClient.hash.MD5=function(b){var a=toByteArray(b);b=bytesToWords(a);var h=8*a.length;a=1732584193;for(var d=-271733879,f=-1732584194,m=271733878,l=0;l>>24)&16711935|(b[l]<<24|b[l]>>>8)&4278255360;b[h>>>5]|=128<>>9<<4)+14]=h;h=function(b,c,a,e,g,l,k){b=b+(c&a|~c&e)+(g>>>0)+k;return(b<>>32-l)+c};var k=function(b,c,a,e,g,l,k){b=b+(c&e|a&~e)+(g>>>0)+k;return(b<>>32-l)+c},e=function(b,c,a,e,g,l,k){b=b+(c^a^e)+(g>>>0)+k;return(b<>>32-l)+c},
-g=function(b,c,a,e,g,l,k){b=b+(a^(c|~e))+(g>>>0)+k;return(b<>>32-l)+c};for(l=0;l>>0;d=d+n>>>0;f=f+p>>>0;m=m+q>>>0}var r=function(b){if(b.constructor==Number)return(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;for(var c=0;cf;f+=2){var l=b>>f&3;switch(l){case 0:case 1:0>>24&255),
-h+=String.fromCharCode(a>>>16&255),h+=String.fromCharCode(a>>>8&255);case "B":h+=String.fromCharCode(a&255)}return h},unpack:function(b,a){var h=[],d=0,f=0;switch(b){case "Q":f=new BigInteger("0",10);f=f.add((new BigInteger(a.charCodeAt(0).toString(),10)).shiftLeft(56));f=f.add((new BigInteger(a.charCodeAt(1).toString(),10)).shiftLeft(48));f=f.add((new BigInteger(a.charCodeAt(2).toString(),10)).shiftLeft(40));f=f.add((new BigInteger(a.charCodeAt(3).toString(),10)).shiftLeft(32));f=f.add((new BigInteger(a.charCodeAt(4).toString(),
-10)).shiftLeft(24));f=f.add((new BigInteger(a.charCodeAt(5).toString(),10)).shiftLeft(16));f=f.add((new BigInteger(a.charCodeAt(6).toString(),10)).shiftLeft(8));f=f.add((new BigInteger(a.charCodeAt(7).toString(),10)).shiftLeft(0));h.push(f);break;case "I":f+=a.charCodeAt(0)<<24>>>0,f+=a.charCodeAt(1)<<16>>>0,f+=a.charCodeAt(2)<<8>>>0,d+=3;case "B":f+=a.charCodeAt(0+d)<<0>>>0,h.push(f)}return h}};function inflate_long(b){var a=new BigInteger("0",10);b.length%4&&(b=Array(4-b.length%4+1).join("\x00")+b);for(var h=0;hh.charCodeAt(0)&&(h="\u00ff"+h));return h}function toByteArray(b){for(var a=new Uint8Array(b.length),h=0;h>>5]|=(b[h]&255)<<24-d%32;return a}function wordsToBytes(b){for(var a=[],h=0;h<32*b.length;h+=8)a.push(b[h>>>5]>>>24-h%32&255);return a}
-function setCharAt(b,a,h){return b.substring(0,a)+h+b.substring(a+1)}function fromUtf8(b){for(var a="",h=toByteArray(b),d=0;d=f){var m=h[++d];f=(f&31)<<6|m&63}else if(224<=f&&239>=f){m=h[++d];var l=h[++d];f=(f&15)<<12|(m&63)<<6|l&63}else 128<=f&&(f=".");a+=String.fromCharCode(f)}return a}function read_rng(b){return String.fromCharCode.apply(null,window.crypto.getRandomValues(new Uint8Array(b)))}
-function filter(b,a){b=b.split(",");for(var h=0;ha?0:255;a=0>a?-1*a:a;var d=h>>16,f=h>>8&255;h&=255;return"#"+(16777216+65536*(Math.round((b-d)*a)+d)+256*(Math.round((b-f)*a)+f)+(Math.round((b-h)*a)+h)).toString(16).slice(1)}
-function ascii2hex(b){for(var a="",h=0;hthis._terminal.rows},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"isCursorInViewport",{get:function(){var a=this.ybase+this.y-this.ydisp;return 0<=a&&ad.MAX_BUFFER_SIZE?d.MAX_BUFFER_SIZE:a};a.prototype.fillViewportRows=function(){if(0===this._lines.length)for(var a=this._terminal.rows;a--;)this.lines.push(this._terminal.blankLine())};a.prototype.clear=function(){this.x=this.y=this.ybase=this.ydisp=0;this._lines=new f.CircularList(this._getCorrectBufferLength(this._terminal.rows));this.scrollTop=0;this.scrollBottom=this._terminal.rows-1;this.setupTabStops()};a.prototype.resize=function(a,k){var e=this._getCorrectBufferLength(k);
-e>this._lines.maxLength&&(this._lines.maxLength=e);if(0k;c--)this._lines.length>k+this.ybase&&(this._lines.length>this.ybase+this.y+1?this._lines.pop():(this.ybase++,this.ydisp++));e=m&&a--,g>=m&&f--):1m&&(a+=h[d.CHAR_DATA_CHAR_INDEX].length-1),g>m&&(f+=h[d.CHAR_DATA_CHAR_INDEX].length-1))}return k&&(k=c.search(/\s+$/),-1!==k&&(f=Math.min(f,k)),f<=a)?"":c.substring(a,
-f)};a.prototype.setupTabStops=function(a){null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);for(;a=this._terminal.cols?this._terminal.cols-1:0>a?0:a};a.prototype.nextStop=function(a){null==a&&(a=this.x);for(;!this.tabs[++a]&&a=this._terminal.cols?this._terminal.cols-1:0>a?0:a};return a}();
-d.Buffer=a},{"./utils/CircularList":32}],2:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,e){a.__proto__=e}||function(a,e){for(var g in e)e.hasOwnProperty(g)&&(a[g]=e[g])};return function(k,e){function g(){this.constructor=k}a(k,e);k.prototype=null===e?Object.create(e):(g.prototype=e.prototype,new g)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("./Buffer");a=function(a){function k(e){var g=a.call(this)||
-this;g._terminal=e;g._normal=new m.Buffer(g._terminal,!0);g._normal.fillViewportRows();g._alt=new m.Buffer(g._terminal,!1);g._activeBuffer=g._normal;g.setupTabStops();return g}f(k,a);Object.defineProperty(k.prototype,"alt",{get:function(){return this._alt},enumerable:!0,configurable:!0});Object.defineProperty(k.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!0,configurable:!0});Object.defineProperty(k.prototype,"normal",{get:function(){return this._normal},enumerable:!0,
-configurable:!0});k.prototype.activateNormalBuffer=function(){this._activeBuffer!==this._normal&&(this._alt.clear(),this._activeBuffer=this._normal,this.emit("activate",{activeBuffer:this._normal,inactiveBuffer:this._alt}))};k.prototype.activateAltBuffer=function(){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(),this._activeBuffer=this._alt,this.emit("activate",{activeBuffer:this._alt,inactiveBuffer:this._normal}))};k.prototype.resize=function(a,g){this._normal.resize(a,g);this._alt.resize(a,
-g)};k.prototype.setupTabStops=function(a){this._normal.setupTabStops(a);this._alt.setupTabStops(a)};return k}(a("./EventEmitter").EventEmitter);d.BufferSet=a},{"./Buffer":1,"./EventEmitter":7}],3:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});d.wcwidth=function(a){function d(a,e){var c=0,g=e.length-1;if(ae[g][1])return!1;for(;g>=c;){var k=c+g>>1;if(a>e[k][1])c=k+1;else if(ac)return e|0;if(127>c)return 1;var n;if(!(n=g)){g="undefined"===typeof Uint32Array?Array(4096):new Uint32Array(4096);for(n=0;4096>n;++n){for(var f=0,m=16;m--;){f<<=2;var h=16*n+m;h=0===h?a.nul:32>h||127<=h&&160>h?a.control:d(h,l)?0:4352<=h&&(4447>=
-h||9001===h||9002===h||11904<=h&&42191>=h&&12351!==h||44032<=h&&55203>=h||63744<=h&&64255>=h||65040<=h&&65049>=h||65072<=h&&65135>=h||65280<=h&&65376>=h||65504<=h&&65510>=h)?2:1;f|=h}g[n]=f}n=g}if(65536>c)return n[c>>4]>>((c&15)<<1)&3;c=d(c,k)?0:131072<=c&&196605>=c||196608<=c&&262141>=c?2:1;return c}}({nul:0,control:0})},{}],4:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});d.CHARSETS={};d.DEFAULT_CHARSET=d.CHARSETS.B;d.CHARSETS["0"]={"`":"\u25c6",a:"\u2592",b:"\t",c:"\f",d:"\r",
-e:"\n",f:"\u00b0",g:"\u00b1",h:"\u2424",i:"\x0B",j:"\u2518",k:"\u2510",l:"\u250c",m:"\u2514",n:"\u253c",o:"\u23ba",p:"\u23bb",q:"\u2500",r:"\u23bc",s:"\u23bd",t:"\u251c",u:"\u2524",v:"\u2534",w:"\u252c",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03c0","|":"\u2260","}":"\u00a3","~":"\u00b7"};d.CHARSETS.A={"#":"\u00a3"};d.CHARSETS.B=null;d.CHARSETS["4"]={"#":"\u00a3","@":"\u00be","[":"ij","\\":"\u00bd","]":"|","{":"\u00a8","|":"f","}":"\u00bc","~":"\u00b4"};d.CHARSETS.C=d.CHARSETS["5"]={"[":"\u00c4","\\":"\u00d6",
-"]":"\u00c5","^":"\u00dc","`":"\u00e9","{":"\u00e4","|":"\u00f6","}":"\u00e5","~":"\u00fc"};d.CHARSETS.R={"#":"\u00a3","@":"\u00e0","[":"\u00b0","\\":"\u00e7","]":"\u00a7","{":"\u00e9","|":"\u00f9","}":"\u00e8","~":"\u00a8"};d.CHARSETS.Q={"@":"\u00e0","[":"\u00e2","\\":"\u00e7","]":"\u00ea","^":"\u00ee","`":"\u00f4","{":"\u00e9","|":"\u00f9","}":"\u00e8","~":"\u00fb"};d.CHARSETS.K={"@":"\u00a7","[":"\u00c4","\\":"\u00d6","]":"\u00dc","{":"\u00e4","|":"\u00f6","}":"\u00fc","~":"\u00df"};d.CHARSETS.Y=
-{"#":"\u00a3","@":"\u00a7","[":"\u00b0","\\":"\u00e7","]":"\u00e9","`":"\u00f9","{":"\u00e0","|":"\u00f2","}":"\u00e8","~":"\u00ec"};d.CHARSETS.E=d.CHARSETS["6"]={"@":"\u00c4","[":"\u00c6","\\":"\u00d8","]":"\u00c5","^":"\u00dc","`":"\u00e4","{":"\u00e6","|":"\u00f8","}":"\u00e5","~":"\u00fc"};d.CHARSETS.Z={"#":"\u00a3","@":"\u00a7","[":"\u00a1","\\":"\u00d1","]":"\u00bf","{":"\u00b0","|":"\u00f1","}":"\u00e7"};d.CHARSETS.H=d.CHARSETS["7"]={"@":"\u00c9","[":"\u00c4","\\":"\u00d6","]":"\u00c5","^":"\u00dc",
-"`":"\u00e9","{":"\u00e4","|":"\u00f6","}":"\u00e5","~":"\u00fc"};d.CHARSETS["="]={"#":"\u00f9","@":"\u00e0","[":"\u00e9","\\":"\u00e7","]":"\u00ea","^":"\u00ee",_:"\u00e8","`":"\u00f4","{":"\u00e4","|":"\u00f6","}":"\u00fc","~":"\u00fb"}},{}],5:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});a=function(){function a(a,l,k){this.textarea=a;this.compositionView=l;this.terminal=k;this.isSendingComposition=this.isComposing=!1;this.compositionPosition={start:null,end:null}}a.prototype.compositionstart=
-function(){this.isComposing=!0;this.compositionPosition.start=this.textarea.value.length;this.compositionView.textContent="";this.compositionView.classList.add("active")};a.prototype.compositionupdate=function(a){var l=this;this.compositionView.textContent=a.data;this.updateCompositionElements();setTimeout(function(){l.compositionPosition.end=l.textarea.value.length},0)};a.prototype.compositionend=function(){this.finalizeComposition(!0)};a.prototype.keydown=function(a){if(this.isComposing||this.isSendingComposition){if(229===
-a.keyCode||16===a.keyCode||17===a.keyCode||18===a.keyCode)return!1;this.finalizeComposition(!1)}return 229===a.keyCode?(this.handleAnyTextareaChanges(),!1):!0};a.prototype.finalizeComposition=function(a){var l=this;this.compositionView.classList.remove("active");this.isComposing=!1;this.clearTextareaPosition();if(a){var k=this.compositionPosition.start,e=this.compositionPosition.end;this.isSendingComposition=!0;setTimeout(function(){if(l.isSendingComposition){l.isSendingComposition=!1;var a=l.isComposing?
-l.textarea.value.substring(k,e):l.textarea.value.substring(k);l.terminal.handler(a)}},0)}else this.isSendingComposition=!1,a=this.textarea.value.substring(this.compositionPosition.start,this.compositionPosition.end),this.terminal.handler(a)};a.prototype.handleAnyTextareaChanges=function(){var a=this,l=this.textarea.value;setTimeout(function(){if(!a.isComposing){var k=a.textarea.value.replace(l,"");0=this._terminal.cols)if(this._terminal.wraparoundMode)this._terminal.buffer.x=0,this._terminal.buffer.y++,this._terminal.buffer.y>this._terminal.buffer.scrollBottom?(this._terminal.buffer.y--,this._terminal.scroll(!0)):this._terminal.buffer.lines.get(this._terminal.buffer.y).isWrapped=!0;else if(2===
-g)return;c=this._terminal.buffer.y+this._terminal.buffer.ybase;if(this._terminal.insertMode)for(var k=0;kthis._terminal.buffer.scrollBottom&&(this._terminal.buffer.y--,this._terminal.scroll());this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--;this._terminal.emit("linefeed")};a.prototype.carriageReturn=function(){this._terminal.buffer.x=0};a.prototype.backspace=function(){0a&&(a=1);for(var c=this._terminal.buffer.y+this._terminal.buffer.ybase,e=this._terminal.buffer.x,g=[this._terminal.eraseAttr()," ",1,32];a--&&ea&&(a=1);this._terminal.buffer.y-=a;0>this._terminal.buffer.y&&(this._terminal.buffer.y=0)};a.prototype.cursorDown=
-function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y+=a;this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1);this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--};a.prototype.cursorForward=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x+=a;this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)};a.prototype.cursorBackward=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x>=this._terminal.cols&&
-this._terminal.buffer.x--;this._terminal.buffer.x-=a;0>this._terminal.buffer.x&&(this._terminal.buffer.x=0)};a.prototype.cursorNextLine=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y+=a;this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1);this._terminal.buffer.x=0};a.prototype.cursorPrecedingLine=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y-=a;0>this._terminal.buffer.y&&(this._terminal.buffer.y=0);this._terminal.buffer.x=0};a.prototype.cursorCharAbsolute=
-function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x=a-1};a.prototype.cursorPosition=function(a){var c=a[0]-1;a=2<=a.length?a[1]-1:0;0>c?c=0:c>=this._terminal.rows&&(c=this._terminal.rows-1);0>a?a=0:a>=this._terminal.cols&&(a=this._terminal.cols-1);this._terminal.buffer.x=a;this._terminal.buffer.y=c};a.prototype.cursorForwardTab=function(a){for(a=a[0]||1;a--;)this._terminal.buffer.x=this._terminal.buffer.nextStop()};a.prototype.eraseInDisplay=function(a){switch(a[0]){case 0:this._terminal.eraseRight(this._terminal.buffer.x,
-this._terminal.buffer.y);for(a=this._terminal.buffer.y+1;aa&&(a=1);for(var c=this._terminal.buffer.y+this._terminal.buffer.ybase,
-e=this._terminal.rows-1+this._terminal.buffer.ybase-(this._terminal.rows-1-this._terminal.buffer.scrollBottom)+1;a--;)this._terminal.buffer.lines.splice(e-1,1),this._terminal.buffer.lines.splice(c,0,this._terminal.blankLine(!0));this._terminal.updateRange(this._terminal.buffer.y);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};a.prototype.deleteLines=function(a){a=a[0];1>a&&(a=1);var c=this._terminal.buffer.y+this._terminal.buffer.ybase;var e=this._terminal.rows-1-this._terminal.buffer.scrollBottom;
-for(e=this._terminal.rows-1+this._terminal.buffer.ybase-e;a--;)this._terminal.buffer.lines.splice(c,1),this._terminal.buffer.lines.splice(e,0,this._terminal.blankLine(!0));this._terminal.updateRange(this._terminal.buffer.y);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};a.prototype.deleteChars=function(a){a=a[0];1>a&&(a=1);for(var c=this._terminal.buffer.y+this._terminal.buffer.ybase,e=[this._terminal.eraseAttr()," ",1,32];a--;)this._terminal.buffer.lines.get(c).splice(this._terminal.buffer.x,
-1),this._terminal.buffer.lines.get(c).push(e);this._terminal.updateRange(this._terminal.buffer.y)};a.prototype.scrollUp=function(a){for(a=a[0]||1;a--;)this._terminal.buffer.lines.splice(this._terminal.buffer.ybase+this._terminal.buffer.scrollTop,1),this._terminal.buffer.lines.splice(this._terminal.buffer.ybase+this._terminal.buffer.scrollBottom,0,this._terminal.blankLine());this._terminal.updateRange(this._terminal.buffer.scrollTop);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};
-a.prototype.scrollDown=function(a){for(a=a[0]||1;a--;)this._terminal.buffer.lines.splice(this._terminal.buffer.ybase+this._terminal.buffer.scrollBottom,1),this._terminal.buffer.lines.splice(this._terminal.buffer.ybase+this._terminal.buffer.scrollTop,0,this._terminal.blankLine());this._terminal.updateRange(this._terminal.buffer.scrollTop);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};a.prototype.eraseChars=function(a){a=a[0];1>a&&(a=1);for(var c=this._terminal.buffer.y+this._terminal.buffer.ybase,
-e=this._terminal.buffer.x,g=[this._terminal.eraseAttr()," ",1,32];a--&&ea&&(a=1);this._terminal.buffer.x=a-1;this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)};a.prototype.HPositionRelative=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x+=
-a;this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)};a.prototype.repeatPrecedingCharacter=function(a){a=a[0]||1;for(var c=this._terminal.buffer.lines.get(this._terminal.buffer.ybase+this._terminal.buffer.y),e=c[this._terminal.buffer.x-1]||[this._terminal.defAttr," ",1,32];a--;)c[this._terminal.buffer.x++]=e};a.prototype.sendDeviceAttributes=function(a){0"===this._terminal.prefix&&(this._terminal.is("xterm")?this._terminal.send(f.C0.ESC+
-"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._terminal.send(f.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._terminal.send(a[0]+"c"):this._terminal.is("screen")&&this._terminal.send(f.C0.ESC+"[>83;40003;0c")):this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._terminal.send(f.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._terminal.send(f.C0.ESC+"[?6c"))};a.prototype.linePosAbsolute=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y=
-a-1;this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1)};a.prototype.VPositionRelative=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y+=a;this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1);this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--};a.prototype.HVPosition=function(a){1>a[0]&&(a[0]=1);1>a[1]&&(a[1]=1);this._terminal.buffer.y=a[0]-1;this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=
-this._terminal.rows-1);this._terminal.buffer.x=a[1]-1;this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)};a.prototype.tabClear=function(a){a=a[0];0>=a?delete this._terminal.buffer.tabs[this._terminal.buffer.x]:3===a&&(this._terminal.buffer.tabs={})};a.prototype.setMode=function(a){if(1>18,g=this._terminal.curAttr>>9&511,l=this._terminal.curAttr&511,d,f=0;f=d?g=d-30:40<=d&&47>=d?l=d-40:90<=d&&97>=d?(d+=8,g=d-90):100<=d&&107>=d?(d+=8,l=d-100):0===d?(e=this._terminal.defAttr>>
-18,g=this._terminal.defAttr>>9&511,l=this._terminal.defAttr&511):1===d?e|=k.FLAGS.BOLD:4===d?e|=k.FLAGS.UNDERLINE:5===d?e|=k.FLAGS.BLINK:7===d?e|=k.FLAGS.INVERSE:8===d?e|=k.FLAGS.INVISIBLE:2===d?e|=k.FLAGS.DIM:22===d?(e&=~k.FLAGS.BOLD,e&=~k.FLAGS.DIM):24===d?e&=~k.FLAGS.UNDERLINE:25===d?e&=~k.FLAGS.BLINK:27===d?e&=~k.FLAGS.INVERSE:28===d?e&=~k.FLAGS.INVISIBLE:39===d?g=this._terminal.defAttr>>9&511:49===d?l=this._terminal.defAttr&511:38===d?2===a[f+1]?(f+=2,g=this._terminal.matchColor(a[f]&255,a[f+
-1]&255,a[f+2]&255),-1===g&&(g=511),f+=2):5===a[f+1]&&(f+=2,g=d=a[f]&255):48===d?2===a[f+1]?(f+=2,l=this._terminal.matchColor(a[f]&255,a[f+1]&255,a[f+2]&255),-1===l&&(l=511),f+=2):5===a[f+1]&&(f+=2,l=d=a[f]&255):100===d?(g=this._terminal.defAttr>>9&511,l=this._terminal.defAttr&511):this._terminal.error("Unknown SGR attribute: %d.",d);this._terminal.curAttr=e<<18|g<<9|l}};a.prototype.deviceStatus=function(a){if(!this._terminal.prefix)switch(a[0]){case 5:this._terminal.send(f.C0.ESC+"[0n");break;case 6:this._terminal.send(f.C0.ESC+
-"["+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R")}else if("?"===this._terminal.prefix)switch(a[0]){case 6:this._terminal.send(f.C0.ESC+"[?"+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R")}};a.prototype.softReset=function(a){this._terminal.cursorHidden=!1;this._terminal.insertMode=!1;this._terminal.originMode=!1;this._terminal.wraparoundMode=!0;this._terminal.applicationKeypad=!1;this._terminal.viewport.syncScrollArea();this._terminal.applicationCursor=!1;this._terminal.buffer.scrollTop=
-0;this._terminal.buffer.scrollBottom=this._terminal.rows-1;this._terminal.curAttr=this._terminal.defAttr;this._terminal.buffer.x=this._terminal.buffer.y=0;this._terminal.charset=null;this._terminal.glevel=0;this._terminal.charsets=[null]};a.prototype.setCursorStyle=function(a){a=1>a[0]?1:a[0];switch(a){case 1:case 2:this._terminal.setOption("cursorStyle","block");break;case 3:case 4:this._terminal.setOption("cursorStyle","underline");break;case 5:case 6:this._terminal.setOption("cursorStyle","bar")}this._terminal.setOption("cursorBlink",
-1===a%2)};a.prototype.setScrollRegion=function(a){this._terminal.prefix||(this._terminal.buffer.scrollTop=(a[0]||1)-1,this._terminal.buffer.scrollBottom=(a[1]&&a[1]<=this._terminal.rows?a[1]:this._terminal.rows)-1,this._terminal.buffer.x=0,this._terminal.buffer.y=0)};a.prototype.saveCursor=function(a){this._terminal.buffer.savedX=this._terminal.buffer.x;this._terminal.buffer.savedY=this._terminal.buffer.y};a.prototype.restoreCursor=function(a){this._terminal.buffer.x=this._terminal.buffer.savedX||
-0;this._terminal.buffer.y=this._terminal.buffer.savedY||0};return a}();d.InputHandler=a},{"./Buffer":1,"./CharWidth":3,"./Charsets":4,"./EscapeSequences":6,"./renderer/Types":28}],9:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var e in c)c.hasOwnProperty(e)&&(a[e]=c[e])};return function(e,c){function g(){this.constructor=e}a(e,c);e.prototype=null===c?Object.create(c):(g.prototype=
-c.prototype,new g)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("./Types"),l=a("./input/MouseZoneManager"),k=/(?:^|[^\da-z\.-]+)((https?:\/\/)((([\da-z\.-]+)\.([a-z\.]{2,6}))|((\d{1,3}\.){3}\d{1,3})|(localhost))(:\d{1,5})?(\/[\/\w\.\-%~]*)*(\?[0-9\w\[\]\(\)\/\?\!#@$%&'*+,:;~\=\.\-]*)?(#[0-9\w\[\]\(\)\/\?\!#@$%&'*+,:;~\=\.\-]*)?)($|[^\/\w\.\-%]+)/;a=function(a){function e(c){var e=a.call(this)||this;e._terminal=c;e._linkMatchers=[];e._nextLinkMatcherId=0;e._rowsToLinkify={start:null,
-end:null};e.registerLinkMatcher(k,null,{matchIndex:1});return e}f(e,a);e.prototype.attachToDom=function(a){this._mouseZoneManager=a};e.prototype.linkifyRows=function(a,g){var c=this;this._mouseZoneManager&&(null===this._rowsToLinkify.start?(this._rowsToLinkify.start=a,this._rowsToLinkify.end=g):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,a),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,g)),this._mouseZoneManager.clearAll(a,g),this._rowsTimeoutId&&clearTimeout(this._rowsTimeoutId),
-this._rowsTimeoutId=setTimeout(function(){return c._linkifyRows()},e.TIME_BEFORE_LINKIFY))};e.prototype._linkifyRows=function(){this._rowsTimeoutId=null;for(var a=this._rowsToLinkify.start;a<=this._rowsToLinkify.end;a++)this._linkifyRow(a);this._rowsToLinkify.start=null;this._rowsToLinkify.end=null};e.prototype.setHypertextLinkHandler=function(a){this._linkMatchers[0].handler=a};e.prototype.setHypertextValidationCallback=function(a){this._linkMatchers[0].validationCallback=a};e.prototype.registerLinkMatcher=
-function(a,e,g){void 0===g&&(g={});if(0!==this._nextLinkMatcherId&&!e)throw Error("handler must be defined");a={id:this._nextLinkMatcherId++,regex:a,handler:e,matchIndex:g.matchIndex,validationCallback:g.validationCallback,hoverTooltipCallback:g.tooltipCallback,hoverLeaveCallback:g.leaveCallback,willLinkActivate:g.willLinkActivate,priority:g.priority||0};this._addLinkMatcherToList(a);return a.id};e.prototype._addLinkMatcherToList=function(a){if(0===this._linkMatchers.length)this._linkMatchers.push(a);
-else{for(var c=this._linkMatchers.length-1;0<=c;c--)if(a.priority<=this._linkMatchers[c].priority){this._linkMatchers.splice(c+1,0,a);return}this._linkMatchers.splice(0,0,a)}};e.prototype.deregisterLinkMatcher=function(a){for(var c=1;c=this._terminal.buffer.lines.length)){c=this._terminal.buffer.translateBufferLineToString(c,
-!1);for(var e=0;e":function(a){return a.setPrefix(">")},
-"!":function(a){return a.setPrefix("!")},0:function(a){return a.setParam(10*a.getParam())},1:function(a){return a.setParam(10*a.getParam()+1)},2:function(a){return a.setParam(10*a.getParam()+2)},3:function(a){return a.setParam(10*a.getParam()+3)},4:function(a){return a.setParam(10*a.getParam()+4)},5:function(a){return a.setParam(10*a.getParam()+5)},6:function(a){return a.setParam(10*a.getParam()+6)},7:function(a){return a.setParam(10*a.getParam()+7)},8:function(a){return a.setParam(10*a.getParam()+
-8)},9:function(a){return a.setParam(10*a.getParam()+9)},$:function(a){return a.setPostfix("$")},'"':function(a){return a.setPostfix('"')}," ":function(a){return a.setPostfix(" ")},"'":function(a){return a.setPostfix("'")},";":function(a){return a.finalizeParam()}};e[f.C0.CAN]=function(a){return a.setState(c.NORMAL)};var g={"@":function(a,c,e){return a.insertChars(c)},A:function(a,c,e){return a.cursorUp(c)},B:function(a,c,e){return a.cursorDown(c)},C:function(a,c,e){return a.cursorForward(c)},D:function(a,
-c,e){return a.cursorBackward(c)},E:function(a,c,e){return a.cursorNextLine(c)},F:function(a,c,e){return a.cursorPrecedingLine(c)},G:function(a,c,e){return a.cursorCharAbsolute(c)},H:function(a,c,e){return a.cursorPosition(c)},I:function(a,c,e){return a.cursorForwardTab(c)},J:function(a,c,e){return a.eraseInDisplay(c)},K:function(a,c,e){return a.eraseInLine(c)},L:function(a,c,e){return a.insertLines(c)},M:function(a,c,e){return a.deleteLines(c)},P:function(a,c,e){return a.deleteChars(c)},S:function(a,
-c,e){return a.scrollUp(c)},T:function(a,c,e){2>c.length&&!e&&a.scrollDown(c)},X:function(a,c,e){return a.eraseChars(c)},Z:function(a,c,e){return a.cursorBackwardTab(c)},"`":function(a,c,e){return a.charPosAbsolute(c)},a:function(a,c,e){return a.HPositionRelative(c)},b:function(a,c,e){return a.repeatPrecedingCharacter(c)},c:function(a,c,e){return a.sendDeviceAttributes(c)},d:function(a,c,e){return a.linePosAbsolute(c)},e:function(a,c,e){return a.VPositionRelative(c)},f:function(a,c,e){return a.HVPosition(c)},
-g:function(a,c,e){return a.tabClear(c)},h:function(a,c,e){return a.setMode(c)},l:function(a,c,e){return a.resetMode(c)},m:function(a,c,e){return a.charAttributes(c)},n:function(a,c,e){return a.deviceStatus(c)},p:function(a,c,e){switch(e){case "!":a.softReset(c)}},q:function(a,c,e,g){" "===g&&a.setCursorStyle(c)},r:function(a,c){return a.setScrollRegion(c)},s:function(a,c){return a.saveCursor(c)},u:function(a,c){return a.restoreCursor(c)}};g[f.C0.CAN]=function(a,e,g,k,d){return d.setState(c.NORMAL)};
-var c;(function(a){a[a.NORMAL=0]="NORMAL";a[a.ESCAPED=1]="ESCAPED";a[a.CSI_PARAM=2]="CSI_PARAM";a[a.CSI=3]="CSI";a[a.OSC=4]="OSC";a[a.CHARSET=5]="CHARSET";a[a.DCS=6]="DCS";a[a.IGNORE=7]="IGNORE"})(c=d.ParserState||(d.ParserState={}));a=function(){function a(a,e){this._inputHandler=a;this._terminal=e;this._state=c.NORMAL}a.prototype.parse=function(a){var d=a.length,h=this._terminal.buffer.x,n=this._terminal.buffer.y;this._terminal.debug&&this._terminal.log("data: "+a);this._position=0;this._terminal.surrogate_high&&
-(a=this._terminal.surrogate_high+a,this._terminal.surrogate_high="");for(;this._position=v){var C=a.charCodeAt(this._position+1);if(isNaN(C)){this._terminal.surrogate_high=p;continue}v=1024*(v-55296)+(C-56320)+65536;p+=a.charAt(this._position+1)}if(!(56320<=v&&57343>=v))switch(this._state){case c.NORMAL:if(p in l)l[p](this,this._inputHandler);else this._inputHandler.addChar(p,v);break;case c.ESCAPED:if(p in
-k){k[p](this,this._terminal);break}switch(p){case "(":case ")":case "*":case "+":case "-":case ".":switch(p){case "(":this._terminal.gcharset=0;break;case ")":this._terminal.gcharset=1;break;case "*":this._terminal.gcharset=2;break;case "+":this._terminal.gcharset=3;break;case "-":this._terminal.gcharset=1;break;case ".":this._terminal.gcharset=2}this._state=c.CHARSET;break;case "/":this._terminal.gcharset=3;this._state=c.CHARSET;this._position--;break;case "N":this._state=c.NORMAL;break;case "O":this._state=
-c.NORMAL;break;case "n":this._terminal.setgLevel(2);this._state=c.NORMAL;break;case "o":this._terminal.setgLevel(3);this._state=c.NORMAL;break;case "|":this._terminal.setgLevel(3);this._state=c.NORMAL;break;case "}":this._terminal.setgLevel(2);this._state=c.NORMAL;break;case "~":this._terminal.setgLevel(1);this._state=c.NORMAL;break;case "7":this._inputHandler.saveCursor();this._state=c.NORMAL;break;case "8":this._inputHandler.restoreCursor();this._state=c.NORMAL;break;case "#":this._state=c.NORMAL;
-this._position++;break;case "H":this._terminal.tabSet();this._state=c.NORMAL;break;case "=":this._terminal.log("Serial port requested application keypad.");this._terminal.applicationKeypad=!0;this._terminal.viewport&&this._terminal.viewport.syncScrollArea();this._state=c.NORMAL;break;case ">":this._terminal.log("Switching back to normal keypad.");this._terminal.applicationKeypad=!1;this._terminal.viewport&&this._terminal.viewport.syncScrollArea();this._state=c.NORMAL;break;default:this._state=c.NORMAL,
-this._terminal.error("Unknown ESC control: %s.",p)}break;case c.CHARSET:p in m.CHARSETS?(v=m.CHARSETS[p],"/"===p&&this.skipNextChar()):v=m.DEFAULT_CHARSET;this._terminal.setgCharset(this._terminal.gcharset,v);this._terminal.gcharset=null;this._state=c.NORMAL;break;case c.OSC:if(p===f.C0.ESC||p===f.C0.BEL){p===f.C0.ESC&&this._position++;this._terminal.params.push(this._terminal.currentParam);switch(this._terminal.params[0]){case 0:case 1:case 2:this._terminal.params[1]&&(this._terminal.title=this._terminal.params[1],
-this._terminal.handleTitle(this._terminal.title))}this._terminal.params=[];this._terminal.currentParam=0;this._state=c.NORMAL}else this._terminal.params.length?this._terminal.currentParam+=p:"0"<=p&&"9">=p?this._terminal.currentParam=10*this._terminal.currentParam+p.charCodeAt(0)-48:";"===p&&(this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam="");break;case c.CSI_PARAM:if(p in e){e[p](this);break}this.finalizeParam();this._state=c.CSI;case c.CSI:p in g?(this._terminal.debug&&
-this._terminal.log("CSI "+(this._terminal.prefix?this._terminal.prefix:"")+" "+(this._terminal.params?this._terminal.params.join(";"):"")+" "+(this._terminal.postfix?this._terminal.postfix:"")+" "+p),g[p](this._inputHandler,this._terminal.params,this._terminal.prefix,this._terminal.postfix,this)):this._terminal.error("Unknown CSI code: %s.",p);this._state=c.NORMAL;this._terminal.prefix="";this._terminal.postfix="";break;case c.DCS:if(p===f.C0.ESC||p===f.C0.BEL){p===f.C0.ESC&&this._position++;switch(this._terminal.prefix){case "":break;
-case "$q":p=this._terminal.currentParam;v=!1;switch(p){case '"q':p='0"q';break;case '"p':p='61"p';break;case "r":p=""+(this._terminal.buffer.scrollTop+1)+";"+(this._terminal.buffer.scrollBottom+1)+"r";break;case "m":p="0m";break;default:this._terminal.error("Unknown DCS Pt: %s.",p),p=""}this._terminal.send(f.C0.ESC+"P"+ +v+"$r"+p+f.C0.ESC+"\\");break;case "+p":break;case "+q":p=this._terminal.currentParam;v=!1;this._terminal.send(f.C0.ESC+"P"+ +v+"+r"+p+f.C0.ESC+"\\");break;default:this._terminal.error("Unknown DCS prefix: %s.",
-this._terminal.prefix)}this._terminal.currentParam=0;this._terminal.prefix="";this._state=c.NORMAL}else this._terminal.currentParam?this._terminal.currentParam+=p:this._terminal.prefix||"$"===p||"+"===p?2===this._terminal.prefix.length?this._terminal.currentParam=p:this._terminal.prefix+=p:this._terminal.currentParam=p;break;case c.IGNORE:if(p===f.C0.ESC||p===f.C0.BEL)p===f.C0.ESC&&this._position++,this._state=c.NORMAL}}this._terminal.buffer.x===h&&this._terminal.buffer.y===n||this._terminal.emit("cursormove");
-return this._state};a.prototype.setState=function(a){this._state=a};a.prototype.setPrefix=function(a){this._terminal.prefix=a};a.prototype.setPostfix=function(a){this._terminal.postfix=a};a.prototype.setParam=function(a){this._terminal.currentParam=a};a.prototype.getParam=function(){return this._terminal.currentParam};a.prototype.finalizeParam=function(){this._terminal.params.push(this._terminal.currentParam);this._terminal.currentParam=0};a.prototype.skipNextChar=function(){this._position++};return a}();
-d.Parser=a},{"./Charsets":4,"./EscapeSequences":6}],11:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var e in c)c.hasOwnProperty(e)&&(a[e]=c[e])};return function(c,e){function g(){this.constructor=c}a(c,e);c.prototype=null===e?Object.create(e):(g.prototype=e.prototype,new g)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("./utils/MouseHelper"),l=a("./shared/utils/Browser");
-h=a("./EventEmitter");var k=a("./SelectionModel"),e=a("./Buffer"),g=a("./handlers/AltClickHandler");a=String.fromCharCode(160);var c=new RegExp(a,"g"),n;(function(a){a[a.NORMAL=0]="NORMAL";a[a.WORD=1]="WORD";a[a.LINE=2]="LINE"})(n||(n={}));a=function(a){function d(c,e){var g=a.call(this)||this;g._terminal=c;g._charMeasure=e;g._enabled=!0;g._initListeners();g.enable();g._model=new k.SelectionModel(c);g._activeSelectionMode=n.NORMAL;return g}f(d,a);Object.defineProperty(d.prototype,"_buffer",{get:function(){return this._terminal.buffers.active},
-enumerable:!0,configurable:!0});d.prototype._initListeners=function(){var a=this;this._mouseMoveListener=function(c){return a._onMouseMove(c)};this._mouseUpListener=function(c){return a._onMouseUp(c)};this._trimListener=function(c){return a._onTrim(c)};this.initBuffersListeners()};d.prototype.initBuffersListeners=function(){var a=this;this._terminal.buffer.lines.on("trim",this._trimListener);this._terminal.buffers.on("activate",function(c){return a._onBufferActivate(c)})};d.prototype.disable=function(){this.clearSelection();
-this._enabled=!1};d.prototype.enable=function(){this._enabled=!0};Object.defineProperty(d.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,"hasSelection",{get:function(){var a=this._model.finalSelectionStart,c=this._model.finalSelectionEnd;return a&&c?a[0]!==c[0]||a[1]!==
-c[1]:!1},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,"selectionText",{get:function(){var a=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!a||!e)return"";var g=[];g.push(this._buffer.translateBufferLineToString(a[1],!0,a[0],a[1]===e[1]?e[0]:null));for(var d=a[1]+1;d<=e[1]-1;d++){var k=this._buffer.lines.get(d),f=this._buffer.translateBufferLineToString(d,!0);k.isWrapped?g[g.length-1]+=f:g.push(f)}a[1]!==e[1]&&(k=this._buffer.lines.get(e[1]),f=this._buffer.translateBufferLineToString(e[1],
-!0,0,e[0]),k.isWrapped?g[g.length-1]+=f:g.push(f));return g.map(function(a){return a.replace(c," ")}).join(l.isMSWindows?"\r\n":"\n")},enumerable:!0,configurable:!0});d.prototype.clearSelection=function(){this._model.clearSelection();this._removeMouseDownListeners();this.refresh()};d.prototype.refresh=function(a){var c=this;this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(function(){return c._refresh()}));l.isLinux&&a&&this.selectionText.length&&this.emit("newselection",
-this.selectionText)};d.prototype._refresh=function(){this._refreshAnimationFrame=null;this.emit("refresh",{start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd})};d.prototype.isClickInSelection=function(a){a=this._getMouseBufferCoords(a);var c=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return c&&e?a[1]>c[1]&&a[1]c[0]&&a[0]c&&(a-=c);a=Math.min(Math.max(a,-50),50);a/=50;return a/Math.abs(a)+Math.round(14*a)};d.prototype.shouldForceSelection=function(a){return l.isMac?a.altKey:a.shiftKey};d.prototype.onMouseDown=function(a){this._mouseDownTimeStamp=a.timeStamp;if((2!==
-a.button||!this.hasSelection)&&0===a.button){if(!this._enabled){if(!this.shouldForceSelection(a))return;a.stopPropagation()}a.preventDefault();this._dragScrollAmount=0;this._enabled&&a.shiftKey?this._onIncrementalClick(a):1===a.detail?this._onSingleClick(a):2===a.detail?this._onDoubleClick(a):3===a.detail&&this._onTripleClick(a);this._addMouseDownListeners();this.refresh(!0)}};d.prototype._addMouseDownListeners=function(){var a=this;this._terminal.element.ownerDocument.addEventListener("mousemove",
-this._mouseMoveListener);this._terminal.element.ownerDocument.addEventListener("mouseup",this._mouseUpListener);this._dragScrollIntervalTimer=setInterval(function(){return a._dragScroll()},50)};d.prototype._removeMouseDownListeners=function(){this._terminal.element.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener);this._terminal.element.ownerDocument.removeEventListener("mouseup",this._mouseUpListener);clearInterval(this._dragScrollIntervalTimer);this._dragScrollIntervalTimer=
-null};d.prototype._onIncrementalClick=function(a){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(a))};d.prototype._onSingleClick=function(a){this._model.selectionStartLength=0;this._model.isSelectAllActive=!1;this._activeSelectionMode=n.NORMAL;this._model.selectionStart=this._getMouseBufferCoords(a);this._model.selectionStart&&(this._model.selectionEnd=null,(a=this._buffer.lines.get(this._model.selectionStart[1]))&&(a.length>=this._model.selectionStart[0]||0===a[this._model.selectionStart[0]][e.CHAR_DATA_WIDTH_INDEX]&&
-this._model.selectionStart[0]++))};d.prototype._onDoubleClick=function(a){if(a=this._getMouseBufferCoords(a))this._activeSelectionMode=n.WORD,this._selectWordAt(a,!0)};d.prototype._onTripleClick=function(a){if(a=this._getMouseBufferCoords(a))this._activeSelectionMode=n.LINE,this._selectLineAt(a[1])};d.prototype._onMouseMove=function(a){a.stopImmediatePropagation();var c=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;this._model.selectionEnd=this._getMouseBufferCoords(a);
-this._model.selectionEnd?(this._activeSelectionMode===n.LINE?this._model.selectionEnd[0]=this._model.selectionEnd[1]this._dragScrollAmount&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=this.selectionText.length&&500>c?(new g.AltClickHandler(a,this._terminal)).move():this.hasSelection&&this._terminal.emit("selection")};d.prototype._onBufferActivate=function(a){this.clearSelection();a.inactiveBuffer.lines.off("trim",this._trimListener);a.activeBuffer.lines.on("trim",this._trimListener)};d.prototype._convertViewportColToCharacterIndex=function(a,c){for(var g=c[0],d=0;c[0]>=
-d;d++){var k=a[d];0===k[e.CHAR_DATA_WIDTH_INDEX]?g--:1d[1]||a[1]===d[1]&&a[0]>d[0]:!1};a.prototype.onTrim=function(a){this.selectionStart&&(this.selectionStart[1]-=
-a);this.selectionEnd&&(this.selectionEnd[1]-=a);if(this.selectionEnd&&0>this.selectionEnd[1])return this.clearSelection(),!0;this.selectionStart&&0>this.selectionStart[1]&&(this.selectionStart[1]=0);return!1};return a}();d.SelectionModel=a},{}],13:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var e in c)c.hasOwnProperty(e)&&(a[e]=c[e])};return function(c,e){function g(){this.constructor=
-c}a(c,e);c.prototype=null===e?Object.create(e):(g.prototype=e.prototype,new g)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("./BufferSet"),l=a("./Buffer"),k=a("./CompositionHelper");h=a("./EventEmitter");var e=a("./Viewport"),g=a("./handlers/Clipboard"),c=a("./EscapeSequences"),n=a("./InputHandler"),p=a("./Parser"),q=a("./renderer/Renderer"),r=a("./Linkifier"),t=a("./SelectionManager"),y=a("./utils/CharMeasure"),v=a("./shared/utils/Browser"),C=a("./utils/MouseHelper"),z=a("./utils/Sounds"),
-x=a("./renderer/ColorManager"),B=a("./input/MouseZoneManager"),u="undefined"!==typeof window?window.document:null,A={cols:80,rows:24,convertEol:!1,termName:"xterm",cursorBlink:!1,cursorStyle:"block",bellSound:z.BELL_SOUND,bellStyle:"none",enableBold:!0,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",lineHeight:1,letterSpacing:0,scrollback:1E3,screenKeys:!1,debug:!1,macOptionIsMeta:!1,cancelEvents:!1,disableStdin:!1,useFlowControl:!1,allowTransparency:!1,
-tabStopWidth:8,theme:null,rightClickSelectsWord:v.isMac};a=function(a){function d(c){void 0===c&&(c={});var e=a.call(this)||this;e.browser=v;e.options=c;e.setup();return e}f(d,a);d.prototype.setup=function(){var a=this;Object.keys(A).forEach(function(c){null==a.options[c]&&(a.options[c]=A[c]);a[c]=a.options[c]});this.parent=u?u.body:null;this.cols=this.options.cols;this.rows=this.options.rows;if(this.options.handler)this.on("data",this.options.handler);this.cursorState=0;this.cursorHidden=!1;this.sendDataQueue=
-"";this.customKeyEventHandler=null;this.insertMode=this.originMode=this.applicationCursor=this.applicationKeypad=!1;this.wraparoundMode=!0;this.bracketedPasteMode=!1;this.gcharset=this.charset=null;this.glevel=0;this.charsets=[null];this.writable=this.readable=!0;this.curAttr=this.defAttr=131840;this.params=[];this.currentParam=0;this.postfix=this.prefix="";this.writeBuffer=[];this.writeStopped=this.xoffSentToCatchUp=this.writeInProgress=!1;this.surrogateHigh="";this.userScrolling=!1;this.inputHandler=
-new n.InputHandler(this);this.parser=new p.Parser(this.inputHandler,this);this.renderer=this.renderer||null;this.selectionManager=this.selectionManager||null;this.linkifier=this.linkifier||new r.Linkifier(this);this._mouseZoneManager=this._mouseZoneManager||null;this.buffers=new m.BufferSet(this);this.selectionManager&&(this.selectionManager.clearSelection(),this.selectionManager.initBuffersListeners())};Object.defineProperty(d.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!0,
-configurable:!0});d.prototype.eraseAttr=function(){return this.defAttr&-512|this.curAttr&511};d.prototype.focus=function(){this.textarea&&this.textarea.focus()};Object.defineProperty(d.prototype,"isFocused",{get:function(){return u.activeElement===this.textarea},enumerable:!0,configurable:!0});d.prototype.getOption=function(a){if(!(a in A))throw Error('No option with key "'+a+'"');return"undefined"!==typeof this.options[a]?this.options[a]:this[a]};d.prototype.setOption=function(a,c){if(!(a in A))throw Error('No option with key "'+
-a+'"');switch(a){case "bellStyle":c||(c="none");break;case "cursorStyle":c||(c="block");break;case "fontWeight":c||(c="normal");break;case "fontWeightBold":c||(c="bold");break;case "lineHeight":if(1>c){console.warn(a+" cannot be less than 1, value: "+c);return}case "tabStopWidth":if(1>c){console.warn(a+" cannot be less than 1, value: "+c);return}break;case "theme":if(this.renderer){this._setTheme(c);return}break;case "scrollback":c=Math.min(c,l.MAX_BUFFER_SIZE);if(0>c){console.warn(a+" cannot be less than 0, value: "+
-c);return}if(this.options[a]!==c){var e=this.rows+c;if(this.buffer.lines.length>e){e=this.buffer.lines.length-e;var d=0>this.buffer.ydisp-e;this.buffer.lines.trimStart(e);this.buffer.ybase=Math.max(this.buffer.ybase-e,0);this.buffer.ydisp=Math.max(this.buffer.ydisp-e,0);d&&this.refresh(0,this.rows-1)}}}this[a]=c;this.options[a]=c;switch(a){case "fontFamily":case "fontSize":this.renderer.clear();this.charMeasure.measure(this.options);break;case "enableBold":case "letterSpacing":case "lineHeight":case "fontWeight":case "fontWeightBold":a=
-"fontWeight"===a||"fontWeightBold"===a||"enableBold"===a,this.renderer.clear(),this.renderer.onResize(this.cols,this.rows,a),this.refresh(0,this.rows-1);case "scrollback":this.buffers.resize(this.cols,this.rows);this.viewport.syncScrollArea();break;case "tabStopWidth":this.buffers.setupTabStops();break;case "bellSound":case "bellStyle":this.syncBellSound()}if(this.renderer)this.renderer.onOptionsChanged()};d.prototype._onTextAreaFocus=function(){this.sendFocus&&this.send(c.C0.ESC+"[I");this.element.classList.add("focus");
-this.showCursor();this.emit("focus")};d.prototype.blur=function(){return this.textarea.blur()};d.prototype._onTextAreaBlur=function(){this.refresh(this.buffer.y,this.buffer.y);this.sendFocus&&this.send(c.C0.ESC+"[O");this.element.classList.remove("focus");this.emit("blur")};d.prototype.initGlobal=function(){var a=this;this.bindKeys();w(this.element,"copy",function(c){a.hasSelection()&&g.copyHandler(c,a,a.selectionManager)});var c=function(c){return g.pasteHandler(c,a)};w(this.textarea,"paste",c);
-w(this.element,"paste",c);v.isFirefox?w(this.element,"mousedown",function(c){2===c.button&&g.rightClickHandler(c,a.textarea,a.selectionManager,a.options.rightClickSelectsWord)}):w(this.element,"contextmenu",function(c){g.rightClickHandler(c,a.textarea,a.selectionManager,a.options.rightClickSelectsWord)});v.isLinux&&w(this.element,"auxclick",function(c){1===c.button&&g.moveTextAreaUnderMouseCursor(c,a.textarea)})};d.prototype.bindKeys=function(){var a=this,c=this;w(this.element,"keydown",function(a){u.activeElement===
-this&&c._keyDown(a)},!0);w(this.element,"keypress",function(a){u.activeElement===this&&c._keyPress(a)},!0);w(this.element,"keyup",function(c){16!==c.keyCode&&17!==c.keyCode&&18!==c.keyCode&&a.focus()},!0);w(this.textarea,"keydown",function(c){a._keyDown(c)},!0);w(this.textarea,"keypress",function(c){a._keyPress(c);a.textarea.value=""},!0);w(this.textarea,"compositionstart",function(){return a.compositionHelper.compositionstart()});w(this.textarea,"compositionupdate",function(c){return a.compositionHelper.compositionupdate(c)});
-w(this.textarea,"compositionend",function(){return a.compositionHelper.compositionend()});this.on("refresh",function(){return a.compositionHelper.updateCompositionElements()});this.on("refresh",function(c){return a.queueLinkification(c.start,c.end)})};d.prototype.open=function(a){var c=this;this.parent=a||this.parent;if(!this.parent)throw Error("Terminal requires a parent element.");this.context=this.parent.ownerDocument.defaultView;this.document=this.parent.ownerDocument;this.body=this.document.body;
-this.element=this.document.createElement("div");this.element.classList.add("terminal");this.element.classList.add("xterm");this.element.setAttribute("tabindex","0");this.parent.appendChild(this.element);a=u.createDocumentFragment();this.viewportElement=u.createElement("div");this.viewportElement.classList.add("xterm-viewport");a.appendChild(this.viewportElement);this.viewportScrollArea=u.createElement("div");this.viewportScrollArea.classList.add("xterm-scroll-area");this.viewportElement.appendChild(this.viewportScrollArea);
-this.screenElement=u.createElement("div");this.screenElement.classList.add("xterm-screen");this.helperContainer=u.createElement("div");this.helperContainer.classList.add("xterm-helpers");this.screenElement.appendChild(this.helperContainer);a.appendChild(this.screenElement);this._mouseZoneManager=new B.MouseZoneManager(this);this.on("scroll",function(){return c._mouseZoneManager.clearAll()});this.linkifier.attachToDom(this._mouseZoneManager);this.textarea=u.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea");
-this.textarea.setAttribute("autocorrect","off");this.textarea.setAttribute("autocapitalize","off");this.textarea.setAttribute("spellcheck","false");this.textarea.tabIndex=0;this.textarea.addEventListener("focus",function(){return c._onTextAreaFocus()});this.textarea.addEventListener("blur",function(){return c._onTextAreaBlur()});this.helperContainer.appendChild(this.textarea);this.compositionView=u.createElement("div");this.compositionView.classList.add("composition-view");this.compositionHelper=
-new k.CompositionHelper(this.textarea,this.compositionView,this);this.helperContainer.appendChild(this.compositionView);this.charSizeStyleElement=u.createElement("style");this.helperContainer.appendChild(this.charSizeStyleElement);this.charMeasure=new y.CharMeasure(u,this.helperContainer);this.syncBellSound();this.element.appendChild(a);this.renderer=new q.Renderer(this,this.options.theme);this.options.theme=null;this.viewport=new e.Viewport(this,this.viewportElement,this.viewportScrollArea,this.charMeasure);
-this.viewport.onThemeChanged(this.renderer.colorManager.colors);this.on("cursormove",function(){return c.renderer.onCursorMove()});this.on("resize",function(){return c.renderer.onResize(c.cols,c.rows,!1)});this.on("blur",function(){return c.renderer.onBlur()});this.on("focus",function(){return c.renderer.onFocus()});this.charMeasure.on("charsizechanged",function(){return c.renderer.onResize(c.cols,c.rows,!0)});this.renderer.on("resize",function(a){return c.viewport.syncScrollArea()});this.selectionManager=
-new t.SelectionManager(this,this.charMeasure);this.element.addEventListener("mousedown",function(a){return c.selectionManager.onMouseDown(a)});this.selectionManager.on("refresh",function(a){return c.renderer.onSelectionChanged(a.start,a.end)});this.selectionManager.on("newselection",function(a){c.textarea.value=a;c.textarea.focus();c.textarea.select()});this.on("scroll",function(){c.viewport.syncScrollArea();c.selectionManager.refresh()});this.viewportElement.addEventListener("scroll",function(){return c.selectionManager.refresh()});
-this.mouseHelper=new C.MouseHelper(this.renderer);this.charMeasure.measure(this.options);this.refresh(0,this.rows-1);this.initGlobal();this.bindMouse()};d.prototype._setTheme=function(a){a=this.renderer.setTheme(a);if(this.viewport)this.viewport.onThemeChanged(a)};d.applyAddon=function(a){a.apply(d)};d.prototype.bindMouse=function(){function a(a){switch(a.overrideType||a.type){case "mousedown":var c=null!=a.button?+a.button:null!=a.which?a.which-1:null;v.isMSIE&&(c=1===c?0:4===c?1:c);break;case "mouseup":c=
-3;break;case "DOMMouseScroll":c=0>a.detail?64:65;break;case "wheel":c=0c?a.push(c):(2047>6),a.push(128|c&63)):255===c?a.push(0):(127a){if(0===this.buffer.ydisp)return;
-this.userScrolling=!0}else a+this.buffer.ydisp>=this.buffer.ybase&&(this.userScrolling=!1);var e=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+a,this.buffer.ybase),0);e!==this.buffer.ydisp&&(c||this.emit("scroll",this.buffer.ydisp),this.refresh(0,this.rows-1))};d.prototype.scrollPages=function(a){this.scrollLines(a*(this.rows-1))};d.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)};d.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-
-this.buffer.ydisp)};d.prototype.write=function(a){var e=this;this.writeBuffer.push(a);this.options.useFlowControl&&!this.xoffSentToCatchUp&&5<=this.writeBuffer.length&&(this.send(c.C0.DC3),this.xoffSentToCatchUp=!0);!this.writeInProgress&&0=a.keyCode?e.key=c.C0.ESC+String.fromCharCode(a.keyCode+32):192===a.keyCode?e.key=c.C0.ESC+"`":48<=a.keyCode&&57>=a.keyCode&&(e.key=c.C0.ESC+(a.keyCode-48)):65<=a.keyCode&&90>=a.keyCode?e.key=String.fromCharCode(a.keyCode-64):32===a.keyCode?e.key=String.fromCharCode(0):51<=a.keyCode&&
-55>=a.keyCode?e.key=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?e.key=String.fromCharCode(127):219===a.keyCode?e.key=String.fromCharCode(27):220===a.keyCode?e.key=String.fromCharCode(28):221===a.keyCode&&(e.key=String.fromCharCode(29))}return e};d.prototype.setgLevel=function(a){this.glevel=a;this.charset=this.charsets[a]};d.prototype.setgCharset=function(a,c){this.charsets[a]=c;this.glevel===a&&(this.charset=c)};d.prototype._keyPress=function(a){if(this.customKeyEventHandler&&!1===this.customKeyEventHandler(a))return!1;
-this.cancel(a);if(a.charCode)var c=a.charCode;else if(null==a.which)c=a.keyCode;else if(0!==a.which&&0!==a.charCode)c=a.which;else return!1;if(!c||(a.altKey||a.ctrlKey||a.metaKey)&&!this._isThirdLevelShift(this.browser,a))return!1;c=String.fromCharCode(c);this.emit("keypress",c,a);this.emit("key",c,a);this.showCursor();this.handler(c);return!0};d.prototype.send=function(a){var c=this;this.sendDataQueue||setTimeout(function(){c.handler(c.sendDataQueue);c.sendDataQueue=""},1);this.sendDataQueue+=a};
-d.prototype.bell=function(){var a=this;this.emit("bell");this.soundBell()&&this.bellAudioElement.play();this.visualBell()&&(this.element.classList.add("visual-bell-active"),clearTimeout(this.visualBellTimer),this.visualBellTimer=window.setTimeout(function(){a.element.classList.remove("visual-bell-active")},200))};d.prototype.log=function(a,c){this.options.debug&&this.context.console&&this.context.console.log&&this.context.console.log(a,c)};d.prototype.error=function(a,c){this.options.debug&&this.context.console&&
-this.context.console.error&&this.context.console.error(a,c)};d.prototype.resize=function(a,c){isNaN(a)||isNaN(c)||(a===this.cols&&c===this.rows?this.charMeasure.width&&this.charMeasure.height||this.charMeasure.measure(this.options):(1>a&&(a=1),1>c&&(c=1),this.buffers.resize(a,c),this.cols=a,this.rows=c,this.buffers.setupTabStops(this.cols),this.charMeasure.measure(this.options),this.refresh(0,this.rows-1),this.emit("resize",{cols:a,rows:c})))};d.prototype.updateRange=function(a){athis.refreshEnd&&(this.refreshEnd=a)};d.prototype.maxRange=function(){this.refreshStart=0;this.refreshEnd=this.rows-1};d.prototype.eraseRight=function(a,c){var e=this.buffer.lines.get(this.buffer.ybase+c);if(e){for(var d=[this.eraseAttr()," ",1,32];athis.buffer.scrollBottom&&(this.buffer.y--,this.scroll());this.buffer.x>=this.cols&&this.buffer.x--};d.prototype.reverseIndex=function(){this.buffer.y===this.buffer.scrollTop?(this.buffer.lines.shiftElements(this.buffer.y+this.buffer.ybase,this.buffer.scrollBottom-this.buffer.scrollTop,1),this.buffer.lines.set(this.buffer.y+this.buffer.ybase,this.blankLine(!0)),this.updateRange(this.buffer.scrollTop),this.updateRange(this.buffer.scrollBottom)):
-this.buffer.y--};d.prototype.reset=function(){this.options.rows=this.rows;this.options.cols=this.cols;var a=this.customKeyEventHandler,c=this.inputHandler;this.setup();this.customKeyEventHandler=a;this.inputHandler=c;this.refresh(0,this.rows-1);this.viewport.syncScrollArea()};d.prototype.tabSet=function(){this.buffer.tabs[this.buffer.x]=!0};d.prototype.cancel=function(a,c){if(this.options.cancelEvents||c)return a.preventDefault(),a.stopPropagation(),!1};d.prototype.matchColor=function(a,c,e){var d=
-a<<16|c<<8|e;if(null!=E[d])a=E[d];else{for(var g=Infinity,k=-1,l=0,f,h,m;le;e++)a.push([c[e/36%6|0],c[e/6%6|0],c[e%6]]);for(e=0;24>e;e++)c=8+10*e,a.push([c,c,c]);return a}(),E={}},{"./Buffer":1,"./BufferSet":2,"./CompositionHelper":5,"./EscapeSequences":6,"./EventEmitter":7,"./InputHandler":8,"./Linkifier":9,"./Parser":10,"./SelectionManager":11,"./Viewport":15,"./handlers/Clipboard":17,"./input/MouseZoneManager":18,"./renderer/ColorManager":21,
-"./renderer/Renderer":25,"./shared/utils/Browser":30,"./utils/CharMeasure":31,"./utils/MouseHelper":33,"./utils/Sounds":35}],14:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});a=d.LinkHoverEventTypes||(d.LinkHoverEventTypes={});a.HOVER="linkhover";a.TOOLTIP="linktooltip";a.LEAVE="linkleave"},{}],15:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});a=function(){function a(a,d,k,e){var g=this;this.terminal=a;this.viewportElement=d;this.scrollArea=k;this.charMeasure=
-e;this.lastRecordedBufferHeight=this.lastRecordedViewportHeight=this.lastRecordedBufferLength=this.currentRowHeight=this.scrollBarWidth=0;this.scrollBarWidth=this.viewportElement.offsetWidth-this.scrollArea.offsetWidth||15;this.viewportElement.addEventListener("scroll",this.onScroll.bind(this));setTimeout(function(){return g.syncScrollArea()},0)}a.prototype.onThemeChanged=function(a){this.viewportElement.style.backgroundColor=a.background};a.prototype.refresh=function(){if(0=this._endCol&&athis._endRow?l.Up:l.Down};a.prototype._bufferLine=function(a,d,c,k,l){for(var e=a,g="";e!==c||d!==k;)e+=l?1:-1,l&&e>this._terminal.cols-1?(g+=this._terminal.buffer.translateBufferLineToString(d,!1,a,e),a=e=0,d++):!l&&0>e&&(g+=this._terminal.buffer.translateBufferLineToString(d,!1,0,a+1),a=e=this._terminal.cols-1,d--);return g+this._terminal.buffer.translateBufferLineToString(d,!1,a,e)};a.prototype._sequence=function(a){return m.C0.ESC+(this._terminal.applicationCursor?
-"O":"[")+a};return a}();d.AltClickHandler=a},{"../EscapeSequences":6}],17:[function(a,h,d){function f(a,e){return e?a.replace(/\r?\n/g,"\r"):a}function m(a,e){return e?"\u001b[200~"+a+"\u001b[201~":a}function l(a,e){e.style.position="fixed";e.style.width="20px";e.style.height="20px";e.style.left=a.clientX-10+"px";e.style.top=a.clientY-10+"px";e.style.zIndex="1000";e.focus();setTimeout(function(){e.style.position=null;e.style.width=null;e.style.height=null;e.style.left=null;e.style.top=null;e.style.zIndex=
-null},200)}Object.defineProperty(d,"__esModule",{value:!0});d.prepareTextForTerminal=f;d.bracketTextForPaste=m;d.copyHandler=function(a,e,d){e.browser.isMSIE?window.clipboardData.setData("Text",d.selectionText):a.clipboardData.setData("text/plain",d.selectionText);a.preventDefault()};d.pasteHandler=function(a,e){a.stopPropagation();var d=function(c){c=f(c,e.browser.isMSWindows);c=m(c,e.bracketedPasteMode);e.handler(c);e.textarea.value="";e.emit("paste",c);e.cancel(a)};if(e.browser.isMSIE){if(window.clipboardData){var c=
-window.clipboardData.getData("Text");d(c)}}else a.clipboardData&&(c=a.clipboardData.getData("text/plain"),d(c))};d.moveTextAreaUnderMouseCursor=l;d.rightClickHandler=function(a,e,d,c){l(a,e);c&&!d.isClickInSelection(a)&&d.selectWordAtCursor(a);e.value=d.selectionText;e.select()}},{}],18:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});a=function(){function a(a){var d=this;this._terminal=a;this._zones=[];this._areZonesActive=!1;this._currentZone=this._tooltipTimeout=null;this._lastHoverCoords=
-[null,null];this._terminal.element.addEventListener("mousedown",function(a){return d._onMouseDown(a)});this._mouseMoveListener=function(a){return d._onMouseMove(a)};this._clickListener=function(a){return d._onClick(a)}}a.prototype.add=function(a){this._zones.push(a);1===this._zones.length&&this._activate()};a.prototype.clearAll=function(a,d){if(0!==this._zones.length){d||(a=0,d=this._terminal.rows-1);for(var k=0;ka&&e.y<=d+1&&(this._currentZone&&this._currentZone===
-e&&(this._currentZone.leaveCallback(),this._currentZone=null),this._zones.splice(k--,1))}0===this._zones.length&&this._deactivate()}};a.prototype._activate=function(){this._areZonesActive||(this._areZonesActive=!0,this._terminal.element.addEventListener("mousemove",this._mouseMoveListener),this._terminal.element.addEventListener("click",this._clickListener))};a.prototype._deactivate=function(){this._areZonesActive&&(this._areZonesActive=!1,this._terminal.element.removeEventListener("mousemove",this._mouseMoveListener),
-this._terminal.element.removeEventListener("click",this._clickListener))};a.prototype._onMouseMove=function(a){if(this._lastHoverCoords[0]!==a.pageX||this._lastHoverCoords[1]!==a.pageY)this._onHover(a),this._lastHoverCoords=[a.pageX,a.pageY]};a.prototype._onHover=function(a){var d=this,k=this._findZoneEventAt(a);k!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=null,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),k&&(this._currentZone=k,k.hoverCallback&&
-k.hoverCallback(a),this._tooltipTimeout=setTimeout(function(){return d._onTooltip(a)},500)))};a.prototype._onTooltip=function(a){this._tooltipTimeout=null;var d=this._findZoneEventAt(a);d&&d.tooltipCallback&&d.tooltipCallback(a)};a.prototype._onMouseDown=function(a){if(this._areZonesActive){var d=this._findZoneEventAt(a);d&&d.willLinkActivate(a)&&(a.preventDefault(),a.stopImmediatePropagation())}};a.prototype._onClick=function(a){var d=this._findZoneEventAt(a);d&&(d.clickCallback(a),a.preventDefault(),
-a.stopImmediatePropagation())};a.prototype._findZoneEventAt=function(a){a=this._terminal.mouseHelper.getCoords(a,this._terminal.screenElement,this._terminal.charMeasure,this._terminal.options.lineHeight,this._terminal.cols,this._terminal.rows);if(!a)return null;for(var d=0;da[0])return k}return null};return a}();d.MouseZoneManager=a;a=function(){return function(a,d,l,k,e,g,c,h){this.x1=a;this.x2=d;this.y=l;this.clickCallback=
-k;this.hoverCallback=e;this.tooltipCallback=g;this.leaveCallback=c;this.willLinkActivate=h}}();d.MouseZone=a},{}],19:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});var f=a("./CharAtlas"),m=a("../Buffer");d.INVERTED_DEFAULT_COLOR=-1;a=function(){function a(a,e,d,c,l){this._container=a;this._alpha=c;this._colors=l;this._scaledCharTop=this._scaledCharLeft=this._scaledCellHeight=this._scaledCellWidth=this._scaledCharHeight=this._scaledCharWidth=0;this._canvas=document.createElement("canvas");
-this._canvas.classList.add("xterm-"+e+"-layer");this._canvas.style.zIndex=d.toString();this._initCanvas();this._container.appendChild(this._canvas)}a.prototype._initCanvas=function(){this._ctx=this._canvas.getContext("2d",{alpha:this._alpha});this._alpha||this.clearAll()};a.prototype.onOptionsChanged=function(a){};a.prototype.onBlur=function(a){};a.prototype.onFocus=function(a){};a.prototype.onCursorMove=function(a){};a.prototype.onGridChanged=function(a,e,d){};a.prototype.onSelectionChanged=function(a,
-e,d){};a.prototype.onThemeChanged=function(a,e){this._refreshCharAtlas(a,e)};a.prototype.setTransparency=function(a,e){if(e!==this._alpha){var d=this._canvas;this._alpha=e;this._canvas=this._canvas.cloneNode();this._initCanvas();this._container.replaceChild(this._canvas,d);this._refreshCharAtlas(a,this._colors);this.onGridChanged(a,0,a.rows-1)}};a.prototype._refreshCharAtlas=function(a,e){var d=this;0>=this._scaledCharWidth&&0>=this._scaledCharHeight||(this._charAtlas=null,a=f.acquireCharAtlas(a,
-e,this._scaledCharWidth,this._scaledCharHeight),a instanceof HTMLCanvasElement?this._charAtlas=a:a.then(function(a){return d._charAtlas=a}))};a.prototype.resize=function(a,e,d){this._scaledCellWidth=e.scaledCellWidth;this._scaledCellHeight=e.scaledCellHeight;this._scaledCharWidth=e.scaledCharWidth;this._scaledCharHeight=e.scaledCharHeight;this._scaledCharLeft=e.scaledCharLeft;this._scaledCharTop=e.scaledCharTop;this._canvas.width=e.scaledCanvasWidth;this._canvas.height=e.scaledCanvasHeight;this._canvas.style.width=
-e.canvasWidth+"px";this._canvas.style.height=e.canvasHeight+"px";this._alpha||this.clearAll();d&&this._refreshCharAtlas(a,this._colors)};a.prototype.fillCells=function(a,e,d,c){this._ctx.fillRect(a*this._scaledCellWidth,e*this._scaledCellHeight,d*this._scaledCellWidth,c*this._scaledCellHeight)};a.prototype.fillBottomLineAtCells=function(a,e,d){void 0===d&&(d=1);this._ctx.fillRect(a*this._scaledCellWidth,(e+1)*this._scaledCellHeight-window.devicePixelRatio-1,d*this._scaledCellWidth,window.devicePixelRatio)};
-a.prototype.fillLeftLineAtCell=function(a,e){this._ctx.fillRect(a*this._scaledCellWidth,e*this._scaledCellHeight,window.devicePixelRatio,this._scaledCellHeight)};a.prototype.strokeRectAtCell=function(a,e,d,c){this._ctx.lineWidth=window.devicePixelRatio;this._ctx.strokeRect(a*this._scaledCellWidth+window.devicePixelRatio/2,e*this._scaledCellHeight+window.devicePixelRatio/2,d*this._scaledCellWidth-window.devicePixelRatio,c*this._scaledCellHeight-window.devicePixelRatio)};a.prototype.clearAll=function(){this._alpha?
-this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))};a.prototype.clearCells=function(a,e,d,c){this._alpha?this._ctx.clearRect(a*this._scaledCellWidth,e*this._scaledCellHeight,d*this._scaledCellWidth,c*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background,this._ctx.fillRect(a*this._scaledCellWidth,e*this._scaledCellHeight,d*this._scaledCellWidth,c*this._scaledCellHeight))};
-a.prototype.fillCharTrueColor=function(a,e,d,c){this._ctx.font=this._getFont(a,!1);this._ctx.textBaseline="top";this._clipRow(a,c);this._ctx.fillText(e[m.CHAR_DATA_CHAR_INDEX],d*this._scaledCellWidth+this._scaledCharLeft,c*this._scaledCellHeight+this._scaledCharTop)};a.prototype.drawChar=function(a,e,d,c,l,h,m,r,t,y){var g=0;256>m?g=m+2:t&&a.options.enableBold&&(g=1);this._charAtlas&&256>d&&(1m&&(8>m||t)||256<=m)&&256<=r?(e=this._scaledCharWidth+f.CHAR_ATLAS_CELL_SPACING,c=this._scaledCharHeight+
-f.CHAR_ATLAS_CELL_SPACING,y&&(this._ctx.globalAlpha=.5),t&&!a.options.enableBold&&1c?this._colors.ansi[c]:this._colors.foreground;this._clipRow(a,f);m&&(this._ctx.globalAlpha=.5);this._ctx.fillText(e,l*this._scaledCellWidth+this._scaledCharLeft,f*this._scaledCellHeight+this._scaledCharTop);this._ctx.restore()};a.prototype._clipRow=function(a,e){this._ctx.beginPath();this._ctx.rect(0,e*this._scaledCellHeight,a.cols*this._scaledCellWidth,this._scaledCellHeight);this._ctx.clip()};a.prototype._getFont=function(a,e){return(e?a.options.fontWeightBold:
-a.options.fontWeight)+" "+a.options.fontSize*window.devicePixelRatio+"px "+a.options.fontFamily};return a}();d.BaseRenderLayer=a},{"../Buffer":1,"./CharAtlas":20}],20:[function(a,h,d){function f(a,d,c,k){k={foreground:k.foreground,background:k.background,cursor:null,cursorAccent:null,selection:null,ansi:k.ansi.slice(0,16)};return{scaledCharWidth:a,scaledCharHeight:d,fontFamily:c.options.fontFamily,fontSize:c.options.fontSize,fontWeight:c.options.fontWeight,fontWeightBold:c.options.fontWeightBold,
-allowTransparency:c.options.allowTransparency,colors:k}}function m(a,d){for(var c=0;ca.length?
-"0"+a:a}Object.defineProperty(d,"__esModule",{value:!0});d.DEFAULT_ANSI_COLORS="#2e3436 #cc0000 #4e9a06 #c4a000 #3465a4 #75507b #06989a #d3d7cf #555753 #ef2929 #8ae234 #fce94f #729fcf #ad7fa8 #34e2e2 #eeeeec".split(" ");a=function(){function a(){for(var a=d.DEFAULT_ANSI_COLORS.slice(),k=[0,95,135,175,215,255],e=0;216>e;e++){var g=f(k[e/36%6|0]),c=f(k[e/6%6|0]),h=f(k[e%6]);a.push("#"+g+c+h)}for(e=0;24>e;e++)k=f(8+10*e),a.push("#"+k+k+k);this.colors={foreground:"#ffffff",background:"#000000",cursor:"#ffffff",
-cursorAccent:"#000000",selection:"rgba(255, 255, 255, 0.3)",ansi:a}}a.prototype.setTheme=function(a){this.colors.foreground=a.foreground||"#ffffff";this.colors.background=a.background||"#000000";this.colors.cursor=a.cursor||"#ffffff";this.colors.cursorAccent=a.cursorAccent||"#000000";this.colors.selection=a.selection||"rgba(255, 255, 255, 0.3)";this.colors.ansi[0]=a.black||d.DEFAULT_ANSI_COLORS[0];this.colors.ansi[1]=a.red||d.DEFAULT_ANSI_COLORS[1];this.colors.ansi[2]=a.green||d.DEFAULT_ANSI_COLORS[2];
-this.colors.ansi[3]=a.yellow||d.DEFAULT_ANSI_COLORS[3];this.colors.ansi[4]=a.blue||d.DEFAULT_ANSI_COLORS[4];this.colors.ansi[5]=a.magenta||d.DEFAULT_ANSI_COLORS[5];this.colors.ansi[6]=a.cyan||d.DEFAULT_ANSI_COLORS[6];this.colors.ansi[7]=a.white||d.DEFAULT_ANSI_COLORS[7];this.colors.ansi[8]=a.brightBlack||d.DEFAULT_ANSI_COLORS[8];this.colors.ansi[9]=a.brightRed||d.DEFAULT_ANSI_COLORS[9];this.colors.ansi[10]=a.brightGreen||d.DEFAULT_ANSI_COLORS[10];this.colors.ansi[11]=a.brightYellow||d.DEFAULT_ANSI_COLORS[11];
-this.colors.ansi[12]=a.brightBlue||d.DEFAULT_ANSI_COLORS[12];this.colors.ansi[13]=a.brightMagenta||d.DEFAULT_ANSI_COLORS[13];this.colors.ansi[14]=a.brightCyan||d.DEFAULT_ANSI_COLORS[14];this.colors.ansi[15]=a.brightWhite||d.DEFAULT_ANSI_COLORS[15]};return a}();d.ColorManager=a},{}],22:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,d){a.__proto__=d}||function(a,d){for(var c in d)d.hasOwnProperty(c)&&(a[c]=d[c])};return function(e,
-d){function c(){this.constructor=e}a(e,d);e.prototype=null===d?Object.create(d):(c.prototype=d.prototype,new c)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("../Buffer");a=function(a){function e(e,c,d){e=a.call(this,e,"cursor",c,!0,d)||this;e._state={x:null,y:null,isFocused:null,style:null,width:null};e._cursorRenderers={bar:e._renderBarCursor.bind(e),block:e._renderBlockCursor.bind(e),underline:e._renderUnderlineCursor.bind(e)};return e}f(e,a);e.prototype.resize=function(e,c,d){a.prototype.resize.call(this,
-e,c,d);this._state={x:null,y:null,isFocused:null,style:null,width:null}};e.prototype.reset=function(a){this._clearCursor();this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=null,this.onOptionsChanged(a))};e.prototype.onBlur=function(a){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause();a.refresh(a.buffer.y,a.buffer.y)};e.prototype.onFocus=function(a){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume(a):a.refresh(a.buffer.y,
-a.buffer.y)};e.prototype.onOptionsChanged=function(a){var c=this;a.options.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new l(a,function(){c._render(a,!0)})):(this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=null),a.refresh(a.buffer.y,a.buffer.y))};e.prototype.onCursorMove=function(a){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation(a)};e.prototype.onGridChanged=function(a,c,e){!this._cursorBlinkStateManager||
-this._cursorBlinkStateManager.isPaused?this._render(a,!1):this._cursorBlinkStateManager.restartBlinkAnimation(a)};e.prototype._render=function(a,c){if(!a.cursorState||a.cursorHidden)this._clearCursor();else{var e=a.buffer.ybase+a.buffer.y;c=e-a.buffer.ydisp;if(0>c||c>=a.rows)this._clearCursor();else if(e=a.buffer.lines.get(e)[a.buffer.x])if(a.isFocused)if(this._cursorBlinkStateManager&&!this._cursorBlinkStateManager.isCursorVisible)this._clearCursor();else{if(this._state){if(this._state.x===a.buffer.x&&
-this._state.y===c&&this._state.isFocused===a.isFocused&&this._state.style===a.options.cursorStyle&&this._state.width===e[m.CHAR_DATA_WIDTH_INDEX])return;this._clearCursor()}this._ctx.save();this._cursorRenderers[a.options.cursorStyle||"block"](a,a.buffer.x,c,e);this._ctx.restore();this._state.x=a.buffer.x;this._state.y=c;this._state.isFocused=!1;this._state.style=a.options.cursorStyle;this._state.width=e[m.CHAR_DATA_WIDTH_INDEX]}else this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor,
-this._renderBlurCursor(a,a.buffer.x,c,e),this._ctx.restore(),this._state.x=a.buffer.x,this._state.y=c,this._state.isFocused=!1,this._state.style=a.options.cursorStyle,this._state.width=e[m.CHAR_DATA_WIDTH_INDEX]}};e.prototype._clearCursor=function(){this._state&&(this.clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:null,y:null,isFocused:null,style:null,width:null})};e.prototype._renderBarCursor=function(a,c,e,d){this._ctx.save();this._ctx.fillStyle=this._colors.cursor;this.fillLeftLineAtCell(c,
-e);this._ctx.restore()};e.prototype._renderBlockCursor=function(a,c,e,d){this._ctx.save();this._ctx.fillStyle=this._colors.cursor;this.fillCells(c,e,d[m.CHAR_DATA_WIDTH_INDEX],1);this._ctx.fillStyle=this._colors.cursorAccent;this.fillCharTrueColor(a,d,c,e);this._ctx.restore()};e.prototype._renderUnderlineCursor=function(a,c,e,d){this._ctx.save();this._ctx.fillStyle=this._colors.cursor;this.fillBottomLineAtCells(c,e);this._ctx.restore()};e.prototype._renderBlurCursor=function(a,c,e,d){this._ctx.save();
-this._ctx.strokeStyle=this._colors.cursor;this.strokeRectAtCell(c,e,d[m.CHAR_DATA_WIDTH_INDEX],1);this._ctx.restore()};return e}(a("./BaseRenderLayer").BaseRenderLayer);d.CursorRenderLayer=a;var l=function(){function a(a,d){this.renderCallback=d;this.isCursorVisible=!0;a.isFocused&&this._restartInterval()}Object.defineProperty(a.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0});a.prototype.dispose=function(){this._blinkInterval&&
-(window.clearInterval(this._blinkInterval),this._blinkInterval=null);this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=null);this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=null)};a.prototype.restartBlinkAnimation=function(a){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame(function(){e.renderCallback();
-e._animationFrame=null})))};a.prototype._restartInterval=function(a){var e=this;void 0===a&&(a=600);this._blinkInterval&&window.clearInterval(this._blinkInterval);this._blinkStartTimeout=setTimeout(function(){if(e._animationTimeRestarted){var a=600-(Date.now()-e._animationTimeRestarted);e._animationTimeRestarted=null;if(0e&&(e=this._refreshRowsQueue[d].end)}this._refreshRowsQueue=[];this._refreshAnimationFrame=null;c=Math.max(c,0);e=Math.min(e,this._terminal.rows-1);this._renderLayers.forEach(function(d){return d.onGridChanged(a._terminal,
-c,e)});this._terminal.emit("refresh",{start:c,end:e})};d.prototype._updateDimensions=function(){this._terminal.charMeasure.width&&this._terminal.charMeasure.height&&(this.dimensions.scaledCharWidth=Math.floor(this._terminal.charMeasure.width*window.devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._terminal.charMeasure.height*window.devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._terminal.options.lineHeight),this.dimensions.scaledCharTop=
-1===this._terminal.options.lineHeight?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._terminal.options.letterSpacing),this.dimensions.scaledCharLeft=Math.floor(this._terminal.options.letterSpacing/2),this.dimensions.scaledCanvasHeight=this._terminal.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._terminal.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=
-Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._terminal.rows,this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._terminal.cols)};return d}(h.EventEmitter);d.Renderer=a},{"../EventEmitter":7,"../utils/ScreenDprMonitor":34,"./ColorManager":21,"./CursorRenderLayer":22,"./LinkRenderLayer":24,"./SelectionRenderLayer":26,
-"./TextRenderLayer":27}],26:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,d){a.__proto__=d}||function(a,d){for(var e in d)d.hasOwnProperty(e)&&(a[e]=d[e])};return function(d,k){function e(){this.constructor=d}a(d,k);d.prototype=null===k?Object.create(k):(e.prototype=k.prototype,new e)}}();Object.defineProperty(d,"__esModule",{value:!0});a=function(a){function d(d,e,g){d=a.call(this,d,"selection",e,!0,g)||this;d._state=
-{start:null,end:null};return d}f(d,a);d.prototype.resize=function(d,e,g){a.prototype.resize.call(this,d,e,g);this._state={start:null,end:null}};d.prototype.reset=function(a){this._state.start&&this._state.end&&(this._state={start:null,end:null},this.clearAll())};d.prototype.onSelectionChanged=function(a,e,d){if(this._state.start!==e&&this._state.end!==d&&(this.clearAll(),e&&d)){var c=e[1]-a.buffer.ydisp,g=d[1]-a.buffer.ydisp,f=Math.max(c,0),k=Math.min(g,a.rows-1);if(!(f>=a.rows||0>k)){c=c===f?e[0]:
-0;var l=f===k?d[0]:a.cols;this._ctx.fillStyle=this._colors.selection;this.fillCells(c,f,l-c,1);this.fillCells(0,f+1,a.cols,Math.max(k-f-1,0));f!==k&&this.fillCells(0,k,g===k?d[0]:a.cols,1);this._state.start=[e[0],e[1]];this._state.end=[d[0],d[1]]}}};return d}(a("./BaseRenderLayer").BaseRenderLayer);d.SelectionRenderLayer=a},{"./BaseRenderLayer":19}],27:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,e){a.__proto__=e}||
-function(a,e){for(var c in e)e.hasOwnProperty(c)&&(a[c]=e[c])};return function(c,e){function d(){this.constructor=c}a(c,e);c.prototype=null===e?Object.create(e):(d.prototype=e.prototype,new d)}}();Object.defineProperty(d,"__esModule",{value:!0});var m=a("../Buffer"),l=a("./Types"),k=a("./GridCache"),e=a("./BaseRenderLayer");a=function(a){function c(c,e,d,g){c=a.call(this,c,"text",e,g,d)||this;c._characterOverlapCache={};c._state=new k.GridCache;return c}f(c,a);c.prototype.resize=function(c,e,d){a.prototype.resize.call(this,
-c,e,d);d=this._getFont(c,!1);if(this._characterWidth!==e.scaledCharWidth||this._characterFont!==d)this._characterWidth=e.scaledCharWidth,this._characterFont=d,this._characterOverlapCache={};this._state.clear();this._state.resize(c.cols,c.rows)};c.prototype.reset=function(a){this._state.clear();this.clearAll()};c.prototype.onGridChanged=function(a,c,d){if(0!==this._state.cache.length)for(;c<=d;c++){var g=a.buffer.lines.get(c+a.buffer.ydisp);this.clearCells(0,c,a.cols,1);for(var f=0;f>18,u=p&511,A=256<=u,w=B&l.FLAGS.INVISIBLE,D=B&l.FLAGS.INVERSE;!h||32===h&&A&&!D||w||(0!==q&&this._isOverlapping(k)&&f>9&511,D&&(D=u,u=k,k=D,256===k&&(k=e.INVERTED_DEFAULT_COLOR),257===u&&(u=e.INVERTED_DEFAULT_COLOR)),256>u&&(this._ctx.save(),this._ctx.fillStyle=
-u===e.INVERTED_DEFAULT_COLOR?this._colors.foreground:this._colors.ansi[u],this.fillCells(f,c,q,1),this._ctx.restore()),this._ctx.save(),B&l.FLAGS.BOLD&&(this._ctx.font=this._getFont(a,!0),8>k&&(k+=8)),B&l.FLAGS.UNDERLINE&&(this._ctx.fillStyle=k===e.INVERTED_DEFAULT_COLOR?this._colors.background:256>k?this._colors.ansi[k]:this._colors.foreground,this.fillBottomLineAtCells(f,c)),this.drawChar(a,n,h,q,f,c,k,u,!!(B&l.FLAGS.BOLD),!!(B&l.FLAGS.DIM)),this._ctx.restore())}}}};c.prototype.onOptionsChanged=
-function(a){this.setTransparency(a,a.options.allowTransparency)};c.prototype._isOverlapping=function(a){if(1!==a[m.CHAR_DATA_WIDTH_INDEX]||256>a[m.CHAR_DATA_CODE_INDEX])return!1;a=a[m.CHAR_DATA_CHAR_INDEX];if(this._characterOverlapCache.hasOwnProperty(a))return this._characterOverlapCache[a];this._ctx.save();this._ctx.font=this._characterFont;var c=Math.floor(this._ctx.measureText(a).width)>this._characterWidth;this._ctx.restore();return this._characterOverlapCache[a]=c};c.prototype._clearChar=function(a,
-c){var e=1,d=this._state.cache[a][c];d&&2===d[m.CHAR_DATA_WIDTH_INDEX]&&(e=2);this.clearCells(a,c,e,1)};return c}(e.BaseRenderLayer);d.TextRenderLayer=a},{"../Buffer":1,"./BaseRenderLayer":19,"./GridCache":23,"./Types":28}],28:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});a=d.FLAGS||(d.FLAGS={});a[a.BOLD=1]="BOLD";a[a.UNDERLINE=2]="UNDERLINE";a[a.BLINK=4]="BLINK";a[a.INVERSE=8]="INVERSE";a[a.INVISIBLE=16]="INVISIBLE";a[a.DIM=32]="DIM"},{}],29:[function(a,h,d){function f(a,e,d,
-c){for(var g=0;gq;q++)e.save(),e.beginPath(),e.rect(q*c,0,c,k),e.clip(),e.fillText(String.fromCharCode(q),q*c,0),e.restore();e.save();e.font=m(g.fontWeightBold,g);for(q=0;256>q;q++)e.save(),e.beginPath(),e.rect(q*c,k,c,k),e.clip(),e.fillText(String.fromCharCode(q),q*c,k),e.restore();e.restore();e.font=m(g.fontWeight,g);for(var r=0;16>r;r++){8===r&&(e.font=m(g.fontWeightBold,g));var t=(r+
-2)*k;for(q=0;256>q;q++)e.save(),e.beginPath(),e.rect(q*c,t,c,k),e.clip(),e.fillStyle=g.ansiColors[r],e.fillText(String.fromCharCode(q),q*c,t),e.restore()}e.restore();if(!("createImageBitmap"in a)||l.isFirefox)return h instanceof HTMLCanvasElement?h:new Promise(function(a){return a(h.transferToImageBitmap())});c=e.getImageData(0,0,h.width,h.height);k=parseInt(g.background.substr(1,2),16);e=parseInt(g.background.substr(3,2),16);g=parseInt(g.background.substr(5,2),16);f(c,k,e,g);return a.createImageBitmap(c)}},
-{"./utils/Browser":30}],30:[function(a,h,d){Object.defineProperty(d,"__esModule",{value:!0});h=(a="undefined"===typeof navigator?!0:!1)?"node":navigator.userAgent;a=a?"node":navigator.platform;d.isFirefox=!!~h.indexOf("Firefox");d.isMSIE=!!~h.indexOf("MSIE")||!!~h.indexOf("Trident");h=0<=["Macintosh","MacIntel","MacPPC","Mac68K"].indexOf(a);d.isMac=h;d.isIpad="iPad"===a;d.isIphone="iPhone"===a;h=0<=["Windows","Win16","Win32","WinCE"].indexOf(a);d.isMSWindows=h;d.isLinux=0<=a.indexOf("Linux")},{}],
-31:[function(a,h,d){var f=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,d){a.__proto__=d}||function(a,d){for(var e in d)d.hasOwnProperty(e)&&(a[e]=d[e])};return function(d,f){function e(){this.constructor=d}a(d,f);d.prototype=null===f?Object.create(f):(e.prototype=f.prototype,new e)}}();Object.defineProperty(d,"__esModule",{value:!0});a=function(a){function d(d,e){var g=a.call(this)||this;g._document=d;g._parentElement=e;g._measureElement=
-g._document.createElement("span");g._measureElement.style.position="absolute";g._measureElement.style.top="0";g._measureElement.style.left="-9999em";g._measureElement.style.lineHeight="normal";g._measureElement.textContent="W";g._measureElement.setAttribute("aria-hidden","true");g._parentElement.appendChild(g._measureElement);return g}f(d,a);Object.defineProperty(d.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0});Object.defineProperty(d.prototype,"height",{get:function(){return this._height},
-enumerable:!0,configurable:!0});d.prototype.measure=function(a){this._measureElement.style.fontFamily=a.fontFamily;this._measureElement.style.fontSize=a.fontSize+"px";a=this._measureElement.getBoundingClientRect();0===a.width||0===a.height||this._width===a.width&&this._height===a.height||(this._width=a.width,this._height=Math.ceil(a.height),this.emit("charsizechanged"))};return d}(a("../EventEmitter").EventEmitter);d.CharMeasure=a},{"../EventEmitter":7}],32:[function(a,h,d){var f=this&&this.__extends||
-function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,d){a.__proto__=d}||function(a,d){for(var e in d)d.hasOwnProperty(e)&&(a[e]=d[e])};return function(d,f){function e(){this.constructor=d}a(d,f);d.prototype=null===f?Object.create(f):(e.prototype=f.prototype,new e)}}();Object.defineProperty(d,"__esModule",{value:!0});a=function(a){function d(d){var e=a.call(this)||this;e._maxLength=d;e._array=Array(e._maxLength);e._startIndex=0;e._length=0;return e}f(d,a);Object.defineProperty(d.prototype,
-"maxLength",{get:function(){return this._maxLength},set:function(a){if(this._maxLength!==a){for(var e=Array(a),d=0;dthis._length)for(var e=this._length;e=a;c--)this._array[this._getCyclicIndex(c+d.length)]=this._array[this._getCyclicIndex(c)];for(c=0;cthis.maxLength?(d=this._length+d.length-this.maxLength,this._startIndex+=d,this._length=this.maxLength,this.emit("trim",d)):this._length+=d.length}};d.prototype.trimStart=function(a){a>this._length&&(a=this._length);this._startIndex+=a;this._length-=a;this.emit("trim",a)};d.prototype.shiftElements=function(a,e,d){if(!(0>=e)){if(0>a||a>=this._length)throw Error("start argument out of range");if(0>a+d)throw Error("Cannot shift elements in list beyond index 0");if(0this.maxLength;)this._length--,this._startIndex++,this.emit("trim",1)}else for(c=0;c>=1;for(;!(h=read_rng(a),h=String.fromCharCode(h[0].charCodeAt(0)&d)+h.substring(1),h=inflate_long(h,1),0b?a+Array(b-a.length+1).join("\x00"):a},get_int:function(){return struct.unpack("I",this.get_bytes(4))[0]},get_string:function(){return this.get_bytes(this.get_int())},get_mpint:function(){return inflate_long(this.get_string())},add_bytes:function(b){this.packet+=b;return this},add_boolean:function(b){this.add_bytes(!0===
-b?"\u0001":"\x00");return this},add_int:function(b){this.packet+=struct.pack("I",b);return this},add_mpint:function(b){this.add_string(deflate_long(b));return this},add_string:function(b){this.add_int(b.length);this.packet+=b;return this}};SSHyClient.parceler=function(b,a){this.socket=b;this.transport=a;this.encrypting=!1;this.hmacSHAVersion=this.inbound_iv=this.inbound_enc_key=this.inbound_mac_key=this.inbound_cipher=this.outbound_enc_iv=this.outbound_enc_key=this.outbound_mac_key=this.outbound_cipher=null;this.outbound_sequence_num=this.inbound_sequence_num=this.macSize=0;this.block_size=8;this.prevHeader=this.inbound_buffer="";this.windowSize=SSHyClient.WINDOW_SIZE;this.recieveData=this.transmitData=0};
-SSHyClient.parceler.prototype={send:function(b){packet=this.pack_message(b.toString());this.encrypting&&(packet=this.outbound_cipher.encrypt(packet)+SSHyClient.hash.HMAC(this.outbound_mac_key,struct.pack("I",this.outbound_sequence_num)+packet,this.hmacSHAVersion));this.socket.sendB64(packet);this.outbound_sequence_num++},pack_message:function(b){var a=3+this.block_size-(b.length+8)%this.block_size;b=struct.pack("I",b.length+a+1)+struct.pack("B",a)+b;return b+=this.encrypting?read_rng(a):Array(a+1).join("\x00")},
-handle:function(b){this.recieveData+=b.length;this.transport.settings.setNetTraffic(transport.parceler.recieveData,!0);if(this.encrypting)this.inbound_buffer+=b,this.decrypt();else if(this.transport.remote_version)this.inbound_buffer+=b,this.decrypt(b);else this.transport.handler_table[0](this.transport,b)},decrypt:function(){for(var b=" ",a;null!==b;){if(this.prevHeader)a=this.prevHeader,this.prevHeader="";else{a=this.read_ibuffer();if(!a)break;this.encrypting&&(a=this.inbound_cipher.decrypt(a))}var h=
-struct.unpack("I",a.substring(0,4))[0],d=a.substring(4);b=this.read_ibuffer(h+this.macSize-d.length);if(!b){this.prevHeader=a;break}a=b.substring(0,h-d.length);this.encrypting&&(a=this.inbound_cipher.decrypt(a));a=d+a;if(this.macSize){d=b.substring(h-d.length);var f=struct.pack("I",this.inbound_sequence_num)+struct.pack("I",h)+a;if(SSHyClient.hash.HMAC(this.inbound_mac_key,f,this.hmacSHAVersion)!=d)throw this.transport.disconnect(),"Inbound MAC verification failed - Mismatched MAC";}this.inbound_sequence_num++;
-this.windowSize-=h;0>=this.windowSize&&this.transport.winAdjust();this.transport.handle_dec(a)}},read_ibuffer:function(b){b=void 0===b?this.block_size:b;if(this.inbound_buffer.lengththis.shellString.length||(-1!==this.shellString.indexOf("]0;fish")?(this.shellString="",this.fsHintLeave=SSHyClient.fishFsHintLeave):-1!==this.shellString.indexOf("@")&&(this.shellString="",this.fsHintLeave=
-SSHyClient.bashFsHintLeave)))},setLocalEcho:function(b){this.localEcho=Math.min(Math.max(this.localEcho+=b,0),2);document.getElementById("currentLEcho").innerHTML=["Force Off","Auto","Force On"][this.localEcho];b=document.getElementById("autoEchoState");1===this.localEcho?(b.style.visibility="visible",b.innerHTML="State: "+(!1===this.autoEchoState?"Disabled":"Enabled")):b.style.visibility="hidden"},parseLocalEcho:function(b){if(1===this.localEcho){var a=performance.now();if(!(100>a-this.autoEchoTimeout))if(b=
-b.substring(0,64),!this.autoEchoState)-1!=b.indexOf(this.fsHintLeave)&&-1!=b.indexOf("@")&&(this.autoEchoState=!0,this.autoEchoElement.innerHTML="State: Enabled",this.autoEchoTimeout=a);else if(-1!=b.indexOf(this.fsHintEnter)||-1!=b.toLowerCase().indexOf("password"))this.autoEchoState=!1,this.autoEchoElement.innerHTML="State: Disabled",this.autoEchoTimeout=a}},parseKey:function(b){1===this.localEcho&&!1===this.autoEchoState||1i;i++)a.deleteRule(13);"Tango"===
-h?(this.colorTango=!0,document.getElementById("currentColor").innerHTML="Tango"):(a.insertRule("html, body {background-color: "+b.background+" !important;}",13),a.insertRule(".sidenav {background-color: "+modColorPercent(b.background,-.2)+" !important;}",13),a.insertRule(".brightgreen {color: "+b.brightGreen+" !important;}",13),a.insertRule(".brightyellow {color: "+b.brightYellow+" !important;}",13),this.colorTango=!1,document.getElementById("currentColor").innerHTML=void 0===h?"Custom":h)},importXresources:function(){var b=
-new FileReader,a=document.getElementById("Xresources").files[0];b.readAsText(a);b.onload=function(){var h=b.result.split("\n");h=h.sort((new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"})).compare);colScheme=[];for(var d=0;dthis.colorNames.length-1||0>this.colorCounter)this.colorCounter=1===b?0:this.colorNames.length-1;this.setColorScheme(this.colorCounter)},modFontSize:function(b){this.fontSize+=b;term.setOption("fontSize",this.fontSize);document.getElementById("currentFontSize").innerHTML=
-transport.settings.fontSize+"px";term.fit();transport.auth.mod_pty("window-change",term.cols,term.rows)},modTerm:function(b,a){b?term.resize(term.cols,a):term.resize(a,term.rows);transport.auth.mod_pty("window-change",term.cols,term.rows)},setNetTraffic:function(b,a){if(this.sidenavElementState){switch(!0){case 1024>b:b+="Bytes";break;case 1024<=b&&1048576>b:b=(b/1024).toFixed(3)+"KB";break;case 1048576<=b&&1073741824>b:b=(b/1048576).toFixed(3)+"MB";break;default:b=(b/1073741824).toFixed(3)+"GB"}element=
-!0===a?this.rxElement:this.txElement;element.innerHTML=b}}};var ws,transport,term=null;window.msCrypto&&(window.crypto={},window.crypto.getRandomValues=function(b){return window.msCrypto.getRandomValues(b)},Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:Array.prototype.slice}));var resizeInterval;
-window.onload=function(){document.body.innerHTML+='\n\t\t\t\t\t\t\t\t\t
×\n\t\t\t\t\t\t\t\t\t
Terminal Options\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
Font Size\n\t\t\t\t\t\t\t\t\t
<--\n\t\t\t\t\t\t\t\t\t
16px\n\t\t\t\t\t\t\t\t\t
--\x3e\n\t\t\t\t\t\t\t\t\t
Terminal Size\n\t\t\t\t\t\t\t\t\t
Cols:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
Rows:\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
Local Echo\n\t\t\t\t\t\t\t\t\t
<--\n\t\t\t\t\t\t\t\t\t
--\x3e\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\tState: Enabled\n\t\t\t\t\t\t\t\t\t\tForce Off\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
Colours\n\t\t\t\t\t\t\t\t\t
<--\n\t\t\t\t\t\t\t\t\t
Monokai\n\t\t\t\t\t\t\t\t\t
--\x3e\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\tFormat: Xresources\n\t\t\t\t\t\t\t\t\t\tUpload\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
Keep Alive\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t0 to disable\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t seconds\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
Network Traffic\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\trx: \n\t\t\t\t\t\t\t\t\t\ttx: \n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t Host Key\n\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t⚙';fit.apply(Terminal);
-startSSHy()};window.onresize=function(){clearTimeout(resizeInterval);resizeInterval=setTimeout(resize,400)};window.onbeforeunload=function(){(ws||transport)&&transport.disconnect()};function resize(){term&&term.fit()}
-function toggleNav(b){document.getElementById("settingsNav").style.width=b;if(transport.settings.sidenavElementState=b)transport.settings.setNetTraffic(transport.parceler.recieveData,!0),transport.settings.setNetTraffic(transport.parceler.transmitData,!1);b=document.getElementById("gear").style;b.visibility="hidden"===b.visibility?"visible":"hidden"}
-function startSSHy(){document.title="SSHy Client";ws=new WebSocket(wsproxyURL,"base64");ws.onopen=function(b){transport=new SSHyClient.Transport(ws);transport.settings.rsaCheckEnabled=!1};ws.onmessage=function(b){transport.parceler.handle(atob(b.data))};ws.onclose=function(b){term?transport.closing||(term.write("\n\n\rWebsocket connection to "+transport.auth.hostname+" was unexpectedly closed."),transport.settings.keepAliveInterval||term.write("\n\n\rThis was likely caused by he remote SSH server timing out the session due to inactivity.\r\n- Session Keep Alive interval can be set in the settings to prevent this behaviour.")):
-(termInit(),term.write("WebSocket connection failed: Error in connection establishment: code "+b.code))};ws.sendB64=function(b){this.send(btoa(b));transport.parceler.transmitData+=b.length;transport.settings.setNetTraffic(transport.parceler.transmitData,!1)}}
-function termInit(){term=new Terminal({cols:80,rows:24});term.open(document.getElementById("terminal"),!0);term.fit();term.focus();document.getElementById("termCols").value=term.cols;document.getElementById("termRows").value=term.rows;transport.settings.setColorScheme(1)}
-function startxtermjs(){termInit();transport.auth.authenticated||term.write("Login as: ");term.textarea.onkeydown=function(b){if(ws&&transport&&!(5<=transport.auth.failedAttempts)&&!transport.auth.awaitingAuthentication){var a=b.char&&1==b.char.length?b.char:b.key;if(!(1a.length)if(5E3a;a++)b.add_string(this.preferred_algorithms[a]),b.add_string(this.preferred_algorithms[a]);b.add_boolean(!1);b.add_int(0);this.local_kex_message=b=b.toString();this.send_packet(b)},parse_kex_reply:function(b){b=new SSHyClient.Message(b);b.get_bytes(17);var a=filter(this.preferred_algorithms[0],b.get_string().split(",")),h=filter(this.preferred_algorithms[1],b.get_string().split(","));b.get_string();var d=filter(this.preferred_algorithms[2],b.get_string().split(","));b.get_string();
-b=filter(this.preferred_algorithms[3],b.get_string().split(","));if(!(a&&h&&d&&b))throw"Chosen Algs = kex="+a+", keys="+h+", cipher="+d+", mac="+b;this.preferred_kex=this.kex_info[a](this);this.preferred_mac=this.mac_info[b](this)},generate_key:function(b,a){var h=new SSHyClient.Message;h.add_mpint(SSHyClient.kex.K);h.add_bytes(SSHyClient.kex.H);h.add_bytes(b);h.add_bytes(SSHyClient.kex.sessionId);return"SHA-1"==this.preferred_kex.SHAVersion?(new SSHyClient.hash.SHA1(h.toString())).digest().substring(0,
-a):(new SSHyClient.hash.SHA256(h.toString())).digest().substring(0,a)},activate_encryption:function(){this.parceler.block_size=16;this.parceler.macSize=this.preferred_hash;this.parceler.outbound_enc_iv=this.generate_key("A",this.parceler.block_size,this.preferred_kex.SHAVersion);this.parceler.outbound_enc_key=this.generate_key("C",this.parceler.block_size,this.preferred_kex.SHAVersion);this.parceler.outbound_mac_key=this.generate_key("E",this.parceler.macSize,this.preferred_kex.SHAVersion);this.parceler.outbound_cipher=
-new SSHyClient.crypto.AES(this.parceler.outbound_enc_key,SSHyClient.AES_CTR,this.parceler.outbound_enc_iv,new SSHyClient.crypto.counter(8*this.parceler.block_size,inflate_long(this.parceler.outbound_enc_iv)));this.parceler.inbound_enc_iv=this.generate_key("B",this.parceler.block_size,this.preferred_kex.SHAVersion);this.parceler.inbound_enc_key=this.generate_key("D",this.parceler.block_size,this.preferred_kex.SHAVersion);this.parceler.inbound_mac_key=this.generate_key("F",this.parceler.macSize,this.preferred_kex.SHAVersion);
-this.parceler.inbound_cipher=new SSHyClient.crypto.AES(this.parceler.inbound_enc_key,SSHyClient.AES_CTR,this.parceler.inbound_enc_iv,new SSHyClient.crypto.counter(8*this.parceler.block_size,inflate_long(this.parceler.inbound_enc_iv)));this.parceler.encrypting=!0;this.auth.request_auth()},handle_dec:function(b){b=this.cut_padding(b);try{this.handler_table[b.substring(0,1).charCodeAt(0)](this,b)}catch(a){console.log(a),console.log("Error! code - "+b.substring(0,1).charCodeAt(0)+" does not exist!")}},
-str_to_bytes:function(b){return unescape(encodeURIComponent(b))},expect_key:function(b){if(b){var a=new SSHyClient.Message;a.add_bytes(String.fromCharCode(SSHyClient.MSG_CHANNEL_DATA));a.add_int(0);a.add_string(this.str_to_bytes(b.toString()));this.parceler.send(a)}},send_new_keys:function(b){b=new SSHyClient.Message;b.add_bytes(String.fromCharCode(SSHyClient.MSG_NEW_KEYS));this.send_packet(b)}};
+SSHyClient = {
+ // Global Defines
+ MSG_DISCONNECT: 1,
+ MSG_IGNORE: 2,
+ MSG_UNIMPLEMENTED: 3,
+ MSG_DEBUG: 4,
+ MSG_SERVICE_REQUEST: 5,
+ MSG_SERVICE_ACCEPT: 6,
+
+ MSG_KEX_INIT: 20,
+ MSG_NEW_KEYS: 21,
+ MSG_KEXDH_INIT: 30,
+ MSG_KEXDH_GEX_GROUP: 31,
+ MSG_KEXDH_GEX_INIT: 32,
+ MSG_KEXDH_GEX_REPLY: 33,
+ MSG_KEXDH_GEX_REQUEST: 34,
+
+ MSG_USERAUTH_REQUEST: 50,
+ MSG_USERAUTH_FAILURE: 51,
+ MSG_USERAUTH_SUCCESS: 52,
+ MSG_USERAUTH_BANNER: 53,
+
+ MSG_GLOBAL_REQUEST: 80,
+ MSG_REQUEST_SUCCESS: 81,
+ MSG_REQUEST_FAILURE: 82,
+
+ MSG_CHANNEL_OPEN: 90,
+ MSG_CHANNEL_OPEN_SUCCESS: 91,
+ MSG_CHANNEL_OPEN_FAILURE: 92,
+ MSG_CHANNEL_WINDOW_ADJUST: 93,
+ MSG_CHANNEL_DATA: 94,
+ MSG_CHANNEL_EXTENDED_DATA: 95,
+ MSG_CHANNEL_EOF: 96,
+ MSG_CHANNEL_CLOSE: 97,
+ MSG_CHANNEL_REQUEST: 98,
+ MSG_CHANNEL_SUCCESS: 99,
+ MSG_CHANNEL_FAILURE: 100,
+
+ WINDOW_SIZE: 40674, // Coppied from Putty
+ MAX_PACKET_SIZE: 16384,
+
+ AES_CBC: 2,
+ AES_CTR: 6,
+
+ /* Fish Binding */
+ fishFsHintLeave: "\x1b\x5b\x33\x32",
+ /* Bash Binding */
+ bashFsHintLeave: "\x1b\x5d\x30\x3b"
+};
+var BigInteger = function() {
+ function e(a, b, c) {
+ null != a && ("number" == typeof a ? this.fromNumber(a, b, c) : null == b && "string" != typeof a ? this.fromString(a, 256) : this.fromString(a, b))
+ }
+
+ function l() {
+ return new e(null)
+ }
+
+ function F(a, b, c, d, k, e) {
+ for (; 0 <= --e;) {
+ var f = b * this[a++] + c[d] + k;
+ k = Math.floor(f / 67108864);
+ c[d++] = f & 67108863
+ }
+ return k
+ }
+
+ function G(a, b, c, d, k, e) {
+ var f = b & 32767;
+ for (b >>= 15; 0 <= --e;) {
+ var g = this[a] & 32767,
+ l = this[a++] >> 15,
+ m = b * g + l * f,
+ g = f * g + ((m & 32767) << 15) + c[d] + (k & 1073741823);
+ k = (g >>> 30) + (m >>> 15) + b * l + (k >>> 30);
+ c[d++] =
+ g & 1073741823
+ }
+ return k
+ }
+
+ function H(a, b, c, d, k, e) {
+ var f = b & 16383;
+ for (b >>= 14; 0 <= --e;) {
+ var g = this[a] & 16383,
+ l = this[a++] >> 14,
+ m = b * g + l * f,
+ g = f * g + ((m & 16383) << 14) + c[d] + k;
+ k = (g >> 28) + (m >> 14) + b * l;
+ c[d++] = g & 268435455
+ }
+ return k
+ }
+
+ function B(a, b) {
+ var c = y[a.charCodeAt(b)];
+ return null == c ? -1 : c
+ }
+
+ function t(a) {
+ var b = l();
+ b.fromInt(a);
+ return b
+ }
+
+ function z(a) {
+ var b = 1,
+ c;
+ 0 != (c = a >>> 16) && (a = c, b += 16);
+ 0 != (c = a >> 8) && (a = c, b += 8);
+ 0 != (c = a >> 4) && (a = c, b += 4);
+ 0 != (c = a >> 2) && (a = c, b += 2);
+ 0 != a >> 1 && (b += 1);
+ return b
+ }
+
+ function u(a) {
+ this.m = a
+ }
+
+ function w(a) {
+ this.m =
+ a;
+ this.mp = a.invDigit();
+ this.mpl = this.mp & 32767;
+ this.mph = this.mp >> 15;
+ this.um = (1 << a.DB - 15) - 1;
+ this.mt2 = 2 * a.t
+ }
+
+ function I(a, b) {
+ return a & b
+ }
+
+ function A(a, b) {
+ return a | b
+ }
+
+ function C(a, b) {
+ return a ^ b
+ }
+
+ function D(a, b) {
+ return a & ~b
+ }
+
+ function v() {}
+
+ function E(a) {
+ return a
+ }
+
+ function x(a) {
+ this.r2 = l();
+ this.q3 = l();
+ e.ONE.dlShiftTo(2 * a.t, this.r2);
+ this.mu = this.r2.divide(a);
+ this.m = a
+ }
+ var m;
+ "Microsoft Internet Explorer" == navigator.appName ? (e.prototype.am = G, m = 30) : "Netscape" != navigator.appName ? (e.prototype.am = F, m = 26) : (e.prototype.am =
+ H, m = 28);
+ e.prototype.DB = m;
+ e.prototype.DM = (1 << m) - 1;
+ e.prototype.DV = 1 << m;
+ e.prototype.FV = Math.pow(2, 52);
+ e.prototype.F1 = 52 - m;
+ e.prototype.F2 = 2 * m - 52;
+ var y = [],
+ n;
+ m = 48;
+ for (n = 0; 9 >= n; ++n) y[m++] = n;
+ m = 97;
+ for (n = 10; 36 > n; ++n) y[m++] = n;
+ m = 65;
+ for (n = 10; 36 > n; ++n) y[m++] = n;
+ u.prototype.convert = function(a) {
+ return 0 > a.s || 0 <= a.compareTo(this.m) ? a.mod(this.m) : a
+ };
+ u.prototype.revert = function(a) {
+ return a
+ };
+ u.prototype.reduce = function(a) {
+ a.divRemTo(this.m, null, a)
+ };
+ u.prototype.mulTo = function(a, b, c) {
+ a.multiplyTo(b, c);
+ this.reduce(c)
+ };
+ u.prototype.sqrTo =
+ function(a, b) {
+ a.squareTo(b);
+ this.reduce(b)
+ };
+ w.prototype.convert = function(a) {
+ var b = l();
+ a.abs().dlShiftTo(this.m.t, b);
+ b.divRemTo(this.m, null, b);
+ 0 > a.s && 0 < b.compareTo(e.ZERO) && this.m.subTo(b, b);
+ return b
+ };
+ w.prototype.revert = function(a) {
+ var b = l();
+ a.copyTo(b);
+ this.reduce(b);
+ return b
+ };
+ w.prototype.reduce = function(a) {
+ for (; a.t <= this.mt2;) a[a.t++] = 0;
+ for (var b = 0; b < this.m.t; ++b) {
+ var c = a[b] & 32767,
+ d = c * this.mpl + ((c * this.mph + (a[b] >> 15) * this.mpl & this.um) << 15) & a.DM,
+ c = b + this.m.t;
+ for (a[c] += this.m.am(0, d, a, b, 0, this.m.t); a[c] >=
+ a.DV;) a[c] -= a.DV, a[++c]++
+ }
+ a.clamp();
+ a.drShiftTo(this.m.t, a);
+ 0 <= a.compareTo(this.m) && a.subTo(this.m, a)
+ };
+ w.prototype.mulTo = function(a, b, c) {
+ a.multiplyTo(b, c);
+ this.reduce(c)
+ };
+ w.prototype.sqrTo = function(a, b) {
+ a.squareTo(b);
+ this.reduce(b)
+ };
+ e.prototype.copyTo = function(a) {
+ for (var b = this.t - 1; 0 <= b; --b) a[b] = this[b];
+ a.t = this.t;
+ a.s = this.s
+ };
+ e.prototype.fromInt = function(a) {
+ this.t = 1;
+ this.s = 0 > a ? -1 : 0;
+ 0 < a ? this[0] = a : -1 > a ? this[0] = a + DV : this.t = 0
+ };
+ e.prototype.fromString = function(a, b) {
+ var c;
+ if (16 == b) c = 4;
+ else if (8 == b) c = 3;
+ else if (256 ==
+ b) c = 8;
+ else if (2 == b) c = 1;
+ else if (32 == b) c = 5;
+ else if (4 == b) c = 2;
+ else {
+ this.fromRadix(a, b);
+ return
+ }
+ this.s = this.t = 0;
+ for (var d = a.length, k = !1, f = 0; 0 <= --d;) {
+ var h = 8 == c ? a[d] & 255 : B(a, d);
+ 0 > h ? "-" == a.charAt(d) && (k = !0) : (k = !1, 0 == f ? this[this.t++] = h : f + c > this.DB ? (this[this.t - 1] |= (h & (1 << this.DB - f) - 1) << f, this[this.t++] = h >> this.DB - f) : this[this.t - 1] |= h << f, f += c, f >= this.DB && (f -= this.DB))
+ }
+ 8 == c && 0 != (a[0] & 128) && (this.s = -1, 0 < f && (this[this.t - 1] |= (1 << this.DB - f) - 1 << f));
+ this.clamp();
+ k && e.ZERO.subTo(this, this)
+ };
+ e.prototype.clamp = function() {
+ for (var a =
+ this.s & this.DM; 0 < this.t && this[this.t - 1] == a;) --this.t
+ };
+ e.prototype.dlShiftTo = function(a, b) {
+ var c;
+ for (c = this.t - 1; 0 <= c; --c) b[c + a] = this[c];
+ for (c = a - 1; 0 <= c; --c) b[c] = 0;
+ b.t = this.t + a;
+ b.s = this.s
+ };
+ e.prototype.drShiftTo = function(a, b) {
+ for (var c = a; c < this.t; ++c) b[c - a] = this[c];
+ b.t = Math.max(this.t - a, 0);
+ b.s = this.s
+ };
+ e.prototype.lShiftTo = function(a, b) {
+ var c = a % this.DB,
+ d = this.DB - c,
+ e = (1 << d) - 1,
+ f = Math.floor(a / this.DB),
+ h = this.s << c & this.DM,
+ g;
+ for (g = this.t - 1; 0 <= g; --g) b[g + f + 1] = this[g] >> d | h, h = (this[g] & e) << c;
+ for (g = f - 1; 0 <= g; --g) b[g] =
+ 0;
+ b[f] = h;
+ b.t = this.t + f + 1;
+ b.s = this.s;
+ b.clamp()
+ };
+ e.prototype.rShiftTo = function(a, b) {
+ b.s = this.s;
+ var c = Math.floor(a / this.DB);
+ if (c >= this.t) b.t = 0;
+ else {
+ var d = a % this.DB,
+ e = this.DB - d,
+ f = (1 << d) - 1;
+ b[0] = this[c] >> d;
+ for (var h = c + 1; h < this.t; ++h) b[h - c - 1] |= (this[h] & f) << e, b[h - c] = this[h] >> d;
+ 0 < d && (b[this.t - c - 1] |= (this.s & f) << e);
+ b.t = this.t - c;
+ b.clamp()
+ }
+ };
+ e.prototype.subTo = function(a, b) {
+ for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] - a[c], b[c++] = d & this.DM, d >>= this.DB;
+ if (a.t < this.t) {
+ for (d -= a.s; c < this.t;) d += this[c], b[c++] =
+ d & this.DM, d >>= this.DB;
+ d += this.s
+ } else {
+ for (d += this.s; c < a.t;) d -= a[c], b[c++] = d & this.DM, d >>= this.DB;
+ d -= a.s
+ }
+ b.s = 0 > d ? -1 : 0; - 1 > d ? b[c++] = this.DV + d : 0 < d && (b[c++] = d);
+ b.t = c;
+ b.clamp()
+ };
+ e.prototype.multiplyTo = function(a, b) {
+ var c = this.abs(),
+ d = a.abs(),
+ k = c.t;
+ for (b.t = k + d.t; 0 <= --k;) b[k] = 0;
+ for (k = 0; k < d.t; ++k) b[k + c.t] = c.am(0, d[k], b, k, 0, c.t);
+ b.s = 0;
+ b.clamp();
+ this.s != a.s && e.ZERO.subTo(b, b)
+ };
+ e.prototype.squareTo = function(a) {
+ for (var b = this.abs(), c = a.t = 2 * b.t; 0 <= --c;) a[c] = 0;
+ for (c = 0; c < b.t - 1; ++c) {
+ var d = b.am(c, b[c], a, 2 * c, 0, 1);
+ (a[c +
+ b.t] += b.am(c + 1, 2 * b[c], a, 2 * c + 1, d, b.t - c - 1)) >= b.DV && (a[c + b.t] -= b.DV, a[c + b.t + 1] = 1)
+ }
+ 0 < a.t && (a[a.t - 1] += b.am(c, b[c], a, 2 * c, 0, 1));
+ a.s = 0;
+ a.clamp()
+ };
+ e.prototype.divRemTo = function(a, b, c) {
+ var d = a.abs();
+ if (!(0 >= d.t)) {
+ var k = this.abs();
+ if (k.t < d.t) null != b && b.fromInt(0), null != c && this.copyTo(c);
+ else {
+ null == c && (c = l());
+ var f = l(),
+ h = this.s;
+ a = a.s;
+ var g = this.DB - z(d[d.t - 1]);
+ 0 < g ? (d.lShiftTo(g, f), k.lShiftTo(g, c)) : (d.copyTo(f), k.copyTo(c));
+ d = f.t;
+ k = f[d - 1];
+ if (0 != k) {
+ var m = k * (1 << this.F1) + (1 < d ? f[d - 2] >> this.F2 : 0),
+ p = this.FV / m,
+ m = (1 <<
+ this.F1) / m,
+ n = 1 << this.F2,
+ r = c.t,
+ t = r - d,
+ q = null == b ? l() : b;
+ f.dlShiftTo(t, q);
+ 0 <= c.compareTo(q) && (c[c.t++] = 1, c.subTo(q, c));
+ e.ONE.dlShiftTo(d, q);
+ for (q.subTo(f, f); f.t < d;) f[f.t++] = 0;
+ for (; 0 <= --t;) {
+ var u = c[--r] == k ? this.DM : Math.floor(c[r] * p + (c[r - 1] + n) * m);
+ if ((c[r] += f.am(0, u, c, t, 0, d)) < u)
+ for (f.dlShiftTo(t, q), c.subTo(q, c); c[r] < --u;) c.subTo(q, c)
+ }
+ null != b && (c.drShiftTo(d, b), h != a && e.ZERO.subTo(b, b));
+ c.t = d;
+ c.clamp();
+ 0 < g && c.rShiftTo(g, c);
+ 0 > h && e.ZERO.subTo(c, c)
+ }
+ }
+ }
+ };
+ e.prototype.invDigit = function() {
+ if (1 > this.t) return 0;
+ var a =
+ this[0];
+ if (0 == (a & 1)) return 0;
+ var b = a & 3,
+ b = b * (2 - (a & 15) * b) & 15,
+ b = b * (2 - (a & 255) * b) & 255,
+ b = b * (2 - ((a & 65535) * b & 65535)) & 65535,
+ b = b * (2 - a * b % this.DV) % this.DV;
+ return 0 < b ? this.DV - b : -b
+ };
+ e.prototype.isEven = function() {
+ return 0 == (0 < this.t ? this[0] & 1 : this.s)
+ };
+ e.prototype.exp = function(a, b) {
+ if (4294967295 < a || 1 > a) return e.ONE;
+ var c = l(),
+ d = l(),
+ k = b.convert(this),
+ f = z(a) - 1;
+ for (k.copyTo(c); 0 <= --f;)
+ if (b.sqrTo(c, d), 0 < (a & 1 << f)) b.mulTo(d, k, c);
+ else var h = c,
+ c = d,
+ d = h;
+ return b.revert(c)
+ };
+ e.prototype.toString = function(a) {
+ if (0 > this.s) return "-" +
+ this.negate().toString(a);
+ if (16 == a) a = 4;
+ else if (8 == a) a = 3;
+ else if (2 == a) a = 1;
+ else if (32 == a) a = 5;
+ else if (4 == a) a = 2;
+ else return this.toRadix(a);
+ var b = (1 << a) - 1,
+ c, d = !1,
+ e = "",
+ f = this.t,
+ h = this.DB - f * this.DB % a;
+ if (0 < f--)
+ for (h < this.DB && 0 < (c = this[f] >> h) && (d = !0, e = "0123456789abcdefghijklmnopqrstuvwxyz".charAt(c)); 0 <= f;) h < a ? (c = (this[f] & (1 << h) - 1) << a - h, c |= this[--f] >> (h += this.DB - a)) : (c = this[f] >> (h -= a) & b, 0 >= h && (h += this.DB, --f)), 0 < c && (d = !0), d && (e += "0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));
+ return d ? e : "0"
+ };
+ e.prototype.negate =
+ function() {
+ var a = l();
+ e.ZERO.subTo(this, a);
+ return a
+ };
+ e.prototype.abs = function() {
+ return 0 > this.s ? this.negate() : this
+ };
+ e.prototype.compareTo = function(a) {
+ var b = this.s - a.s;
+ if (0 != b) return b;
+ var c = this.t,
+ b = c - a.t;
+ if (0 != b) return b;
+ for (; 0 <= --c;)
+ if (0 != (b = this[c] - a[c])) return b;
+ return 0
+ };
+ e.prototype.bitLength = function() {
+ return 0 >= this.t ? 0 : this.DB * (this.t - 1) + z(this[this.t - 1] ^ this.s & this.DM)
+ };
+ e.prototype.mod = function(a) {
+ var b = l();
+ this.abs().divRemTo(a, null, b);
+ 0 > this.s && 0 < b.compareTo(e.ZERO) && a.subTo(b, b);
+ return b
+ };
+ e.prototype.modPowInt = function(a, b) {
+ var c;
+ c = 256 > a || b.isEven() ? new u(b) : new w(b);
+ return this.exp(a, c)
+ };
+ e.ZERO = t(0);
+ e.ONE = t(1);
+ v.prototype.convert = E;
+ v.prototype.revert = E;
+ v.prototype.mulTo = function(a, b, c) {
+ a.multiplyTo(b, c)
+ };
+ v.prototype.sqrTo = function(a, b) {
+ a.squareTo(b)
+ };
+ x.prototype.convert = function(a) {
+ if (0 > a.s || a.t > 2 * this.m.t) return a.mod(this.m);
+ if (0 > a.compareTo(this.m)) return a;
+ var b = l();
+ a.copyTo(b);
+ this.reduce(b);
+ return b
+ };
+ x.prototype.revert = function(a) {
+ return a
+ };
+ x.prototype.reduce = function(a) {
+ a.drShiftTo(this.m.t -
+ 1, this.r2);
+ a.t > this.m.t + 1 && (a.t = this.m.t + 1, a.clamp());
+ this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
+ for (this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); 0 > a.compareTo(this.r2);) a.dAddOffset(1, this.m.t + 1);
+ for (a.subTo(this.r2, a); 0 <= a.compareTo(this.m);) a.subTo(this.m, a)
+ };
+ x.prototype.mulTo = function(a, b, c) {
+ a.multiplyTo(b, c);
+ this.reduce(c)
+ };
+ x.prototype.sqrTo = function(a, b) {
+ a.squareTo(b);
+ this.reduce(b)
+ };
+ var p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109,
+ 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509
+ ],
+ J = 67108864 / p[p.length - 1];
+ e.prototype.chunkSize = function(a) {
+ return Math.floor(Math.LN2 * this.DB / Math.log(a))
+ };
+ e.prototype.toRadix = function(a) {
+ null == a && (a = 10);
+ if (0 == this.signum() || 2 > a || 36 < a) return "0";
+ var b = this.chunkSize(a),
+ b = Math.pow(a,
+ b),
+ c = t(b),
+ d = l(),
+ e = l(),
+ f = "";
+ for (this.divRemTo(c, d, e); 0 < d.signum();) f = (b + e.intValue()).toString(a).substr(1) + f, d.divRemTo(c, d, e);
+ return e.intValue().toString(a) + f
+ };
+ e.prototype.fromRadix = function(a, b) {
+ this.fromInt(0);
+ null == b && (b = 10);
+ for (var c = this.chunkSize(b), d = Math.pow(b, c), k = !1, f = 0, h = 0, g = 0; g < a.length; ++g) {
+ var l = B(a, g);
+ 0 > l ? "-" == a.charAt(g) && 0 == this.signum() && (k = !0) : (h = b * h + l, ++f >= c && (this.dMultiply(d), this.dAddOffset(h, 0), h = f = 0))
+ }
+ 0 < f && (this.dMultiply(Math.pow(b, f)), this.dAddOffset(h, 0));
+ k && e.ZERO.subTo(this,
+ this)
+ };
+ e.prototype.fromNumber = function(a, b, c) {
+ if ("number" == typeof b)
+ if (2 > a) this.fromInt(1);
+ else
+ for (this.fromNumber(a, c), this.testBit(a - 1) || this.bitwiseTo(e.ONE.shiftLeft(a - 1), A, this), this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(b);) this.dAddOffset(2, 0), this.bitLength() > a && this.subTo(e.ONE.shiftLeft(a - 1), this);
+ else {
+ c = [];
+ var d = a & 7;
+ c.length = (a >> 3) + 1;
+ b.nextBytes(c);
+ c[0] = 0 < d ? c[0] & (1 << d) - 1 : 0;
+ this.fromString(c, 256)
+ }
+ };
+ e.prototype.bitwiseTo = function(a, b, c) {
+ var d, e, f = Math.min(a.t, this.t);
+ for (d =
+ 0; d < f; ++d) c[d] = b(this[d], a[d]);
+ if (a.t < this.t) {
+ e = a.s & this.DM;
+ for (d = f; d < this.t; ++d) c[d] = b(this[d], e);
+ c.t = this.t
+ } else {
+ e = this.s & this.DM;
+ for (d = f; d < a.t; ++d) c[d] = b(e, a[d]);
+ c.t = a.t
+ }
+ c.s = b(this.s, a.s);
+ c.clamp()
+ };
+ e.prototype.changeBit = function(a, b) {
+ var c = e.ONE.shiftLeft(a);
+ this.bitwiseTo(c, b, c);
+ return c
+ };
+ e.prototype.addTo = function(a, b) {
+ for (var c = 0, d = 0, e = Math.min(a.t, this.t); c < e;) d += this[c] + a[c], b[c++] = d & this.DM, d >>= this.DB;
+ if (a.t < this.t) {
+ for (d += a.s; c < this.t;) d += this[c], b[c++] = d & this.DM, d >>= this.DB;
+ d += this.s
+ } else {
+ for (d +=
+ this.s; c < a.t;) d += a[c], b[c++] = d & this.DM, d >>= this.DB;
+ d += a.s
+ }
+ b.s = 0 > d ? -1 : 0;
+ 0 < d ? b[c++] = d : -1 > d && (b[c++] = this.DV + d);
+ b.t = c;
+ b.clamp()
+ };
+ e.prototype.dMultiply = function(a) {
+ this[this.t] = this.am(0, a - 1, this, 0, 0, this.t);
+ ++this.t;
+ this.clamp()
+ };
+ e.prototype.dAddOffset = function(a, b) {
+ if (0 != a) {
+ for (; this.t <= b;) this[this.t++] = 0;
+ for (this[b] += a; this[b] >= this.DV;) this[b] -= this.DV, ++b >= this.t && (this[this.t++] = 0), ++this[b]
+ }
+ };
+ e.prototype.multiplyLowerTo = function(a, b, c) {
+ var d = Math.min(this.t + a.t, b);
+ c.s = 0;
+ for (c.t = d; 0 < d;) c[--d] =
+ 0;
+ var e;
+ for (e = c.t - this.t; d < e; ++d) c[d + this.t] = this.am(0, a[d], c, d, 0, this.t);
+ for (e = Math.min(a.t, b); d < e; ++d) this.am(0, a[d], c, d, 0, b - d);
+ c.clamp()
+ };
+ e.prototype.multiplyUpperTo = function(a, b, c) {
+ --b;
+ var d = c.t = this.t + a.t - b;
+ for (c.s = 0; 0 <= --d;) c[d] = 0;
+ for (d = Math.max(b - this.t, 0); d < a.t; ++d) c[this.t + d - b] = this.am(b - d, a[d], c, 0, 0, this.t + d - b);
+ c.clamp();
+ c.drShiftTo(1, c)
+ };
+ e.prototype.modInt = function(a) {
+ if (0 >= a) return 0;
+ var b = this.DV % a,
+ c = 0 > this.s ? a - 1 : 0;
+ if (0 < this.t)
+ if (0 == b) c = this[0] % a;
+ else
+ for (var d = this.t - 1; 0 <= d; --d) c = (b *
+ c + this[d]) % a;
+ return c
+ };
+ e.prototype.millerRabin = function(a) {
+ var b = this.subtract(e.ONE),
+ c = b.getLowestSetBit();
+ if (0 >= c) return !1;
+ var d = b.shiftRight(c);
+ a = a + 1 >> 1;
+ a > p.length && (a = p.length);
+ for (var k = l(), f = 0; f < a; ++f) {
+ k.fromInt(p[f]);
+ var h = k.modPow(d, this);
+ if (0 != h.compareTo(e.ONE) && 0 != h.compareTo(b)) {
+ for (var g = 1; g++ < c && 0 != h.compareTo(b);)
+ if (h = h.modPowInt(2, this), 0 == h.compareTo(e.ONE)) return !1;
+ if (0 != h.compareTo(b)) return !1
+ }
+ }
+ return !0
+ };
+ e.prototype.clone = function() {
+ var a = l();
+ this.copyTo(a);
+ return a
+ };
+ e.prototype.intValue =
+ function() {
+ if (0 > this.s) {
+ if (1 == this.t) return this[0] - this.DV;
+ if (0 == this.t) return -1
+ } else {
+ if (1 == this.t) return this[0];
+ if (0 == this.t) return 0
+ }
+ return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]
+ };
+ e.prototype.byteValue = function() {
+ return 0 == this.t ? this.s : this[0] << 24 >> 24
+ };
+ e.prototype.shortValue = function() {
+ return 0 == this.t ? this.s : this[0] << 16 >> 16
+ };
+ e.prototype.signum = function() {
+ return 0 > this.s ? -1 : 0 >= this.t || 1 == this.t && 0 >= this[0] ? 0 : 1
+ };
+ e.prototype.toByteArray = function() {
+ var a = this.t,
+ b = [];
+ b[0] = this.s;
+ var c = this.DB -
+ a * this.DB % 8,
+ d, e = 0;
+ if (0 < a--)
+ for (c < this.DB && (d = this[a] >> c) != (this.s & this.DM) >> c && (b[e++] = d | this.s << this.DB - c); 0 <= a;)
+ if (8 > c ? (d = (this[a] & (1 << c) - 1) << 8 - c, d |= this[--a] >> (c += this.DB - 8)) : (d = this[a] >> (c -= 8) & 255, 0 >= c && (c += this.DB, --a)), 0 != (d & 128) && (d |= -256), 0 == e && (this.s & 128) != (d & 128) && ++e, 0 < e || d != this.s) b[e++] = d;
+ return b
+ };
+ e.prototype.equals = function(a) {
+ return 0 == this.compareTo(a)
+ };
+ e.prototype.min = function(a) {
+ return 0 > this.compareTo(a) ? this : a
+ };
+ e.prototype.max = function(a) {
+ return 0 < this.compareTo(a) ? this : a
+ };
+ e.prototype.and =
+ function(a) {
+ var b = l();
+ this.bitwiseTo(a, I, b);
+ return b
+ };
+ e.prototype.or = function(a) {
+ var b = l();
+ this.bitwiseTo(a, A, b);
+ return b
+ };
+ e.prototype.xor = function(a) {
+ var b = l();
+ this.bitwiseTo(a, C, b);
+ return b
+ };
+ e.prototype.andNot = function(a) {
+ var b = l();
+ this.bitwiseTo(a, D, b);
+ return b
+ };
+ e.prototype.not = function() {
+ for (var a = l(), b = 0; b < this.t; ++b) a[b] = this.DM & ~this[b];
+ a.t = this.t;
+ a.s = ~this.s;
+ return a
+ };
+ e.prototype.shiftLeft = function(a) {
+ var b = l();
+ 0 > a ? this.rShiftTo(-a, b) : this.lShiftTo(a, b);
+ return b
+ };
+ e.prototype.shiftRight = function(a) {
+ var b =
+ l();
+ 0 > a ? this.lShiftTo(-a, b) : this.rShiftTo(a, b);
+ return b
+ };
+ e.prototype.getLowestSetBit = function() {
+ for (var a = 0; a < this.t; ++a)
+ if (0 != this[a]) {
+ var b = a * this.DB;
+ a = this[a];
+ if (0 == a) a = -1;
+ else {
+ var c = 0;
+ 0 == (a & 65535) && (a >>= 16, c += 16);
+ 0 == (a & 255) && (a >>= 8, c += 8);
+ 0 == (a & 15) && (a >>= 4, c += 4);
+ 0 == (a & 3) && (a >>= 2, c += 2);
+ 0 == (a & 1) && ++c;
+ a = c
+ }
+ return b + a
+ }
+ return 0 > this.s ? this.t * this.DB : -1
+ };
+ e.prototype.bitCount = function() {
+ for (var a = 0, b = this.s & this.DM, c = 0; c < this.t; ++c) {
+ for (var d = this[c] ^ b, e = 0; 0 != d;) d &= d - 1, ++e;
+ a += e
+ }
+ return a
+ };
+ e.prototype.testBit =
+ function(a) {
+ var b = Math.floor(a / this.DB);
+ return b >= this.t ? 0 != this.s : 0 != (this[b] & 1 << a % this.DB)
+ };
+ e.prototype.setBit = function(a) {
+ return this.changeBit(a, A)
+ };
+ e.prototype.clearBit = function(a) {
+ return this.changeBit(a, D)
+ };
+ e.prototype.flipBit = function(a) {
+ return this.changeBit(a, C)
+ };
+ e.prototype.add = function(a) {
+ var b = l();
+ this.addTo(a, b);
+ return b
+ };
+ e.prototype.subtract = function(a) {
+ var b = l();
+ this.subTo(a, b);
+ return b
+ };
+ e.prototype.multiply = function(a) {
+ var b = l();
+ this.multiplyTo(a, b);
+ return b
+ };
+ e.prototype.divide = function(a) {
+ var b =
+ l();
+ this.divRemTo(a, b, null);
+ return b
+ };
+ e.prototype.remainder = function(a) {
+ var b = l();
+ this.divRemTo(a, null, b);
+ return b
+ };
+ e.prototype.divideAndRemainder = function(a) {
+ var b = l(),
+ c = l();
+ this.divRemTo(a, b, c);
+ return [b, c]
+ };
+ e.prototype.modPow = function(a, b) {
+ var c = a.bitLength(),
+ d, e = t(1),
+ f;
+ if (0 >= c) return e;
+ d = 18 > c ? 1 : 48 > c ? 3 : 144 > c ? 4 : 768 > c ? 5 : 6;
+ f = 8 > c ? new u(b) : b.isEven() ? new x(b) : new w(b);
+ var h = [],
+ g = 3,
+ m = d - 1,
+ p = (1 << d) - 1;
+ h[1] = f.convert(this);
+ if (1 < d)
+ for (c = l(), f.sqrTo(h[1], c); g <= p;) h[g] = l(), f.mulTo(c, h[g - 2], h[g]), g += 2;
+ for (var n =
+ a.t - 1, r, v = !0, q = l(), c = z(a[n]) - 1; 0 <= n;) {
+ c >= m ? r = a[n] >> c - m & p : (r = (a[n] & (1 << c + 1) - 1) << m - c, 0 < n && (r |= a[n - 1] >> this.DB + c - m));
+ for (g = d; 0 == (r & 1);) r >>= 1, --g;
+ 0 > (c -= g) && (c += this.DB, --n);
+ if (v) h[r].copyTo(e), v = !1;
+ else {
+ for (; 1 < g;) f.sqrTo(e, q), f.sqrTo(q, e), g -= 2;
+ 0 < g ? f.sqrTo(e, q) : (g = e, e = q, q = g);
+ f.mulTo(q, h[r], e)
+ }
+ for (; 0 <= n && 0 == (a[n] & 1 << c);) f.sqrTo(e, q), g = e, e = q, q = g, 0 > --c && (c = this.DB - 1, --n)
+ }
+ return f.revert(e)
+ };
+ e.prototype.modInverse = function(a) {
+ var b = a.isEven();
+ if (this.isEven() && b || 0 == a.signum()) return e.ZERO;
+ for (var c = a.clone(),
+ d = this.clone(), k = t(1), f = t(0), h = t(0), g = t(1); 0 != c.signum();) {
+ for (; c.isEven();) c.rShiftTo(1, c), b ? (k.isEven() && f.isEven() || (k.addTo(this, k), f.subTo(a, f)), k.rShiftTo(1, k)) : f.isEven() || f.subTo(a, f), f.rShiftTo(1, f);
+ for (; d.isEven();) d.rShiftTo(1, d), b ? (h.isEven() && g.isEven() || (h.addTo(this, h), g.subTo(a, g)), h.rShiftTo(1, h)) : g.isEven() || g.subTo(a, g), g.rShiftTo(1, g);
+ 0 <= c.compareTo(d) ? (c.subTo(d, c), b && k.subTo(h, k), f.subTo(g, f)) : (d.subTo(c, d), b && h.subTo(k, h), g.subTo(f, g))
+ }
+ if (0 != d.compareTo(e.ONE)) return e.ZERO;
+ if (0 <= g.compareTo(a)) return g.subtract(a);
+ if (0 > g.signum()) g.addTo(a, g);
+ else return g;
+ return 0 > g.signum() ? g.add(a) : g
+ };
+ e.prototype.pow = function(a) {
+ return this.exp(a, new v)
+ };
+ e.prototype.gcd = function(a) {
+ var b = 0 > this.s ? this.negate() : this.clone();
+ a = 0 > a.s ? a.negate() : a.clone();
+ if (0 > b.compareTo(a)) {
+ var c = b,
+ b = a;
+ a = c
+ }
+ var c = b.getLowestSetBit(),
+ d = a.getLowestSetBit();
+ if (0 > d) return b;
+ c < d && (d = c);
+ 0 < d && (b.rShiftTo(d, b), a.rShiftTo(d, a));
+ for (; 0 < b.signum();) 0 < (c = b.getLowestSetBit()) && b.rShiftTo(c, b), 0 < (c = a.getLowestSetBit()) &&
+ a.rShiftTo(c, a), 0 <= b.compareTo(a) ? (b.subTo(a, b), b.rShiftTo(1, b)) : (a.subTo(b, a), a.rShiftTo(1, a));
+ 0 < d && a.lShiftTo(d, a);
+ return a
+ };
+ e.prototype.isProbablePrime = function(a) {
+ var b, c = this.abs();
+ if (1 == c.t && c[0] <= p[p.length - 1]) {
+ for (b = 0; b < p.length; ++b)
+ if (c[0] == p[b]) return !0;
+ return !1
+ }
+ if (c.isEven()) return !1;
+ for (b = 1; b < p.length;) {
+ for (var d = p[b], e = b + 1; e < p.length && d < J;) d *= p[e++];
+ for (d = c.modInt(d); b < e;)
+ if (0 == d % p[b++]) return !1
+ }
+ return c.millerRabin(a)
+ };
+ return {
+ BigInteger: e
+ }
+ }(),
+ BigInteger = BigInteger.BigInteger;
+SSHyClient.hash = {};
+
+SSHyClient.hash.SHA1 = function(a) {
+ this.data = a || "";
+ this.digest_size = 20
+};
+SSHyClient.hash.SHA1.prototype = {
+ digest: function() {
+ var a = toByteArray(this.data),
+ h = bytesToWords(a),
+ f = 8 * a.length,
+ a = [],
+ g = 1732584193,
+ c = -271733879,
+ d = -1732584194,
+ e = 271733878,
+ k = -1009589776;
+ h[f >> 5] |= 128 << 24 - f % 32;
+ h[(f + 64 >>> 9 << 4) + 15] = f;
+ for (f = 0; f < h.length; f += 16) {
+ for (var m = g, n = c, p = d, q = e, r = k, b = 0; 80 > b; b++) {
+ if (16 > b) a[b] = h[f + b];
+ else {
+ var l = a[b - 3] ^ a[b - 8] ^ a[b - 14] ^ a[b - 16];
+ a[b] = l << 1 | l >>> 31
+ }
+ l = (g << 5 | g >>> 27) + k + (a[b] >>> 0) + (20 > b ? (c & d | ~c & e) + 1518500249 : 40 > b ? (c ^ d ^ e) + 1859775393 : 60 > b ? (c & d | c & e | d & e) - 1894007588 : (c ^ d ^ e) - 899497514);
+ k = e;
+ e = d;
+ d = c << 30 | c >>> 2;
+ c = g;
+ g = l
+ }
+ g += m;
+ c += n;
+ d += p;
+ e += q;
+ k += r
+ }
+ return fromByteArray(wordsToBytes([g, c, d, e, k]))
+ }
+};
+
+SSHyClient.hash.SHA256 = function(a) {
+ this.data = a || ""
+ this.digest_size = 32
+}
+SSHyClient.hash.SHA256.prototype = {
+ digest: function() {
+ var hashData = toByteArray(this.data);
+
+ // Constants
+ var K = [ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
+ 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
+ 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
+ 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
+ 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
+ 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
+ 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
+ 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
+ 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
+ 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
+ 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
+ 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
+ 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
+ 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
+ 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
+ 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 ];
+
+ var m = bytesToWords(hashData),
+ l = hashData.length * 8,
+ H = [ 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
+ 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19 ],
+ w = [],
+ a, b, c, d, e, f, g, h, i, j,
+ t1, t2;
+
+ // Padding
+ m[l >> 5] |= 0x80 << (24 - l % 32);
+ m[((l + 64 >> 9) << 4) + 15] = l;
+
+ for (var i = 0; i < m.length; i += 16) {
+ a = H[0];
+ b = H[1];
+ c = H[2];
+ d = H[3];
+ e = H[4];
+ f = H[5];
+ g = H[6];
+ h = H[7];
+
+ for (var j = 0; j < 64; j++) {
+ if (j < 16) {
+ w[j] = m[j + i];
+ } else {
+ var gamma0x = w[j - 15],
+ gamma1x = w[j - 2],
+ gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
+ ((gamma0x << 14) | (gamma0x >>> 18)) ^
+ (gamma0x >>> 3),
+ gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
+ ((gamma1x << 13) | (gamma1x >>> 19)) ^
+ (gamma1x >>> 10);
+
+ w[j] = gamma0 + (w[j - 7] >>> 0) +
+ gamma1 + (w[j - 16] >>> 0);
+ }
+
+ var ch = e & f ^ ~e & g,
+ maj = a & b ^ a & c ^ b & c,
+ sigma0 = ((a << 30) | (a >>> 2)) ^
+ ((a << 19) | (a >>> 13)) ^
+ ((a << 10) | (a >>> 22)),
+ sigma1 = ((e << 26) | (e >>> 6)) ^
+ ((e << 21) | (e >>> 11)) ^
+ ((e << 7) | (e >>> 25));
+
+ t1 = (h >>> 0) + sigma1 + ch + (K[j]) + (w[j] >>> 0);
+ t2 = sigma0 + maj;
+
+ h = g;
+ g = f;
+ f = e;
+ e = (d + t1) >>> 0;
+ d = c;
+ c = b;
+ b = a;
+ a = (t1 + t2) >>> 0;
+ }
+
+ H[0] += a;
+ H[1] += b;
+ H[2] += c;
+ H[3] += d;
+ H[4] += e;
+ H[5] += f;
+ H[6] += g;
+ H[7] += h;
+ }
+
+ return fromByteArray(wordsToBytes(H));
+ }
+ }
+
+SSHyClient.hash.HMAC = function(a, g, SHAVersion) {
+ var b = digestmod = SHAVersion == 'SHA-1' ? SSHyClient.hash.SHA1 : SSHyClient.hash.SHA256,
+ d = new b,
+ e = new b;
+ 64 < a.length && (a = (new b(a)).digest());
+ a += Array(64 - a.length + 1).join("\x00");
+ for (var b = toByteArray(a).slice(0), f = toByteArray(a).slice(0), c = 0; 64 > c; ++c) b[c] ^= 92, f[c] ^= 54;
+ d.data += fromByteArray(b)
+ e.data += fromByteArray(f);
+ e.data += g;
+ d.data += e.digest();
+ return d.digest()
+};
+
+SSHyClient.hash.MD5 = function(data){
+ var hashData = toByteArray(data);
+
+ var m = bytesToWords(hashData),
+ l = hashData.length * 8,
+ a = 1732584193,
+ b = -271733879,
+ c = -1732584194,
+ d = 271733878;
+
+ // Swap endian
+ for (var i = 0; i < m.length; i++) {
+ m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
+ ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
+ }
+
+ // Padding
+ m[l >>> 5] |= 0x80 << (l % 32);
+ m[(((l + 64) >>> 9) << 4) + 14] = l;
+
+ // Method shortcuts
+ var FF = function (a, b, c, d, x, s, t) {
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ var GG = function (a, b, c, d, x, s, t) {
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ var HH = function (a, b, c, d, x, s, t) {
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+ var II = function (a, b, c, d, x, s, t) {
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
+ return ((n << s) | (n >>> (32 - s))) + b;
+ };
+
+ for (var i = 0; i < m.length; i += 16) {
+ var aa = a,
+ bb = b,
+ cc = c,
+ dd = d;
+
+ a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
+ d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
+ c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
+ b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
+ a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
+ d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
+ c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
+ b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
+ a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
+ d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
+ c = FF(c, d, a, b, m[i+10], 17, -42063);
+ b = FF(b, c, d, a, m[i+11], 22, -1990404162);
+ a = FF(a, b, c, d, m[i+12], 7, 1804603682);
+ d = FF(d, a, b, c, m[i+13], 12, -40341101);
+ c = FF(c, d, a, b, m[i+14], 17, -1502002290);
+ b = FF(b, c, d, a, m[i+15], 22, 1236535329);
+
+ a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
+ d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
+ c = GG(c, d, a, b, m[i+11], 14, 643717713);
+ b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
+ a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
+ d = GG(d, a, b, c, m[i+10], 9, 38016083);
+ c = GG(c, d, a, b, m[i+15], 14, -660478335);
+ b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
+ a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
+ d = GG(d, a, b, c, m[i+14], 9, -1019803690);
+ c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
+ b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
+ a = GG(a, b, c, d, m[i+13], 5, -1444681467);
+ d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
+ c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
+ b = GG(b, c, d, a, m[i+12], 20, -1926607734);
+
+ a = HH(a, b, c, d, m[i+ 5], 4, -378558);
+ d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
+ c = HH(c, d, a, b, m[i+11], 16, 1839030562);
+ b = HH(b, c, d, a, m[i+14], 23, -35309556);
+ a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
+ d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
+ c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
+ b = HH(b, c, d, a, m[i+10], 23, -1094730640);
+ a = HH(a, b, c, d, m[i+13], 4, 681279174);
+ d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
+ c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
+ b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
+ a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
+ d = HH(d, a, b, c, m[i+12], 11, -421815835);
+ c = HH(c, d, a, b, m[i+15], 16, 530742520);
+ b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
+
+ a = II(a, b, c, d, m[i+ 0], 6, -198630844);
+ d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
+ c = II(c, d, a, b, m[i+14], 15, -1416354905);
+ b = II(b, c, d, a, m[i+ 5], 21, -57434055);
+ a = II(a, b, c, d, m[i+12], 6, 1700485571);
+ d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
+ c = II(c, d, a, b, m[i+10], 15, -1051523);
+ b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
+ a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
+ d = II(d, a, b, c, m[i+15], 10, -30611744);
+ c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
+ b = II(b, c, d, a, m[i+13], 21, 1309151649);
+ a = II(a, b, c, d, m[i+ 4], 6, -145523070);
+ d = II(d, a, b, c, m[i+11], 10, -1120210379);
+ c = II(c, d, a, b, m[i+ 2], 15, 718787259);
+ b = II(b, c, d, a, m[i+ 9], 21, -343485551);
+
+ a = (a + aa) >>> 0;
+ b = (b + bb) >>> 0;
+ c = (c + cc) >>> 0;
+ d = (d + dd) >>> 0;
+ }
+
+ var rotl = function (n, b) {
+ return (n << b) | (n >>> (32 - b));
+ };
+
+ var endian = function (n) {
+ // If number given, swap endian
+ if (n.constructor == Number) {
+ return rotl(n, 8) & 0x00FF00FF |
+ rotl(n, 24) & 0xFF00FF00;
+ }
+
+ // Else, assume array and swap all items
+ for (var i = 0; i < n.length; i++) {
+ n[i] = endian(n[i]);
+ }
+ return n;
+ };
+
+ return fromByteArray(wordsToBytes(endian([a, b, c, d])));
+};
+sjcl = {
+ cipher: {}
+};
+sjcl.cipher.aes = function(e, d) {
+ this._tables[0][0][0] || this._precompute();
+ this.mode = d;
+ var c, b, a, f, g, h = this._tables[0][4],
+ n = this._tables[1];
+ b = e.length;
+ var l = 1;
+ if (4 !== b && 6 !== b && 8 !== b) throw "invalid aes key size";
+ this._key = [f = e.slice(0), g = []];
+ for (c = b; c < 4 * b + 28; c++) {
+ a = f[c - 1];
+ if (0 === c % b || 8 === b && 4 === c % b) a = h[a >>> 24] << 24 ^ h[a >> 16 & 255] << 16 ^ h[a >> 8 & 255] << 8 ^ h[a & 255], 0 === c % b && (a = a << 8 ^ a >>> 24 ^ l << 24, l = l << 1 ^ 283 * (l >> 7));
+ f[c] = f[c - b] ^ a
+ }
+ for (b = 0; c; b++, c--) a = f[b & 3 ? c : c - 4], g[b] = 4 >= c || 4 > b ? a : n[0][h[a >>> 24]] ^ n[1][h[a >> 16 & 255]] ^ n[2][h[a >>
+ 8 & 255]] ^ n[3][h[a & 255]]
+};
+sjcl.cipher.aes.MODE_CBC = 2;
+sjcl.cipher.aes.MODE_CTR = 6;
+sjcl.cipher.aes.prototype = {
+ encrypt: function(e, d, c) {
+ d = this.mode == sjcl.cipher.aes.MODE_CBC ? d : [];
+ for (var b = [], a = 0; a < e.length / 16; a++) {
+ var f = e.slice(16 * a, 16 * (a + 1));
+ if (this.mode == sjcl.cipher.aes.MODE_CBC) {
+ for (var g = 0; 16 > g; g++) f[g] ^= d[g];
+ d = sjcl.codec.bytes.fromBits(this._crypt(sjcl.codec.bytes.toBits(f), 0))
+ } else
+ for (d = sjcl.codec.bytes.fromBits(this._crypt(sjcl.codec.bytes.toBits(toByteArray(c.increment())), 0)), g = 0; 16 > g; g++) d[g] ^= f[g];
+ b = b.concat(d)
+ }
+ return b
+ },
+ decrypt: function(e, d) {
+ for (var c = [], b = 0; b < e.length /
+ 16; b++) {
+ var a = e.slice(16 * b, 16 * (b + 1));
+ ct = sjcl.codec.bytes.fromBits(this._crypt(sjcl.codec.bytes.toBits(a), 1));
+ if (this.mode == sjcl.cipher.aes.MODE_CBC) {
+ for (var f = 0; 16 > f; f++) ct[f] ^= d[f];
+ d = a
+ }
+ c = c.concat(ct)
+ }
+ return c
+ },
+ _tables: [
+ [
+ [],
+ [],
+ [],
+ [],
+ []
+ ],
+ [
+ [],
+ [],
+ [],
+ [],
+ []
+ ]
+ ],
+ _precompute: function() {
+ var e = this._tables[0],
+ d = this._tables[1],
+ c = e[4],
+ b = d[4],
+ a, f, g, h = [],
+ n = [],
+ l, p, k, m;
+ for (a = 0; 256 > a; a++) n[(h[a] = a << 1 ^ 283 * (a >> 7)) ^ a] = a;
+ for (f = g = 0; !c[f]; f ^= l || 1, g = n[g] || 1)
+ for (k = g ^ g << 1 ^ g << 2 ^ g << 3 ^ g << 4, k = k >> 8 ^ k & 255 ^ 99, c[f] = k, b[k] = f, p = h[a =
+ h[l = h[f]]], m = 16843009 * p ^ 65537 * a ^ 257 * l ^ 16843008 * f, p = 257 * h[k] ^ 16843008 * k, a = 0; 4 > a; a++) e[a][f] = p = p << 24 ^ p >>> 8, d[a][k] = m = m << 24 ^ m >>> 8;
+ for (a = 0; 5 > a; a++) e[a] = e[a].slice(0), d[a] = d[a].slice(0)
+ },
+ _crypt: function(e, d) {
+ if (4 !== e.length) throw "invalid aes block size";
+ var c = this._key[d],
+ b = e[0] ^ c[0],
+ a = e[d ? 3 : 1] ^ c[1],
+ f = e[2] ^ c[2],
+ g = e[d ? 1 : 3] ^ c[3],
+ h, n, l, p = c.length / 4 - 2,
+ k, m = 4,
+ w = [0, 0, 0, 0];
+ h = this._tables[d];
+ var q = h[0],
+ r = h[1],
+ t = h[2],
+ u = h[3],
+ v = h[4];
+ for (k = 0; k < p; k++) h = q[b >>> 24] ^ r[a >> 16 & 255] ^ t[f >> 8 & 255] ^ u[g & 255] ^ c[m], n = q[a >>> 24] ^ r[f >>
+ 16 & 255] ^ t[g >> 8 & 255] ^ u[b & 255] ^ c[m + 1], l = q[f >>> 24] ^ r[g >> 16 & 255] ^ t[b >> 8 & 255] ^ u[a & 255] ^ c[m + 2], g = q[g >>> 24] ^ r[b >> 16 & 255] ^ t[a >> 8 & 255] ^ u[f & 255] ^ c[m + 3], m += 4, b = h, a = n, f = l;
+ for (k = 0; 4 > k; k++) w[d ? 3 & -k : k] = v[b >>> 24] << 24 ^ v[a >> 16 & 255] << 16 ^ v[f >> 8 & 255] << 8 ^ v[g & 255] ^ c[m++], h = b, b = a, a = f, f = g, g = h;
+ return w
+ }
+};
+sjcl.codec = {};
+sjcl.codec.bytes = {
+ fromBits: function(e) {
+ var d = [],
+ c = sjcl.bitArray.bitLength(e),
+ b, a;
+ for (b = 0; b < c / 8; b++) 0 === (b & 3) && (a = e[b / 4]), d.push(a >>> 24), a <<= 8;
+ return d
+ },
+ toBits: function(e) {
+ var d = [],
+ c, b = 0;
+ for (c = 0; c < e.length; c++) b = b << 8 | e[c], 3 === (c & 3) && (d.push(b), b = 0);
+ c & 3 && d.push(sjcl.bitArray.partial(8 * (c & 3), b));
+ return d
+ }
+};
+sjcl.bitArray = {
+ bitLength: function(e) {
+ var d = e.length;
+ return 0 === d ? 0 : 32 * (d - 1) + sjcl.bitArray.getPartial(e[d - 1])
+ },
+ partial: function(e, d, c) {
+ return 32 === e ? d : (c ? d | 0 : d << 32 - e) + 1099511627776 * e
+ },
+ getPartial: function(e) {
+ return Math.round(e / 1099511627776) || 32
+ }
+};
+/*
+ Slightly modified version of [randomart](https://github.com/purpliminal/randomart)
+ to run in web browsers based on SSH RSA keys
+*/
+
+var symbols = {
+ "-2": "E",
+ "-1": "S",
+ "0": " ",
+ "1": ".",
+ "2": "o",
+ "3": "+",
+ "4": "=",
+ "5": "*",
+ "6": "B",
+ "7": "O",
+ "8": "X",
+ "9": "@",
+ "10": "%",
+ "11": "&",
+ "12": "#",
+ "13": "/",
+ "14": "^"
+};
+
+var bounds = {
+ width: 17,
+ height: 9
+};
+
+function createBoard(bounds) {
+ var result = [];
+
+ for (var i = 0; i < bounds.width; i++) {
+ result[i] = [];
+ for (var j = 0; j < bounds.height; j++) {
+ result[i][j] = 0;
+ }
+ }
+ return result;
+}
+
+function generateBoard(data) {
+ var board = createBoard(bounds);
+
+ var x = Math.floor(bounds.width / 2);
+ var y = Math.floor(bounds.height / 2);
+
+ board[x][y] = -1;
+
+ data.forEach(
+ function(b) {
+ for (var s = 0; s < 8; s += 2) {
+ var d = (b >> s) & 3;
+
+ switch (d) {
+ case 0: // up
+ case 1:
+ if (y > 0) y--;
+ break;
+ case 2: // down
+ case 3:
+ if (y < (bounds.height - 1)) y++;
+ break;
+ }
+ switch (d) {
+ case 0: // left
+ case 2:
+ if (x > 0) x--;
+ break;
+ case 1: // right
+ case 3:
+ if (x < (bounds.width - 1)) x++;
+ break;
+ }
+
+ if (board[x][y] >= 0) board[x][y]++;
+ }
+ }
+ );
+
+ board[x][y] = -2;
+ return board;
+}
+
+function boardToString(board) {
+ result = [];
+
+ for (var i = 0; i < bounds.height; i++) {
+ result[i] = [];
+ for (var j = 0; j < bounds.width; j++) {
+ result[i][j] = symbols[board[j][i]] || symbols[0];
+ }
+ // Add | to start and end of result[i]
+ result[i] = '|' + result[i].join('') + '|';
+ }
+ result.splice(0, 0, '\n+---[ RSA2048 ]---+');
+ result.push('+-----------------+');
+ return result.join('\n');
+}
+
+function randomart(data) {
+ var buffer = [];
+ for(var i = 0, length = data.length; i < length; i++){
+ buffer.push('0x' + data[i]);
+ }
+ // Write the board to HTML
+ document.getElementById('hostKeyImg').innerHTML = boardToString(generateBoard(buffer));
+ return;
+}
+var struct = {
+ pack: function(e, a) {
+ var b = "";
+ switch (e) {
+ case "Q":
+ var d = new BigInteger("ff", 16),
+ b = b + String.fromCharCode(a.shiftRight(56).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(48).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(40).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(32).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(24).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(16).and(d)),
+ b = b + String.fromCharCode(a.shiftRight(8).and(d)),
+ b = b + String.fromCharCode(a.and(d));
+ break;
+ case "I":
+ b += String.fromCharCode(a >>>
+ 24 & 255), b += String.fromCharCode(a >>> 16 & 255), b += String.fromCharCode(a >>> 8 & 255);
+ case "B":
+ b += String.fromCharCode(a & 255)
+ }
+ return b
+ },
+ unpack: function(e, a) {
+ var b = [],
+ d = 0,
+ c = 0;
+ switch (e) {
+ case "Q":
+ c = new BigInteger("0", 10);
+ c = c.add((new BigInteger(a.charCodeAt(0).toString(), 10)).shiftLeft(56));
+ c = c.add((new BigInteger(a.charCodeAt(1).toString(), 10)).shiftLeft(48));
+ c = c.add((new BigInteger(a.charCodeAt(2).toString(), 10)).shiftLeft(40));
+ c = c.add((new BigInteger(a.charCodeAt(3).toString(), 10)).shiftLeft(32));
+ c = c.add((new BigInteger(a.charCodeAt(4).toString(),
+ 10)).shiftLeft(24));
+ c = c.add((new BigInteger(a.charCodeAt(5).toString(), 10)).shiftLeft(16));
+ c = c.add((new BigInteger(a.charCodeAt(6).toString(), 10)).shiftLeft(8));
+ c = c.add((new BigInteger(a.charCodeAt(7).toString(), 10)).shiftLeft(0));
+ b.push(c);
+ break;
+ case "I":
+ c += a.charCodeAt(0) << 24 >>> 0, c += a.charCodeAt(1) << 16 >>> 0, c += a.charCodeAt(2) << 8 >>> 0, d += 3;
+ case "B":
+ c += a.charCodeAt(0 + d) << 0 >>> 0, b.push(c)
+ }
+ return b
+ }
+};
+function inflate_long(a) {
+ var c = new BigInteger("0", 10);
+ a.length % 4 && (a = Array(4 - a.length % 4 + 1).join("\x00") + a);
+ for (var b = 0; b < a.length; b += 4)
+ c = c.shiftLeft(32), c = c.add(new BigInteger(struct.unpack("I", a.substring(b, b + 4))[0].toString(), 10));
+ return c
+}
+
+function deflate_long(a, c) {
+ a = "number" == typeof a ? new BigInteger(a.toString(), 10) : a.clone();
+ c = void 0 == c ? !0 : c;
+ for (var b = "", d = new BigInteger("-1", 10), f = new BigInteger("ffffffff", 16); !a.equals(BigInteger.ZERO) && !a.equals(d);) b = struct.pack("I", a.and(f)) + b, a = a.shiftRight(32);
+ for (var f = !1, e = 0; e < b.length; ++e) {
+ if (a.equals(BigInteger.ZERO) && "\x00" != b.charAt(e)) {
+ f = !0;
+ break
+ }
+ if (a.equals(d) && "\u00ff" != b.charAt(e)) {
+ f = !0;
+ break
+ }
+ }
+ f || (e = 0, b = a.equals(BigInteger.ZERO) ? "\x00" : "\u00ff");
+ b = b.substring(e);
+ c && (a.equals(BigInteger.ZERO) &&
+ 128 <= b.charCodeAt(0) && (b = "\x00" + b), a.equals(d) && 128 > b.charCodeAt(0) && (b = "\u00ff" + b));
+ return b
+}
+// Converts strings to byte arrays
+function toByteArray(a) {
+ var bufView = new Uint8Array(a.length);
+ for (var i=0; i < a.length; i++) {
+ bufView[i] = a.charCodeAt(i);
+ }
+ return bufView;
+}
+// Converts byte arrays to strings
+function fromByteArray(a) {
+ return String.fromCharCode.apply(null, new Uint8Array(a));
+}
+// Converts bytes to words
+function bytesToWords(a) {
+ for (var c = [], b = 0, d = 0; b < a.length; b++, d += 8) c[d >>> 5] |= (a[b] & 255) << 24 - d % 32;
+ return c
+}
+// Converts words to bytes
+function wordsToBytes(a) {
+ for (var c = [], b = 0; b < 32 * a.length; b += 8) c.push(a[b >>> 5] >>> 24 - b % 32 & 255);
+ return c
+}
+// Used to set specific values for the AES counter
+function setCharAt(a, c, b) {
+ return a.substring(0, c) + b + a.substring(c + 1)
+};
+// Converts UTF-8 strings to raw encoding that xtemrm.js can handle
+function fromUtf8(str) {
+ var res = '';
+ var bytes = toByteArray(str);
+ for (var i = 0; i < str.length; i++) {
+ var c = str.charCodeAt(i);
+ if (c >= 0x00C0 && c <= 0x00DF) {
+ var c2 = bytes[++i];
+ c = ((c & 0x1F) << 6) | (c2 & 0x3F);
+ } else if (c >= 0x00E0 && c <= 0x00EF) {
+ var c2 = bytes[++i];
+ var c3 = bytes[++i];
+ c = ((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F);
+ } else if (c >= 0x0080) {
+ c = '.'; // Invalid encoding, unprintable character
+ }
+ res += String.fromCharCode(c);
+ }
+ return res;
+ }
+// returns a b byte random number
+function read_rng(b) {
+ return String.fromCharCode.apply(null, window.crypto.getRandomValues(new Uint8Array(b)))
+}
+// Used for filtering algorithms and selecting the algorithms to be used during kex_init
+function filter(client, server) {
+ client = client.split(',')
+ for (var x = 0; x < client.length; ++x) {
+ if (server.indexOf(client[x]) != -1) {
+ return client[x];
+ }
+ }
+}
+// Used to split large chunks of text pasted into the client into managable portions
+function splitSlice(str, len = 5000) {
+ var ret = [ ];
+ for (var offset = 0, strLen = str.length; offset < strLen; offset += len) {
+ ret.push(str.slice(offset, len + offset));
+ }
+ return ret;
+}
+// Modifies a hex color by percent (+/-) light/darkness
+function modColorPercent(color, percent) {
+ var f=parseInt(color.slice(1),16),t=percent<0?0:255,p=percent<0?percent*-1:percent,R=f>>16,G=f>>8&0x00FF,B=f&0x0000FF;
+ return "#"+(0x1000000+(Math.round((t-R)*p)+R)*0x10000+(Math.round((t-G)*p)+G)*0x100+(Math.round((t-B)*p)+B)).toString(16).slice(1);
+}
+// Converts an ascii string to hex encoded string
+function ascii2hex(a) {
+ for (var c = "", b = 0; b < a.length; b++) c = 1 == a.charCodeAt(b).toString(16).length ? c + ("0" + a.charCodeAt(b).toString(16)) : c + ("" + a.charCodeAt(b).toString(16));
+ return c;
+}
+
+// Moves the cursor back one and deletes a character from xtermjs term
+function termBackspace(term) {
+ term.write('\b');
+ term.eraseRight(term.buffers._terminal.buffer.x - 1, term.buffers._terminal.buffer.y);
+}SSHyClient.kex = {
+ K: null, // Our secret key K generated by our preferred_kex algorithm
+ H: null, // A hash used for encryption key generation by the preferred_keys algorithm
+ sessionId: null // Session identifier; should be the same as H until a rekey event
+};
+
+function verifyKey(host_key, sig){
+ var rsa = new SSHyClient.RSAKey(new SSHyClient.Message(host_key));
+ if(!rsa.verify(SSHyClient.kex.H, new SSHyClient.Message(sig))){
+ transport.disconnect();
+ throw 'RSA signature verification failed, disconnecting.';
+ }
+}
+
+SSHyClient.kex.DiffieHellman = function(transport, group, SHAVersion){
+ this.transport = transport;
+ this.SHAVersion = SHAVersion;
+ this.group = group;
+
+ // Using group to determine what type of DH; 0= GEX; 1=g1; 14=g14
+ if(this.group === undefined){
+ this.p = this.q = this.g = this.x = this.e = this.f = null;
+
+ this.minBits = 1024;
+ this.maxBits = 8192;
+ this.preferredBits = 2048;
+ return;
+ } else if(this.group === 1){
+ this.p = new BigInteger("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF", 16);
+ } else if(this.group === 14){
+ this.p = new BigInteger("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF", 16);
+ }
+
+ // These only apply to DH group 1 and 14
+ this.x = this.e = this.f = new BigInteger('0', 10);
+ this.G = new BigInteger("2", 10);
+};
+
+SSHyClient.kex.DiffieHellman.prototype = {
+ start: function() {
+ var m = new SSHyClient.Message();
+
+ if(this.group === undefined){
+ m.add_bytes(String.fromCharCode(SSHyClient.MSG_KEXDH_GEX_REQUEST));
+ m.add_int(this.minBits);
+ m.add_int(this.preferredBits);
+ m.add_int(this.maxBits);
+ } else {
+ // generates our 128 bit random number
+ this.x = inflate_long(read_rng(128));
+
+ // Now we calculate e = (g=2) ^ x mod p
+ this.e = this.G.modPow(this.x, this.p);
+
+ // Now we create the message and send it
+ m.add_bytes(String.fromCharCode(SSHyClient.MSG_KEXDH_INIT));
+ m.add_mpint(this.e);
+ }
+
+ this.transport.send_packet(m);
+ },
+
+ parse_reply: function(ptype, r) {
+ if(this.group === undefined && ptype == SSHyClient.MSG_KEXDH_GEX_GROUP){
+ this.parse_gex_group(r);
+ return;
+ }
+ this.handleDHReply(r);
+ },
+
+ handleDHReply: function(r){
+ // convert r into message format for deconstruction
+ r = new SSHyClient.Message(r);
+
+ // get the host key, f and signature from the message
+ var host_key = r.get_string();
+ if(transport.settings.rsaCheckEnabled){
+ // Now lets make sure that the host_key is recognised, firstly we'll pre-fetch all the data we require (ip/port/rsaKey)
+ var key = wsproxyURL.split('/')[3];
+ // Cache the hexified host key
+ var hexHostKey = ascii2hex(host_key);
+ // Generate the short MD5'd key for randomart and confirm
+ var shortKey = ascii2hex(SSHyClient.hash.MD5(host_key)).match(/.{2}/g);
+
+ // Create the randomArt image
+ randomart(shortKey);
+
+ // Since we've got everthing we need lets see if the key exists already
+ var localObj = localStorage.getItem(key);
+
+ if(localObj){
+ // Check all the details match.. they should but Sanity
+ if(localObj != hexHostKey){
+ if(confirm('WARNING - POTENTIAL SECURITY BREACH!\r\n\nThe server\s host key does not match the one SSHy has cached in local storage. This means that either the server administrator has changed the host key, or you have actually connected to another computer pretending to be the server.\r\nThe new rsa2 key fingerprint is:\r\nssh-rsa 2048 ' + shortKey.join(':') + '\r\nIf you were expecting this change and trust the new key, hit `Ok` to add the key to SSHy\'s cache and carry on connecting.\r\nIf you do not trust this new key, hit `Cancel` to abandon the connection')){
+ // User has agree'd to the new host key so lets save it for them
+ localStorage.setItem(key, hexHostKey);
+ } else {
+ // Close the connection
+ ws.close();
+ throw 'Error: Locally stored rsa key does not match remote key';
+ }
+ }
+ } else {
+ // Prompt the user just like they are in puTTy
+ if(confirm('The server\'s host key is not cached in local storage. You have no guarentee that the server is the computer you think it is.\n\rThe server\'s rsa2 key finterprint is:\r\nssh-rsa 2048 ' + shortKey.join(':') + '\r\nIf you trust the host, hit `Ok` to add the key to SSHy\'s cache and carry on connecting.\r\nIf you do not trust this host, hit `Cancel` to abandon the connection')){
+ // User has confirmed it is correct so save the RSA key
+ localStorage.setItem(key, hexHostKey);
+ } else {
+ // need to disconnect and kill the connection
+ ws.close();
+ throw 'User has declined the rsa-key and closed the connection';
+ }
+ }
+ }
+
+ this.f = r.get_mpint();
+
+ var sig = r.get_string();
+ // calculate our shared secret key (K) using f
+ var K = this.f.modPow(this.x, this.p);
+
+ /*
+ Now we need to generate H = hash(V_C || V_S || I_C || I_S || K_S || e || f || K)
+ where V_ = identification string, K_ = public host key, I_ = SSH_MSG_KEXINIT message
+ */
+ var m = new SSHyClient.Message();
+ m.add_string(this.transport.local_version);
+ m.add_string(this.transport.remote_version);
+ m.add_string(this.transport.local_kex_message);
+ m.add_string(this.transport.remote_kex_message);
+ m.add_string(host_key);
+ // Only add these if we're using DH GEX
+ if(this.group === undefined){
+ m.add_int(this.minBits);
+ m.add_int(this.preferredBits);
+ m.add_int(this.maxBits);
+ m.add_mpint(this.p);
+ m.add_mpint(this.g);
+ }
+ m.add_mpint(this.e);
+ m.add_mpint(this.f);
+ m.add_mpint(K);
+
+ SSHyClient.kex.K = K;
+ SSHyClient.kex.sessionId = SSHyClient.kex.H = this.SHAVersion == 'SHA-1' ? new SSHyClient.hash.SHA1(m.toString()).digest() : new SSHyClient.hash.SHA256(m.toString()).digest();
+ if(transport.settings.rsaCheckEnabled){
+ verifyKey(host_key, sig);
+ }
+ this.transport.send_new_keys();
+ },
+
+ // generates our secret x
+ generate_x: function() {
+ var q = this.p.subtract(BigInteger.ONE);
+ q = q.divide(new BigInteger("2", 10));
+
+ var qnorm = deflate_long(q, 0);
+ var qhbyte = qnorm[0].charCodeAt(0);
+ var bytes = qnorm.length;
+ var qmask = 0xff;
+ while (!(qhbyte & 0x80)) {
+ qhbyte <<= 1;
+ qmask >>= 1;
+ }
+ var x;
+ while (true) {
+ var x_bytes = read_rng(bytes);
+ x_bytes = String.fromCharCode(x_bytes[0].charCodeAt(0) & qmask) + x_bytes.substring(1);
+ x = inflate_long(x_bytes, 1);
+ if (x.compareTo(BigInteger.ONE) > 0 && q.compareTo(x) > 0) {
+ break;
+ }
+ }
+ this.x = x;
+ },
+ // gets the prime and group from parse_reply and generates our secret number e
+ parse_gex_group: function(m) {
+ m = new SSHyClient.Message(m);
+ this.p = m.get_mpint();
+ this.g = m.get_mpint();
+
+ this.generate_x();
+
+ this.e = this.g.modPow(this.x, this.p);
+
+ m = new SSHyClient.Message();
+ m.add_bytes(String.fromCharCode(SSHyClient.MSG_KEXDH_GEX_INIT));
+ m.add_mpint(this.e);
+ this.transport.send_packet(m);
+ }
+};
+SSHyClient.Transport = function(ws, settings) {
+ this.local_version = 'SSH-2.0-SSHyClient';
+ this.remote_version = '';
+
+ // Kex variables
+ this.local_kex_message = null; // Our local kex init message containing algorithm negotiation
+ this.remote_kex_message = null; // The remote servers ^
+
+ // Our supported Algorithms
+ this.preferred_algorithms = ['diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha256,diffie-hellman-group1-sha1',
+ 'ssh-rsa',
+ 'aes128-ctr',
+ 'hmac-sha2-256,hmac-sha1',
+ 'none',
+ ''
+ ];
+
+ // Objects storing references to our different algorithm modules
+ this.preferred_kex = null;
+ this.preferred_mac = null;
+ this.preferred_hash = null;
+
+ // Other SSHyClient module classes
+ this.parceler = new SSHyClient.parceler(ws, this);
+ this.auth = new SSHyClient.auth(this.parceler);
+ this.settings = settings === undefined ? new SSHyClient.settings() : settings;
+
+ this.lastKey = '';
+
+ this.closing = false;
+};
+
+SSHyClient.Transport.prototype = {
+ /* Lookup table for all of our supported KEX algorithms
+ - Called by kex_info[ id]
+ - returns