]> prime8.dev >> repos - ttyd.git/commitdiff
protocol: use binary message
authorShuanglei Tao <tsl0922@gmail.com>
Thu, 23 Nov 2017 14:01:22 +0000 (22:01 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sat, 25 Nov 2017 14:53:44 +0000 (22:53 +0800)
html/css/app.css
html/index.html
html/js/app.js
html/js/utf8.js [deleted file]
src/index.html
src/protocol.c
src/server.c
src/server.h

index fd2e5f712ff1465ba933765521ca6d58379905f0..c93c2842b8148c43da0a46dc8f8d56102a346a88 100644 (file)
@@ -17,7 +17,7 @@ html, body {
     background-color: #101010;
     color: #f0f0f0;
     font-size: 10pt;
-    font-family: Menlo,Consolas,"DejaVu Sans Mono","Liberation Mono",Courier,monospace;
+    font-family: "Menlo for Powerline", Menlo,Consolas,"DejaVu Sans Mono","Liberation Mono",Courier,monospace;
     font-variant-ligatures: none;
     -moz-osx-font-smoothing: grayscale;
     -webkit-font-smoothing: antialiased;
index d252eaf23699fcf61d3bfec9c3791184c99dd6dc..f67c919021028dd53f9e0692104616c92ae0e600 100644 (file)
@@ -9,7 +9,6 @@
     <link inline href="css/app.css">
     <script inline src="node_modules/xterm/dist/xterm.js"></script>
     <script inline src="node_modules/xterm/dist/addons/fit/fit.js"></script>
-    <script inline src="js/utf8.js"></script>
     <script inline src="js/overlay.js"></script>
 </head>
 <body>
index 47a732ce8bef2c0fce049424f6dd1e720108ec6d..da2509247ba28409748e75319481d2b205cf75f7 100644 (file)
@@ -8,18 +8,30 @@
         term, pingTimer, wsError;
 
     var openWs = function() {
-        var ws = new WebSocket(url, protocols);
+        var ws = new WebSocket(url, protocols),
+            textDecoder = new TextDecoder(),
+            textEncoder = new TextEncoder();
         var unloadCallback = function(event) {
             var message = 'Close terminal? this will also terminate the command.';
             (event || window.event).returnValue = message;
             return message;
         };
+        var sendMessage = function (msg) {
+            if (ws.readyState === WebSocket.OPEN) {
+                ws.send(textEncoder.encode(msg));
+            }
+        };
+        var sendPing = function() {
+            sendMessage("1");
+        };
+
+        ws.binaryType = 'arraybuffer';
 
-        ws.onopen = function(event) {
+        ws.onopen = function() {
             console.log("Websocket connection opened");
             wsError = false;
-            ws.send(JSON.stringify({AuthToken: authToken}));
-            pingTimer = setInterval(sendPing, 30 * 1000, ws);
+            sendMessage(JSON.stringify({AuthToken: authToken}));
+            pingTimer = setInterval(sendPing, 30 * 1000);
 
             if (typeof term !== 'undefined') {
                 term.destroy();
             term = new Terminal();
 
             term.on('resize', function(size) {
-                if (ws.readyState === WebSocket.OPEN) {
-                    ws.send("2" + JSON.stringify({columns: size.cols, rows: size.rows}));
-                }
+                sendMessage("2" + JSON.stringify({columns: size.cols, rows: size.rows}));
                 setTimeout(function() {
                     term.showOverlay(size.cols + 'x' + size.rows);
                 }, 500);
             });
 
             term.on("data", function(data) {
-                if (ws.readyState === WebSocket.OPEN) {
-                    ws.send("0" + data);
-                }
+                sendMessage("0" + data);
             });
 
             term.on('open', function() {
         };
 
         ws.onmessage = function(event) {
-            var data = event.data.slice(1);
-            switch(event.data[0]) {
+            var cmd = String.fromCharCode(new DataView(event.data).getUint8()),
+                data = textDecoder.decode(event.data.slice(1));
+            switch(cmd) {
                 case '0':
-                    term.writeUTF8(window.atob(data));
+                    term.write(data);
                     break;
                 case '1': // pong
                     break;
         };
     };
 
-    var sendPing = function(ws) {
-        ws.send("1");
-    };
-
     openWs();
 })();
\ No newline at end of file
diff --git a/html/js/utf8.js b/html/js/utf8.js
deleted file mode 100644 (file)
index 5a10144..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-// ported from hterm.Terminal.IO.prototype.writeUTF8
-// https://chromium.googlesource.com/apps/libapps/+/master/hterm/js/hterm_terminal_io.js
-
-UTF8Decoder = function() {
-    this.bytesLeft = 0;
-    this.codePoint = 0;
-    this.lowerBound = 0;
-};
-
-UTF8Decoder.prototype.decode = function(str) {
-    var ret = '';
-    for (var i = 0; i < str.length; i++) {
-        var c = str.charCodeAt(i);
-        if (this.bytesLeft == 0) {
-            if (c <= 0x7F) {
-                ret += str.charAt(i);
-            } else if (0xC0 <= c && c <= 0xDF) {
-                this.codePoint = c - 0xC0;
-                this.bytesLeft = 1;
-                this.lowerBound = 0x80;
-            } else if (0xE0 <= c && c <= 0xEF) {
-                this.codePoint = c - 0xE0;
-                this.bytesLeft = 2;
-                this.lowerBound = 0x800;
-            } else if (0xF0 <= c && c <= 0xF7) {
-                this.codePoint = c - 0xF0;
-                this.bytesLeft = 3;
-                this.lowerBound = 0x10000;
-            } else if (0xF8 <= c && c <= 0xFB) {
-                this.codePoint = c - 0xF8;
-                this.bytesLeft = 4;
-                this.lowerBound = 0x200000;
-            } else if (0xFC <= c && c <= 0xFD) {
-                this.codePoint = c - 0xFC;
-                this.bytesLeft = 5;
-                this.lowerBound = 0x4000000;
-            } else {
-                ret += '\ufffd';
-            }
-        } else {
-            if (0x80 <= c && c <= 0xBF) {
-                this.bytesLeft--;
-                this.codePoint = (this.codePoint << 6) + (c - 0x80);
-                if (this.bytesLeft == 0) {
-                    var codePoint = this.codePoint;
-                    if (codePoint < this.lowerBound
-                        || (0xD800 <= codePoint && codePoint <= 0xDFFF)
-                        || codePoint > 0x10FFFF) {
-                        ret += '\ufffd';
-                    } else {
-                        if (codePoint < 0x10000) {
-                            ret += String.fromCharCode(codePoint);
-                        } else {
-                            codePoint -= 0x10000;
-                            ret += String.fromCharCode(
-                                0xD800 + ((codePoint >>> 10) & 0x3FF),
-                                0xDC00 + (codePoint & 0x3FF));
-                        }
-                    }
-                }
-            } else {
-                ret += '\ufffd';
-                this.bytesLeft = 0;
-                i--;
-            }
-        }
-    }
-    return ret;
-};
-
-Terminal.prototype.decodeUTF8 = function(str) {
-    return (new UTF8Decoder()).decode(str);
-};
-
-Terminal.prototype.encodeUTF8 = function(str) {
-    var ret = '';
-    for (var i = 0; i < str.length; i++) {
-        var c = str.charCodeAt(i);
-        if (0xDC00 <= c && c <= 0xDFFF) {
-            c = 0xFFFD;
-        } else if (0xD800 <= c && c <= 0xDBFF) {
-            if (i+1 < str.length) {
-                var d = str.charCodeAt(i+1);
-                if (0xDC00 <= d && d <= 0xDFFF) {
-                    c = 0x10000 + ((c & 0x3FF) << 10) + (d & 0x3FF);
-                    i++;
-                } else {
-                    c = 0xFFFD;
-                }
-            } else {
-                c = 0xFFFD;
-            }
-        }
-        var bytesLeft;
-        if (c <= 0x7F) {
-            ret += str.charAt(i);
-            continue;
-        } else if (c <= 0x7FF) {
-            ret += String.fromCharCode(0xC0 | (c >>> 6));
-            bytesLeft = 1;
-        } else if (c <= 0xFFFF) {
-            ret += String.fromCharCode(0xE0 | (c >>> 12));
-            bytesLeft = 2;
-        } else {
-            ret += String.fromCharCode(0xF0 | (c >>> 18));
-            bytesLeft = 3;
-        }
-        while (bytesLeft > 0) {
-            bytesLeft--;
-            ret += String.fromCharCode(0x80 | ((c >>> (6 * bytesLeft)) & 0x3F));
-        }
-    }
-    return ret;
-};
-
-Terminal.prototype.writeUTF8 = function (str) {
-    this.write(this.decodeUTF8(str));
-};
index d6152869b74b7dbbf59c718e18439057610d13a9..56abdd5e24fe69998094b7962581bfe463edebc9 100644 (file)
@@ -6,18 +6,17 @@
     <title>ttyd - Terminal</title>
     <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAcCAYAAAAAwr0iAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA0xpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDY3IDc5LjE1Nzc0NywgMjAxNS8wMy8zMC0yMzo0MDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OTgyRjc1RjA3MTZEMTFFNjg2M0NCOEY3RjJBMEY3N0EiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OTgyRjc1RUY3MTZEMTFFNjg2M0NCOEY3RjJBMEY3N0EiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTUgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjU3YmQxNjhjLWI5ZDctMTE3OS1hM2RlLWZmNjQyYTM4NTJmMCIgc3RSZWY6ZG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjU3YmQxNjhjLWI5ZDctMTE3OS1hM2RlLWZmNjQyYTM4NTJmMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PhsssMYAAALDSURBVHjaxFa9jxJBFH8zDMdCYrhIAppgIjaG5C5RQ+zO2Gty5gpbY2KsbOyu1MrGGEtj/A9stLPXs6CjJ5GYIF6AE5IDBHZmfG92F4ZzvQAnyyO7O8zX+73f+5gRd3bvvSgffN4/l948YgASFhQ9aWhqM6+pYfrVjD5WH9NK8f7x8ebNnVtvWC6b/RaPxy8zxsxmbB5lIfNsIDMggreezqG1o9GIGj8E45zFNzYgnU4D5xyUUkBglpFAKfgWa5gFY89rNVvgJJMgSBkpjcViIISA4XAI4/EYkBXTdyYQ9LOUU9sw7bmG2lqgPwwAKSV9D/P5/G2csNtoNJ71+32HFjqOszyQkDY9xLbrjkEorSe+wYGc67o72Wz2dSqV+tjr9e4iiAfdbnfL+G4B10wtDV/nBSYAN5O053eivVqtvq1UKr/RDaVCofCyVCo9ogXE0qISppgsJ3GlCzzGkQHcOEgT8n2xWLyfy+XeDwaDK7Va7Xm73X4YUHaaRfMwcbIPdTNBGWBSwkP3Ewdr9Xr9FcbAUwpICkyKAXuTRdkIAxH4QThOEn61W2YSKruAVpeJiUQiYRQjqHImk9nDjDiPijnO+d7pdN5hXOwRuGXdYRggANIdM9sy2tTeGPsuNpvNJwgkRVUMpYPdV5dJURsIZZ9WBEB6aRhKkeeWSzi2j9kxk8vLFqsABFkvlWSYhoqdni6zY2dRfHJfYoErvxBFLb5expVUDFlYCwDpM8CU0pEDoADUGH9YCf8dgKuQSRagXoo/Lg0Da3CBVwm9syBKBv46FfHNIlc+BYFZQHe0yBnQPgN0HFtV8H8VmXko8ABgEOo1uIDZMbCWALRiQAR/gkvpqsU+Rcl4gW9zR6JLCXXQ5XTVAKR/sqIvGODl89BnJfLHcRJNceP6tQ9fDr4+RmRHmAUqoiLEkOnM1vb2pz8CDACUMgcHE3VMqAAAAABJRU5ErkJggg==" />
     <style>.terminal{background-color:#000;color:#fff;font-family:courier-new,courier,monospace;font-feature-settings:"liga" 0;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.terminal.focus,.terminal:focus{outline:none}.terminal .xterm-helpers{position:absolute;top:0}.terminal .xterm-helper-textarea{position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-10;white-space:nowrap;overflow:hidden;resize:none}.terminal a{color:inherit;text-decoration:none}.terminal a:hover{cursor:pointer;text-decoration:underline}.terminal a.xterm-invalid-link:hover{cursor:text;text-decoration:none}.terminal .terminal-cursor{position:relative}.terminal:not(.focus) .terminal-cursor{outline:1px solid #fff;outline-offset:-1px}.terminal.xterm-cursor-style-block.focus:not(.xterm-cursor-blink-on) .terminal-cursor{background-color:#fff;color:#000}.terminal.focus.xterm-cursor-style-bar:not(.xterm-cursor-blink-on) .terminal-cursor::before,.terminal.focus.xterm-cursor-style-underline:not(.xterm-cursor-blink-on) .terminal-cursor::before{content:'';position:absolute;background-color:#fff}.terminal.focus.xterm-cursor-style-bar:not(.xterm-cursor-blink-on) .terminal-cursor::before{top:0;left:0;bottom:0;width:1px}.terminal.focus.xterm-cursor-style-underline:not(.xterm-cursor-blink-on) .terminal-cursor::before{bottom:0;left:0;right:0;height:1px}.terminal .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.terminal .composition-view.active{display:block}.terminal .xterm-viewport{background-color:#000;overflow-y:scroll}.terminal .xterm-normal-char,.terminal .xterm-wide-char{display:inline-block}.terminal .xterm-rows{position:absolute;left:0;top:0}.terminal .xterm-rows>div{white-space:nowrap}.terminal .xterm-scroll-area{visibility:hidden}.terminal .xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;left:-9999em}.terminal.enable-mouse-events{cursor:default}.terminal .xterm-selection{position:absolute;top:0;left:0;z-index:1;opacity:.3;pointer-events:none}.terminal .xterm-selection div{position:absolute;background-color:#fff}.terminal .xterm-bold{font-weight:700}.terminal .xterm-underline{text-decoration:underline}.terminal .xterm-blink{text-decoration:blink}.terminal .xterm-blink.xterm-underline{text-decoration:blink underline}.terminal .xterm-hidden{visibility:hidden}.terminal .xterm-color-0{color:#2e3436}.terminal .xterm-bg-color-0{background-color:#2e3436}.terminal .xterm-color-1{color:#c00}.terminal .xterm-bg-color-1{background-color:#c00}.terminal .xterm-color-2{color:#4e9a06}.terminal .xterm-bg-color-2{background-color:#4e9a06}.terminal .xterm-color-3{color:#c4a000}.terminal .xterm-bg-color-3{background-color:#c4a000}.terminal .xterm-color-4{color:#3465a4}.terminal .xterm-bg-color-4{background-color:#3465a4}.terminal .xterm-color-5{color:#75507b}.terminal .xterm-bg-color-5{background-color:#75507b}.terminal .xterm-color-6{color:#06989a}.terminal .xterm-bg-color-6{background-color:#06989a}.terminal .xterm-color-7{color:#d3d7cf}.terminal .xterm-bg-color-7{background-color:#d3d7cf}.terminal .xterm-color-8{color:#555753}.terminal .xterm-bg-color-8{background-color:#555753}.terminal .xterm-color-9{color:#ef2929}.terminal .xterm-bg-color-9{background-color:#ef2929}.terminal .xterm-color-10{color:#8ae234}.terminal .xterm-bg-color-10{background-color:#8ae234}.terminal .xterm-color-11{color:#fce94f}.terminal .xterm-bg-color-11{background-color:#fce94f}.terminal .xterm-color-12{color:#729fcf}.terminal .xterm-bg-color-12{background-color:#729fcf}.terminal .xterm-color-13{color:#ad7fa8}.terminal .xterm-bg-color-13{background-color:#ad7fa8}.terminal .xterm-color-14{color:#34e2e2}.terminal .xterm-bg-color-14{background-color:#34e2e2}.terminal .xterm-color-15{color:#eeeeec}.terminal .xterm-bg-color-15{background-color:#eeeeec}.terminal .xterm-color-16{color:#000}.terminal .xterm-bg-color-16{background-color:#000}.terminal .xterm-color-17{color:#00005f}.terminal .xterm-bg-color-17{background-color:#00005f}.terminal .xterm-color-18{color:#000087}.terminal .xterm-bg-color-18{background-color:#000087}.terminal .xterm-color-19{color:#0000af}.terminal .xterm-bg-color-19{background-color:#0000af}.terminal .xterm-color-20{color:#0000d7}.terminal .xterm-bg-color-20{background-color:#0000d7}.terminal .xterm-color-21{color:#00f}.terminal .xterm-bg-color-21{background-color:#00f}.terminal .xterm-color-22{color:#005f00}.terminal .xterm-bg-color-22{background-color:#005f00}.terminal .xterm-color-23{color:#005f5f}.terminal .xterm-bg-color-23{background-color:#005f5f}.terminal .xterm-color-24{color:#005f87}.terminal .xterm-bg-color-24{background-color:#005f87}.terminal .xterm-color-25{color:#005faf}.terminal .xterm-bg-color-25{background-color:#005faf}.terminal .xterm-color-26{color:#005fd7}.terminal .xterm-bg-color-26{background-color:#005fd7}.terminal .xterm-color-27{color:#005fff}.terminal .xterm-bg-color-27{background-color:#005fff}.terminal .xterm-color-28{color:#008700}.terminal .xterm-bg-color-28{background-color:#008700}.terminal .xterm-color-29{color:#00875f}.terminal .xterm-bg-color-29{background-color:#00875f}.terminal .xterm-color-30{color:#008787}.terminal .xterm-bg-color-30{background-color:#008787}.terminal .xterm-color-31{color:#0087af}.terminal .xterm-bg-color-31{background-color:#0087af}.terminal .xterm-color-32{color:#0087d7}.terminal .xterm-bg-color-32{background-color:#0087d7}.terminal .xterm-color-33{color:#0087ff}.terminal .xterm-bg-color-33{background-color:#0087ff}.terminal .xterm-color-34{color:#00af00}.terminal .xterm-bg-color-34{background-color:#00af00}.terminal .xterm-color-35{color:#00af5f}.terminal .xterm-bg-color-35{background-color:#00af5f}.terminal .xterm-color-36{color:#00af87}.terminal .xterm-bg-color-36{background-color:#00af87}.terminal .xterm-color-37{color:#00afaf}.terminal .xterm-bg-color-37{background-color:#00afaf}.terminal .xterm-color-38{color:#00afd7}.terminal .xterm-bg-color-38{background-color:#00afd7}.terminal .xterm-color-39{color:#00afff}.terminal .xterm-bg-color-39{background-color:#00afff}.terminal .xterm-color-40{color:#00d700}.terminal .xterm-bg-color-40{background-color:#00d700}.terminal .xterm-color-41{color:#00d75f}.terminal .xterm-bg-color-41{background-color:#00d75f}.terminal .xterm-color-42{color:#00d787}.terminal .xterm-bg-color-42{background-color:#00d787}.terminal .xterm-color-43{color:#00d7af}.terminal .xterm-bg-color-43{background-color:#00d7af}.terminal .xterm-color-44{color:#00d7d7}.terminal .xterm-bg-color-44{background-color:#00d7d7}.terminal .xterm-color-45{color:#00d7ff}.terminal .xterm-bg-color-45{background-color:#00d7ff}.terminal .xterm-color-46{color:#0f0}.terminal .xterm-bg-color-46{background-color:#0f0}.terminal .xterm-color-47{color:#00ff5f}.terminal .xterm-bg-color-47{background-color:#00ff5f}.terminal .xterm-color-48{color:#00ff87}.terminal .xterm-bg-color-48{background-color:#00ff87}.terminal .xterm-color-49{color:#00ffaf}.terminal .xterm-bg-color-49{background-color:#00ffaf}.terminal .xterm-color-50{color:#00ffd7}.terminal .xterm-bg-color-50{background-color:#00ffd7}.terminal .xterm-color-51{color:#0ff}.terminal .xterm-bg-color-51{background-color:#0ff}.terminal .xterm-color-52{color:#5f0000}.terminal .xterm-bg-color-52{background-color:#5f0000}.terminal .xterm-color-53{color:#5f005f}.terminal .xterm-bg-color-53{background-color:#5f005f}.terminal .xterm-color-54{color:#5f0087}.terminal .xterm-bg-color-54{background-color:#5f0087}.terminal .xterm-color-55{color:#5f00af}.terminal .xterm-bg-color-55{background-color:#5f00af}.terminal .xterm-color-56{color:#5f00d7}.terminal .xterm-bg-color-56{background-color:#5f00d7}.terminal .xterm-color-57{color:#5f00ff}.terminal .xterm-bg-color-57{background-color:#5f00ff}.terminal .xterm-color-58{color:#5f5f00}.terminal .xterm-bg-color-58{background-color:#5f5f00}.terminal .xterm-color-59{color:#5f5f5f}.terminal .xterm-bg-color-59{background-color:#5f5f5f}.terminal .xterm-color-60{color:#5f5f87}.terminal .xterm-bg-color-60{background-color:#5f5f87}.terminal .xterm-color-61{color:#5f5faf}.terminal .xterm-bg-color-61{background-color:#5f5faf}.terminal .xterm-color-62{color:#5f5fd7}.terminal .xterm-bg-color-62{background-color:#5f5fd7}.terminal .xterm-color-63{color:#5f5fff}.terminal .xterm-bg-color-63{background-color:#5f5fff}.terminal .xterm-color-64{color:#5f8700}.terminal .xterm-bg-color-64{background-color:#5f8700}.terminal .xterm-color-65{color:#5f875f}.terminal .xterm-bg-color-65{background-color:#5f875f}.terminal .xterm-color-66{color:#5f8787}.terminal .xterm-bg-color-66{background-color:#5f8787}.terminal .xterm-color-67{color:#5f87af}.terminal .xterm-bg-color-67{background-color:#5f87af}.terminal .xterm-color-68{color:#5f87d7}.terminal .xterm-bg-color-68{background-color:#5f87d7}.terminal .xterm-color-69{color:#5f87ff}.terminal .xterm-bg-color-69{background-color:#5f87ff}.terminal .xterm-color-70{color:#5faf00}.terminal .xterm-bg-color-70{background-color:#5faf00}.terminal .xterm-color-71{color:#5faf5f}.terminal .xterm-bg-color-71{background-color:#5faf5f}.terminal .xterm-color-72{color:#5faf87}.terminal .xterm-bg-color-72{background-color:#5faf87}.terminal .xterm-color-73{color:#5fafaf}.terminal .xterm-bg-color-73{background-color:#5fafaf}.terminal .xterm-color-74{color:#5fafd7}.terminal .xterm-bg-color-74{background-color:#5fafd7}.terminal .xterm-color-75{color:#5fafff}.terminal .xterm-bg-color-75{background-color:#5fafff}.terminal .xterm-color-76{color:#5fd700}.terminal .xterm-bg-color-76{background-color:#5fd700}.terminal .xterm-color-77{color:#5fd75f}.terminal .xterm-bg-color-77{background-color:#5fd75f}.terminal .xterm-color-78{color:#5fd787}.terminal .xterm-bg-color-78{background-color:#5fd787}.terminal .xterm-color-79{color:#5fd7af}.terminal .xterm-bg-color-79{background-color:#5fd7af}.terminal .xterm-color-80{color:#5fd7d7}.terminal .xterm-bg-color-80{background-color:#5fd7d7}.terminal .xterm-color-81{color:#5fd7ff}.terminal .xterm-bg-color-81{background-color:#5fd7ff}.terminal .xterm-color-82{color:#5fff00}.terminal .xterm-bg-color-82{background-color:#5fff00}.terminal .xterm-color-83{color:#5fff5f}.terminal .xterm-bg-color-83{background-color:#5fff5f}.terminal .xterm-color-84{color:#5fff87}.terminal .xterm-bg-color-84{background-color:#5fff87}.terminal .xterm-color-85{color:#5fffaf}.terminal .xterm-bg-color-85{background-color:#5fffaf}.terminal .xterm-color-86{color:#5fffd7}.terminal .xterm-bg-color-86{background-color:#5fffd7}.terminal .xterm-color-87{color:#5fffff}.terminal .xterm-bg-color-87{background-color:#5fffff}.terminal .xterm-color-88{color:#870000}.terminal .xterm-bg-color-88{background-color:#870000}.terminal .xterm-color-89{color:#87005f}.terminal .xterm-bg-color-89{background-color:#87005f}.terminal .xterm-color-90{color:#870087}.terminal .xterm-bg-color-90{background-color:#870087}.terminal .xterm-color-91{color:#8700af}.terminal .xterm-bg-color-91{background-color:#8700af}.terminal .xterm-color-92{color:#8700d7}.terminal .xterm-bg-color-92{background-color:#8700d7}.terminal .xterm-color-93{color:#8700ff}.terminal .xterm-bg-color-93{background-color:#8700ff}.terminal .xterm-color-94{color:#875f00}.terminal .xterm-bg-color-94{background-color:#875f00}.terminal .xterm-color-95{color:#875f5f}.terminal .xterm-bg-color-95{background-color:#875f5f}.terminal .xterm-color-96{color:#875f87}.terminal .xterm-bg-color-96{background-color:#875f87}.terminal .xterm-color-97{color:#875faf}.terminal .xterm-bg-color-97{background-color:#875faf}.terminal .xterm-color-98{color:#875fd7}.terminal .xterm-bg-color-98{background-color:#875fd7}.terminal .xterm-color-99{color:#875fff}.terminal .xterm-bg-color-99{background-color:#875fff}.terminal .xterm-color-100{color:#878700}.terminal .xterm-bg-color-100{background-color:#878700}.terminal .xterm-color-101{color:#87875f}.terminal .xterm-bg-color-101{background-color:#87875f}.terminal .xterm-color-102{color:#878787}.terminal .xterm-bg-color-102{background-color:#878787}.terminal .xterm-color-103{color:#8787af}.terminal .xterm-bg-color-103{background-color:#8787af}.terminal .xterm-color-104{color:#8787d7}.terminal .xterm-bg-color-104{background-color:#8787d7}.terminal .xterm-color-105{color:#8787ff}.terminal .xterm-bg-color-105{background-color:#8787ff}.terminal .xterm-color-106{color:#87af00}.terminal .xterm-bg-color-106{background-color:#87af00}.terminal .xterm-color-107{color:#87af5f}.terminal .xterm-bg-color-107{background-color:#87af5f}.terminal .xterm-color-108{color:#87af87}.terminal .xterm-bg-color-108{background-color:#87af87}.terminal .xterm-color-109{color:#87afaf}.terminal .xterm-bg-color-109{background-color:#87afaf}.terminal .xterm-color-110{color:#87afd7}.terminal .xterm-bg-color-110{background-color:#87afd7}.terminal .xterm-color-111{color:#87afff}.terminal .xterm-bg-color-111{background-color:#87afff}.terminal .xterm-color-112{color:#87d700}.terminal .xterm-bg-color-112{background-color:#87d700}.terminal .xterm-color-113{color:#87d75f}.terminal .xterm-bg-color-113{background-color:#87d75f}.terminal .xterm-color-114{color:#87d787}.terminal .xterm-bg-color-114{background-color:#87d787}.terminal .xterm-color-115{color:#87d7af}.terminal .xterm-bg-color-115{background-color:#87d7af}.terminal .xterm-color-116{color:#87d7d7}.terminal .xterm-bg-color-116{background-color:#87d7d7}.terminal .xterm-color-117{color:#87d7ff}.terminal .xterm-bg-color-117{background-color:#87d7ff}.terminal .xterm-color-118{color:#87ff00}.terminal .xterm-bg-color-118{background-color:#87ff00}.terminal .xterm-color-119{color:#87ff5f}.terminal .xterm-bg-color-119{background-color:#87ff5f}.terminal .xterm-color-120{color:#87ff87}.terminal .xterm-bg-color-120{background-color:#87ff87}.terminal .xterm-color-121{color:#87ffaf}.terminal .xterm-bg-color-121{background-color:#87ffaf}.terminal .xterm-color-122{color:#87ffd7}.terminal .xterm-bg-color-122{background-color:#87ffd7}.terminal .xterm-color-123{color:#87ffff}.terminal .xterm-bg-color-123{background-color:#87ffff}.terminal .xterm-color-124{color:#af0000}.terminal .xterm-bg-color-124{background-color:#af0000}.terminal .xterm-color-125{color:#af005f}.terminal .xterm-bg-color-125{background-color:#af005f}.terminal .xterm-color-126{color:#af0087}.terminal .xterm-bg-color-126{background-color:#af0087}.terminal .xterm-color-127{color:#af00af}.terminal .xterm-bg-color-127{background-color:#af00af}.terminal .xterm-color-128{color:#af00d7}.terminal .xterm-bg-color-128{background-color:#af00d7}.terminal .xterm-color-129{color:#af00ff}.terminal .xterm-bg-color-129{background-color:#af00ff}.terminal .xterm-color-130{color:#af5f00}.terminal .xterm-bg-color-130{background-color:#af5f00}.terminal .xterm-color-131{color:#af5f5f}.terminal .xterm-bg-color-131{background-color:#af5f5f}.terminal .xterm-color-132{color:#af5f87}.terminal .xterm-bg-color-132{background-color:#af5f87}.terminal .xterm-color-133{color:#af5faf}.terminal .xterm-bg-color-133{background-color:#af5faf}.terminal .xterm-color-134{color:#af5fd7}.terminal .xterm-bg-color-134{background-color:#af5fd7}.terminal .xterm-color-135{color:#af5fff}.terminal .xterm-bg-color-135{background-color:#af5fff}.terminal .xterm-color-136{color:#af8700}.terminal .xterm-bg-color-136{background-color:#af8700}.terminal .xterm-color-137{color:#af875f}.terminal .xterm-bg-color-137{background-color:#af875f}.terminal .xterm-color-138{color:#af8787}.terminal .xterm-bg-color-138{background-color:#af8787}.terminal .xterm-color-139{color:#af87af}.terminal .xterm-bg-color-139{background-color:#af87af}.terminal .xterm-color-140{color:#af87d7}.terminal .xterm-bg-color-140{background-color:#af87d7}.terminal .xterm-color-141{color:#af87ff}.terminal .xterm-bg-color-141{background-color:#af87ff}.terminal .xterm-color-142{color:#afaf00}.terminal .xterm-bg-color-142{background-color:#afaf00}.terminal .xterm-color-143{color:#afaf5f}.terminal .xterm-bg-color-143{background-color:#afaf5f}.terminal .xterm-color-144{color:#afaf87}.terminal .xterm-bg-color-144{background-color:#afaf87}.terminal .xterm-color-145{color:#afafaf}.terminal .xterm-bg-color-145{background-color:#afafaf}.terminal .xterm-color-146{color:#afafd7}.terminal .xterm-bg-color-146{background-color:#afafd7}.terminal .xterm-color-147{color:#afafff}.terminal .xterm-bg-color-147{background-color:#afafff}.terminal .xterm-color-148{color:#afd700}.terminal .xterm-bg-color-148{background-color:#afd700}.terminal .xterm-color-149{color:#afd75f}.terminal .xterm-bg-color-149{background-color:#afd75f}.terminal .xterm-color-150{color:#afd787}.terminal .xterm-bg-color-150{background-color:#afd787}.terminal .xterm-color-151{color:#afd7af}.terminal .xterm-bg-color-151{background-color:#afd7af}.terminal .xterm-color-152{color:#afd7d7}.terminal .xterm-bg-color-152{background-color:#afd7d7}.terminal .xterm-color-153{color:#afd7ff}.terminal .xterm-bg-color-153{background-color:#afd7ff}.terminal .xterm-color-154{color:#afff00}.terminal .xterm-bg-color-154{background-color:#afff00}.terminal .xterm-color-155{color:#afff5f}.terminal .xterm-bg-color-155{background-color:#afff5f}.terminal .xterm-color-156{color:#afff87}.terminal .xterm-bg-color-156{background-color:#afff87}.terminal .xterm-color-157{color:#afffaf}.terminal .xterm-bg-color-157{background-color:#afffaf}.terminal .xterm-color-158{color:#afffd7}.terminal .xterm-bg-color-158{background-color:#afffd7}.terminal .xterm-color-159{color:#afffff}.terminal .xterm-bg-color-159{background-color:#afffff}.terminal .xterm-color-160{color:#d70000}.terminal .xterm-bg-color-160{background-color:#d70000}.terminal .xterm-color-161{color:#d7005f}.terminal .xterm-bg-color-161{background-color:#d7005f}.terminal .xterm-color-162{color:#d70087}.terminal .xterm-bg-color-162{background-color:#d70087}.terminal .xterm-color-163{color:#d700af}.terminal .xterm-bg-color-163{background-color:#d700af}.terminal .xterm-color-164{color:#d700d7}.terminal .xterm-bg-color-164{background-color:#d700d7}.terminal .xterm-color-165{color:#d700ff}.terminal .xterm-bg-color-165{background-color:#d700ff}.terminal .xterm-color-166{color:#d75f00}.terminal .xterm-bg-color-166{background-color:#d75f00}.terminal .xterm-color-167{color:#d75f5f}.terminal .xterm-bg-color-167{background-color:#d75f5f}.terminal .xterm-color-168{color:#d75f87}.terminal .xterm-bg-color-168{background-color:#d75f87}.terminal .xterm-color-169{color:#d75faf}.terminal .xterm-bg-color-169{background-color:#d75faf}.terminal .xterm-color-170{color:#d75fd7}.terminal .xterm-bg-color-170{background-color:#d75fd7}.terminal .xterm-color-171{color:#d75fff}.terminal .xterm-bg-color-171{background-color:#d75fff}.terminal .xterm-color-172{color:#d78700}.terminal .xterm-bg-color-172{background-color:#d78700}.terminal .xterm-color-173{color:#d7875f}.terminal .xterm-bg-color-173{background-color:#d7875f}.terminal .xterm-color-174{color:#d78787}.terminal .xterm-bg-color-174{background-color:#d78787}.terminal .xterm-color-175{color:#d787af}.terminal .xterm-bg-color-175{background-color:#d787af}.terminal .xterm-color-176{color:#d787d7}.terminal .xterm-bg-color-176{background-color:#d787d7}.terminal .xterm-color-177{color:#d787ff}.terminal .xterm-bg-color-177{background-color:#d787ff}.terminal .xterm-color-178{color:#d7af00}.terminal .xterm-bg-color-178{background-color:#d7af00}.terminal .xterm-color-179{color:#d7af5f}.terminal .xterm-bg-color-179{background-color:#d7af5f}.terminal .xterm-color-180{color:#d7af87}.terminal .xterm-bg-color-180{background-color:#d7af87}.terminal .xterm-color-181{color:#d7afaf}.terminal .xterm-bg-color-181{background-color:#d7afaf}.terminal .xterm-color-182{color:#d7afd7}.terminal .xterm-bg-color-182{background-color:#d7afd7}.terminal .xterm-color-183{color:#d7afff}.terminal .xterm-bg-color-183{background-color:#d7afff}.terminal .xterm-color-184{color:#d7d700}.terminal .xterm-bg-color-184{background-color:#d7d700}.terminal .xterm-color-185{color:#d7d75f}.terminal .xterm-bg-color-185{background-color:#d7d75f}.terminal .xterm-color-186{color:#d7d787}.terminal .xterm-bg-color-186{background-color:#d7d787}.terminal .xterm-color-187{color:#d7d7af}.terminal .xterm-bg-color-187{background-color:#d7d7af}.terminal .xterm-color-188{color:#d7d7d7}.terminal .xterm-bg-color-188{background-color:#d7d7d7}.terminal .xterm-color-189{color:#d7d7ff}.terminal .xterm-bg-color-189{background-color:#d7d7ff}.terminal .xterm-color-190{color:#d7ff00}.terminal .xterm-bg-color-190{background-color:#d7ff00}.terminal .xterm-color-191{color:#d7ff5f}.terminal .xterm-bg-color-191{background-color:#d7ff5f}.terminal .xterm-color-192{color:#d7ff87}.terminal .xterm-bg-color-192{background-color:#d7ff87}.terminal .xterm-color-193{color:#d7ffaf}.terminal .xterm-bg-color-193{background-color:#d7ffaf}.terminal .xterm-color-194{color:#d7ffd7}.terminal .xterm-bg-color-194{background-color:#d7ffd7}.terminal .xterm-color-195{color:#d7ffff}.terminal .xterm-bg-color-195{background-color:#d7ffff}.terminal .xterm-color-196{color:red}.terminal .xterm-bg-color-196{background-color:red}.terminal .xterm-color-197{color:#ff005f}.terminal .xterm-bg-color-197{background-color:#ff005f}.terminal .xterm-color-198{color:#ff0087}.terminal .xterm-bg-color-198{background-color:#ff0087}.terminal .xterm-color-199{color:#ff00af}.terminal .xterm-bg-color-199{background-color:#ff00af}.terminal .xterm-color-200{color:#ff00d7}.terminal .xterm-bg-color-200{background-color:#ff00d7}.terminal .xterm-color-201{color:#f0f}.terminal .xterm-bg-color-201{background-color:#f0f}.terminal .xterm-color-202{color:#ff5f00}.terminal .xterm-bg-color-202{background-color:#ff5f00}.terminal .xterm-color-203{color:#ff5f5f}.terminal .xterm-bg-color-203{background-color:#ff5f5f}.terminal .xterm-color-204{color:#ff5f87}.terminal .xterm-bg-color-204{background-color:#ff5f87}.terminal .xterm-color-205{color:#ff5faf}.terminal .xterm-bg-color-205{background-color:#ff5faf}.terminal .xterm-color-206{color:#ff5fd7}.terminal .xterm-bg-color-206{background-color:#ff5fd7}.terminal .xterm-color-207{color:#ff5fff}.terminal .xterm-bg-color-207{background-color:#ff5fff}.terminal .xterm-color-208{color:#ff8700}.terminal .xterm-bg-color-208{background-color:#ff8700}.terminal .xterm-color-209{color:#ff875f}.terminal .xterm-bg-color-209{background-color:#ff875f}.terminal .xterm-color-210{color:#ff8787}.terminal .xterm-bg-color-210{background-color:#ff8787}.terminal .xterm-color-211{color:#ff87af}.terminal .xterm-bg-color-211{background-color:#ff87af}.terminal .xterm-color-212{color:#ff87d7}.terminal .xterm-bg-color-212{background-color:#ff87d7}.terminal .xterm-color-213{color:#ff87ff}.terminal .xterm-bg-color-213{background-color:#ff87ff}.terminal .xterm-color-214{color:#ffaf00}.terminal .xterm-bg-color-214{background-color:#ffaf00}.terminal .xterm-color-215{color:#ffaf5f}.terminal .xterm-bg-color-215{background-color:#ffaf5f}.terminal .xterm-color-216{color:#ffaf87}.terminal .xterm-bg-color-216{background-color:#ffaf87}.terminal .xterm-color-217{color:#ffafaf}.terminal .xterm-bg-color-217{background-color:#ffafaf}.terminal .xterm-color-218{color:#ffafd7}.terminal .xterm-bg-color-218{background-color:#ffafd7}.terminal .xterm-color-219{color:#ffafff}.terminal .xterm-bg-color-219{background-color:#ffafff}.terminal .xterm-color-220{color:gold}.terminal .xterm-bg-color-220{background-color:gold}.terminal .xterm-color-221{color:#ffd75f}.terminal .xterm-bg-color-221{background-color:#ffd75f}.terminal .xterm-color-222{color:#ffd787}.terminal .xterm-bg-color-222{background-color:#ffd787}.terminal .xterm-color-223{color:#ffd7af}.terminal .xterm-bg-color-223{background-color:#ffd7af}.terminal .xterm-color-224{color:#ffd7d7}.terminal .xterm-bg-color-224{background-color:#ffd7d7}.terminal .xterm-color-225{color:#ffd7ff}.terminal .xterm-bg-color-225{background-color:#ffd7ff}.terminal .xterm-color-226{color:#ff0}.terminal .xterm-bg-color-226{background-color:#ff0}.terminal .xterm-color-227{color:#ffff5f}.terminal .xterm-bg-color-227{background-color:#ffff5f}.terminal .xterm-color-228{color:#ffff87}.terminal .xterm-bg-color-228{background-color:#ffff87}.terminal .xterm-color-229{color:#ffffaf}.terminal .xterm-bg-color-229{background-color:#ffffaf}.terminal .xterm-color-230{color:#ffffd7}.terminal .xterm-bg-color-230{background-color:#ffffd7}.terminal .xterm-color-231{color:#fff}.terminal .xterm-bg-color-231{background-color:#fff}.terminal .xterm-color-232{color:#080808}.terminal .xterm-bg-color-232{background-color:#080808}.terminal .xterm-color-233{color:#121212}.terminal .xterm-bg-color-233{background-color:#121212}.terminal .xterm-color-234{color:#1c1c1c}.terminal .xterm-bg-color-234{background-color:#1c1c1c}.terminal .xterm-color-235{color:#262626}.terminal .xterm-bg-color-235{background-color:#262626}.terminal .xterm-color-236{color:#303030}.terminal .xterm-bg-color-236{background-color:#303030}.terminal .xterm-color-237{color:#3a3a3a}.terminal .xterm-bg-color-237{background-color:#3a3a3a}.terminal .xterm-color-238{color:#444}.terminal .xterm-bg-color-238{background-color:#444}.terminal .xterm-color-239{color:#4e4e4e}.terminal .xterm-bg-color-239{background-color:#4e4e4e}.terminal .xterm-color-240{color:#585858}.terminal .xterm-bg-color-240{background-color:#585858}.terminal .xterm-color-241{color:#626262}.terminal .xterm-bg-color-241{background-color:#626262}.terminal .xterm-color-242{color:#6c6c6c}.terminal .xterm-bg-color-242{background-color:#6c6c6c}.terminal .xterm-color-243{color:#767676}.terminal .xterm-bg-color-243{background-color:#767676}.terminal .xterm-color-244{color:gray}.terminal .xterm-bg-color-244{background-color:gray}.terminal .xterm-color-245{color:#8a8a8a}.terminal .xterm-bg-color-245{background-color:#8a8a8a}.terminal .xterm-color-246{color:#949494}.terminal .xterm-bg-color-246{background-color:#949494}.terminal .xterm-color-247{color:#9e9e9e}.terminal .xterm-bg-color-247{background-color:#9e9e9e}.terminal .xterm-color-248{color:#a8a8a8}.terminal .xterm-bg-color-248{background-color:#a8a8a8}.terminal .xterm-color-249{color:#b2b2b2}.terminal .xterm-bg-color-249{background-color:#b2b2b2}.terminal .xterm-color-250{color:#bcbcbc}.terminal .xterm-bg-color-250{background-color:#bcbcbc}.terminal .xterm-color-251{color:#c6c6c6}.terminal .xterm-bg-color-251{background-color:#c6c6c6}.terminal .xterm-color-252{color:#d0d0d0}.terminal .xterm-bg-color-252{background-color:#d0d0d0}.terminal .xterm-color-253{color:#dadada}.terminal .xterm-bg-color-253{background-color:#dadada}.terminal .xterm-color-254{color:#e4e4e4}.terminal .xterm-bg-color-254{background-color:#e4e4e4}.terminal .xterm-color-255{color:#eee}.terminal .xterm-bg-color-255{background-color:#eee}</style>
-    <style>body,html{height:100%;min-height:100%;margin:0;overflow:hidden}#terminal-container{width:auto;height:100%;margin:0 auto;padding:0 5px;background-color:#101010}.terminal{background-color:#101010;color:#f0f0f0;font-size:10pt;font-family:Menlo,Consolas,"DejaVu Sans Mono","Liberation Mono",Courier,monospace;font-variant-ligatures:none;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.terminal .xterm-viewport{background-color:rgba(121,121,121,0);-webkit-background-clip:text;-webkit-text-fill-color:transparent;transition:background-color 800ms linear}.terminal .xterm-viewport::-webkit-scrollbar{width:10px}.terminal .xterm-viewport::-webkit-scrollbar-track{opacity:0}.terminal .xterm-viewport::-webkit-scrollbar-thumb{background-color:rgba(121,121,121,.4)}.terminal .xterm-viewport::-webkit-scrollbar-thumb:hover{transition:opacity 0ms linear;background-color:rgba(100,100,100,.7)}.terminal .xterm-viewport::-webkit-scrollbar-thumb:window-inactive{background-color:inherit}.terminal .terminal-cursor{background-color:#f0f0f0;color:#101010;opacity:.7}.terminal:not(.focus) .terminal-cursor{outline:1px solid #f0f0f0}@keyframes blink-cursor{0%{background-color:#f0f0f0;color:#101010}50%{background-color:transparent;color:#f0f0f0}}</style>
+    <style>body,html{height:100%;min-height:100%;margin:0;overflow:hidden}#terminal-container{width:auto;height:100%;margin:0 auto;padding:0 5px;background-color:#101010}.terminal{background-color:#101010;color:#f0f0f0;font-size:10pt;font-family:"Menlo for Powerline",Menlo,Consolas,"DejaVu Sans Mono","Liberation Mono",Courier,monospace;font-variant-ligatures:none;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.terminal .xterm-viewport{background-color:rgba(121,121,121,0);-webkit-background-clip:text;-webkit-text-fill-color:transparent;transition:background-color 800ms linear}.terminal .xterm-viewport::-webkit-scrollbar{width:10px}.terminal .xterm-viewport::-webkit-scrollbar-track{opacity:0}.terminal .xterm-viewport::-webkit-scrollbar-thumb{background-color:rgba(121,121,121,.4)}.terminal .xterm-viewport::-webkit-scrollbar-thumb:hover{transition:opacity 0ms linear;background-color:rgba(100,100,100,.7)}.terminal .xterm-viewport::-webkit-scrollbar-thumb:window-inactive{background-color:inherit}.terminal .terminal-cursor{background-color:#f0f0f0;color:#101010;opacity:.7}.terminal:not(.focus) .terminal-cursor{outline:1px solid #f0f0f0}@keyframes blink-cursor{0%{background-color:#f0f0f0;color:#101010}50%{background-color:transparent;color:#f0f0f0}}</style>
     <script>!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Terminal=e()}}(function(){var e;return function e(t,i,r){function s(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(n)return n(o,!0);var h=new Error("Cannot find module '"+o+"'");throw h.code="MODULE_NOT_FOUND",h}var c=i[o]={exports:{}};t[o][0].call(c.exports,function(e){var i=t[o][1][e];return s(i?i:e)},c,c.exports,e,t,i,r)}return i[o].exports}for(var n="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=e("./utils/CircularList"),s=function(){function e(e){this._terminal=e,this.clear()}return Object.defineProperty(e.prototype,"lines",{get:function(){return this._lines},enumerable:!0,configurable:!0}),e.prototype.fillViewportRows=function(){if(0===this._lines.length)for(var e=this._terminal.rows;e--;)this.lines.push(this._terminal.blankLine())},e.prototype.clear=function(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.scrollBottom=0,this.scrollTop=0,this.tabs={},this._lines=new r.CircularList(this._terminal.scrollback),this.scrollBottom=this._terminal.rows-1},e.prototype.resize=function(e,t){if(0!==this._lines.length){if(this._terminal.cols<e)for(var i=[this._terminal.defAttr," ",1],r=0;r<this._lines.length;r++)for(void 0===this._lines.get(r)&&this._lines.set(r,this._terminal.blankLine(void 0,void 0,e));this._lines.get(r).length<e;)this._lines.get(r).push(i);var s=0;if(this._terminal.rows<t)for(var n=this._terminal.rows;n<t;n++)this._lines.length<t+this.ybase&&(this.ybase>0&&this._lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this._lines.push(this._terminal.blankLine(void 0,void 0,e)));else for(var n=this._terminal.rows;n>t;n--)this._lines.length>t+this.ybase&&(this._lines.length>this.ybase+this.y+1?this._lines.pop():(this.ybase++,this.ydisp++));this.y>=t&&(this.y=t-1),s&&(this.y+=s),this.x>=e&&(this.x=e-1),this.scrollTop=0,this.scrollBottom=t-1}},e}();i.Buffer=s},{"./utils/CircularList":18}],2:[function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();Object.defineProperty(i,"__esModule",{value:!0});var s=e("./Buffer"),n=e("./EventEmitter"),o=function(e){function t(t){var i=e.call(this)||this;return i._terminal=t,i._normal=new s.Buffer(i._terminal),i._normal.fillViewportRows(),i._alt=new s.Buffer(i._terminal),i._activeBuffer=i._normal,i}return r(t,e),Object.defineProperty(t.prototype,"alt",{get:function(){return this._alt},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},enumerable:!0,configurable:!0}),t.prototype.activateNormalBuffer=function(){this._alt.clear(),this._activeBuffer=this._normal,this.emit("activate",this._normal)},t.prototype.activateAltBuffer=function(){this._alt.fillViewportRows(),this._activeBuffer=this._alt,this.emit("activate",this._alt)},t.prototype.resize=function(e,t){this._normal.resize(e,t),this._alt.resize(e,t)},t}(n.EventEmitter);i.BufferSet=o},{"./Buffer":1,"./EventEmitter":6}],3:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"\t",c:"\f",d:"\r",e:"\n",f:"°",g:"±",h:"␤",i:"\v",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=null,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},{}],4:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t,i){this.textarea=e,this.compositionView=t,this.terminal=i,this.isComposing=!1,this.isSendingComposition=!1,this.compositionPosition={start:null,end:null}}return e.prototype.compositionstart=function(){this.isComposing=!0,this.compositionPosition.start=this.textarea.value.length,this.compositionView.textContent="",this.compositionView.classList.add("active")},e.prototype.compositionupdate=function(e){var t=this;this.compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(function(){t.compositionPosition.end=t.textarea.value.length},0)},e.prototype.compositionend=function(){this.finalizeComposition(!0)},e.prototype.keydown=function(e){if(this.isComposing||this.isSendingComposition){if(229===e.keyCode)return!1;if(16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this.finalizeComposition(!1)}return 229!==e.keyCode||(this.handleAnyTextareaChanges(),!1)},e.prototype.finalizeComposition=function(e){var t=this;if(this.compositionView.classList.remove("active"),this.isComposing=!1,this.clearTextareaPosition(),e){var i={start:this.compositionPosition.start,end:this.compositionPosition.end};this.isSendingComposition=!0,setTimeout(function(){if(t.isSendingComposition){t.isSendingComposition=!1;var e=void 0;e=t.isComposing?t.textarea.value.substring(i.start,i.end):t.textarea.value.substring(i.start),t.terminal.handler(e)}},0)}else{this.isSendingComposition=!1;var r=this.textarea.value.substring(this.compositionPosition.start,this.compositionPosition.end);this.terminal.handler(r)}},e.prototype.handleAnyTextareaChanges=function(){var e=this,t=this.textarea.value;setTimeout(function(){if(!e.isComposing){var i=e.textarea.value,r=i.replace(t,"");r.length>0&&e.terminal.handler(r)}},0)},e.prototype.updateCompositionElements=function(e){var t=this;if(this.isComposing){var i=this.terminal.element.querySelector(".terminal-cursor");if(i){var r=this.terminal.element.querySelector(".xterm-rows"),s=r.offsetTop+i.offsetTop;this.compositionView.style.left=i.offsetLeft+"px",this.compositionView.style.top=s+"px",this.compositionView.style.height=i.offsetHeight+"px",this.compositionView.style.lineHeight=i.offsetHeight+"px";var n=this.compositionView.getBoundingClientRect();this.textarea.style.left=i.offsetLeft+"px",this.textarea.style.top=s+"px",this.textarea.style.width=n.width+"px",this.textarea.style.height=n.height+"px",this.textarea.style.lineHeight=n.height+"px"}e||setTimeout(function(){return t.updateCompositionElements(!0)},0)}},e.prototype.clearTextareaPosition=function(){this.textarea.style.left="",this.textarea.style.top=""},e}();i.CompositionHelper=r},{}],5:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r;!function(e){e.NUL="\0",e.SOH="\ 1",e.STX="\ 2",e.ETX="\ 3",e.EOT="\ 4",e.ENQ="\ 5",e.ACK="\ 6",e.BEL="\a",e.BS="\b",e.HT="\t",e.LF="\n",e.VT="\v",e.FF="\f",e.CR="\r",e.SO="\ e",e.SI="\ f",e.DLE="\10",e.DC1="\11",e.DC2="\12",e.DC3="\13",e.DC4="\14",e.NAK="\15",e.SYN="\16",e.ETB="\17",e.CAN="\18",e.EM="\19",e.SUB="\1a",e.ESC="\e",e.FS="\1c",e.GS="\1d",e.RS="\1e",e.US="\1f",e.SP=" ",e.DEL="\7f"}(r=i.C0||(i.C0={}))},{}],6:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(){this._events=this._events||{}}return e.prototype.on=function(e,t){this._events[e]=this._events[e]||[],this._events[e].push(t)},e.prototype.off=function(e,t){if(this._events[e])for(var i=this._events[e],r=i.length;r--;)if(i[r]===t||i[r].listener===t)return void i.splice(r,1)},e.prototype.removeAllListeners=function(e){this._events[e]&&delete this._events[e]},e.prototype.once=function(e,t){function i(){var r=Array.prototype.slice.call(arguments);return this.off(e,i),t.apply(this,r)}return i.listener=t,this.on(e,i)},e.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(this._events[e])for(var r=this._events[e],s=0;s<r.length;s++)r[s].apply(this,t)},e.prototype.listeners=function(e){return this._events[e]||[]},e}();i.EventEmitter=r},{}],7:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=e("./EscapeSequences"),s=e("./Charsets"),n=function(){function e(e){this._terminal=e}return e.prototype.addChar=function(e,t){if(e>=" "){var r=i.wcwidth(t);this._terminal.charset&&this._terminal.charset[e]&&(e=this._terminal.charset[e]);var s=this._terminal.buffer.y+this._terminal.buffer.ybase;if(!r&&this._terminal.buffer.x)return void(this._terminal.buffer.lines.get(s)[this._terminal.buffer.x-1]&&(this._terminal.buffer.lines.get(s)[this._terminal.buffer.x-1][2]?this._terminal.buffer.lines.get(s)[this._terminal.buffer.x-1][1]+=e:this._terminal.buffer.lines.get(s)[this._terminal.buffer.x-2]&&(this._terminal.buffer.lines.get(s)[this._terminal.buffer.x-2][1]+=e),this._terminal.updateRange(this._terminal.buffer.y)));if(this._terminal.buffer.x+r-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===r)return;if(s=this._terminal.buffer.y+this._terminal.buffer.ybase,this._terminal.insertMode)for(var n=0;n<r;++n){var o=this._terminal.buffer.lines.get(this._terminal.buffer.y+this._terminal.buffer.ybase).pop();0===o[2]&&this._terminal.buffer.lines.get(s)[this._terminal.cols-2]&&2===this._terminal.buffer.lines.get(s)[this._terminal.cols-2][2]&&(this._terminal.buffer.lines.get(s)[this._terminal.cols-2]=[this._terminal.curAttr," ",1]),this._terminal.buffer.lines.get(s).splice(this._terminal.buffer.x,0,[this._terminal.curAttr," ",1])}this._terminal.buffer.lines.get(s)[this._terminal.buffer.x]=[this._terminal.curAttr,e,r],this._terminal.buffer.x++,this._terminal.updateRange(this._terminal.buffer.y),2===r&&(this._terminal.buffer.lines.get(s)[this._terminal.buffer.x]=[this._terminal.curAttr,"",0],this._terminal.buffer.x++)}},e.prototype.bell=function(){var e=this;this._terminal.visualBell&&(this._terminal.element.style.borderColor="white",setTimeout(function(){return e._terminal.element.style.borderColor=""},10),this._terminal.popOnBell&&this._terminal.focus())},e.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")},e.prototype.carriageReturn=function(){this._terminal.buffer.x=0},e.prototype.backspace=function(){this._terminal.buffer.x>0&&this._terminal.buffer.x--},e.prototype.tab=function(){this._terminal.buffer.x=this._terminal.nextStop()},e.prototype.shiftOut=function(){this._terminal.setgLevel(1)},e.prototype.shiftIn=function(){this._terminal.setgLevel(0)},e.prototype.insertChars=function(e){var t,i,r,s;for(t=e[0],t<1&&(t=1),i=this._terminal.buffer.y+this._terminal.buffer.ybase,r=this._terminal.buffer.x,s=[this._terminal.eraseAttr()," ",1];t--&&r<this._terminal.cols;)this._terminal.buffer.lines.get(i).splice(r++,0,s),this._terminal.buffer.lines.get(i).pop()},e.prototype.cursorUp=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y-=t,this._terminal.buffer.y<0&&(this._terminal.buffer.y=0)},e.prototype.cursorDown=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y+=t,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--},e.prototype.cursorForward=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x+=t,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.cursorBackward=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x>=this._terminal.cols&&this._terminal.buffer.x--,this._terminal.buffer.x-=t,this._terminal.buffer.x<0&&(this._terminal.buffer.x=0)},e.prototype.cursorNextLine=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y+=t,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x=0},e.prototype.cursorPrecedingLine=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y-=t,this._terminal.buffer.y<0&&(this._terminal.buffer.y=0),this._terminal.buffer.x=0},e.prototype.cursorCharAbsolute=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x=t-1},e.prototype.cursorPosition=function(e){var t,i;t=e[0]-1,i=e.length>=2?e[1]-1:0,t<0?t=0:t>=this._terminal.rows&&(t=this._terminal.rows-1),i<0?i=0:i>=this._terminal.cols&&(i=this._terminal.cols-1),this._terminal.buffer.x=i,this._terminal.buffer.y=t},e.prototype.cursorForwardTab=function(e){for(var t=e[0]||1;t--;)this._terminal.buffer.x=this._terminal.nextStop()},e.prototype.eraseInDisplay=function(e){var t;switch(e[0]){case 0:for(this._terminal.eraseRight(this._terminal.buffer.x,this._terminal.buffer.y),t=this._terminal.buffer.y+1;t<this._terminal.rows;t++)this._terminal.eraseLine(t);break;case 1:for(this._terminal.eraseLeft(this._terminal.buffer.x,this._terminal.buffer.y),t=this._terminal.buffer.y;t--;)this._terminal.eraseLine(t);break;case 2:for(t=this._terminal.rows;t--;)this._terminal.eraseLine(t);break;case 3:var i=this._terminal.buffer.lines.length-this._terminal.rows;i>0&&(this._terminal.buffer.lines.trimStart(i),this._terminal.buffer.ybase=Math.max(this._terminal.buffer.ybase-i,0),this._terminal.buffer.ydisp=Math.max(this._terminal.buffer.ydisp-i,0),this._terminal.emit("scroll",0))}},e.prototype.eraseInLine=function(e){switch(e[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)}},e.prototype.insertLines=function(e){var t,i,r;for(t=e[0],t<1&&(t=1),i=this._terminal.buffer.y+this._terminal.buffer.ybase,r=this._terminal.rows-1-this._terminal.buffer.scrollBottom,r=this._terminal.rows-1+this._terminal.buffer.ybase-r+1;t--;)this._terminal.buffer.lines.length===this._terminal.buffer.lines.maxLength&&(this._terminal.buffer.lines.trimStart(1),this._terminal.buffer.ybase--,this._terminal.buffer.ydisp--,i--,r--),this._terminal.buffer.lines.splice(i,0,this._terminal.blankLine(!0)),this._terminal.buffer.lines.splice(r,1);this._terminal.updateRange(this._terminal.buffer.y),this._terminal.updateRange(this._terminal.buffer.scrollBottom)},e.prototype.deleteLines=function(e){var t,i,r;for(t=e[0],t<1&&(t=1),i=this._terminal.buffer.y+this._terminal.buffer.ybase,r=this._terminal.rows-1-this._terminal.buffer.scrollBottom,r=this._terminal.rows-1+this._terminal.buffer.ybase-r;t--;)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(r+1,0,this._terminal.blankLine(!0)),this._terminal.buffer.lines.splice(i,1);this._terminal.updateRange(this._terminal.buffer.y),this._terminal.updateRange(this._terminal.buffer.scrollBottom)},e.prototype.deleteChars=function(e){var t,i,r;for(t=e[0],t<1&&(t=1),i=this._terminal.buffer.y+this._terminal.buffer.ybase,r=[this._terminal.eraseAttr()," ",1];t--;)this._terminal.buffer.lines.get(i).splice(this._terminal.buffer.x,1),this._terminal.buffer.lines.get(i).push(r)},e.prototype.scrollUp=function(e){for(var t=e[0]||1;t--;)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)},e.prototype.scrollDown=function(e){for(var t=e[0]||1;t--;)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)},e.prototype.eraseChars=function(e){var t,i,r,s;for(t=e[0],t<1&&(t=1),i=this._terminal.buffer.y+this._terminal.buffer.ybase,r=this._terminal.buffer.x,s=[this._terminal.eraseAttr()," ",1];t--&&r<this._terminal.cols;)this._terminal.buffer.lines.get(i)[r++]=s},e.prototype.cursorBackwardTab=function(e){for(var t=e[0]||1;t--;)this._terminal.buffer.x=this._terminal.prevStop()},e.prototype.charPosAbsolute=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x=t-1,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.HPositionRelative=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.x+=t,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.repeatPrecedingCharacter=function(e){for(var t=e[0]||1,i=this._terminal.buffer.lines.get(this._terminal.buffer.ybase+this._terminal.buffer.y),r=i[this._terminal.buffer.x-1]||[this._terminal.defAttr," ",1];t--;)i[this._terminal.buffer.x++]=r},e.prototype.sendDeviceAttributes=function(e){e[0]>0||(this._terminal.prefix?">"===this._terminal.prefix&&(this._terminal.is("xterm")?this._terminal.send(r.C0.ESC+"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._terminal.send(r.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._terminal.send(e[0]+"c"):this._terminal.is("screen")&&this._terminal.send(r.C0.ESC+"[>83;40003;0c")):this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._terminal.send(r.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._terminal.send(r.C0.ESC+"[?6c"))},e.prototype.linePosAbsolute=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y=t-1,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1)},e.prototype.VPositionRelative=function(e){var t=e[0];t<1&&(t=1),this._terminal.buffer.y+=t,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--},e.prototype.HVPosition=function(e){e[0]<1&&(e[0]=1),e[1]<1&&(e[1]=1),this._terminal.buffer.y=e[0]-1,this._terminal.buffer.y>=this._terminal.rows&&(this._terminal.buffer.y=this._terminal.rows-1),this._terminal.buffer.x=e[1]-1,this._terminal.buffer.x>=this._terminal.cols&&(this._terminal.buffer.x=this._terminal.cols-1)},e.prototype.tabClear=function(e){var t=e[0];t<=0?delete this._terminal.buffer.tabs[this._terminal.buffer.x]:3===t&&(this._terminal.buffer.tabs={})},e.prototype.setMode=function(e){if(e.length>1)for(var t=0;t<e.length;t++)this.setMode([e[t]]);else if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(e[0]){case 1:this._terminal.applicationCursor=!0;break;case 2:this._terminal.setgCharset(0,s.DEFAULT_CHARSET),this._terminal.setgCharset(1,s.DEFAULT_CHARSET),this._terminal.setgCharset(2,s.DEFAULT_CHARSET),this._terminal.setgCharset(3,s.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 12: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===e[0],this._terminal.vt200Mouse=1e3===e[0],this._terminal.normalMouse=e[0]>1e3,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(e[0]){case 4:this._terminal.insertMode=!0;break;case 20:}},e.prototype.resetMode=function(e){if(e.length>1)for(var t=0;t<e.length;t++)this.resetMode([e[t]]);else if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(e[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 12: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(e[0]){case 4:this._terminal.insertMode=!1;break;case 20:}},e.prototype.charAttributes=function(e){if(1===e.length&&0===e[0])return void(this._terminal.curAttr=this._terminal.defAttr);for(var t,i=e.length,r=0,s=this._terminal.curAttr>>18,n=this._terminal.curAttr>>9&511,o=511&this._terminal.curAttr;r<i;r++)t=e[r],t>=30&&t<=37?n=t-30:t>=40&&t<=47?o=t-40:t>=90&&t<=97?(t+=8,n=t-90):t>=100&&t<=107?(t+=8,o=t-100):0===t?(s=this._terminal.defAttr>>18,n=this._terminal.defAttr>>9&511,o=511&this._terminal.defAttr):1===t?s|=1:4===t?s|=2:5===t?s|=4:7===t?s|=8:8===t?s|=16:22===t?s&=-2:24===t?s&=-3:25===t?s&=-5:27===t?s&=-9:28===t?s&=-17:39===t?n=this._terminal.defAttr>>9&511:49===t?o=511&this._terminal.defAttr:38===t?2===e[r+1]?(r+=2,n=this._terminal.matchColor(255&e[r],255&e[r+1],255&e[r+2]),n===-1&&(n=511),r+=2):5===e[r+1]&&(r+=2,t=255&e[r],n=t):48===t?2===e[r+1]?(r+=2,o=this._terminal.matchColor(255&e[r],255&e[r+1],255&e[r+2]),o===-1&&(o=511),r+=2):5===e[r+1]&&(r+=2,t=255&e[r],o=t):100===t?(n=this._terminal.defAttr>>9&511,o=511&this._terminal.defAttr):this._terminal.error("Unknown SGR attribute: %d.",t);this._terminal.curAttr=s<<18|n<<9|o},e.prototype.deviceStatus=function(e){if(this._terminal.prefix){if("?"===this._terminal.prefix)switch(e[0]){case 6:this._terminal.send(r.C0.ESC+"[?"+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R");break;case 15:break;case 25:break;case 26:break;case 53:}}else switch(e[0]){case 5:this._terminal.send(r.C0.ESC+"[0n");break;case 6:this._terminal.send(r.C0.ESC+"["+(this._terminal.buffer.y+1)+";"+(this._terminal.buffer.x+1)+"R")}},e.prototype.softReset=function(e){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]},e.prototype.setCursorStyle=function(e){var t=e[0]<1?1:e[0];switch(t){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")}var i=t%2===1;this._terminal.setOption("cursorBlink",i)},e.prototype.setScrollRegion=function(e){this._terminal.prefix||(this._terminal.buffer.scrollTop=(e[0]||1)-1,this._terminal.buffer.scrollBottom=(e[1]&&e[1]<=this._terminal.rows?e[1]:this._terminal.rows)-1,this._terminal.buffer.x=0,this._terminal.buffer.y=0)},e.prototype.saveCursor=function(e){this._terminal.buffer.savedX=this._terminal.buffer.x,this._terminal.buffer.savedY=this._terminal.buffer.y},e.prototype.restoreCursor=function(e){this._terminal.buffer.x=this._terminal.buffer.savedX||0,this._terminal.buffer.y=this._terminal.buffer.savedY||0},e}();i.InputHandler=n,i.wcwidth=function(e){function t(e,t){var i,r=0,s=t.length-1;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=r;)if(i=r+s>>1,e>t[i][1])r=i+1;else{if(!(e<t[i][0]))return!0;s=i-1}return!1}function i(i){return 0===i?e.nul:i<32||i>=127&&i<160?e.control:t(i,o)?0:r(i)?2:1}function r(e){return e>=4352&&(e<=4447||9001===e||9002===e||e>=11904&&e<=42191&&12351!==e||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510)}function s(e){return t(e,a)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function n(){var e=65536,t=2,r=32,s=e*t/r,n=r/t;h="undefined"==typeof Uint32Array?new Array(s):new Uint32Array(s);for(var o=0;o<s;++o){for(var a=0,l=n;l--;)a=a<<2|i(n*o+l);h[o]=a}return h}var o=[[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]],a=[[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]],l=0|e.control,h=null;return function(e){if(e=0|e,e<32)return 0|l;if(e<127)return 1;var t=h||n();return e<65536?t[e>>4]>>((15&e)<<1)&3:s(e)}}({nul:0,control:0})},{"./Charsets":3,"./EscapeSequences":5}],8:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r="xterm-invalid-link",s="(https?:\\/\\/)",n="[\\da-z\\.-]+",o="[^\\da-z\\.-]+",a="("+n+")",l="([a-z\\.]{2,6})",h="((\\d{1,3}\\.){3}\\d{1,3})",c="(localhost)",u="(:\\d{1,5})",f="(("+a+"\\."+l+")|"+h+"|"+c+")"+u+"?",m="(\\/[\\/\\w\\.\\-%~]*)*",p="[0-9\\w\\[\\]\\(\\)\\/\\?\\!#@$%&'*+,:;~\\=\\.\\-]*",d="(\\?"+p+")?",_="(#"+p+")?",y="[^\\/\\w\\.\\-%]+",b=f+m+d+_,v="(?:^|"+o+")(",C=")($|"+y+")",g=new RegExp(v+s+b+C),S=0,w=function(){function e(){this._nextLinkMatcherId=S,this._rowTimeoutIds=[],this._linkMatchers=[],this.registerLinkMatcher(g,null,{matchIndex:1})}return e.prototype.attachToDom=function(e,t){this._document=e,this._rows=t},e.prototype.linkifyRow=function(t){if(this._document){var i=this._rowTimeoutIds[t];i&&clearTimeout(i),this._rowTimeoutIds[t]=setTimeout(this._linkifyRow.bind(this,t),e.TIME_BEFORE_LINKIFY)}},e.prototype.setHypertextLinkHandler=function(e){this._linkMatchers[S].handler=e},e.prototype.setHypertextValidationCallback=function(e){this._linkMatchers[S].validationCallback=e},e.prototype.registerLinkMatcher=function(e,t,i){if(void 0===i&&(i={}),this._nextLinkMatcherId!==S&&!t)throw new Error("handler must be defined");var r={id:this._nextLinkMatcherId++,regex:e,handler:t,matchIndex:i.matchIndex,validationCallback:i.validationCallback,priority:i.priority||0};return this._addLinkMatcherToList(r),r.id},e.prototype._addLinkMatcherToList=function(e){if(0===this._linkMatchers.length)return void this._linkMatchers.push(e);for(var t=this._linkMatchers.length-1;t>=0;t--)if(e.priority<=this._linkMatchers[t].priority)return void this._linkMatchers.splice(t+1,0,e);this._linkMatchers.splice(0,0,e)},e.prototype.deregisterLinkMatcher=function(e){for(var t=1;t<this._linkMatchers.length;t++)if(this._linkMatchers[t].id===e)return this._linkMatchers.splice(t,1),!0;return!1},e.prototype._linkifyRow=function(e){var t=this._rows[e];if(t)for(var i=(t.textContent,0);i<this._linkMatchers.length;i++){var s=this._linkMatchers[i],n=this._doLinkifyRow(t,s);if(n.length>0){if(s.validationCallback)for(var o=function(e){var t=n[e];s.validationCallback(t.textContent,t,function(e){e||t.classList.add(r)})},a=0;a<n.length;a++)o(a);return}}},e.prototype._doLinkifyRow=function(e,t){var i=[],r=t.id===S,s=e.childNodes,n=e.textContent.match(t.regex);if(!n||0===n.length)return i;for(var o=n["number"!=typeof t.matchIndex?0:t.matchIndex],a=n.index+o.length,l=0;l<s.length;l++){var h=s[l],c=h.textContent.indexOf(o);if(c>=0){var u=this._createAnchorElement(o,t.handler,r);if(h.textContent.length===o.length)if(3===h.nodeType)this._replaceNode(h,u);else{var f=h;if("A"===f.nodeName)return i;f.innerHTML="",f.appendChild(u)}else if(h.childNodes.length>1)for(var m=0;m<h.childNodes.length;m++){var p=h.childNodes[m],d=p.textContent.indexOf(o);if(d!==-1){this._replaceNodeSubstringWithNode(p,u,o,d);break}}else{var _=this._replaceNodeSubstringWithNode(h,u,o,c);l+=_}if(i.push(u),n=e.textContent.substring(a).match(t.regex),!n||0===n.length)return i;o=n["number"!=typeof t.matchIndex?0:t.matchIndex],a+=n.index+o.length}}return i},e.prototype._createAnchorElement=function(e,t,i){var s=this._document.createElement("a");return s.textContent=e,s.draggable=!1,i?(s.href=e,s.target="_blank",s.addEventListener("click",function(i){if(t)return t(i,e)})):s.addEventListener("click",function(i){if(!s.classList.contains(r))return t(i,e)}),s},e.prototype._replaceNode=function(e){
 for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var r=e.parentNode,s=0;s<t.length;s++)r.insertBefore(t[s],e);r.removeChild(e)},e.prototype._replaceNodeSubstringWithNode=function(e,t,i,r){if(1===e.childNodes.length&&(e=e.childNodes[0]),3!==e.nodeType)throw new Error("targetNode must be a text node or only contain a single text node");var s=e.textContent;if(0===r){var n=s.substring(i.length),o=this._document.createTextNode(n);return this._replaceNode(e,t,o),0}if(r===e.textContent.length-i.length){var a=s.substring(0,r),l=this._document.createTextNode(a);return this._replaceNode(e,l,t),0}var h=s.substring(0,r),c=this._document.createTextNode(h),u=s.substring(r+i.length),f=this._document.createTextNode(u);return this._replaceNode(e,c,t,f),1},e}();w.TIME_BEFORE_LINKIFY=200,i.Linkifier=w},{}],9:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=e("./EscapeSequences"),s=e("./Charsets"),n={};n[r.C0.BEL]=function(e,t){return t.bell()},n[r.C0.LF]=function(e,t){return t.lineFeed()},n[r.C0.VT]=n[r.C0.LF],n[r.C0.FF]=n[r.C0.LF],n[r.C0.CR]=function(e,t){return t.carriageReturn()},n[r.C0.BS]=function(e,t){return t.backspace()},n[r.C0.HT]=function(e,t){return t.tab()},n[r.C0.SO]=function(e,t){return t.shiftOut()},n[r.C0.SI]=function(e,t){return t.shiftIn()},n[r.C0.ESC]=function(e,t){return e.setState(h.ESCAPED)};var o={};o["["]=function(e,t){t.params=[],t.currentParam=0,e.setState(h.CSI_PARAM)},o["]"]=function(e,t){t.params=[],t.currentParam=0,e.setState(h.OSC)},o.P=function(e,t){t.params=[],t.currentParam=0,e.setState(h.DCS)},o._=function(e,t){e.setState(h.IGNORE)},o["^"]=function(e,t){e.setState(h.IGNORE)},o.c=function(e,t){t.reset()},o.E=function(e,t){t.buffer.x=0,t.index(),e.setState(h.NORMAL)},o.D=function(e,t){t.index(),e.setState(h.NORMAL)},o.M=function(e,t){t.reverseIndex(),e.setState(h.NORMAL)},o["%"]=function(e,t){t.setgLevel(0),t.setgCharset(0,s.DEFAULT_CHARSET),e.setState(h.NORMAL),e.skipNextChar()},o[r.C0.CAN]=function(e){return e.setState(h.NORMAL)};var a={};a["?"]=function(e){return e.setPrefix("?")},a[">"]=function(e){return e.setPrefix(">")},a["!"]=function(e){return e.setPrefix("!")},a[0]=function(e){return e.setParam(10*e.getParam())},a[1]=function(e){return e.setParam(10*e.getParam()+1)},a[2]=function(e){return e.setParam(10*e.getParam()+2)},a[3]=function(e){return e.setParam(10*e.getParam()+3)},a[4]=function(e){return e.setParam(10*e.getParam()+4)},a[5]=function(e){return e.setParam(10*e.getParam()+5)},a[6]=function(e){return e.setParam(10*e.getParam()+6)},a[7]=function(e){return e.setParam(10*e.getParam()+7)},a[8]=function(e){return e.setParam(10*e.getParam()+8)},a[9]=function(e){return e.setParam(10*e.getParam()+9)},a.$=function(e){return e.setPostfix("$")},a['"']=function(e){return e.setPostfix('"')},a[" "]=function(e){return e.setPostfix(" ")},a["'"]=function(e){return e.setPostfix("'")},a[";"]=function(e){return e.finalizeParam()},a[r.C0.CAN]=function(e){return e.setState(h.NORMAL)};var l={};l["@"]=function(e,t,i){return e.insertChars(t)},l.A=function(e,t,i){return e.cursorUp(t)},l.B=function(e,t,i){return e.cursorDown(t)},l.C=function(e,t,i){return e.cursorForward(t)},l.D=function(e,t,i){return e.cursorBackward(t)},l.E=function(e,t,i){return e.cursorNextLine(t)},l.F=function(e,t,i){return e.cursorPrecedingLine(t)},l.G=function(e,t,i){return e.cursorCharAbsolute(t)},l.H=function(e,t,i){return e.cursorPosition(t)},l.I=function(e,t,i){return e.cursorForwardTab(t)},l.J=function(e,t,i){return e.eraseInDisplay(t)},l.K=function(e,t,i){return e.eraseInLine(t)},l.L=function(e,t,i){return e.insertLines(t)},l.M=function(e,t,i){return e.deleteLines(t)},l.P=function(e,t,i){return e.deleteChars(t)},l.S=function(e,t,i){return e.scrollUp(t)},l.T=function(e,t,i){t.length<2&&!i&&e.scrollDown(t)},l.X=function(e,t,i){return e.eraseChars(t)},l.Z=function(e,t,i){return e.cursorBackwardTab(t)},l["`"]=function(e,t,i){return e.charPosAbsolute(t)},l.a=function(e,t,i){return e.HPositionRelative(t)},l.b=function(e,t,i){return e.repeatPrecedingCharacter(t)},l.c=function(e,t,i){return e.sendDeviceAttributes(t)},l.d=function(e,t,i){return e.linePosAbsolute(t)},l.e=function(e,t,i){return e.VPositionRelative(t)},l.f=function(e,t,i){return e.HVPosition(t)},l.g=function(e,t,i){return e.tabClear(t)},l.h=function(e,t,i){return e.setMode(t)},l.l=function(e,t,i){return e.resetMode(t)},l.m=function(e,t,i){return e.charAttributes(t)},l.n=function(e,t,i){return e.deviceStatus(t)},l.p=function(e,t,i){switch(i){case"!":e.softReset(t)}},l.q=function(e,t,i,r){" "===r&&e.setCursorStyle(t)},l.r=function(e,t){return e.setScrollRegion(t)},l.s=function(e,t){return e.saveCursor(t)},l.u=function(e,t){return e.restoreCursor(t)},l[r.C0.CAN]=function(e,t,i,r,s){return s.setState(h.NORMAL)};var h;!function(e){e[e.NORMAL=0]="NORMAL",e[e.ESCAPED=1]="ESCAPED",e[e.CSI_PARAM=2]="CSI_PARAM",e[e.CSI=3]="CSI",e[e.OSC=4]="OSC",e[e.CHARSET=5]="CHARSET",e[e.DCS=6]="DCS",e[e.IGNORE=7]="IGNORE"}(h||(h={}));var c=function(){function e(e,t){this._inputHandler=e,this._terminal=t,this._state=h.NORMAL}return e.prototype.parse=function(e){var t,i,c,u,f=e.length;for(this._terminal.debug&&this._terminal.log("data: "+e),this._position=0,this._terminal.surrogate_high&&(e=this._terminal.surrogate_high+e,this._terminal.surrogate_high="");this._position<f;this._position++){if(i=e[this._position],c=e.charCodeAt(this._position),55296<=c&&c<=56319){if(u=e.charCodeAt(this._position+1),isNaN(u)){this._terminal.surrogate_high=i;continue}c=1024*(c-55296)+(u-56320)+65536,i+=e.charAt(this._position+1)}if(!(56320<=c&&c<=57343))switch(this._state){case h.NORMAL:i in n?n[i](this,this._inputHandler):this._inputHandler.addChar(i,c);break;case h.ESCAPED:if(i in o){o[i](this,this._terminal);break}switch(i){case"(":case")":case"*":case"+":case"-":case".":switch(i){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=h.CHARSET;break;case"/":this._terminal.gcharset=3,this._state=h.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=h.NORMAL;break;case"8":this._inputHandler.restoreCursor(),this._state=h.NORMAL;break;case"#":this._state=h.NORMAL,this._position++;break;case"H":this._terminal.tabSet(),this._state=h.NORMAL;break;case"=":this._terminal.log("Serial port requested application keypad."),this._terminal.applicationKeypad=!0,this._terminal.viewport.syncScrollArea(),this._state=h.NORMAL;break;case">":this._terminal.log("Switching back to normal keypad."),this._terminal.applicationKeypad=!1,this._terminal.viewport.syncScrollArea(),this._state=h.NORMAL;break;default:this._state=h.NORMAL,this._terminal.error("Unknown ESC control: %s.",i)}break;case h.CHARSET:i in s.CHARSETS?(t=s.CHARSETS[i],"/"===i&&this.skipNextChar()):t=s.DEFAULT_CHARSET,this._terminal.setgCharset(this._terminal.gcharset,t),this._terminal.gcharset=null,this._state=h.NORMAL;break;case h.OSC:if(i===r.C0.ESC||i===r.C0.BEL){switch(i===r.C0.ESC&&this._position++,this._terminal.params.push(this._terminal.currentParam),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));break;case 3:break;case 4:case 5:break;case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:break;case 46:break;case 50:break;case 51:break;case 52:break;case 104:case 105:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:}this._terminal.params=[],this._terminal.currentParam=0,this._state=h.NORMAL}else this._terminal.params.length?this._terminal.currentParam+=i:i>="0"&&i<="9"?this._terminal.currentParam=10*this._terminal.currentParam+i.charCodeAt(0)-48:";"===i&&(this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam="");break;case h.CSI_PARAM:if(i in a){a[i](this);break}this.finalizeParam(),this._state=h.CSI;case h.CSI:i 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:"")+" "+i),l[i](this._inputHandler,this._terminal.params,this._terminal.prefix,this._terminal.postfix,this)):this._terminal.error("Unknown CSI code: %s.",i),this._state=h.NORMAL,this._terminal.prefix="",this._terminal.postfix="";break;case h.DCS:if(i===r.C0.ESC||i===r.C0.BEL){i===r.C0.ESC&&this._position++;var m=void 0,p=void 0;switch(this._terminal.prefix){case"":break;case"$q":switch(m=this._terminal.currentParam,p=!1,m){case'"q':m='0"q';break;case'"p':m='61"p';break;case"r":m=""+(this._terminal.buffer.scrollTop+1)+";"+(this._terminal.buffer.scrollBottom+1)+"r";break;case"m":m="0m";break;default:this._terminal.error("Unknown DCS Pt: %s.",m),m=""}this._terminal.send(r.C0.ESC+"P"+ +p+"$r"+m+r.C0.ESC+"\\");break;case"+p":break;case"+q":m=this._terminal.currentParam,p=!1,this._terminal.send(r.C0.ESC+"P"+ +p+"+r"+m+r.C0.ESC+"\\");break;default:this._terminal.error("Unknown DCS prefix: %s.",this._terminal.prefix)}this._terminal.currentParam=0,this._terminal.prefix="",this._state=h.NORMAL}else this._terminal.currentParam?this._terminal.currentParam+=i:this._terminal.prefix||"$"===i||"+"===i?2===this._terminal.prefix.length?this._terminal.currentParam=i:this._terminal.prefix+=i:this._terminal.currentParam=i;break;case h.IGNORE:i!==r.C0.ESC&&i!==r.C0.BEL||(i===r.C0.ESC&&this._position++,this._state=h.NORMAL)}}return this._state},e.prototype.setState=function(e){this._state=e},e.prototype.setPrefix=function(e){this._terminal.prefix=e},e.prototype.setPostfix=function(e){this._terminal.postfix=e},e.prototype.setParam=function(e){this._terminal.currentParam=e},e.prototype.getParam=function(){return this._terminal.currentParam},e.prototype.finalizeParam=function(){this._terminal.params.push(this._terminal.currentParam),this._terminal.currentParam=0},e.prototype.skipNextChar=function(){this._position++},e}();i.Parser=c},{"./Charsets":3,"./EscapeSequences":5}],10:[function(e,t,i){"use strict";function r(e){var t=e.ownerDocument,i=t.createElement("span");i.innerHTML="hello world",e.appendChild(i);var r=i.offsetWidth,s=i.offsetHeight;i.style.fontWeight="bold";var n=i.offsetWidth,o=i.offsetHeight;return e.removeChild(i),r!==n||s!==o}Object.defineProperty(i,"__esModule",{value:!0});var s,n=e("./utils/DomElementObjectPool"),o=5;!function(e){e[e.BOLD=1]="BOLD",e[e.UNDERLINE=2]="UNDERLINE",e[e.BLINK=4]="BLINK",e[e.INVERSE=8]="INVERSE",e[e.INVISIBLE=16]="INVISIBLE"}(s||(s={}));var a=null,l=function(){function e(e){this._terminal=e,this._refreshRowsQueue=[],this._refreshFramesSkipped=0,this._refreshAnimationFrame=null,this._spanElementObjectPool=new n.DomElementObjectPool("span"),null===a&&(a=r(this._terminal.element)),this._spanElementObjectPool=new n.DomElementObjectPool("span")}return e.prototype.queueRefresh=function(e,t){this._refreshRowsQueue.push({start:e,end:t}),this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(this._refreshLoop.bind(this)))},e.prototype._refreshLoop=function(){var e=this._terminal.writeBuffer.length>0&&this._refreshFramesSkipped++<=o;if(e)return void(this._refreshAnimationFrame=window.requestAnimationFrame(this._refreshLoop.bind(this)));this._refreshFramesSkipped=0;var t,i;if(this._refreshRowsQueue.length>4)t=0,i=this._terminal.rows-1;else{t=this._refreshRowsQueue[0].start,i=this._refreshRowsQueue[0].end;for(var r=1;r<this._refreshRowsQueue.length;r++)this._refreshRowsQueue[r].start<t&&(t=this._refreshRowsQueue[r].start),this._refreshRowsQueue[r].end>i&&(i=this._refreshRowsQueue[r].end)}this._refreshRowsQueue=[],this._refreshAnimationFrame=null,this._refresh(t,i)},e.prototype._refresh=function(e,t){var i;t-e>=this._terminal.rows/2&&(i=this._terminal.element.parentNode,i&&this._terminal.element.removeChild(this._terminal.rowContainer));var r=this._terminal.cols,n=e;for(t>=this._terminal.rows&&(this._terminal.log("`end` is too large. Most likely a bad CSR."),t=this._terminal.rows-1);n<=t;n++){var o=n+this._terminal.buffer.ydisp,l=this._terminal.buffer.lines.get(o),h=void 0;h=this._terminal.buffer.y===n-(this._terminal.buffer.ybase-this._terminal.buffer.ydisp)&&this._terminal.cursorState&&!this._terminal.cursorHidden?this._terminal.buffer.x:-1;for(var c=this._terminal.defAttr,u=document.createDocumentFragment(),f="",m=void 0;this._terminal.children[n].children.length;){var p=this._terminal.children[n].children[0];this._terminal.children[n].removeChild(p),this._spanElementObjectPool.release(p)}for(var d=0;d<r;d++){var _=l[d][0],y=l[d][1],b=l[d][2],v=d===h;if(b){if((_!==c||v)&&(c===this._terminal.defAttr||v||(f&&(m.innerHTML=f,f=""),u.appendChild(m),m=null),_!==this._terminal.defAttr||v)){f&&!m&&(m=this._spanElementObjectPool.acquire()),m&&(f&&(m.innerHTML=f,f=""),u.appendChild(m)),m=this._spanElementObjectPool.acquire();var C=511&_,g=_>>9&511,S=_>>18;if(v&&(m.classList.add("reverse-video"),m.classList.add("terminal-cursor")),S&s.BOLD&&(a||m.classList.add("xterm-bold"),g<8&&(g+=8)),S&s.UNDERLINE&&m.classList.add("xterm-underline"),S&s.BLINK&&m.classList.add("xterm-blink"),S&s.INVERSE){var w=C;C=g,g=w,1&S&&g<8&&(g+=8)}S&s.INVISIBLE&&!v&&m.classList.add("xterm-hidden"),S&s.INVERSE&&(257===C&&(C=15),256===g&&(g=0)),C<256&&m.classList.add("xterm-bg-color-"+C),g<256&&m.classList.add("xterm-color-"+g)}if(2===b)f+='<span class="xterm-wide-char">'+y+"</span>";else if(y.charCodeAt(0)>255)f+='<span class="xterm-normal-char">'+y+"</span>";else switch(y){case"&":f+="&amp;";break;case"<":f+="&lt;";break;case">":f+="&gt;";break;default:f+=y<=" "?"&nbsp;":y}c=v?-1:_}}f&&!m&&(m=this._spanElementObjectPool.acquire()),m&&(f&&(m.innerHTML=f,f=""),u.appendChild(m),m=null),this._terminal.children[n].appendChild(u)}i&&this._terminal.element.appendChild(this._terminal.rowContainer),this._terminal.emit("refresh",{element:this._terminal.element,start:e,end:t})},e.prototype.refreshSelection=function(e,t){for(;this._terminal.selectionContainer.children.length;)this._terminal.selectionContainer.removeChild(this._terminal.selectionContainer.children[0]);if(e&&t){var i=e[1]-this._terminal.buffer.ydisp,r=t[1]-this._terminal.buffer.ydisp,s=Math.max(i,0),n=Math.min(r,this._terminal.rows-1);if(!(s>=this._terminal.rows||n<0)){var o=document.createDocumentFragment(),a=i===s?e[0]:0,l=s===n?t[0]:this._terminal.cols;o.appendChild(this._createSelectionElement(s,a,l));var h=n-s-1;if(o.appendChild(this._createSelectionElement(s+1,0,this._terminal.cols,h)),s!==n){var c=r===n?t[0]:this._terminal.cols;o.appendChild(this._createSelectionElement(n,0,c))}this._terminal.selectionContainer.appendChild(o)}}},e.prototype._createSelectionElement=function(e,t,i,r){void 0===r&&(r=1);var s=document.createElement("div");return s.style.height=r*this._terminal.charMeasure.height+"px",s.style.top=e*this._terminal.charMeasure.height+"px",s.style.left=t*this._terminal.charMeasure.width+"px",s.style.width=this._terminal.charMeasure.width*(i-t)+"px",s},e}();i.Renderer=l},{"./utils/DomElementObjectPool":19}],11:[function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();Object.defineProperty(i,"__esModule",{value:!0});var s,n=e("./utils/Mouse"),o=e("./utils/Browser"),a=e("./EventEmitter"),l=e("./SelectionModel"),h=e("./utils/BufferLine"),c=50,u=15,f=50,m=" ()[]{}'\"",p=2,d=String.fromCharCode(160),_=new RegExp(d,"g");!function(e){e[e.NORMAL=0]="NORMAL",e[e.WORD=1]="WORD",e[e.LINE=2]="LINE"}(s||(s={}));var y=function(e){function t(t,i,r,n){var o=e.call(this)||this;return o._terminal=t,o._buffer=i,o._rowContainer=r,o._charMeasure=n,o._enabled=!0,o._initListeners(),o.enable(),o._model=new l.SelectionModel(t),o._activeSelectionMode=s.NORMAL,o}return r(t,e),t.prototype._initListeners=function(){var e=this;this._mouseMoveListener=function(t){return e._onMouseMove(t)},this._mouseUpListener=function(t){return e._onMouseUp(t)},this._rowContainer.addEventListener("mousedown",function(t){return e._onMouseDown(t)}),this._buffer.on("trim",function(t){return e._onTrim(t)})},t.prototype.disable=function(){this.clearSelection(),this._enabled=!1},t.prototype.enable=function(){this._enabled=!0},t.prototype.setBuffer=function(e){this._buffer=e,this.clearSelection()},Object.defineProperty(t.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasSelection",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t)&&(e[0]!==t[0]||e[1]!==t[1])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectionText",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";var i=e[1]===t[1]?t[0]:null,r=[];r.push(h.translateBufferLineToString(this._buffer.get(e[1]),!0,e[0],i));for(var s=e[1]+1;s<=t[1]-1;s++){var n=this._buffer.get(s),a=h.translateBufferLineToString(n,!0);n.isWrapped?r[r.length-1]+=a:r.push(a)}if(e[1]!==t[1]){var n=this._buffer.get(t[1]),a=h.translateBufferLineToString(n,!0,0,t[0]);n.isWrapped?r[r.length-1]+=a:r.push(a)}var l=r.map(function(e){return e.replace(_," ")}).join(o.isMSWindows?"\r\n":"\n");return l},enumerable:!0,configurable:!0}),t.prototype.clearSelection=function(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh()},t.prototype.refresh=function(e){var t=this;if(this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame(function(){return t._refresh()})),o.isLinux&&e){var i=this.selectionText;i.length&&this.emit("newselection",this.selectionText)}},t.prototype._refresh=function(){this._refreshAnimationFrame=null,this.emit("refresh",{start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd})},t.prototype.selectAll=function(){this._model.isSelectAllActive=!0,this.refresh()},t.prototype._onTrim=function(e){var t=this._model.onTrim(e);t&&this.refresh()},t.prototype._getMouseBufferCoords=function(e){var t=n.getCoords(e,this._rowContainer,this._charMeasure,this._terminal.cols,this._terminal.rows,!0);return t?(t[0]--,t[1]--,t[1]+=this._terminal.buffer.ydisp,t):null},t.prototype._getMouseEventScrollAmount=function(e){var t=n.getCoordsRelativeToElement(e,this._rowContainer)[1],i=this._terminal.rows*this._charMeasure.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-c),c),t/=c,t/Math.abs(t)+Math.round(t*(u-1)))},t.prototype._onMouseDown=function(e){if(2===e.button&&this.hasSelection)return void e.stopPropagation();if(0===e.button){if(!this._enabled){var t=o.isMac&&e.altKey;if(!t)return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._onIncrementalClick(e):1===e.detail?this._onSingleClick(e):2===e.detail?this._onDoubleClick(e):3===e.detail&&this._onTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}},t.prototype._addMouseDownListeners=function(){var e=this;this._rowContainer.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._rowContainer.ownerDocument.addEventListener("mouseup",this._mouseUpListener),this._dragScrollIntervalTimer=setInterval(function(){return e._dragScroll()},f)},t.prototype._removeMouseDownListeners=function(){this._rowContainer.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._rowContainer.ownerDocument.removeEventListener("mouseup",this._mouseUpListener),clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=null},t.prototype._onIncrementalClick=function(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))},t.prototype._onSingleClick=function(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=s.NORMAL,this._model.selectionStart=this._getMouseBufferCoords(e),this._model.selectionStart){this._model.selectionEnd=null;var t=this._buffer.get(this._model.selectionStart[1]);if(t){var i=t[this._model.selectionStart[0]];0===i[p]&&this._model.selectionStart[0]++}}},t.prototype._onDoubleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=s.WORD,this._selectWordAt(t))},t.prototype._onTripleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=s.LINE,this._selectLineAt(t[1]))},t.prototype._onMouseMove=function(e){var t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);if(this._activeSelectionMode===s.LINE?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._terminal.cols:this._activeSelectionMode===s.WORD&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._dragScrollAmount>0?this._model.selectionEnd[0]=this._terminal.cols-1:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]<this._buffer.length){var i=this._buffer.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];i&&0===i[2]&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)},t.prototype._dragScroll=function(){this._dragScrollAmount&&(this._terminal.scrollDisp(this._dragScrollAmount,!1),this._dragScrollAmount>0?this._model.selectionEnd=[this._terminal.cols-1,this._terminal.buffer.ydisp+this._terminal.rows]:this._model.selectionEnd=[0,this._terminal.buffer.ydisp],this.refresh())},t.prototype._onMouseUp=function(e){this._removeMouseDownListeners()},t.prototype._convertViewportColToCharacterIndex=function(e,t){for(var i=t[0],r=0;t[0]>=r;r++){var s=e[r];0===s[p]&&i--}return i},t.prototype.setSelection=function(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh()},t.prototype._getWordAt=function(e){var t=this._buffer.get(e[1]);if(!t)return null;var i=h.translateBufferLineToString(t,!1),r=this._convertViewportColToCharacterIndex(t,e),s=r,n=e[0]-s,o=0,a=0;if(" "===i.charAt(s)){for(;s>0&&" "===i.charAt(s-1);)s--;for(;r<i.length&&" "===i.charAt(r+1);)r++}else{var l=e[0],c=e[0];for(0===t[l][p]&&(o++,l--),2===t[c][p]&&(a++,c++);s>0&&!this._isCharWordSeparator(i.charAt(s-1));)0===t[l-1][p]&&(o++,l--),s--,l--;for(;r+1<i.length&&!this._isCharWordSeparator(i.charAt(r+1));)2===t[c+1][p]&&(a++,c++),r++,c++}var u=s+n-o,f=Math.min(r-s+o+a+1,this._terminal.cols);return{start:u,length:f}},t.prototype._selectWordAt=function(e){var t=this._getWordAt(e);t&&(this._model.selectionStart=[t.start,e[1]],this._model.selectionStartLength=t.length)},t.prototype._selectToWordAt=function(e){var t=this._getWordAt(e);t&&(this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,e[1]])},t.prototype._isCharWordSeparator=function(e){return m.indexOf(e)>=0},t.prototype._selectLineAt=function(e){this._model.selectionStart=[0,e],this._model.selectionStartLength=this._terminal.cols},t}(a.EventEmitter);i.SelectionManager=y},{"./EventEmitter":6,"./SelectionModel":12,"./utils/Browser":15,"./utils/BufferLine":16,"./utils/Mouse":21}],12:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e){this._terminal=e,this.clearSelection()}return e.prototype.clearSelection=function(){this.selectionStart=null,this.selectionEnd=null,this.isSelectAllActive=!1,this.selectionStartLength=0},Object.defineProperty(e.prototype,"finalSelectionStart",{get:function(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"finalSelectionEnd",{get:function(){return this.isSelectAllActive?[this._terminal.cols,this._terminal.buffer.ybase+this._terminal.rows-1]:this.selectionStart?!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:null},enumerable:!0,configurable:!0}),e.prototype.areSelectionValuesReversed=function(){var e=this.selectionStart,t=this.selectionEnd;return e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]},e.prototype.onTrim=function(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)},e}();i.SelectionModel=r},{}],13:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t,i,r){var s=this;this.terminal=e,this.viewportElement=t,this.scrollArea=i,this.charMeasure=r,this.currentRowHeight=0,this.lastRecordedBufferLength=0,this.lastRecordedViewportHeight=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 s.syncScrollArea()},0)}return e.prototype.refresh=function(){if(this.charMeasure.height>0){var e=this.charMeasure.height!==this.currentRowHeight;e&&(this.currentRowHeight=this.charMeasure.height,this.viewportElement.style.lineHeight=this.charMeasure.height+"px",this.terminal.rowContainer.style.lineHeight=this.charMeasure.height+"px");var t=this.lastRecordedViewportHeight!==this.terminal.rows;(e||t)&&(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"}},e.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 e=this.terminal.buffer.ydisp*this.currentRowHeight;this.viewportElement.scrollTop!==e&&(this.viewportElement.scrollTop=e)},e.prototype.onScroll=function(e){var t=Math.round(this.viewportElement.scrollTop/this.currentRowHeight),i=t-this.terminal.buffer.ydisp;this.terminal.scrollDisp(i,!0)},e.prototype.onWheel=function(e){if(0!==e.deltaY){var t=1;e.deltaMode===WheelEvent.DOM_DELTA_LINE?t=this.currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t=this.currentRowHeight*this.terminal.rows),this.viewportElement.scrollTop+=e.deltaY*t,e.preventDefault()}},e.prototype.onTouchStart=function(e){this.lastTouchY=e.touches[0].pageY},e.prototype.onTouchMove=function(e){var t=this.lastTouchY-e.touches[0].pageY;this.lastTouchY=e.touches[0].pageY,0!==t&&(this.viewportElement.scrollTop+=t,e.preventDefault())},e}();i.Viewport=r},{}],14:[function(e,t,i){"use strict";function r(e,t){return t?e.replace(/\r?\n/g,"\r"):e}function s(e,t,i){t.browser.isMSIE?window.clipboardData.setData("Text",i.selectionText):e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault()}function n(e,t){e.stopPropagation();var i,s=function(i){return i=r(i,t.browser.isMSWindows),t.handler(i),t.textarea.value="",t.emit("paste",i),t.cancel(e)};t.browser.isMSIE?window.clipboardData&&(i=window.clipboardData.getData("Text"),s(i)):e.clipboardData&&(i=e.clipboardData.getData("text/plain"),s(i))}function o(e,t){t.style.position="fixed",t.style.width="20px",t.style.height="20px",t.style.left=e.clientX-10+"px",t.style.top=e.clientY-10+"px",t.style.zIndex="1000",t.focus(),setTimeout(function(){t.style.position=null,t.style.width=null,t.style.height=null,t.style.left=null,t.style.top=null,t.style.zIndex=null},4)}function a(e,t,i){o(e,t),t.value=i.selectionText,t.select()}Object.defineProperty(i,"__esModule",{value:!0}),i.prepareTextForTerminal=r,i.copyHandler=s,i.pasteHandler=n,i.moveTextAreaUnderMouseCursor=o,i.rightClickHandler=a},{}],15:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=e("./Generic"),s="undefined"==typeof navigator,n=s?"node":navigator.userAgent,o=s?"node":navigator.platform;i.isFirefox=!!~n.indexOf("Firefox"),i.isMSIE=!!~n.indexOf("MSIE")||!!~n.indexOf("Trident"),i.isMac=r.contains(["Macintosh","MacIntel","MacPPC","Mac68K"],o),i.isIpad="iPad"===o,i.isIphone="iPhone"===o,i.isMSWindows=r.contains(["Windows","Win16","Win32","WinCE"],o),i.isLinux=o.indexOf("Linux")>=0},{"./Generic":20}],16:[function(e,t,i){"use strict";function r(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=null);for(var o="",a=i,l=r,h=0;h<e.length;h++){var c=e[h];o+=c[s],0===c[n]&&(i>=h&&a--,r>=h&&l--)}var u=l||e.length;if(t){var f=o.search(/\s+$/);if(f!==-1&&(u=Math.min(u,f)),u<=a)return""}return o.substring(a,u)}Object.defineProperty(i,"__esModule",{value:!0});var s=1,n=2;i.translateBufferLineToString=r},{}],17:[function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();Object.defineProperty(i,"__esModule",{value:!0});var s=e("../EventEmitter.js"),n=function(e){function t(t,i){var r=e.call(this)||this;return r._document=t,r._parentElement=i,r}return r(t,e),Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),t.prototype.measure=function(){var e=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 e._doMeasure()},0))},t.prototype._doMeasure=function(){var e=this._measureElement.getBoundingClientRect();0!==e.width&&0!==e.height&&(this._width===e.width&&this._height===e.height||(this._width=e.width,this._height=e.height,this.emit("charsizechanged")))},t}(s.EventEmitter);i.CharMeasure=n},{"../EventEmitter.js":6}],18:[function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();Object.defineProperty(i,"__esModule",{value:!0});var s=e("../EventEmitter"),n=function(e){function t(t){var i=e.call(this)||this;return i._array=new Array(t),
 i._startIndex=0,i._length=0,i}return r(t,e),Object.defineProperty(t.prototype,"maxLength",{get:function(){return this._array.length},set:function(e){for(var t=new Array(e),i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._startIndex=0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._length},set:function(e){if(e>this._length)for(var t=this._length;t<e;t++)this._array[t]=void 0;this._length=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"forEach",{get:function(){var e=this;return function(t){for(var i=e.length,r=0;r<i;r++)t(e.get(r),r)}},enumerable:!0,configurable:!0}),t.prototype.get=function(e){return this._array[this._getCyclicIndex(e)]},t.prototype.set=function(e,t){this._array[this._getCyclicIndex(e)]=t},t.prototype.push=function(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this.maxLength?(this._startIndex++,this._startIndex===this.maxLength&&(this._startIndex=0),this.emit("trim",1)):this._length++},t.prototype.pop=function(){return this._array[this._getCyclicIndex(this._length-- -1)]},t.prototype.splice=function(e,t){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];if(t){for(var s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t}if(i&&i.length){for(var s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(var s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(this._length+i.length>this.maxLength){var n=this._length+i.length-this.maxLength;this._startIndex+=n,this._length=this.maxLength,this.emit("trim",n)}else this._length+=i.length}},t.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.emit("trim",e)},t.prototype.shiftElements=function(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(var r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));var s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this.maxLength;)this._length--,this._startIndex++,this.emit("trim",1)}else for(var r=0;r<t;r++)this.set(e+r+i,this.get(e+r))}},t.prototype._getCyclicIndex=function(e){return(this._startIndex+e)%this.maxLength},t}(s.EventEmitter);i.CircularList=n},{"../EventEmitter":6}],19:[function(e,t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e){this.type=e,this._type=e,this._pool=[],this._inUse={}}return e.prototype.acquire=function(){var t;return t=0===this._pool.length?this._createNew():this._pool.pop(),this._inUse[t.getAttribute(e.OBJECT_ID_ATTRIBUTE)]=t,t},e.prototype.release=function(t){if(!this._inUse[t.getAttribute(e.OBJECT_ID_ATTRIBUTE)])throw new Error("Could not release an element not yet acquired");delete this._inUse[t.getAttribute(e.OBJECT_ID_ATTRIBUTE)],this._cleanElement(t),this._pool.push(t)},e.prototype._createNew=function(){var t=document.createElement(this._type),i=e._objectCount++;return t.setAttribute(e.OBJECT_ID_ATTRIBUTE,i.toString(10)),t},e.prototype._cleanElement=function(e){e.className="",e.innerHTML=""},e}();r.OBJECT_ID_ATTRIBUTE="data-obj-id",r._objectCount=0,i.DomElementObjectPool=r},{}],20:[function(e,t,i){"use strict";function r(e,t){return e.indexOf(t)>=0}Object.defineProperty(i,"__esModule",{value:!0}),i.contains=r},{}],21:[function(e,t,i){"use strict";function r(e,t){if(null==e.pageX)return null;for(var i=e.pageX,r=e.pageY;t&&t!==self.document.documentElement;)i-=t.offsetLeft,r-=t.offsetTop,t="offsetParent"in t?t.offsetParent:t.parentElement;return[i,r]}function s(e,t,i,s,n,o){if(!i.width||!i.height)return null;var a=r(e,t);return a?(a[0]=Math.ceil((a[0]+(o?i.width/2:0))/i.width),a[1]=Math.ceil(a[1]/i.height),a[0]=Math.min(Math.max(a[0],1),s+1),a[1]=Math.min(Math.max(a[1],1),n+1),a):null}function n(e,t,i,r,n){var o=s(e,t,i,r,n),a=o[0],l=o[1];return a+=32,l+=32,{x:a,y:l}}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoordsRelativeToElement=r,i.getCoords=s,i.getRawByteCoords=n},{}],22:[function(t,i,r){"use strict";function s(e){var t=this;return this instanceof s?(t.browser=x,t.cancel=s.cancel,_.EventEmitter.call(this),"number"==typeof e&&(e={cols:arguments[0],rows:arguments[1],handler:arguments[2]}),e=e||{},Object.keys(s.defaults).forEach(function(i){null==e[i]&&(e[i]=s.options[i],s[i]!==s.defaults[i]&&(e[i]=s[i])),t[i]=e[i]}),8===e.colors.length?e.colors=e.colors.concat(s._colors.slice(8)):16===e.colors.length?e.colors=e.colors.concat(s._colors.slice(16)):10===e.colors.length?e.colors=e.colors.slice(0,-2).concat(s._colors.slice(8,-2),e.colors.slice(-2)):18===e.colors.length&&(e.colors=e.colors.concat(s._colors.slice(16,-2),e.colors.slice(-2))),this.colors=e.colors,this.options=e,this.parent=e.body||e.parent||(L?L.getElementsByTagName("body")[0]:null),this.cols=e.cols||e.geometry[0],this.rows=e.rows||e.geometry[1],this.geometry=[this.cols,this.rows],e.handler&&this.on("data",e.handler),this.cursorState=0,this.cursorHidden=!1,this.convertEol,this.queue="",this.customKeyEventHandler=null,this.cursorBlinkInterval=null,this.applicationKeypad=!1,this.applicationCursor=!1,this.originMode=!1,this.insertMode=!1,this.wraparoundMode=!0,this.charset=null,this.gcharset=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.readable=!0,this.writable=!0,this.defAttr=131840,this.curAttr=this.defAttr,this.params=[],this.currentParam=0,this.prefix="",this.postfix="",this.inputHandler=new C.InputHandler(this),this.parser=new g.Parser(this.inputHandler,this),this.renderer=this.renderer||null,this.selectionManager=this.selectionManager||null,this.linkifier=this.linkifier||new w.Linkifier,this.writeBuffer=[],this.writeInProgress=!1,this.xoffSentToCatchUp=!1,this.writeStopped=!1,this.surrogate_high="",this.buffers=new p.BufferSet(this),this.buffer=this.buffers.active,this.buffers.on("activate",function(e){this._terminal.buffer=e}),this.selectionManager&&this.selectionManager.setBuffer(this.buffer.lines),this.setupStops(),void(this.userScrolling=!1)):new s(arguments[0],arguments[1],arguments[2])}function n(e,t,i,r){Array.isArray(e)||(e=[e]),e.forEach(function(e){e.addEventListener(t,i,r||!1)})}function o(e,t,i,r){e.removeEventListener(t,i,r||!1)}function a(e,t){if(this.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}function l(e,t){function i(){this.constructor=e}i.prototype=t.prototype,e.prototype=new i}function h(e,t){var i=e.browser.isMac&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.browser.isMSWindows&&t.altKey&&t.ctrlKey&&!t.metaKey;return"keypress"==t.type?i:i&&(!t.keyCode||t.keyCode>47)}function c(e,t,i){var r=e<<16|t<<8|i;if(null!=c._cache[r])return c._cache[r];for(var n,o,a,l,h,u=1/0,f=-1,m=0;m<s.vcolors.length;m++){if(n=s.vcolors[m],o=n[0],a=n[1],l=n[2],h=c.distance(e,t,i,o,a,l),0===h){f=m;break}h<u&&(u=h,f=m)}return c._cache[r]=f}function u(e,t,i){if(e.forEach)return e.forEach(t,i);for(var r=0;r<e.length;r++)t.call(i,e[r],r,e)}function f(e){return 16===e.keyCode||17===e.keyCode||18===e.keyCode}function m(e){if(Object.keys)return Object.keys(e);var t,i=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&i.push(t);return i}Object.defineProperty(r,"__esModule",{value:!0});var p=t("./BufferSet"),d=t("./CompositionHelper"),_=t("./EventEmitter"),y=t("./Viewport"),b=t("./handlers/Clipboard"),v=t("./EscapeSequences"),C=t("./InputHandler"),g=t("./Parser"),S=t("./Renderer"),w=t("./Linkifier"),E=t("./SelectionManager"),k=t("./utils/CharMeasure"),x=t("./utils/Browser"),M=t("./utils/Mouse"),A=t("./utils/BufferLine"),L="undefined"!=typeof window?window.document:null,T=5,R=300,P=600;l(s,_.EventEmitter),s.prototype.eraseAttr=function(){return this.defAttr&-512|511&this.curAttr},s.tangoColors=["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"],s.colors=function(){function e(e,i,s){r.push("#"+t(e)+t(i)+t(s))}function t(e){return e=e.toString(16),e.length<2?"0"+e:e}var i,r=s.tangoColors.slice(),n=[0,95,135,175,215,255];for(i=0;i<216;i++)e(n[i/36%6|0],n[i/6%6|0],n[i%6]);for(i=0;i<24;i++)n=8+10*i,e(n,n,n);return r}(),s._colors=s.colors.slice(),s.vcolors=function(){for(var e,t=[],i=s.colors,r=0;r<256;r++)e=parseInt(i[r].substring(1),16),t.push([e>>16&255,e>>8&255,255&e]);return t}(),s.defaults={colors:s.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},s.options={},s.focus=null,u(m(s.defaults),function(e){s[e]=s.defaults[e],s.options[e]=s.defaults[e]}),s.prototype.focus=function(){return this.textarea.focus()},s.prototype.getOption=function(e){if(!(e in s.defaults))throw new Error('No option with key "'+e+'"');return"undefined"!=typeof this.options[e]?this.options[e]:this[e]},s.prototype.setOption=function(e,t){if(!(e in s.defaults))throw new Error('No option with key "'+e+'"');switch(e){case"scrollback":if(t<this.rows){var i="Setting the scrollback value less than the number of rows ";return i+="("+this.rows+") is not allowed.",console.warn(i),!1}if(this.options[e]!==t){if(this.buffer.lines.length>t){var r=this.buffer.lines.length-t,n=this.buffer.ydisp-r<0;this.buffer.lines.trimStart(r),this.buffer.ybase=Math.max(this.buffer.ybase-r,0),this.buffer.ydisp=Math.max(this.buffer.ydisp-r,0),n&&this.refresh(0,this.rows-1)}this.buffer.lines.maxLength=t,this.viewport.syncScrollArea()}}switch(this[e]=t,this.options[e]=t,e){case"cursorBlink":this.setCursorBlinking(t);break;case"cursorStyle":this.element.classList.toggle("xterm-cursor-style-block","block"===t),this.element.classList.toggle("xterm-cursor-style-underline","underline"===t),this.element.classList.toggle("xterm-cursor-style-bar","bar"===t);break;case"tabStopWidth":this.setupStops()}},s.prototype.restartCursorBlinking=function(){this.setCursorBlinking(this.options.cursorBlink)},s.prototype.setCursorBlinking=function(e){if(this.element.classList.toggle("xterm-cursor-blink",e),this.clearCursorBlinkingInterval(),e){var t=this;this.cursorBlinkInterval=setInterval(function(){t.element.classList.toggle("xterm-cursor-blink-on")},P)}},s.prototype.clearCursorBlinkingInterval=function(){this.element.classList.remove("xterm-cursor-blink-on"),this.cursorBlinkInterval&&(clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=null)},s.bindFocus=function(e){n(e.textarea,"focus",function(t){e.sendFocus&&e.send(v.C0.ESC+"[I"),e.element.classList.add("focus"),e.showCursor(),e.restartCursorBlinking.apply(e),s.focus=e,e.emit("focus",{terminal:e})})},s.prototype.blur=function(){return this.textarea.blur()},s.bindBlur=function(e){n(e.textarea,"blur",function(t){e.refresh(e.buffer.y,e.buffer.y),e.sendFocus&&e.send(v.C0.ESC+"[O"),e.element.classList.remove("focus"),e.clearCursorBlinkingInterval.apply(e),s.focus=null,e.emit("blur",{terminal:e})})},s.prototype.initGlobal=function(){var e=this,t=this;s.bindKeys(this),s.bindFocus(this),s.bindBlur(this),n(this.element,"copy",function(i){t.hasSelection()&&b.copyHandler(i,t,e.selectionManager)});var i=function(e){return b.pasteHandler(e,t)};n(this.textarea,"paste",i),n(this.element,"paste",i),t.browser.isFirefox?n(this.element,"mousedown",function(t){2==t.button&&b.rightClickHandler(t,e.textarea,e.selectionManager)}):n(this.element,"contextmenu",function(t){b.rightClickHandler(t,e.textarea,e.selectionManager)}),t.browser.isLinux&&n(this.element,"auxclick",function(t){1===t.button&&b.moveTextAreaUnderMouseCursor(t,e.textarea,e.selectionManager)})},s.bindKeys=function(e){n(e.element,"keydown",function(t){L.activeElement==this&&e.keyDown(t)},!0),n(e.element,"keypress",function(t){L.activeElement==this&&e.keyPress(t)},!0),n(e.element,"keyup",function(t){f(t)||e.focus(e)},!0),n(e.textarea,"keydown",function(t){e.keyDown(t)},!0),n(e.textarea,"keypress",function(t){e.keyPress(t),this.value=""},!0),n(e.textarea,"compositionstart",e.compositionHelper.compositionstart.bind(e.compositionHelper)),n(e.textarea,"compositionupdate",e.compositionHelper.compositionupdate.bind(e.compositionHelper)),n(e.textarea,"compositionend",e.compositionHelper.compositionend.bind(e.compositionHelper)),e.on("refresh",e.compositionHelper.updateCompositionElements.bind(e.compositionHelper)),e.on("refresh",function(t){e.queueLinkification(t.start,t.end)})},s.prototype.insertRow=function(e){return"object"!=typeof e&&(e=L.createElement("div")),this.rowContainer.appendChild(e),this.children.push(e),e},s.prototype.open=function(e,t){var i=this,r=this,s=0;if(this.parent=e||this.parent,!this.parent)throw new Error("Terminal requires a parent element.");for(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=L.createElement("div"),this.viewportElement.classList.add("xterm-viewport"),this.element.appendChild(this.viewportElement),this.viewportScrollArea=L.createElement("div"),this.viewportScrollArea.classList.add("xterm-scroll-area"),this.viewportElement.appendChild(this.viewportScrollArea),this.selectionContainer=L.createElement("div"),this.selectionContainer.classList.add("xterm-selection"),this.element.appendChild(this.selectionContainer),this.rowContainer=L.createElement("div"),this.rowContainer.classList.add("xterm-rows"),this.element.appendChild(this.rowContainer),this.children=[],this.linkifier.attachToDom(L,this.children),this.helperContainer=L.createElement("div"),this.helperContainer.classList.add("xterm-helpers"),this.element.appendChild(this.helperContainer),this.textarea=L.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(){r.emit("focus",{terminal:r})}),this.textarea.addEventListener("blur",function(){r.emit("blur",{terminal:r})}),this.helperContainer.appendChild(this.textarea),this.compositionView=L.createElement("div"),this.compositionView.classList.add("composition-view"),this.compositionHelper=new d.CompositionHelper(this.textarea,this.compositionView,this),this.helperContainer.appendChild(this.compositionView),this.charSizeStyleElement=L.createElement("style"),this.helperContainer.appendChild(this.charSizeStyleElement);s<this.rows;s++)this.insertRow();if(this.parent.appendChild(this.element),this.charMeasure=new k.CharMeasure(L,this.helperContainer),this.charMeasure.on("charsizechanged",function(){r.updateCharSizeStyles()}),this.charMeasure.measure(),this.viewport=new y.Viewport(this,this.viewportElement,this.viewportScrollArea,this.charMeasure),this.renderer=new S.Renderer(this),this.selectionManager=new E.SelectionManager(this,this.buffer.lines,this.rowContainer,this.charMeasure),this.selectionManager.on("refresh",function(e){i.renderer.refreshSelection(e.start,e.end)}),this.selectionManager.on("newselection",function(e){i.textarea.value=e,i.textarea.focus(),i.textarea.select()}),this.on("scroll",function(){return i.selectionManager.refresh()}),this.viewportElement.addEventListener("scroll",function(){return i.selectionManager.refresh()}),this.refresh(0,this.rows-1),this.initGlobal(),"undefined"==typeof t){var n="You did not pass the `focus` argument in `Terminal.prototype.open()`.\n";n+="The `focus` argument now defaults to `true` but starting with xterm.js 3.0 ",n+="it will default to `false`.",console.warn(n),t=!0}t&&this.focus(),this.bindMouse(),this.emit("open")},s.loadAddon=function(s,n){return"object"==typeof r&&"object"==typeof i?t("./addons/"+s+"/"+s):"function"==typeof e?t(["./addons/"+s+"/"+s],n):(console.error("Cannot load a module without a CommonJS or RequireJS environment."),!1)},s.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;}")},s.prototype.bindMouse=function(){function e(e){var t,i;if(t=s(e),i=M.getRawByteCoords(e,l.rowContainer,l.charMeasure,l.cols,l.rows))switch(r(t,i),e.overrideType||e.type){case"mousedown":h=t;break;case"mouseup":h=32;break;case"wheel":}}function t(e){var t,i=h;t=M.getRawByteCoords(e,l.rowContainer,l.charMeasure,l.cols,l.rows),t&&(i+=32,r(i,t))}function i(e,t){if(l.utfMouse){if(2047===t)return e.push(0);t<127?e.push(t):(t>2047&&(t=2047),e.push(192|t>>6),e.push(128|63&t))}else{if(255===t)return e.push(0);t>127&&(t=127),e.push(t)}}function r(e,t){if(l.vt300Mouse){e&=3,t.x-=32,t.y-=32;var r=v.C0.ESC+"[24";if(0===e)r+="1";else if(1===e)r+="3";else if(2===e)r+="5";else{if(3===e)return;r+="0"}return r+="~["+t.x+","+t.y+"]\r",void l.send(r)}if(l.decLocator)return e&=3,t.x-=32,t.y-=32,0===e?e=2:1===e?e=4:2===e?e=6:3===e&&(e=3),void l.send(v.C0.ESC+"["+e+";"+(3===e?4:0)+";"+t.y+";"+t.x+";"+(t.page||0)+"&w");if(l.urxvtMouse)return t.x-=32,t.y-=32,t.x++,t.y++,void l.send(v.C0.ESC+"["+e+";"+t.x+";"+t.y+"M");if(l.sgrMouse)return t.x-=32,t.y-=32,void l.send(v.C0.ESC+"[<"+((3===(3&e)?e&-4:e)-32)+";"+t.x+";"+t.y+(3===(3&e)?"m":"M"));var r=[];i(r,e),i(r,t.x),i(r,t.y),l.send(v.C0.ESC+"[M"+String.fromCharCode.apply(String,r))}function s(e){var t,i,r,s,n;switch(e.overrideType||e.type){case"mousedown":t=null!=e.button?+e.button:null!=e.which?e.which-1:null,l.browser.isMSIE&&(t=1===t?0:4===t?1:t);break;case"mouseup":t=3;break;case"DOMMouseScroll":t=e.detail<0?64:65;break;case"wheel":t=e.wheelDeltaY>0?64:65}return i=e.shiftKey?4:0,r=e.metaKey?8:0,s=e.ctrlKey?16:0,n=i|r|s,l.vt200Mouse?n&=s:l.normalMouse||(n=0),t=32+(n<<2)+t}var a=this.element,l=this,h=32;n(a,"mousedown",function(i){if(i.preventDefault(),l.focus(),l.mouseEvents)return e(i),l.vt200Mouse?(i.overrideType="mouseup",e(i),l.cancel(i)):(l.normalMouse&&n(l.document,"mousemove",t),l.x10Mouse||n(l.document,"mouseup",function i(r){return e(r),l.normalMouse&&o(l.document,"mousemove",t),o(l.document,"mouseup",i),l.cancel(r)}),l.cancel(i))}),n(a,"wheel",function(t){if(l.mouseEvents&&!(l.x10Mouse||l.vt300Mouse||l.decLocator))return e(t),l.cancel(t)}),n(a,"wheel",function(e){if(!l.mouseEvents)return l.viewport.onWheel(e),l.cancel(e)}),n(a,"touchstart",function(e){if(!l.mouseEvents)return l.viewport.onTouchStart(e),l.cancel(e)}),n(a,"touchmove",function(e){if(!l.mouseEvents)return l.viewport.onTouchMove(e),l.cancel(e)})},s.prototype.destroy=function(){this.readable=!1,this.writable=!1,this._events={},this.handler=function(){},this.write=function(){},this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)},s.prototype.refresh=function(e,t){this.renderer&&this.renderer.queueRefresh(e,t)},s.prototype.queueLinkification=function(e,t){if(this.linkifier)for(var i=e;i<=t;i++)this.linkifier.linkifyRow(i)},s.prototype.showCursor=function(){this.cursorState||(this.cursorState=1,this.refresh(this.buffer.y,this.buffer.y))},s.prototype.scroll=function(e){var t;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),t=this.buffer.ybase+this.rows-1,t-=this.rows-1-this.buffer.scrollBottom,t===this.buffer.lines.length?this.buffer.lines.push(this.blankLine(void 0,e)):this.buffer.lines.splice(t,0,this.blankLine(void 0,e)),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)},s.prototype.scrollDisp=function(e,t){if(e<0){if(0===this.buffer.ydisp)return;this.userScrolling=!0}else e+this.buffer.ydisp>=this.buffer.ybase&&(this.userScrolling=!1);var i=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+e,this.buffer.ybase),0),i!==this.buffer.ydisp&&(t||this.emit("scroll",this.buffer.ydisp),this.refresh(0,this.rows-1))},s.prototype.scrollPages=function(e){this.scrollDisp(e*(this.rows-1))},s.prototype.scrollToTop=function(){this.scrollDisp(-this.buffer.ydisp)},s.prototype.scrollToBottom=function(){this.scrollDisp(this.buffer.ybase-this.buffer.ydisp)},s.prototype.write=function(e){if(this.writeBuffer.push(e),this.options.useFlowControl&&!this.xoffSentToCatchUp&&this.writeBuffer.length>=T&&(this.send(v.C0.DC3),this.xoffSentToCatchUp=!0),!this.writeInProgress&&this.writeBuffer.length>0){this.writeInProgress=!0;var t=this;setTimeout(function(){t.innerWrite()})}},s.prototype.innerWrite=function(){for(var e=this.writeBuffer.splice(0,R);e.length>0;){var t=e.shift();t.length;this.xoffSentToCatchUp&&0===e.length&&0===this.writeBuffer.length&&(this.send(v.C0.DC1),this.xoffSentToCatchUp=!1),this.refreshStart=this.buffer.y,this.refreshEnd=this.buffer.y;var i=this.parser.parse(t);this.parser.setState(i),this.updateRange(this.buffer.y),this.refresh(this.refreshStart,this.refreshEnd)}if(this.writeBuffer.length>0){var r=this;setTimeout(function(){r.innerWrite()},0)}else this.writeInProgress=!1},s.prototype.writeln=function(e){this.write(e+"\r\n")},s.prototype.attachCustomKeydownHandler=function(e){var t="attachCustomKeydownHandler() is DEPRECATED and will be removed soon. Please use attachCustomKeyEventHandler() instead.";console.warn(t),this.attachCustomKeyEventHandler(e)},s.prototype.attachCustomKeyEventHandler=function(e){this.customKeyEventHandler=e},s.prototype.setHypertextLinkHandler=function(e){if(!this.linkifier)throw new Error("Cannot attach a hypertext link handler before Terminal.open is called");this.linkifier.setHypertextLinkHandler(e),this.refresh(0,this.rows-1)},s.prototype.setHypertextValidationCallback=function(e){if(!this.linkifier)throw new Error("Cannot attach a hypertext validation callback before Terminal.open is called");this.linkifier.setHypertextValidationCallback(e),this.refresh(0,this.rows-1)},s.prototype.registerLinkMatcher=function(e,t,i){if(this.linkifier){var r=this.linkifier.registerLinkMatcher(e,t,i);return this.refresh(0,this.rows-1),r}},s.prototype.deregisterLinkMatcher=function(e){this.linkifier&&this.linkifier.deregisterLinkMatcher(e)&&this.refresh(0,this.rows-1)},s.prototype.hasSelection=function(){return!!this.selectionManager&&this.selectionManager.hasSelection},s.prototype.getSelection=function(){return this.selectionManager?this.selectionManager.selectionText:""},s.prototype.clearSelection=function(){this.selectionManager&&this.selectionManager.clearSelection()},s.prototype.selectAll=function(){this.selectionManager&&this.selectionManager.selectAll()},s.prototype.keyDown=function(e){if(this.customKeyEventHandler&&this.customKeyEventHandler(e)===!1)return!1;if(this.restartCursorBlinking(),!this.compositionHelper.keydown.bind(this.compositionHelper)(e))return this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;var t=this.evaluateKeyEscapeSequence(e);return t.key===v.C0.DC3?this.writeStopped=!0:t.key===v.C0.DC1&&(this.writeStopped=!1),t.scrollDisp?(this.scrollDisp(t.scrollDisp),this.cancel(e,!0)):!!h(this,e)||(t.cancel&&this.cancel(e,!0),!t.key||(this.emit("keydown",e),this.emit("key",t.key,e),this.showCursor(),this.handler(t.key),this.cancel(e,!0)))},s.prototype.evaluateKeyEscapeSequence=function(e){var t={cancel:!1,key:void 0,scrollDisp:void 0},i=e.shiftKey<<0|e.altKey<<1|e.ctrlKey<<2|e.metaKey<<3;switch(e.keyCode){case 8:if(e.shiftKey){t.key=v.C0.BS;break}t.key=v.C0.DEL;break;case 9:if(e.shiftKey){t.key=v.C0.ESC+"[Z";break}t.key=v.C0.HT,t.cancel=!0;break;case 13:t.key=v.C0.CR,t.cancel=!0;break;case 27:t.key=v.C0.ESC,t.cancel=!0;break;case 37:i?(t.key=v.C0.ESC+"[1;"+(i+1)+"D",t.key==v.C0.ESC+"[1;3D"&&(t.key=this.browser.isMac?v.C0.ESC+"b":v.C0.ESC+"[1;5D")):this.applicationCursor?t.key=v.C0.ESC+"OD":t.key=v.C0.ESC+"[D";break;case 39:i?(t.key=v.C0.ESC+"[1;"+(i+1)+"C",t.key==v.C0.ESC+"[1;3C"&&(t.key=this.browser.isMac?v.C0.ESC+"f":v.C0.ESC+"[1;5C")):this.applicationCursor?t.key=v.C0.ESC+"OC":t.key=v.C0.ESC+"[C";break;case 38:i?(t.key=v.C0.ESC+"[1;"+(i+1)+"A",t.key==v.C0.ESC+"[1;3A"&&(t.key=v.C0.ESC+"[1;5A")):this.applicationCursor?t.key=v.C0.ESC+"OA":t.key=v.C0.ESC+"[A";break;case 40:i?(t.key=v.C0.ESC+"[1;"+(i+1)+"B",t.key==v.C0.ESC+"[1;3B"&&(t.key=v.C0.ESC+"[1;5B")):this.applicationCursor?t.key=v.C0.ESC+"OB":t.key=v.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(t.key=v.C0.ESC+"[2~");break;case 46:i?t.key=v.C0.ESC+"[3;"+(i+1)+"~":t.key=v.C0.ESC+"[3~";break;case 36:i?t.key=v.C0.ESC+"[1;"+(i+1)+"H":this.applicationCursor?t.key=v.C0.ESC+"OH":t.key=v.C0.ESC+"[H";break;case 35:i?t.key=v.C0.ESC+"[1;"+(i+1)+"F":this.applicationCursor?t.key=v.C0.ESC+"OF":t.key=v.C0.ESC+"[F";break;case 33:e.shiftKey?t.scrollDisp=-(this.rows-1):t.key=v.C0.ESC+"[5~";break;case 34:e.shiftKey?t.scrollDisp=this.rows-1:t.key=v.C0.ESC+"[6~";break;case 112:i?t.key=v.C0.ESC+"[1;"+(i+1)+"P":t.key=v.C0.ESC+"OP";break;case 113:i?t.key=v.C0.ESC+"[1;"+(i+1)+"Q":t.key=v.C0.ESC+"OQ";break;case 114:i?t.key=v.C0.ESC+"[1;"+(i+1)+"R":t.key=v.C0.ESC+"OR";break;case 115:i?t.key=v.C0.ESC+"[1;"+(i+1)+"S":t.key=v.C0.ESC+"OS";break;case 116:i?t.key=v.C0.ESC+"[15;"+(i+1)+"~":t.key=v.C0.ESC+"[15~";break;case 117:i?t.key=v.C0.ESC+"[17;"+(i+1)+"~":t.key=v.C0.ESC+"[17~";break;case 118:i?t.key=v.C0.ESC+"[18;"+(i+1)+"~":t.key=v.C0.ESC+"[18~";break;case 119:i?t.key=v.C0.ESC+"[19;"+(i+1)+"~":t.key=v.C0.ESC+"[19~";break;case 120:i?t.key=v.C0.ESC+"[20;"+(i+1)+"~":t.key=v.C0.ESC+"[20~";break;case 121:i?t.key=v.C0.ESC+"[21;"+(i+1)+"~":t.key=v.C0.ESC+"[21~";break;case 122:i?t.key=v.C0.ESC+"[23;"+(i+1)+"~":t.key=v.C0.ESC+"[23~";break;case 123:i?t.key=v.C0.ESC+"[24;"+(i+1)+"~":t.key=v.C0.ESC+"[24~";break;default:!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey?this.browser.isMac||!e.altKey||e.ctrlKey||e.metaKey?this.browser.isMac&&!e.altKey&&!e.ctrlKey&&e.metaKey&&65===e.keyCode&&this.selectAll():e.keyCode>=65&&e.keyCode<=90?t.key=v.C0.ESC+String.fromCharCode(e.keyCode+32):192===e.keyCode?t.key=v.C0.ESC+"`":e.keyCode>=48&&e.keyCode<=57&&(t.key=v.C0.ESC+(e.keyCode-48)):e.keyCode>=65&&e.keyCode<=90?t.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?t.key=String.fromCharCode(0):e.keyCode>=51&&e.keyCode<=55?t.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?t.key=String.fromCharCode(127):219===e.keyCode?t.key=String.fromCharCode(27):220===e.keyCode?t.key=String.fromCharCode(28):221===e.keyCode&&(t.key=String.fromCharCode(29))}return t},s.prototype.setgLevel=function(e){this.glevel=e,this.charset=this.charsets[e]},s.prototype.setgCharset=function(e,t){this.charsets[e]=t,this.glevel===e&&(this.charset=t)},s.prototype.keyPress=function(e){var t;if(this.customKeyEventHandler&&this.customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null==e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!h(this,e))&&(t=String.fromCharCode(t),this.emit("keypress",t,e),this.emit("key",t,e),this.showCursor(),this.handler(t),!0)},s.prototype.send=function(e){var t=this;this.queue||setTimeout(function(){t.handler(t.queue),t.queue=""},1),this.queue+=e},s.prototype.bell=function(){if(this.visualBell){var e=this;this.element.style.borderColor="white",setTimeout(function(){e.element.style.borderColor=""},10),this.popOnBell&&this.focus()}},s.prototype.log=function(){if(this.debug&&this.context.console&&this.context.console.log){var e=Array.prototype.slice.call(arguments);this.context.console.log.apply(this.context.console,e)}},s.prototype.error=function(){if(this.debug&&this.context.console&&this.context.console.error){var e=Array.prototype.slice.call(arguments);this.context.console.error.apply(this.context.console,e)}},s.prototype.resize=function(e,t){if(!isNaN(e)&&!isNaN(t)){t>this.getOption("scrollback")&&this.setOption("scrollback",t);var i;if(e===this.cols&&t===this.rows)return void(this.charMeasure.width&&this.charMeasure.height||this.charMeasure.measure());for(e<1&&(e=1),t<1&&(t=1),this.buffers.resize(e,t);this.children.length<t;)this.insertRow();for(;this.children.length>t;)i=this.children.shift(),i&&i.parentNode.removeChild(i);this.cols=e,this.rows=t,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:e,rows:t})}},s.prototype.updateRange=function(e){e<this.refreshStart&&(this.refreshStart=e),e>this.refreshEnd&&(this.refreshEnd=e)},s.prototype.maxRange=function(){this.refreshStart=0,this.refreshEnd=this.rows-1},s.prototype.setupStops=function(e){for(null!=e?this.buffer.tabs[e]||(e=this.prevStop(e)):(this.buffer.tabs={},e=0);e<this.cols;e+=this.getOption("tabStopWidth"))this.buffer.tabs[e]=!0},s.prototype.prevStop=function(e){for(null==e&&(e=this.buffer.x);!this.buffer.tabs[--e]&&e>0;);return e>=this.cols?this.cols-1:e<0?0:e},s.prototype.nextStop=function(e){for(null==e&&(e=this.buffer.x);!this.buffer.tabs[++e]&&e<this.cols;);return e>=this.cols?this.cols-1:e<0?0:e},s.prototype.eraseRight=function(e,t){var i=this.buffer.lines.get(this.buffer.ybase+t);if(i){for(var r=[this.eraseAttr()," ",1];e<this.cols;e++)i[e]=r;this.updateRange(t)}},s.prototype.eraseLeft=function(e,t){var i=this.buffer.lines.get(this.buffer.ybase+t);if(i){var r=[this.eraseAttr()," ",1];for(e++;e--;)i[e]=r;this.updateRange(t)}},s.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 e=1;e<this.rows;e++)this.buffer.lines.push(this.blankLine());this.refresh(0,this.rows-1),this.emit("scroll",this.buffer.ydisp)}},s.prototype.eraseLine=function(e){this.eraseRight(0,e)},s.prototype.blankLine=function(e,t,i){var r=e?this.eraseAttr():this.defAttr,s=[r," ",1],n=[],o=0;for(t&&(n.isWrapped=t),i=i||this.cols;o<i;o++)n[o]=s;return n},s.prototype.ch=function(e){return e?[this.eraseAttr()," ",1]:[this.defAttr," ",1]},s.prototype.is=function(e){var t=this.termName;return 0===(t+"").indexOf(e)},s.prototype.handler=function(e){this.options.disableStdin||(this.selectionManager&&this.selectionManager.hasSelection&&this.selectionManager.clearSelection(),this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),this.emit("data",e))},s.prototype.handleTitle=function(e){this.emit("title",e)},s.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--},s.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--},s.prototype.reset=function(){this.options.rows=this.rows,this.options.cols=this.cols;var e=this.customKeyEventHandler,t=this.cursorBlinkInterval,i=this.inputHandler;s.call(this,this.options),
 this.customKeyEventHandler=e,this.cursorBlinkInterval=t,this.inputHandler=i,this.refresh(0,this.rows-1),this.viewport.syncScrollArea()},s.prototype.tabSet=function(){this.buffer.tabs[this.buffer.x]=!0},s.prototype.matchColor=c,c._cache={},c.distance=function(e,t,i,r,s,n){return Math.pow(30*(e-r),2)+Math.pow(59*(t-s),2)+Math.pow(11*(i-n),2)},s.translateBufferLineToString=A.translateBufferLineToString,s.EventEmitter=_.EventEmitter,s.inherits=l,s.on=n,s.off=o,s.cancel=a,i.exports=s},{"./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)});</script>
     <script>!function(e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("../../xterm")):"function"==typeof define?define(["../../xterm"],e):e(window.Terminal)}(function(e){var t={};return t.proposeGeometry=function(e){if(!e.element.parentElement)return null;var t,n,r,o,i,p=window.getComputedStyle(e.element.parentElement),a=parseInt(p.getPropertyValue("height")),l=Math.max(0,parseInt(p.getPropertyValue("width"))-17),s=window.getComputedStyle(e.element),u=parseInt(s.getPropertyValue("padding-top"))+parseInt(s.getPropertyValue("padding-bottom")),d=parseInt(s.getPropertyValue("padding-right"))+parseInt(s.getPropertyValue("padding-left")),y=a-u,g=l-d,m=(e.rowContainer,e.rowContainer.firstElementChild),f=m.innerHTML;return m.style.display="inline",m.innerHTML="W",r=m.getBoundingClientRect().width,m.style.display="",t=m.getBoundingClientRect().height,m.innerHTML=f,n=parseInt(y/t),o=parseInt(g/r),i={cols:o,rows:n}},t.fit=function(e){var n=t.proposeGeometry(e);n&&e.resize(n.cols,n.rows)},e.prototype.proposeGeometry=function(){return t.proposeGeometry(this)},e.prototype.fit=function(){return t.fit(this)},t});</script>
-    <script>UTF8Decoder=function(){this.bytesLeft=0,this.codePoint=0,this.lowerBound=0},UTF8Decoder.prototype.decode=function(t){for(var e="",o=0;o<t.length;o++){var i=t.charCodeAt(o);if(0==this.bytesLeft)i<=127?e+=t.charAt(o):192<=i&&i<=223?(this.codePoint=i-192,this.bytesLeft=1,this.lowerBound=128):224<=i&&i<=239?(this.codePoint=i-224,this.bytesLeft=2,this.lowerBound=2048):240<=i&&i<=247?(this.codePoint=i-240,this.bytesLeft=3,this.lowerBound=65536):248<=i&&i<=251?(this.codePoint=i-248,this.bytesLeft=4,this.lowerBound=2097152):252<=i&&i<=253?(this.codePoint=i-252,this.bytesLeft=5,this.lowerBound=67108864):e+="�";else if(128<=i&&i<=191){if(this.bytesLeft--,this.codePoint=(this.codePoint<<6)+(i-128),0==this.bytesLeft){var r=this.codePoint;r<this.lowerBound||55296<=r&&r<=57343||r>1114111?e+="�":r<65536?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode(55296+(r>>>10&1023),56320+(1023&r)))}}else e+="�",this.bytesLeft=0,o--}return e},Terminal.prototype.decodeUTF8=function(t){return(new UTF8Decoder).decode(t)},Terminal.prototype.encodeUTF8=function(t){for(var e="",o=0;o<t.length;o++){var i=t.charCodeAt(o);if(56320<=i&&i<=57343)i=65533;else if(55296<=i&&i<=56319)if(o+1<t.length){var r=t.charCodeAt(o+1);56320<=r&&r<=57343?(i=65536+((1023&i)<<10)+(1023&r),o++):i=65533}else i=65533;var n;if(i<=127)e+=t.charAt(o);else for(i<=2047?(e+=String.fromCharCode(192|i>>>6),n=1):i<=65535?(e+=String.fromCharCode(224|i>>>12),n=2):(e+=String.fromCharCode(240|i>>>18),n=3);n>0;)n--,e+=String.fromCharCode(128|i>>>6*n&63)}return e},Terminal.prototype.writeUTF8=function(t){this.write(this.decodeUTF8(t))};</script>
     <script>Terminal.prototype.showOverlay=function(e,t){if(!this.overlayNode_){if(!this.element)return;this.overlayNode_=document.createElement("div"),this.overlayNode_.style.cssText="border-radius: 15px;font-size: xx-large;opacity: 0.75;padding: 0.2em 0.5em 0.2em 0.5em;position: absolute;-webkit-user-select: none;-webkit-transition: opacity 180ms ease-in;-moz-user-select: none;-moz-transition: opacity 180ms ease-in;",this.overlayNode_.addEventListener("mousedown",function(e){e.preventDefault(),e.stopPropagation()},!0)}this.overlayNode_.style.color="#101010",this.overlayNode_.style.backgroundColor="#f0f0f0",this.overlayNode_.textContent=e,this.overlayNode_.style.opacity="0.75",this.overlayNode_.parentNode||this.element.appendChild(this.overlayNode_);var o=this.element.getBoundingClientRect(),i=this.overlayNode_.getBoundingClientRect();this.overlayNode_.style.top=(o.height-i.height)/2+"px",this.overlayNode_.style.left=(o.width-i.width)/2+"px";var l=this;this.overlayTimeout_&&clearTimeout(this.overlayTimeout_),null!==t&&(this.overlayTimeout_=setTimeout(function(){l.overlayNode_.style.opacity="0",l.overlayTimeout_=setTimeout(function(){l.overlayNode_.parentNode&&l.overlayNode_.parentNode.removeChild(l.overlayNode_),l.overlayTimeout_=null,l.overlayNode_.style.opacity="0.75"},200)},t||1500))};</script>
 </head>
 <body>
        <div id="terminal-container"></div>
        <script src="auth_token.js"></script>
-       <script>!function(){var e,n,o,t=document.getElementById("terminal-container"),i="https:"===window.location.protocol,s=(i?"wss://":"ws://")+window.location.host+window.location.pathname+"ws",c="undefined"!=typeof tty_auth_token?tty_auth_token:null,a=["tty"],r=-1,d=function(){var i=new WebSocket(s,a),w=function(e){var n="Close terminal? this will also terminate the command.";return(e||window.event).returnValue=n,n};i.onopen=function(s){for(console.log("Websocket connection opened"),o=!1,i.send(JSON.stringify({AuthToken:c})),n=setInterval(l,3e4,i),"undefined"!=typeof e&&e.destroy(),e=new Terminal,e.on("resize",function(n){i.readyState===WebSocket.OPEN&&i.send("2"+JSON.stringify({columns:n.cols,rows:n.rows})),setTimeout(function(){e.showOverlay(n.cols+"x"+n.rows)},500)}),e.on("data",function(e){i.readyState===WebSocket.OPEN&&i.send("0"+e)}),e.on("open",function(){window.addEventListener("resize",function(){clearTimeout(window.resizedFinished),window.resizedFinished=setTimeout(function(){e.fit()},250)}),window.addEventListener("beforeunload",w),e.fit()});t.firstChild;)t.removeChild(t.firstChild);e.open(t,!0)},i.onmessage=function(n){var o=n.data.slice(1);switch(n.data[0]){case"0":e.writeUTF8(window.atob(o));break;case"1":break;case"2":document.title=o;break;case"3":var t=JSON.parse(o);Object.keys(t).forEach(function(n){console.log("Setting "+n+": "+t[n]),e.setOption(n,t[n])});break;case"4":r=JSON.parse(o),console.log("Enabling reconnect: "+r+" seconds")}},i.onclose=function(t){console.log("Websocket connection closed with code: "+t.code),e&&(e.off("data"),e.off("resize"),o||e.showOverlay("Connection Closed",null)),window.removeEventListener("beforeunload",w),clearInterval(n),1e3!==t.code&&r>0&&setTimeout(d,1e3*r)}},l=function(e){e.send("1")};d()}();</script>
+       <script>!function(){var e,n,o,t=document.getElementById("terminal-container"),i="https:"===window.location.protocol,c=(i?"wss://":"ws://")+window.location.host+window.location.pathname+"ws",r="undefined"!=typeof tty_auth_token?tty_auth_token:null,s=["tty"],a=-1,d=function(){var i=new WebSocket(c,s),l=new TextDecoder,f=new TextEncoder,w=function(e){var n="Close terminal? this will also terminate the command.";return(e||window.event).returnValue=n,n},u=function(e){i.readyState===WebSocket.OPEN&&i.send(f.encode(e))},h=function(){u("1")};i.binaryType="arraybuffer",i.onopen=function(){for(console.log("Websocket connection opened"),o=!1,u(JSON.stringify({AuthToken:r})),n=setInterval(h,3e4),"undefined"!=typeof e&&e.destroy(),e=new Terminal,e.on("resize",function(n){u("2"+JSON.stringify({columns:n.cols,rows:n.rows})),setTimeout(function(){e.showOverlay(n.cols+"x"+n.rows)},500)}),e.on("data",function(e){u("0"+e)}),e.on("open",function(){window.addEventListener("resize",function(){clearTimeout(window.resizedFinished),window.resizedFinished=setTimeout(function(){e.fit()},250)}),window.addEventListener("beforeunload",w),e.fit()});t.firstChild;)t.removeChild(t.firstChild);e.open(t,!0)},i.onmessage=function(n){var o=String.fromCharCode(new DataView(n.data).getUint8()),t=l.decode(n.data.slice(1));switch(o){case"0":e.write(t);break;case"1":break;case"2":document.title=t;break;case"3":var i=JSON.parse(t);Object.keys(i).forEach(function(n){console.log("Setting "+n+": "+i[n]),e.setOption(n,i[n])});break;case"4":a=JSON.parse(t),console.log("Enabling reconnect: "+a+" seconds")}},i.onclose=function(t){console.log("Websocket connection closed with code: "+t.code),e&&(e.off("data"),e.off("resize"),o||e.showOverlay("Connection Closed",null)),window.removeEventListener("beforeunload",w),clearInterval(n),1e3!==t.code&&a>0&&setTimeout(d,1e3*a)}};d()}();</script>
 </body>
 </html>
index 9d3ba1f6533fbe90b4e3917b08167c8679bf22cb..70fdc6c67757ac7803f0629b670a68669f2eed2c 100644 (file)
@@ -1,7 +1,5 @@
 #include "server.h"
 
-#define BUF_SIZE 1024
-
 int
 send_initial_message(struct lws *wsi) {
     unsigned char message[LWS_PRE + 256];
@@ -13,17 +11,17 @@ send_initial_message(struct lws *wsi) {
 
     // window title
     n = sprintf((char *) p, "%c%s (%s)", SET_WINDOW_TITLE, server->command, hostname);
-    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_TEXT) < n) {
+    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_BINARY) < n) {
         return -1;
     }
     // reconnect time
     n = sprintf((char *) p, "%c%d", SET_RECONNECT, server->reconnect);
-    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_TEXT) < n) {
+    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_BINARY) < n) {
         return -1;
     }
     // client preferences
     n = sprintf((char *) p, "%c%s", SET_PREFERENCES, server->prefs_json);
-    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_TEXT) < n) {
+    if (lws_write(wsi, p, (size_t) n, LWS_WRITE_BINARY) < n) {
         return -1;
     }
     return 0;
@@ -86,7 +84,7 @@ check_host_origin(struct lws *wsi) {
 
 void
 tty_client_remove(struct tty_client *client) {
-    pthread_mutex_lock(&server->lock);
+    pthread_mutex_lock(&server->mutex);
     struct tty_client *iterator;
     LIST_FOREACH(iterator, &server->clients, list) {
         if (iterator == client) {
@@ -95,7 +93,7 @@ tty_client_remove(struct tty_client *client) {
             break;
         }
     }
-    pthread_mutex_unlock(&server->lock);
+    pthread_mutex_unlock(&server->mutex);
 }
 
 void
@@ -119,6 +117,8 @@ tty_client_destroy(struct tty_client *client) {
     if (client->buffer != NULL)
         free(client->buffer);
 
+    pthread_mutex_destroy(&client->mutex);
+
     // remove from client list
     tty_client_remove(client);
 }
@@ -127,8 +127,6 @@ void *
 thread_run_command(void *args) {
     struct tty_client *client;
     int pty;
-    int bytes;
-    char buf[BUF_SIZE];
     fd_set des_set;
 
     client = (struct tty_client *) args;
@@ -141,11 +139,11 @@ thread_run_command(void *args) {
         case 0: /* child */
             if (setenv("TERM", "xterm-256color", true) < 0) {
                 perror("setenv");
-                exit(1);
+                pthread_exit((void *) 1);
             }
             if (execvp(server->argv[0], server->argv) < 0) {
                 perror("execvp");
-                exit(1);
+                pthread_exit((void *) 1);
             }
             break;
         default: /* parent */
@@ -164,23 +162,25 @@ thread_run_command(void *args) {
                     break;
 
                 if (FD_ISSET (pty, &des_set)) {
-                    memset(buf, 0, BUF_SIZE);
-                    bytes = (int) read(pty, buf, BUF_SIZE);
-                    struct pty_data *frame = (struct pty_data *) xmalloc(sizeof(struct pty_data));
-                    frame->len = bytes;
-                    if (bytes > 0) {
-                        frame->data = xmalloc((size_t) bytes);
-                        memcpy(frame->data, buf, bytes);
+                    while (client->running) {
+                        pthread_mutex_lock(&client->mutex);
+                        if (client->state == STATE_READY) {
+                            pthread_mutex_unlock(&client->mutex);
+                            usleep(5);
+                            continue;
+                        }
+                        memset(client->pty_buffer, 0, sizeof(client->pty_buffer));
+                        client->pty_len = read(pty, client->pty_buffer, sizeof(client->pty_buffer));
+                        client->state = STATE_READY;
+                        pthread_mutex_unlock(&client->mutex);
+                        break;
                     }
-                    pthread_mutex_lock(&client->lock);
-                    STAILQ_INSERT_TAIL(&client->queue, frame, list);
-                    pthread_mutex_unlock(&client->lock);
                 }
             }
             break;
     }
 
-    return 0;
+    pthread_exit((void *) 0);
 }
 
 int
@@ -216,15 +216,17 @@ callback_tty(struct lws *wsi, enum lws_callback_reasons reason,
             client->authenticated = false;
             client->wsi = wsi;
             client->buffer = NULL;
+            client->state = STATE_INIT;
+            client->pty_len = 0;
+            pthread_mutex_init(&client->mutex, NULL);
             lws_get_peer_addresses(wsi, lws_get_socket_fd(wsi),
                                    client->hostname, sizeof(client->hostname),
                                    client->address, sizeof(client->address));
-            STAILQ_INIT(&client->queue);
 
-            pthread_mutex_lock(&server->lock);
+            pthread_mutex_lock(&server->mutex);
             LIST_INSERT_HEAD(&server->clients, client, list);
             server->client_count++;
-            pthread_mutex_unlock(&server->lock);
+            pthread_mutex_unlock(&server->mutex);
             lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_GET_URI);
 
             lwsl_notice("WS   %s - %s (%s), clients: %d\n", buf, client->address, client->hostname, server->client_count);
@@ -240,44 +242,31 @@ callback_tty(struct lws *wsi, enum lws_callback_reasons reason,
                 client->initialized = true;
                 break;
             }
+            if (client->state != STATE_READY)
+                break;
 
-            pthread_mutex_lock(&client->lock);
-            while (!STAILQ_EMPTY(&client->queue)) {
-                struct pty_data *frame = STAILQ_FIRST(&client->queue);
-                // read error or client exited, close connection
-                if (frame->len <= 0) {
-                    STAILQ_REMOVE_HEAD(&client->queue, list);
-                    free(frame);
-                    tty_client_remove(client);
-                    lws_close_reason(wsi,
-                                     frame->len == 0 ? LWS_CLOSE_STATUS_NORMAL : LWS_CLOSE_STATUS_UNEXPECTED_CONDITION,
-                                     NULL, 0);
-                    return -1;
-                }
+            // read error or client exited, close connection
+            if (client->pty_len <= 0) {
+                tty_client_remove(client);
+                lws_close_reason(wsi,
+                                 client->pty_len == 0 ? LWS_CLOSE_STATUS_NORMAL
+                                                       : LWS_CLOSE_STATUS_UNEXPECTED_CONDITION,
+                                 NULL, 0);
+                return -1;
+            }
 
-                char *b64_text = base64_encode((const unsigned char *) frame->data, (size_t) frame->len);
-                size_t msg_len = LWS_PRE + strlen(b64_text) + 1;
-                unsigned char message[msg_len];
+            {
+                size_t n = (size_t) client->pty_len + 1;
+                unsigned char message[LWS_PRE + n];
                 unsigned char *p = &message[LWS_PRE];
-                size_t n = sprintf((char *) p, "%c%s", OUTPUT, b64_text);
+                *p = OUTPUT;
+                memcpy(p + 1, client->pty_buffer, client->pty_len);
+                client->state = STATE_DONE;
 
-                free(b64_text);
-
-                if (lws_write(wsi, p, n, LWS_WRITE_TEXT) < n) {
+                if (lws_write(wsi, p, n, LWS_WRITE_BINARY) < n) {
                     lwsl_err("write data to WS\n");
-                    break;
-                }
-
-                STAILQ_REMOVE_HEAD(&client->queue, list);
-                free(frame->data);
-                free(frame);
-
-                if (lws_partial_buffered(wsi)) {
-                    lws_callback_on_writable(wsi);
-                    break;
                 }
             }
-            pthread_mutex_unlock(&client->lock);
             break;
 
         case LWS_CALLBACK_RECEIVE:
@@ -321,7 +310,7 @@ callback_tty(struct lws *wsi, enum lws_callback_reasons reason,
                 case PING:
                     {
                         unsigned char c = PONG;
-                        if (lws_write(wsi, &c, 1, LWS_WRITE_TEXT) != 1) {
+                        if (lws_write(wsi, &c, 1, LWS_WRITE_BINARY) != 1) {
                             lwsl_err("send PONG\n");
                             tty_client_remove(client);
                             lws_close_reason(wsi, LWS_CLOSE_STATUS_UNEXPECTED_CONDITION, NULL, 0);
index 3d1cf518f39701d516fe54477b3f9fcc38cd2930..3fcd2377253f4ec88a49b19af3f20c0e7c3e7710 100644 (file)
@@ -140,6 +140,7 @@ tty_server_free(struct tty_server *ts) {
             unlink(ts->socket_path);
         }
     }
+    pthread_mutex_destroy(&ts->mutex);
     free(ts);
 }
 
@@ -203,6 +204,7 @@ main(int argc, char **argv) {
 
     int start = calc_command_start(argc, argv);
     server = tty_server_new(argc, argv, start);
+    pthread_mutex_init(&server->mutex, NULL);
 
     struct lws_context_creation_info info;
     memset(&info, 0, sizeof(info));
@@ -442,16 +444,19 @@ main(int argc, char **argv) {
 
     // libwebsockets main loop
     while (!force_exit) {
-        pthread_mutex_lock(&server->lock);
+        pthread_mutex_lock(&server->mutex);
         if (!LIST_EMPTY(&server->clients)) {
             struct tty_client *client;
             LIST_FOREACH(client, &server->clients, list) {
-                if (client->running && !STAILQ_EMPTY(&client->queue)) {
-                    lws_callback_on_writable(client->wsi);
+                if (client->running) {
+                    pthread_mutex_lock(&client->mutex);
+                    if (client->state != STATE_DONE)
+                        lws_callback_on_writable(client->wsi);
+                    pthread_mutex_unlock(&client->mutex);
                 }
             }
         }
-        pthread_mutex_unlock(&server->lock);
+        pthread_mutex_unlock(&server->mutex);
         lws_service(context, 10);
     }
 
index 02bd1904860e9173ea6a54c5c0aab4df48767df4..c357315b971c7f3b23d4649a1c4e7206c5ece775 100644 (file)
 // websocket url path
 #define WS_PATH "/ws"
 
+#define BUF_SIZE 32768 // 32K
+
 extern volatile bool force_exit;
 extern struct lws_context *context;
 extern struct tty_server *server;
 
-struct pty_data {
-    char *data;
-    int len;
-    STAILQ_ENTRY(pty_data) list;
+enum pty_state {
+    STATE_INIT, STATE_READY, STATE_DONE
 };
 
 struct tty_client {
@@ -87,12 +87,14 @@ struct tty_client {
     struct winsize size;
     char *buffer;
     size_t len;
+
     int pid;
     int pty;
+    enum pty_state state;
+    char pty_buffer[BUF_SIZE];
+    ssize_t pty_len;
     pthread_t thread;
-
-    STAILQ_HEAD(pty, pty_data) queue;
-    pthread_mutex_t lock;
+    pthread_mutex_t mutex;
 
     LIST_ENTRY(tty_client) list;
 };
@@ -113,7 +115,7 @@ struct tty_server {
     int max_clients;                          // maximum clients to support
     bool once;                                // whether accept only one client and exit on disconnection
     char socket_path[255];                    // UNIX domain socket path
-    pthread_mutex_t lock;
+    pthread_mutex_t mutex;
 };
 
 extern int