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.8b43b1d-en.js

4 lines
135 KiB

!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},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=10)}([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.parse2B=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.charCodeAt(t++)-1+127*(e.charCodeAt(t)-1)},t.parse3B=function(e){var t=arguments.length>1&&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=void 0,n=void 0;return t=e%127,e=(e-t)/127,t+=1,n=e+1,String.fromCharCode(t)+String.fromCharCode(n)},t.encode3B=function(e){var t=void 0,n=void 0,i=void 0;return t=e%127,e=(e-t)/127,t+=1,n=e%127,e=(e-n)/127,n+=1,i=e+1,String.fromCharCode(t)+String.fromCharCode(n)+String.fromCharCode(i)}},function(e,t,n){"use strict";var i="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};/*!chibi 3.0.7, Copyright 2012-2016 Kyle Barrow, released under MIT license */
!function(){function t(){var e;for(m=!0,e=0;e<v.length;e+=1)v[e]();v=[]}function n(){var e;for(g=!0,m||t(),e=0;e<p.length;e+=1)p[e]();p=[]}function r(e,t){var n;for(n=t.length-1;n>=0;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)]:w.getComputedStyle?w.getComputedStyle(e,null).getPropertyValue(t):null}function a(e,t){return encodeURIComponent(e).replace(/%20/g,"+")+"="+encodeURIComponent(t).replace(/%20/g,"+")}function l(e,t,n){try{e.style[o(t)]=n}catch(e){}}function u(e){e.style.display="","none"===s(e,"display")&&(e.style.display="block")}function c(e){var t,n,i,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 r(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":t.length>0&&(o+="&"+a(t.name,t.value));break;case"select-multiple":for(i=0;i<t.length;i+=1)t[i].selected&&(o+="&"+a(t.name,t[i].value));break;case"checkbox":case"radio":t.checked&&(o+="&"+a(t.name,t.value));break;default:o+="&"+a(t.name,t.value)}},e);return o.length>0?o.substring(1):""}function h(e,t,n){var i,o,s=!1;return e&&(i=e.split(/\s+/),r(function(e){for(o=0;o<i.length;o+=1){var n=i[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 d(e,t,n){var i,o;e&&r(function(n){for(i=y.createElement("div"),i.innerHTML=e;null!==(o=i.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 f(e){var t,n,a,c=[],v=!1;if(e)if(e.nodeType&&1===e.nodeType)c=[e];else if("object"===(void 0===e?"undefined":i(e)))v="number"!=typeof e.length,c=e;else if("string"==typeof e)for(n=y.querySelectorAll(e),a=0;a<n.length;a+=1)c[a]=n[a];return t=v?{}:c,t.each=function(e){return"function"==typeof e&&r(function(t){return e.apply(t,arguments)},c),t},t.first=function(){return f(c.shift())},t.last=function(){return f(c.pop())},t.odd=function(){var e,t=[];for(e=0;e<c.length;e+=2)t.push(c[e]);return f(t)},t.even=function(){var e,t=[];for(e=1;e<c.length;e+=2)t.push(c[e]);return f(t)},t.hide=function(){return r(function(e){e.style.display="none"},c),t},t.show=function(){return r(function(e){u(e)},c),t},t.toggle=function(e){return void 0!==e?e?t.show():t.hide():r(function(e){"none"===s(e,"display")?u(e):e.style.display="none"},c),t},t.remove=function(){return r(function(e){try{e.parentNode.removeChild(e)}catch(e){}},c),f()},t.css=function(e,n){if(e){if(n||""===n)return r(function(t){l(t,e,n)},c),t;if(c[0]){if(c[0].style[o(e)])return c[0].style[o(e)];if(s(c[0],e))return s(c[0],e)}}},t.getClass=function(){if(c[0]&&c[0].className.length>0)return c[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"").replace(/\s+/," ")},t.setClass=function(e){return(e||""===e)&&r(function(t){t.className=e},c),t},t.addClass=function(e){return h(e,"add",c),t},t.removeClass=function(e){return h(e,"remove",c),t},t.toggleClass=function(e,n){return h(e,void 0===n?"toggle":+n?"add":"remove",c),t},t.hasClass=function(e){return h(e,"has",c)},t.html=function(e){return e||""===e?(r(function(t){t.innerHTML=e},c),t):c[0]?c[0].innerHTML:void 0},t.htmlBefore=function(e){return d(e,"before",c),t},t.htmlAfter=function(e){return d(e,"after",c),t},t.htmlAppend=function(e){return d(e,"append",c),t},t.htmlPrepend=function(e){return d(e,"prepend",c),t},t.attr=function(e,n){if(e){if(e=e.toLowerCase(),void 0!==n)return r(function(t){"style"===e?t.style.cssText=n:"class"===e?t.className=n:t.setAttribute(e,n)},c),t;if(c[0])if("style"===e){if(c[0].style.cssText)return c[0].style.cssText}else if("class"===e){if(c[0].className)return c[0].className}else if(c[0].getAttribute(e))return c[0].getAttribute(e)}},t.data=function(e,n){if(e)return t.attr("data-"+e,n)},t.val=function(e){var n,i,o;if(void 0!==e)return r(function(t){switch(t.nodeName){case"SELECT":for("string"!=typeof e&&"number"!=typeof e||(e=[e]),i=0;i<t.length;i+=1)for(o=0;o<e.length;o+=1)if(t[i].selected="",t[i].value===""+e[o]){t[i].selected="selected";break}break;case"INPUT":case"TEXTAREA":case"BUTTON":t.value=e}},c),t;if(c[0])switch(c[0].nodeName){case"SELECT":for(n=[],i=0;i<c[0].length;i+=1)c[0][i].selected&&n.push(c[0][i].value);return n.length>1?n:n[0];case"INPUT":case"TEXTAREA":case"BUTTON":return c[0].value}},t.checked=function(e){return"boolean"==typeof e?(r(function(t){"INPUT"!==t.nodeName||"checkbox"!==t.type&&"radio"!==t.type||(t.checked=e)},c),t):!c[0]||"INPUT"!==c[0].nodeName||"checkbox"!==c[0].type&&"radio"!==c[0].type?void 0:!!c[0].checked},t.on=function(n,i){return e!==w&&e!==y||(c=[e]),r(function(e){y.addEventListener?e.addEventListener(n,i,!1):y.attachEvent&&(e[n+i]=function(){return i.apply(e,arguments)},e.attachEvent("on"+n,e[n+i]))},c),t},t.off=function(n,i){return e!==w&&e!==y||(c=[e]),r(function(e){y.addEventListener?e.removeEventListener(n,i,!1):y.attachEvent&&(e.detachEvent("on"+n,e[n+i]),e[n+i]=null)},c),t},t}var v=[],p=[],m=!1,g=!1,y=document,w=window;y.addEventListener?(y.addEventListener("DOMContentLoaded",t,!1),w.addEventListener("load",n,!1)):y.attachEvent?(y.attachEvent("onreadystatechange",t),w.attachEvent("onload",n)):w.onload=n,f.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?f._loader:function(){},i=t.url,r=t.method,o=null;t.data&&(o=c(t.data)),o&&"GET"===r&&(i+=-1===i.indexOf("?")?"?"+o:"&"+o,o=null);var s=new XMLHttpRequest;if(t.nocache){var a=(+new Date).toString(36);i+=(-1===i.indexOf("?")?"?":"&")+"_="+a}n(!0),s.open(r,i,!0),s.timeout=t.timeout;var l=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(l))},s.setRequestHeader("X-Requested-With","XMLHttpRequest"),"POST"===r&&s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s},f._loader=function(){},f.get=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="GET",f.ajax(n)},f.post=function(e,t,n){return n=n||{},n.url=e,n.callback=t,n.method="POST",f.ajax(n)},f.ready=function(e){if(e){if(m)return e(),f;v.push(e)}},f.loaded=function(e){if(e){if(g)return e(),f;p.push(e)}};var b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};f.htmlEscape=function(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return b[e]})},e.exports=f}()},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function r(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(!r(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,r,a,l,u;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 c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(n=this._events[e],s(n))return!1;if(i(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),u=n.slice(),r=u.length,l=0;l<r;l++)u[l].apply(this,a);return!0},n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(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&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&r>0&&this._events[e].length>r&&(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),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,r=-1,n===t||i(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){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,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],i(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]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(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";var i=n(1),r=n(7),o=r.rgb255ToHex,s=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"],["#eee8d5","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#073642","#fdf6e3","#cb4b16","#93a1a1","#839496","#657b83","#6c71c4","#586e75","#002b36"],["#073642","#dc322f","#859900","#b58900","#268bd2","#d33682","#2aa198","#fdf6e3","#002b36","#cb4b16","#657b83","#839496","#93a1a1","#6c71c4","#eee8d5","#fdf6e3"]];t.fgbgThemes=[["#AAAAAA","#000000","Lnx","Linux"],["#FFFFFF","#000000","W+K","White on Black"],["#00FF00","#000000","Lim","Lime"],["#E53C00","#000000","Nix","Nixie"],["#EFF0F1","#31363B","Brz","Breeze"],["#FFFFFF","#300A24","Amb","Ambiance"],["#839496","#002B36","SoD","Solarized Dark"],["#93a1a1","#002b36","SoH","Solarized Dark (High Contrast)"],["#657B83","#FDF6E3","SoL","Solarized Light"],["#000000","#FFD75F","Wsp","Wasp"],["#000000","#FFFFDD","K+Y","Black on Yellow"],["#000000","#FFFFFF","K+W","Black on White"]];var a=null;t.buildColorTable=function(){if(null!==a)return a;a=new Array(16).fill("#000000");for(var e=0;e<6;e++)for(var t=0;t<6;t++)for(var n=0;n<6;n++){var i=40*e+(e?55:0),r=40*t+(t?55:0),s=40*n+(n?55:0);a.push(o(i,r,s))}for(var l=0;l<24;l++){var u=10*l+8;a.push(o(u,u,u))}return a},t.SELECTION_FG="#333",t.SELECTION_BG="#b2d7fe",t.themePreview=function(e){i("[data-fg]").forEach(function(n){var i=n.dataset.fg;/^\d+$/.test(i)&&(i=t.toHex(i,e)),n.style.color=i}),i("[data-bg]").forEach(function(n){var i=n.dataset.bg;/^\d+$/.test(i)&&(i=t.toHex(i,e)),n.style.backgroundColor=i})},t.colorTable256=null,t.ensureColorTable256=function(){t.colorTable256||(t.colorTable256=t.buildColorTable())},t.getColor=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e<16&&e in n?n[e]:-1===e?t.SELECTION_FG:-2===e?t.SELECTION_BG:e>15&&e<256?(t.ensureColorTable256(),t.colorTable256[e]):e>255?(e-=256,"#"+("000000"+e.toString(16)).substr(-6)):Math.floor(Date.now()/1e3)%2==0?"#ff0ff":"#00ff00"},t.toHex=function(e,n){return/^\d+$/.test(e)?(e=+e,t.getColor(e,s[n])):e}},function(e,t,n){"use strict";var i=n(1),r={},o=null;r.show=function(e,t){var n=i(e);n.removeClass("hidden visible"),setTimeout(function(){n.addClass("visible")},1),o=t},r.hide=function(e){var t=i(e);t.removeClass("visible"),setTimeout(function(){t.addClass("hidden"),o&&o()},500)},r.init=function(){i(".Modal").on("click",function(){i(this).hasClass("no-close")||r.hide(this)}),i(".Dialog").on("click",function(e){e.stopImmediatePropagation()}),i(window).on("keydown",function(e){27===e.which&&r.hide(".Modal")})},e.exports=r},function(e,t,n){"use strict";var i=n(1),r=n(4),o={},s=void 0,a=void 0,l=void 0,u=!1,c=function(){clearTimeout(a),clearTimeout(l)};o.show=function(e,t,n){s.toggleClass("error",!0===n),s.html(e),r.show(s),c(),(!t||t<=0)&&(t=2500),a=setTimeout(o.hide,t),u=!1,setTimeout(function(){u=!0},500)},o.hide=function(){var e=i("#notif");e.removeClass("visible"),l=setTimeout(function(){e.addClass("hidden")},250)},o.init=function(){s=i("#notif"),i(document).on("click",function(){u&&o.hide(this)}),s.on("click",function(e){return e.stopImmediatePropagation(),!1}),s.on("mouseenter",function(){c(),s.removeClass("hidden").addClass("visible")})},e.exports=o},function(e,t,n){"use strict";t.ATTR_FG=1,t.ATTR_BG=2,t.ATTR_BOLD=4,t.ATTR_UNDERLINE=8,t.ATTR_INVERSE=16,t.ATTR_BLINK=32,t.ATTR_ITALIC=64,t.ATTR_STRIKE=128,t.ATTR_OVERLINE=256,t.ATTR_FAINT=512,t.ATTR_FRAKTUR=1024},function(e,t,n){"use strict";function i(e){return("00"+e).substr(-2)}var r=Math,o=2*r.PI;t.hue2rgb=function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),6*n<1?e+6*(t-e)*n:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e},t.hsl2rgb=function(e,n,i){e/=o;var r=void 0,s=void 0,a=void 0;if(0===n)r=s=a=i;else{var l=void 0,u=void 0;u=i<.5?i*(1+n):i+n-n*i,l=2*i-u,r=t.hue2rgb(l,u,e+1/3),s=t.hue2rgb(l,u,e),a=t.hue2rgb(l,u,e-1/3)}return[r,s,a]},t.rgb2hsl=function(e,t,n){var i=r.min(e,t,n),s=r.max(e,t,n),a=s-i,l=void 0,u=void 0,c=void 0;if(c=(s+i)/2,0===a)l=u=0;else{u=c<.5?a/(s+i):a/(2-s-i);var h=((s-e)/6+a/2)/a,d=((s-t)/6+a/2)/a,f=((s-n)/6+a/2)/a;e===s?l=f-d:t===s?l=1/3+h-f:n===s&&(l=2/3+d-h),l<0?l+=1:l>1&&(l-=1)}return l*=o,[l,u,c]},t.hex2rgb=function(e){var t=e.match(/^#([\da-f]{3,6})$/i);if(t){e=t[1];var n=e.length/3,i=Math.pow(16,n)-1;return[0,1,2].map(function(t){return parseInt(e.slice(t*n,(t+1)*n),16)/i})}return[0,0,0]},t.rgb255ToHex=function(e,t,n){return"#"+[e,t,n].map(function(e){return i(e.toString(16))}).join("")},t.rgb2hex=function(e,t,n){return"#"+[e,t,n].map(function(e){return i(Math.round(255*e).toString(16))}).join("")}},function(e,t,n){"use strict";function i(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 r(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,i){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,n);if(void 0===r){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,i)}if("value"in r)return r.value;var s=r.get;if(void 0!==s)return s.call(i)},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=n(2),c=n(0),h=c.parse2B,d=n(3),f=d.themes,v=function(e){return String.fromCodePoint(e+(e>=55296?2049:1))},p=function(){function e(t){s(this,e),this.reset(),this.handler=t,this.joinChunks=!0}return l(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),i=n?n.split(";").map(function(e){return+e.replace(/\D/g,"")}):[],r=i.length?i[0]:1;if("H"===t)this.handler("set-cursor",(0|i[0])-1,(0|i[1])-1);else if(t>="A"&&t<="D")this.handler("move-cursor-"+(t<="B"?"y":"x"),("B"===t||"C"===t?1:-1)*r);else if("E"===t||"F"===t)this.handler("move-cursor-line",("E"===t?1:-1)*r);else if("G"===t)this.handler("set-cursor-x",r-1);else if("J"===t){var o=i.length?i[0]:2;2===o&&this.handler("clear")}else if("P"===t)this.handler("delete",r);else if("@"===t)this.handler("insert-blanks",r);else if("q"===t)this.handler("set-cursor-style",r);else if("m"===t){if(!i.length)return void this.handler("reset-style");for(var s=void 0;s=i.shift();)if(0===s)this.handler("reset-style");else if(1===s)this.handler("add-attrs",4);else if(2===s)this.handler("add-attrs",512);else if(3===s)this.handler("add-attrs",64);else if(4===s)this.handler("add-attrs",8);else if(5===s||6===s)this.handler("add-attrs",32);else if(7===s)this.handler("add-attrs",16);else if(9===s)this.handler("add-attrs",128);else if(20===s)this.handler("add-attrs",1024);else if(s>=30&&s<=37)this.handler("set-color-fg",s%10);else if(s>=40&&s<=47)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(s>=90&&s<=98)this.handler("set-color-fg",s%10+8);else if(s>=100&&s<=108)this.handler("set-color-bg",s%10+8);else if(38===s||48===s){var a=i.shift();if(2===a){var l=i.shift(),u=i.shift(),c=i.shift(),h=256+(l<<16|u<<8|c);38===s&&this.handler("set-color-fg",h),48===s&&this.handler("set-color-bg",h)}else if(5===a){var d=255&(0|i.shift());38===s&&this.handler("set-color-fg",d),48===s&&this.handler("set-color-bg",d)}}}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,i=void 0;try{for(var r,o=e.toString()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.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=""):this.currentSequence>1?this.sequence+=s:1===this.currentSequence?(this.currentSequence=0,this.handler("write",s)):a<3?this.handler("_null"):3===a?this.handler("sigint"):a<=6?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,i=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw i}}this.joinChunks||this.reset()}}]),e}(),m=[0,0,0],g=function(e){return 16+36*Math.floor(2.5*Math.sin(e)+2.5)+6*Math.floor(2.5*Math.sin(e+2/3*Math.PI)+2.5)+Math.floor(2.5*Math.sin(e+4/3*Math.PI)+2.5)},y=function(){function e(t){var n=this;s(this,e),this.width=80,this.height=25,this.termScreen=t,this.parser=new p(function(){return n.handleParsed.apply(n,arguments)}),this.buttonLabels=[],this.reset(),this._lastLoad=Date.now(),this.loadTimer(),window.showPage()}return l(e,[{key:"reset",value:function(){this.style=m.slice(),this.cursor={x:0,y:0,style:1,visible:!0},this.trackMouse=!1,this.theme=0,this.defaultFG=7,this.defaultBG=0,this.rainbow=this.superRainbow=!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.slice()])}},{key:"scroll",value:function(){this.screen.splice(0,this.width);for(var e=0;e<this.width;e++)this.screen.push([" ",m.slice()]);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.slice()],++this.cursor.x>=this.width&&(this.cursor.x=0,this.newLine())}},{key:"moveBack",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=0;t<e;t++)--this.cursor.x<0&&(this.cursor.y>0?this.cursor.x=this.width-1:this.cursor.x=0,this.cursor.y=Math.max(0,this.cursor.y-1))}},{key:"moveForward",value:function(){for(var e=arguments.length>0&&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,[" ",m.slice()]),this.screen.splice(this.cursor.y*this.width+this.cursor.x,1)}},{key:"deleteForward",value:function(e){e=Math.min(this.width,e);for(var t=0;t<e;t++)this.screen.splice((this.cursor.y+1)*this.width,0,[" ",m.slice()]);this.screen.splice(this.cursor.y*this.width+this.cursor.x,e)}},{key:"clampCursor",value:function(){this.cursor.x<0&&(this.cursor.x=0),this.cursor.y<0&&(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(arguments.length<=1?void 0:arguments[1]):"delete"===e?this.deleteForward(arguments.length<=1?void 0:arguments[1]):"insert-blanks"===e?this.insertBlanks(arguments.length<=1?void 0:arguments[1]):"clear"===e?this.clear():"bell"===e?this.termScreen.load("UB"):"back"===e?this.moveBack():"new-line"===e?(this.newLine(),this.cursor.x=0):"return"===e?this.cursor.x=0:"set-cursor"===e?(this.cursor.x=arguments.length<=2?void 0:arguments[2],this.cursor.y=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-y"===e?(this.cursor.y+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-x"===e?(this.cursor.x+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"move-cursor-line"===e?(this.cursor.x=0,this.cursor.y+=arguments.length<=1?void 0:arguments[1],this.clampCursor()):"set-cursor-x"===e?this.cursor.x=arguments.length<=1?void 0:arguments[1]:"set-cursor-style"===e?this.cursor.style=Math.max(0,Math.min(6,arguments.length<=1?void 0:arguments[1])):"reset-style"===e?this.style=m.slice():"add-attrs"===e?this.style[2]|=arguments.length<=1?void 0:arguments[1]:"set-color-fg"===e?(this.style[0]=arguments.length<=1?void 0:arguments[1],this.style[2]|=1):"set-color-bg"===e?(this.style[1]=arguments.length<=1?void 0:arguments[1],this.style[2]|=2):"reset-color-fg"===e?(this.style[0]=0,1&this.style[2]&&(this.style[2]^=1)):"reset-color-bg"===e?(this.style[1]=0,2&this.style[2]&&(this.style[2]^=2)):"hide-cursor"===e?this.cursor.visible=!1:"show-cursor"===e&&(this.cursor.visible=!0)}},{key:"write",value:function(e){this.parser.write(e)}},{key:"getScreenOpts",value:function(){var e="O";e+=v(25),e+=v(80),e+=v(this.theme),e+=this.encodeColor(this.defaultFG),e+=this.encodeColor(this.defaultBG);var t=+this.cursor.visible;return t|=96*+this.trackMouse,t|=384,t|=this.cursor.style<<9,e+=v(t)}},{key:"getButtons",value:function(){var e="B";return e+=v(this.buttonLabels.length),e+=this.buttonLabels.map(function(e){return""+e+""}).join("")}},{key:"getTitle",value:function(){return"TESPTerm Web UI Demo"}},{key:"getCursor",value:function(){var e="C";return e+=v(this.cursor.y),e+=v(this.cursor.x),e+=v(0)}},{key:"encodeColor",value:function(e){return e<256?v(e):(e-=256,v(4095&e|65536)+v(e>>12))}},{key:"serializeScreen",value:function(){var e="S";e+=v(0)+v(0),e+=v(this.height)+v(this.width);var t=[null,null,null],n=0,i=!0,r=!1,o=void 0;try{for(var s,a=this.screen[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value,u=l[1].slice();if(this.rainbow){var c=n%this.width,h=Math.floor(n/this.width),d=(c+h)/10+Date.now()/1e3;this.superRainbow&&(d=(c*h+Date.now())/100+Date.now()/1e3),u[0]=g(d),u[1]=0,this.superRainbow&&(u[1]=g(d/10)),u[2]=1|u[2],!this.superRainbow&&2&u[2]&&(u[2]^=2),n++}var f=u[0],p=u[1],m=u[2],y=f!==t[0],w=p!==t[1],b=m!==t[2];y&&w?f<256&&p<256?e+=""+v(p<<8|f):(e+=""+this.encodeColor(f),e+=""+this.encodeColor(p)):y?e+=""+this.encodeColor(f):w&&(e+=""+this.encodeColor(p)),b&&(e+=""+v(m)),t=u,e+=l[0]}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}return e}},{key:"getUpdate",value:function(){var e=[],t=this.getScreenOpts(),n=this.getTitle(),i=this.getButtons(),r=this.getCursor(),o=this.serializeScreen();return this._screenOpts!==t&&(this._screenOpts=t,e.push(t)),this._title!==n&&(this._title=n,e.push(n)),this._buttons!==i&&(this._buttons=i,e.push(i)),this._cursor!==r&&(this._cursor=r,e.push(r)),this._screen!==o&&(this._screen=o,e.push(o)),e.length?"U"+v(0)+e.join(""):""}},{key:"loadTimer",value:function(){var e=this;clearInterval(this._loadTimer),this._loadTimer=setInterval(function(){var t=e.getUpdate();t&&e.termScreen.load(t)},30)}}]),e}(),w=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"write",value:function(e){this.emit("in",e)}},{key:"destroy",value:function(){this.emit("exit",0)}},{key:"run",value:function(){}}]),t}(u),b={buttons:[],mouseReceiver:null},k={clear:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write",""),this.destroy()}}]),t}(w),screenfetch:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(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="",i=0;i<t.length;i++)for(var r=0;r<80;r++)t[i][r]?n+="[38;5;"+g((r+i)/10)+"m"+t[i][r]:n+=" ";this.emit("write","\r\n[?25l");!function t(){e.emit("write",n.substr(0,80)),n=n.substr(80),n.length?setTimeout(t,50):(e.emit("write","\r\n[?25h"),e.destroy())}()}}]),t}(w),"local-echo":function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(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 and may not work as expected in this demo\n"),this.emit("buttons",[{label:"Exit",action:function(e){e.write("")}}])}},{key:"write",value:function(e){this.emit("write",e)}}]),t}(w),info:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];var r=n.includes("--fast");this.showSplash().then(function(){e.printText(r)})}},{key:"showSplash",value:function(){var e=this,t="\n -#####- -###*..#####- ######-\n -#* -#- .## .##. *#-\n -##### .-###*..#####- *#- -*##*- #*-#--#**#-*##-\n -#* -#-.##. *#- *##@#* ##. -#* *# .#*\n -#####--####- .##. *#- -*#@@- ##. -#* *# .#*\n ".split("\n").filter(function(e){return e.trim()}),n={" ":-231,".":4,"-":8,"*":17,"#":24},i={" ":" ",".":"░","-":"▒","*":"▓","#":"█"};for(var r in t)t[r].length<79&&(t[r]+=" ".repeat(79-t[r].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 i=t-o,r=n-s;e.emit("write","["+Math.abs(i)+(i>0?"C":"D")),e.emit("write","["+Math.abs(r)+(r>0?"B":"A")),o=t,s=n},l=function(r,o){if(a(r,o),"@"===t[o][r])e.emit("write","▄\b");else{var s=231+n[t[o][r]],l=i[t[o][r]];e.emit("write","[48;5;"+s+"m[38;5;"+s+"m"+l+"\b")}};return new Promise(function(n,i){var r=e,o=13,s=0;!function e(){for(var i=0;i<t.length;i++){var u=o-i;u>0&&l(u,i)}++o<70?++s>=3?(setTimeout(e,50),s=0):e():(a(0,t.length),r.emit("write","[?25h"),n())}()})}},{key:"printText",value:function(){var e=arguments.length>0&&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;!function e(){n.emit("write",t.shift()+"\r\n"),t.length?setTimeout(e,17):n.destroy()}()}}}]),t}(w),colors:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write","\r\n");this.emit("write"," ");for(var e=0;e<16;e++)this.emit("write","["+(e<8?"3"+e:"9"+(e-8))+"m"),this.emit("write","foreground-color"[e]+" ");this.emit("write","\r\n ");for(var t=0;t<16;t++)this.emit("write","["+(t<8?"4"+t:"10"+(t-8))+"m ");this.emit("write","\r\n");for(var n=0;n<6;n++){this.emit("write"," ");for(var i=0;i<6;i++){for(var r=0;r<6;r++)this.emit("write","[48;5;"+(16+36*n+6*i+r)+"m ");this.emit("write","")}this.emit("write","\r\n")}this.emit("write"," ");for(var o=0;o<24;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),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){this.emit("write","List of demo commands\r\n");for(var e in k)"string"!=typeof k[e]&&this.emit("write",e+"\r\n");this.destroy()}}]),t}(w),theme:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),l(t,[{key:"run",value:function(){var e=0|+(arguments.length<=0?void 0:arguments[0]),t=f.length;if(!arguments.length||!Number.isFinite(e)||e<0||e>=t)return this.emit("write","Usage: theme [0–"+(t-1)+"]\n"),void this.destroy();this.shell.terminal.theme=e,this.shell.terminal.termScreen.drawnScreenFG=[],this.emit("write",""),this.destroy()}}]),t}(w),themes:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n.parser=new p(function(){return n.handler.apply(n,arguments)}),n}return o(t,e),l(t,[{key:"destroy",value:function(){this.shell.terminal.cursor.style=this.savedCursorStyle,this.emit("write","\n\n"),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"run",value:function(){var e=this;this.savedCursorStyle=this.shell.terminal.cursor.style,this.shell.terminal.cursor.style=3,this.fgType=0,this.bgType=0;var t=function(){return e.shell.terminal.defaultFG-256},n=function(t){e.shell.terminal.defaultFG=t+256},i=function(){return e.shell.terminal.defaultBG-256},r=function(t){e.shell.terminal.defaultBG=t+256},o=function(t,n,i,r,o){return n*=4,{label:t,length:1,getValue:function(){return i()>>n&15},getDisplay:function(){return(i()>>n&15).toString(16)},setValue:function(e){r(i()&(16777215^15<<n)|(15&e)<<n)},shouldShow:function(){return 1===e[o+"Type"]},parseValue:function(e){return 15&parseInt(e,16)},moveAfterInput:0!==n}};this.controls=[{label:"Theme: ",length:f.length.toString().length,getValue:function(){return e.shell.terminal.theme},setValue:function(t){var n=f.length;e.shell.terminal.theme=(t%n+n)%n}},{label:" Default Foreground: ",length:6,getValue:function(){return e.fgType},getDisplay:function(){return 0===e.fgType?"256":"24-bit"},setValue:function(t){e.fgType=(t%2+2)%2}},{label:" ",length:3,getValue:function(){return 255&e.shell.terminal.defaultFG},setValue:function(t){e.shell.terminal.defaultFG=255&t},shouldShow:function(){return 0===e.fgType},parseValue:function(e){return parseInt(e,16)}},o(" #",5,t,n,"fg"),o("",4,t,n,"fg"),o("",3,t,n,"fg"),o("",2,t,n,"fg"),o("",1,t,n,"fg"),o("",0,t,n,"fg"),{label:" Default Background: ",length:6,getValue:function(){return e.bgType},getDisplay:function(){return 0===e.bgType?"256":"24-bit"},setValue:function(t){e.bgType=(t%2+2)%2}},{label:" ",length:3,getValue:function(){return 255&e.shell.terminal.defaultBG},setValue:function(t){e.shell.terminal.defaultBG=255&t},shouldShow:function(){return 0===e.bgType},parseValue:function(e){return parseInt(e,16)}},o(" #",5,i,r,"bg"),o("",4,i,r,"bg"),o("",3,i,r,"bg"),o("",2,i,r,"bg"),o("",1,i,r,"bg"),o("",0,i,r,"bg")],this.selection=0,this.emit("write","Themes\n\n\n\n"),this.render()}},{key:"render",value:function(){this.emit("write","\r"),this.emit("write"," ".repeat(this.shell.terminal.width-1)+"\r");var e=0,t=0,n=!0,i=!1,r=void 0;try{for(var o,s=this.controls[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;if(!a.shouldShow||a.shouldShow()){a.label&&this.emit("write",""+a.label+""),this.emit("write","");var l=a.getDisplay?a.getDisplay():a.getValue().toString();this.emit("write",(a.fill||" ").repeat(Math.max(0,a.length-l.length))),this.emit("write",l.substr(0,a.length)),this.emit("write",""),e===this.selection?(t=this.shell.terminal.cursor.x-1,this.emit("write","▲▼")):this.emit("write","  "),e++}}}catch(e){i=!0,r=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw r}}this.shell.terminal.cursor.x=t}},{key:"write",value:function(e){this.parser.write(e)}},{key:"getControlCount",value:function(){var e=0,t=!0,n=!1,i=void 0;try{for(var r,o=this.controls[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){var s=r.value;s.shouldShow&&!s.shouldShow()||e++}}catch(e){n=!0,i=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw i}}return e}},{key:"getSelectedControl",value:function(){var e=null,t=0,n=!0,i=!1,r=void 0;try{for(var o,s=this.controls[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){var a=o.value;if(!a.shouldShow||a.shouldShow()){if(t===this.selection){e=a;break}t++}}}catch(e){i=!0,r=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw r}}return e}},{key:"handler",value:function(e){for(var t,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];if((t=console).log.apply(t,[e].concat(i)),"move-cursor-x"===e){this.selection+=i[0];var o=this.getControlCount();this.selection=(this.selection%o+o)%o}else if("move-cursor-y"===e){var s=this.getSelectedControl();s&&s.setValue(s.getValue()-i[0])}else if("write"===e){var a=this.getSelectedControl();if(a&&a.parseValue){var l=a.parseValue(i[0]);Number.isFinite(l)&&(a.setValue(l),a.moveAfterInput&&this.selection<this.getControlCount()-1&&this.selection++)}}this.render()}}]),t}(w),cursor:function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t.includes("--steady");t.includes("block")?this.emit("write","["+2*i+" q"):t.includes("line")?this.emit("write","["+(3+i)+" q"):t.includes("bar")||t.includes("beam")?this.emit("write","["+(5+i)+" q"):this.emit("write","Usage: cursor [block|line|bar] [--steady]\r\n"),this.destroy()}}]),t}(w),rainbow:function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.shell=e,i.su=n.su,i.abort=!1,i}return o(t,e),l(t,[{key:"write",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];"y"===e?(this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.superRainbow=!0,b._didWarnRainbow=!0):this.emit("write",e),t&&this.emit("write","Rainbow!\n"),this.destroy()}},{key:"run",value:function(){this.su&&!this.shell.terminal.rainbow?b._didWarnRainbow?this.write("y",!1):this.emit("write","Warning: flashy colors. Continue? [y/N] "):(this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.superRainbow=!1,this.destroy())}},{key:"destroy",value:function(){this.abort=!0,a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}}]),t}(w),mouse:function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n}return o(t,e),l(t,[{key:"run",value:function(){var e=this,t=this;this.emit("buttons",[{label:"Exit",action:function(e){e.write("")}},{label:"Add Box",action:function(){t.boxes.push(t.generateRandomBox()),t.render()}}]),this.shell.terminal.trackMouse=!0,b.mouseReceiver=this,this.boxes=Array(3).fill(0).map(function(t){return e.generateRandomBox()}),this.grabbedBox=null,this.grabOffset=[0,0],this.render()}},{key:"render",value:function(){this.emit("write",""),this.emit("write","Mouse Demo\r\nMove boxes around or scroll their contents!");var e=!0,t=!1,n=void 0;try{for(var i,r=this.boxes[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){var o=i.value;this.emit("write","["+(o.y+1)+";"+(o.x+1)+"H"),this.emit("write","[48;2;"+o.color.join(";")+"m");for(var s=o.y;s<o.y+o.height;s++){for(var a=0,l=o.x;l<o.x+o.width;l++)l<0||l>=this.shell.terminal.width-1||s<0||s>=this.shell.terminal.height||(a++,this.emit("write",o.content[s-o.y][l-o.x]));this.emit("write","".repeat(a)+"")}}}catch(e){t=!0,n=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw n}}this.mouse&&this.emit("write","["+(this.mouse.y+1)+";"+(this.mouse.x+1)+"H")}},{key:"generateRandomBox",value:function(){for(var e="abcdefghijklmnopqrstuvwxyz-*()!@#$%",t=[],n=[5,10,15][Math.floor(3*Math.random())],i=[4,5,6][Math.floor(3*Math.random())],r=0;r<i;r++){t.push("");for(var o=0;o<n;o++)Math.random()>.6?t[r]+=e[Math.floor(Math.random()*e.length)]:t[r]+=" "}return{x:Math.floor(Math.random()*(this.shell.terminal.width-1))+1,y:Math.floor(Math.random()*(this.shell.terminal.height-1))+1,width:n,height:i,color:[Math.random(),Math.random(),Math.random()].map(function(e){return Math.floor(255*e)}),content:t}}},{key:"getBoxAt",value:function(e,t){var n=this.boxes.slice().reverse(),i=!0,r=!1,o=void 0;try{for(var s,a=n[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value;if(l.x<=e&&l.x+l.width>e&&l.y<=t&&l.y+l.height>t)return l}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}}},{key:"mouseMove",value:function(e,t){this.mouse={x:e,y:t},this.grabbedBox&&(this.grabbedBox.x=e+this.grabOffset[0],this.grabbedBox.y=t+this.grabOffset[1]),this.render()}},{key:"mouseDown",value:function(e,t,n){if(4===n)this.scrollInsideBox(this.getBoxAt(e,t),-1);else if(5===n)this.scrollInsideBox(this.getBoxAt(e,t),1);else{var r=this.getBoxAt(e,t);if(r){var o;this.grabbedBox=r,this.grabOffset=[r.x-e,r.y-t],(o=this.boxes).push.apply(o,i(this.boxes.splice(this.boxes.indexOf(r),1)))}}this.render()}},{key:"mouseUp",value:function(e,t,n){this.grabbedBox=null}},{key:"scrollInsideBox",value:function(e,t){if(e){var n=e.content.slice();e.content=[];for(var i=0;i<n.length;i++)e.content.push(n[(i+t%n.length+n.length)%n.length])}}},{key:"destroy",value:function(){this.shell.terminal.write(""),this.shell.terminal.trackMouse=!1,b.mouseReceiver===this&&(b.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=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.shell=e,n.didDestroy=!1,n}return o(t,e),l(t,[{key:"run",value:function(){for(var e=this,t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];if(0===n.length)this.emit("write","Usage: sudo [command]\r\n"),this.destroy();else{var r=n.shift();if(this.shell.index[r]){var o=this.shell.index[r];if(o instanceof Function){var s=this.child=new o(this.shell,{su:!0});this.on("in",function(e){return s.write(e)});var a=function(t){return e.emit("write",t)},l=function(t){return e.emit("buttons",t)};s.on("write",a),s.on("buttons",l),s.on("exit",function(t){s.removeListener("write",a),s.removeListener("buttons",l),e.destroy()}),s.run.apply(s,n)}else this.emit("write",o),this.destroy()}else this.emit("write","sudo: "+r+": command not found\r\n"),this.destroy()}}},{key:"destroy",value:function(){this.didDestroy||(this.didDestroy=!0,this.child&&this.child.destroy(),a(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this))}}]),t}(w),make:function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};s(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.su=n.su,i}return o(t,e),l(t,[{key:"run",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(0===t.length)this.emit("write","make: *** No targets specified. Stop.\r\n");else if(3===t.length&&"me a sandwich"===t.join(" ").toLowerCase())if(this.su){var i="",r="",o="",s="";this.emit("write"," _.---._\r\n _.-~ ~-._\r\n _.-~ ~-._\r\n _.-~ ~---._\r\n _.-~ ~\\\r\n .-~ _.;\r\n :-._ _.-~ ./\r\n `-._~-._ _..__.-~ _.-~\r\n "+o+"/ "+i+"~-._~-._ / .__..--"+o+"~-"+r+"---._\r\n"+o+" \\_____(_"+i+";-._\\. _.-~_/"+o+" ~)"+r+".. . \\\r\n"+r+" /(_____ "+i+"\\`--...--~_.-~"+o+"______..-+"+r+"_______)\r\n"+r+" .(_________/"+i+"`--...--~/"+r+" _/ "+s+" "+i+"/\\\r\n"+i+" /-._"+s+" \\_ "+r+"(___./_..-~"+s+"__....."+i+"__..-~./\r\n"+i+" `-._~-._"+s+" ~\\--------~ .-~"+i+"_..__.-~ _.-~\r\n"+i+" ~-._~-._ "+s+"~---------` "+i+"/ .__..--~\r\n"+i+" ~-._\\. _.-~_/\r\n"+i+" \\`--...--~_.-~\r\n"+i+" `--...--~\r\n")}else this.emit("write","make: me a sandwich : Permission denied\r\n");else 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),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),l(t,[{key:"run",value:function(){window.open("https://github.com/espterm/espterm-firmware"),this.destroy()}}]),t}(w)},_={"local-echo":"local-echo [--suppress-note]",theme:"theme [n]",cursor:"cursor [block|line|bar] [--steady]",sudo:"sudo [command]"},S=function(){function e(t,n){var i=this;s(this,e),this.terminal=t,this.terminal.reset(),this.parser=new p(function(){return i.handleParsed.apply(i,arguments)}),this.history=[],this.historyIndex=0,this.cursorPos=0,this.lastInputLength=0,this.child=null,this.index=k,n?this.run("info"):this.prompt()}return l(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=!(arguments.length>0&&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,this.setButtons()}},{key:"copyFromHistoryIndex",value:function(){if(this.historyIndex){var e=this.history[this.historyIndex];this.history[0]=e,this.historyIndex=0}}},{key:"getCompleted",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.history[0]){var t=this.history[0],n="";if(t.startsWith("sudo ")){var i=t.replace(/^(sudo\s+)+/,"");n=t.substr(0,t.length-i.length),t=i}if(!t)return null;for(var r in this.index)if(r.startsWith(t)&&r!==t)return e&&r in _?n+_[r]:n+r;return null}return null}},{key:"handleParsed",value:function(e){if(this.terminal.write("["+(this.lastInputLength-this.cursorPos)+"P"),this.terminal.write("\b".repeat(this.cursorPos)),"write"===e)this.copyFromHistoryIndex(),this.history[0]=this.history[0].substr(0,this.cursorPos)+(arguments.length<=1?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),--this.cursorPos<0&&(this.cursorPos=0);else if("tab"===e){var t=this.getCompleted();t&&(this.history[0]=t,this.cursorPos=this.history[0].length)}else if("move-cursor-x"===e)this.cursorPos=Math.max(0,Math.min(this.history[this.historyIndex].length,this.cursorPos+(arguments.length<=1?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 n=this.history[0].substr(0,this.cursorPos).split(" ");n.pop(),this.history[0]=n.join(" ")+this.history[0].substr(this.cursorPos),this.cursorPos=n.join(" ").length}else"move-cursor-y"===e&&(this.historyIndex-=arguments.length<=1?void 0:arguments[1],this.historyIndex<0&&(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.lastInputLength=this.cursorPos;var i=this.getCompleted(!0);if(0===this.historyIndex&&i&&"return"!==e){var r=i.substr(this.history[0].length);this.terminal.write(""+r+""+"\b".repeat(r.length)),this.lastInputLength+=r.length}"return"===e&&(this.terminal.write("\n"),this.parse(this.history[this.historyIndex]))}},{key:"parse",value:function(e){"help"===e&&(e="info"),e?this.run(e):this.prompt()}},{key:"run",value:function(e){var t=[""],n=!1,i=!0,r=!1,o=void 0;try{for(var s,a=e.trim()[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){var l=s.value;n&&l!==n?t[t.length-1]+=l:n?n=!1:'"'===l||"'"===l?n=l:l.match(/\s/)?t[t.length-1]&&t.push(""):t[t.length-1]+=l}}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}var u=t.shift();u in this.index?this.spawn(u,t):(this.terminal.write("demosh: Unknown command: "+u+"\r\n"),this.prompt(!1))}},{key:"spawn",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.index[e];if(r instanceof Function){var o;this.setButtons([]),this.child=new r(this);var s=function(e){return t.terminal.write(e)},a=function(e){return t.setButtons(e)};this.child.on("write",s),this.child.on("buttons",a),this.child.on("exit",function(e){t.child&&(t.child.removeListener("write",s),t.child.removeListener("buttons",a)),t.child=null,t.prompt(!e)}),(o=this.child).run.apply(o,i(n))}else this.terminal.write(r),this.prompt()}},{key:"setButtons",value:function(e){if(!e){var t=this,n=function(e){var n=function n(){t.write(e[0]),(e=e.substr(1))&&setTimeout(n,100)};setTimeout(n,200)};e=[{label:"Open GitHub",action:function(e){e.child&&e.child.destroy(),n("github\r")}},{label:"Help",action:function(e){e.child&&e.child.destroy(),n("info\r")}}]}e.length||e.push({label:"",action:function(){}}),this.buttons=e,this.terminal.buttonLabels=e.map(function(e){return e.label})}},{key:"onButtonPress",value:function(e){var t=this.buttons[e];t&&t.action(this,this.terminal)}}]),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 i=n.charCodeAt(0);this.shell.onButtonPress(i-1)}else if("m"===t||"p"===t||"r"===t){var r=h(n,0),o=h(n,2),s=h(n,4),a=h(n,6);b.mouseReceiver&&("m"===t?b.mouseReceiver.mouseMove(o,r,s,a):"p"===t?b.mouseReceiver.mouseDown(o,r,s,a):"r"===t&&b.mouseReceiver.mouseUp(o,r,s,a))}},didInit:!1,init:function(e){this.didInit||(this.didInit=!0,this.terminal=new y(e),this.shell=new S(this.terminal,!0))}}},function(e,t,n){"use strict";var i=n(14);e.exports=function(e){return i[e]||"?"+e+"?"}},function(e,t,n){"use strict";n(11),n(4),n(5),n(12);try{n(8)}catch(e){}n(13);var i=n(1),r=n(0),o=r.qs;window.termInit=n(15),window.$=i,window.qs=o,window.themes=n(3),window.TermConf=n(26)},function(e,t,n){"use strict";/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
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,i=function(){var e,i,r=[],o=-1,s=arguments.length;if(!s)return"";for(var a="";++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||n(l)!=l)throw RangeError("Invalid code point: "+l);l<=65535?r.push(l):(l-=65536,e=55296+(l>>10),i=l%1024+56320,r.push(e,i)),(o+1==s||r.length>16384)&&(a+=t.apply(null,r),r.length=0)}return a};e?e(String,"fromCodePoint",{value:i,configurable:!0,writable:!0}):String.fromCodePoint=i}()},function(e,t,n){"use strict";function i(){d=!0,r("#content").addClass("load")}var r=n(1),o=n(0),s=o.mk,a=o.qs,l=o.qsa,u=o.cr,c=n(4),h=n(5);r.ready(function(){function e(){r("#menu").toggleClass("expanded")}r("#brand").on("click",e).on("keypress",u(e)),r(".Row.checkbox").forEach(function(e){var t=e.querySelector("input"),n=e.querySelector(".box");r(n).toggleClass("checked",t.value);var i=function(){t.value=1-t.value,r(n).toggleClass("checked",t.value)};r(e).on("click",i).on("keypress",u(i))}),r(".Box.mobcol,.Box.fold").forEach(function(e){var t=e.querySelector("h2"),n=function(){r(e).hasClass("d-expanded")?r(e).removeClass("d-expanded"):r(e).toggleClass("expanded")};r(t).on("click",n).on("keypress",u(n))}),r("form").forEach(function(e){r(e).on("keypress",function(t){10!==t.keyCode&&13!==t.keyCode||!t.ctrlKey||e.submit()})}),setInterval(function(){r(".anim-dots").each(function(e){var t=r(e),n=t.html()+".";5===n.length&&(n="."),t.html(n)})},1e3),r("input[type=number]").on("wheel",function(e){var t=r(this),n=+t.val();isNaN(n)&&(n=1);var i=+(t.attr("step")||1),o=+t.attr("min"),s=+t.attr("max");if(e.deltaY>0?n+=i:n-=i,Number.isFinite(o)&&(n=Math.max(n,+o)),Number.isFinite(s)&&(n=Math.min(n,+s)),t.val(n),"createEvent"in document){var a=document.createEvent("HTMLEvents");a.initEvent("change",!1,!0),t[0].dispatchEvent(a)}else t[0].fireEvent("onchange");e.preventDefault()});try{do{var t=void 0,n=void 0;if(-1!==(t=window.location.search.indexOf("err="))&&a(".Box.errors")){if("break"===function(){var e=decodeURIComponent(window.location.search.substr(t+4)).split(","),n=[];return e.forEach(function(e){if(0!==e.length){var t=l('label[for="'+e+'"]');if(t&&t.length>0)for(var i=0;i<t.length;i++){var r=t[i];r.classList.add("error"),0===i&&n.push(r.childNodes[0].textContent.trim().replace(/: ?$/,""))}else console.log(JSON.stringify(e)),n.push(e)}}),a(".Box.errors .list").innerHTML=n.join(", "),a(".Box.errors").classList.remove("hidden"),"break"}())break}var i=function(e,t){e.classList.remove("hidden"),setTimeout(function(){e.classList.add("hiding"),setTimeout(function(){e.classList.add("hidden")},1e3)},t)};if(t=window.location.search.indexOf("errmsg="),n=a(".Box.errmessage"),-1!==t&&n){var o=decodeURIComponent(window.location.search.substr(t+7));n.innerHTML=o,i(n,3e3);break}if(t=window.location.search.indexOf("msg="),n=a(".Box.message"),-1!==t&&n){var s=decodeURIComponent(window.location.search.substr(t+4));n.innerHTML=s,i(n,2e3);break}}while(0)}catch(e){console.error(e)}if(c.init(),h.init(),window.innerWidth>550){r(".Box h2").forEach(function(e){e.removeAttribute("tabindex")});var d=a("#brand");d&&d.addEventListener("click",function(){window.location.href="/"})}}),r._loader=function(e){r("#loader").toggleClass("show",e)};var d=!1;window.showPage=i,r.ready(function(){!0===window.noAutoShow?setTimeout(function(){if(!d){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),a("#screen").classList.add("failed"),i()}},2e3):setTimeout(function(){i()},1)})},function(e,t,n){"use strict";var i=n(1),r=n(0),o=r.mk,s=n(9),a=window.location.protocol.match(/s:/),l=function(e){return"+"+(.25*e.value).toFixed(2)+" dBm"},u=function(e,t,n){i("#sta_ssid").val(e),i("#sta_password").val(t),i("#sta-nw").toggleClass("hidden",0===e.length),i("#sta-nw-nil").toggleClass("hidden",e.length>0),i("#sta-nw .essid").html(i.htmlEscape(e));var r=!!t;i("#sta-nw .passwd").toggleClass("hidden",!r),i("#sta-nw .nopasswd").toggleClass("hidden",r),i("#sta-nw .ip").html(n.length>0?s("wifi.connected_ip_is")+n:s("wifi.not_conn"))},c=function(e,t){if(200!==t)return void f(5e3);try{e=JSON.parse(e)}catch(e){return console.log(e),void f(5e3)}var n=!e.result.inProgress&&e.result.APs.length>0;if(f(n?15e3:1e3),n){var r=i("#ap-list");i("#ap-list .AP").remove(),r.toggleClass("hidden",!n),i("#ap-loader").toggleClass("hidden",n),e.result.APs.sort(function(e,t){return t.rssi-e.rssi}).forEach(function(e){if(e.enc=parseInt(e.enc),!(e.enc>4)){var t=o("div"),n=i(t).data("ssid",e.essid).data("pwd",e.enc).attr("tabindex",0).addClass("AP");e.essid===g&&n.addClass("selected");var a=o("div"),l=i.htmlEscape(e.essid);i(a).addClass("inner").htmlAppend('<div class="rssi">'+e.rssi_perc+"</div>").htmlAppend('<div class="essid" title="'+l+'">'+l+"</div>").htmlAppend('<div class="auth">'+m[e.enc]+"</div>"),n.on("click",function(){var e=i(this),t=e.data("ssid"),n="";+e.data("pwd")&&!(n=window.prompt(s("wifi.enter_passwd").replace(":ssid:",t)))||(i("#sta_password").val(n),i("#sta_ssid").val(t),u(t,n,""))}),t.appendChild(a),r[0].appendChild(t)}})}},h=function(){i("#ap-loader").removeClass("hidden"),i("#ap-scan").addClass("hidden"),i("#ap-loader .anim-dots").html("."),d()},d=function(){window._demo?c(window._demo_aps,200):i.get((a?"https":"http")+"://"+window._root+"/cfg/wifi/scan",c)},f=function(e){setTimeout(d,e)},v=function(e){i(".Row.range").forEach(function(e){var t=e.querySelector("input"),n=e.querySelector(".x-disp1"),r=e.querySelector(".x-disp2"),o=l(t);i(n).html(o),i(r).html(o),i(t).on("input",function(){o=l(t),i(n).html(o),i(r).html(o)})}),i("#forget-sta").on("click",function(){return u("","",""),!1}),u(e.sta_ssid,e.sta_password,e.sta_active_ip),g=e.sta_active_ssid},p=window.WiFi={},m=["Open","WEP","WPA","WPA2","WPA/WPA2"],g=void 0;p.init=v,p.startScanning=h},function(e,t){e.exports={"wifi.connected_ip_is":"Connected, IP is ","wifi.not_conn":"Not connected.","wifi.enter_passwd":'Enter password for ":ssid:"',"term_nav.fullscreen":"Fullscreen","term_conn.connecting":"Connecting","term_conn.waiting_content":"Waiting for content","term_conn.disconnected":"Disconnected","term_conn.waiting_server":"Waiting for server","term_conn.reconnecting":"Reconnecting"}},function(e,t,n){"use strict";function i(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 r=n(1),o=n(0),s=o.qs,a=o.mk,l=n(9),u=n(5),c=n(16),h=n(20),d=n(21),f=n(22),v=n(23),p=n(24),m=n(25);e.exports=function(e){var t=new c,n=new h(t),o=d(n,t),g=f(n,o,t);o.termUpload=g,t.on("mousedown",function(){return o.onMouseDown.apply(o,arguments)}),t.on("mousemove",function(){return o.onMouseMove.apply(o,arguments)}),t.on("mouseup",function(){return o.onMouseUp.apply(o,arguments)}),t.on("mousewheel",function(){return o.onMouseWheel.apply(o,arguments)}),t.on("input-alts",function(){return o.setAlts.apply(o,arguments)}),t.on("mouse-mode",function(){return o.setMouseMode.apply(o,arguments)}),r.ready(function(){var e=s("#touch-select-menu");t.on("show-touch-select-menu",function(t,n){var i=e.getBoundingClientRect();t-=i.width/2,n-=i.height/2,e.classList.add("open"),e.style.transform="translate("+t+"px,"+n+"px)"}),t.on("hide-touch-select-menu",function(){return e.classList.remove("open")});var n=s("#touch-select-copy-btn");n&&n.addEventListener("click",function(){t.copySelectionToClipboard()})});var y=m(o);t.on("buttons-update",function(e){y.labels=e.labels,y.colors=e.colors}),y.palette=t.layout.renderer.palette,t.layout.renderer.on("palette-update",function(e){y.palette=e}),t.on("full-load",function(){var e=s("#screen"),t=s("#load-failed");e&&e.classList.remove("failed"),t&&t.parentNode.removeChild(t)});var w=function(e){var t=[].concat(i(document.querySelectorAll(".x-term-conf-btn")));e?t.forEach(function(e){return e.classList.remove("hidden")}):t.forEach(function(e){return e.classList.add("hidden")})},b=function(e){e?s("#action-buttons").classList.remove("hidden"):s("#action-buttons").classList.add("hidden")};t.on("opts-update",function(){w(t.showLinks),b(t.showButtons)}),t.on("title-update",function(e){s("#screen-title").textContent=e,e||(e="Terminal"),s("title").textContent=e+" :: ESPTerm"});var k=null,_=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;clearTimeout(k),k=setTimeout(function(){t.window.statusScreen=e},n)};n.on("open",function(){_({title:l("term_conn.connecting"),loading:!0})}),n.on("connect",function(){_({title:l("term_conn.waiting_content"),loading:!0})}),t.on("load",function(){clearTimeout(k),t.window.statusScreen&&(t.window.statusScreen=null)}),n.on("disconnect",function(){_({title:l("term_conn.disconnected")},500),t.screen=[],t.screenFG=[],t.screenBG=[],t.screenAttrs=[]}),n.on("silence",function(){_({title:l("term_conn.waiting_server"),loading:!0},0)}),n.on("ping-success",function(){_({title:l("term_conn.reconnecting"),loading:!0},0)}),n.init(),o.init(e),g.init(),u.init(),window.onerror=function(e,t,n,i){return u.show("<b>JS ERROR!</b><br>"+e+"<br>at "+t+":"+n+":"+i,1e4,!0),!1},s("#screen").appendChild(t.layout.canvas),v(t,o),p&&p(t,n);var S={},C=!1,x=!1,T=!1,L=t.layout.window.padding,A=function(){C?(S.className="icn-resize-small",x?(t.layout.window.fitIntoWidth=window.screen.width,t.layout.window.fitIntoHeight=window.screen.height,t.layout.window.padding=0):(t.layout.window.fitIntoWidth=window.innerWidth,s("#term-nav").classList.contains("hidden")?t.layout.window.fitIntoHeight=window.innerHeight:t.layout.window.fitIntoHeight=window.innerHeight-24,t.layout.window.padding=0)):(S.className="icn-resize-full",t.layout.window.fitIntoWidth=T?window.innerWidth-4:0,t.layout.window.fitIntoHeight=T?window.innerHeight:0,t.layout.window.padding=L)};A(),window.addEventListener("resize",A);var E=function(){T=!T;var e=s("#resize-button-icon");T?(e.classList.remove("icn-resize-small"),e.classList.add("icn-resize-full")):(e.classList.remove("icn-resize-full"),e.classList.add("icn-resize-small")),A()};if(s("#term-fit-screen").addEventListener("click",function(){return E(),!1}),window.Element.prototype.requestFullscreen||window.Element.prototype.webkitRequestFullscreen){x=!0;var P=function(){!C||window.innerWidth===window.screen.width&&window.innerHeight===window.screen.height||(C=!1,A())};setInterval(P,500)}var R=a("a");R.id="fullscreen-button",R.href="#",R.addEventListener("click",function(e){if(e.preventDefault(),document.body.classList.contains("pseudo-fullscreen"))return document.body.classList.remove("pseudo-fullscreen"),C=!1,void A();C=!0,A(),t.layout.updateSize(),x?t.layout.canvas.requestFullscreen?t.layout.canvas.requestFullscreen():t.layout.canvas.webkitRequestFullscreen():document.body.classList.add("pseudo-fullscreen")}),S=a("i"),S.className="icn-resize-full",R.appendChild(S);var F=a("span");F.textContent=l("term_nav.fullscreen"),R.appendChild(F),s("#term-nav").insertBefore(R,s("#term-nav").firstChild),window.termScreen=t,window.buttons=y,window.conn=n,window.input=o,window.termUpl=g}},function(e,t,n){"use strict";function i(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 r(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 i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(2),u=n(0),c=u.mk,h=n(5),d=n(17),f=n(18),v=n(6),p=v.ATTR_BLINK;e.exports=function(e){function t(){r(this,t);var e=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.parser=new d,e.layout=new f,e._debug=null,"AudioContext"in window||"webkitAudioContext"in window?e.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn("No AudioContext!"),e._window={width:0,height:0,debug:0,statusScreen:null},e.window=new Proxy(e._window,{set:function(e,t,i){return e[t]!==i&&(e[t]=i,n.updateLayout(),n.renderScreen("window:"+t+"="+i),n.emit("update-window:"+t,i)),!0}}),e.on("update-window:debug",function(t){e.layout.window.debug=!!t}),e.cursor={x:0,y:0,blinking:!0,visible:!0,hanging:!1,style:"block"};var n=e;e.selection={selectable:null,start:[0,0],end:[0,0],setSelectable:function(e){e!==this.selectable&&(this.selectable=n.layout.selectable=e)}},e.mouseMode={clicks:!1,movement:!1},e.showLinks=!1,e.showButtons=!1,e.title="",e.bracketedPaste=!1,e.blinkingCellCount=0,e.reverseVideo=!1,e.screen=[],e.screenFG=[],e.screenBG=[],e.screenAttrs=[],e.screenLines=[];var s=!1,a=function(t,n){s||(s=!0,e.selection.start=e.selection.end=e.layout.screenToGrid(t,n,!0),e.renderScreen("select-start"))},l=function(t,n){s&&(e.selection.end=e.layout.screenToGrid(t,n,!0),e.renderScreen("select-move"))},u=function(t,n){s&&(s=!1,e.selection.end=e.layout.screenToGrid(t,n,!0),e.renderScreen("select-end"),Object.assign(e.selection,e.getNormalizedSelection()))};e.layout.on("mousedown",function(t){e.emit("hide-touch-select-menu"),(e.selection.selectable||t.altKey)&&0===t.button?a(t.offsetX,t.offsetY):e.emit.apply(e,["mousedown"].concat(i(e.layout.screenToGrid(t.offsetX,t.offsetY)),[t.button+1]))}),window.addEventListener("mousemove",function(e){l(e.offsetX,e.offsetY)}),window.addEventListener("mouseup",function(e){u(e.offsetX,e.offsetY)});var c=null,h=0,v=!1,p=function(t){var n=e.layout.canvas.getBoundingClientRect();return[t.clientX-n.left,t.clientY-n.top]};e.layout.on("touchstart",function(t){if(c=p(t.touches[0]),v=!1,h=Date.now(),e.mouseMode.clicks){var n;e.emit.apply(e,["mousedown"].concat(i((n=e.layout).screenToGrid.apply(n,i(c))),[1])),t.preventDefault()}}),e.layout.on("touchmove",function(t){if(c=p(t.touches[0]),s||!1!==v){if(s)t.preventDefault(),l.apply(void 0,i(c));else if(e.mouseMode.movement&&!s){var n;e.emit.apply(e,["mousemove"].concat(i((n=e.layout).screenToGrid.apply(n,i(c))))),t.preventDefault()}}else h<Date.now()-500&&a.apply(void 0,i(c));v=!0}),e.layout.on("touchend",function(t){if(t.touches[0]&&(c=p(t.touches[0])),s){t.preventDefault(),u.apply(void 0,i(c));var n=e.layout.gridToScreen((e.selection.start[0]+e.selection.end[0])/2,e.selection.start[1]-1);e.emit("show-touch-select-menu",n[0],n[1])}else if(e.mouseMode.clicks){var r;e.emit.apply(e,["mouseup"].concat(i((r=e.layout).screenToGrid.apply(r,i(c))),[1])),t.preventDefault()}v||e.mouseMode.clicks?v||e.resetSelection():e.emit("tap",Object.assign(t,{x:c[0],y:c[1]})),c=null}),e.on("tap",function(t){e.selection.start[0]!==e.selection.end[0]||e.selection.start[1]!==e.selection.end[1]?e.resetSelection():(t.preventDefault(),e.emit("open-soft-keyboard"))}),e.layout.on("mousemove",function(t){s||e.emit.apply(e,["mousemove"].concat(i(e.layout.screenToGrid(t.offsetX,t.offsetY))))}),e.layout.on("mouseup",function(t){s||e.emit.apply(e,["mouseup"].concat(i(e.layout.screenToGrid(t.offsetX,t.offsetY)),[t.button+1]))});var m=0;return e.layout.on("wheel",function(t){e.mouseMode.clicks&&(120===Math.abs(t.wheelDeltaY)?e.emit.apply(e,["mousewheel"].concat(i(e.layout.screenToGrid(t.offsetX,t.offsetY)),[t.deltaY>0?1:-1])):(m-=t.wheelDeltaY,Math.abs(m)>=40&&(e.emit.apply(e,["mousewheel"].concat(i(e.layout.screenToGrid(t.offsetX,t.offsetY)),[m>0?1:-1])),m=0)),t.preventDefault())}),e.layout.on("contextmenu",function(t){e.mouseMode.clicks&&t.preventDefault(),u(t.offsetX,t.offsetY)}),e}return s(t,e),a(t,[{key:"resetScreen",value:function(){var e=this.window,t=e.width,n=e.height;this.blinkingCellCount=0,this.screen.screen=new Array(t*n).fill(" "),this.screen.screenFG=new Array(t*n).fill(0),this.screen.screenBG=new Array(t*n).fill(0),this.screen.screenAttrs=new Array(t*n).fill(0),this.screen.screenLines=new Array(n).fill(0)}},{key:"updateLayout",value:function(){this.layout.window.width=this.window.width,this.layout.window.height=this.window.height}},{key:"renderScreen",value:function(e){for(var t=[],n=0;n<this.screen.length;n++)t.push(this.isInSelection(n%this.window.width,Math.floor(n/this.window.width)));this.layout.render(e,{width:this.window.width,height:this.window.height,screen:this.screen,screenFG:this.screenFG,screenBG:this.screenBG,screenSelection:t,screenAttrs:this.screenAttrs,screenLines:this.screenLines,cursor:this.cursor,statusScreen:this.window.statusScreen,reverseVideo:this.reverseVideo,hasBlinkingCells:!!this.blinkingCellCount})}},{key:"resetSelection",value:function(){this.selection.start=this.selection.end=[0,0],this.emit("hide-touch-select-menu"),this.renderScreen("select-reset")}},{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 i=[n,t];t=i[0],n=i[1]}return{start:t,end:n}}},{key:"isInSelection",value:function(e,t){var n=this.getNormalizedSelection(),i=n.start,r=n.end,o=i[0]<=e,s=e<r[0],a=t===i[1],l=t===r[1];return a&&l?o&&s:a?o:l?s:i[1]<t&&t<r[1]}},{key:"getSelectedText",value:function(){for(var e=this.window.width*this.window.height,t=[],n=-1,i=0;i<e;i++){var r=i%this.window.width,o=Math.floor(i/this.window.width);this.isInSelection(r,o)&&(n!==o&&(n=o,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=c("textarea");document.body.appendChild(t),t.value=e,t.select(),document.execCommand("copy")?h.show("Copied to clipboard"):h.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():h.show(e)}},{key:"beep",value:function(){var e=this.audioCtx;if(e&&!(this._lastBeep&&this._lastBeep>Date.now()-50)){if(this._lastBeep=Date.now(),!this._convolver){this._convolver=e.createConvolver();for(var t=.8*e.sampleRate,n=e.createBuffer(2,t,e.sampleRate),i=0;i<t;i++)n.getChannelData(0)[i]=Math.pow(1-i/t,7+Math.random()),n.getChannelData(1)[i]=Math.pow(1-i/t,7+Math.random());this._convolver.buffer=n,this._convolver.connect(e.destination)}var r=e.createOscillator(),o=e.createGain();r.connect(o),o.gain.value=4,r.frequency.value=750,r.type="sine";var s=e.createOscillator(),a=e.createGain();s.connect(a),a.gain.value=2,s.frequency.value=400,s.type="sine",o.connect(this._convolver),a.connect(this._convolver);var l=e.currentTime;r.start(),r.stop(l+.5),s.start(l+.05),s.stop(l+.8);!function t(){e.currentTime<l+.8&&window.requestAnimationFrame(t),o.gain.value*=.8,a.gain.value*=.8}()}}},{key:"load",value:function(){var e,t=(e=this.parser).parse.apply(e,arguments),n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var l=s.value;switch(l.topic){case"screen-opts":l.width===this.window.width&&l.height===this.window.height||(this.window.width=l.width,this.window.height=l.height,this.resetScreen()),this.layout.renderer.loadTheme(l.theme),this.layout.renderer.setDefaultColors(l.defFG,l.defBG),this.cursor.visible=l.cursorVisible,this.emit.apply(this,["input-alts"].concat(i(l.inputAlts))),this.mouseMode.clicks=l.trackMouseClicks,this.mouseMode.movement=l.trackMouseMovement,this.emit("mouse-mode",l.trackMouseClicks,l.trackMouseMovement),this.selection.setSelectable(!l.trackMouseClicks&&!l.trackMouseMovement),this.cursor.blinking!==l.cursorBlinking&&(this.cursor.blinking=l.cursorBlinking,this.layout.renderer.resetCursorBlink()),this.cursor.style=l.cursorStyle,this.bracketedPaste=l.bracketedPaste,this.reverseVideo=l.reverseVideo,this.window.debug&=1,this.window.debug|=+l.debugEnabled<<1,this.showLinks=l.showConfigLinks,this.showButtons=l.showButtons,this.emit("opts-update");break;case"double-lines":this.screenLines=l.lines,this.renderScreen("double-lines");break;case"static-opts":this.layout.window.fontFamily=l.fontStack||null,this.layout.window.fontSize=l.fontSize;break;case"cursor":this.cursor.x===l.x&&this.cursor.y===l.y&&this.cursor.hanging===l.hanging||(this.cursor.x=l.x,this.cursor.y=l.y,this.cursor.hanging=l.hanging,this.layout.renderer.resetCursorBlink(),this.emit("cursor-moved"),this.renderScreen("cursor-moved"));break;case"title":this.emit("title-update",this.title=l.title);break;case"buttons-update":this.emit("buttons-update",l);break;case"backdrop":this.backgroundImage=l.image;break;case"bell":this.beep();break;case"internal":this.emit("internal",l);break;case"content":var u=l.frameX,c=l.frameY,h=l.frameWidth,d=l.frameHeight,f=l.cells;this._debug&&this.window.debug&&this._debug.pushFrame([u,c,h,d]);for(var v=0;v<f.length;v++){var m=f[v],g=v%h,y=Math.floor(v/h),w=(c+y)*this.window.width+u+g;(this.screenAttrs[w]&p)!=(m[3]&p)&&(m[3]&p?this.blinkingCellCount++:this.blinkingCellCount--),this.screen[w]=m[0],this.screenFG[w]=m[1],this.screenBG[w]=m[2],this.screenAttrs[w]=m[3]}this.window.debug&&console.log("Blinking cells: "+this.blinkingCellCount),this.renderScreen("load"),this.emit("load");break;case"full-load-complete":this.emit("full-load");break;case"notification":this.showNotification(l.content);break;default:console.warn("Unhandled update",l)}}}catch(e){r=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw o}}this.emit("update")}}]),t}(l)},function(e,t,n){"use strict";function i(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 r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){if(!e)return NaN;var t=e.codePointAt(0);return t>57343&&(t-=2048),t-1}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(6),l=a.ATTR_FG,u=a.ATTR_BG,c=a.ATTR_BOLD,h=a.ATTR_UNDERLINE,d=a.ATTR_BLINK,f=a.ATTR_STRIKE,v=a.ATTR_OVERLINE,p=a.ATTR_FAINT;e.exports=function(){function e(){r(this,e),this.contentLoaded=!1}return s(e,[{key:"parseUpdate",value:function(e){for(var t=0,n=Array.from?Array.from(e):e.split(""),i=void 0,r=o(n[t++]),s=function(){for(i="";t<n.length;){var e=n[t++];if(""===e)break;i+=e}return i},a=function(){var e=o(n[t++]);return 65536&e&&(e&=4095,e|=(4095&o(n[t++]))<<12,e+=256),e},m=[];t<n.length;){var g=n[t++];if("O"===g){var y=o(n[t++]),w=o(n[t++]),b=o(n[t++]),k=a(),_=a(),S=o(n[t++]),C=!!(1&S),x=[!!(4&S),!!(8&S),!!(16&S),!!(4096&S)],T=!!(32&S),L=!!(64&S),A=S>>9&7;A>0&&A--;var E=A>>1,P=!(1&A);E=0===E?"block":1===E?"line":"bar";var R=!!(128&S),F=!!(256&S),O=!!(8192&S),B=!!(16384&S),M=!!(2&S);m.push({topic:"screen-opts",width:w,height:y,theme:b,defFG:k,defBG:_,cursorVisible:C,cursorBlinking:P,cursorStyle:E,inputAlts:x,trackMouseClicks:T,trackMouseMovement:L,showButtons:R,showConfigLinks:F,bracketedPaste:O,reverseVideo:B,debugEnabled:M})}else if("C"===g){var D=o(n[t++]),I=o(n[t++]),N=!!o(n[t++]);m.push({topic:"cursor",x:I,y:D,hanging:N})}else if("P"===g){var j=s(),G=o(n[t++]);m.push({topic:"static-opts",fontStack:j,fontSize:G})}else if("H"===g){for(var z=[],H=o(n[t++]),W=0;W<H;W++){var q=o(n[t++]);z[q>>3]=7&q}m.push({topic:"double-lines",lines:z})}else if("T"===g)m.push({topic:"title",title:s()});else if("B"===g){for(var U=o(n[t++]),V=[],K=[],X=0;X<U;X++)K.push(a()),V.push(s());m.push({topic:"buttons-update",labels:V,colors:K})}else if("W"===g)m.push({topic:"backdrop",image:s()});else if("!"===g)m.push({topic:"bell"});else if("D"===g){var Y=o(n[t++]),$=o(n[t++]),J=o(n[t++]),Q=o(n[t++]),Z=o(n[t++]),ee=n[t++],te=n[t++],ne=a(),ie=a(),re=o(n[t++]),oe=o(n[t++]);m.push({topic:"internal",flags:Y,cursorAttrs:$,regionStart:J,regionEnd:Q,charsetGx:Z,charsetG0:ee,charsetG1:te,cursorFg:ne,cursorBg:ie,freeHeap:re,clientCount:oe})}else"S"===g&&function(){for(var e=o(n[t++]),i=o(n[t++]),r=o(n[t++]),s=o(n[t++]),a=7,g=0,y=0,w=0,b=" ",k=s*r,_=h|v|f,S=d,C=[],x=function(){var e=y&l,t=y&u,n=a,i=g,r=y;e||(n=0),t||(i=0),r&S&&(" "===b&&0==(r&_)||a===g&&e&&t)&&(r^=S),r&c&&!(r&p)&&e&&n<8&&(n+=8),C.push([b,n,i,r])};t<n.length&&w<k;){var T=n[t++],L=T.codePointAt(0),A=void 0,E=void 0;switch(L){case 2:E=o(n[t++]);for(var P=0;P<E&&(x(),!(++w>k));P++);break;case 1:w+=o(n[t++]);break;case 3:A=o(n[t++]),a=255&A,g=A>>8&255;break;case 4:A=o(n[t++]),y=65535&A;break;case 7:y=0;break;case 5:A=o(n[t++]),65536&A&&(A&=4095,A|=(4095&o(n[t++]))<<12,A+=256),a=A;break;case 6:A=o(n[t++]),65536&A&&(A&=4095,A|=(4095&o(n[t++]))<<12,A+=256),g=A;break;default:L<32&&(T="<EFBFBD>"),b=T,x(),w++}}m.push({topic:"content",frameX:i,frameY:e,frameWidth:s,frameHeight:r,cells:C})}();59&r&&!this.contentLoaded&&(m.push({topic:"full-load-complete"}),this.contentLoaded=!0)}return m}},{key:"parse",value:function(e){var t=e.substr(1),n=[];switch(e[0]){case"U":n.push.apply(n,i(this.parseUpdate(t)));break;case"G":return[{topic:"notification",content:t}];default:console.warn("Bad data message type; ignoring.\n"+JSON.stringify(e))}return n}}]),e}()},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(2),l=n(19),u='"DejaVu Sans Mono", "Liberation Mono", "Inconsolata", "Menlo", monospace';e.exports=function(e){function t(){i(this,t);var e=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.canvas=document.createElement("canvas"),e.renderer=new l(e.canvas),e._window={width:0,height:0,devicePixelRatio:1,fontFamily:u,fontSize:20,padding:6,gridScaleX:1,gridScaleY:1.2,fitIntoWidth:0,fitIntoHeight:0,debug:!1},e._windowScale=1,e._padding=0,e.windowState={width:0,height:0,devicePixelRatio:0,padding:0,gridScaleX:0,gridScaleY:0,fontFamily:"",fontSize:0,fitIntoWidth:0,fitIntoHeight:0},e.charSize={width:0,height:0};var n=e;return e.window=new Proxy(e._window,{set:function(e,t,i){return e[t]!==i&&(e[t]=i,n.scheduleSizeUpdate(),n.renderer.scheduleDraw("window:"+t+"="+i),n.emit("update-window:"+t,i)),!0}}),e.on("update-window:debug",function(t){e.renderer.debug=t}),e.canvas.addEventListener("mousedown",function(t){return e.emit("mousedown",t)}),e.canvas.addEventListener("mousemove",function(t){return e.emit("mousemove",t)}),e.canvas.addEventListener("mouseup",function(t){return e.emit("mouseup",t)}),e.canvas.addEventListener("touchstart",function(t){return e.emit("touchstart",t)}),e.canvas.addEventListener("touchmove",function(t){return e.emit("touchmove",t)}),e.canvas.addEventListener("touchend",function(t){return e.emit("touchend",t)}),e.canvas.addEventListener("wheel",function(t){return e.emit("wheel",t)}),e.canvas.addEventListener("contextmenu",function(t){return e.emit("contextmenu",t)}),e}return o(t,e),s(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=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.style||"normal",n=e.weight||"normal",i=this.window.fontFamily||"";return i.length>0&&(i+=","),i+=u,t+" normal "+n+" "+this.window.fontSize+"px "+i}},{key:"screenToGrid",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.getCellSize();return e=e/this._windowScale-this._padding,t=t/this._windowScale-this._padding,t=Math.floor(t/i.height),this.renderer.drawnScreenLines[t]&&(e/=2),e=Math.floor((e+(n?i.width/2:0))/i.width),e=Math.max(0,Math.min(this.window.width-1,e)),t=Math.max(0,Math.min(this.window.height-1,t)),[e,t]}},{key:"gridToScreen",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.getCellSize();return this.renderer.drawnScreenLines[t]&&(e*=2),[e*r.width,t*r.height].map(function(e){return n._padding+(i?e*n._windowScale:e)})}},{key:"updateCharSize",value:function(){return this.charSize={width:this.renderer.getCharWidthFor(this.getFont()),height:this.window.fontSize},this.charSize}},{key:"getCellSize",value:function(){return!this.charSize.height&&this.window.fontSize&&this.updateCharSize(),{width:Math.ceil(this.charSize.width*this.window.gridScaleX),height:Math.ceil(this.charSize.height*this.window.gridScaleY)}}},{key:"updateSize",value:function(){this._window.devicePixelRatio=Math.ceil(this._windowScale*(window.devicePixelRatio||1));var e=!1;for(var t in this.windowState)this.windowState.hasOwnProperty(t)&&this.windowState[t]!==this.window[t]&&(e=!0,this.windowState[t]=this.window[t]);if(e){var n=this.window,i=n.width,r=n.height,o=n.fitIntoWidth,s=n.fitIntoHeight,a=n.padding;this.updateCharSize();var l=this.getCellSize(),u=i*l.width,c=r*l.height,h=u;if(o&&s){var d=u/c;d<o/s?(c=s-2*a,u=c*d):(u=o-2*a,c=u/d)}this._windowScale=u/h,u+=2*a,c+=2*a,this._padding=a*(h/u);var f=this._window.devicePixelRatio=Math.ceil(this._windowScale*(window.devicePixelRatio||1));this.canvas.width=(i*l.width+2*Math.round(this._padding))*f,this.canvas.style.width=u+"px",this.canvas.height=(r*l.height+2*Math.round(this._padding))*f,this.canvas.style.height=c+"px",this.renderer.resetDrawn(),this.renderer.render("update-size",this.serializeRenderData()),this.emit("size-update")}}},{key:"serializeRenderData",value:function(){return{padding:Math.round(this._padding),devicePixelRatio:this.window.devicePixelRatio,charSize:this.charSize,cellSize:this.getCellSize(),fonts:[this.getFont(),this.getFont({weight:"bold"}),this.getFont({style:"italic"}),this.getFont({weight:"bold",style:"italic"})]}}},{key:"render",value:function(e,t){this.window.width=t.width,this.window.height=t.height,Object.assign(t,this.serializeRenderData()),this.renderer.render(e,t)}},{key:"backgroundImage",get:function(){return this.canvas.style.backgroundImage},set:function(e){this.canvas.style.backgroundImage=e?"url("+e+")":"",this.renderer.backgroundImage!==!!e&&(this.renderer.backgroundImage=!!e,this.renderer.resetDrawn(),this.renderer.scheduleDraw("background-image"))}},{key:"selectable",get:function(){return this.canvas.classList.contains("selectable")},set:function(e){e?this.canvas.classList.add("selectable"):this.canvas.classList.remove("selectable")}}]),t}(a)},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)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")}}(),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),l=n(2),u=n(3),c=u.themes,h=u.getColor,d=n(6),f=d.ATTR_FG,v=d.ATTR_BG,p=d.ATTR_BOLD,m=d.ATTR_UNDERLINE,g=d.ATTR_INVERSE,y=d.ATTR_BLINK,w=d.ATTR_ITALIC,b=d.ATTR_STRIKE,k=d.ATTR_OVERLINE,_=d.ATTR_FAINT,S=d.ATTR_FRAKTUR,C={C:"ℭ",H:"ℌ",I:"ℑ",R:"ℜ",Z:"ℨ"};e.exports=function(e){function t(e){i(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.canvas=e,n.ctx=n.canvas.getContext("2d"),n._palette=null,n.defaultBG=0,n.defaultFG=7,n.debug=!1,n._debug=null,n.graphics=0,n.statusFont="-apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif",n.width=0,n.height=0,n.padding=0,n.charSize={width:0,height:0},n.cellSize={width:0,height:0},n.fonts=["","","",""],n.screen=[],n.screenFG=[],n.screenBG=[],n.screenAttrs=[],n.screenSelection=[],n.screenLines=[],n.cursor={},n.reverseVideo=!1,n.hasBlinkingCells=!1,n.statusScreen=null,n.resetDrawn(),n.blinkStyleOn=!1,n.blinkInterval=null,n.cursorBlinkOn=!1,n.cursorBlinkInterval=null,n.resetBlink(),n.resetCursorBlink(),n}return o(t,e),a(t,[{key:"render",value:function(e,t){"hasBlinkingCells"in t&&t.hasBlinkingCells!==this.hasBlinkingCells&&(t.hasBlinkingCells?this.resetBlink():clearInterval(this.blinkInterval)),Object.assign(this,t),this.scheduleDraw(e)}},{key:"resetDrawn",value:function(){this.debug&&console.log("Resetting drawn screen"),this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.drawnScreenLines=[],this.drawnCursor=[-1,-1,"",!1]}},{key:"getCharWidthFor",value:function(e){return this.ctx.font=e,Math.floor(this.ctx.measureText(" ").width)}},{key:"loadTheme",value:function(e){e in c&&(this.palette=c[e])}},{key:"setDefaultColors",value:function(e,t){e===this.defaultFG&&t===this.defaultBG||(this.resetDrawn(),this.defaultFG=e,this.defaultBG=t,this.scheduleDraw("default-colors"),this.canvas.style.backgroundColor=this.getColor(t))}},{key:"scheduleDraw",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;clearTimeout(this._scheduledDraw),this._scheduledDraw=setTimeout(function(){return t.draw(e)},n)}},{key:"getColor",value:function(e){return h(e,this.palette)}},{key:"resetCursorBlink",value:function(){var e=this;this.cursorBlinkOn=!0,clearInterval(this.cursorBlinkInterval),this.cursorBlinkInterval=setInterval(function(){e.cursorBlinkOn=!e.cursor.blinking||!e.cursorBlinkOn,e.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(){e.blinkingCellCount<=0||(t++,t>=4&&e.blinkStyleOn?(e.blinkStyleOn=!1,t=0,e.scheduleDraw("blink-style")):t>=1&&!e.blinkStyleOn&&(e.blinkStyleOn=!0,t=0,e.scheduleDraw("blink-style")))},200)}},{key:"drawBackground",value:function(e){var t=e.x,n=e.y,i=e.cellWidth,r=e.cellHeight,o=e.bg,s=e.isDefaultBG,a=this.ctx,l=this.width,u=this.height,c=this.padding;1&this.screenLines[n]&&(i*=2),a.fillStyle=this.getColor(o);var h=t*i+c,d=n*r+c,f=0===t||0===n||t===l-1||n===u-1,v=void 0,p=void 0,m=void 0,g=void 0;if(f){var y=h,w=d,b=h+i,k=d+r;0===t?y-=c:t===l-1&&(b+=c),0===n?w-=c:n===u-1&&(k+=c),v=y,p=w,m=b-y,g=k-w}else v=h,p=d,m=i,g=r;a.clearRect(v,p,m,g),(!s||o<0||!this.backgroundImage)&&a.fillRect(v,p,m,g)}},{key:"drawCharacter",value:function(e){var n=e.x,i=e.y,r=e.charSize,o=e.cellWidth,s=e.cellHeight,a=e.text,l=e.fg,u=e.attrs;if(a){var c=this.ctx,h=this.padding,d=!1,f=!1,v=!1;u&_&&(c.globalAlpha=.5),u&m&&(d=!0),u&S&&(a=t.alphaToFraktur(a)),u&b&&(f=!0),u&k&&(v=!0),c.fillStyle=this.getColor(l);var p=n*o+h,g=i*s+h,y=1&this.screenLines[i],w=2&this.screenLines[i],C=4&this.screenLines[i];this.screenLines[i]&&(y&&(o*=2),c.save(),c.translate(h,g+.5*s),y&&c.scale(2,1),w?(c.scale(1,2),c.translate(0,s/4)):C&&(c.scale(1,2),c.translate(0,-s/4)),c.translate(-h,-g-.5*s),y&&c.translate(-o/4,0),(C||w)&&(c.beginPath(),w?c.rect(p,g,o,s/2):c.rect(p,g+s/2,o,s/2),c.clip()));var x=a.codePointAt(0);if(x>=9600&&x<=9631){c.beginPath();var T=p,L=g,A=o,E=s,P=o/2,R=s/2;if(9600===x)c.rect(T,L,A,R);else if(x<=9608){var F=(1-(x-9600)/8)*E;c.rect(T,L+F,A,E-F)}else if(x<=9615){var O=(x-9608)/8*A;c.rect(T,L,A-O,E)}else if(9616===x)c.rect(T+P,L,P,E);else if(x<=9619){var B=void 0,M=void 0,D=void 0;9617===x?(B=A/4,M=E/10,D=1):9618===x?(B=A/6,M=A/10,D=1):9619===x&&(B=A/4,M=A/7,D=2);for(var I=!1,N=0;N<E;N+=M){for(var j=0;j<A;j+=B){var G=Math.min(D,E-N);c.rect(T+(I?A-j-D:j),L+N,D,G)}I=!I}}else 9620===x?c.rect(T,L,A,E/8):9621===x?c.rect(T+7/8*A,L,A/8,E):9622===x?c.rect(T,L+R,P,R):9623===x?c.rect(T+P,L+R,P,R):9624===x?c.rect(T,L,P,R):9625===x?(c.rect(T,L,P,E),c.rect(T+P,L+R,P,R)):9626===x?(c.rect(T,L,P,R),c.rect(T+P,L+R,P,R)):9627===x?(c.rect(T,L,P,E),c.rect(T+P,L,P,R)):9628===x?(c.rect(T,L,A,R),c.rect(T+P,L+R,P,R)):9629===x?c.rect(T+P,L,P,R):9630===x?(c.rect(T,L+R,P,R),c.rect(T+P,L,P,R)):9631===x&&(c.rect(T,L+R,P,R),c.rect(T+P,L,P,E));c.fill()}else x>=57520&&x<=57523?(c.beginPath(),57520===x||57521===x?(c.moveTo(p,g),c.lineTo(p+o,g+s/2),c.lineTo(p,g+s)):57522!==x&&57523!==x||(c.moveTo(p+o,g),c.lineTo(p,g+s/2),c.lineTo(p+o,g+s)),x%2==0?c.fill():(c.strokeStyle=c.fillStyle,c.stroke())):c.fillText(a,p+.5*o,g+.5*s);if(d||f||v){if(c.strokeStyle=this.getColor(l),c.lineWidth=1,c.lineCap="round",c.beginPath(),d){var z=Math.round(g+r.height)+.5;c.moveTo(p,z),c.lineTo(p+o,z)}if(f){var H=Math.round(g+.5*s)+.5;c.moveTo(p,H),c.lineTo(p+o,H)}if(v){var W=Math.round(g)+.5;c.moveTo(p,W),c.lineTo(p+o,W)}c.stroke()}this.screenLines[i]&&c.restore(),c.globalAlpha=1}}},{key:"getAdjacentCells",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.width,i=this.height,r=n*i,o=[],s=-t;s<=t;s++)for(var a=-t;a<=t;a++)0===s&&0===a||o.push(e+s+a*n);return o.filter(function(e){return e>=0&&e<r})}},{key:"draw",value:function(e){var t=this.ctx,n=this.width,i=this.height,r=this.devicePixelRatio,o=this.statusScreen;if(o)return this.drawStatus(o),void this.startDrawLoop();this.stopDrawLoop();var a=this.charSize,l=this.cellSize,u=l.width,c=l.height,h=n*i;t.setTransform(r,0,0,r,0,0),this.debug&&this._debug&&this._debug.drawStart(e),t.font=this.fonts[0],t.textAlign="center",t.textBaseline="middle";for(var d=p|w,m=new Map,b=new Map,k=0;k<h;k++){var _=k%n,S=Math.floor(k/n),C=this.cursorBlinkOn&&this.cursor.x===_&&this.cursor.y===S&&this.cursor.visible,x=_===this.drawnCursor[0]&&S===this.drawnCursor[1],T=this.screen[k],L=0|this.screenFG[k],A=0|this.screenBG[k],E=0|this.screenAttrs[k],P=this.screenSelection[k],R=!1;if(E&f||(L=this.defaultFG),E&v||(A=this.defaultBG,R=!0),E&g){var F=[A,L];L=F[0],A=F[1]}if(this.reverseVideo){var O=[A,L];L=O[0],A=O[1]}E&y&&!this.blinkStyleOn&&(T=" "),P&&(L=-1,A=-2);var B=T!==this.drawnScreen[k]||L!==this.drawnScreenFG[k]||A!==this.drawnScreenBG[k]||E!==this.drawnScreenAttrs[k]||this.screenLines[S]!==this.drawnScreenLines[S]||C||x||C&&this.cursor.style!==this.drawnCursor[2]||C&&this.cursor.hanging!==this.drawnCursor[3],M=E&d;m.has(M)||m.set(M,[]),m.get(M).push({cell:k,x:_,y:S,text:T,fg:L,bg:A,attrs:E,isCursor:C,inSelection:P,isDefaultBG:R}),b.set(k,B)}this.drawnScreenLines=this.screenLines.slice();var D=[];if(this.graphics>=1){var I=!0,N=!1,j=void 0;try{for(var G,z=b.keys()[Symbol.iterator]();!(I=(G=z.next()).done);I=!0){var H=G.value;if(!b.get(H)){var W=b.get(H-1)||!1,q=b.get(H+1)||!1;W&&q&&(b.set(H,!0),this.debug&&this._debug&&D.push(H))}}}catch(e){N=!0,j=e}finally{try{!I&&z.return&&z.return()}finally{if(N)throw j}}}var U=new Map,V=new Map,K=function(e){return" "!==e&&t.measureText(e).width>=u+.05},X=!0,Y=!1,$=void 0;try{for(var J,Q=b.keys()[Symbol.iterator]();!(X=(J=Q.next()).done);X=!0){var Z=J.value,ee=b.get(Z)||U.get(Z)||!1,te=this.screen[Z],ne=K(te),ie=ne?2:1;if(!ee){var re=!1,oe=!0,se=!1,ae=void 0;try{for(var le,ue=this.getAdjacentCells(Z,ie)[Symbol.iterator]();!(oe=(le=ue.next()).done);oe=!0){var ce=le.value;if(b.get(ce)&&(this.graphics<2||ne||K(this.screen[ce]))&&!this.screenLines[Math.floor(Z/this.width)]&&!this.screenLines[Math.floor(ce/this.width)]){re=!0,this.getAdjacentCells(Z,1).includes(ce)&&V.set(Z,!0);break}}}catch(e){se=!0,ae=e}finally{try{!oe&&ue.return&&ue.return()}finally{if(se)throw ae}}re&&(ee=!0)}b.get(Z)&&V.set(Z,!0),U.set(Z,ee)}}catch(e){Y=!0,$=e}finally{try{!X&&Q.return&&Q.return()}finally{if(Y)throw $}}if(this.graphics>=1){for(var he=this.padding,de=[],fe=0;fe<i;fe++){for(var ve=null,pe=0;pe<n;pe++){var me=fe*n+pe,ge=V.get(me);ge&&null===ve&&(ve=pe),ge||null===ve||(de.push([ve,fe,pe,fe+1]),ve=null)}null!==ve&&de.push([ve,fe,n,fe+1])}for(var ye=0;ye<de.length;){for(var we=de[ye],be=0;be<de.length;){var ke=de[be];ke!==we?(ke[0]===we[0]&&ke[2]===we[2]&&ke[3]===we[1]&&(we[1]=ke[1],de.splice(be,1),ye>be&&ye--,be--),be++):be++}ye++}t.save(),t.beginPath();var _e=!0,Se=!1,Ce=void 0;try{for(var xe,Te=de[Symbol.iterator]();!(_e=(xe=Te.next()).done);_e=!0){var Le=xe.value,Ae=s(Le,4),Ee=Ae[0],Pe=Ae[1],Re=Ae[2],Fe=Ae[3],Oe=he+Ee*u,Be=he+Pe*c,Me=(Re-Ee)*u,De=(Fe-Pe)*c;0===Ee&&(Oe-=he,Me+=he),0===Pe&&(Be-=he,De+=he),Re===n-1&&(Me+=he),Pe===i-1&&(De+=he),t.rect(Oe,Be,Me,De)}}catch(e){Se=!0,Ce=e}finally{try{!_e&&Te.return&&Te.return()}finally{if(Se)throw Ce}}t.clip()}var Ie=!0,Ne=!1,je=void 0;try{for(var Ge,ze=m.keys()[Symbol.iterator]();!(Ie=(Ge=ze.next()).done);Ie=!0){var He=Ge.value,We=!0,qe=!1,Ue=void 0;try{for(var Ve,Ke=m.get(He)[Symbol.iterator]();!(We=(Ve=Ke.next()).done);We=!0){var Xe=Ve.value,Ye=Xe.cell,$e=Xe.x,Je=Xe.y,Qe=Xe.text,Ze=Xe.bg,et=Xe.isDefaultBG;if(U.get(Ye)&&(this.drawBackground({x:$e,y:Je,cellWidth:u,cellHeight:c,bg:Ze,isDefaultBG:et}),this.debug)){var tt=+U.get(Ye);tt|=+b.get(Ye)<<1,tt|=+V.get(Ye)<<2,tt|=+K(Qe)<<3,tt|=+D.includes(Ye)<<4,this._debug.setCell(Ye,tt)}}}catch(e){qe=!0,Ue=e}finally{try{!We&&Ke.return&&Ke.return()}finally{if(qe)throw Ue}}}}catch(e){Ne=!0,je=e}finally{try{!Ie&&ze.return&&ze.return()}finally{if(Ne)throw je}}this.drawnCursor=[-1,-1,"",!1];var nt=!0,it=!1,rt=void 0;try{for(var ot,st=m.keys()[Symbol.iterator]();!(nt=(ot=st.next()).done);nt=!0){var at=ot.value,lt=0;at&p&&(lt|=1),at&w&&(lt|=2),t.font=this.fonts[lt];var ut=!0,ct=!1,ht=void 0;try{for(var dt,ft=m.get(at)[Symbol.iterator]();!(ut=(dt=ft.next()).done);ut=!0){var vt=dt.value,pt=vt.cell,mt=vt.x,gt=vt.y,yt=vt.text,wt=vt.fg,bt=vt.bg,kt=vt.attrs,_t=vt.isCursor,St=vt.inSelection;if(U.get(pt)&&(this.drawCharacter({x:mt,y:gt,charSize:a,cellWidth:u,cellHeight:c,text:yt,fg:wt,attrs:kt}),this.drawnScreen[pt]=yt,this.drawnScreenFG[pt]=wt,this.drawnScreenBG[pt]=bt,this.drawnScreenAttrs[pt]=kt,_t&&(this.drawnCursor=[mt,gt,this.cursor.style,this.cursor.hanging]),_t&&!St)){t.save(),t.beginPath();var Ct=mt,xt=gt,Tt=u;this.cursor.hanging&&(Ct+=1),1&this.screenLines[xt]&&(Tt*=2);var Lt=Ct*Tt+this.padding,At=xt*c+this.padding;if("block"===this.cursor.style)t.rect(Lt,At,Tt,c);else if("bar"===this.cursor.style){t.rect(Lt,At,2,c)}else if("line"===this.cursor.style){t.rect(Lt,At+a.height,Tt,2)}t.clip();var Et=[bt,wt];wt=Et[0],bt=Et[1],wt===bt&&(bt=0===wt?7:0),this.drawBackground({x:Ct,y:xt,cellWidth:u,cellHeight:c,bg:bt}),this.drawCharacter({x:Ct,y:xt,charSize:a,cellWidth:u,cellHeight:c,text:yt,fg:wt,attrs:kt}),t.restore()}}}catch(e){ct=!0,ht=e}finally{try{!ut&&ft.return&&ft.return()}finally{if(ct)throw ht}}}}catch(e){it=!0,rt=e}finally{try{!nt&&st.return&&st.return()}finally{if(it)throw rt}}this.graphics>=1&&t.restore(),this.debug&&this._debug&&this._debug.drawEnd(),this.emit("draw",e)}},{key:"drawStatus",value:function(e){var t=this.ctx,n=this.width,i=this.height,r=this.devicePixelRatio;this.drawnScreen=[];var o=this.cellSize,s=n*o.width+2*this.padding,a=i*o.height+2*this.padding;if(t.setTransform(r,0,0,r,0,0),t.fillStyle=this.getColor(this.defaultBG),t.fillRect(0,0,s,a),t.font="24px "+this.statusFont,t.fillStyle=this.getColor(this.defaultFG),t.textAlign="center",t.textBaseline="middle",t.fillText(e.title||"",s/2,a/2-50),e.loading){t.save(),t.translate(s/2,a/2+20),t.strokeStyle=this.getColor(this.defaultFG),t.lineWidth=5,t.lineCap="round";for(var l=Date.now()/1e3,u=0;u<12;u++){t.rotate(Math.PI/6);var c=(12*l-u)%12;t.globalAlpha=Math.max(.2,1-c/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||c[0]},set:function(e){this._palette!==e&&(this._palette=e,this.resetDrawn(),this.emit("palette-update",e),this.scheduleDraw("palette"))}}],[{key:"alphaToFraktur",value:function(e){return e>="a"&&e<="z"?e=String.fromCodePoint(119997+e.charCodeAt(0)):e>="A"&&e<="Z"&&(e=C[e]||String.fromCodePoint(120003+e.charCodeAt(0))),e}}]),t}(l)},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=n(2),l=n(1),u=void 0;try{u=n(8)}catch(e){}var c=window.location.protocol.match(/s:/);e.exports=function(e){function t(e){i(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));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.queue=[];try{n.blobReader=new window.FileReader,n.blobReader.onload=function(e){n.onDecodedWSMessage(n.blobReader.result)},n.blobReader.onerror=function(e){console.error(e)}}catch(e){n.blobReader=null}return 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),s(t,[{key:"onWSOpen",value:function(e){console.log("CONNECTED"),this.heartbeat(),this.send("i"),this.forceClosing=!1,this.emit("connect")}},{key:"onWSClose",value:function(e){var t=this;if(this.forceClosing)return void(this.forceClosing=!1);console.warn("SOCKET CLOSED, code "+e.code+". Reconnecting..."),e.code<1e3&&console.error("Bad code from socket!"),clearTimeout(this.reconnTimeout),this.reconnTimeout=setTimeout(function(){return t.init()},2e3),this.emit("disconnect",e.code)}},{key:"onDecodedWSMessage",value:function(e){var t=this;switch(e.charAt(0)){case".":break;case"-":this.xoff=!0,this.autoXoffTimeout=setTimeout(function(){t.xoff=!1,t.flushQueue()},250);break;case"+":this.xoff=!1,this.flushQueue(),clearTimeout(this.autoXoffTimeout);break;default:this.screen.load(e),this.pageShown||(window.showPage(),this.pageShown=!0)}this.heartbeat()}},{key:"onWSMessage",value:function(e){var t=this;if("string"==typeof e.data)this.onDecodedWSMessage(e.data);else{if(!this.blobReader)return void console.error("No FileReader!");1!==this.blobReader.readyState?this.blobReader.readAsText(e.data):setTimeout(function(){t.onWSMessage(e)},1)}}},{key:"canSend",value:function(){return!this.xoff}},{key:"send",value:function(e){return window._demo?(void 0!==window.demoInterface?u.input(e):console.log("TX: "+JSON.stringify(e)),!0):this.xoff?(console.log("Can't send, flood control. Queueing"),this.queue.push(e),!1):!!this.ws&&(1!==this.ws.readyState?(console.error("Socket not ready"),!1):("string"!=typeof e&&(e=JSON.stringify(e)),this.ws.send(e),!0))}},{key:"flushQueue",value:function(){console.log("Flushing input queue");var e=!0,t=!1,n=void 0;try{for(var i,r=this.queue[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){var o=i.value;this.send(o)}}catch(e){t=!0,n=e}finally{try{!e&&r.return&&r.return()}finally{if(t)throw n}}this.queue=[]}},{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;if(window._demo)return void(void 0===window.demoInterface?window.alert("Demoing non-demo build!"):u.init(this.screen));clearTimeout(this.reconnTimeout),clearTimeout(this.heartbeatTimeout),this.closeSocket(),this.ws=new window.WebSocket((c?"wss":"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(),this.emit("open")}},{key:"heartbeat",value:function(){var e=this;this.emit("heartbeat"),clearTimeout(this.heartbeatTimeout),this.heartbeatTimeout=setTimeout(function(){return e.onHeartbeatFail()},3e3)}},{key:"sendPing",value:function(){var e=this;console.log("> ping"),this.emit("ping"),l.get((c?"https":"http")+"://"+window._root+"/api/v1/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})}},{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(){e.sendPing()},1e3),setTimeout(function(){e.sendPing()},200)}}]),t}(a)},function(e,t,n){"use strict";var i=n(0),r=i.encode2B;e.exports=function(e,t){function n(t){return e.send("s"+t)}function i(t){e.send("b"+String.fromCharCode(t+1))}function o(e){var i=e.allFn;window.addEventListener("keypress",function(e){if(b()&&!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)),t.length>0&&t.charCodeAt(0)>=32&&(32===e.which&&e.preventDefault(),n(t))}}),window.addEventListener("keydown",S),window.addEventListener("copy",function(e){if(b()){var n=t.getSelectedText();n&&(e.preventDefault(),e.clipboardData.setData("text/plain",n))}}),window.addEventListener("paste",function(e){if(b()){e.preventDefault();var i=e.clipboardData.getData("text/plain");i.includes("\n")||i.length>90?(l.termUpload||console.error("input.termUpload is undefined"),l.termUpload.setContent(i),l.termUpload.open()):(t.bracketedPaste&&(i="[200~"+i+"[201~"),n(i))}}),v.all_fn=i}function s(e){o(e),window.addEventListener("mousedown",function(e){0===e.button&&(C=1),1===e.button&&(x=1),2===e.button&&(T=1)}),window.addEventListener("mouseup",function(e){0===e.button&&(C=0),1===e.button&&(x=0),2===e.button&&(T=0)})}function a(){return L}for(var l=void 0,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"},c=48;c<=57;c++)u[c]=String.fromCharCode(c);for(var h=65;h<=90;h++)u[h]=String.fromCharCode(h);for(var d=112;d<=131;d++)u[d]="F"+(d-112+1);for(var f=96;f<=105;f++)u[f]="Numpad"+(f-96);for(var v={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 v.fn_alt?e:t},m=function(e,t){return v.cu_alt?e:t},g=function(e,t){return v.np_alt?e:t},y={Backspace:"\b",Tab:"\t",Enter:function(){return v.crlf_mode?"\r\n":"\r"},"Control+Enter":"\n",Escape:"",ArrowUp:function(){return m("OA","")},ArrowDown:function(){return m("OB","")},ArrowRight:function(){return m("OC","")},ArrowLeft:function(){return m("OD","")},Home:function(){return m("OH",p("","[1~"))},Insert:"[2~",Delete:"[3~",End:function(){return m("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 g("Op","0")},Numpad1:function(){return g("Oq","1")},Numpad2:function(){return g("Or","2")},Numpad3:function(){return g("Os","3")},Numpad4:function(){return g("Ot","4")},Numpad5:function(){return g("Ou","5")},Numpad6:function(){return g("Ov","6")},Numpad7:function(){return g("Ow","7")},Numpad8:function(){return g("Ox","8")},Numpad9:function(){return g("Oy","9")},"Numpad*":function(){return g("OR","*")},"Numpad+":function(){return g("Ol","+")},"Numpad-":function(){return g("OS","-")},"Numpad.":function(){return g("On",".")},"Numpad/":function(){return g("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}},w=1;w<=26;w++)y["Control+"+String.fromCharCode(64+w)]=String.fromCharCode(w);var b=function(){return!v.no_keys&&!(document.activeElement instanceof window.HTMLTextAreaElement)},k=["F5","F11","F12","Shift+F5"],_={alt:!1,ctrl:!1,meta:!1,shift:!1},S=function(e){if(b()){var t=[];(e.altKey||_.alt)&&t.push("Alt"),(e.ctrlKey||_.ctrl)&&t.push("Control"),(e.metaKey||_.meta)&&t.push("Meta"),(e.shiftKey||_.shift)&&t.push("Shift");var i=u[e.which]||e.key;if(!e.ctrlKey&&!e.metaKey||"V"!==i){var r=null;for(var o in y){var s=o.split("+");if(s.pop()===i&&s.sort().join()===t.join()){if(k.includes(o)&&!v.all_fn)continue;r=y[o];break}}r&&(r instanceof Function&&(r=r()),e.preventDefault(),"string"==typeof r&&n(r))}}},C=0,x=0,T=0,L=0;return window.addEventListener("keydown",function(e){e.ctrlKey&&(L|=1),e.shiftKey&&(L|=2),e.altKey&&(L|=4),e.metaKey&&(L|=8)}),window.addEventListener("keyup",function(e){L=0,e.ctrlKey&&(L|=1),e.shiftKey&&(L|=2),e.altKey&&(L|=4),e.metaKey&&(L|=8)}),l={init:s,sendString:n,sendButton:i,setAlts:function(e,t,n,i){v.cu_alt===e&&v.np_alt===t&&v.fn_alt===n&&v.crlf_mode===i||(v.cu_alt=e,v.np_alt=t,v.fn_alt=n,v.crlf_mode=i)},setMouseMode:function(e,t){v.mt_click=e,v.mt_move=t},onMouseMove:function(t,n){if(v.mt_move){var i=C?1:x?2:T?3:0,o=a();e.send("m"+r(n)+r(t)+r(i)+r(o))}},onMouseDown:function(t,n,i){if(v.mt_click&&!(i>3||i<1)){var o=a();e.send("p"+r(n)+r(t)+r(i)+r(o))}},onMouseUp:function(t,n,i){if(v.mt_click&&!(i>3||i<1)){var o=a();e.send("r"+r(n)+r(t)+r(i)+r(o))}},onMouseWheel:function(t,n,i){if(v.mt_click){var o=a(),s=i<0?4:5;e.send("p"+r(n)+r(t)+r(s)+r(o))}},blockKeys:function(e){v.no_keys=e},handleKeyDown:S,softModifiers:_}}},function(e,t,n){"use strict";var i=n(1),r=n(0),o=r.qs,s=n(4);e.exports=function(e,t,n){function r(){l("Ready..."),s.show("#fu_modal",a),i("#fu_form").toggleClass("busy",!1),t.blockKeys(!0)}function a(){console.log("Upload modal closed."),clearTimeout(p),v=0,t.blockKeys(!1)}function l(e){o("#fu_prog").textContent=e}function u(){var e=o("#fu_text").value;if(!e.length)return void d();f=e.split("\n"),v=0,w=0,m=+o("#fu_delay").value,m<0&&(m=0,o("#fu_delay").value=m),g={CR:"\r",LF:"\n",CRLF:"\r\n"}[o("#fu_crlf").value],i("#fu_form").toggleClass("busy",!0),l("Starting..."),c()}function c(){if(i("#fu_modal").hasClass("visible")){if(!e.canSend())return void(p=setTimeout(c,1));0===w&&(y="",0===v&&n.bracketedPaste&&(y="[200~"),y+=f[v++]+g,v===f.length&&n.bracketedPaste&&(y+="[201~"));var r=+o("#fu_chunk").value;(0===r||r>b)&&(r=b);var s=void 0;if(y.length-w<=r?(s=y.substr(w,r),w=0):(s=y.substr(w,r),w+=r),!t.sendString(s))return void l("FAILED!");var a=Math.round(v/f.length*1e3)/10;l(v+" / "+f.length+" ("+a+"%)"),f.length>v||w>0?p=setTimeout(c,m):h()}}function h(){e.canSend()?(l("Done."),d()):(l("Waiting for Tx buffer..."),setTimeout(h,100))}function d(){s.hide("#fu_modal")}var f=void 0,v=void 0,p=void 0,m=void 0,g=void 0,y=void 0,w=void 0,b=128;return{init:function(){o("#fu_file").addEventListener("change",function(e){var t=new window.FileReader,n=e.target.files[0],i=n.type||"application/octet-stream";if(console.log("Selected file type: "+i),!i.match(/text\/.*|application\/(json|csv|.*xml.*|.*script.*|x-php)/)&&!window.confirm("This does not look like a text file: "+i+"\nReally load?"))return void(o("#fu_file").value="");t.onload=function(e){var t=e.target.result.replace(/[\r\n]+/,"\n");o("#fu_text").value=t},console.log("Loading file..."),t.readAsText(n)},!1),o("#term-fu-open").addEventListener("click",function(e){e.preventDefault(),r()}),o("#term-fu-start").addEventListener("click",function(e){e.preventDefault(),u()}),o("#term-fu-close").addEventListener("click",function(e){e.preventDefault(),d()})},open:r,setContent:function(e){o("#fu_text").value=e}}}},function(e,t,n){"use strict";var i=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)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")}}(),r=n(0),o=r.qs;e.exports=function(e,t){var n=o("#softkb-input");if(n){var r=document.createElement("div");r.id="keyboard-shortcut-bar",navigator.userAgent.match(/iPad|iPhone|iPod/)&&o("#screen").appendChild(r);var s=!1,a=function(){if(s){var t=e.layout.gridToScreen(e.cursor.x,e.cursor.y,!0),r=i(t,2),o=r[0],a=r[1];n.style.transform="translate("+o+"px, "+a+"px)"}};n.addEventListener("focus",function(){s=!0,a(),r.classList.add("open")}),n.addEventListener("blur",function(){s=!1,r.classList.remove("open")}),e.on("cursor-moved",a),o("#term-kb-open").addEventListener("click",function(e){e.preventDefault(),n.focus()});var l="",u=function(e){null===e&&(e="");var n=!1;e.length>l.length?e.startsWith(l)?t.sendString(e.substr(l.length)):n=!0:e.length<l.length?l.startsWith(e)?t.sendString("\b".repeat(l.length-e.length)):n=!0:e!==l&&(n=!0),n&&t.sendString("\b".repeat(l.length)+e),l=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?u(e.data):e.isComposing?u(n.value):"insertCompositionText"===e.inputType?t.sendString(e.data):"deleteContentBackward"===e.inputType?(l="",u("")):"insertText"===e.inputType&&t.sendString(e.data)}),n.addEventListener("compositionstart",function(e){l=""}),n.addEventListener("compositionend",function(e){l="",n.value=""}),e.on("open-soft-keyboard",function(){return n.focus()});var c={Control:"ctrl",Esc:27,Tab:9,"←":37,"↓":40,"↑":38,"→":39},h=!1;for(var d in c)!function(e){var n=document.createElement("button");n.classList.add("shortcut-button"),n.textContent=e,r.appendChild(n);var i=c[e];"string"==typeof i&&n.classList.add("modifier"),n.addEventListener("touchstart",function(e){h=!1,"string"==typeof i&&(t.softModifiers[i]=!0,n.classList.add("enabled"),e.preventDefault())}),window.addEventListener("touchmove",function(e){h=!0}),n.addEventListener("touchend",function(e){if(e.preventDefault(),"number"==typeof i){if(h)return;var r={which:i,preventDefault:function(){}};t.handleKeyDown(r)}else"string"==typeof i&&(n.classList.remove("enabled"),t.softModifiers[i]=!1)})}(d)}}},function(e,t,n){"use strict";function i(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 r=function(){function e(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)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(3),s=o.getColor,a=n(6),l=a.ATTR_FG,u=a.ATTR_BG,c=a.ATTR_BOLD,h=a.ATTR_UNDERLINE,d=a.ATTR_BLINK,f=a.ATTR_ITALIC,v=a.ATTR_STRIKE,p=a.ATTR_OVERLINE,m=a.ATTR_FAINT,g=a.ATTR_FRAKTUR;e.exports=function(e,t){var n=document.createElement("canvas");n.classList.add("debug-canvas");var o=n.getContext("2d"),a=document.createElement("div");a.classList.add("debug-toolbar");var y=document.createElement("div");y.classList.add("debug-tooltip"),y.classList.add("hidden");var w=void 0,b=void 0,k=null,_=function(t){if(t.target!==e.layout.canvas)return void(k=null);k=e.layout.screenToGrid(t.offsetX,t.offsetY),w()},S=function(e){k=null,y.classList.add("hidden")},C=function(){var t=e.layout.window,i=t.width,r=t.height,o=t.devicePixelRatio,s=e.layout.getCellSize(),a=Math.round(e.layout._padding);n.width=(i*s.width+2*a)*o,n.height=(r*s.height+2*a)*o,n.style.width=i*s.width+2*e.layout._padding+"px",n.style.height=r*s.height+2*e.layout._padding+"px"},x=void 0,T=!1,L=void 0,A=function(t){t&&!n.parentNode?(e.layout.canvas.parentNode.appendChild(n),L=n.parentNode,L.addEventListener("mousemove",_),L.addEventListener("mouseout",S),e.layout.on("size-update",C),C(),T=!0,x()):!t&&n.parentNode&&(n.parentNode.removeChild(n),L.removeEventListener("mousemove",_),L.removeEventListener("mouseout",S),e.layout.removeListener("size-update",C),T=!1)},E=function(t){t&&!a.parentNode?(e.layout.canvas.parentNode.appendChild(a),e.layout.canvas.parentNode.appendChild(y),b()):!t&&a.parentNode&&(e.layout.canvas.parentNode.removeChild(a),e.layout.canvas.parentNode.removeChild(y))};e.on("update-window:debug",function(e){E(e)}),e.layout.on("update-window:debug",function(e){A(e)});var P={reason:"",showUpdates:!1,startTime:0,endTime:0,frames:[],cells:new Map,scrollRegion:null};e._debug=e.layout.renderer._debug={drawStart:function(e){P.reason=e,P.startTime=window.performance.now()},drawEnd:function(){P.endTime=window.performance.now()},setCell:function(e,t){P.cells.set(e,[t,window.performance.now()])},pushFrame:function(e){P.frames.push([].concat(i(e),[window.performance.now()]))}};var R=!1,F=function t(){T?window.requestAnimationFrame(t):R=!1;var n=window.performance.now(),i=e.layout.window,s=i.width,a=i.height,l=i.devicePixelRatio,u=Math.round(e.layout._padding),c=e.layout.getCellSize();if(o.setTransform(l,0,0,l,0,0),o.clearRect(0,0,s*c.width+2*u,a*c.height+2*u),o.translate(u,u),o.lineWidth=2,o.lineJoin="round",P.showUpdates){for(var h=P.cells,d=0;d<s*a;d++)if(h.has(d)&&0!==h.get(d)[0]){var f=h.get(d),v=r(f,2),p=v[0],m=v[1],g=(n-m)/1e3;if(g>1)h.delete(d);else{o.globalAlpha=.5*Math.max(0,1-g);var y=d%s,w=Math.floor(d/s);2&p?o.fillStyle="#0f0":1&p&&(o.fillStyle="#f0f"),4&p||(o.fillStyle="#0ff"),16&p&&(o.globalAlpha/=2),o.fillRect(y*c.width,w*c.height,c.width,c.height),8&p&&(o.strokeStyle="#f00",o.beginPath(),o.moveTo(y*c.width,(w+1)*c.height),o.lineTo((y+1)*c.width,(w+1)*c.height),o.stroke())}}var b=[],_=!0,S=!1,C=void 0;try{for(var x,L=P.frames[Symbol.iterator]();!(_=(x=L.next()).done);_=!0){var A=x.value,E=A[4],F=(n-E)/1e3;F>1?b.push(A):(o.globalAlpha=1-F,o.strokeStyle="#ff0",o.strokeRect(A[0]*c.width,A[1]*c.height,A[2]*c.width,A[3]*c.height))}}catch(e){S=!0,C=e}finally{try{!_&&L.return&&L.return()}finally{if(S)throw C}}var O=!0,B=!1,M=void 0;try{for(var D,I=b[Symbol.iterator]();!(O=(D=I.next()).done);O=!0){var N=D.value;P.frames.splice(P.frames.indexOf(N),1)}}catch(e){B=!0,M=e}finally{try{!O&&I.return&&I.return()}finally{if(B)throw M}}}if(null!==k){var j=k,G=r(j,2),z=G[0],H=G[1];o.save(),o.globalAlpha=.5,o.lineWidth=1,o.beginPath(),o.moveTo(0,H*c.height),o.lineTo(z*c.width,H*c.height),o.strokeStyle="#f00",o.setLineDash([c.width]),o.stroke(),o.beginPath(),o.moveTo(z*c.width,0),o.lineTo(z*c.width,H*c.height),o.strokeStyle="#0f0",o.setLineDash([c.height]),o.stroke(),o.globalAlpha=1,o.lineWidth=1+.5*Math.sin(n/1e3*10),o.strokeStyle="#fff",o.lineJoin="round",o.setLineDash([2,2]),o.lineDashOffset=n/1e3*10,o.strokeRect(z*c.width,H*c.height,c.width,c.height),o.lineDashOffset+=2,o.strokeStyle="#000",o.strokeRect(z*c.width,H*c.height,c.width,c.height),o.restore()}if(null!==P.scrollRegion){var W=r(P.scrollRegion,2),q=W[0],U=W[1];o.save(),o.globalAlpha=1,o.strokeStyle="#00f",o.lineWidth=2,o.setLineDash([2,2]),o.beginPath(),o.moveTo(0,q*c.height),o.lineTo(s*c.width,q*c.height),o.stroke(),o.beginPath(),o.moveTo(0,(U+1)*c.height),o.lineTo(s*c.width,(U+1)*c.height),o.stroke(),o.restore()}};x=function(){R||(R=!0,F())};var O=function(e){return("00"+e.toString()).substr(-2)},B=function(e){return e<256?e.toString():"#"+O(e>>16)+O(e>>8&255)+O(255&e)},M=function(e,t){var n=document.createElement("span");return n.textContent=e,Object.assign(n.style,t||{}),n},D=function(e,t){t&l&&e.appendChild(M("HasFG")),t&u&&e.appendChild(M("HasBG")),t&c&&e.appendChild(M("Bold",{fontWeight:"bold"})),t&h&&e.appendChild(M("Uline",{textDecoration:"underline"})),t&d&&e.appendChild(M("Blink")),t&f&&e.appendChild(M("Italic",{fontStyle:"italic"})),t&v&&e.appendChild(M("Strike",{textDecoration:"line-through"})),t&p&&e.appendChild(M("Oline",{textDecoration:"overline"})),t&m&&e.appendChild(M("Faint",{opacity:.5})),t&g&&e.appendChild(M("Fraktur"))};w=function(){y.classList.remove("hidden"),y.innerHTML="";var t=k[1]*e.window.width+k[0];if(e.screen[t]){var n=document.createElement("span");n.textContent=B(e.screenFG[t]);var i=document.createElement("span");i.textContent=" ●",i.style.color=s(e.screenFG[t],e.layout.renderer.palette),n.appendChild(i);var r=document.createElement("span");r.textContent=B(e.screenBG[t]);var o=document.createElement("span");o.textContent=" ●",o.style.color=s(e.screenBG[t],e.layout.renderer.palette),r.appendChild(o);var a=e.screen[t],l=a.codePointAt(0),u=l.toString(16).length<=4?("0000"+l.toString(16)).substr(-4):l.toString(16),c=document.createElement("span");c.classList.add("attributes"),D(c,e.screenAttrs[t]);var h={Cell:"col "+(k[0]+1)+", ln "+(k[1]+1)+" ("+t+")",Foreground:n,Background:r,Character:"U+"+u,Attributes:c},d=document.createElement("table");for(var f in h){var v=document.createElement("tr"),p=document.createElement("td");p.appendChild(new window.Text(f)),p.classList.add("label");var m=document.createElement("td");m.appendChild("string"==typeof h[f]?new window.Text(h[f]):h[f]),m.classList.add("value"),v.appendChild(p),v.appendChild(m),d.appendChild(v)}y.appendChild(d);var g=e.layout.getCellSize(),w=(k[0]+1)*g.width+3,b=(k[1]+1)*g.height+3;y.style.transform="translate("+w+"px, "+b+"px)"}};var I=null,N={},j=function(){if(!I){var t=document.createElement("input");t.type="checkbox",t.addEventListener("change",function(e){P.showUpdates=t.checked});var n=document.createElement("input");n.type="checkbox",n.value=!!e.layout.renderer.graphics,n.addEventListener("change",function(t){e.layout.renderer.graphics=+n.checked}),I={cursor:{title:"Cursor",Position:"",Style:"",Visible:!0,Hanging:!1},internal:{Flags:"","Cursor Attributes":"","Code Page":"",Heap:0,Clients:0},drawing:{title:"Drawing","Last Update":"","Show Updates":t,"Fancy Graphics":n,"Redraw Screen":function(){e.layout.renderer.resetDrawn(),e.layout.renderer.draw("debug-redraw")}}};for(var i in I)!function(e){var t=I[e],n=document.createElement("table");n.classList.add("toolbar-group"),N[e]={};for(var i in t)!function(i){var r=document.createElement("tr"),o=document.createElement("td");o.classList.add("name");var s=document.createElement("td");if(s.classList.add("value"),N[e][i]={name:o,value:s},"title"===i)o.textContent=t[i],o.classList.add("title");else if(o.textContent=i,t[i]instanceof Function){o.textContent="";var a=document.createElement("button");o.classList.add("has-button"),o.appendChild(a),a.textContent=i,a.addEventListener("click",function(e){return t[i](e)})}else t[i]instanceof window.Node?s.appendChild(t[i]):s.textContent=t[i];r.appendChild(o),r.appendChild(s),n.appendChild(r)}(i);a.appendChild(n)}(i);var r=N.heartbeat=document.createElement("div");r.classList.add("heartbeat"),r.textContent="❤",a.appendChild(r)}};t.on("heartbeat",function(){T&&N.heartbeat&&(N.heartbeat.classList.remove("beat"),window.requestAnimationFrame(function(){N.heartbeat.classList.add("beat")}))}),b=function(){j(),Object.assign(I.cursor,{Position:"col "+(e.cursor.x+1)+", ln "+(e.cursor.y+1),Style:e.cursor.style+(e.cursor.blinking?", blink":""),Visible:e.cursor.visible,Hanging:e.cursor.hanging});var t=Math.round(100*(P.endTime-P.startTime))/100;I.drawing["Last Update"]=P.reason+" ("+t+"ms)",I.drawing["Fancy Graphics"].checked=!!e.layout.renderer.graphics;for(var n in I){var i=I[n],r=N[n];for(var o in i)if("title"!==o){var s=r[o].value;i[o]instanceof window.Node||i[o]instanceof Function||(s.textContent=i[o])}}},e.on("update",b),e.on("internal",function(e){T&&I&&(Object.assign(I.internal,{Flags:e.flags.toString(2),"Cursor Attributes":e.cursorAttrs.toString(2),"Code Page":e.charsetGx+" ("+e.charsetG0+", "+e.charsetG1+")",Heap:e.freeHeap,Clients:e.clientCount}),P.scrollRegion=[e.regionStart,e.regionEnd],b())})}},function(e,t,n){"use strict";function i(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 r=n(3),o=r.getColor,s=n(0),a=s.qs,l=n(7),u=l.rgb2hsl,c=l.hex2rgb,h=l.rgb2hex,d=l.hsl2rgb;e.exports=function(e){var t=a("#action-buttons"),n=[],r=[],s={},l=[],f=function(){var n=document.createElement("button");return n.classList.add("action-button"),n.setAttribute("data-n",l.length),l.push(n),t.appendChild(n),n.addEventListener("click",function(t){var i=+n.getAttribute("data-n");e.sendButton(i),t.target.blur()}),n.addEventListener("mouseleave",function(e){e.target.blur()}),n},v=function(){var e=l.pop();e.parentNode.removeChild(e)},p=function(){if(r.length>l.length)for(var e=l.length;e<r.length;e++)f();else if(l.length>r.length)for(var t=l.length;t>r.length;t--)v();for(var a=0;a<r.length;a++){var p=r[a].trim(),m=l[a],g=s[a];if(m.textContent=p||" ",p?m.classList.remove("inactive"):m.classList.add("inactive"),Number.isFinite(g)&&0!==g){var y=o(g,n);m.style.background=y;var w=u.apply(void 0,i(c(y))),b=h.apply(void 0,i(d(w[0],w[1],.7*w[2])));m.style.boxShadow="0 3px 0 "+b}else m.style.background=null,m.style.boxShadow=null}};return{update:p,get labels(){return r},set labels(e){r=e,p()},get colors(){return s},set colors(e){s=e,p()},get palette(){return n},set palette(e){n=e,p()}}}},function(e,t,n){"use strict";function i(){return+s("#theme").val()}function r(){var e=u(".color-example"),t=s("#default_fg").val(),n=s("#default_bg").val();/^\d+$/.test(t)?t=+t:/^#[\da-f]{6}$/i.test(t)||(t="black"),/^\d+$/.test(n)?n=+n:/^#[\da-f]{6}$/i.test(n)||(n="black");var r=i();e.dataset.fg=t,e.dataset.bg=n,a.themePreview(r),s(".colorprev.fg span").css("background",a.toHex(n,r))}var o=n(27),s=n(1),a=n(3),l=n(0),u=l.qs;t.init=function(){s("#theme").on("change",r),s("#default_fg,#default_bg").on("input",r);var e={padding:10,event:"drag",uppercase:!0,trianglePointerSize:20,size:200,parseColor:function(e){return a.toHex(e,i())}};o.initInput(u("#default_fg"),e),o.initInput(u("#default_bg"),e);for(var t=1;t<=5;t++)o.initInput(u("#bc"+t),e);s(".colorprev.bg span").on("click",function(){var e=this.dataset.bg;void 0!==e&&s("#default_bg").val(e),r()}),s(".colorprev.fg span").on("click",function(){var e=this.dataset.fg;void 0!==e&&s("#default_fg").val(e),r()});for(var n=s("#fgbg_presets"),l=0;l<a.fgbgThemes.length;l++){var c=a.fgbgThemes[l],h=c[0],d=c[1],f=c[2],v=c[3];n.htmlAppend('<span class="preset" data-xfg="'+h+'" data-xbg="'+d+'" style="color:'+h+";background:"+d+'" title="'+v+'">&nbsp;'+f+"&nbsp;</span>"),(l+1)%5==0&&n.htmlAppend("<br>")}s(".preset").on("click",function(){s("#default_fg").val(this.dataset.xfg),s("#default_bg").val(this.dataset.xbg),r()}),r()},t.nextTheme=function(){var e=u("#theme"),t=e.selectedIndex;e.options[++t%e.options.length].selected=!0,r()},t.prevTheme=function(){var e=u("#theme"),t=e.selectedIndex;e.options[(e.options.length+--t)%e.options.length].selected=!0,r()}},function(e,t,n){"use strict";function i(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 r(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)}function a(e,t){for(var n=0;n<e;n++)t(n)}function l(e,t){if(e.length)a(e.length,function(n){t(e[n],n)});else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),c=n(2),h=n(7),d=h.rgb2hex,f=h.hex2rgb,v=h.hsl2rgb,p=h.rgb2hsl,m=window,g=document,y=Math,w=2*y.PI;e.exports=function(e){function t(e,n){r(this,t);var i=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.options={size:150,padding:8,triangleSize:.8,wheelPointerColor1:"#444",wheelPointerColor2:"#eee",trianglePointerSize:16,trianglePointerColor1:"#eee",trianglePointerColor2:"#444",background:"transparent"},i.pixelRatio=window.devicePixelRatio,i.setOptions(n),i.calculateProperties(),i.createContainer(),i.createTriangle(),i.createWheel(),i.createWheelPointer(),i.createTrianglePointer(),i.attachEvents(),e=e||"#f00","string"==typeof e&&i.setHEX(e),i}return s(t,e),u(t,[{key:"calculateProperties",value:function(){var e=this.options;this.padding=e.padding,this.innerSize=e.size-2*e.padding,this.triangleSize=e.triangleSize*this.innerSize,this.wheelThickness=(this.innerSize-this.triangleSize)/2,this.wheelPointerSize=e.wheelPointerSize||this.wheelThickness,this.wheelRadius=this.innerSize/2,this.triangleRadius=this.triangleSize/2,this.triangleSideLength=y.sqrt(3)*this.triangleRadius}},{key:"calculatePositions",value:function(){var e=this.triangleRadius,t=this.hue,n=w/3,i=this.saturation,r=this.lightness,o=this.hx=y.cos(t)*e,s=this.hy=-y.sin(t)*e,a=this.sx=y.cos(t-n)*e,l=this.sy=-y.sin(t-n)*e,u=this.vx=y.cos(t+n)*e,c=this.vy=-y.sin(t+n)*e,h=(a+u)/2,d=(l+c)/2,f=(1-2*y.abs(r-.5))*i;this.x=a+(u-a)*r+(o-h)*f,this.y=l+(c-l)*r+(s-d)*f}},{key:"createContainer",value:function(){var e=this.container=g.createElement("div");e.className="color-triangle",e.style.display="block",e.style.padding=this.padding+"px",e.style.position="relative",e.style.boxShadow="0 1px 10px black",e.style.borderRadius="5px",e.style.width=e.style.height=this.innerSize+2*this.padding+"px",e.style.background=this.options.background}},{key:"createWheel",value:function(){var e=this.wheel=g.createElement("canvas");e.width=e.height=this.innerSize*this.pixelRatio,e.style.width=e.style.height=this.innerSize+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",e.style.left=e.style.top=this.padding+"px",this.drawWheel(e.getContext("2d")),this.container.appendChild(e)}},{key:"drawWheel",value:function(e){var t=void 0,n=void 0;for(e.save(),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),e.translate(this.wheelRadius,this.wheelRadius),t=this.wheelRadius-this.triangleRadius,n=0;n<360;n++)e.rotate(w/-360),e.beginPath(),e.fillStyle="hsl("+n+", 100%, 50%)",e.arc(this.wheelRadius-t/2,0,t/2,0,w,!0),e.fill();e.restore()}},{key:"createTriangle",value:function(){var e=this.triangle=g.createElement("canvas");e.width=e.height=this.innerSize*this.pixelRatio,e.style.width=e.style.height=this.innerSize+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",e.style.left=e.style.top=this.padding+"px",this.triangleCtx=e.getContext("2d"),this.container.appendChild(e)}},{key:"drawTriangle",value:function(){var e=this.hx,t=this.hy,n=this.sx,i=this.sy,r=this.vx,o=this.vy,s=this.innerSize,a=this.triangleCtx;a.clearRect(0,0,s*this.pixelRatio,s*this.pixelRatio),a.save(),a.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),a.translate(this.wheelRadius,this.wheelRadius),a.beginPath(),a.moveTo(e,t),a.lineTo(n,i),a.lineTo(r,o),a.closePath(),a.clip(),a.fillStyle="#000",a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s);var l=a.createLinearGradient(e,t,(n+r)/2,(i+o)/2),u="hsla("+y.round(this.hue*(360/w))+", 100%, 50%, ";l.addColorStop(0,u+"1)"),l.addColorStop(1,u+"0)"),a.fillStyle=l,a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s);var c=a.createLinearGradient(r,o,(e+n)/2,(t+i)/2);c.addColorStop(0,"#fff"),c.addColorStop(1,"rgba(255, 255, 255, 0)"),a.globalCompositeOperation="lighter",a.fillStyle=c,a.fillRect(-this.wheelRadius,-this.wheelRadius,s,s),a.restore()}},{key:"createWheelPointer",value:function(){var e=this.wheelPointer=g.createElement("canvas"),t=this.wheelPointerSize;e.width=e.height=t*this.pixelRatio,e.style.width=e.style.height=t+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",this.drawPointer(e.getContext("2d"),t/2,this.options.wheelPointerColor1,this.options.wheelPointerColor2),this.container.appendChild(e)}},{key:"moveWheelPointer",value:function(){var e=this.wheelPointerSize/2,t=this.wheelPointer.style;t.top=this.padding+this.wheelRadius-y.sin(this.hue)*(this.triangleRadius+this.wheelThickness/2)-e+"px",t.left=this.padding+this.wheelRadius+y.cos(this.hue)*(this.triangleRadius+this.wheelThickness/2)-e+"px"}},{key:"createTrianglePointer",value:function(){var e=this.trianglePointer=g.createElement("canvas"),t=this.options.trianglePointerSize;e.width=e.height=t*this.pixelRatio,e.style.width=e.style.height=t+"px",e.style.position="absolute",e.style.margin=e.style.padding="0",this.drawPointer(e.getContext("2d"),t/2,this.options.trianglePointerColor1,this.options.trianglePointerColor2),this.container.appendChild(e)}},{key:"moveTrianglePointer",value:function(e,t){var n=this.trianglePointer.style,i=this.options.trianglePointerSize/2;n.top=this.y+this.wheelRadius+this.padding-i+"px",n.left=this.x+this.wheelRadius+this.padding-i+"px"}},{key:"drawPointer",value:function(e,t,n,i){e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),e.fillStyle=i,e.beginPath(),e.arc(t,t,t,0,w,!0),e.fill(),e.fillStyle=n,e.beginPath(),e.arc(t,t,t-2,0,w,!0),e.fill(),e.fillStyle=i,e.beginPath(),e.arc(t,t,t/4+2,0,w,!0),e.fill(),e.globalCompositeOperation="destination-out",e.beginPath(),e.arc(t,t,t/4,0,w,!0),e.fill()}},{key:"inject",value:function(e){e.appendChild(this.container)}},{key:"getRelativeCoordinates",value:function(e){var t=this.triangle,n=t.getBoundingClientRect();return{x:e.clientX-n.x,y:e.clientY-n.y}}},{key:"dispose",value:function(){var e=this.container.parentNode;e&&e.removeChild(this.container)}},{key:"getElement",value:function(){return this.container}},{key:"getCSS",value:function(){return"hsl("+Math.round(this.hue*(360/w))+", "+Math.round(100*this.saturation)+"%, "+Math.round(100*this.lightness)+"%)"}},{key:"getHEX",value:function(){return d.apply(void 0,i(this.getRGB()))}},{key:"setHEX",value:function(e){this.setRGB.apply(this,i(f(e)))}},{key:"getRGB",value:function(){return v.apply(void 0,i(this.getHSL()))}},{key:"setRGB",value:function(e,t,n){this.setHSL.apply(this,i(p(e,t,n)))}},{key:"getHSL",value:function(){return[this.hue,this.saturation,this.lightness]}},{key:"setHSL",value:function(e,t,n){this.hue=e,this.saturation=t,this.lightness=n,this.initColor()}},{key:"initColor",value:function(){this.calculatePositions(),this.moveWheelPointer(),this.drawTriangle(),this.moveTrianglePointer()}},{key:"attachEvents",value:function(){var e=this;this.down=null;var t=function(t){t.stopPropagation(),t.preventDefault(),g.body.addEventListener("mousemove",n,!1),g.body.addEventListener("mouseup",i,!1);var r=e.getRelativeCoordinates(t);e.map(r.x,r.y)},n=function(t){var n=e.getRelativeCoordinates(t);e.move(n.x,n.y)},i=function t(i){e.down&&(e.down=null,e.emit("dragend")),g.body.removeEventListener("mousemove",n,!1),g.body.removeEventListener("mouseup",t,!1)};this.container.addEventListener("mousedown",t,!1),this.container.addEventListener("mousemove",n,!1)}},{key:"map",value:function(e,t){var n=e,i=t;e-=this.wheelRadius,t-=this.wheelRadius;var r=y.sqrt(e*e+t*t);r>this.triangleRadius&&r<this.wheelRadius?(this.down="wheel",this.emit("dragstart"),this.move(n,i)):r<this.triangleRadius&&(this.down="triangle",this.emit("dragstart"),this.move(n,i))}},{key:"move",value:function(e,t){if(this.down){e-=this.wheelRadius,t-=this.wheelRadius;var n=y.atan2(-t,e);if(n<0&&(n+=w),"wheel"===this.down)this.hue=n,this.initColor(),this.emit("drag");else if("triangle"===this.down){var i=(n+w-this.hue)%w,r=i%(w/3)-w/6,o=.5*this.triangleRadius,s=y.tan(r)*o,a=y.sqrt(e*e+t*t),l=y.sqrt(o*o+s*s);if(a>l){var u=y.tan(r)*a,c=y.atan(u/l);c>w/6?c=w/6:c<-w/6&&(c=-w/6),n+=c-r,i=(n+w-this.hue)%w,r=i%(w/3)-w/6,s=y.tan(r)*o,a=l=y.sqrt(o*o+s*s)}e=y.round(y.cos(n)*a),t=y.round(-y.sin(n)*a);var h=this.lightness=y.sin(i)*a/this.triangleSideLength+.5,d=1-2*y.abs(h-.5),f=this.saturation=(y.cos(i)*a+this.triangleRadius/2)/(1.5*this.triangleRadius)/d;f=y.max(0,f),f=y.min(1,f),this.lightness=h,this.saturation=f,this.x=e,this.y=t,this.moveTrianglePointer(),this.emit("drag")}}}},{key:"setOptions",value:function(e){e=e||{};var t=this.options,n=this.options={};l(t,function(t,i){n[i]=e.hasOwnProperty(i)?e[i]:t})}}],[{key:"initInput",value:function(e,n){n=n||{};var i=void 0,r=function(){var r=e.value;n.parseColor&&(r=n.parseColor(r)),i?i.setHEX(r):(n.size=n.size||e.offsetWidth,n.background=m.getComputedStyle(e,null).backgroundColor,n.margin=n.margin||10,n.event=n.event||"dragend",i=new t(r,n),i.on(n.event,function(){var t=i.getHEX();e.value=n.uppercase?t.toUpperCase():t,s()}));var o=e.offsetTop;m.innerHeight-e.getBoundingClientRect().top>e.offsetHeight+n.margin+n.size?o+=e.offsetHeight+n.margin:o-=n.margin+n.size;var a=i.getElement();a.style.position="absolute",a.style.left=e.offsetLeft+"px",a.style.top=o+"px",a.style.zIndex="1338",i.inject(e.parentNode)},o=function(){i&&i.dispose()},s=function(){var t=g.createEvent("HTMLEvents");t.initEvent("input",!0,!1),e.dispatchEvent(t)};e.addEventListener("focus",r,!1),e.addEventListener("blur",o,!1),e.addEventListener("keyup",function(){e.value.match(/^#((?:[0-9A-Fa-f]{3})|(?:[0-9A-Fa-f]{6}))$/)?(r(),s()):o()},!1)}}]),t}(c)}]);
//# sourceMappingURL=app.8b43b1d-en.js.map