(function(z){"object"===typeof exports&&"undefined"!==typeof module?module.exports=z():"function"===typeof define&&define.amd?define([],z):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Terminal=z()})(function(){return function d(n,e,b){function i(a,l){if(!e[a]){if(!n[a]){var f="function"==typeof require&&require;if(!l&&f)return f(a,!0);if(c)return c(a,!0);f=Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f;}f=e[a]={exports:{}};
n[a][0].call(f.exports,function(m){var j=n[a][1][m];return i(j?j:m)},f,f.exports,d,n,e,b)}return e[a].exports}for(var c="function"==typeof require&&require,a=0;a<b.length;a++)i(b[a]);return i}({1:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});var b=d("./utils/CircularList"),d=function(){function i(b){this._terminal=b;this.clear()}Object.defineProperty(i.prototype,"lines",{get:function(){return this._lines},enumerable:!0,configurable:!0});i.prototype.fillViewportRows=function(){if(0===
this._lines.length)for(var b=this._terminal.rows;b--;)this.lines.push(this._terminal.blankLine())};i.prototype.clear=function(){this.scrollTop=this.scrollBottom=this.x=this.y=this.ybase=this.ydisp=0;this.tabs={};this._lines=new b.CircularList(this._terminal.scrollback);this.scrollBottom=this._terminal.rows-1};i.prototype.resize=function(b,a){if(0!==this._lines.length){if(this._terminal.cols<b)for(var k=[this._terminal.defAttr," ",1],l=0;l<this._lines.length;l++)for(void 0===this._lines.get(l)&&this._lines.set(l,
this._terminal.blankLine(void 0,void 0,b));this._lines.get(l).length<b;)this._lines.get(l).push(k);k=0;if(this._terminal.rows<a)for(l=this._terminal.rows;l<a;l++)this._lines.length<a+this.ybase&&(0<this.ybase&&this._lines.length<=this.ybase+this.y+k+1?(this.ybase--,k++,0<this.ydisp&&this.ydisp--):this._lines.push(this._terminal.blankLine(void 0,void 0,b)));else for(l=this._terminal.rows;l>a;l--)this._lines.length>a+this.ybase&&(this._lines.length>this.ybase+this.y+1?this._lines.pop():(this.ybase++,
this.ydisp++));this.y>=a&&(this.y=a-1);k&&(this.y+=k);this.x>=b&&(this.x=b-1);this.scrollTop=0;this.scrollBottom=a-1}};return i}();e.Buffer=d},{"./utils/CircularList":18}],2:[function(d,n,e){var b=this&&this.__extends||function(){var b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var l in b)b.hasOwnProperty(l)&&(a[l]=b[l])};return function(a,k){function l(){this.constructor=a}b(a,k);a.prototype=null===k?Object.create(k):(l.prototype=k.prototype,
new l)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=d("./Buffer"),d=function(c){function a(a){var b=c.call(this)||this;b._terminal=a;b._normal=new i.Buffer(b._terminal);b._normal.fillViewportRows();b._alt=new i.Buffer(b._terminal);b._activeBuffer=b._normal;return b}b(a,c);Object.defineProperty(a.prototype,"alt",{get:function(){return this._alt},enumerable:!0,configurable:!0});Object.defineProperty(a.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!0,configurable:!0});
Object.defineProperty(a.prototype,"normal",{get:function(){return this._normal},enumerable:!0,configurable:!0});a.prototype.activateNormalBuffer=function(){this._alt.clear();this._activeBuffer=this._normal;this.emit("activate",this._normal)};a.prototype.activateAltBuffer=function(){this._alt.fillViewportRows();this._activeBuffer=this._alt;this.emit("activate",this._alt)};a.prototype.resize=function(a,b){this._normal.resize(a,b);this._alt.resize(a,b)};return a}(d("./EventEmitter").EventEmitter);e.BufferSet=
d},{"./Buffer":1,"./EventEmitter":6}],3:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});e.CHARSETS={};e.DEFAULT_CHARSET=e.CHARSETS.B;e.CHARSETS["0"]={"`":"\u25c6",a:"\u2592",b:"\t",c:"\u000c",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"};
e.CHARSETS.A={"#":"\u00a3"};e.CHARSETS.B=null;e.CHARSETS["4"]={"#":"\u00a3","@":"\u00be","[":"ij","\\":"\u00bd","]":"|","{":"\u00a8","|":"f","}":"\u00bc","~":"\u00b4"};e.CHARSETS.C=e.CHARSETS["5"]={"[":"\u00c4","\\":"\u00d6","]":"\u00c5","^":"\u00dc","`":"\u00e9","{":"\u00e4","|":"\u00f6","}":"\u00e5","~":"\u00fc"};e.CHARSETS.R={"#":"\u00a3","@":"\u00e0","[":"\u00b0","\\":"\u00e7","]":"\u00a7","{":"\u00e9","|":"\u00f9","}":"\u00e8","~":"\u00a8"};e.CHARSETS.Q={"@":"\u00e0","[":"\u00e2","\\":"\u00e7",
"]":"\u00ea","^":"\u00ee","`":"\u00f4","{":"\u00e9","|":"\u00f9","}":"\u00e8","~":"\u00fb"};e.CHARSETS.K={"@":"\u00a7","[":"\u00c4","\\":"\u00d6","]":"\u00dc","{":"\u00e4","|":"\u00f6","}":"\u00fc","~":"\u00df"};e.CHARSETS.Y={"#":"\u00a3","@":"\u00a7","[":"\u00b0","\\":"\u00e7","]":"\u00e9","`":"\u00f9","{":"\u00e0","|":"\u00f2","}":"\u00e8","~":"\u00ec"};e.CHARSETS.E=e.CHARSETS["6"]={"@":"\u00c4","[":"\u00c6","\\":"\u00d8","]":"\u00c5","^":"\u00dc","`":"\u00e4","{":"\u00e6","|":"\u00f8","}":"\u00e5",
"~":"\u00fc"};e.CHARSETS.Z={"#":"\u00a3","@":"\u00a7","[":"\u00a1","\\":"\u00d1","]":"\u00bf","{":"\u00b0","|":"\u00f1","}":"\u00e7"};e.CHARSETS.H=e.CHARSETS["7"]={"@":"\u00c9","[":"\u00c4","\\":"\u00d6","]":"\u00c5","^":"\u00dc","`":"\u00e9","{":"\u00e4","|":"\u00f6","}":"\u00e5","~":"\u00fc"};e.CHARSETS["="]={"#":"\u00f9","@":"\u00e0","[":"\u00e9","\\":"\u00e7","]":"\u00ea","^":"\u00ee",_:"\u00e8","`":"\u00f4","{":"\u00e4","|":"\u00f6","}":"\u00fc","~":"\u00fb"}},{}],4:[function(d,n,e){Object.defineProperty(e,
"__esModule",{value:!0});d=function(){function b(b,c,a){this.textarea=b;this.compositionView=c;this.terminal=a;this.isSendingComposition=this.isComposing=!1;this.compositionPosition={start:null,end:null}}b.prototype.compositionstart=function(){this.isComposing=!0;this.compositionPosition.start=this.textarea.value.length;this.compositionView.textContent="";this.compositionView.classList.add("active")};b.prototype.compositionupdate=function(b){var c=this;this.compositionView.textContent=b.data;this.updateCompositionElements();
setTimeout(function(){c.compositionPosition.end=c.textarea.value.length},0)};b.prototype.compositionend=function(){this.finalizeComposition(!0)};b.prototype.keydown=function(b){if(this.isComposing||this.isSendingComposition){if(229===b.keyCode||16===b.keyCode||17===b.keyCode||18===b.keyCode)return!1;this.finalizeComposition(!1)}return 229===b.keyCode?(this.handleAnyTextareaChanges(),!1):!0};b.prototype.finalizeComposition=function(b){var c=this;this.compositionView.classList.remove("active");this.isComposing=
!1;this.clearTextareaPosition();if(b){var a=this.compositionPosition.start,k=this.compositionPosition.end;this.isSendingComposition=!0;setTimeout(function(){if(c.isSendingComposition){c.isSendingComposition=!1;var b=void 0,b=c.isComposing?c.textarea.value.substring(a,k):c.textarea.value.substring(a);c.terminal.handler(b)}},0)}else this.isSendingComposition=!1,this.terminal.handler(this.textarea.value.substring(this.compositionPosition.start,this.compositionPosition.end))};b.prototype.handleAnyTextareaChanges=
function(){var b=this,c=this.textarea.value;setTimeout(function(){if(!b.isComposing){var a=b.textarea.value.replace(c,"");0<a.length&&b.terminal.handler(a)}},0)};b.prototype.updateCompositionElements=function(b){var c=this;if(this.isComposing){var a=this.terminal.element.querySelector(".terminal-cursor");if(a){var k=this.terminal.element.querySelector(".xterm-rows").offsetTop+a.offsetTop;this.compositionView.style.left=a.offsetLeft+"px";this.compositionView.style.top=k+"px";this.compositionView.style.height=
a.offsetHeight+"px";this.compositionView.style.lineHeight=a.offsetHeight+"px";var l=this.compositionView.getBoundingClientRect();this.textarea.style.left=a.offsetLeft+"px";this.textarea.style.top=k+"px";this.textarea.style.width=l.width+"px";this.textarea.style.height=l.height+"px";this.textarea.style.lineHeight=l.height+"px"}b||setTimeout(function(){return c.updateCompositionElements(!0)},0)}};b.prototype.clearTextareaPosition=function(){this.textarea.style.left="";this.textarea.style.top=""};return b}();
e.CompositionHelper=d},{}],5:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});d=e.C0||(e.C0={});d.NUL="\x00";d.SOH="\u0001";d.STX="\u0002";d.ETX="\u0003";d.EOT="\u0004";d.ENQ="\u0005";d.ACK="\u0006";d.BEL="\u0007";d.BS="\u0008";d.HT="\t";d.LF="\n";d.VT="\x0B";d.FF="\u000c";d.CR="\r";d.SO="\u000e";d.SI="\u000f";d.DLE="\u0010";d.DC1="\u0011";d.DC2="\u0012";d.DC3="\u0013";d.DC4="\u0014";d.NAK="\u0015";d.SYN="\u0016";d.ETB="\u0017";d.CAN="\u0018";d.EM="\u0019";d.SUB="\u001a";d.ESC="\u001b";
d.FS="\u001c";d.GS="\u001d";d.RS="\u001e";d.US="\u001f";d.SP=" ";d.DEL="\u007f"},{}],6:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});d=function(){function b(){this._events=this._events||{}}b.prototype.on=function(b,c){this._events[b]=this._events[b]||[];this._events[b].push(c)};b.prototype.off=function(b,c){if(this._events[b])for(var a=this._events[b],k=a.length;k--;)if(a[k]===c||a[k].listener===c){a.splice(k,1);break}};b.prototype.removeAllListeners=function(b){this._events[b]&&
delete this._events[b]};b.prototype.once=function(b,c){function a(){var k=Array.prototype.slice.call(arguments);this.off(b,a);return c.apply(this,k)}a.listener=c;return this.on(b,a)};b.prototype.emit=function(b){for(var c=[],a=1;a<arguments.length;a++)c[a-1]=arguments[a];if(this._events[b])for(var a=this._events[b],k=0;k<a.length;k++)a[k].apply(this,c)};b.prototype.listeners=function(b){return this._events[b]||[]};return b}();e.EventEmitter=d},{}],7:[function(d,n,e){Object.defineProperty(e,"__esModule",
{value:!0});var b=d("./EscapeSequences"),i=d("./Charsets"),d=function(){function c(a){this._terminal=a}c.prototype.addChar=function(a,b){if(" "<=a){var c=e.wcwidth(b);this._terminal.charset&&this._terminal.charset[a]&&(a=this._terminal.charset[a]);var f=this._terminal.buffer.y+this._terminal.buffer.ybase;if(!c&&this._terminal.buffer.x)this._terminal.buffer.lines.get(f)[this._terminal.buffer.x-1]&&(this._terminal.buffer.lines.get(f)[this._terminal.buffer.x-1][2]?this._terminal.buffer.lines.get(f)[this._terminal.buffer.x-
1][1]+=a:this._terminal.buffer.lines.get(f)[this._terminal.buffer.x-2]&&(this._terminal.buffer.lines.get(f)[this._terminal.buffer.x-2][1]+=a),this._terminal.updateRange(this._terminal.buffer.y));else{if(this._terminal.buffer.x+c-1>=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===c)return;f=this._terminal.buffer.y+this._terminal.buffer.ybase;if(this._terminal.insertMode)for(var m=0;m<c;++m)0===this._terminal.buffer.lines.get(this._terminal.buffer.y+this._terminal.buffer.ybase).pop()[2]&&this._terminal.buffer.lines.get(f)[this._terminal.cols-2]&&2===this._terminal.buffer.lines.get(f)[this._terminal.cols-2][2]&&(this._terminal.buffer.lines.get(f)[this._terminal.cols-2]=[this._terminal.curAttr," ",1]),this._terminal.buffer.lines.get(f).splice(this._terminal.buffer.x,
0,[this._terminal.curAttr," ",1]);this._terminal.buffer.lines.get(f)[this._terminal.buffer.x]=[this._terminal.curAttr,a,c];this._terminal.buffer.x++;this._terminal.updateRange(this._terminal.buffer.y);2===c&&(this._terminal.buffer.lines.get(f)[this._terminal.buffer.x]=[this._terminal.curAttr,"",0],this._terminal.buffer.x++)}}};c.prototype.bell=function(){var a=this;this._terminal.visualBell&&(this._terminal.element.style.borderColor="white",setTimeout(function(){return a._terminal.element.style.borderColor=
""},10),this._terminal.popOnBell&&this._terminal.focus())};c.prototype.lineFeed=function(){this._terminal.convertEol&&(this._terminal.buffer.x=0);this._terminal.buffer.y++;this._terminal.buffer.y>this._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")};c.prototype.carriageReturn=function(){this._terminal.buffer.x=0};c.prototype.backspace=function(){0<this._terminal.buffer.x&&
this._terminal.buffer.x--};c.prototype.tab=function(){this._terminal.buffer.x=this._terminal.nextStop()};c.prototype.shiftOut=function(){this._terminal.setgLevel(1)};c.prototype.shiftIn=function(){this._terminal.setgLevel(0)};c.prototype.insertChars=function(a){var b,c,f,a=a[0];1>a&&(a=1);b=this._terminal.buffer.y+this._terminal.buffer.ybase;c=this._terminal.buffer.x;for(f=[this._terminal.eraseAttr()," ",1];a--&&c<this._terminal.cols;)this._terminal.buffer.lines.get(b).splice(c++,0,f),this._terminal.buffer.lines.get(b).pop()};
c.prototype.cursorUp=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.y-=a;0>this._terminal.buffer.y&&(this._terminal.buffer.y=0)};c.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--};c.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)};c.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)};c.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};c.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};c.prototype.cursorCharAbsolute=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x=a-1};c.prototype.cursorPosition=function(a){var b;b=a[0]-1;a=2<=a.length?a[1]-1:0;0>b?b=0:b>=this._terminal.rows&&(b=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=b};c.prototype.cursorForwardTab=function(a){for(a=
a[0]||1;a--;)this._terminal.buffer.x=this._terminal.nextStop()};c.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;a<this._terminal.rows;a++)this._terminal.eraseLine(a);break;case 1:this._terminal.eraseLeft(this._terminal.buffer.x,this._terminal.buffer.y);for(a=this._terminal.buffer.y;a--;)this._terminal.eraseLine(a);break;case 2:for(a=this._terminal.rows;a--;)this._terminal.eraseLine(a);
break;case 3:a=this._terminal.buffer.lines.length-this._terminal.rows,0<a&&(this._terminal.buffer.lines.trimStart(a),this._terminal.buffer.ybase=Math.max(this._terminal.buffer.ybase-a,0),this._terminal.buffer.ydisp=Math.max(this._terminal.buffer.ydisp-a,0),this._terminal.emit("scroll",0))}};c.prototype.eraseInLine=function(a){switch(a[0]){case 0:this._terminal.eraseRight(this._terminal.buffer.x,this._terminal.buffer.y);break;case 1:this._terminal.eraseLeft(this._terminal.buffer.x,this._terminal.buffer.y);
break;case 2:this._terminal.eraseLine(this._terminal.buffer.y)}};c.prototype.insertLines=function(a){var b,c,a=a[0];1>a&&(a=1);b=this._terminal.buffer.y+this._terminal.buffer.ybase;c=this._terminal.rows-1-this._terminal.buffer.scrollBottom;for(c=this._terminal.rows-1+this._terminal.buffer.ybase-c+1;a--;)this._terminal.buffer.lines.length===this._terminal.buffer.lines.maxLength&&(this._terminal.buffer.lines.trimStart(1),this._terminal.buffer.ybase--,this._terminal.buffer.ydisp--,b--,c--),this._terminal.buffer.lines.splice(b,
0,this._terminal.blankLine(!0)),this._terminal.buffer.lines.splice(c,1);this._terminal.updateRange(this._terminal.buffer.y);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};c.prototype.deleteLines=function(a){var b,c,a=a[0];1>a&&(a=1);b=this._terminal.buffer.y+this._terminal.buffer.ybase;c=this._terminal.rows-1-this._terminal.buffer.scrollBottom;for(c=this._terminal.rows-1+this._terminal.buffer.ybase-c;a--;)this._terminal.buffer.lines.length===this._terminal.buffer.lines.maxLength&&
(this._terminal.buffer.lines.trimStart(1),this._terminal.buffer.ybase-=1,this._terminal.buffer.ydisp-=1),this._terminal.buffer.lines.splice(c+1,0,this._terminal.blankLine(!0)),this._terminal.buffer.lines.splice(b,1);this._terminal.updateRange(this._terminal.buffer.y);this._terminal.updateRange(this._terminal.buffer.scrollBottom)};c.prototype.deleteChars=function(a){var b,c,a=a[0];1>a&&(a=1);b=this._terminal.buffer.y+this._terminal.buffer.ybase;for(c=[this._terminal.eraseAttr()," ",1];a--;)this._terminal.buffer.lines.get(b).splice(this._terminal.buffer.x,
1),this._terminal.buffer.lines.get(b).push(c)};c.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)};c.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)};c.prototype.eraseChars=function(a){var b,c,f,a=a[0];1>a&&(a=1);b=this._terminal.buffer.y+this._terminal.buffer.ybase;c=this._terminal.buffer.x;for(f=[this._terminal.eraseAttr()," ",1];a--&&c<this._terminal.cols;)this._terminal.buffer.lines.get(b)[c++]=
f};c.prototype.cursorBackwardTab=function(a){for(a=a[0]||1;a--;)this._terminal.buffer.x=this._terminal.prevStop()};c.prototype.charPosAbsolute=function(a){a=a[0];1>a&&(a=1);this._terminal.buffer.x=a-1;this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)};c.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)};c.prototype.repeatPrecedingCharacter=
function(a){for(var a=a[0]||1,b=this._terminal.buffer.lines.get(this._terminal.buffer.ybase+this._terminal.buffer.y),c=b[this._terminal.buffer.x-1]||[this._terminal.defAttr," ",1];a--;)b[this._terminal.buffer.x++]=c};c.prototype.sendDeviceAttributes=function(a){0<a[0]||(this._terminal.prefix?">"===this._terminal.prefix&&(this._terminal.is("xterm")?this._terminal.send(b.C0.ESC+"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._terminal.send(b.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._terminal.send(a[0]+
"c"):this._terminal.is("screen")&&this._terminal.send(b.C0.ESC+"[>83;40003;0c")):this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._terminal.send(b.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._terminal.send(b.C0.ESC+"[?6c"))};c.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)};c.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--};c.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)};c.prototype.tabClear=function(a){a=a[0];0>=a?delete this._terminal.buffer.tabs[this._terminal.buffer.x]:3===a&&(this._terminal.buffer.tabs={})};c.prototype.setMode=function(a){if(1<a.length)for(var b=0;b<a.length;b++)this.setMode([a[b]]);else if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(a[0]){case 1:this._terminal.applicationCursor=!0;break;case 2:this._terminal.setgCharset(0,i.DEFAULT_CHARSET);this._terminal.setgCharset(1,i.DEFAULT_CHARSET);this._terminal.setgCharset(2,
i.DEFAULT_CHARSET);this._terminal.setgCharset(3,i.DEFAULT_CHARSET);break;case 3:this._terminal.savedCols=this._terminal.cols;this._terminal.resize(132,this._terminal.rows);break;case 6:this._terminal.originMode=!0;break;case 7:this._terminal.wraparoundMode=!0;break;case 66:this._terminal.log("Serial port requested application keypad.");this._terminal.applicationKeypad=!0;this._terminal.viewport.syncScrollArea();break;case 9:case 1E3:case 1002:case 1003:this._terminal.x10Mouse=9===a[0];this._terminal.vt200Mouse=
1E3===a[0];this._terminal.normalMouse=1E3<a[0];this._terminal.mouseEvents=!0;this._terminal.element.classList.add("enable-mouse-events");this._terminal.selectionManager.disable();this._terminal.log("Binding to mouse events.");break;case 1004:this._terminal.sendFocus=!0;break;case 1005:this._terminal.utfMouse=!0;break;case 1006:this._terminal.sgrMouse=!0;break;case 1015:this._terminal.urxvtMouse=!0;break;case 25:this._terminal.cursorHidden=!1;break;case 1049:case 47:case 1047:this._terminal.buffers.activateAltBuffer(),
this._terminal.viewport.syncScrollArea(),this._terminal.showCursor()}}else switch(a[0]){case 4:this._terminal.insertMode=!0}};c.prototype.resetMode=function(a){if(1<a.length)for(var b=0;b<a.length;b++)this.resetMode([a[b]]);else if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(a[0]){case 1:this._terminal.applicationCursor=!1;break;case 3:132===this._terminal.cols&&this._terminal.savedCols&&this._terminal.resize(this._terminal.savedCols,this._terminal.rows);delete this._terminal.savedCols;
break;case 6:this._terminal.originMode=!1;break;case 7:this._terminal.wraparoundMode=!1;break;case 66:this._terminal.log("Switching back to normal keypad.");this._terminal.applicationKeypad=!1;this._terminal.viewport.syncScrollArea();break;case 9:case 1E3:case 1002:case 1003:this._terminal.x10Mouse=!1;this._terminal.vt200Mouse=!1;this._terminal.normalMouse=!1;this._terminal.mouseEvents=!1;this._terminal.element.classList.remove("enable-mouse-events");this._terminal.selectionManager.enable();break;
case 1004:this._terminal.sendFocus=!1;break;case 1005:this._terminal.utfMouse=!1;break;case 1006:this._terminal.sgrMouse=!1;break;case 1015:this._terminal.urxvtMouse=!1;break;case 25:this._terminal.cursorHidden=!0;break;case 1049:case 47:case 1047:this._terminal.buffers.activateNormalBuffer(),this._terminal.selectionManager.setBuffer(this._terminal.buffer.lines),this._terminal.refresh(0,this._terminal.rows-1),this._terminal.viewport.syncScrollArea(),this._terminal.showCursor()}}else switch(a[0]){case 4:this._terminal.insertMode=
!1}};c.prototype.charAttributes=function(a){if(1===a.length&&0===a[0])this._terminal.curAttr=this._terminal.defAttr;else{for(var b=a.length,c=0,f=this._terminal.curAttr>>18,m=this._terminal.curAttr>>9&511,j=this._terminal.curAttr&511,h;c<b;c++)h=a[c],30<=h&&37>=h?m=h-30:40<=h&&47>=h?j=h-40:90<=h&&97>=h?(h+=8,m=h-90):100<=h&&107>=h?(h+=8,j=h-100):0===h?(f=this._terminal.defAttr>>18,m=this._terminal.defAttr>>9&511,j=this._terminal.defAttr&511):1===h?f|=1:4===h?f|=2:5===h?f|=4:7===h?f|=8:8===h?f|=16:
22===h?f&=-2:24===h?f&=-3:25===h?f&=-5:27===h?f&=-9:28===h?f&=-17:39===h?m=this._terminal.defAttr>>9&511:49===h?j=this._terminal.defAttr&511:38===h?2===a[c+1]?(c+=2,m=this._terminal.matchColor(a[c]&255,a[c+1]&255,a[c+2]&255),-1===m&&(m=511),c+=2):5===a[c+1]&&(c+=2,m=h=a[c]&255):48===h?2===a[c+1]?(c+=2,j=this._terminal.matchColor(a[c]&255,a[c+1]&255,a[c+2]&255),-1===j&&(j=511),c+=2):5===a[c+1]&&(c+=2,j=h=a[c]&255):100===h?(m=this._terminal.defAttr>>9&511,j=this._terminal.defAttr&511):this._terminal.error("Unknown SGR attribute: %d.",
h);this._terminal.curAttr=f<<18|m<<9|j}};c.prototype.deviceStatus=function(a){if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(a[0]){case 6:this._terminal.send(b.C0.ESC+"[?"+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R")}}else switch(a[0]){case 5:this._terminal.send(b.C0.ESC+"[0n");break;case 6:this._terminal.send(b.C0.ESC+"["+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R")}};c.prototype.softReset=function(){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]};c.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)};c.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)};c.prototype.saveCursor=function(){this._terminal.buffer.savedX=this._terminal.buffer.x;this._terminal.buffer.savedY=this._terminal.buffer.y};c.prototype.restoreCursor=function(){this._terminal.buffer.x=this._terminal.buffer.savedX||0;this._terminal.buffer.y=this._terminal.buffer.savedY||0};return c}();e.InputHandler=d;e.wcwidth=function(b){function a(a,b){var c=0,m=b.length-1,f;if(a<b[0][0]||a>b[m][1])return!1;for(;m>=c;)if(f=c+m>>1,a>b[f][1])c=f+1;else if(a<b[f][0])m=f-1;else return!0;return!1}
var k=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,
2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,
4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,
64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],f=b.control|0,m=null;return function(j){j|=0;if(32>j)return f|0;if(127>j)return 1;var h;if(!(h=m)){m="undefined"===typeof Uint32Array?Array(4096):new Uint32Array(4096);for(h=0;4096>h;++h){for(var i=0,g=16;g--;){var i=i<<2,d;d=16*h+g;d=
0===d?b.nul:32>d||127<=d&&160>d?b.control:a(d,k)?0:4352<=d&&(4447>=d||9001===d||9002===d||11904<=d&&42191>=d&&12351!==d||44032<=d&&55203>=d||63744<=d&&64255>=d||65040<=d&&65049>=d||65072<=d&&65135>=d||65280<=d&&65376>=d||65504<=d&&65510>=d)?2:1;i|=d}m[h]=i}h=m}j=65536>j?h[j>>4]>>((j&15)<<1)&3:a(j,l)?0:131072<=j&&196605>=j||196608<=j&&262141>=j?2:1;return j}}({nul:0,control:0})},{"./Charsets":3,"./EscapeSequences":5}],8:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});var b=RegExp("(?:^|[^\\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\\.\\-%]+)"),
i=0,d=function(){function c(){this._nextLinkMatcherId=i;this._rowTimeoutIds=[];this._linkMatchers=[];this.registerLinkMatcher(b,null,{matchIndex:1})}c.prototype.attachToDom=function(a,b){this._document=a;this._rows=b};c.prototype.linkifyRow=function(a){if(this._document){var b=this._rowTimeoutIds[a];b&&clearTimeout(b);this._rowTimeoutIds[a]=setTimeout(this._linkifyRow.bind(this,a),c.TIME_BEFORE_LINKIFY)}};c.prototype.setHypertextLinkHandler=function(a){this._linkMatchers[i].handler=a};c.prototype.setHypertextValidationCallback=
function(a){this._linkMatchers[i].validationCallback=a};c.prototype.registerLinkMatcher=function(a,b,c){void 0===c&&(c={});if(this._nextLinkMatcherId!==i&&!b)throw Error("handler must be defined");a={id:this._nextLinkMatcherId++,regex:a,handler:b,matchIndex:c.matchIndex,validationCallback:c.validationCallback,priority:c.priority||0};this._addLinkMatcherToList(a);return a.id};c.prototype._addLinkMatcherToList=function(a){if(0===this._linkMatchers.length)this._linkMatchers.push(a);else{for(var b=this._linkMatchers.length-
1;0<=b;b--)if(a.priority<=this._linkMatchers[b].priority){this._linkMatchers.splice(b+1,0,a);return}this._linkMatchers.splice(0,0,a)}};c.prototype.deregisterLinkMatcher=function(a){for(var b=1;b<this._linkMatchers.length;b++)if(this._linkMatchers[b].id===a)return this._linkMatchers.splice(b,1),!0;return!1};c.prototype._linkifyRow=function(a){if(a=this._rows[a])for(var b=0;b<this._linkMatchers.length;b++){var c=this._linkMatchers[b],f=this._doLinkifyRow(a,c);if(0<f.length){if(c.validationCallback){a=
function(a){var b=f[a];c.validationCallback(b.textContent,b,function(a){a||b.classList.add("xterm-invalid-link")})};for(b=0;b<f.length;b++)a(b)}break}}};c.prototype._doLinkifyRow=function(a,b){var c=[],f=b.id===i,m=a.childNodes,j=a.textContent.match(b.regex);if(!j||0===j.length)return c;for(var h=j["number"!==typeof b.matchIndex?0:b.matchIndex],d=j.index+h.length,g=0;g<m.length;g++){var e=m[g],o=e.textContent.indexOf(h);if(0<=o){j=this._createAnchorElement(h,b.handler,f);if(e.textContent.length===
h.length)if(3===e.nodeType)this._replaceNode(e,j);else{h=e;if("A"===h.nodeName)break;h.innerHTML="";h.appendChild(j)}else if(1<e.childNodes.length)for(o=0;o<e.childNodes.length;o++){var p=e.childNodes[o],n=p.textContent.indexOf(h);if(-1!==n){this._replaceNodeSubstringWithNode(p,j,h,n);break}}else h=this._replaceNodeSubstringWithNode(e,j,h,o),g+=h;c.push(j);j=a.textContent.substring(d).match(b.regex);if(!j||0===j.length)break;h=j["number"!==typeof b.matchIndex?0:b.matchIndex];d+=j.index+h.length}}return c};
c.prototype._createAnchorElement=function(a,b,c){var f=this._document.createElement("a");f.textContent=a;f.draggable=!1;c?(f.href=a,f.target="_blank",f.addEventListener("click",function(c){if(b)return b(c,a)})):f.addEventListener("click",function(c){return f.classList.contains("xterm-invalid-link")?void 0:b(c,a)});return f};c.prototype._replaceNode=function(a){for(var b=[],c=1;c<arguments.length;c++)b[c-1]=arguments[c];for(var c=a.parentNode,f=0;f<b.length;f++)c.insertBefore(b[f],a);c.removeChild(a)};
c.prototype._replaceNodeSubstringWithNode=function(a,b,c,f){1===a.childNodes.length&&(a=a.childNodes[0]);if(3!==a.nodeType)throw Error("targetNode must be a text node or only contain a single text node");var m=a.textContent;if(0===f){var j=this._document.createTextNode(m.substring(c.length));this._replaceNode(a,b,j);return 0}if(f===a.textContent.length-c.length)return j=this._document.createTextNode(m.substring(0,f)),this._replaceNode(a,j,b),0;j=this._document.createTextNode(m.substring(0,f));c=this._document.createTextNode(m.substring(f+
c.length));this._replaceNode(a,j,b,c);return 1};return c}();d.TIME_BEFORE_LINKIFY=200;e.Linkifier=d},{}],9:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});var b=d("./EscapeSequences"),i=d("./Charsets"),c={};c[b.C0.BEL]=function(a,b){return b.bell()};c[b.C0.LF]=function(a,b){return b.lineFeed()};c[b.C0.VT]=c[b.C0.LF];c[b.C0.FF]=c[b.C0.LF];c[b.C0.CR]=function(a,b){return b.carriageReturn()};c[b.C0.BS]=function(a,b){return b.backspace()};c[b.C0.HT]=function(a,b){return b.tab()};c[b.C0.SO]=
function(a,b){return b.shiftOut()};c[b.C0.SI]=function(a,b){return b.shiftIn()};c[b.C0.ESC]=function(a){return a.setState(f.ESCAPED)};var a={"[":function(a,b){b.params=[];b.currentParam=0;a.setState(f.CSI_PARAM)},"]":function(a,b){b.params=[];b.currentParam=0;a.setState(f.OSC)},P:function(a,b){b.params=[];b.currentParam=0;a.setState(f.DCS)},_:function(a){a.setState(f.IGNORE)},"^":function(a){a.setState(f.IGNORE)},c:function(a,b){b.reset()},E:function(a,b){b.buffer.x=0;b.index();a.setState(f.NORMAL)},
D:function(a,b){b.index();a.setState(f.NORMAL)},M:function(a,b){b.reverseIndex();a.setState(f.NORMAL)},"%":function(a,b){b.setgLevel(0);b.setgCharset(0,i.DEFAULT_CHARSET);a.setState(f.NORMAL);a.skipNextChar()}};a[b.C0.CAN]=function(a){return a.setState(f.NORMAL)};var k={"?":function(a){return a.setPrefix("?")},">":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()}};k[b.C0.CAN]=function(a){return a.setState(f.NORMAL)};var l={"@":function(a,b){return a.insertChars(b)},A:function(a,b){return a.cursorUp(b)},B:function(a,b){return a.cursorDown(b)},C:function(a,b){return a.cursorForward(b)},D:function(a,b){return a.cursorBackward(b)},E:function(a,b){return a.cursorNextLine(b)},F:function(a,b){return a.cursorPrecedingLine(b)},G:function(a,b){return a.cursorCharAbsolute(b)},H:function(a,
b){return a.cursorPosition(b)},I:function(a,b){return a.cursorForwardTab(b)},J:function(a,b){return a.eraseInDisplay(b)},K:function(a,b){return a.eraseInLine(b)},L:function(a,b){return a.insertLines(b)},M:function(a,b){return a.deleteLines(b)},P:function(a,b){return a.deleteChars(b)},S:function(a,b){return a.scrollUp(b)},T:function(a,b,c){2>b.length&&!c&&a.scrollDown(b)},X:function(a,b){return a.eraseChars(b)},Z:function(a,b){return a.cursorBackwardTab(b)},"`":function(a,b){return a.charPosAbsolute(b)},
a:function(a,b){return a.HPositionRelative(b)},b:function(a,b){return a.repeatPrecedingCharacter(b)},c:function(a,b){return a.sendDeviceAttributes(b)},d:function(a,b){return a.linePosAbsolute(b)},e:function(a,b){return a.VPositionRelative(b)},f:function(a,b){return a.HVPosition(b)},g:function(a,b){return a.tabClear(b)},h:function(a,b){return a.setMode(b)},l:function(a,b){return a.resetMode(b)},m:function(a,b){return a.charAttributes(b)},n:function(a,b){return a.deviceStatus(b)},p:function(a,b,c){switch(c){case "!":a.softReset(b)}},
q:function(a,b,c,f){" "===f&&a.setCursorStyle(b)},r:function(a,b){return a.setScrollRegion(b)},s:function(a,b){return a.saveCursor(b)},u:function(a,b){return a.restoreCursor(b)}};l[b.C0.CAN]=function(a,b,c,d,g){return g.setState(f.NORMAL)};var f;(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"})(f||(f={}));d=function(){function d(a,b){this._inputHandler=a;this._terminal=
b;this._state=f.NORMAL}d.prototype.parse=function(d){var h=d.length,e,g,m;this._terminal.debug&&this._terminal.log("data: "+d);this._position=0;this._terminal.surrogate_high&&(d=this._terminal.surrogate_high+d,this._terminal.surrogate_high="");for(;this._position<h;this._position++){g=d[this._position];e=d.charCodeAt(this._position);if(55296<=e&&56319>=e){m=d.charCodeAt(this._position+1);if(isNaN(m)){this._terminal.surrogate_high=g;continue}e=1024*(e-55296)+(m-56320)+65536;g+=d.charAt(this._position+
1)}if(!(56320<=e&&57343>=e))switch(this._state){case f.NORMAL:if(g in c)c[g](this,this._inputHandler);else this._inputHandler.addChar(g,e);break;case f.ESCAPED:if(g in a){a[g](this,this._terminal);break}switch(g){case "(":case ")":case "*":case "+":case "-":case ".":switch(g){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=f.CHARSET;break;case "/":this._terminal.gcharset=3;this._state=f.CHARSET;this._position--;break;case "N":break;case "O":break;case "n":this._terminal.setgLevel(2);break;case "o":this._terminal.setgLevel(3);break;case "|":this._terminal.setgLevel(3);break;case "}":this._terminal.setgLevel(2);break;case "~":this._terminal.setgLevel(1);break;case "7":this._inputHandler.saveCursor();this._state=f.NORMAL;break;case "8":this._inputHandler.restoreCursor();this._state=f.NORMAL;break;case "#":this._state=
f.NORMAL;this._position++;break;case "H":this._terminal.tabSet();this._state=f.NORMAL;break;case "=":this._terminal.log("Serial port requested application keypad.");this._terminal.applicationKeypad=!0;this._terminal.viewport.syncScrollArea();this._state=f.NORMAL;break;case ">":this._terminal.log("Switching back to normal keypad.");this._terminal.applicationKeypad=!1;this._terminal.viewport.syncScrollArea();this._state=f.NORMAL;break;default:this._state=f.NORMAL,this._terminal.error("Unknown ESC control: %s.",
g)}break;case f.CHARSET:g in i.CHARSETS?(e=i.CHARSETS[g],"/"===g&&this.skipNextChar()):e=i.DEFAULT_CHARSET;this._terminal.setgCharset(this._terminal.gcharset,e);this._terminal.gcharset=null;this._state=f.NORMAL;break;case f.OSC:if(g===b.C0.ESC||g===b.C0.BEL){g===b.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=f.NORMAL}else this._terminal.params.length?this._terminal.currentParam+=g:"0"<=g&&"9">=g?this._terminal.currentParam=10*this._terminal.currentParam+g.charCodeAt(0)-48:";"===g&&(this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam="");break;case f.CSI_PARAM:if(g in k){k[g](this);break}this.finalizeParam();this._state=f.CSI;case f.CSI:g in l?(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:"")+" "+g),l[g](this._inputHandler,this._terminal.params,this._terminal.prefix,this._terminal.postfix,this)):this._terminal.error("Unknown CSI code: %s.",g);this._state=f.NORMAL;this._terminal.prefix="";this._terminal.postfix="";break;case f.DCS:if(g===b.C0.ESC||g===b.C0.BEL){g===b.C0.ESC&&this._position++;e=g=void 0;switch(this._terminal.prefix){case "":break;case "$q":g=this._terminal.currentParam;
e=!1;switch(g){case '"q':g='0"q';break;case '"p':g='61"p';break;case "r":g=""+(this._terminal.buffer.scrollTop+1)+";"+(this._terminal.buffer.scrollBottom+1)+"r";break;case "m":g="0m";break;default:this._terminal.error("Unknown DCS Pt: %s.",g),g=""}this._terminal.send(b.C0.ESC+"P"+ +e+"$r"+g+b.C0.ESC+"\\");break;case "+p":break;case "+q":g=this._terminal.currentParam;e=!1;this._terminal.send(b.C0.ESC+"P"+ +e+"+r"+g+b.C0.ESC+"\\");break;default:this._terminal.error("Unknown DCS prefix: %s.",this._terminal.prefix)}this._terminal.currentParam=
0;this._terminal.prefix="";this._state=f.NORMAL}else this._terminal.currentParam?this._terminal.currentParam+=g:!this._terminal.prefix&&"$"!==g&&"+"!==g?this._terminal.currentParam=g:2===this._terminal.prefix.length?this._terminal.currentParam=g:this._terminal.prefix+=g;break;case f.IGNORE:if(g===b.C0.ESC||g===b.C0.BEL)g===b.C0.ESC&&this._position++,this._state=f.NORMAL}}return this._state};d.prototype.setState=function(a){this._state=a};d.prototype.setPrefix=function(a){this._terminal.prefix=a};
d.prototype.setPostfix=function(a){this._terminal.postfix=a};d.prototype.setParam=function(a){this._terminal.currentParam=a};d.prototype.getParam=function(){return this._terminal.currentParam};d.prototype.finalizeParam=function(){this._terminal.params.push(this._terminal.currentParam);this._terminal.currentParam=0};d.prototype.skipNextChar=function(){this._position++};return d}();e.Parser=d},{"./Charsets":3,"./EscapeSequences":5}],10:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});
var b=d("./utils/DomElementObjectPool"),i;(function(a){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"})(i||(i={}));var c=null,d=function(){function a(a){this._terminal=a;this._refreshRowsQueue=[];this._refreshFramesSkipped=0;this._refreshAnimationFrame=null;this._spanElementObjectPool=new b.DomElementObjectPool("span");if(null===c){var a=this._terminal.element,d=a.ownerDocument.createElement("span");d.innerHTML="hello world";
a.appendChild(d);var f=d.offsetWidth,i=d.offsetHeight;d.style.fontWeight="bold";var e=d.offsetWidth,h=d.offsetHeight;a.removeChild(d);c=f!==e||i!==h}this._spanElementObjectPool=new b.DomElementObjectPool("span")}a.prototype.queueRefresh=function(a,b){this._refreshRowsQueue.push({start:a,end:b});this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(this._refreshLoop.bind(this)))};a.prototype._refreshLoop=function(){if(0<this._terminal.writeBuffer.length&&5>=this._refreshFramesSkipped++)this._refreshAnimationFrame=
window.requestAnimationFrame(this._refreshLoop.bind(this));else{this._refreshFramesSkipped=0;var a,b;if(4<this._refreshRowsQueue.length)a=0,b=this._terminal.rows-1;else{a=this._refreshRowsQueue[0].start;b=this._refreshRowsQueue[0].end;for(var c=1;c<this._refreshRowsQueue.length;c++)this._refreshRowsQueue[c].start<a&&(a=this._refreshRowsQueue[c].start),this._refreshRowsQueue[c].end>b&&(b=this._refreshRowsQueue[c].end)}this._refreshRowsQueue=[];this._refreshAnimationFrame=null;this._refresh(a,b)}};
a.prototype._refresh=function(a,b){var f;b-a>=this._terminal.rows/2&&(f=this._terminal.element.parentNode)&&this._terminal.element.removeChild(this._terminal.rowContainer);var d=this._terminal.cols,e=a;b>=this._terminal.rows&&(this._terminal.log("`end` is too large. Most likely a bad CSR."),b=this._terminal.rows-1);for(;e<=b;e++){for(var h=this._terminal.buffer.lines.get(e+this._terminal.buffer.ydisp),u=void 0,u=this._terminal.buffer.y===e-(this._terminal.buffer.ybase-this._terminal.buffer.ydisp)&&
this._terminal.cursorState&&!this._terminal.cursorHidden?this._terminal.buffer.x:-1,g=this._terminal.defAttr,n=document.createDocumentFragment(),o="",p=void 0;this._terminal.children[e].children.length;){var s=this._terminal.children[e].children[0];this._terminal.children[e].removeChild(s);this._spanElementObjectPool.release(s)}for(s=0;s<d;s++){var v=h[s][0],w=h[s][1],y=h[s][2],t=s===u;if(y){if(v!==g||t)if(g!==this._terminal.defAttr&&!t&&(o&&(p.innerHTML=o,o=""),n.appendChild(p),p=null),v!==this._terminal.defAttr||
t){o&&!p&&(p=this._spanElementObjectPool.acquire());p&&(o&&(p.innerHTML=o,o=""),n.appendChild(p));var p=this._spanElementObjectPool.acquire(),g=v&511,r=v>>9&511,q=v>>18;t&&(p.classList.add("reverse-video"),p.classList.add("terminal-cursor"));q&i.BOLD&&(c||p.classList.add("xterm-bold"),8>r&&(r+=8));q&i.UNDERLINE&&p.classList.add("xterm-underline");q&i.BLINK&&p.classList.add("xterm-blink");if(q&i.INVERSE){var x=g,g=r,r=x;q&1&&8>r&&(r+=8)}q&i.INVISIBLE&&!t&&p.classList.add("xterm-hidden");q&i.INVERSE&&
(257===g&&(g=15),256===r&&(r=0));256>g&&p.classList.add("xterm-bg-color-"+g);256>r&&p.classList.add("xterm-color-"+r)}if(2===y)o+='<span class="xterm-wide-char">'+w+"</span>";else if(255<w.charCodeAt(0))o+='<span class="xterm-normal-char">'+w+"</span>";else switch(w){case "&":o+="&amp;";break;case "<":o+="&lt;";break;case ">":o+="&gt;";break;default:o=" ">=w?o+"&nbsp;":o+w}g=t?-1:v}}o&&!p&&(p=this._spanElementObjectPool.acquire());p&&(o&&(p.innerHTML=o),n.appendChild(p));this._terminal.children[e].appendChild(n)}f&&
this._terminal.element.appendChild(this._terminal.rowContainer);this._terminal.emit("refresh",{element:this._terminal.element,start:a,end:b})};a.prototype.refreshSelection=function(a,b){for(;this._terminal.selectionContainer.children.length;)this._terminal.selectionContainer.removeChild(this._terminal.selectionContainer.children[0]);if(a&&b){var c=a[1]-this._terminal.buffer.ydisp,d=b[1]-this._terminal.buffer.ydisp,i=Math.max(c,0),h=Math.min(d,this._terminal.rows-1);if(!(i>=this._terminal.rows||0>
h)){var e=document.createDocumentFragment();e.appendChild(this._createSelectionElement(i,c===i?a[0]:0,i===h?b[0]:this._terminal.cols));e.appendChild(this._createSelectionElement(i+1,0,this._terminal.cols,h-i-1));i!==h&&e.appendChild(this._createSelectionElement(h,0,d===h?b[0]:this._terminal.cols));this._terminal.selectionContainer.appendChild(e)}}};a.prototype._createSelectionElement=function(a,b,c,d){void 0===d&&(d=1);var i=document.createElement("div");i.style.height=d*this._terminal.charMeasure.height+
"px";i.style.top=a*this._terminal.charMeasure.height+"px";i.style.left=b*this._terminal.charMeasure.width+"px";i.style.width=this._terminal.charMeasure.width*(c-b)+"px";return i};return a}();e.Renderer=d},{"./utils/DomElementObjectPool":19}],11:[function(d,n,e){var b=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=
b}a(b,c);b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}();Object.defineProperty(e,"__esModule",{value:!0});var i=d("./utils/Mouse"),c=d("./utils/Browser"),n=d("./EventEmitter"),a=d("./SelectionModel"),k=d("./utils/BufferLine"),d=String.fromCharCode(160),l=RegExp(d,"g"),f;(function(a){a[a.NORMAL=0]="NORMAL";a[a.WORD=1]="WORD";a[a.LINE=2]="LINE"})(f||(f={}));d=function(d){function e(b,c,g,i){var k=d.call(this)||this;k._terminal=b;k._buffer=c;k._rowContainer=g;k._charMeasure=
i;k._enabled=!0;k._initListeners();k.enable();k._model=new a.SelectionModel(b);k._activeSelectionMode=f.NORMAL;return k}b(e,d);e.prototype._initListeners=function(){var a=this;this._mouseMoveListener=function(b){return a._onMouseMove(b)};this._mouseUpListener=function(b){return a._onMouseUp(b)};this._rowContainer.addEventListener("mousedown",function(b){return a._onMouseDown(b)});this._buffer.on("trim",function(b){return a._onTrim(b)})};e.prototype.disable=function(){this.clearSelection();this._enabled=
!1};e.prototype.enable=function(){this._enabled=!0};e.prototype.setBuffer=function(a){this._buffer=a;this.clearSelection()};Object.defineProperty(e.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0});Object.defineProperty(e.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0});Object.defineProperty(e.prototype,"hasSelection",{get:function(){var a=this._model.finalSelectionStart,
b=this._model.finalSelectionEnd;return!a||!b?!1:a[0]!==b[0]||a[1]!==b[1]},enumerable:!0,configurable:!0});Object.defineProperty(e.prototype,"selectionText",{get:function(){var a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd;if(!a||!b)return"";var d=a[1]===b[1]?b[0]:null,f=[];f.push(k.translateBufferLineToString(this._buffer.get(a[1]),!0,a[0],d));for(d=a[1]+1;d<=b[1]-1;d++){var e=this._buffer.get(d),i=k.translateBufferLineToString(e,!0);e.isWrapped?f[f.length-1]+=i:f.push(i)}a[1]!==
b[1]&&(e=this._buffer.get(b[1]),i=k.translateBufferLineToString(e,!0,0,b[0]),e.isWrapped?f[f.length-1]+=i:f.push(i));return f.map(function(a){return a.replace(l," ")}).join(c.isMSWindows?"\r\n":"\n")},enumerable:!0,configurable:!0});e.prototype.clearSelection=function(){this._model.clearSelection();this._removeMouseDownListeners();this.refresh()};e.prototype.refresh=function(a){var b=this;this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(function(){return b._refresh()}));
c.isLinux&&a&&this.selectionText.length&&this.emit("newselection",this.selectionText)};e.prototype._refresh=function(){this._refreshAnimationFrame=null;this.emit("refresh",{start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd})};e.prototype.selectAll=function(){this._model.isSelectAllActive=!0;this.refresh()};e.prototype._onTrim=function(a){this._model.onTrim(a)&&this.refresh()};e.prototype._getMouseBufferCoords=function(a){a=i.getCoords(a,this._rowContainer,this._charMeasure,this._terminal.cols,
this._terminal.rows,!0);if(!a)return null;a[0]--;a[1]--;a[1]+=this._terminal.buffer.ydisp;return a};e.prototype._getMouseEventScrollAmount=function(a){var a=i.getCoordsRelativeToElement(a,this._rowContainer)[1],b=this._terminal.rows*this._charMeasure.height;if(0<=a&&a<=b)return 0;a>b&&(a-=b);a=Math.min(Math.max(a,-50),50);a/=50;return a/Math.abs(a)+Math.round(14*a)};e.prototype._onMouseDown=function(a){if(2===a.button&&this.hasSelection)a.stopPropagation();else if(0===a.button){if(!this._enabled){if(!c.isMac||
!a.altKey)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)}};e.prototype._addMouseDownListeners=function(){var a=this;this._rowContainer.ownerDocument.addEventListener("mousemove",this._mouseMoveListener);this._rowContainer.ownerDocument.addEventListener("mouseup",this._mouseUpListener);
this._dragScrollIntervalTimer=setInterval(function(){return a._dragScroll()},50)};e.prototype._removeMouseDownListeners=function(){this._rowContainer.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener);this._rowContainer.ownerDocument.removeEventListener("mouseup",this._mouseUpListener);clearInterval(this._dragScrollIntervalTimer);this._dragScrollIntervalTimer=null};e.prototype._onIncrementalClick=function(a){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(a))};
e.prototype._onSingleClick=function(a){this._model.selectionStartLength=0;this._model.isSelectAllActive=!1;this._activeSelectionMode=f.NORMAL;this._model.selectionStart=this._getMouseBufferCoords(a);this._model.selectionStart&&(this._model.selectionEnd=null,(a=this._buffer.get(this._model.selectionStart[1]))&&0===a[this._model.selectionStart[0]][2]&&this._model.selectionStart[0]++)};e.prototype._onDoubleClick=function(a){if(a=this._getMouseBufferCoords(a))this._activeSelectionMode=f.WORD,this._selectWordAt(a)};
e.prototype._onTripleClick=function(a){if(a=this._getMouseBufferCoords(a))this._activeSelectionMode=f.LINE,this._selectLineAt(a[1])};e.prototype._onMouseMove=function(a){var b=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;this._model.selectionEnd=this._getMouseBufferCoords(a);this._model.selectionEnd?(this._activeSelectionMode===f.LINE?this._model.selectionEnd[0]=this._model.selectionEnd[1]<this._model.selectionStart[1]?0:this._terminal.cols:this._activeSelectionMode===
f.WORD&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(a),0<this._dragScrollAmount?this._model.selectionEnd[0]=this._terminal.cols-1:0>this._dragScrollAmount&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]<this._buffer.length&&(a=this._buffer.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]])&&0===a[2]&&this._model.selectionEnd[0]++,(!b||b[0]!==this._model.selectionEnd[0]||b[1]!==this._model.selectionEnd[1])&&this.refresh(!0)):
this.refresh(!0)};e.prototype._dragScroll=function(){this._dragScrollAmount&&(this._terminal.scrollDisp(this._dragScrollAmount,!1),this._model.selectionEnd=0<this._dragScrollAmount?[this._terminal.cols-1,this._terminal.buffer.ydisp+this._terminal.rows]:[0,this._terminal.buffer.ydisp],this.refresh())};e.prototype._onMouseUp=function(){this._removeMouseDownListeners()};e.prototype._convertViewportColToCharacterIndex=function(a,b){for(var c=b[0],d=0;b[0]>=d;d++)0===a[d][2]&&c--;return c};e.prototype.setSelection=
function(a,b,c){this._model.clearSelection();this._removeMouseDownListeners();this._model.selectionStart=[a,b];this._model.selectionStartLength=c;this.refresh()};e.prototype._getWordAt=function(a){var b=this._buffer.get(a[1]);if(!b)return null;var c=k.translateBufferLineToString(b,!1),d=this._convertViewportColToCharacterIndex(b,a),f=d,e=a[0]-f,i=0,l=0;if(" "===c.charAt(f)){for(;0<f&&" "===c.charAt(f-1);)f--;for(;d<c.length&&" "===c.charAt(d+1);)d++}else{var j=a[0],a=a[0];0===b[j][2]&&(i++,j--);2===
b[a][2]&&(l++,a++);for(;0<f&&!this._isCharWordSeparator(c.charAt(f-1));)0===b[j-1][2]&&(i++,j--),f--,j--;for(;d+1<c.length&&!this._isCharWordSeparator(c.charAt(d+1));)2===b[a+1][2]&&(l++,a++),d++,a++}b=f+e-i;d=Math.min(d-f+i+l+1,this._terminal.cols);return{start:b,length:d}};e.prototype._selectWordAt=function(a){var b=this._getWordAt(a);b&&(this._model.selectionStart=[b.start,a[1]],this._model.selectionStartLength=b.length)};e.prototype._selectToWordAt=function(a){var b=this._getWordAt(a);b&&(this._model.selectionEnd=
[this._model.areSelectionValuesReversed()?b.start:b.start+b.length,a[1]])};e.prototype._isCharWordSeparator=function(a){return 0<=" ()[]{}'\"".indexOf(a)};e.prototype._selectLineAt=function(a){this._model.selectionStart=[0,a];this._model.selectionStartLength=this._terminal.cols};return e}(n.EventEmitter);e.SelectionManager=d},{"./EventEmitter":6,"./SelectionModel":12,"./utils/Browser":15,"./utils/BufferLine":16,"./utils/Mouse":21}],12:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});
d=function(){function b(b){this._terminal=b;this.clearSelection()}b.prototype.clearSelection=function(){this.selectionEnd=this.selectionStart=null;this.isSelectAllActive=!1;this.selectionStartLength=0};Object.defineProperty(b.prototype,"finalSelectionStart",{get:function(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,
"finalSelectionEnd",{get:function(){return this.isSelectAllActive?[this._terminal.cols,this._terminal.buffer.ybase+this._terminal.rows-1]:!this.selectionStart?null:!this.selectionEnd||this.areSelectionValuesReversed()?[this.selectionStart[0]+this.selectionStartLength,this.selectionStart[1]]:this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]?[Math.max(this.selectionStart[0]+this.selectionStartLength,this.selectionEnd[0]),this.selectionEnd[1]]:this.selectionEnd},enumerable:!0,
configurable:!0});b.prototype.areSelectionValuesReversed=function(){var b=this.selectionStart,c=this.selectionEnd;return b[1]>c[1]||b[1]===c[1]&&b[0]>c[0]};b.prototype.onTrim=function(b){this.selectionStart&&(this.selectionStart[1]-=b);this.selectionEnd&&(this.selectionEnd[1]-=b);if(this.selectionEnd&&0>this.selectionEnd[1])return this.clearSelection(),!0;this.selectionStart&&0>this.selectionStart[1]&&(this.selectionStart[1]=0);return!1};return b}();e.SelectionModel=d},{}],13:[function(d,n,e){Object.defineProperty(e,
"__esModule",{value:!0});d=function(){function b(b,c,a,d){var e=this;this.terminal=b;this.viewportElement=c;this.scrollArea=a;this.charMeasure=d;this.lastRecordedViewportHeight=this.lastRecordedBufferLength=this.currentRowHeight=0;this.terminal.on("scroll",this.syncScrollArea.bind(this));this.terminal.on("resize",this.syncScrollArea.bind(this));this.viewportElement.addEventListener("scroll",this.onScroll.bind(this));setTimeout(function(){return e.syncScrollArea()},0)}b.prototype.refresh=function(){if(0<
this.charMeasure.height){var b=this.charMeasure.height!==this.currentRowHeight;b&&(this.currentRowHeight=this.charMeasure.height,this.viewportElement.style.lineHeight=this.charMeasure.height+"px",this.terminal.rowContainer.style.lineHeight=this.charMeasure.height+"px");var c=this.lastRecordedViewportHeight!==this.terminal.rows;if(b||c)this.lastRecordedViewportHeight=this.terminal.rows,this.viewportElement.style.height=this.charMeasure.height*this.terminal.rows+"px",this.terminal.selectionContainer.style.height=
this.viewportElement.style.height;this.scrollArea.style.height=this.charMeasure.height*this.lastRecordedBufferLength+"px"}};b.prototype.syncScrollArea=function(){this.lastRecordedBufferLength!==this.terminal.buffer.lines.length?(this.lastRecordedBufferLength=this.terminal.buffer.lines.length,this.refresh()):this.lastRecordedViewportHeight!==this.terminal.rows?this.refresh():this.charMeasure.height!==this.currentRowHeight&&this.refresh();var b=this.terminal.buffer.ydisp*this.currentRowHeight;this.viewportElement.scrollTop!==
b&&(this.viewportElement.scrollTop=b)};b.prototype.onScroll=function(){this.terminal.scrollDisp(Math.round(this.viewportElement.scrollTop/this.currentRowHeight)-this.terminal.buffer.ydisp,!0)};b.prototype.onWheel=function(b){if(0!==b.deltaY){var c=1;b.deltaMode===WheelEvent.DOM_DELTA_LINE?c=this.currentRowHeight:b.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(c=this.currentRowHeight*this.terminal.rows);this.viewportElement.scrollTop+=b.deltaY*c;b.preventDefault()}};b.prototype.onTouchStart=function(b){this.lastTouchY=
b.touches[0].pageY};b.prototype.onTouchMove=function(b){var c=this.lastTouchY-b.touches[0].pageY;this.lastTouchY=b.touches[0].pageY;0!==c&&(this.viewportElement.scrollTop+=c,b.preventDefault())};return b}();e.Viewport=d},{}],14:[function(d,n,e){function b(b,a){return a?b.replace(/\r?\n/g,"\r"):b}function i(b,a){a.style.position="fixed";a.style.width="20px";a.style.height="20px";a.style.left=b.clientX-10+"px";a.style.top=b.clientY-10+"px";a.style.zIndex="1000";a.focus();setTimeout(function(){a.style.position=
null;a.style.width=null;a.style.height=null;a.style.left=null;a.style.top=null;a.style.zIndex=null},4)}Object.defineProperty(e,"__esModule",{value:!0});e.prepareTextForTerminal=b;e.copyHandler=function(b,a,d){a.browser.isMSIE?window.clipboardData.setData("Text",d.selectionText):b.clipboardData.setData("text/plain",d.selectionText);b.preventDefault()};e.pasteHandler=function(c,a){c.stopPropagation();var d,e=function(d){d=b(d,a.browser.isMSWindows);a.handler(d);a.textarea.value="";a.emit("paste",d);
return a.cancel(c)};a.browser.isMSIE?window.clipboardData&&(d=window.clipboardData.getData("Text"),e(d)):c.clipboardData&&(d=c.clipboardData.getData("text/plain"),e(d))};e.moveTextAreaUnderMouseCursor=i;e.rightClickHandler=function(b,a,d){i(b,a);a.value=d.selectionText;a.select()}},{}],15:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});var d=d("./Generic"),b="undefined"===typeof navigator?!0:!1,n=b?"node":navigator.userAgent,b=b?"node":navigator.platform;e.isFirefox=!!~n.indexOf("Firefox");
e.isMSIE=!!~n.indexOf("MSIE")||!!~n.indexOf("Trident");e.isMac=d.contains(["Macintosh","MacIntel","MacPPC","Mac68K"],b);e.isIpad="iPad"===b;e.isIphone="iPhone"===b;e.isMSWindows=d.contains(["Windows","Win16","Win32","WinCE"],b);e.isLinux=0<=b.indexOf("Linux")},{"./Generic":20}],16:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});e.translateBufferLineToString=function(b,d,c,a){void 0===c&&(c=0);void 0===a&&(a=null);for(var e="",l=c,f=a,m=0;m<b.length;m++){var j=b[m],e=e+j[1];0===j[2]&&
(c>=m&&l--,a>=m&&f--)}b=f||b.length;return d&&(d=e.search(/\s+$/),-1!==d&&(b=Math.min(b,d)),b<=l)?"":e.substring(l,b)}},{}],17:[function(d,n,e){var b=this&&this.__extends||function(){var b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,a){b.__proto__=a}||function(b,a){for(var d in a)a.hasOwnProperty(d)&&(b[d]=a[d])};return function(c,a){function d(){this.constructor=c}b(c,a);c.prototype=null===a?Object.create(a):(d.prototype=a.prototype,new d)}}();Object.defineProperty(e,"__esModule",
{value:!0});d=function(d){function c(a,b){var c=d.call(this)||this;c._document=a;c._parentElement=b;return c}b(c,d);Object.defineProperty(c.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0});c.prototype.measure=function(){var a=this;this._measureElement?this._doMeasure():(this._measureElement=this._document.createElement("span"),this._measureElement.style.position=
"absolute",this._measureElement.style.top="0",this._measureElement.style.left="-9999em",this._measureElement.textContent="W",this._measureElement.setAttribute("aria-hidden","true"),this._parentElement.appendChild(this._measureElement),setTimeout(function(){return a._doMeasure()},0))};c.prototype._doMeasure=function(){var a=this._measureElement.getBoundingClientRect();if(!(0===a.width||0===a.height))if(this._width!==a.width||this._height!==a.height)this._width=a.width,this._height=a.height,this.emit("charsizechanged")};
return c}(d("../EventEmitter.js").EventEmitter);e.CharMeasure=d},{"../EventEmitter.js":6}],18:[function(d,n,e){var b=this&&this.__extends||function(){var b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,a){b.__proto__=a}||function(b,a){for(var d in a)a.hasOwnProperty(d)&&(b[d]=a[d])};return function(c,a){function d(){this.constructor=c}b(c,a);c.prototype=null===a?Object.create(a):(d.prototype=a.prototype,new d)}}();Object.defineProperty(e,"__esModule",{value:!0});d=function(d){function c(a){var b=
d.call(this)||this;b._array=Array(a);b._startIndex=0;b._length=0;return b}b(c,d);Object.defineProperty(c.prototype,"maxLength",{get:function(){return this._array.length},set:function(a){for(var b=Array(a),c=0;c<Math.min(a,this.length);c++)b[c]=this._array[this._getCyclicIndex(c)];this._array=b;this._startIndex=0},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"length",{get:function(){return this._length},set:function(a){if(a>this._length)for(var b=this._length;b<a;b++)this._array[b]=
void 0;this._length=a},enumerable:!0,configurable:!0});Object.defineProperty(c.prototype,"forEach",{get:function(){var a=this;return function(b){for(var c=a.length,d=0;d<c;d++)b(a.get(d),d)}},enumerable:!0,configurable:!0});c.prototype.get=function(a){return this._array[this._getCyclicIndex(a)]};c.prototype.set=function(a,b){this._array[this._getCyclicIndex(a)]=b};c.prototype.push=function(a){this._array[this._getCyclicIndex(this._length)]=a;this._length===this.maxLength?(this._startIndex++,this._startIndex===
this.maxLength&&(this._startIndex=0),this.emit("trim",1)):this._length++};c.prototype.pop=function(){return this._array[this._getCyclicIndex(this._length-- -1)]};c.prototype.splice=function(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];if(b){for(d=a;d<this._length-b;d++)this._array[this._getCyclicIndex(d)]=this._array[this._getCyclicIndex(d+b)];this._length-=b}if(c&&c.length){for(d=this._length-1;d>=a;d--)this._array[this._getCyclicIndex(d+c.length)]=this._array[this._getCyclicIndex(d)];
for(d=0;d<c.length;d++)this._array[this._getCyclicIndex(a+d)]=c[d];this._length+c.length>this.maxLength?(c=this._length+c.length-this.maxLength,this._startIndex+=c,this._length=this.maxLength,this.emit("trim",c)):this._length+=c.length}};c.prototype.trimStart=function(a){a>this._length&&(a=this._length);this._startIndex+=a;this._length-=a;this.emit("trim",a)};c.prototype.shiftElements=function(a,b,c){if(!(0>=b)){if(0>a||a>=this._length)throw Error("start argument out of range");if(0>a+c)throw Error("Cannot shift elements in list beyond index 0");
if(0<c){for(var d=b-1;0<=d;d--)this.set(a+d+c,this.get(a+d));a=a+b+c-this._length;if(0<a)for(this._length+=a;this._length>this.maxLength;)this._length--,this._startIndex++,this.emit("trim",1)}else for(d=0;d<b;d++)this.set(a+d+c,this.get(a+d))}};c.prototype._getCyclicIndex=function(a){return(this._startIndex+a)%this.maxLength};return c}(d("../EventEmitter").EventEmitter);e.CircularList=d},{"../EventEmitter":6}],19:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});d=function(){function b(b){this._type=
this.type=b;this._pool=[];this._inUse={}}b.prototype.acquire=function(){var d;d=0===this._pool.length?this._createNew():this._pool.pop();return this._inUse[d.getAttribute(b.OBJECT_ID_ATTRIBUTE)]=d};b.prototype.release=function(d){if(!this._inUse[d.getAttribute(b.OBJECT_ID_ATTRIBUTE)])throw Error("Could not release an element not yet acquired");delete this._inUse[d.getAttribute(b.OBJECT_ID_ATTRIBUTE)];this._cleanElement(d);this._pool.push(d)};b.prototype._createNew=function(){var d=document.createElement(this._type),
c=b._objectCount++;d.setAttribute(b.OBJECT_ID_ATTRIBUTE,c.toString(10));return d};b.prototype._cleanElement=function(b){b.className="";b.innerHTML=""};return b}();d.OBJECT_ID_ATTRIBUTE="data-obj-id";d._objectCount=0;e.DomElementObjectPool=d},{}],20:[function(d,n,e){Object.defineProperty(e,"__esModule",{value:!0});e.contains=function(b,d){return 0<=b.indexOf(d)}},{}],21:[function(d,n,e){function b(b,a){if(null==b.pageX)return null;for(var d=b.pageX,e=b.pageY;a&&a!==self.document.documentElement;)d-=
a.offsetLeft,e-=a.offsetTop,a="offsetParent"in a?a.offsetParent:a.parentElement;return[d,e]}function i(c,a,d,e,f,i){if(!d.width||!d.height)return null;c=b(c,a);if(!c)return null;c[0]=Math.ceil((c[0]+(i?d.width/2:0))/d.width);c[1]=Math.ceil(c[1]/d.height);c[0]=Math.min(Math.max(c[0],1),e+1);c[1]=Math.min(Math.max(c[1],1),f+1);return c}Object.defineProperty(e,"__esModule",{value:!0});e.getCoordsRelativeToElement=b;e.getCoords=i;e.getRawByteCoords=function(b,a,d,e,f){a=i(b,a,d,e,f);b=a[0];a=a[1];return{x:b+
32,y:a+32}}},{}],22:[function(d,n,e){function b(a,c,d){var e=this;if(!(this instanceof b))return new b(a,c,d);e.browser=y;e.cancel=b.cancel;j.EventEmitter.call(this);"number"===typeof a&&(a={cols:a,rows:c,handler:d});a=a||{};Object.keys(b.defaults).forEach(function(c){null==a[c]&&(a[c]=b.options[c],b[c]!==b.defaults[c]&&(a[c]=b[c]));e[c]=a[c]});8===a.colors.length?a.colors=a.colors.concat(b._colors.slice(8)):16===a.colors.length?a.colors=a.colors.concat(b._colors.slice(16)):10===a.colors.length?a.colors=
a.colors.slice(0,-2).concat(b._colors.slice(8,-2),a.colors.slice(-2)):18===a.colors.length&&(a.colors=a.colors.concat(b._colors.slice(16,-2),a.colors.slice(-2)));this.colors=a.colors;this.options=a;this.parent=a.body||a.parent||(q?q.getElementsByTagName("body")[0]:null);this.cols=a.cols||a.geometry[0];this.rows=a.rows||a.geometry[1];this.geometry=[this.cols,this.rows];if(a.handler)this.on("data",a.handler);this.cursorState=0;this.cursorHidden=!1;this.convertEol;this.queue="";this.cursorBlinkInterval=
this.customKeyEventHandler=null;this.insertMode=this.originMode=this.applicationCursor=this.applicationKeypad=!1;this.wraparoundMode=!0;this.gcharset=this.charset=null;this.glevel=0;this.charsets=[null];this.decLocator;this.x10Mouse;this.vt200Mouse;this.vt300Mouse;this.normalMouse;this.mouseEvents;this.sendFocus;this.utfMouse;this.sgrMouse;this.urxvtMouse;this.element;this.children;this.refreshStart;this.refreshEnd;this.savedX;this.savedY;this.savedCols;this.writable=this.readable=!0;this.curAttr=
this.defAttr=131840;this.params=[];this.currentParam=0;this.postfix=this.prefix="";this.inputHandler=new A.InputHandler(this);this.parser=new o.Parser(this.inputHandler,this);this.renderer=this.renderer||null;this.selectionManager=this.selectionManager||null;this.linkifier=this.linkifier||new s.Linkifier;this.writeBuffer=[];this.writeStopped=this.xoffSentToCatchUp=this.writeInProgress=!1;this.surrogate_high="";this.buffers=new f.BufferSet(this);this.buffer=this.buffers.active;this.buffers.on("activate",
function(a){this._terminal.buffer=a});this.selectionManager&&this.selectionManager.setBuffer(this.buffer.lines);this.setupStops();this.userScrolling=!1}function i(a,b,c,d){Array.isArray(a)||(a=[a]);a.forEach(function(a){a.addEventListener(b,c,d||!1)})}function c(a,b,c,d){a.removeEventListener(b,c,d||!1)}function a(a,b){function c(){this.constructor=a}c.prototype=b.prototype;a.prototype=new c}function k(a,b){var c=a.browser.isMac&&b.altKey&&!b.ctrlKey&&!b.metaKey||a.browser.isMSWindows&&b.altKey&&
b.ctrlKey&&!b.metaKey;return"keypress"==b.type?c:c&&(!b.keyCode||47<b.keyCode)}function l(a,c,d){var e=a<<16|c<<8|d;if(null!=l._cache[e])return l._cache[e];for(var f=Infinity,g=-1,i=0,h,j,k;i<b.vcolors.length;i++){h=b.vcolors[i];j=h[0];k=h[1];h=h[2];j=l.distance(a,c,d,j,k,h);if(0===j){g=i;break}j<f&&(f=j,g=i)}return l._cache[e]=g}Object.defineProperty(e,"__esModule",{value:!0});var f=d("./BufferSet"),m=d("./CompositionHelper"),j=d("./EventEmitter"),h=d("./Viewport"),u=d("./handlers/Clipboard"),g=
d("./EscapeSequences"),A=d("./InputHandler"),o=d("./Parser"),p=d("./Renderer"),s=d("./Linkifier"),v=d("./SelectionManager"),w=d("./utils/CharMeasure"),y=d("./utils/Browser"),t=d("./utils/Mouse"),r=d("./utils/BufferLine"),q="undefined"!=typeof window?window.document:null;a(b,j.EventEmitter);b.prototype.eraseAttr=function(){return this.defAttr&-512|this.curAttr&511};b.tangoColors="#2e3436,#cc0000,#4e9a06,#c4a000,#3465a4,#75507b,#06989a,#d3d7cf,#555753,#ef2929,#8ae234,#fce94f,#729fcf,#ad7fa8,#34e2e2,#eeeeec".split(",");
b.colors=function(){function a(b,x,e){d.push("#"+c(b)+c(x)+c(e))}function c(a){a=a.toString(16);return 2>a.length?"0"+a:a}var d=b.tangoColors.slice(),e=[0,95,135,175,215,255],f;for(f=0;216>f;f++)a(e[f/36%6|0],e[f/6%6|0],e[f%6]);for(f=0;24>f;f++)e=8+10*f,a(e,e,e);return d}();b._colors=b.colors.slice();b.vcolors=function(){for(var a=[],c=b.colors,d=0,e;256>d;d++)e=parseInt(c[d].substring(1),16),a.push([e>>16&255,e>>8&255,e&255]);return a}();b.defaults={colors:b.colors,theme:"default",convertEol:!1,
termName:"xterm",geometry:[80,24],cursorBlink:!1,cursorStyle:"block",visualBell:!1,popOnBell:!1,scrollback:1E3,screenKeys:!1,debug:!1,cancelEvents:!1,disableStdin:!1,useFlowControl:!1,tabStopWidth:8};b.options={};b.focus=null;(function(a,b,c){if(a.forEach)return a.forEach(b,c);for(var d=0;d<a.length;d++)b.call(c,a[d],d,a)})(function(a){if(Object.keys)return Object.keys(a);var b,c=[];for(b in a)Object.prototype.hasOwnProperty.call(a,b)&&c.push(b);return c}(b.defaults),function(a){b[a]=b.defaults[a];
b.options[a]=b.defaults[a]});b.prototype.focus=function(){return this.textarea.focus()};b.prototype.getOption=function(a){if(!(a in b.defaults))throw Error('No option with key "'+a+'"');return"undefined"!==typeof this.options[a]?this.options[a]:this[a]};b.prototype.setOption=function(a,c){if(!(a in b.defaults))throw Error('No option with key "'+a+'"');switch(a){case "scrollback":if(c<this.rows){var d;d="Setting the scrollback value less than the number of rows "+("("+this.rows+") is not allowed.");
console.warn(d);return!1}if(this.options[a]!==c){if(this.buffer.lines.length>c){d=this.buffer.lines.length-c;var e=0>this.buffer.ydisp-d;this.buffer.lines.trimStart(d);this.buffer.ybase=Math.max(this.buffer.ybase-d,0);this.buffer.ydisp=Math.max(this.buffer.ydisp-d,0);e&&this.refresh(0,this.rows-1)}this.buffer.lines.maxLength=c;this.viewport.syncScrollArea()}}this[a]=c;this.options[a]=c;switch(a){case "cursorBlink":this.setCursorBlinking(c);break;case "cursorStyle":this.element.classList.toggle("xterm-cursor-style-block",
"block"===c);this.element.classList.toggle("xterm-cursor-style-underline","underline"===c);this.element.classList.toggle("xterm-cursor-style-bar","bar"===c);break;case "tabStopWidth":this.setupStops()}};b.prototype.restartCursorBlinking=function(){this.setCursorBlinking(this.options.cursorBlink)};b.prototype.setCursorBlinking=function(a){this.element.classList.toggle("xterm-cursor-blink",a);this.clearCursorBlinkingInterval();if(a){var b=this;this.cursorBlinkInterval=setInterval(function(){b.element.classList.toggle("xterm-cursor-blink-on")},
600)}};b.prototype.clearCursorBlinkingInterval=function(){this.element.classList.remove("xterm-cursor-blink-on");this.cursorBlinkInterval&&(clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=null)};b.bindFocus=function(a){i(a.textarea,"focus",function(){a.sendFocus&&a.send(g.C0.ESC+"[I");a.element.classList.add("focus");a.showCursor();a.restartCursorBlinking.apply(a);b.focus=a;a.emit("focus",{terminal:a})})};b.prototype.blur=function(){return this.textarea.blur()};b.bindBlur=function(a){i(a.textarea,
"blur",function(){a.refresh(a.buffer.y,a.buffer.y);a.sendFocus&&a.send(g.C0.ESC+"[O");a.element.classList.remove("focus");a.clearCursorBlinkingInterval.apply(a);b.focus=null;a.emit("blur",{terminal:a})})};b.prototype.initGlobal=function(){var a=this,c=this;b.bindKeys(this);b.bindFocus(this);b.bindBlur(this);i(this.element,"copy",function(b){c.hasSelection()&&u.copyHandler(b,c,a.selectionManager)});var d=function(a){return u.pasteHandler(a,c)};i(this.textarea,"paste",d);i(this.element,"paste",d);c.browser.isFirefox?
i(this.element,"mousedown",function(b){2==b.button&&u.rightClickHandler(b,a.textarea,a.selectionManager)}):i(this.element,"contextmenu",function(b){u.rightClickHandler(b,a.textarea,a.selectionManager)});c.browser.isLinux&&i(this.element,"auxclick",function(b){1===b.button&&u.moveTextAreaUnderMouseCursor(b,a.textarea,a.selectionManager)})};b.bindKeys=function(a){i(a.element,"keydown",function(b){q.activeElement==this&&a.keyDown(b)},!0);i(a.element,"keypress",function(b){q.activeElement==this&&a.keyPress(b)},
!0);i(a.element,"keyup",function(b){16===b.keyCode||17===b.keyCode||18===b.keyCode||a.focus(a)},!0);i(a.textarea,"keydown",function(b){a.keyDown(b)},!0);i(a.textarea,"keypress",function(b){a.keyPress(b);this.value=""},!0);i(a.textarea,"compositionstart",a.compositionHelper.compositionstart.bind(a.compositionHelper));i(a.textarea,"compositionupdate",a.compositionHelper.compositionupdate.bind(a.compositionHelper));i(a.textarea,"compositionend",a.compositionHelper.compositionend.bind(a.compositionHelper));
a.on("refresh",a.compositionHelper.updateCompositionElements.bind(a.compositionHelper));a.on("refresh",function(b){a.queueLinkification(b.start,b.end)})};b.prototype.insertRow=function(a){"object"!=typeof a&&(a=q.createElement("div"));this.rowContainer.appendChild(a);this.children.push(a);return a};b.prototype.open=function(a,b){var c=this,d=this,e=0;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.getElementsByTagName("body")[0];this.element=this.document.createElement("div");this.element.classList.add("terminal");this.element.classList.add("xterm");this.element.classList.add("xterm-theme-"+this.theme);this.element.classList.add("xterm-cursor-style-"+this.options.cursorStyle);this.setCursorBlinking(this.options.cursorBlink);this.element.setAttribute("tabindex",0);this.viewportElement=q.createElement("div");this.viewportElement.classList.add("xterm-viewport");
this.element.appendChild(this.viewportElement);this.viewportScrollArea=q.createElement("div");this.viewportScrollArea.classList.add("xterm-scroll-area");this.viewportElement.appendChild(this.viewportScrollArea);this.selectionContainer=q.createElement("div");this.selectionContainer.classList.add("xterm-selection");this.element.appendChild(this.selectionContainer);this.rowContainer=q.createElement("div");this.rowContainer.classList.add("xterm-rows");this.element.appendChild(this.rowContainer);this.children=
[];this.linkifier.attachToDom(q,this.children);this.helperContainer=q.createElement("div");this.helperContainer.classList.add("xterm-helpers");this.element.appendChild(this.helperContainer);this.textarea=q.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(){d.emit("focus",
{terminal:d})});this.textarea.addEventListener("blur",function(){d.emit("blur",{terminal:d})});this.helperContainer.appendChild(this.textarea);this.compositionView=q.createElement("div");this.compositionView.classList.add("composition-view");this.compositionHelper=new m.CompositionHelper(this.textarea,this.compositionView,this);this.helperContainer.appendChild(this.compositionView);this.charSizeStyleElement=q.createElement("style");for(this.helperContainer.appendChild(this.charSizeStyleElement);e<
this.rows;e++)this.insertRow();this.parent.appendChild(this.element);this.charMeasure=new w.CharMeasure(q,this.helperContainer);this.charMeasure.on("charsizechanged",function(){d.updateCharSizeStyles()});this.charMeasure.measure();this.viewport=new h.Viewport(this,this.viewportElement,this.viewportScrollArea,this.charMeasure);this.renderer=new p.Renderer(this);this.selectionManager=new v.SelectionManager(this,this.buffer.lines,this.rowContainer,this.charMeasure);this.selectionManager.on("refresh",
function(a){c.renderer.refreshSelection(a.start,a.end)});this.selectionManager.on("newselection",function(a){c.textarea.value=a;c.textarea.focus();c.textarea.select()});this.on("scroll",function(){return c.selectionManager.refresh()});this.viewportElement.addEventListener("scroll",function(){return c.selectionManager.refresh()});this.refresh(0,this.rows-1);this.initGlobal();"undefined"==typeof b&&(console.warn("You did not pass the `focus` argument in `Terminal.prototype.open()`.\nThe `focus` argument now defaults to `true` but starting with xterm.js 3.0 it will default to `false`."),
b=!0);b&&this.focus();this.bindMouse();this.emit("open")};b.loadAddon=function(a){if("object"===typeof e&&"object"===typeof n)return d("./addons/"+a+"/"+a);console.error("Cannot load a module without a CommonJS or RequireJS environment.");return!1};b.prototype.updateCharSizeStyles=function(){this.charSizeStyleElement.textContent=".xterm-wide-char{width:"+2*this.charMeasure.width+"px;}"+(".xterm-normal-char{width:"+this.charMeasure.width+"px;}")+(".xterm-rows > div{height:"+this.charMeasure.height+
"px;}")};b.prototype.bindMouse=function(){function a(b){var c,d,f,x;switch(b.overrideType||b.type){case "mousedown":c=null!=b.button?+b.button:null!=b.which?b.which-1:null;h.browser.isMSIE&&(c=1===c?0:4===c?1:c);break;case "mouseup":c=3;break;case "DOMMouseScroll":c=0>b.detail?64:65;break;case "wheel":c=0<b.wheelDeltaY?64:65}f=b.shiftKey?4:0;x=b.metaKey?8:0;d=b.ctrlKey?16:0;f=f|x|d;h.vt200Mouse?f&=d:h.normalMouse||(f=0);c=32+(f<<2)+c;if(d=t.getRawByteCoords(b,h.rowContainer,h.charMeasure,h.cols,h.rows))switch(e(c,
d),b.overrideType||b.type){case "mousedown":j=c;break;case "mouseup":j=32}}function b(a){var c=j;(a=t.getRawByteCoords(a,h.rowContainer,h.charMeasure,h.cols,h.rows))&&e(c+32,a)}function d(a,b){if(h.utfMouse){if(2047===b)return a.push(0);127>b?a.push(b):(2047<b&&(b=2047),a.push(192|b>>6),a.push(128|b&63))}else{if(255===b)return a.push(0);127<b&&(b=127);a.push(b)}}function e(a,b){if(h.vt300Mouse){a&=3;b.x-=32;b.y-=32;var c=g.C0.ESC+"[24";if(0===a)c+="1";else if(1===a)c+="3";else if(2===a)c+="5";else{if(3===
a)return;c+="0"}c+="~["+b.x+","+b.y+"]\r";h.send(c)}else h.decLocator?(a&=3,b.x-=32,b.y-=32,0===a?a=2:1===a?a=4:2===a?a=6:3===a&&(a=3),h.send(g.C0.ESC+"["+a+";"+(3===a?4:0)+";"+b.y+";"+b.x+";"+(b.page||0)+"&w")):h.urxvtMouse?(b.x-=32,b.y-=32,b.x++,b.y++,h.send(g.C0.ESC+"["+a+";"+b.x+";"+b.y+"M")):h.sgrMouse?(b.x-=32,b.y-=32,h.send(g.C0.ESC+"[<"+((3===(a&3)?a&-4:a)-32)+";"+b.x+";"+b.y+(3===(a&3)?"m":"M"))):(c=[],d(c,a),d(c,b.x),d(c,b.y),h.send(g.C0.ESC+"[M"+String.fromCharCode.apply(String,c)))}var f=
this.element,h=this,j=32;i(f,"mousedown",function(d){d.preventDefault();h.focus();if(h.mouseEvents){a(d);if(h.vt200Mouse)return d.overrideType="mouseup",a(d),h.cancel(d);h.normalMouse&&i(h.document,"mousemove",b);h.x10Mouse||i(h.document,"mouseup",function B(d){a(d);h.normalMouse&&c(h.document,"mousemove",b);c(h.document,"mouseup",B);return h.cancel(d)});return h.cancel(d)}});i(f,"wheel",function(b){if(h.mouseEvents&&!h.x10Mouse&&!h.vt300Mouse&&!h.decLocator)return a(b),h.cancel(b)});i(f,"wheel",
function(a){if(!h.mouseEvents)return h.viewport.onWheel(a),h.cancel(a)});i(f,"touchstart",function(a){if(!h.mouseEvents)return h.viewport.onTouchStart(a),h.cancel(a)});i(f,"touchmove",function(a){if(!h.mouseEvents)return h.viewport.onTouchMove(a),h.cancel(a)})};b.prototype.destroy=function(){this.writable=this.readable=!1;this._events={};this.handler=function(){};this.write=function(){};this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)};b.prototype.refresh=function(a,
b){this.renderer&&this.renderer.queueRefresh(a,b)};b.prototype.queueLinkification=function(a,b){if(this.linkifier)for(var c=a;c<=b;c++)this.linkifier.linkifyRow(c)};b.prototype.showCursor=function(){this.cursorState||(this.cursorState=1,this.refresh(this.buffer.y,this.buffer.y))};b.prototype.scroll=function(a){var b;this.buffer.lines.length===this.buffer.lines.maxLength&&(this.buffer.lines.trimStart(1),this.buffer.ybase--,0!==this.buffer.ydisp&&this.buffer.ydisp--);this.buffer.ybase++;this.userScrolling||
(this.buffer.ydisp=this.buffer.ybase);b=this.buffer.ybase+this.rows-1;b-=this.rows-1-this.buffer.scrollBottom;b===this.buffer.lines.length?this.buffer.lines.push(this.blankLine(void 0,a)):this.buffer.lines.splice(b,0,this.blankLine(void 0,a));0!==this.buffer.scrollTop&&(0!==this.buffer.ybase&&(this.buffer.ybase--,this.userScrolling||(this.buffer.ydisp=this.buffer.ybase)),this.buffer.lines.splice(this.buffer.ybase+this.buffer.scrollTop,1));this.updateRange(this.buffer.scrollTop);this.updateRange(this.buffer.scrollBottom);
this.emit("scroll",this.buffer.ydisp)};b.prototype.scrollDisp=function(a,b){if(0>a){if(0===this.buffer.ydisp)return;this.userScrolling=!0}else a+this.buffer.ydisp>=this.buffer.ybase&&(this.userScrolling=!1);var c=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+a,this.buffer.ybase),0);c!==this.buffer.ydisp&&(b||this.emit("scroll",this.buffer.ydisp),this.refresh(0,this.rows-1))};b.prototype.scrollPages=function(a){this.scrollDisp(a*(this.rows-1))};b.prototype.scrollToTop=function(){this.scrollDisp(-this.buffer.ydisp)};
b.prototype.scrollToBottom=function(){this.scrollDisp(this.buffer.ybase-this.buffer.ydisp)};b.prototype.write=function(a){this.writeBuffer.push(a);this.options.useFlowControl&&!this.xoffSentToCatchUp&&5<=this.writeBuffer.length&&(this.send(g.C0.DC3),this.xoffSentToCatchUp=!0);if(!this.writeInProgress&&0<this.writeBuffer.length){this.writeInProgress=!0;var b=this;setTimeout(function(){b.innerWrite()})}};b.prototype.innerWrite=function(){for(var a=this.writeBuffer.splice(0,300);0<a.length;){var b=a.shift();
this.xoffSentToCatchUp&&0===a.length&&0===this.writeBuffer.length&&(this.send(g.C0.DC1),this.xoffSentToCatchUp=!1);this.refreshEnd=this.refreshStart=this.buffer.y;this.parser.setState(this.parser.parse(b));this.updateRange(this.buffer.y);this.refresh(this.refreshStart,this.refreshEnd)}if(0<this.writeBuffer.length){var c=this;setTimeout(function(){c.innerWrite()},0)}else this.writeInProgress=!1};b.prototype.writeln=function(a){this.write(a+"\r\n")};b.prototype.attachCustomKeydownHandler=function(a){console.warn("attachCustomKeydownHandler() is DEPRECATED and will be removed soon. Please use attachCustomKeyEventHandler() instead.");
this.attachCustomKeyEventHandler(a)};b.prototype.attachCustomKeyEventHandler=function(a){this.customKeyEventHandler=a};b.prototype.setHypertextLinkHandler=function(a){if(!this.linkifier)throw Error("Cannot attach a hypertext link handler before Terminal.open is called");this.linkifier.setHypertextLinkHandler(a);this.refresh(0,this.rows-1)};b.prototype.setHypertextValidationCallback=function(a){if(!this.linkifier)throw Error("Cannot attach a hypertext validation callback before Terminal.open is called");
this.linkifier.setHypertextValidationCallback(a);this.refresh(0,this.rows-1)};b.prototype.registerLinkMatcher=function(a,b,c){if(this.linkifier)return a=this.linkifier.registerLinkMatcher(a,b,c),this.refresh(0,this.rows-1),a};b.prototype.deregisterLinkMatcher=function(a){this.linkifier&&this.linkifier.deregisterLinkMatcher(a)&&this.refresh(0,this.rows-1)};b.prototype.hasSelection=function(){return this.selectionManager?this.selectionManager.hasSelection:!1};b.prototype.getSelection=function(){return this.selectionManager?
this.selectionManager.selectionText:""};b.prototype.clearSelection=function(){this.selectionManager&&this.selectionManager.clearSelection()};b.prototype.selectAll=function(){this.selectionManager&&this.selectionManager.selectAll()};b.prototype.keyDown=function(a){if(this.customKeyEventHandler&&!1===this.customKeyEventHandler(a))return!1;this.restartCursorBlinking();if(!this.compositionHelper.keydown.bind(this.compositionHelper)(a))return this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),
!1;var b=this.evaluateKeyEscapeSequence(a);b.key===g.C0.DC3?this.writeStopped=!0:b.key===g.C0.DC1&&(this.writeStopped=!1);if(b.scrollDisp)return this.scrollDisp(b.scrollDisp),this.cancel(a,!0);if(k(this,a))return!0;b.cancel&&this.cancel(a,!0);if(!b.key)return!0;this.emit("keydown",a);this.emit("key",b.key,a);this.showCursor();this.handler(b.key);return this.cancel(a,!0)};b.prototype.evaluateKeyEscapeSequence=function(a){var b={cancel:!1,key:void 0,scrollDisp:void 0},c=a.shiftKey<<0|a.altKey<<1|a.ctrlKey<<
2|a.metaKey<<3;switch(a.keyCode){case 8:if(a.shiftKey){b.key=g.C0.BS;break}b.key=g.C0.DEL;break;case 9:if(a.shiftKey){b.key=g.C0.ESC+"[Z";break}b.key=g.C0.HT;b.cancel=!0;break;case 13:b.key=g.C0.CR;b.cancel=!0;break;case 27:b.key=g.C0.ESC;b.cancel=!0;break;case 37:c?(b.key=g.C0.ESC+"[1;"+(c+1)+"D",b.key==g.C0.ESC+"[1;3D"&&(b.key=this.browser.isMac?g.C0.ESC+"b":g.C0.ESC+"[1;5D")):b.key=this.applicationCursor?g.C0.ESC+"OD":g.C0.ESC+"[D";break;case 39:c?(b.key=g.C0.ESC+"[1;"+(c+1)+"C",b.key==g.C0.ESC+
"[1;3C"&&(b.key=this.browser.isMac?g.C0.ESC+"f":g.C0.ESC+"[1;5C")):b.key=this.applicationCursor?g.C0.ESC+"OC":g.C0.ESC+"[C";break;case 38:c?(b.key=g.C0.ESC+"[1;"+(c+1)+"A",b.key==g.C0.ESC+"[1;3A"&&(b.key=g.C0.ESC+"[1;5A")):b.key=this.applicationCursor?g.C0.ESC+"OA":g.C0.ESC+"[A";break;case 40:c?(b.key=g.C0.ESC+"[1;"+(c+1)+"B",b.key==g.C0.ESC+"[1;3B"&&(b.key=g.C0.ESC+"[1;5B")):b.key=this.applicationCursor?g.C0.ESC+"OB":g.C0.ESC+"[B";break;case 45:!a.shiftKey&&!a.ctrlKey&&(b.key=g.C0.ESC+"[2~");break;
case 46:b.key=c?g.C0.ESC+"[3;"+(c+1)+"~":g.C0.ESC+"[3~";break;case 36:b.key=c?g.C0.ESC+"[1;"+(c+1)+"H":this.applicationCursor?g.C0.ESC+"OH":g.C0.ESC+"[H";break;case 35:b.key=c?g.C0.ESC+"[1;"+(c+1)+"F":this.applicationCursor?g.C0.ESC+"OF":g.C0.ESC+"[F";break;case 33:a.shiftKey?b.scrollDisp=-(this.rows-1):b.key=g.C0.ESC+"[5~";break;case 34:a.shiftKey?b.scrollDisp=this.rows-1:b.key=g.C0.ESC+"[6~";break;case 112:b.key=c?g.C0.ESC+"[1;"+(c+1)+"P":g.C0.ESC+"OP";break;case 113:b.key=c?g.C0.ESC+"[1;"+(c+1)+
"Q":g.C0.ESC+"OQ";break;case 114:b.key=c?g.C0.ESC+"[1;"+(c+1)+"R":g.C0.ESC+"OR";break;case 115:b.key=c?g.C0.ESC+"[1;"+(c+1)+"S":g.C0.ESC+"OS";break;case 116:b.key=c?g.C0.ESC+"[15;"+(c+1)+"~":g.C0.ESC+"[15~";break;case 117:b.key=c?g.C0.ESC+"[17;"+(c+1)+"~":g.C0.ESC+"[17~";break;case 118:b.key=c?g.C0.ESC+"[18;"+(c+1)+"~":g.C0.ESC+"[18~";break;case 119:b.key=c?g.C0.ESC+"[19;"+(c+1)+"~":g.C0.ESC+"[19~";break;case 120:b.key=c?g.C0.ESC+"[20;"+(c+1)+"~":g.C0.ESC+"[20~";break;case 121:b.key=c?g.C0.ESC+"[21;"+
(c+1)+"~":g.C0.ESC+"[21~";break;case 122:b.key=c?g.C0.ESC+"[23;"+(c+1)+"~":g.C0.ESC+"[23~";break;case 123:b.key=c?g.C0.ESC+"[24;"+(c+1)+"~":g.C0.ESC+"[24~";break;default:a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey?65<=a.keyCode&&90>=a.keyCode?b.key=String.fromCharCode(a.keyCode-64):32===a.keyCode?b.key=String.fromCharCode(0):51<=a.keyCode&&55>=a.keyCode?b.key=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?b.key=String.fromCharCode(127):219===a.keyCode?b.key=String.fromCharCode(27):220===a.keyCode?
b.key=String.fromCharCode(28):221===a.keyCode&&(b.key=String.fromCharCode(29)):!this.browser.isMac&&a.altKey&&!a.ctrlKey&&!a.metaKey?65<=a.keyCode&&90>=a.keyCode?b.key=g.C0.ESC+String.fromCharCode(a.keyCode+32):192===a.keyCode?b.key=g.C0.ESC+"`":48<=a.keyCode&&57>=a.keyCode&&(b.key=g.C0.ESC+(a.keyCode-48)):this.browser.isMac&&!a.altKey&&!a.ctrlKey&&a.metaKey&&65===a.keyCode&&this.selectAll()}return b};b.prototype.setgLevel=function(a){this.glevel=a;this.charset=this.charsets[a]};b.prototype.setgCharset=
function(a,b){this.charsets[a]=b;this.glevel===a&&(this.charset=b)};b.prototype.keyPress=function(a){var b;if(this.customKeyEventHandler&&!1===this.customKeyEventHandler(a))return!1;this.cancel(a);if(a.charCode)b=a.charCode;else if(null==a.which)b=a.keyCode;else if(0!==a.which&&0!==a.charCode)b=a.which;else return!1;if(!b||(a.altKey||a.ctrlKey||a.metaKey)&&!k(this,a))return!1;b=String.fromCharCode(b);this.emit("keypress",b,a);this.emit("key",b,a);this.showCursor();this.handler(b);return!0};b.prototype.send=
function(a){var b=this;this.queue||setTimeout(function(){b.handler(b.queue);b.queue=""},1);this.queue+=a};b.prototype.bell=function(){if(this.visualBell){var a=this;this.element.style.borderColor="white";setTimeout(function(){a.element.style.borderColor=""},10);this.popOnBell&&this.focus()}};b.prototype.log=function(){this.debug&&this.context.console&&this.context.console.log&&this.context.console.log.apply(this.context.console,Array.prototype.slice.call(arguments))};b.prototype.error=function(){this.debug&&
this.context.console&&this.context.console.error&&this.context.console.error.apply(this.context.console,Array.prototype.slice.call(arguments))};b.prototype.resize=function(a,b){if(!isNaN(a)&&!isNaN(b)){b>this.getOption("scrollback")&&this.setOption("scrollback",b);var c;if(a===this.cols&&b===this.rows)(!this.charMeasure.width||!this.charMeasure.height)&&this.charMeasure.measure();else{1>a&&(a=1);1>b&&(b=1);for(this.buffers.resize(a,b);this.children.length<b;)this.insertRow();for(;this.children.length>
b;)(c=this.children.shift())&&c.parentNode.removeChild(c);this.cols=a;this.rows=b;this.setupStops(this.cols);this.charMeasure.measure();this.refresh(0,this.rows-1);this.geometry=[this.cols,this.rows];this.emit("resize",{terminal:this,cols:a,rows:b})}}};b.prototype.updateRange=function(a){a<this.refreshStart&&(this.refreshStart=a);a>this.refreshEnd&&(this.refreshEnd=a)};b.prototype.maxRange=function(){this.refreshStart=0;this.refreshEnd=this.rows-1};b.prototype.setupStops=function(a){null!=a?this.buffer.tabs[a]||
(a=this.prevStop(a)):(this.buffer.tabs={},a=0);for(;a<this.cols;a+=this.getOption("tabStopWidth"))this.buffer.tabs[a]=!0};b.prototype.prevStop=function(a){null==a&&(a=this.buffer.x);for(;!this.buffer.tabs[--a]&&0<a;);return a>=this.cols?this.cols-1:0>a?0:a};b.prototype.nextStop=function(a){null==a&&(a=this.buffer.x);for(;!this.buffer.tabs[++a]&&a<this.cols;);return a>=this.cols?this.cols-1:0>a?0:a};b.prototype.eraseRight=function(a,b){var c=this.buffer.lines.get(this.buffer.ybase+b);if(c){for(var d=
[this.eraseAttr()," ",1];a<this.cols;a++)c[a]=d;this.updateRange(b)}};b.prototype.eraseLeft=function(a,b){var c=this.buffer.lines.get(this.buffer.ybase+b);if(c){var d=[this.eraseAttr()," ",1];for(a++;a--;)c[a]=d;this.updateRange(b)}};b.prototype.clear=function(){if(!(0===this.buffer.ybase&&0===this.buffer.y)){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y));this.buffer.lines.length=1;this.buffer.ydisp=0;this.buffer.ybase=0;this.buffer.y=0;for(var a=1;a<this.rows;a++)this.buffer.lines.push(this.blankLine());
this.refresh(0,this.rows-1);this.emit("scroll",this.buffer.ydisp)}};b.prototype.eraseLine=function(a){this.eraseRight(0,a)};b.prototype.blankLine=function(a,b,c){var a=[a?this.eraseAttr():this.defAttr," ",1],d=[],e=0;b&&(d.isWrapped=b);for(c=c||this.cols;e<c;e++)d[e]=a;return d};b.prototype.ch=function(a){return a?[this.eraseAttr()," ",1]:[this.defAttr," ",1]};b.prototype.is=function(a){return 0===(this.termName+"").indexOf(a)};b.prototype.handler=function(a){this.options.disableStdin||(this.selectionManager&&
this.selectionManager.hasSelection&&this.selectionManager.clearSelection(),this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),this.emit("data",a))};b.prototype.handleTitle=function(a){this.emit("title",a)};b.prototype.index=function(){this.buffer.y++;this.buffer.y>this.buffer.scrollBottom&&(this.buffer.y--,this.scroll());this.buffer.x>=this.cols&&this.buffer.x--};b.prototype.reverseIndex=function(){this.buffer.y===this.buffer.scrollTop?(this.buffer.lines.shiftElements(this.buffer.y+this.buffer.ybase,
this.rows-1,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--};b.prototype.reset=function(){this.options.rows=this.rows;this.options.cols=this.cols;var a=this.customKeyEventHandler,c=this.cursorBlinkInterval,d=this.inputHandler;b.call(this,this.options);this.customKeyEventHandler=a;this.cursorBlinkInterval=c;this.inputHandler=d;this.refresh(0,this.rows-1);this.viewport.syncScrollArea()};
b.prototype.tabSet=function(){this.buffer.tabs[this.buffer.x]=!0};b.prototype.matchColor=l;l._cache={};l.distance=function(a,b,c,d,e,f){return Math.pow(30*(a-d),2)+Math.pow(59*(b-e),2)+Math.pow(11*(c-f),2)};b.translateBufferLineToString=r.translateBufferLineToString;b.EventEmitter=j.EventEmitter;b.inherits=a;b.on=i;b.off=c;b.cancel=function(a,b){if(this.cancelEvents||b)return a.preventDefault(),a.stopPropagation(),!1};n.exports=b},{"./BufferSet":2,"./CompositionHelper":4,"./EscapeSequences":5,"./EventEmitter":6,
"./InputHandler":7,"./Linkifier":8,"./Parser":9,"./Renderer":10,"./SelectionManager":11,"./Viewport":13,"./handlers/Clipboard":14,"./utils/Browser":15,"./utils/BufferLine":16,"./utils/CharMeasure":17,"./utils/Mouse":21}]},{},[22])(22)});
