See espterm.github.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
espterm-demo-website/js/app.f5dd70a.js

2 lines
88 KiB

!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=7)}([function(e,t,n){"use strict";t.mk=function(e){return document.createElement(e)},t.qs=function(e){return document.querySelector(e)},t.qsa=function(e){return document.querySelectorAll(e)},t.cr=function(e){return function(t){(10===t.which||13===t.which||32===t.which)&&e()}},t.bool=function(e){return 1===e||"1"===e||!0===e||"true"===e},t.parse2B=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return e.charCodeAt(t++)-1+127*(e.charCodeAt(t)-1)},t.parse3B=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;return e.charCodeAt(t)-1+127*(e.charCodeAt(t+1)-1)+127*(e.charCodeAt(t+2)-1)*127},t.encode2B=function(e){var t,n,r=String.fromCharCode;return t=e%127,e=(e-t)/127,t+=1,n=e+1,r(t)+r(n)},t.encode3B=function(e){var t,n,r,i=String.fromCharCode;return t=e%127,e=(e-t)/127,t+=1,n=e%127,e=(e-n)/127,n+=1,r=e+1,i(t)+i(n)+i(r)}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){function t(){var e;for(p=!0,e=0;e<v.length;e+=1)v[e]();v=[]}function n(){var e;for(w=!0,p||t(),e=0;e<m.length;e+=1)m[e]();m=[]}function i(e,t){var n;for(n=t.length-1;0<=n;n-=1)e(t[n])}function o(e){return e.replace(/-\w/g,function(e){return e.charAt(1).toUpperCase()})}function s(e,t){return e.currentStyle?e.currentStyle[o(t)]:g.getComputedStyle?g.getComputedStyle(e,null).getPropertyValue(t):null}function a(e,t){return encodeURIComponent(e).replace(/%20/g,"+")+"="+encodeURIComponent(t).replace(/%20/g,"+")}function c(e,t,n){try{e.style[o(t)]=n}catch(e){}}function l(e){e.style.display="","none"===s(e,"display")&&(e.style.display="block")}function u(e){var t,n,r,o="";if(e.constructor===Object){for(t in e)if(e.hasOwnProperty(t))if(e[t].constructor===Array)for(n=0;n<e[t].length;n+=1)o+="&"+a(t,e[t][n]);else o+="&"+a(t,e[t])}else i(function(e){if("FORM"===e.nodeName)for(n=0;n<e.elements.length;n+=1)if(t=e.elements[n],!t.disabled)switch(t.type){case"button":case"image":case"file":case"submit":case"reset":break;case"select-one":0<t.length&&(o+="&"+a(t.name,t.value));break;case"select-multiple":for(r=0;r<t.length;r+=1)t[r].selected&&(o+="&"+a(t.name,t[r].value));break;case"checkbox":case"radio":t.checked&&(o+="&"+a(t.name,t.value));break;default:o+="&"+a(t.name,t.value)}},e);return 0<o.length?o.substring(1):""}function h(e,t,n){var r,o,s=!1;return e&&(r=e.split(/\s+/),i(function(e){for(o=0;o<r.length;o+=1){var n=r[o];if("remove"===t)e.classList.remove(n);else if("add"===t)e.classList.add(n);else if("toggle"===t)e.classList.toggle(n);else if("has"===t&&e.classList.contains(n)){s=!0;break}}},n)),s}function f(e,t,n){var r,o;e&&i(function(n){for(r=y.createElement("div"),r.innerHTML=e;null!==(o=r.lastChild);)try{"before"===t?n.parentNode.insertBefore(o,n):"after"===t?n.parentNode.insertBefore(o,n.nextSibling):"append"===t?n.appendChild(o):"prepend"===t&&n.insertBefore(o,n.firstChild)}catch(e){break}},n)}function d(e){var t,n,a,u=[],v=!1;if(e)if(e.nodeType&&1===e.nodeType)u=[e];else if("object"===(void 0===e?"undefined":r(e)))v="number"!=typeof e.length,u=e;else if("string"==typeof e)for(n=y.querySelectorAll(e),a=0;a<n.length;a+=1)u[a]=n[a];return t=v?{}:u,t.each=function(e){return"function"==typeof e&&i(function(t){return e.apply(t,arguments)},u),t},t.first=function(){return d(u.shift())},t.last=function(){return d(u.pop())},t.odd=function(){var e,t=[];for(e=0;e<u.length;e+=2)t.push(u[e]);return d(t)},t.even=function(){var e,t=[];for(e=1;e<u.length;e+=2)t.push(u[e]);return d(t)},t.hide=function(){return i(function(e){e.style.display="none"},u),t},t.show=function(){return i(function(e){l(e)},u),t},t.toggle=function(e){return void 0===e?i(function(e){"none"===s(e,"display")?l(e):e.style.display="none"},u):e?t.show():t.hide(),t},t.remove=function(){return i(function(e){try{e.parentNode.removeChild(e)}catch(e){}},u),d()},t.css=function(e,n){if(e){if(n||""===n)return i(function(t){c(t,e,n)},u),t;if(u[0]){if(u[0].style[o(e)])return u[0].style[o(e)];if(s(u[0],e))return s(u[0],e)}}},t.getClass=function(){if(u[0]&&0<u[0].className.length)return u[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"").replace(/\s+/," ")},t.setClass=function(e){return(e||""===e)&&i(function(t){t.className=e},u),t},t.addClass=function(e){return h(e,"add",u),t},t.removeClass=function(e){return h(e,"remove",u),t},t.toggleClass=function(e,n){return h(e,void 0===n?"toggle":+n?"add":"remove",u),t},t.hasClass=function(e){return h(e,"has",u)},t.html=function(e){return e||""===e?(i(function(t){t.innerHTML=e},u),t):u[0]?u[0].innerHTML:void 0},t.htmlBefore=function(e){return f(e,"before",u),t},t.htmlAfter=function(e){return f(e,"after",u),t},t.htmlAppend=function(e){return f(e,"append",u),t},t.htmlPrepend=function(e){return f(e,"prepend",u),t},t.attr=function(e,n){if(e){if(e=e.toLowerCase(),void 0!==n)return i(function(t){"style"===e?t.style.cssText=n:"class"===e?t.className=n:t.setAttribute(e,n)},u),t;if(u[0])if("style"===e){if(u[0].style.cssText)return u[0].style.cssText}else if("class"===e){if(u[0].className)return u[0].className}else if(u[0].getAttribute(e))return u[0].getAttribute(e)}},t.data=function(e,n){if(e)return t.attr("data-"+e,n)},t.val=function(e){var n,r,o;if(void 0!==e)return i(function(t){switch(t.nodeName){case"SELECT":for(("string"==typeof e||"number"==typeof e)&&(e=[e]),r=0;r<t.length;r+=1)for(o=0;o<e.length;o+=1)if(t[r].selected="",t[r].value===""+e[o]){t[r].selected="selected";break}break;case"INPUT":case"TEXTAREA":case"BUTTON":t.value=e}},u),t;if(u[0])switch(u[0].nodeName){case"SELECT":for(n=[],r=0;r<u[0].length;r+=1)u[0][r].selected&&n.push(u[0][r].value);return 1<n.length?n:n[0];case"INPUT":case"TEXTAREA":case"BUTTON":return u[0].value}},t.checked=function(e){return"boolean"==typeof e?(i(function(t){"INPUT"===t.nodeName&&("checkbox"===t.type||"radio"===t.type)&&(t.checked=e)},u),t):!u[0]||"INPUT"!==u[0].nodeName||"checkbox"!==u[0].type&&"radio"!==u[0].type?void 0:!!u[0].checked},t.on=function(n,r){return(e===g||e===y)&&(u=[e]),i(function(e){y.addEventListener?e.addEventListener(n,r,!1):y.attachEvent&&(e[n+r]=function(){return r.apply(e,arguments)},e.attachEvent("on"+n,e[n+r]))},u),t},t.off=function(n,r){return(e===g||e===y)&&(u=[e]),i(function(e){y.addEventListener?e.removeEventListener(n,r,!1):y.attachEvent&&(e.detachEvent("on"+n,e[n+r]),e[n+r]=null)},u),t},t}var v=[],m=[],p=!1,w=!1,y=document,g=window;y.addEventListener?(y.addEventListener("DOMContentLoaded",t,!1),g.addEventListener("load",n,!1)):y.attachEvent?(y.attachEvent("onreadystatechange",t),g.attachEvent("onload",n)):g.onload=n,d.ajax=function(e){var t=Object.assign({method:"GET",nocache:!0,timeout:5e3,loader:!0,callback:null},e);t.method=t.method.toUpperCase();var n=t.loader?d._loader:function(){},r=t.url,i=t.method,o=null;t.data&&(o=u(t.data)),o&&"GET"===i&&(r+=-1===r.indexOf("?")?"?"+o:"&"+o,o=null);var s=new XMLHttpRequest;if(t.nocache){var a=(+new Date).toString(36);r+=(-1===r.indexOf("?")?"?":"&")+"_="+a}n(!0),s.open(i,r,!0),s.timeout=t.timeout;var c=setTimeout(function(){console.error("XHR timed out."),s.abort(),n(!1)},t.timeout+10);return s.onreadystatechange=function(){4===s.readyState&&(n(!1),t.callback&&t.callback(s.responseText,s.status),clearTimeout(c))},s.setRequestHeader("X-Requested-With","XMLHttpRequest"),"POST"===i&&s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s},d._loader=function(){},d.get=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="GET",d.ajax(n)},d.post=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="POST",d.ajax(n)},d.ready=function(e){if(e){if(p)return e(),d;v.push(e)}},d.loaded=function(e){if(e){if(w)return e(),d;m.push(e)}};var b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};d.htmlEscape=function(e){return(e+"").replace(/[&<>"'`=\/]/g,function(e){return b[e]})},e.exports=d}()},function(e,t,n){"use strict";var r=n(1),i={},o=null;i.show=function(e,t){var n=r(e);n.removeClass("hidden visible"),setTimeout(function(){n.addClass("visible")},1),o=t},i.hide=function(e){var t=r(e);t.removeClass("visible"),setTimeout(function(){t.addClass("hidden"),o&&o()},500)},i.init=function(){r(".Modal").on("click",function(){r(this).hasClass("no-close")||i.hide(this)}),r(".Dialog").on("click",function(e){e.stopImmediatePropagation()}),r(window).on("keydown",function(e){27===e.which&&i.hide(".Modal")})},e.exports=i},function(e,t,n){"use strict";var r,i,o,s=n(1),a=n(2),c={},l=!1,u=function(){clearTimeout(i),clearTimeout(o)};c.show=function(e,t,n){r.toggleClass("error",!0===n),r.html(e),a.show(r),u(),(!t||0>=t)&&(t=2500),i=setTimeout(c.hide,t),l=!1,setTimeout(function(){l=!0},500)},c.hide=function(){var e=s("#notif");e.removeClass("visible"),o=setTimeout(function(){e.addClass("hidden")},250)},c.init=function(){r=s("#notif"),s(document).on("click",function(){l&&c.hide(this)}),r.on("click",function(e){return e.stopImmediatePropagation(),!1}),r.on("mouseenter",function(){u(),r.removeClass("hidden").addClass("visible")})},e.exports=c},function(e,t,n){"use strict";function r(e,n){return n=+n,n=16>n?i[e][n]:t.buildColorTable()[n]}var i=t.themes=[["#111213","#CC0000","#4E9A06","#C4A000","#3465A4","#75507B","#06989A","#D3D7CF","#555753","#EF2929","#8AE234","#FCE94F","#729FCF","#AD7FA8","#34E2E2","#EEEEEC"],["#000000","#aa0000","#00aa00","#aa5500","#0000aa","#aa00aa","#00aaaa","#aaaaaa","#555555","#ff5555","#55ff55","#ffff55","#5555ff","#ff55ff","#55ffff","#ffffff"],["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"],["#000000","#cd0000","#00cd00","#cdcd00","#0000cd","#cd00cd","#00cdcd","#faebd7","#404040","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"],["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"],["#073642","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#eee8d5","#002b36","#cb4b16","#586e75","#657b83","#839496","#6c71c4","#93a1a1","#fdf6e3"],["#000000","#69001A","#117800","#769100","#1A00A6","#8019AB","#289E76","#A4A4A4","#484848","#C54E76","#6DD441","#D2ED46","#765BFF","#DC75FF","#84FAD2","#FFFFFF"],["#000000","#aa0000","#00aa00","#aaaa00","#0000aa","#aa00aa","#00aaaa","#aaaaaa","#000000","#ff0000","#00FF00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"],["#000000","#722640","#0E5940","#808080","#40337F","#E434FE","#1B9AFE","#BFB3FF","#404C00","#E46501","#1BCB01","#BFCC80","#808080","#F1A6BF","#8DD9BF","#ffffff"],["#000000","#8D3E37","#55A049","#AAB95D","#40318D","#80348B","#72C1C8","#D59F74","#8B5429","#B86962","#94E089","#FFFFB2","#8071CC","#AA5FB6","#87D6DD","#ffffff"]];t.fgbgThemes=[["#AAAAAA","#000000"],["#EFF0F1","#31363B"],["#FFFFFF","#000000"],["#00FF00","#000000"],["#E53C00","#000000"],["#FFFFFF","#300A24"],["#839496","#002B36"],["#657B83","#FDF6E3"],["#000000","#FFFFDD"],["#000000","#FFFFFF"]];var o=null;t.buildColorTable=function(){if(null!=o)return o;o=Array(16).fill("rgba(0, 0, 0, 0)");for(var e=0;6>e;e++)for(var t=0;6>t;t++)for(var n=0;6>n;n++){var r=40*e+(e?55:0),i=40*t+(t?55:0),s=40*n+(n?55:0);o.push("rgb("+r+", "+i+", "+s+")")}for(var a=0;24>a;a++){var c=10*a+8;o.push("rgb("+c+", "+c+", "+c+")")}return o},t.SELECTION_FG="#333",t.SELECTION_BG="#b2d7fe",t.themePreview=function(e){document.querySelectorAll("[data-fg]").forEach(function(t){var n=t.dataset.fg;/^\d+$/.test(n)&&(n=r(e,n)),t.style.color=n}),document.querySelectorAll("[data-bg]").forEach(function(t){var n=t.dataset.bg;/^\d+$/.test(n)&&(n=r(e,n)),t.style.backgroundColor=n})}},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,a,c,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(o(n))for(a=Array.prototype.slice.call(arguments,1),l=n.slice(),i=l.length,c=0;c<i;c++)l[c].apply(this,a);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var s=i.get;return void 0===s?void 0:s.call(r)},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(5),u=n(0),h=u.parse2B,f=n(4),d=f.themes,v=function(){function e(t){s(this,e),this.reset(),this.handler=t,this.joinChunks=!0}return c(e,[{key:"reset",value:function(){this.currentSequence=0,this.sequence=""}},{key:"parseSequence",value:function(e){if("["===e[0]){var t=e[e.length-1],n=e.substring(1,e.length-1),r=n?n.split(";").map(function(e){return+e.replace(/\D/g,"")}):[],i=r.length?r[0]:1;if("H"===t)this.handler("set-cursor",(0|r[0])-1,(0|r[1])-1);else if("A"<=t&&"D">=t)this.handler("move-cursor-"+("B">=t?"y":"x"),("B"===t||"C"===t?1:-1)*i);else if("E"===t||"F"===t)this.handler("move-cursor-line",("E"===t?1:-1)*i);else if("G"===t)this.handler("set-cursor-x",i-1);else if("J"===t){var o=r.length?r[0]:2;2===o&&this.handler("clear")}else if("P"===t)this.handler("delete",i);else if("@"===t)this.handler("insert-blanks",i);else if("q"===t)this.handler("set-cursor-style",i);else if("m"===t){if(!r.length||0===r[0])return void this.handler("reset-style");var s=r[0];if(1===s)this.handler("add-attrs",1);else if(2===s)this.handler("add-attrs",2);else if(3===s)this.handler("add-attrs",4);else if(4===s)this.handler("add-attrs",8);else if(5===s||6===s)this.handler("add-attrs",16);else if(7===s)this.handler("add-attrs",-1);else if(9===s)this.handler("add-attrs",64);else if(20===s)this.handler("add-attrs",32);else if(30<=s&&37>=s)this.handler("set-color-fg",s%10);else if(40<=s&&47>=s)this.handler("set-color-bg",s%10);else if(39===s)this.handler("reset-color-fg");else if(49===s)this.handler("reset-color-bg");else if(90<=s&&98>=s)this.handler("set-color-fg",s%10+8);else if(100<=s&&108>=s)this.handler("set-color-bg",s%10+8);else if((38===s||48===s)&&5===r[1]){var a=255&(0|r[2]);38===s&&this.handler("set-color-fg",a),48===s&&this.handler("set-color-bg",a)}}else("h"===t||"l"===t)&&"?25"===n&&("h"===t?this.handler("show-cursor"):"l"===t&&this.handler("hide-cursor"))}}},{key:"write",value:function(e){var t=!0,n=!1,r=void 0;try{for(var i,o=e.toString()[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value,a=s.codePointAt(0);27===a?this.currentSequence=1:1===this.currentSequence&&"["===s?(this.currentSequence=2,this.sequence+="["):this.currentSequence&&s.match(/[\x40-\x7e]/)?(this.parseSequence(this.sequence+s),this.currentSequence=0,this.sequence=""):1<this.currentSequence?this.sequence+=s:1===this.currentSequence?(this.currentSequence=0,this.handler("write",s)):3>a?this.handler("_null"):3===a?this.handler("sigint"):6>=a?this.handler("_null"):7===a?this.handler("bell"):8===a?this.handler("back"):9===a?this.handler("tab"):10===a?this.handler("new-line"):13===a?this.handler("return"):21===a?this.handler("delete-line"):23===a?this.handler("delete-word"):this.handler("write",s)}}catch(e){n=!0,r=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw r}}this.joinChunks||this.reset()}}]),e}(),m=function(e){var t=Math.PI,n=Math.floor,r=Math.sin;return 16+36*n(2.5*r(e)+2.5)+6*n(2.5*r(e+2/3*t)+2.5)+n(2.5*r(e+4/3*t)+2.5)},p=function(){function e(t){var n=this;s(this,e),this.width=80,this.height=25,this.termScreen=t,this.parser=new v(function(){return n.handleParsed.apply(n,arguments)}),this.reset(),this._lastLoad=Date.now(),this.termScreen.load(this.serialize()),window.showPage()}var t=Math.min,n=Math.max;return c(e,[{key:"reset",value:function(){this.style=0,this.cursor={x:0,y:0,style:1,visible:!0},this.trackMouse=!1,this.theme=-1,this.rainbow=!1,this.parser.reset(),this.clear()}},{key:"clear",value:function(){this.screen=[];for(var e=0;e<this.width*this.height;e++)this.screen.push([" ",this.style])}},{key:"scroll",value:function(){this.screen.splice(0,this.width);for(var e=0;e<this.width;e++)this.screen.push([" ",0]);this.cursor.y--}},{key:"newLine",value:function(){++this.cursor.y>=this.height&&this.scroll()}},{key:"writeChar",value:function(e){this.screen[this.cursor.y*this.width+this.cursor.x]=[e,this.style],++this.cursor.x>=this.width&&(this.cursor.x=0,this.newLine())}},{key:"moveBack",value:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,t=0;t<e;t++)0>--this.cursor.x&&(this.cursor.x=0<this.cursor.y?this.width-1:0,this.cursor.y=n(0,this.cursor.y-1))}},{key:"moveForward",value:function(){for(var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,t=0;t<e;t++)++this.cursor.x>=this.width&&(this.cursor.x=0,++this.cursor.y>=this.height&&this.scroll())}},{key:"deleteChar",value:function(){this.moveBack(),this.screen.splice((this.cursor.y+1)*this.width,0,[" ",0]),this.screen.splice(this.cursor.y*this.width+this.cursor.x,1)}},{key:"deleteForward",value:function(e){e=t(this.width,e);for(var n=0;n<e;n++)this.screen.splice((this.cursor.y+1)*this.width,0,[" ",0]);this.screen.splice(this.cursor.y*this.width+this.cursor.x,e)}},{key:"clampCursor",value:function(){0>this.cursor.x&&(this.cursor.x=0),0>this.cursor.y&&(this.cursor.y=0),this.cursor.x>this.width-1&&(this.cursor.x=this.width-1),this.cursor.y>this.height-1&&(this.cursor.y=this.height-1)}},{key:"handleParsed",value:function(e){"write"===e?this.writeChar(1>=arguments.length?void 0:arguments[1]):"delete"===e?this.deleteForward(1>=arguments.length?void 0:arguments[1]):"insert-blanks"===e?this.insertBlanks(1>=arguments.length?void 0:arguments[1]):"clear"===e?this.clear():"bell"===e?this.termScreen.load("B"):"back"===e?this.moveBack():"new-line"===e?this.newLine():"return"===e?this.cursor.x=0:"set-cursor"===e?(this.cursor.x=2>=arguments.length?void 0:arguments[2],this.cursor.y=1>=arguments.length?void 0:arguments[1],this.clampCursor()):"move-cursor-y"===e?(this.cursor.y+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):"move-cursor-x"===e?(this.cursor.x+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):"move-cursor-line"===e?(this.cursor.x=0,this.cursor.y+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):"set-cursor-x"===e?this.cursor.x=1>=arguments.length?void 0:arguments[1]:"set-cursor-style"===e?this.cursor.style=n(0,t(6,1>=arguments.length?void 0:arguments[1])):"reset-style"===e?this.style=0:"add-attrs"===e?this.style|=(1>=arguments.length?void 0:arguments[1])<<16:"set-color-fg"===e?this.style=16777216|4294967040&this.style|(1>=arguments.length?void 0:arguments[1]):"set-color-bg"===e?this.style=33554432|4294902015&this.style|(1>=arguments.length?void 0:arguments[1])<<8:"reset-color-fg"===e?this.style&=4294901504:"reset-color-bg"===e?this.style&=4294770943:"hide-cursor"===e?this.cursor.visible=!1:"show-cursor"===e&&(this.cursor.visible=!0)}},{key:"write",value:function(e){this.parser.write(e),this.scheduleLoad()}},{key:"serialize",value:function(){var e=String.fromCodePoint,t="S";t+=e(this.height+1)+e(this.width+1),t+=e(this.cursor.y+1)+e(this.cursor.x+1);var n=+this.cursor.visible;n|=96*+this.trackMouse,n|=384,n|=this.cursor.style<<9,t+=e(n+1);var r=null,i=0,o=!0,s=!1,a=void 0;try{for(var c,l=this.screen[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var u=c.value,h=u[1];if(this.rainbow){var f=i%this.width,d=Math.floor(i/this.width);h=16777216|4294705152&h|m((f+d)/10+Date.now()/1e3),i++}if(h!==r){var v=255&h,p=255&h>>8,w=65535&h>>16,y=v!=(255&r),g=p!=(255&r>>8),b=w!=(65535&r>>16);y&&g?t+=""+e(1+(65535&h)):y?t+=""+e(v+1):g&&(t+=""+e(p+1)),b&&(t+=""+e(w+1)),r=h}t+=u[0]}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return t}},{key:"scheduleLoad",value:function(){var e=this;clearTimeout(this._scheduledLoad),this._lastLoad<Date.now()-10?(this.termScreen.load(this.serialize(),{theme:this.theme}),this.theme=-1):this._scheduledLoad=setTimeout(function(){e.termScreen.load(e.serialize())},10-this._lastLoad)}},{key:"rainbowTimer",value:function(){var e=this;this.rainbow&&(clearInterval(this._rainbowTimer),this._rainbowTimer=setInterval(function(){e.rainbow&&e.scheduleLoad()},50))}}]),e}(),w=function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"write",value:function(e){this.emit("in",e)}},{key:"destroy",value:function(){this.emit("exit",0)}},{key:"run",value:function(){}}]),t}(l),y={buttons:{1:"",2:"",3:"",4:"",5:function(e,t){t.child&&t.child.destroy();var n="info\r",r=function(){t.write(n[0]),(n=n.substr(1))&&setTimeout(r,100)};setTimeout(r,200)}},mouseReceiver:null},g={clear:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){this.emit("write",""),this.destroy()}}]),t}(w),screenfetch:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e=this,t=("\n ###. ESPTerm Demo\n '###. Hostname: "+window.location.hostname+"\n '###. Shell: ESPTerm Demo Shell\n '###. Resolution: 80x25@"+window.devicePixelRatio+"x\n :###-\n .###'\n .###'\n .###' ###############\n ###' ###############\n ").split("\n").filter(function(e){return e.trim()}),n="",r=0;r<t.length;r++)for(var i=0;80>i;i++)n+=t[r][i]?"[38;5;"+m((i+r)/10)+"m"+t[r][i]:" ";this.emit("write","\r\n[?25l");var o=function(){e.emit("write",n.substr(0,80)),n=n.substr(80),n.length?setTimeout(o,50):(e.emit("write","\r\n[?25h"),e.destroy())};o()}}]),t}(w),"local-echo":function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];t.includes("--suppress-note")||this.emit("write","Note: not all terminal features are supported or and may not work as expected in this demo\r\n")}},{key:"write",value:function(e){this.emit("write",e)}}]),t}(w),info:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=n.includes("--fast");this.showSplash().then(function(){e.printText(i)})}},{key:"showSplash",value:function(){var e=this,t=[""," -#####- -###*..#####- ######-"," -#* -#- .## .##. *#-"," -##### .-###*..#####- *#- -*##*- #*-#--#**#-*##-"," -#* -#-.##. *#- *##@#* ##. -#* *# .#*"," -#####--####- .##. *#- -*#@@- ##. -#* *# .#*"," "].filter(function(e){return e.trim()}),n={" ":-231,".":4,"-":8,"*":17,"#":24},r={" ":" ",".":"░","-":"▒","*":"▓","#":"█"};for(var i in t)79>t[i].length&&(t[i]+=" ".repeat(79-t[i].length));this.emit("write","\r\n".repeat(t.length+1)),this.emit("write","".repeat(t.length)),this.emit("write","[?25l");var o=0,s=0,a=function(t,n){var r=Math.abs,i=t-o,a=n-s;e.emit("write","["+r(i)+(0<i?"C":"D")),e.emit("write","["+r(a)+(0<a?"B":"A")),o=t,s=n},c=function(i,o){if(a(i,o),"@"===t[o][i])e.emit("write","▄\b");else{var s=231+n[t[o][i]],c=r[t[o][i]];e.emit("write","[48;5;"+s+"m[38;5;"+s+"m"+c+"\b")}};return new Promise(function(n){var r=14,i=0,o=function(){for(var s=0;s<t.length;s++){var l=r-s;0<l&&c(l,s)}69>++r?3<=++i?(setTimeout(o,20),i=0):o():(a(0,t.length),e.emit("write","[?25h"),n())};o()})}},{key:"printText",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=[""," ESPTerm is a VT100-like terminal emulator running on the ESP8266 WiFi chip.",""," This is an online demo of the web user interface, simulating a simple "," terminal in your browser.",""," Type ls to list available commands."," Use the links below this screen for a demo of the options and more info.",""];if(e)this.emit("write",t.join("\r\n")+"\r\n"),this.destroy();else{var n=this,r=function(){n.emit("write",t.shift()+"\r\n"),t.length?setTimeout(r,17):n.destroy()};r()}}}]),t}(w),colors:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){this.emit("write","\r\n"),this.emit("write"," ");for(var e=0;16>e;e++)this.emit("write","["+(8>e?"3"+e:"9"+(e-8))+"m"),this.emit("write","foreground-color"[e]+" ");this.emit("write","\r\n ");for(var t=0;16>t;t++)this.emit("write","["+(8>t?"4"+t:"10"+(t-8))+"m ");this.emit("write","\r\n");for(var n=0;6>n;n++){this.emit("write"," ");for(var r=0;6>r;r++){for(var i=0;6>i;i++)this.emit("write","[48;5;"+(16+36*n+6*r+i)+"m ");this.emit("write","")}this.emit("write","\r\n")}this.emit("write"," ");for(var o=0;24>o;o++)this.emit("write","[48;5;"+(232+o)+"m ");this.emit("write","\r\n\n"),this.destroy()}}]),t}(w),ls:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e in this.emit("write","List of demo commands\r\n"),g)"string"!=typeof g[e]&&this.emit("write",e+"\r\n");this.destroy()}}]),t}(w),theme:function(e){function t(e){s(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),c(t,[{key:"run",value:function(){var e=0|+(0>=arguments.length?void 0:arguments[0]),t=d.length;return!arguments.length||!Number.isFinite(e)||0>e||e>=t?(this.emit("write","Usage: theme [0–"+(t-1)+"]\r\n"),void this.destroy()):(this.shell.terminal.theme=e,this.shell.terminal.termScreen.drawnScreenFG=[],this.emit("write",""),void this.destroy())}}]),t}(w),cursor:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.includes("--steady");t.includes("block")?this.emit("write","["+2*r+" q"):t.includes("line")?this.emit("write","["+(3+r)+" q"):t.includes("bar")||t.includes("beam")?this.emit("write","["+(5+r)+" q"):this.emit("write","Usage: cursor [block|line|bar] [--steady]\r\n"),this.destroy()}}]),t}(w),rainbow:function(e){function t(e){s(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),c(t,[{key:"run",value:function(){this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.rainbowTimer(),this.emit("write",""),this.destroy()}}]),t}(w),mouse:function(e){function t(e){s(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),c(t,[{key:"run",value:function(){this.shell.terminal.trackMouse=!0,y.mouseReceiver=this,this.randomData=[],this.highlighted={};for(var e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=0;23>t;t++){for(var n="",r=0;79>r;r++)n+=e[Math.floor(e.length*Math.random())];this.randomData.push(n)}this.scrollOffset=0,this.render()}},{key:"render",value:function(){this.emit("write",""),this.emit("write","Mouse Demo\r\nMouse movement, clicking and scrolling!");for(var e=0;23>e;e++){var t=e+this.scrollOffset;t=(t%this.randomData.length+this.randomData.length)%this.randomData.length;var n=this.randomData[t],r="["+(3+e)+";1H";for(var i in n)this.highlighted[80*(e+2)+ +i]&&(r+=""),r+=n[i],this.highlighted[80*(e+2)+ +i]&&(r+="");this.emit("write",r)}this.mouse&&this.emit("write","["+(this.mouse.y+1)+";"+(this.mouse.x+1)+"H")}},{key:"mouseMove",value:function(e,t){this.mouse={x:e,y:t},this.render()}},{key:"mouseDown",value:function(e,t,n){4===n?this.scrollOffset--:5===n?this.scrollOffset++:this.highlighted[80*t+e]=!this.highlighted[80*t+e],this.render()}},{key:"mouseUp",value:function(){}},{key:"destroy",value:function(){this.shell.terminal.write(""),this.shell.terminal.trackMouse=!1,y.mouseReceiver===this&&(y.mouseReceiver=null),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}}]),t}(w),sudo:function(e){function t(e){s(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),c(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];if(0===n.length)this.emit("write","Usage: sudo <command>\r\n"),this.destroy();else if(4===n.length&&"make me a sandwich"===n.join(" ").toLowerCase()){var i="",o="",s="",a="";this.emit("write"," _.---._\r\n _.-~ ~-._\r\n _.-~ ~-._\r\n _.-~ ~---._\r\n _.-~ ~\\\r\n .-~ _.;\r\n :-._ _.-~ ./\r\n `-._~-._ _..__.-~ _.-~\r\n "+s+"/ "+i+"~-._~-._ / .__..--"+s+"~-"+o+"---._\r\n"+s+" \\_____(_"+i+";-._\\. _.-~_/"+s+" ~)"+o+".. . \\\r\n"+o+" /(_____ "+i+"\\`--...--~_.-~"+s+"______..-+"+o+"_______)\r\n"+o+" .(_________/"+i+"`--...--~/"+o+" _/ "+a+" "+i+"/\\\r\n"+i+" /-._"+a+" \\_ "+o+"(___./_..-~"+a+"__....."+i+"__..-~./\r\n"+i+" `-._~-._"+a+" ~\\--------~ .-~"+i+"_..__.-~ _.-~\r\n"+i+" ~-._~-._ "+a+"~---------` "+i+"/ .__..--~\r\n"+i+" ~-._\\. _.-~_/\r\n"+i+" \\`--...--~_.-~\r\n"+i+" `--...--~\r\n"),this.destroy()}else{var c=n.shift();if(this.shell.index[c]){var l=this.shell.index[c];if(l instanceof Function){var u=new l(this),h=function(t){return e.emit("write",t)};u.on("write",h),u.on("exit",function(){u.removeListener("write",h),e.destroy()}),u.run.apply(u,n)}else this.emit("write",l),this.destroy()}else this.emit("write","sudo: "+c+": command not found\r\n"),this.destroy()}}}]),t}(w),make:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];0===t.length?this.emit("write","make: *** No targets specified. Stop.\r\n"):3===t.length&&"me a sandwich"===t.join(" ").toLowerCase()?this.emit("write","make: me a sandwich : Permission denied\r\n"):this.emit("write","make: *** No rule to make target '"+t.join(" ").toLowerCase()+"'. Stop.\r\n"),this.destroy()}}]),t}(w),pwd:"/this/is/a/demo\r\n",cd:"No directories to change to\r\n",whoami:window.navigator.userAgent+"\r\n",hostname:""+window.location.hostname,uname:"ESPTerm Demo\r\n",mkdir:"Did not create a directory because this is a demo.\r\n",rm:"Did not delete anything because this is a demo.\r\n",cp:"Nothing to copy because this is a demo.\r\n",mv:"Nothing to move because this is a demo.\r\n",ln:"Nothing to link because this is a demo.\r\n",touch:"Nothing to touch\r\n",exit:"Nowhere to go\r\n",github:function(e){function t(){return s(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),c(t,[{key:"run",value:function(){window.open("https://github.com/espterm/espterm-firmware"),this.destroy()}}]),t}(w)},b=function(){function e(t,n){var r=this;s(this,e),this.terminal=t,this.terminal.reset(),this.parser=new v(function(){return r.handleParsed.apply(r,arguments)}),this.history=[],this.historyIndex=0,this.cursorPos=0,this.child=null,this.index=g,n?this.run("info"):this.prompt()}return c(e,[{key:"write",value:function(e){this.child?3===e.codePointAt(0)?this.child.destroy():this.child.write(e):this.parser.write(e)}},{key:"prompt",value:function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];0!==this.terminal.cursor.x&&this.terminal.write("⏎\r\n"),this.terminal.write("demosh "),e||this.terminal.write(""),this.terminal.write("$ "),this.history.unshift(""),this.cursorPos=0}},{key:"copyFromHistoryIndex",value:function(){if(this.historyIndex){var e=this.history[this.historyIndex];this.history[0]=e,this.historyIndex=0}}},{key:"handleParsed",value:function(e){if(this.terminal.write("\b".repeat(this.cursorPos)),"write"===e)this.copyFromHistoryIndex(),this.history[0]=this.history[0].substr(0,this.cursorPos)+(1>=arguments.length?void 0:arguments[1])+this.history[0].substr(this.cursorPos),this.cursorPos++;else if("back"===e)this.copyFromHistoryIndex(),this.history[0]=this.history[0].substr(0,this.cursorPos-1)+this.history[0].substr(this.cursorPos),0>--this.cursorPos&&(this.cursorPos=0);else if("tab"===e)console.warn("TAB not implemented");else if("move-cursor-x"===e)this.cursorPos=Math.max(0,Math.min(this.history[this.historyIndex].length,this.cursorPos+(1>=arguments.length?void 0:arguments[1])));else if("delete-line"===e)this.copyFromHistoryIndex(),this.history[0]="",this.cursorPos=0;else if("delete-word"===e){this.copyFromHistoryIndex();var t=this.history[0].substr(0,this.cursorPos).split(" ");t.pop(),this.history[0]=t.join(" ")+this.history[0].substr(this.cursorPos),this.cursorPos=t.join(" ").length}else"move-cursor-y"===e&&(this.historyIndex-=1>=arguments.length?void 0:arguments[1],0>this.historyIndex&&(this.historyIndex=0),this.historyIndex>=this.history.length&&(this.historyIndex=this.history.length-1),this.cursorPos=this.history[this.historyIndex].length);this.terminal.write(this.history[this.historyIndex]),this.terminal.write("\b".repeat(this.history[this.historyIndex].length)),this.terminal.moveForward(this.cursorPos),this.terminal.write(""),"return"===e&&(this.terminal.write("\r\n"),this.parse(this.history[this.historyIndex]))}},{key:"parse",value:function(e){"help"===e&&(e="info"),this.run(e)}},{key:"run",value:function(e){var t=[""],n=!1,r=!0,i=!1,o=void 0;try{for(var s,a=e.trim()[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var c=s.value;n&&c!==n?t[t.length-1]+=c:n?n=!1:'"'===c||"'"===c?n=c:c.match(/\s/)?t[t.length-1]&&t.push(""):t[t.length-1]+=c}}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}var l=t.shift();l in this.index?this.spawn(l,t):(this.terminal.write("demosh: Unknown command: "+l+"\r\n"),this.prompt(!1))}},{key:"spawn",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],i=this.index[e];if(i instanceof Function){var o;this.child=new i(this);var s=function(e){return t.terminal.write(e)};this.child.on("write",s),this.child.on("exit",function(e){t.child&&t.child.removeListener("write",s),t.child=null,t.prompt(!e)}),(o=this.child).run.apply(o,r(n))}else this.terminal.write(i),this.prompt()}}]),e}();window.demoInterface=e.exports={input:function(e){var t=e[0],n=e.substr(1);if("s"===t)this.shell.write(n);else if("b"===t){var r=n.charCodeAt(0),i=y.buttons[r];i&&("string"==typeof i?this.shell.write(i):i instanceof Function&&i(this.terminal,this.shell))}else if("m"===t||"p"===t||"r"===t){var o=h(n,0),s=h(n,2),a=h(n,4),c=h(n,6);y.mouseReceiver&&("m"===t?y.mouseReceiver.mouseMove(s,o,a,c):"p"===t?y.mouseReceiver.mouseDown(s,o,a,c):"r"===t&&y.mouseReceiver.mouseUp(s,o,a,c))}},didInit:!1,init:function(e){this.didInit||(this.didInit=!0,this.terminal=new p(e),this.shell=new b(this.terminal,!0))}}},function(e,t,n){"use strict";n(8),n(2),n(3),n(9);try{n(6)}catch(e){}n(10);var r=n(1),i=n(0),o=i.qs;window.termInit=n(12),window.$=r,window.qs=o,window.themes=n(4)},function(e,t,n){"use strict";String.fromCodePoint||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=String.fromCharCode,n=Math.floor,r=function(){var e,r,i=[],o=-1,s=arguments.length;if(!s)return"";for(var a="";++o<s;){var c=+arguments[o];if(!isFinite(c)||0>c||1114111<c||n(c)!=c)throw RangeError("Invalid code point: "+c);65535>=c?i.push(c):(c-=65536,e=55296+(c>>10),r=c%1024+56320,i.push(e,r)),(o+1==s||i.length>16384)&&(a+=t.apply(null,i),i.length=0)}return a};e?e(String,"fromCodePoint",{value:r,configurable:!0,writable:!0}):String.fromCodePoint=r}()},function(e,t,n){"use strict";function r(){f=!0,i("#content").addClass("load")}var i=n(1),o=n(0),s=o.mk,a=o.qs,c=o.qsa,l=o.cr,u=n(2),h=n(3);i.ready(function(){function e(){i("#menu").toggleClass("expanded")}i("#brand").on("click",e).on("keypress",l(e)),i(".Row.checkbox").forEach(function(e){var t=e.querySelector("input"),n=e.querySelector(".box");i(n).toggleClass("checked",t.value);var r=function(){t.value=1-t.value,i(n).toggleClass("checked",t.value)};i(e).on("click",r).on("keypress",l(r))}),i(".Box.mobcol,.Box.fold").forEach(function(e){var t=e.querySelector("h2"),n=function(){i(e).hasClass("d-expanded")?i(e).removeClass("d-expanded"):i(e).toggleClass("expanded")};i(t).on("click",n).on("keypress",l(n))}),i("form").forEach(function(e){i(e).on("keypress",function(t){(10===t.keyCode||13===t.keyCode)&&t.ctrlKey&&e.submit()})}),setInterval(function(){i(".anim-dots").each(function(e){var t=i(e),n=t.html()+".";5===n.length&&(n="."),t.html(n)})},1e3),i("input[type=number]").on("mousewheel",function(e){var t=Number.isFinite,n=i(this),r=+n.val();isNaN(r)&&(r=1);var o=+(n.attr("step")||1),s=+n.attr("min"),a=+n.attr("max");if(0<e.wheelDelta?r+=o:r-=o,t(s)||(r=Math.max(r,+s)),t(a)||(r=Math.min(r,+a)),n.val(r),"createEvent"in document){var c=document.createEvent("HTMLEvents");c.initEvent("change",!1,!0),n[0].dispatchEvent(c)}else n[0].fireEvent("onchange");e.preventDefault()});var t=window.location.search.indexOf("err=");if(-1!==t&&a(".Box.errors")){var n=decodeURIComponent(window.location.search.substr(t+4)).split(","),r=[];n.forEach(function(e){var t=c('label[for="'+e+'"]');if(t)for(var n=0;n<t.length;n++){var i=t[n];i.classList.add("error"),0===n&&r.push(i.childNodes[0].textContent.trim().replace(/: ?$/,""))}else r.push(e)}),a(".Box.errors .list").innerHTML=r.join(", "),a(".Box.errors").classList.remove("hidden")}var o=window.location.search.indexOf("msg=");if(-1!==o&&a(".Box.message")){var s=decodeURIComponent(window.location.search.substr(o+4)),f=a(".Box.message");f.innerHTML=s,f.classList.remove("hidden"),setTimeout(function(){f.classList.add("hiding"),setTimeout(function(){f.classList.add("hidden")},1e3)},2e3)}if(u.init(),h.init(),550<window.innerWidth){i(".Box h2").forEach(function(e){e.removeAttribute("tabindex")});var d=a("#brand");d&&d.addEventListener("click",function(){window.location.href="/"})}}),i._loader=function(e){i("#loader").toggleClass("show",e)};var f=!1;window.showPage=r,i.ready(function(){!0===window.noAutoShow?setTimeout(function(){if(!f){var e=s("P");e.id="load-failed",e.innerHTML='Server connection failed! Trying again<span class="anim-dots" style="width:1.5em;text-align:left;display:inline-block">.</span>',a("#screen").appendChild(e),r()}},2e3):setTimeout(function(){r()},1)})},function(e,t,n){"use strict";var r=n(1),i=n(0),o=i.mk,s=i.bool,a=n(11);!function(e){function t(e){return"+"+(.25*e.value).toFixed(2)+" dBm"}function n(e,t,n){r("#sta_ssid").val(e),r("#sta_password").val(t),r("#sta-nw").toggleClass("hidden",0===e.length),r("#sta-nw-nil").toggleClass("hidden",0<e.length),r("#sta-nw .essid").html(r.htmlEscape(e));var i=!t||0===t.length;r("#sta-nw .passwd").toggleClass("hidden",i),r("#sta-nw .nopasswd").toggleClass("hidden",!i),r("#sta-nw .ip").html(0<n.length?a("wifi.connected_ip_is")+n:a("wifi.not_conn"))}function i(e,t){if(200!==t)return void l(5e3);try{e=JSON.parse(e)}catch(e){return console.log(e),void l(5e3)}var i=!s(e.result.inProgress)&&0<e.result.APs.length;if(l(i?15e3:1e3),!!i){var c=r("#ap-list");r("#ap-list .AP").remove(),c.toggleClass("hidden",!i),r("#ap-loader").toggleClass("hidden",i),e.result.APs.sort(function(e,t){return t.rssi-e.rssi}).forEach(function(e){if(e.enc=parseInt(e.enc),!(4<e.enc)){var t=o("div"),i=r(t).data("ssid",e.essid).data("pwd",e.enc).attr("tabindex",0).addClass("AP");e.essid===u&&i.addClass("selected");var s=o("div"),l=r.htmlEscape(e.essid);r(s).addClass("inner").htmlAppend('<div class="rssi">'+e.rssi_perc+"</div>").htmlAppend('<div class="essid" title="'+l+'">'+l+"</div>").htmlAppend('<div class="auth">'+h[e.enc]+"</div>"),i.on("click",function(){var e=r(this),t=e.data("ssid"),i="";+e.data("pwd")&&!(i=window.prompt(a("wifi.enter_passwd").replace(":ssid:",t)))||(r("#sta_password").val(i),r("#sta_ssid").val(t),n(t,i,""))}),t.appendChild(s),c[0].appendChild(t)}})}}function c(){window._demo?i(window._demo_aps,200):r.get("http://"+window._root+"/cfg/wifi/scan",i)}function l(e){setTimeout(c,e)}var u,h=["Open","WEP","WPA","WPA2","WPA/WPA2"];e.init=function(e){r(".Row.range").forEach(function(e){var n=e.querySelector("input"),i=e.querySelector(".x-disp1"),o=e.querySelector(".x-disp2"),s=t(n);r(i).html(s),r(o).html(s),r(n).on("input",function(){s=t(n),r(i).html(s),r(o).html(s)})}),r("#forget-sta").on("click",function(){return n("","",""),!1}),n(e.sta_ssid,e.sta_password,e.sta_active_ip),u=e.sta_active_ssid},e.startScanning=function(){r("#ap-loader").removeClass("hidden"),r("#ap-scan").addClass("hidden"),r("#ap-loader .anim-dots").html("."),c()}}(window.WiFi={})},function(e,t,n){"use strict";var r={"wifi.connected_ip_is":"Connected, IP is ","wifi.not_conn":"Not connected.","wifi.enter_passwd":'Enter password for ":ssid:"'};e.exports=function(e){return r[e]||"?"+e+"?"}},function(e,t,n){"use strict";var r=n(0),i=r.qs,o=r.mk,s=n(3),a=n(13),c=n(16),l=n(17),u=n(18),h=n(19),f=n(20);e.exports=function(e){var t=new a,n=new c(t),r=l(n,t),d=u(n,r,t);t.input=r,t.conn=n,r.termUpload=d;var v=null,m=function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:250;clearTimeout(v),v=setTimeout(function(){t.window.statusScreen=e},n)};n.on("open",function(){m({title:"Connecting",loading:!0})}),n.on("connect",function(){m({title:"Waiting for content",loading:!0})}),n.on("load",function(){clearTimeout(v),t.window.statusScreen&&(t.window.statusScreen=null)}),n.on("disconnect",function(){m({title:"Disconnected"}),t.screen=[],t.screenFG=[],t.screenBG=[],t.screenAttrs=[]}),n.on("silence",function(){m({title:"Waiting for server",loading:!0},0)}),n.on("ping-success",function(){m({title:"Re-connecting",loading:!0},0)}),n.init(),r.init(e),d.init(),s.init(),window.onerror=function(e,t,n,r){return s.show("<b>JS ERROR!</b><br>"+e+"<br>at "+t+":"+n+":"+r,1e4,!0),!1},i("#screen").appendChild(t.canvas),t.load(e.labels,e),h(t,r),f&&f(t);var p=!1,w=!1,y=function(){p?(t.window.fitIntoWidth=window.screen.width,t.window.fitIntoHeight=window.screen.height):(t.window.fitIntoWidth=w?window.innerWidth-20:0,t.window.fitIntoHeight=w?window.innerHeight:0)};y(),window.addEventListener("resize",y);var g=function(){w=!w;var e=i("#resize-button-icon");w?(e.classList.remove("icn-resize-small"),e.classList.add("icn-resize-full")):(e.classList.remove("icn-resize-full"),e.classList.add("icn-resize-small")),y()};if(i("#term-fit-screen").addEventListener("click",function(){return g(),!1}),window.Element.prototype.requestFullscreen||window.Element.prototype.webkitRequestFullscreen){setInterval(function(){p&&(window.innerWidth!==window.screen.width||window.innerHeight!==window.screen.height)&&(p=!1,y())},500);var b=o("a");b.href="#",b.addEventListener("click",function(e){e.preventDefault(),p=!0,y(),t.updateSize(),t.canvas.requestFullscreen?t.canvas.requestFullscreen():t.canvas.webkitRequestFullscreen()});var _=o("i");_.classList.add("icn-resize-full"),b.appendChild(_);var k=o("span");k.textContent="Fullscreen",b.appendChild(k),i("#term-nav").insertBefore(b,i("#term-nav").firstChild)}window.termScreen=t,window.conn=n,window.input=r,window.termUpl=d}},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(5),l=n(1),u=n(0),h=u.mk,f=u.qs,d=n(3),v=n(14),m=n(15);e.exports=function(e){function t(){i(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.canvas=h("canvas"),e.ctx=e.canvas.getContext("2d"),e.parser=new v(e),e.renderer=new m(e),e._debug=null,"AudioContext"in window||"webkitAudioContext"in window?e.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn("No AudioContext!"),e.input=new Proxy({},{get:function(){return function(){return console.warn("TermScreen#input not set!")}}}),e.conn=new Proxy({},{get:function(){return function(){return console.warn("TermScreen#conn not set!")}},set:function(){return function(){return console.warn("TermScreen#conn not set!")}}}),e.cursor={x:0,y:0,blinking:!0,visible:!0,hanging:!1,style:"block"},e._window={width:0,height:0,devicePixelRatio:1,fontFamily:'"DejaVu Sans Mono", "Liberation Mono", "Inconsolata", "Menlo", monospace',fontSize:20,gridScaleX:1,gridScaleY:1.2,fitIntoWidth:0,fitIntoHeight:0,debug:!1,graphics:0,statusScreen:null},e._windowScale=1,e.windowState={width:0,height:0,devicePixelRatio:0,gridScaleX:0,gridScaleY:0,fontFamily:"",fontSize:0,fitIntoWidth:0,fitIntoHeight:0},e.selection={selectable:!0,start:[0,0],end:[0,0]},e.mouseMode={clicks:!1,movement:!1};var n=e;e.window=new Proxy(e._window,{set:function(e,t,r){return e[t]=r,n.scheduleSizeUpdate(),n.renderer.scheduleDraw("window:"+t+"="+r),n.emit("update-window:"+t,r),!0}}),e.bracketedPaste=!1,e.blinkingCellCount=0,e.reverseVideo=!1,e.screen=[],e.screenFG=[],e.screenBG=[],e.screenAttrs=[];var s=!1,a=function(t,n){s||(s=!0,e.selection.start=e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-start"))},c=function(t,n){s&&(e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-move"))},u=function(t,n){s&&(s=!1,e.selection.end=e.screenToGrid(t,n,!0),e.renderer.scheduleDraw("select-end"),Object.assign(e.selection,e.getNormalizedSelection()))};e.canvas.addEventListener("mousedown",function(t){if((e.selection.selectable||t.altKey)&&0===t.button)a(t.offsetX,t.offsetY);else{var n;(n=e.input).onMouseDown.apply(n,r(e.screenToGrid(t.offsetX,t.offsetY)).concat([t.button+1]))}}),window.addEventListener("mousemove",function(e){c(e.offsetX,e.offsetY)}),window.addEventListener("mouseup",function(e){u(e.offsetX,e.offsetY)});var d=null,p=0,w=!1,y=function(t){var n=e.canvas.getBoundingClientRect();return[t.clientX-n.left,t.clientY-n.top]};return e.canvas.addEventListener("touchstart",function(e){d=y(e.touches[0]),w=!1,p=Date.now()},{passive:!0}),e.canvas.addEventListener("touchmove",function(e){d=y(e.touches[0]),s||0!=w?s&&(e.preventDefault(),c.apply(void 0,r(d))):p<Date.now()-500&&a.apply(void 0,r(d)),w=!0}),e.canvas.addEventListener("touchend",function(t){if(t.touches[0]&&(d=y(t.touches[0])),s){t.preventDefault(),u.apply(void 0,r(d));var n=f("#touch-select-menu");n.classList.add("open");var i=n.getBoundingClientRect(),o=e.gridToScreen((e.selection.start[0]+e.selection.end[0])/2,e.selection.start[1]-1);o[0]-=i.width/2,o[1]-=i.height/2,n.style.transform="translate("+o[0]+"px, "+o[1]+"px)"}w||e.emit("tap",Object.assign(t,{x:d[0],y:d[1]})),d=null}),e.on("tap",function(t){e.selection.start[0]!==e.selection.end[0]||e.selection.start[1]!==e.selection.end[1]?(e.selection.start=e.selection.end=[0,0],f("#touch-select-menu").classList.remove("open"),e.renderer.scheduleDraw("select-reset")):(t.preventDefault(),e.emit("open-soft-keyboard"))}),l.ready(function(){var t=f("#touch-select-copy-btn");t&&t.addEventListener("click",function(){e.copySelectionToClipboard()})}),e.canvas.addEventListener("mousemove",function(t){if(!s){var n;(n=e.input).onMouseMove.apply(n,r(e.screenToGrid(t.offsetX,t.offsetY)))}}),e.canvas.addEventListener("mouseup",function(t){if(!s){var n;(n=e.input).onMouseUp.apply(n,r(e.screenToGrid(t.offsetX,t.offsetY)).concat([t.button+1]))}}),e.canvas.addEventListener("wheel",function(t){if(e.mouseMode.clicks){var n;(n=e.input).onMouseWheel.apply(n,r(e.screenToGrid(t.offsetX,t.offsetY)).concat([0<t.deltaY?1:-1])),t.preventDefault()}}),e.canvas.addEventListener("contextmenu",function(t){e.mouseMode.clicks&&t.preventDefault(),u(t.offsetX,t.offsetY)}),e}var n=Math.floor;return s(t,e),a(t,[{key:"scheduleSizeUpdate",value:function(){var e=this;clearTimeout(this._scheduledSizeUpdate),this._scheduledSizeUpdate=setTimeout(function(){return e.updateSize()},1)}},{key:"getFont",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return(e.style||"normal")+" normal "+(e.weight||"normal")+" "+this.window.fontSize+"px "+this.window.fontFamily}},{key:"screenToGrid",value:function(e,t){var r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=this.getCellSize();return[n((e+(r?i.width/2:0))/i.width),n(t/i.height)]}},{key:"gridToScreen",value:function(e,t){var n=this,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=this.getCellSize();return[e*i.width,t*i.height].map(function(e){return r?e*n._windowScale:e})}},{key:"getCharSize",value:function(){return this.ctx.font=this.getFont(),{width:n(this.ctx.measureText(" ").width),height:this.window.fontSize}}},{key:"getCellSize",value:function(){var e=Math.ceil,t=this.getCharSize();return{width:e(t.width*this.window.gridScaleX),height:e(t.height*this.window.gridScaleY)}}},{key:"updateSize",value:function(){var e=Math.round;this._window.devicePixelRatio=e(this._windowScale*(window.devicePixelRatio||1)*2)/2;var t=!1;for(var n in this.windowState)this.windowState.hasOwnProperty(n)&&this.windowState[n]!==this.window[n]&&(t=!0,this.windowState[n]=this.window[n]);if(t){var r=this.window,i=r.width,o=r.height,s=r.fitIntoWidth,a=r.fitIntoHeight,c=this.getCellSize(),l=i*c.width,u=o*c.height;if(s&&a){var h=l/u;h<s/a?(u=a,l=u*h):(l=s,u=l/h)}else s?(u=s/(l/u),l=s):a&&(l=a*(l/u),u=a);this._windowScale=l/(i*c.width);var f=this._window.devicePixelRatio=e(this._windowScale*(window.devicePixelRatio||1)*2)/2;this.canvas.width=i*f*c.width,this.canvas.style.width=l+"px",this.canvas.height=o*f*c.height,this.canvas.style.height=u+"px",this.renderer.resetDrawn(),this.renderer.draw("update-size")}}},{key:"getNormalizedSelection",value:function(){var e=this.selection,t=e.start,n=e.end;if(t[1]>n[1]||t[1]===n[1]&&t[0]>n[0]){var r=[n,t];t=r[0],n=r[1]}return{start:t,end:n}}},{key:"isInSelection",value:function(e,t){var n=this.getNormalizedSelection(),r=n.start,i=n.end,o=r[0]<=e,s=e<i[0],a=t===r[1],c=t===i[1];return a&&c?o&&s:a?o:c?s:r[1]<t&&t<i[1]}},{key:"getSelectedText",value:function(){for(var e=this.window.width*this.window.height,t=[],r=-1,i=0;i<e;i++){var o=i%this.window.width,s=n(i/this.window.width);this.isInSelection(o,s)&&(r!==s&&(r=s,t.push("")),t[t.length-1]+=this.screen[i])}return t.join("\n")}},{key:"copySelectionToClipboard",value:function(){var e=this.getSelectedText();if(e){var t=h("textarea");document.body.appendChild(t),t.value=e,t.select(),document.execCommand("copy")?d.show("Copied to clipboard"):d.show("Failed to copy"),document.body.removeChild(t)}}},{key:"showNotification",value:function(e){if(console.info("Notification: "+e),window.Notification&&"granted"===window.Notification.permission){new window.Notification("ESPTerm",{body:e}).addEventListener("click",function(){return window.focus()})}else window.Notification&&"denied"!==window.Notification.permission?window.Notification.requestPermission():d.show(e)}},{key:"beep",value:function(){var e=Math.pow,t=this.audioCtx;if(t&&!(this._lastBeep&&this._lastBeep>Date.now()-50)){if(this._lastBeep=Date.now(),!this._convolver){this._convolver=t.createConvolver();for(var n=.8*t.sampleRate,r=t.createBuffer(2,n,t.sampleRate),i=0;i<n;i++)r.getChannelData(0)[i]=e(1-i/n,7+Math.random()),r.getChannelData(1)[i]=e(1-i/n,7+Math.random());this._convolver.buffer=r,this._convolver.connect(t.destination)}var o=t.createOscillator(),s=t.createGain();o.connect(s),s.gain.value=4,o.frequency.value=750,o.type="sine";var a=t.createOscillator(),c=t.createGain();a.connect(c),c.gain.value=2,a.frequency.value=400,a.type="sine",s.connect(this._convolver),c.connect(this._convolver);var l=t.currentTime;o.start(),o.stop(l+.5),a.start(l+.05),a.stop(l+.8);var u=function(){t.currentTime<l+.8&&window.requestAnimationFrame(u),s.gain.value*=.8,c.gain.value*=.8};u()}}},{key:"load",value:function(){var e;(e=this.parser).load.apply(e,arguments)}}]),t}(c)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(1),s=n(0),a=s.qs,c=n(4),l=c.themes;e.exports=function(){function e(t){r(this,e),this.screen=t,this.contentLoaded=!1}return i(e,[{key:"loadContent",value:function(e){var t=this,n=0,r=Array.from?Array.from(e):e.split("");if(!this.contentLoaded){var i=a("#load-failed");i&&i.parentNode.removeChild(i),this.contentLoaded=!0}var s=r[n++].codePointAt(0)-1,c=r[n++].codePointAt(0)-1,l=this.screen.window.height!==s||this.screen.window.width!==c;this.screen.window.height=s,this.screen.window.width=c;var u=r[n++].codePointAt(0)-1,h=r[n++].codePointAt(0)-1,f=h!==this.screen.cursor.x||u!==this.screen.cursor.y;this.screen.cursor.x=h,this.screen.cursor.y=u,f&&(this.screen.renderer.resetCursorBlink(),this.screen.emit("cursor-moved"));var d=r[n++].codePointAt(0)-1;this.screen.cursor.visible=!!(1&d),this.screen.cursor.hanging=!!(2&d),this.screen.input.setAlts(!!(4&d),!!(8&d),!!(16&d),!!(4096&d));var v=!!(32&d),m=!!(64&d),p=7&d>>9;0<p&&p--;var w=p>>1,y=!(1&p);0==w?this.screen.cursor.style="block":1==w?this.screen.cursor.style="line":2==w&&(this.screen.cursor.style="bar"),this.screen.cursor.blinking!==y&&(this.screen.cursor.blinking=y,this.screen.renderer.resetCursorBlink()),this.screen.input.setMouseMode(v,m),this.screen.selection.selectable=!v&&!m,o(this.screen.canvas).toggleClass("selectable",this.screen.selection.selectable),this.screen.mouseMode={clicks:v,movement:m},o(".x-term-conf-btn").toggleClass("hidden",!(256&d)),o("#action-buttons").toggleClass("hidden",!(128&d)),this.screen.bracketedPaste=!!(8192&d),this.screen.reverseVideo=!!(16384&d);var g=7,b=0,_=0,k=0,C=" ",x=this.screen.window.width*this.screen.window.height;l&&(this.screen.updateSize(),this.screen.blinkingCellCount=0,this.screen.screen=Array(x).fill(" "),this.screen.screenFG=Array(x).fill(" "),this.screen.screenBG=Array(x).fill(" "),this.screen.screenAttrs=Array(x).fill(0));for(var S=function(){var e=_,n=256&_,r=512&_;0!=(16&e)&&(" "==C&&0==(200&e)||g==b&&n&&r)&&(e^=16),(16&t.screen.screenAttrs[k])!=(16&e)&&(16&e?t.screen.blinkingCellCount++:t.screen.blinkingCellCount--),t.screen.screen[k]=C,t.screen.screenFG[k]=g,t.screen.screenBG[k]=b,t.screen.screenAttrs[k]=e};n<r.length&&k<x;){var T=r[n++],E=T.codePointAt(0),A=void 0;switch(E){case 2:for(var F=r[n++].codePointAt(0)-1,L=0;L<F&&(S(),!(++k>x));L++);break;case 3:A=r[n++].codePointAt(0)-1,g=255&A,b=255&A>>8;break;case 4:A=r[n++].codePointAt(0)-1,_=65535&A;break;case 5:A=r[n++].codePointAt(0)-1,g=255&A;break;case 6:A=r[n++].codePointAt(0)-1,b=255&A;break;default:32>E&&(T="<EFBFBD>"),C=T,S(),k++}}this.screen.window.debug&&console.log("Blinky cells: "+this.screen.blinkingCellCount),this.screen.renderer.scheduleDraw("load",16),this.screen.conn.emit("load")}},{key:"loadLabels",value:function(e){var t=e.split(""),n=t[0];a("#screen-title").textContent=n,0===n.length&&(n="Terminal"),a("title").textContent=n+" :: ESPTerm",o("#action-buttons button").forEach(function(e,n){var r=t[n+1].trim();e.innerHTML=r?o.htmlEscape(r):"&nbsp;",e.style.opacity=r?1:.2})}},{key:"load",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=e.substr(1);switch(t&&(void 0!==t.defaultFg&&void 0!==t.defaultBg&&this.screen.renderer.setDefaultColors(t.defaultFg,t.defaultBg),void 0!==t.theme&&0<=t.theme&&t.theme<l.length&&(this.screen.renderer.palette=l[t.theme])),e[0]){case"S":this.loadContent(n);break;case"T":this.loadLabels(n);break;case"B":this.screen.beep();break;case"G":this.screen.showNotification(n);break;default:console.warn("Bad data message type; ignoring.\n"+JSON.stringify(e))}}}]),e}()},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(4),s=o.themes,a=o.buildColorTable,c=o.SELECTION_FG,l=o.SELECTION_BG,u={C:"ℭ",H:"ℌ",I:"ℑ",R:"ℜ",Z:"ℨ"};e.exports=function(){function e(t){r(this,e),this.screen=t,this.ctx=t.ctx,this._palette=null,this.defaultBgNum=0,this.defaultFgNum=7,this.colorTable256=a(),this.resetDrawn(),this.blinkStyleOn=!1,this.blinkInterval=null,this.cursorBlinkOn=!1,this.cursorBlinkInterval=null,this.resetBlink(),this.resetCursorBlink()}return i(e,[{key:"resetDrawn",value:function(){this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.drawnCursor=[-1,-1,""]}},{key:"setDefaultColors",value:function(e,t){this.defaultFgNum=e,this.defaultBgNum=t,this.resetDrawn(),this.scheduleDraw("defaultColors")}},{key:"scheduleDraw",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;clearTimeout(this._scheduledDraw),this._scheduledDraw=setTimeout(function(){return t.draw(e)},n)}},{key:"getColor",value:function(e){if(16>e&&e in this.palette)return this.palette[e];if(-1===e)return c;if(-2===e)return l;if(15<e&&256>e)return this.colorTable256[e];if(255<e){e-=256;return"rgb("+(255&e>>16)+", "+(255&e>>8)+", "+(255&e)+")"}return 0==Date.now()/1e3%2?"#f0f":"#0f0"}},{key:"resetCursorBlink",value:function(){var e=this;this.cursorBlinkOn=!0,clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=setInterval(function(){e.cursorBlinkOn=!e.screen.cursor.blinking||!e.cursorBlinkOn,e.screen.cursor.blinking&&e.scheduleDraw("cursor-blink")},500)}},{key:"resetBlink",value:function(){var e=this;this.blinkStyleOn=!0,clearInterval(this.blinkInterval);var t=0;this.blinkInterval=setInterval(function(){0>=e.screen.blinkingCellCount||(t++,4<=t&&e.blinkStyleOn?(e.blinkStyleOn=!1,t=0,e.scheduleDraw("blink-style")):1<=t&&!e.blinkStyleOn&&(e.blinkStyleOn=!0,t=0,e.scheduleDraw("blink-style")))},200)}},{key:"drawBackground",value:function(e){var t=e.x,n=e.y,r=e.cellWidth,i=e.cellHeight,o=e.bg,s=this.ctx;s.fillStyle=this.getColor(o),s.clearRect(t*r,n*i,r,i),s.fillRect(t*r,n*i,r,i)}},{key:"drawCharacter",value:function(t){var n=Math.round,r=t.x,i=t.y,o=t.charSize,s=t.cellWidth,a=t.cellHeight,c=t.text,l=t.fg,u=t.attrs;if(c){var h=this.ctx,f=!1,d=!1,v=!1;2&u&&(h.globalAlpha=.5),8&u&&(f=!0),32&u&&(c=e.alphaToFraktur(c)),64&u&&(d=!0),128&u&&(v=!0),h.fillStyle=this.getColor(l);var m=c.codePointAt(0);if(9600<=m&&9631>=m){h.beginPath();var p=r*s,w=i*a,y=s,g=a,b=s/2,_=a/2;if(9600===m)h.rect(p,w,y,_);else if(9608>=m){var k=(1-(m-9600)/8)*g;h.rect(p,w+k,y,g-k)}else if(9615>=m)h.rect(p,w,y-(m-9608)/8*y,g);else if(9616===m)h.rect(p+b,w,b,g);else if(9619>=m){var C,x,S;9617===m?(C=y/4,x=g/10,S=1):9618===m?(C=y/6,x=y/10,S=1):9619===m&&(C=y/4,x=y/7,S=2);for(var T=!1,E=0;E<g;E+=x){for(var A=0;A<y;A+=C){var F=Math.min(S,g-E);h.rect(r*y+(T?y-A-S:A),i*g+E,S,F)}T=!T}}else 9620===m?h.rect(r*y,i*g,y,g/8):9621===m?h.rect((r+7/8)*y,i*g,y/8,g):9622===m?h.rect(p,w+_,b,_):9623===m?h.rect(p+b,w+_,b,_):9624===m?h.rect(p,w,b,_):9625===m?(h.rect(p,w,b,g),h.rect(p+b,w+_,b,_)):9626===m?(h.rect(p,w,b,_),h.rect(p+b,w+_,b,_)):9627===m?(h.rect(p,w,b,g),h.rect(p+b,w,b,_)):9628===m?(h.rect(p,w,y,_),h.rect(p+b,w+_,b,_)):9629===m?h.rect(p+b,w,b,_):9630===m?(h.rect(p,w+_,b,_),h.rect(p+b,w,b,_)):9631===m&&(h.rect(p,w+_,b,_),h.rect(p+b,w,b,g));h.fill()}else h.fillText(c,(r+.5)*s,(i+.5)*a);if(f||d||v){if(h.strokeStyle=this.getColor(l),h.lineWidth=1,h.lineCap="round",h.beginPath(),f){var L=n(i*a+o.height)+.5;h.moveTo(r*s,L),h.lineTo((r+1)*s,L)}if(d){var P=n((i+.5)*a)+.5;h.moveTo(r*s,P),h.lineTo((r+1)*s,P)}if(v){var O=n(i*a)+.5;h.moveTo(r*s,O),h.lineTo((r+1)*s,O)}h.stroke()}h.globalAlpha=1}}},{key:"getAdjacentCells",value:function(e){for(var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=this.screen.window,r=n.width,i=n.height,o=[],s=-t;s<=t;s++)for(var a=-t;a<=t;a++)(0!==s||0!==a)&&o.push(e+s+a*r);return o.filter(function(e){return 0<=e&&e<r*i})}},{key:"draw",value:function(e){var t=this,n=this.ctx,r=this.screen.window,i=r.width,o=r.height,s=r.devicePixelRatio,a=r.statusScreen;if(a)return this.drawStatus(a),void this.startDrawLoop();this.stopDrawLoop();var c=this.screen.getCharSize(),l=this.screen.getCellSize(),u=l.width,h=l.height;n.setTransform(s,0,0,s,0,0),this.screen.window.debug&&this.screen._debug&&this.screen._debug.drawStart(e),n.font=this.screen.getFont(),n.textAlign="center",n.textBaseline="middle";for(var f=new Map,d=new Map,v=0;v<i*o;v++){var m=v%i,p=Math.floor(v/i),w=!this.screen.cursor.hanging&&this.screen.cursor.x===m&&this.screen.cursor.y===p&&this.screen.cursor.visible&&this.cursorBlinkOn,y=m===this.drawnCursor[0]&&p===this.drawnCursor[1],g=this.screen.isInSelection(m,p),b=this.screen.screen[v],_=0|this.screen.screenFG[v],k=0|this.screen.screenBG[v],C=0|this.screen.screenAttrs[v];if(256&C||(_=this.defaultFgNum),512&C||(k=this.defaultBgNum),1024&C){var x=[k,_];_=x[0],k=x[1]}if(this.screen.reverseVideo){var S=[k,_];_=S[0],k=S[1]}16&C&&!this.blinkStyleOn&&(b=""),g&&(_=-1,k=-2);var T=b!==this.drawnScreen[v]||_!==this.drawnScreenFG[v]||k!==this.drawnScreenBG[v]||C!==this.drawnScreenAttrs[v]||w!==y||w&&this.screen.cursor.style!==this.drawnCursor[2],E=5&C;f.has(E)||f.set(E,[]),f.get(E).push({cell:v,x:m,y:p,text:b,fg:_,bg:k,attrs:C,isCursor:w,inSelection:g}),d.set(v,T)}var A=new Map,F=function(e){return" "!==e&&n.measureText(e).width>=u+.05},L=!0,P=!1,O=void 0;try{for(var D,B=d.keys()[Symbol.iterator]();!(L=(D=B.next()).done);L=!0){var N=D.value;!function(e){var n=d.get(e)||A.get(e)||!1,r=t.screen.screen[e],i=F(r),o=i?2:1;if(!n){var s=!1,a=!0,c=!1,l=void 0;try{for(var u,h=t.getAdjacentCells(e,o)[Symbol.iterator]();!(a=(u=h.next()).done);a=!0){var f=u.value;if(d.get(f)&&(2>t.screen.window.graphics||i||F(t.screen.screen[f]))){s=!0;break}}}catch(e){c=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(c)throw l}}s&&(n=!0)}A.set(e,n)}(N)}}catch(e){P=!0,O=e}finally{try{!L&&B.return&&B.return()}finally{if(P)throw O}}if(1<=this.screen.window.graphics){var M=this.screen.window.debug&&this.screen._debug;n.save(),n.beginPath();for(var I=0;I<o;I++){for(var R=null,j=0;j<i;j++){var q=I*i+j,H=A.get(q);H&&null==R&&(R=j),H||null===R||(n.rect(R*u,I*h,(j-R)*u,h),M&&this.screen._debug.clipRect(R*u,I*h,(j-R)*u,h),R=null)}null!==R&&(n.rect(R*u,I*h,(i-R)*u,h),M&&this.screen._debug.clipRect(R*u,I*h,(i-R)*u,h))}n.clip()}var U=!0,z=!1,W=void 0;try{for(var G,K=f.keys()[Symbol.iterator]();!(U=(G=K.next()).done);U=!0){var X=G.value,Y=!0,J=!1,V=void 0;try{for(var $,Q=f.get(X)[Symbol.iterator]();!(Y=($=Q.next()).done);Y=!0){var Z=$.value,ee=Z.cell,te=Z.x,ne=Z.y,re=Z.text,ie=Z.bg;if(A.get(ee)&&(this.drawBackground({x:te,y:ne,cellWidth:u,cellHeight:h,bg:ie}),this.screen.window.debug&&this.screen._debug)){var oe=+A.get(ee);oe|=+d.get(ee)<<1,oe|=+F(re)<<2,this.screen._debug.setCell(ee,oe)}}}catch(e){J=!0,V=e}finally{try{!Y&&Q.return&&Q.return()}finally{if(J)throw V}}}}catch(e){z=!0,W=e}finally{try{!U&&K.return&&K.return()}finally{if(z)throw W}}this.drawnCursor=[-1,-1,-1];var se=!0,ae=!1,ce=void 0;try{for(var le,ue=f.keys()[Symbol.iterator]();!(se=(le=ue.next()).done);se=!0){var he=le.value,fe={};1&he&&(fe.weight="bold"),4&he&&(fe.style="italic"),n.font=this.screen.getFont(fe);var de=!0,ve=!1,me=void 0;try{for(var pe,we=f.get(he)[Symbol.iterator]();!(de=(pe=we.next()).done);de=!0){var ye=pe.value,ge=ye.cell,be=ye.x,_e=ye.y,ke=ye.text,Ce=ye.fg,xe=ye.bg,Se=ye.attrs,Te=ye.isCursor,Ee=ye.inSelection;if(A.get(ge)&&(this.drawCharacter({x:be,y:_e,charSize:c,cellWidth:u,cellHeight:h,text:ke,fg:Ce,attrs:Se}),this.drawnScreen[ge]=ke,this.drawnScreenFG[ge]=Ce,this.drawnScreenBG[ge]=xe,this.drawnScreenAttrs[ge]=Se,Te&&(this.drawnCursor=[be,_e,this.screen.cursor.style]),Te&&!Ee)){n.save(),n.beginPath(),"block"===this.screen.cursor.style?n.rect(be*u,_e*h,u,h):"bar"===this.screen.cursor.style?n.rect(be*u,_e*h,2,h):"line"===this.screen.cursor.style&&n.rect(be*u,_e*h+c.height,u,2),n.clip();var Ae=[xe,Ce];Ce=Ae[0],xe=Ae[1],Ce===xe&&(xe=0===Ce?7:0),this.drawBackground({x:be,y:_e,cellWidth:u,cellHeight:h,bg:xe}),this.drawCharacter({x:be,y:_e,charSize:c,cellWidth:u,cellHeight:h,text:ke,fg:Ce,attrs:Se}),n.restore()}}}catch(e){ve=!0,me=e}finally{try{!de&&we.return&&we.return()}finally{if(ve)throw me}}}}catch(e){ae=!0,ce=e}finally{try{!se&&ue.return&&ue.return()}finally{if(ae)throw ce}}1<=this.screen.window.graphics&&n.restore(),this.screen.window.debug&&this.screen._debug&&this.screen._debug.drawEnd(),this.screen.emit("draw")}},{key:"drawStatus",value:function(e){var t=this.ctx,n=this.screen.window,r=n.fontFamily,i=n.width,o=n.height,s=n.devicePixelRatio;this.drawnScreen=[];var a=this.screen.getCellSize(),c=i*a.width,l=o*a.height;if(t.setTransform(s,0,0,s,0,0),t.clearRect(0,0,c,l),t.font="24px "+r,t.fillStyle="#fff",t.textAlign="center",t.textBaseline="middle",t.fillText(e.title||"",c/2,l/2-50),e.loading){t.save(),t.translate(c/2,l/2+20),t.strokeStyle="#fff",t.lineWidth=5,t.lineCap="round";for(var u=Date.now()/1e3,h=0;12>h;h++){t.rotate(Math.PI/6);var f=(12*u-h)%12;t.globalAlpha=Math.max(.2,1-f/3),t.beginPath(),t.moveTo(0,15),t.lineTo(0,30),t.stroke()}t.restore()}}},{key:"startDrawLoop",value:function(){if(!this._drawTimerThread){var e=Math.random().toString(36);this._drawTimerThread=e,this.drawTimerLoop(e)}}},{key:"stopDrawLoop",value:function(){this._drawTimerThread=null}},{key:"drawTimerLoop",value:function(e){var t=this;e&&e===this._drawTimerThread&&(window.requestAnimationFrame(function(){return t.drawTimerLoop(e)}),this.draw("draw-loop"))}},{key:"palette",get:function(){return this._palette||s[0]},set:function(e){this._palette!==e&&(this._palette=e,this.resetDrawn(),this.scheduleDraw("palette"))}}],[{key:"alphaToFraktur",value:function(e){var t=String.fromCodePoint;return"a"<=e&&"z">=e?e=t(119997+e.charCodeAt(0)):"A"<=e&&"Z">=e&&(e=u[e]||t(120003+e.charCodeAt(0))),e}}]),e}()},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s,a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(5),l=n(1);try{s=n(6)}catch(e){}e.exports=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.screen=e,n.ws=null,n.heartbeatTimeout=null,n.pingInterval=null,n.xoff=!1,n.autoXoffTimeout=null,n.reconnTimeout=null,n.forceClosing=!1,n.pageShown=!1,n.disconnectTimeout=null,document.addEventListener("visibilitychange",function(){!0===document.hidden?(console.info("Window lost focus, freeing socket"),n.disconnectTimeout=setTimeout(function(){n.closeSocket(),clearTimeout(n.heartbeatTimeout)},1e3)):(clearTimeout(n.disconnectTimeout),console.info("Window got focus, re-connecting"),n.init())},!1),n}return o(t,e),a(t,[{key:"onWSOpen",value:function(){console.log("CONNECTED"),this.heartbeat(),this.send("i"),this.forceClosing=!1,this.emit("connect")}},{key:"onWSClose",value:function(e){var t=this;return this.forceClosing?void(this.forceClosing=!1):(console.warn("SOCKET CLOSED, code "+e.code+". Reconnecting..."),1e3>e.code&&console.error("Bad code from socket!"),clearTimeout(this.reconnTimeout),this.reconnTimeout=setTimeout(function(){return t.init()},2e3),void this.emit("disconnect",e.code))}},{key:"onWSMessage",value:function(e){var t=this;try{switch(e.data.charAt(0)){case".":break;case"-":this.xoff=!0,this.autoXoffTimeout=setTimeout(function(){t.xoff=!1},250);break;case"+":this.xoff=!1,clearTimeout(this.autoXoffTimeout);break;default:this.screen.load(e.data),this.pageShown||(window.showPage(),this.pageShown=!0)}this.heartbeat()}catch(e){console.error(e)}}},{key:"canSend",value:function(){return!this.xoff}},{key:"send",value:function(e){return window._demo?(void 0===window.demoInterface?console.log("TX: "+JSON.stringify(e)):s.input(e),!0):this.xoff?(console.log("Can't send, flood control."),!1):!!this.ws&&(1===this.ws.readyState?("string"!=typeof e&&(e=JSON.stringify(e)),this.ws.send(e),!0):(console.error("Socket not ready"),!1))}},{key:"closeSocket",value:function(){this.ws&&(this.forceClosing=!0,1===this.ws.readyState&&this.ws.close(),this.ws=null)}},{key:"init",value:function(){var e=this;return window._demo?void(void 0===window.demoInterface?window.alert("Demoing non-demo build!"):s.init(this.screen)):(clearTimeout(this.reconnTimeout),clearTimeout(this.heartbeatTimeout),this.closeSocket(),this.ws=new window.WebSocket("ws://"+window._root+"/term/update.ws"),this.ws.addEventListener("open",function(){return e.onWSOpen.apply(e,arguments)}),this.ws.addEventListener("close",function(){return e.onWSClose.apply(e,arguments)}),this.ws.addEventListener("message",function(){return e.onWSMessage.apply(e,arguments)}),console.log("Opening socket."),this.heartbeat(),void this.emit("open"))}},{key:"heartbeat",value:function(){var e=this;clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=setTimeout(function(){return e.onHeartbeatFail()},2500)}},{key:"onHeartbeatFail",value:function(){var e=this;this.closeSocket(),this.emit("silence"),console.error("Heartbeat lost, probing server..."),clearInterval(this.pingInterval),this.pingInterval=setInterval(function(){console.log("> ping"),e.emit("ping"),l.get("http://"+window._root+"/system/ping",function(t,n){200===n?(clearInterval(e.pingInterval),console.info("Server ready, opening socket…"),e.emit("ping-success"),e.init()):e.emit("ping-fail",n)},{timeout:100,loader:!1})},1e3)}}]),t}(c)},function(e,t,n){"use strict";var r=n(1),i=n(0),o=i.encode2B;e.exports=function(e,t){function n(t){return e.send("s"+t)}function i(t){e.send("b"+l(t))}function s(e){var r=e.allFn;window.addEventListener("keypress",function(e){if(_()&&!e.ctrlKey&&!e.metaKey){var t="";e.key&&1===e.key.length?t=e.key:e.which&&229!==e.which&&(t=String.fromCodePoint(e.which)),0<t.length&&32<=t.charCodeAt(0)&&(32===e.which&&e.preventDefault(),n(t))}}),window.addEventListener("keydown",x),window.addEventListener("copy",function(e){if(_()){var n=t.getSelectedText();n&&(e.preventDefault(),e.clipboardData.setData("text/plain",n))}}),window.addEventListener("paste",function(e){if(_()){e.preventDefault();var r=e.clipboardData.getData("text/plain");r.includes("\n")||90<r.length?(!c.termUpload&&console.error("input.termUpload is undefined"),c.termUpload.setContent(r),c.termUpload.open()):(t.bracketedPaste&&(r="[200~"+r+"[201~"),n(r))}}),m.all_fn=r}function a(){return A}for(var c,l=String.fromCharCode,u={3:"Cancel",6:"Help",8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",42:"Print",43:"Execute",44:"PrintScreen",45:"Insert",46:"Delete",58:":",59:";",60:"<",61:"=",62:">",63:"?",64:"@",91:"Meta",92:"Meta",93:"ContextMenu",106:"Numpad*",107:"Numpad+",109:"Numpad-",110:"Numpad.",111:"Numpad/",144:"NumLock",145:"ScrollLock",160:"^",161:"!",162:'"',163:"#",164:"$",165:"%",166:"&",167:"_",168:"(",169:")",170:"*",171:"+",172:"|",173:"-",174:"{",175:"}",176:"~",186:";",187:"=",188:"Numpad,",189:"-",190:"Numpad,",192:"`",194:"Numpad,",219:"[",220:"\\",221:"]",222:"'",224:"Meta"},h=48;57>=h;h++)u[h]=l(h);for(var f=65;90>=f;f++)u[f]=l(f);for(var d=112;131>=d;d++)u[d]="F"+(d-112+1);for(var v=96;105>=v;v++)u[v]="Numpad"+(v-96);for(var m={np_alt:!1,cu_alt:!1,fn_alt:!1,mt_click:!1,mt_move:!1,no_keys:!1,crlf_mode:!1,all_fn:!1},p=function(e,t){return m.fn_alt?e:t},w=function(e,t){return m.cu_alt?e:t},y=function(e,t){return m.np_alt?e:t},g={Backspace:"\b",Tab:"\t",Enter:function(){return m.crlf_mode?"\r\n":"\r"},"Control+Enter":"\n",Escape:"",ArrowUp:function(){return w("OA","")},ArrowDown:function(){return w("OB","")},ArrowRight:function(){return w("OC","")},ArrowLeft:function(){return w("OD","")},Home:function(){return w("OH",p("","[1~"))},Insert:"[2~",Delete:"[3~",End:function(){return w("OF",p("","[4~"))},PageUp:"[5~",PageDown:"[6~",F1:function(){return p("OP","[11~")},F2:function(){return p("OQ","[12~")},F3:function(){return p("OR","[13~")},F4:function(){return p("OS","[14~")},F5:"[15~",F6:"[17~",F7:"[18~",F8:"[19~",F9:"[20~",F10:"[21~",F11:"[23~",F12:"[24~","Shift+F1":function(){return p("O1;2P","[25~")},"Shift+F2":function(){return p("O1;2Q","[26~")},"Shift+F3":function(){return p("O1;2R","[28~")},"Shift+F4":function(){return p("O1;2S","[29~")},"Shift+F5":function(){return p("[15;2~","[31~")},"Shift+F6":function(){return p("[17;2~","[32~")},"Shift+F7":function(){return p("[18;2~","[33~")},"Shift+F8":function(){return p("[19;2~","[34~")},"Shift+F9":function(){return p("[20;2~","[35~")},"Shift+F10":function(){return p("[21;2~","[36~")},"Shift+F11":function(){return p("[22;2~","[37~")},"Shift+F12":function(){return p("[23;2~","[38~")},Numpad0:function(){return y("Op","0")},Numpad1:function(){return y("Oq","1")},Numpad2:function(){return y("Or","2")},Numpad3:function(){return y("Os","3")},Numpad4:function(){return y("Ot","4")},Numpad5:function(){return y("Ou","5")},Numpad6:function(){return y("Ov","6")},Numpad7:function(){return y("Ow","7")},Numpad8:function(){return y("Ox","8")},Numpad9:function(){return y("Oy","9")},"Numpad*":function(){return y("OR","*")},"Numpad+":function(){return y("Ol","+")},"Numpad-":function(){return y("OS","-")},"Numpad.":function(){return y("On",".")},"Numpad/":function(){return y("OQ","/")},"Control+]":"","Control+\\":"","Control+[":"","Control+^":"","Control+_":"","Control+ArrowLeft":"[1;5D","Control+ArrowRight":"[1;5C","Control+ArrowUp":"[1;5A","Control+ArrowDown":"[1;5B","Control+Home":"[1;5H","Control+End":"[1;5F","Shift+ArrowLeft":"[1;2D","Shift+ArrowRight":"[1;2C","Shift+ArrowUp":"[1;2A","Shift+ArrowDown":"[1;2B","Shift+Home":"[1;2H","Shift+End":"[1;2F","Alt+ArrowLeft":"b","Alt+ArrowRight":"f","Meta+ArrowLeft":"","Meta+ArrowRight":"","Alt+Backspace":"","Meta+Backspace":"","Control+Shift+C":function(){t.copySelectionToClipboard()},"Control+Insert":function(){t.copySelectionToClipboard()},"Control+F12":function(){t.window.debug^=1}},b=1;26>=b;b++)g["Control+"+l(64+b)]=l(b);var _=function(){return!(m.no_keys||document.activeElement instanceof window.HTMLTextAreaElement)},k=["F5","F11","F12","Shift+F5"],C={alt:!1,ctrl:!1,meta:!1,shift:!1},x=function(e){if(_()){var t=[];(e.altKey||C.alt)&&t.push("Alt"),(e.ctrlKey||C.ctrl)&&t.push("Control"),(e.metaKey||C.meta)&&t.push("Meta"),(e.shiftKey||C.shift)&&t.push("Shift");var r=u[e.which]||e.key;if(!e.ctrlKey&&!e.metaKey||"V"!==r){var i=null;for(var o in g){var s=o.split("+");if(s.pop()===r&&s.sort().join()===t.join()){if(k.includes(o)&&!m.all_fn)continue;i=g[o];break}}i&&(i instanceof Function&&(i=i()),e.preventDefault(),"string"==typeof i&&n(i))}}},S=0,T=0,E=0,A=0;return window.addEventListener("keydown",function(e){e.ctrlKey&&(A|=1),e.shiftKey&&(A|=2),e.altKey&&(A|=4),e.metaKey&&(A|=8)}),window.addEventListener("keyup",function(e){A=0,e.ctrlKey&&(A|=1),e.shiftKey&&(A|=2),e.altKey&&(A|=4),e.metaKey&&(A|=8)}),c={init:function(e){s(e),r("#action-buttons button").forEach(function(e){e.addEventListener("click",function(){i(+this.dataset.n)})}),window.addEventListener("mousedown",function(e){0===e.button&&(S=1),1===e.button&&(T=1),2===e.button&&(E=1)}),window.addEventListener("mouseup",function(e){0===e.button&&(S=0),1===e.button&&(T=0),2===e.button&&(E=0)})},sendString:n,setAlts:function(e,t,n,r){(m.cu_alt!==e||m.np_alt!==t||m.fn_alt!==n||m.crlf_mode!==r)&&(m.cu_alt=e,m.np_alt=t,m.fn_alt=n,m.crlf_mode=r)},setMouseMode:function(e,t){m.mt_click=e,m.mt_move=t},onMouseMove:function(t,n){if(m.mt_move){var r=S?1:T?2:E?3:0,i=a();e.send("m"+o(n)+o(t)+o(r)+o(i))}},onMouseDown:function(t,n,r){if(m.mt_click&&!(3<r||1>r)){var i=a();e.send("p"+o(n)+o(t)+o(r)+o(i))}},onMouseUp:function(t,n,r){if(m.mt_click&&!(3<r||1>r)){var i=a();e.send("r"+o(n)+o(t)+o(r)+o(i))}},onMouseWheel:function(t,n,r){if(m.mt_click){var i=a(),s=0>r?4:5;e.send("p"+o(n)+o(t)+o(s)+o(i))}},blockKeys:function(e){m.no_keys=e},handleKeyDown:x,softModifiers:C}}},function(e,t,n){"use strict";var r=n(1),i=n(0),o=i.qs,s=n(2);e.exports=function(e,t,n){function i(){c("Ready..."),s.show("#fu_modal",a),r("#fu_form").toggleClass("busy",!1),t.blockKeys(!0)}function a(){console.log("Upload modal closed."),clearTimeout(m),v=0,t.blockKeys(!1)}function c(e){o("#fu_prog").textContent=e}function l(){var e=o("#fu_text").value;return e.length?(d=e.split("\n"),v=0,g=0,p=o("#fu_delay").value,0>p&&(p=0,o("#fu_delay").value=p),w={CR:"\r",LF:"\n",CRLF:"\r\n"}[o("#fu_crlf").value],r("#fu_form").toggleClass("busy",!0),c("Starting..."),void u()):void f()}function u(){if(r("#fu_modal").hasClass("visible")){if(!e.canSend())return void(m=setTimeout(u,1));0===g&&(y="",0===v&&n.bracketedPaste&&(y="[200~"),y+=d[v++]+w,v===d.length&&n.bracketedPaste&&(y+="[201~"));var i;if(y.length-g<=b?(i=y.substr(g,b),g=0):(i=y.substr(g,b),g+=b),!t.sendString(i))return void c("FAILED!");var o=Math.round(v/d.length*1e3)/10;c(v+" / "+d.length+" ("+o+"%)"),d.length>v||0<g?m=setTimeout(u,p):h()}}function h(){e.canSend()?(c("Done."),f()):(c("Waiting for Tx buffer..."),setTimeout(h,100))}function f(){s.hide("#fu_modal")}var d,v,m,p,w,y,g,b=128;return{init:function(){o("#fu_file").addEventListener("change",function(e){var t=new window.FileReader,n=e.target.files[0],r=n.type||"application/octet-stream";return console.log("Selected file type: "+r),r.match(/text\/.*|application\/(json|csv|.*xml.*|.*script.*|x-php)/)||window.confirm("This does not look like a text file: "+r+"\nReally load?")?(t.onload=function(e){var t=e.target.result.replace(/[\r\n]+/,"\n");o("#fu_text").value=t},console.log("Loading file..."),void t.readAsText(n)):void(o("#fu_file").value="")},!1),o("#term-fu-open").addEventListener("click",function(){return i(),!1}),o("#term-fu-start").addEventListener("click",function(){return l(),!1}),o("#term-fu-close").addEventListener("click",function(){return f(),!1})},open:i,setContent:function(e){o("#fu_text").value=e}}}},function(e,t,n){"use strict";var r=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!((r=(s=a.next()).done)||(n.push(s.value),t&&n.length===t));r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=n(0),o=i.qs;e.exports=function(e,t){var n=o("#softkb-input");if(n){var i=document.createElement("div");i.id="keyboard-shortcut-bar",navigator.userAgent.match(/iPad|iPhone|iPod/)&&o("#screen").appendChild(i);var s=!1,a=function(){if(s){var t=e.gridToScreen(e.cursor.x,e.cursor.y,!0),i=r(t,2),o=i[0],a=i[1];n.style.transform="translate("+o+"px, "+a+"px)"}};n.addEventListener("focus",function(){s=!0,a(),i.classList.add("open")}),n.addEventListener("blur",function(){s=!1,i.classList.remove("open")}),e.on("cursor-moved",a),o("#term-kb-open").addEventListener("click",function(e){e.preventDefault(),n.focus()});var c="",l=function(e){var n=!1;e.length>c.length?e.startsWith(c)?t.sendString(e.substr(c.length)):n=!0:e.length<c.length?c.startsWith(e)?t.sendString("\b".repeat(c.length-e.length)):n=!0:e!==c&&(n=!0),n&&t.sendString("\b".repeat(c.length)+e),c=e};n.addEventListener("keydown",function(e){"Unidentified"===e.key||(n.value="",e.stopPropagation(),t.handleKeyDown(e))}),n.addEventListener("keypress",function(e){e.stopPropagation()}),n.addEventListener("input",function(e){e.stopPropagation(),e.isComposing&&"data"in e?l(e.data):e.isComposing?l(n.value):"insertCompositionText"===e.inputType?t.sendString(e.data):"deleteContentBackward"===e.inputType?(c="",l("")):"insertText"===e.inputType&&t.sendString(e.data)}),n.addEventListener("compositionstart",function(){c=""}),n.addEventListener("compositionend",function(){c="",n.value=""}),e.on("open-soft-keyboard",function(){return n.focus()});var u={Control:"ctrl",Esc:27,Tab:9,"←":37,"↓":40,"↑":38,"→":39},h=!1;for(var f in u)!function(e){var n=document.createElement("button");n.classList.add("shortcut-button"),n.textContent=e,i.appendChild(n);var r=u[e];"string"==typeof r&&n.classList.add("modifier"),n.addEventListener("touchstart",function(e){h=!1,"string"==typeof r&&(t.softModifiers[r]=!0,n.classList.add("enabled"),e.preventDefault())}),window.addEventListener("touchmove",function(){h=!0}),n.addEventListener("touchend",function(e){if(e.preventDefault(),"number"==typeof r){if(h)return;t.handleKeyDown({which:r,preventDefault:function(){}})}else"string"==typeof r&&(n.classList.remove("enabled"),t.softModifiers[r]=!1)})}(f)}}},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var i=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!((r=(s=a.next()).done)||(n.push(s.value),t&&n.length===t));r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=n(0),s=o.mk;e.exports=function(e){var t=s("canvas"),n=t.getContext("2d");t.style.position="absolute",t.style.top="6px",t.style.left="6px",t.style.pointerEvents="none";var o,a,c,l,u=function(){t.parentNode||e.canvas.parentNode.appendChild(t)},h=function(){t.parentNode&&t.parentNode.removeChild(t)},f=function(){var n=e.window,r=n.width,i=n.height,o=n.devicePixelRatio,s=e.getCellSize();t.width=r*s.width*o,t.height=i*s.height*o,t.style.width=r*s.width+"px",t.style.height=i*s.height+"px"},d=new Map,v=[];e._debug={drawStart:function(e){c=e,o=Date.now(),v=[]},drawEnd:function(){a=Date.now(),console.log("Draw: "+c+" ("+(a-o)+" ms) with fancy graphics: "+e.window.graphics),l()},setCell:function(e,t){d.set(e,[t,Date.now()])},clipRect:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];v.push(t)}};var m,p=document.createElement("canvas");p.width=p.height=12;var w=p.getContext("2d");w.lineWidth=1,w.strokeStyle="#00f",w.beginPath(),w.moveTo(0,0),w.lineTo(-4,12),w.moveTo(4,0),w.lineTo(0,12),w.moveTo(8,0),w.lineTo(4,12),w.moveTo(12,0),w.lineTo(8,12),w.moveTo(16,0),w.lineTo(12,12),w.stroke(),m=n.createPattern(p,"repeat");var y=!1,g=function(){y&&window.requestAnimationFrame(g);var t=e.window,o=t.devicePixelRatio,s=t.width,a=t.height,c=e.getCellSize(),l=c.width,u=c.height,f=Date.now();n.setTransform(o,0,0,o,0,0),n.clearRect(0,0,s*l,a*u);for(var p=0,w=0;w<s*a;w++)if(d.has(w)&&0!==d.get(w)[0]){var b=d.get(w),_=i(b,2),k=_[0],C=_[1],x=(f-C)/1e3;if(!(1<x)){p++,n.globalAlpha=.5*Math.max(0,1-x);var S=w%s,T=Math.floor(w/s);1&k&&(n.fillStyle="#f0f"),2&k&&(n.fillStyle="#0f0"),n.fillRect(S*l,T*u,l,u),4&k&&(n.lineWidth=2,n.strokeStyle="#f00",n.strokeRect(S*l,T*u,l,u))}}if(v.length){n.globalAlpha=.5,n.beginPath();var E=!0,A=!1,F=void 0;try{for(var L,P=v[Symbol.iterator]();!(E=(L=P.next()).done);E=!0){var O=L.value;n.rect.apply(n,r(O))}}catch(e){A=!0,F=e}finally{try{!E&&P.return&&P.return()}finally{if(A)throw F}}n.fillStyle=m,n.fill()}0==p&&(y=!1,h())};l=function(){y||(u(),f(),y=!0,g())};var b=s("div");b.classList.add("debug-toolbar");var _=!1,k=function(){e.canvas.parentNode.appendChild(b)},C=function(){b.parentNode.removeChild(b)};e.on("update-window:debug",function(e){e!==_&&(_=e,e?k():C())}),e.on("draw",function(){if(_){var t=e.cursor.y*e.window.width+e.cursor.x,n=e.screenFG[t],r=e.screenBG[t],i=(e.screen[t]||"").codePointAt(0),o=e.screenAttrs[t],s=i.toString(16).toUpperCase();4>s.length&&(s=("0000"+s).substr(-4)),s="U+"+s,b.textContent="Cursor cell ("+t+"): "+s+" FG: "+n+" BG: "+r+" Attrs: "+o.toString(2)}})}}]);
//# sourceMappingURL=app.f5dd70a.js.map