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.d7551c3.js

19 lines
72 KiB

'use strict';var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a};(function(){'use strict';function a(){var a;for(p=!0,a=0;a<n.length;a+=1)n[a]();n=[]}function b(){var b;for(q=!0,p||a(),b=0;b<o.length;b+=1)o[b]();o=[]}function c(a,b){var c;for(c=b.length-1;0<=c;c-=1)a(b[c])}function e(a){return a.replace(/-\w/g,function(a){return a.charAt(1).toUpperCase()})}function f(a,b){return a.currentStyle?a.currentStyle[e(b)]:d.getComputedStyle?d.getComputedStyle(a,null).getPropertyValue(b):null}function g(a,b){return encodeURIComponent(a).replace(/%20/g,'+')+'='+encodeURIComponent(b).replace(/%20/g,'+')}function h(a,b,c){try{a.style[e(b)]=c}catch(a){}}function i(a){a.style.display='','none'===f(a,'display')&&(a.style.display='block')}function j(a){var b,d,e,f='';if(a.constructor===Object){for(b in a)if(a.hasOwnProperty(b))if(a[b].constructor===Array)for(d=0;d<a[b].length;d+=1)f+='&'+g(b,a[b][d]);else f+='&'+g(b,a[b]);}else c(function(a){if('FORM'===a.nodeName)for(d=0;d<a.elements.length;d+=1)if(b=a.elements[d],!b.disabled)switch(b.type){case'button':case'image':case'file':case'submit':case'reset':break;case'select-one':0<b.length&&(f+='&'+g(b.name,b.value));break;case'select-multiple':for(e=0;e<b.length;e+=1)b[e].selected&&(f+='&'+g(b.name,b[e].value));break;case'checkbox':case'radio':b.checked&&(f+='&'+g(b.name,b.value));break;default:f+='&'+g(b.name,b.value);}},a);return 0<f.length?f.substring(1):''}function k(a,b,d){var e,f,g=!1;return a&&(e=a.split(/\s+/),c(function(a){for(f=0;f<e.length;f+=1){var c=e[f];if('remove'===b)a.classList.remove(c);else if('add'===b)a.classList.add(c);else if('toggle'===b)a.classList.toggle(c);else if('has'===b&&a.classList.contains(c)){g=!0;break}}},d)),g}function l(a,b,d){var e,f;a&&c(function(c){for(e=r.createElement('div'),e.innerHTML=a;null!==(f=e.lastChild);)try{'before'===b?c.parentNode.insertBefore(f,c):'after'===b?c.parentNode.insertBefore(f,c.nextSibling):'append'===b?c.appendChild(f):'prepend'===b&&c.insertBefore(f,c.firstChild)}catch(a){break}},d)}function m(a){var b,g,j,n=[],o=!1;if(a)if(a.nodeType&&1===a.nodeType)n=[a];else if('object'===('undefined'==typeof a?'undefined':_typeof(a)))o='number'!=typeof a.length,n=a;else if('string'==typeof a)for(g=r.querySelectorAll(a),j=0;j<g.length;j+=1)n[j]=g[j];return b=o?{}:n,b.each=function(a){return'function'==typeof a&&c(function(b){return a.apply(b,arguments)},n),b},b.first=function(){return m(n.shift())},b.last=function(){return m(n.pop())},b.odd=function(){var a,b=[];for(a=0;a<n.length;a+=2)b.push(n[a]);return m(b)},b.even=function(){var a,b=[];for(a=1;a<n.length;a+=2)b.push(n[a]);return m(b)},b.hide=function(){return c(function(a){a.style.display='none'},n),b},b.show=function(){return c(function(a){i(a)},n),b},b.toggle=function(a){return'undefined'==typeof a?c(function(a){'none'===f(a,'display')?i(a):a.style.display='none'},n):a?b.show():b.hide(),b},b.remove=function(){return c(function(a){try{a.parentNode.removeChild(a)}catch(a){}},n),m()},b.css=function(a,d){if(a){if(d||''===d)return c(function(b){h(b,a,d)},n),b;if(n[0]){if(n[0].style[e(a)])return n[0].style[e(a)];if(f(n[0],a))return f(n[0],a)}}},b.getClass=function(){if(n[0]&&0<n[0].className.length)return n[0].className.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,'').replace(/\s+/,' ')},b.setClass=function(a){return(a||''===a)&&c(function(b){b.className=a},n),b},b.addClass=function(a){return k(a,'add',n),b},b.removeClass=function(a){return k(a,'remove',n),b},b.toggleClass=function(a,c){var d='undefined'==typeof c?'toggle':+c?'add':'remove';return k(a,d,n),b},b.hasClass=function(a){return k(a,'has',n)},b.html=function(a){return a||''===a?(c(function(b){b.innerHTML=a},n),b):n[0]?n[0].innerHTML:void 0},b.htmlBefore=function(a){return l(a,'before',n),b},b.htmlAfter=function(a){return l(a,'after',n),b},b.htmlAppend=function(a){return l(a,'append',n),b},b.htmlPrepend=function(a){return l(a,'prepend',n),b},b.attr=function(a,d){if(a){if(a=a.toLowerCase(),'undefined'!=typeof d)return c(function(b){'style'===a?b.style.cssText=d:'class'===a?b.className=d:b.setAttribute(a,d)},n),b;if(n[0])if('style'===a){if(n[0].style.cssText)return n[0].style.cssText;}else if('class'===a){if(n[0].className)return n[0].className;}else if(n[0].getAttribute(a))return n[0].getAttribute(a)}},b.data=function(a,c){if(a)return b.attr('data-'+a,c)},b.val=function(a){var d,e,f;if('undefined'!=typeof a)return c(function(b){switch(b.nodeName){case'SELECT':for(('string'==typeof a||'number'==typeof a)&&(a=[a]),e=0;e<b.length;e+=1)for(f=0;f<a.length;f+=1)if(b[e].selected='',b[e].value===''+a[f]){b[e].selected='selected';break}break;case'INPUT':case'TEXTAREA':case'BUTTON':b.value=a;}},n),b;if(n[0])switch(n[0].nodeName){case'SELECT':for(d=[],e=0;e<n[0].length;e+=1)n[0][e].selected&&d.push(n[0][e].value);return 1<d.length?d:d[0];case'INPUT':case'TEXTAREA':case'BUTTON':return n[0].value;}},b.checked=function(a){return'boolean'==typeof a?(c(function(b){'INPUT'===b.nodeName&&('checkbox'===b.type||'radio'===b.type)&&(b.checked=a)},n),b):n[0]&&'INPUT'===n[0].nodeName&&('checkbox'===n[0].type||'radio'===n[0].type)?!!n[0].checked:void 0},b.on=function(e,f){return(a===d||a===r)&&(n=[a]),c(function(a){r.addEventListener?a.addEventListener(e,f,!1):r.attachEvent&&(a[e+f]=function(){return f.apply(a,arguments)},a.attachEvent('on'+e,a[e+f]))},n),b},b.off=function(e,f){return(a===d||a===r)&&(n=[a]),c(function(a){r.addEventListener?a.removeEventListener(e,f,!1):r.attachEvent&&(a.detachEvent('on'+e,a[e+f]),a[e+f]=null)},n),b},b}var n=[],o=[],p=!1,q=!1,r=document,d=window;r.addEventListener?(r.addEventListener('DOMContentLoaded',a,!1),d.addEventListener('load',b,!1)):r.attachEvent?(r.attachEvent('onreadystatechange',a),d.attachEvent('onload',b)):d.onload=b,m.ajax=function(a){var b=Object.assign({method:'GET',nocache:!0,timeout:5e3,loader:!0,callback:null},a);b.method=b.method.toUpperCase();var c=b.loader?m._loader:function(){};var d=b.url;var e=b.method;var f=null;b.data&&(f=j(b.data)),f&&'GET'===e&&(d+=-1===d.indexOf('?')?'?'+f:'&'+f,f=null);var g=new XMLHttpRequest;if(b.nocache){var h=(+new Date).toString(36);d+=(-1===d.indexOf('?')?'?':'&')+'_='+h}c(!0),g.open(e,d,!0),g.timeout=b.timeout;var i=setTimeout(function(){console.error('XHR timed out.'),g.abort(),c(!1)},b.timeout+10);return g.onreadystatechange=function(){4===g.readyState&&(c(!1),b.callback&&b.callback(g.responseText,g.status),clearTimeout(i))},g.setRequestHeader('X-Requested-With','XMLHttpRequest'),'POST'===e&&g.setRequestHeader('Content-Type','application/x-www-form-urlencoded'),g.send(f),g},m._loader=function(){},m.get=function(a,b,c){return c=c||{},c.url=a,c.callback=b,c.method='GET',m.ajax(c)},m.post=function(a,b,c){return c=c||{},c.url=a,c.callback=b,c.method='POST',m.ajax(c)},m.ready=function(a){if(a){if(p)return a(),m;n.push(a)}},m.loaded=function(a){if(a){if(q)return a(),m;o.push(a)}};var t={"&":'&amp;',"<":'&lt;',">":'&gt;','"':'&quot;',"'":'&#39;',"/":'&#x2F;',"`":'&#x60;',"=":'&#x3D;'};m.htmlEscape=function(a){return(a+'').replace(/[&<>"'`=\/]/g,function(a){return t[a]})},d.$=m})();
'use strict';(function(a){function b(a,b){for(var c=a.length;c--;)if(a[c]===b)return c;return-1}function c(a,b){if(a.length!=b.length)return!1;for(var c=0;c<a.length;c++)if(a[c]!==b[c])return!1;return!0}function d(a){for(j in n)n[j]=a[s[j]]}function e(a){var c,e,h,j,i,l;if(c=a.keyCode,-1==b(r,c)&&r.push(c),(93==c||224==c)&&(c=91),c in n){for(h in n[c]=!0,o)o[h]==c&&(f[h]=!0);return}if((d(a),!!f.filter.call(this,a))&&c in m)for(l=g(),j=0;j<m[c].length;j++)if(e=m[c][j],e.scope==l||'all'==e.scope){for(h in i=0<e.mods.length,n)(!n[h]&&-1<b(e.mods,+h)||n[h]&&-1==b(e.mods,+h))&&(i=!1);(0!=e.mods.length||n[16]||n[18]||n[17]||n[91])&&!i||!1!==e.method(a,e)||(a.preventDefault?a.preventDefault():a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.cancelBubble&&(a.cancelBubble=!0))}}function f(a,b,c){var d,e;d=h(a),c===void 0&&(c=b,b='all');for(var f=0;f<d.length;f++)e=[],a=d[f].split('+'),1<a.length&&(e=l(a),a=[a[a.length-1]]),a=a[0],a=q(a),a in m||(m[a]=[]),m[a].push({shortcut:d[f],scope:b,method:c,key:d[f],mods:e})}function g(){return k||'all'}function h(a){var b;return a=a.replace(/\s/g,''),b=a.split(','),''==b[b.length-1]&&(b[b.length-2]+=','),b}function l(a){var b=a.slice(0,a.length-1);for(var c=0;c<b.length;c++)b[c]=o[b[c]];return b}function i(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent('on'+b,function(){c(window.event)})}var j,m={},n={16:!1,17:!1,18:!1,91:!1},k='all',o={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,command:91},p={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":189,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220,insert:45,np_0:96,np_1:97,np_2:98,np_3:99,np_4:100,np_5:101,np_6:102,np_7:103,np_8:104,np_9:105,np_mul:106,np_add:107,np_sub:109,np_point:110,np_div:111,numlock:144},q=function(a){return p[a]||a.toUpperCase().charCodeAt(0)},r=[];for(j=1;20>j;j++)p['f'+j]=111+j;var s={16:'shiftKey',17:'ctrlKey',18:'altKey',91:'metaKey'};for(j in o)f[j]=!1;i(document,'keydown',function(a){e(a)}),i(document,'keyup',function(a){var c,d=a.keyCode,e=b(r,d);if(0<=e&&r.splice(e,1),(93==d||224==d)&&(d=91),d in n)for(c in n[d]=!1,o)o[c]==d&&(f[c]=!1)}),i(window,'focus',function(){for(j in n)n[j]=!1;for(j in o)f[j]=!1});var t=a.key;a.key=f,a.key.setScope=function(a){k=a||'all'},a.key.getScope=g,a.key.deleteScope=function(a){var b,c,d;for(b in m)for(c=m[b],d=0;d<c.length;)c[d].scope===a?c.splice(d,1):d++},a.key.filter=function(a){var b=(a.target||a.srcElement).tagName;return'INPUT'!=b&&'SELECT'!=b&&'TEXTAREA'!=b},a.key.isPressed=function(a){return'string'==typeof a&&(a=q(a)),-1!=b(r,a)},a.key.isModifier=function(a){return'control'==a||'ctrl'==a?n[17]:'shift'==a?n[16]:'meta'==a?n[91]:!('alt'!=a)&&n[18]},a.key.getPressedKeyCodes=function(){return r.slice(0)},a.key.noConflict=function(){var b=a.key;return a.key=t,b},a.key.unbind=function(a,b){var d,e,f,i,j,k=[];for(d=h(a),i=0;i<d.length;i++){if(e=d[i].split('+'),1<e.length&&(k=l(e)),a=e[e.length-1],a=q(a),void 0===b&&(b=g()),!m[a])return;for(f=0;f<m[a].length;f++)j=m[a][f],j.scope===b&&c(j.mods,k)&&(m[a][f]={})}},'undefined'!=typeof module&&(module.exports=f)})(window);
'use strict';String.fromCodePoint||function(){var a=function(){try{var a={};var b=Object.defineProperty;var c=b(a,a,a)&&b}catch(a){}return c}();var b=String.fromCharCode;var c=Math.floor;var d=function(){var a=[];var d;var e;var f=-1;var g=arguments.length;if(!g)return'';for(var h='';++f<g;){var i=+arguments[f];if(!isFinite(i)||0>i||1114111<i||c(i)!=i)throw RangeError('Invalid code point: '+i);65535>=i?a.push(i):(i-=65536,d=(i>>10)+55296,e=i%1024+56320,a.push(d,e)),(f+1==g||a.length>16384)&&(h+=b.apply(null,a),a.length=0)}return h};a?a(String,'fromCodePoint',{value:d,configurable:!0,writable:!0}):String.fromCodePoint=d}();
'use strict';function mk(a){return document.createElement(a)}function qs(a){return document.querySelector(a)}function qsa(a){return document.querySelectorAll(a)}function bool(a){return 1===a||'1'===a||!0===a||'true'===a}function cr(a){return function(b){(10===b.which||13===b.which||32===b.which)&&a()}}function esc(a){return $.htmlEscape(a)}function undef(a){return'undefined'==typeof a}function jsp(a){try{return JSON.parse(a)}catch(a){return console.error(a),null}}function Chr(a){return String.fromCharCode(a)}function parse2B(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;return a.charCodeAt(b++)-1+127*(a.charCodeAt(b)-1)}function parse3B(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;return a.charCodeAt(b)-1+127*(a.charCodeAt(b+1)-1)+127*(127*(a.charCodeAt(b+2)-1))}function encode2B(a){var b,c;return b=a%127,a=(a-b)/127,b+=1,c=a+1,Chr(b)+Chr(c)}function encode3B(a){var b,c,d;return b=a%127,a=(a-b)/127,b+=1,c=a%127,a=(a-c)/127,c+=1,d=a+1,Chr(b)+Chr(c)+Chr(d)}
'use strict';(function(){var a={};var b=null;a.show=function(a,c){var d=$(a);d.removeClass('hidden visible'),setTimeout(function(){d.addClass('visible')},1),b=c},a.hide=function(a){var c=$(a);c.removeClass('visible'),setTimeout(function(){c.addClass('hidden'),b&&b()},500)},a.init=function(){$('.Modal').on('click',function(){$(this).hasClass('no-close')||a.hide(this)}),$('.Dialog').on('click',function(a){a.stopImmediatePropagation()}),$(window).on('keydown',function(b){27===b.which&&a.hide('.Modal')})},window.Modal=a})();
'use strict';window.Notify=function(){var a={};var b='#notif';var c;var d;var e;var f;var g=!1;var h=function(){clearTimeout(d),clearTimeout(e)};return a.show=function(b,e,i){c.toggleClass('error',!0===i),c.html(b),Modal.show(c),h(),(undef(e)||null===e||0>=e)&&(e=2500),d=setTimeout(a.hide,e),g=!1,f=setTimeout(function(){g=!0},500)},a.hide=function(){var a=$(b);a.removeClass('visible'),e=setTimeout(function(){a.addClass('hidden')},250)},a.init=function(){c=$(b),$(document).on('click',function(){g&&a.hide(this)}),c.on('click',function(a){return a.stopImmediatePropagation(),!1}),c.on('mouseenter',function(){h(),c.removeClass('hidden').addClass('visible')})},a}();
'use strict';$.ready(function(){$('.Row.checkbox').forEach(function(a){var b=a.querySelector('input');var c=a.querySelector('.box');$(c).toggleClass('checked',b.value);var d=function(){b.value=1-b.value,$(c).toggleClass('checked',b.value)};$(a).on('click',d).on('keypress',cr(d))}),$('.Box.mobcol,.Box.fold').forEach(function(a){var b=a.querySelector('h2');var c=function(){$(a).toggleClass('expanded')};$(b).on('click',c).on('keypress',cr(c))}),$('form').forEach(function(a){$(a).on('keypress',function(b){(10===b.keyCode||13===b.keyCode)&&b.ctrlKey&&a.submit()})}),setInterval(function(){$('.anim-dots').each(function(a){var b=$(a);var c=b.html()+'.';5===c.length&&(c='.'),b.html(c)})},1e3),$('input[type=number]').on('mousewheel',function(a){var b=$(this);var c=+b.val();isNaN(c)&&(c=1);var d=+(b.attr('step')||1);var e=+b.attr('min');var f=+b.attr('max');if(0<a.wheelDelta?c+=d:c-=d,undef(e)&&(c=Math.max(c,+e)),undef(f)&&(c=Math.min(c,+f)),b.val(c),'createEvent'in document){var g=document.createEvent('HTMLEvents');g.initEvent('change',!1,!0),b[0].dispatchEvent(g)}else b[0].fireEvent('onchange');a.preventDefault()});var a=location.search.indexOf('err=');if(-1!==a&&qs('.Box.errors')){var b=location.search.substr(a+4).split(',');var c=[];b.forEach(function(a){var b=qs('label[for="'+a+'"]');b&&(b.classList.add('error'),c.push(b.childNodes[0].textContent.trim().replace(/: ?$/,'')))}),qs('.Box.errors .list').innerHTML=c.join(', '),qs('.Box.errors').classList.remove('hidden')}if(Modal.init(),Notify.init(),550<window.innerWidth){$('.Box h2').forEach(function(a){a.removeAttribute('tabindex')});var d=qs('#brand');d&&d.addEventListener('click',function(){location.href='/'})}}),$._loader=function(a){$('#loader').toggleClass('show',a)};function showPage(){$('#content').addClass('load')}$.ready(function(){!0!==window.noAutoShow&&setTimeout(function(){showPage()},1)});
'use strict';var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,'value'in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _toConsumableArray(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var ANSIParser=function(){function a(b){_classCallCheck(this,a),this.reset(),this.handler=b,this.joinChunks=!0}return _createClass(a,[{key:'reset',value:function reset(){this.currentSequence=0,this.sequence=''}},{key:'parseSequence',value:function parseSequence(a){if('['===a[0]){var b=a[a.length-1];var c=a.substring(1,a.length-1);var d=c?c.split(';').map(function(a){return+a.replace(/\D/g,'')}):[];var e=d.length?d[0]:1;if('H'===b)this.handler('set-cursor',(0|d[0])-1,(0|d[1])-1);else if('A'<=b&&'D'>=b)this.handler('move-cursor-'+('B'>=b?'y':'x'),('B'===b||'C'===b?1:-1)*e);else if('E'===b||'F'===b)this.handler('move-cursor-line',('E'===b?1:-1)*e);else if('G'===b)this.handler('set-cursor-x',e-1);else if('J'===b){var f=d.length?d[0]:2;2===f&&this.handler('clear')}else if('P'===b)this.handler('delete',e);else if('@'===b)this.handler('insert-blanks',e);else if('q'===b)this.handler('set-cursor-style',e);else if('m'===b){if(!d.length||0===d[0])return void this.handler('reset-style');var g=d[0];if(1===g)this.handler('add-attrs',1);else if(2===g)this.handler('add-attrs',2);else if(3===g)this.handler('add-attrs',4);else if(4===g)this.handler('add-attrs',8);else if(5===g||6===g)this.handler('add-attrs',16);else if(7===g)this.handler('add-attrs',-1);else if(9===g)this.handler('add-attrs',64);else if(20===g)this.handler('add-attrs',32);else if(30<=g&&37>=g)this.handler('set-color-fg',g%10);else if(40<=g&&47>=g)this.handler('set-color-bg',g%10);else if(39===g)this.handler('set-color-fg',7);else if(49===g)this.handler('set-color-bg',0);else if(90<=g&&98>=g)this.handler('set-color-fg',g%10+8);else if(100<=g&&108>=g)this.handler('set-color-bg',g%10+8);else if((38===g||48===g)&&5===d[1]){var h=255&(0|d[2]);38===g&&this.handler('set-color-fg',h),48===g&&this.handler('set-color-bg',h)}}else('h'===b||'l'===b)&&'?25'===c&&('h'===b?this.handler('show-cursor'):'l'===b&&this.handler('hide-cursor'))}}},{key:'write',value:function write(a){var b=!0;var c=!1;var d=void 0;try{for(var e,f=a.toString()[Symbol.iterator]();!(b=(e=f.next()).done);b=!0){var g=e.value;var h=g.codePointAt(0);27===h?this.currentSequence=1:1===this.currentSequence&&'['===g?(this.currentSequence=2,this.sequence+='['):this.currentSequence&&g.match(/[\x40-\x7e]/)?(this.parseSequence(this.sequence+g),this.currentSequence=0,this.sequence=''):1<this.currentSequence?this.sequence+=g:1===this.currentSequence?(this.currentSequence=0,this.handler('write',g)):7===h?this.handler('bell'):8===h?this.handler('back'):10===h?this.handler('new-line'):13===h?this.handler('return'):21===h?this.handler('delete-line'):23===h?this.handler('delete-word'):this.handler('write',g)}}catch(a){c=!0,d=a}finally{try{!b&&f.return&&f.return()}finally{if(c)throw d}}this.joinChunks||this.reset()}}]),a}();var TERM_DEFAULT_STYLE=7;var TERM_MIN_DRAW_DELAY=10;var getRainbowColor=function(a){var c=Math.PI;var d=Math.floor;var e=Math.sin;var f=d(2.5*e(a)+2.5);var h=d(2.5*e(a+2/3*c)+2.5);var g=d(2.5*e(a+4/3*c)+2.5);return 16+36*f+6*h+g};var ScrollingTerminal=function(){function a(b){var c=this;_classCallCheck(this,a),this.width=80,this.height=25,this.termScreen=b,this.parser=new ANSIParser(function(){return c.handleParsed.apply(c,arguments)}),this.reset(),this._lastLoad=Date.now(),this.termScreen.load(this.serialize(),0)}var b=Math.min;var c=Math.max;return _createClass(a,[{key:'reset',value:function reset(){this.style=TERM_DEFAULT_STYLE,this.cursor={x:0,y:0,style:1,visible:!0},this.trackMouse=!1,this.theme=0,this.rainbow=!1,this.parser.reset(),this.clear()}},{key:'clear',value:function clear(){this.screen=[];for(var a=0;a<this.width*this.height;a++)this.screen.push([' ',this.style])}},{key:'scroll',value:function scroll(){this.screen.splice(0,this.width);for(var a=0;a<this.width;a++)this.screen.push([' ',TERM_DEFAULT_STYLE]);this.cursor.y--}},{key:'newLine',value:function newLine(){this.cursor.y++,this.cursor.y>=this.height&&this.scroll()}},{key:'writeChar',value:function writeChar(a){this.screen[this.cursor.y*this.width+this.cursor.x]=[a,this.style],this.cursor.x++,this.cursor.x>=this.width&&(this.cursor.x=0,this.newLine())}},{key:'moveBack',value:function moveBack(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;for(var b=0;b<a;b++)this.cursor.x--,0>this.cursor.x&&(this.cursor.x=0<this.cursor.y?this.width-1:0,this.cursor.y=c(0,this.cursor.y-1))}},{key:'moveForward',value:function moveForward(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1;for(var b=0;b<a;b++)this.cursor.x++,this.cursor.x>=this.width&&(this.cursor.x=0,this.cursor.y++,this.cursor.y>=this.height&&this.scroll())}},{key:'deleteChar',value:function deleteChar(){this.moveBack(),this.screen.splice((this.cursor.y+1)*this.width,0,[' ',TERM_DEFAULT_STYLE]),this.screen.splice(this.cursor.y*this.width+this.cursor.x,1)}},{key:'deleteForward',value:function deleteForward(a){a=b(this.width,a);for(var c=0;c<a;c++)this.screen.splice((this.cursor.y+1)*this.width,0,[' ',TERM_DEFAULT_STYLE]);this.screen.splice(this.cursor.y*this.width+this.cursor.x,a)}},{key:'clampCursor',value:function clampCursor(){0>this.cursor.x&&(this.cursor.x=0),0>this.cursor.y&&(this.cursor.y=0),this.cursor.x>this.width-1&&(this.cursor.x=this.width-1),this.cursor.y>this.height-1&&(this.cursor.y=this.height-1)}},{key:'handleParsed',value:function handleParsed(a){'write'===a?this.writeChar(1>=arguments.length?void 0:arguments[1]):'delete'===a?this.deleteForward(1>=arguments.length?void 0:arguments[1]):'insert-blanks'===a?this.insertBlanks(1>=arguments.length?void 0:arguments[1]):'clear'===a?this.clear():'bell'===a?this.terminal.load('B'):'back'===a?this.moveBack():'new-line'===a?this.newLine():'return'===a?this.cursor.x=0:'set-cursor'===a?(this.cursor.x=1>=arguments.length?void 0:arguments[1],this.cursor.y=2>=arguments.length?void 0:arguments[2],this.clampCursor()):'move-cursor-y'===a?(this.cursor.y+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):'move-cursor-x'===a?(this.cursor.x+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):'move-cursor-line'===a?(this.cursor.x=0,this.cursor.y+=1>=arguments.length?void 0:arguments[1],this.clampCursor()):'set-cursor-x'===a?this.cursor.x=1>=arguments.length?void 0:arguments[1]:'set-cursor-style'===a?this.cursor.style=c(0,b(6,1>=arguments.length?void 0:arguments[1])):'reset-style'===a?this.style=TERM_DEFAULT_STYLE:'add-attrs'===a?-1===(1>=arguments.length?void 0:arguments[1])?this.style=16711680&this.style|255&this.style>>8|(255&this.style)<<8:this.style|=(1>=arguments.length?void 0:arguments[1])<<16:'set-color-fg'===a?this.style=16776960&this.style|(1>=arguments.length?void 0:arguments[1]):'set-color-bg'===a?this.style=16711935&this.style|(1>=arguments.length?void 0:arguments[1])<<8:'hide-cursor'===a?this.cursor.visible=!1:'show-cursor'===a&&(this.cursor.visible=!0)}},{key:'write',value:function write(a){this.parser.write(a),this.scheduleLoad()}},{key:'serialize',value:function serialize(){var a='S';a+=encode2B(this.height)+encode2B(this.width),a+=encode2B(this.cursor.y)+encode2B(this.cursor.x);var b=+this.cursor.visible;b|=96*+this.trackMouse,b|=384,b|=this.cursor.style<<9,a+=encode3B(b);var c=null;var d=0;var e=!0;var f=!1;var g=void 0;try{for(var h,i=this.screen[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value;var k=j[1];if(this.rainbow){var l=d%this.width;var m=Math.floor(d/this.width);k=16711680&k|getRainbowColor((l+m)/10+Date.now()/1e3),d++}if(k!==c){var n=255&k;var o=255&k>>8;var p=255&k>>16;var q=n!=(255&c);var r=o!=(255&c>>8);var s=p!=(255&c>>16);q&&r?a+='\x03'+encode3B(65535&k):q?a+='\x05'+encode2B(n):r&&(a+='\x06'+encode2B(o)),s&&(a+='\x04'+encode2B(p)),c=k}a+=j[0]}}catch(a){f=!0,g=a}finally{try{!e&&i.return&&i.return()}finally{if(f)throw g}}return a}},{key:'scheduleLoad',value:function scheduleLoad(){var a=this;clearTimeout(this._scheduledLoad),this._lastLoad<Date.now()-TERM_MIN_DRAW_DELAY?this.termScreen.load(this.serialize(),this.theme):this._scheduledLoad=setTimeout(function(){a.termScreen.load(a.serialize())},TERM_MIN_DRAW_DELAY-this._lastLoad)}},{key:'rainbowTimer',value:function rainbowTimer(){var a=this;this.rainbow&&(clearInterval(this._rainbowTimer),this._rainbowTimer=setInterval(function(){a.rainbow&&a.scheduleLoad()},50))}}]),a}();var Process=function(){function a(){_classCallCheck(this,a),this._listeners={}}return _createClass(a,[{key:'on',value:function on(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b})}},{key:'once',value:function once(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b,once:!0})}},{key:'off',value:function off(a,b){var c=this._listeners[a];if(c)for(var d in c)if(c[d].listener===b){c.splice(d,1);break}}},{key:'emit',value:function emit(a){var b=this._listeners[a];if(b){var p=[];for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];var f=!0;var g=!1;var h=void 0;try{for(var i,j=b[Symbol.iterator]();!(f=(i=j.next()).done);f=!0){var q=i.value;try{q.listener.apply(q,d),q.once&&p.push(q)}catch(a){console.error(a)}}}catch(a){g=!0,h=a}finally{try{!f&&j.return&&j.return()}finally{if(g)throw h}}var k=!0;var l=!1;var m=void 0;try{for(var n,o=p[Symbol.iterator]();!(k=(n=o.next()).done);k=!0){var r=n.value;b.splice(b.indexOf(r),1)}}catch(a){l=!0,m=a}finally{try{!k&&o.return&&o.return()}finally{if(l)throw m}}}}},{key:'write',value:function write(a){this.emit('in',a)}},{key:'destroy',value:function destroy(){this.emit('exit',0)}},{key:'run',value:function run(){}}]),a}();var demoData={buttons:{1:'',2:'',3:'',4:'',5:function _(a,b){b.child&&b.child.destroy();var c='info\r';var d=function(){b.write(c[0]),c=c.substr(1),c&&setTimeout(d,100)};setTimeout(d,200)}}};var demoshIndex={clear:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){this.emit('write','\x1B[2J\x1B[1;1H'),this.destroy()}}]),b}(Process),screenfetch:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){var a=this;var b=('\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(a){return a.trim()});var c='';for(var e=0;e<b.length;e++)for(var f=0;80>f;f++)c+=b[e][f]?'\x1B[38;5;'+getRainbowColor((f+e)/10)+'m'+b[e][f]:' ';this.emit('write','\r\n\x1B[?25l');var d=function(){a.emit('write',c.substr(0,80)),c=c.substr(80),c.length?setTimeout(d,50):(a.emit('write','\r\n\x1B[?25h'),a.destroy())};d()}}]),b}(Process),"local-echo":function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];b.includes('--suppress-note')||this.emit('write','\x1B[38;5;239mNote: not all terminal features are supported or and may not work as expected in this demo\x1B[0m\r\n')}},{key:'write',value:function write(a){this.emit('write',a)}}]),b}(Process),info:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){var a=this;for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];var e=c.includes('--fast');this.showSplash().then(function(){a.printText(e)})}},{key:'showSplash',value:function showSplash(){var a=this;var b=['',' -#####- -###*..#####- ######-',' -#* -#- .## .##. *#-',' -##### .-###*..#####- *#- -*##*- #*-#--#**#-*##-',' -#* -#-.##. *#- *##@#* ##. -#* *# .#*',' -#####--####- .##. *#- -*#@@- ##. -#* *# .#*',' '].filter(function(a){return a.trim()});var c={" ":-231,".":4,"-":8,"*":17,"#":24};for(var h in b)79>b[h].length&&(b[h]+=' '.repeat(79-b[h].length));this.emit('write','\r\n'.repeat(b.length+1)),this.emit('write','\x1B[A'.repeat(b.length)),this.emit('write','\x1B[?25l');var d=0;var e=0;var f=function(b,c){var f=Math.abs;var g=b-d;var h=c-e;a.emit('write','\x1B['+f(g)+(0<g?'C':'D')),a.emit('write','\x1B['+f(h)+(0<h?'B':'A')),d=b,e=c};var g=function(d,e){f(d,e),'@'===b[e][d]?a.emit('write','\x1B[48;5;8m\x1B[38;5;255m\u2584\b'):a.emit('write','\x1B[48;5;'+(231+c[b[e][d]])+'m \b')};return new Promise(function(c){var d=14;var e=0;var h=function(){for(var i=0;i<b.length;i++){var j=d-i;0<j&&g(j,i)}79>++d?3<=++e?(setTimeout(h,20),e=0):h():(f(0,b.length),a.emit('write','\x1B[m\x1B[?25h'),c())};h()})}},{key:'printText',value:function printText(){var a=0<arguments.length&&void 0!==arguments[0]&&arguments[0];var b=['',' ESPTerm is a VT100-like terminal emulator running on the ESP8266 WiFi chip.','',' \x1B[93mThis is an online demo of the web user interface, simulating a simple ',' terminal in your browser.\x1B[m','',' Type \x1B[92mls\x1B[m to list available commands.',' Use the \x1B[94mlinks\x1B[m below this screen for a demo of the options and more info.',''];if(a)this.emit('write',b.join('\r\n')+'\r\n'),this.destroy();else{var c=this;var d=function(){c.emit('write',b.shift()+'\r\n'),b.length?setTimeout(d,17):c.destroy()};d()}}}]),b}(Process),colors:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){this.emit('write','\r\n');this.emit('write',' ');for(var a=0;16>a;a++)this.emit('write','\x1B['+(8>a?'3'+a:'9'+(a-8))+'m'),this.emit('write','foreground-color'[a]+' ');this.emit('write','\r\n ');for(var c=0;16>c;c++)this.emit('write','\x1B['+(8>c?'4'+c:'10'+(c-8))+'m ');this.emit('write','\x1B[m\r\n');for(var d=0;6>d;d++){this.emit('write',' ');for(var e=0;6>e;e++){for(var f=0;6>f;f++)this.emit('write','\x1B[48;5;'+(16+36*d+6*e+f)+'m ');this.emit('write','\x1B[m')}this.emit('write','\r\n')}this.emit('write',' ');for(var b=0;24>b;b++)this.emit('write','\x1B[48;5;'+(232+b)+'m ');this.emit('write','\x1B[m\r\n\n'),this.destroy()}}]),b}(Process),ls:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){for(var a in this.emit('write','\x1B[92mList of demo commands\x1B[m\r\n'),demoshIndex)'string'!=typeof demoshIndex[a]&&this.emit('write',a+'\r\n');this.destroy()}}]),b}(Process),theme:function(a){function b(a){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return c.shell=a,c}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){var a=0|(0>=arguments.length?void 0:arguments[0]);return!arguments.length||!Number.isFinite(a)||0>a||5<a?(this.emit('write','\x1B[31mUsage: theme [0\u20135]\r\n'),void this.destroy()):void(this.shell.terminal.theme=a,this.shell.terminal.termScreen.drawnScreenFG=[],this.emit('write',''),this.destroy())}}]),b}(Process),cursor:function(a){function b(){return _classCallCheck(this,b),_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];var d=b.includes('--steady');b.includes('block')?this.emit('write','\x1B['+(0+2*d)+' q'):b.includes('line')?this.emit('write','\x1B['+(3+d)+' q'):b.includes('bar')||b.includes('beam')?this.emit('write','\x1B['+(5+d)+' q'):this.emit('write','\x1B[31mUsage: cursor [block|line|bar] [--steady]\r\n'),this.destroy()}}]),b}(Process),rainbow:function(a){function b(a){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return c.shell=a,c}return _inherits(b,a),_createClass(b,[{key:'run',value:function run(){this.shell.terminal.rainbow=!this.shell.terminal.rainbow,this.shell.terminal.rainbowTimer(),this.emit('write',''),this.destroy()}}]),b}(Process),pwd:'/this/is/a/demo\r\n',cd:'\x1B[38;5;239mNo directories to change to\r\n',whoami:window.navigator.userAgent+'\r\n',hostname:''+window.location.hostname,uname:'ESPTerm Demo\r\n',mkdir:'\x1B[38;5;239mDid not create a directory because this is a demo.\r\n',rm:'\x1B[38;5;239mDid not delete anything because this is a demo.\r\n',cp:'\x1B[38;5;239mNothing to copy because this is a demo.\r\n',mv:'\x1B[38;5;239mNothing to move because this is a demo.\r\n',ln:'\x1B[38;5;239mNothing to link because this is a demo.\r\n',touch:'\x1B[38;5;239mNothing to touch\r\n',exit:'\x1B[38;5;239mNowhere to go\r\n'};var DemoShell=function(){function a(b,c){var d=this;_classCallCheck(this,a),this.terminal=b,this.terminal.reset(),this.parser=new ANSIParser(function(){return d.handleParsed.apply(d,arguments)}),this.input='',this.cursorPos=0,this.child=null,this.index=demoshIndex,c?this.run('info'):this.prompt()}return _createClass(a,[{key:'write',value:function write(a){this.child?3===a.codePointAt(0)?this.child.destroy():this.child.write(a):this.parser.write(a)}},{key:'prompt',value:function prompt(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:!0;0!==this.terminal.cursor.x&&this.terminal.write('\x1B[m\x1B[38;5;238m\u23CE\r\n'),this.terminal.write('\x1B[34;1mdemosh \x1B[m'),a||this.terminal.write('\x1B[31m'),this.terminal.write('$ \x1B[m'),this.input='',this.cursorPos=0}},{key:'handleParsed',value:function handleParsed(a){if(this.terminal.write('\b\x1B[P'.repeat(this.cursorPos)),'write'===a)this.input=this.input.substr(0,this.cursorPos)+(1>=arguments.length?void 0:arguments[1])+this.input.substr(this.cursorPos),this.cursorPos++;else if('back'===a)this.input=this.input.substr(0,this.cursorPos-1)+this.input.substr(this.cursorPos),this.cursorPos--,0>this.cursorPos&&(this.cursorPos=0);else if('move-cursor-x'===a)this.cursorPos=Math.max(0,Math.min(this.input.length,this.cursorPos+(1>=arguments.length?void 0:arguments[1])));else if('delete-line'===a)this.input='',this.cursorPos=0;else if('delete-word'===a){var b=this.input.substr(0,this.cursorPos).split(' ');b.pop(),this.input=b.join(' ')+this.input.substr(this.cursorPos),this.cursorPos=b.join(' ').length}this.terminal.write(this.input),this.terminal.write('\b'.repeat(this.input.length)),this.terminal.moveForward(this.cursorPos),this.terminal.write(''),'return'===a&&(this.terminal.write('\r\n'),this.parse(this.input))}},{key:'parse',value:function parse(a){'help'===a&&(a='info'),this.run(a)}},{key:'run',value:function run(a){var b=[''];var c=!1;var d=!0;var e=!1;var f=void 0;try{for(var g,h=a.trim()[Symbol.iterator]();!(d=(g=h.next()).done);d=!0){var j=g.value;c&&j!==c?b[b.length-1]+=j:c?c=!1:'"'===j||'\''===j?c=j:j.match(/\s/)?b[b.length-1]&&b.push(''):b[b.length-1]+=j}}catch(a){e=!0,f=a}finally{try{!d&&h.return&&h.return()}finally{if(e)throw f}}var i=b.shift();i in this.index?this.spawn(i,b):(this.terminal.write('demosh: Unknown command: '+i+'\r\n'),this.prompt(!1))}},{key:'spawn',value:function spawn(a){var b=this;var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];var d=this.index[a];if(d instanceof Function){var e;this.child=new d(this);var f=function(a){return b.terminal.write(a)};this.child.on('write',f),this.child.on('exit',function(a){b.child&&b.child.off('write',f),b.child=null,b.prompt(!a)}),(e=this.child).run.apply(e,_toConsumableArray(c))}else this.terminal.write(d),this.prompt()}}]),a}();window.demoInterface={input:function input(a){var b=a[0];var c=a.substr(1);if('s'===b)this.shell.write(c);else if('b'===b){var d=c.charCodeAt(0);var e=demoData.buttons[d];e&&('string'==typeof e?this.shell.write(e):e instanceof Function&&e(this.terminal,this.shell))}else('m'===b||'p'===b||'r'===b)&&console.log(JSON.stringify(a))},init:function init(a){this.terminal=new ScrollingTerminal(a),this.shell=new DemoShell(this.terminal,!0)}};
"use strict";var _tr={"wifi.connected_ip_is":"Connected, IP is ","wifi.not_conn":"Not connected.","wifi.enter_passwd":"Enter password for \":ssid:\""};function tr(a){return _tr[a]||"?"+a+"?"}
'use strict';(function(a){function b(a){return Math.round(100*(a.value/a.max))+'%'}function c(a,b,c){$('#sta_ssid').val(a),$('#sta_password').val(b),$('#sta-nw').toggleClass('hidden',0===a.length),$('#sta-nw-nil').toggleClass('hidden',0<a.length),$('#sta-nw .essid').html(esc(a));var d=undef(b)||0===b.length;$('#sta-nw .passwd').toggleClass('hidden',d),$('#sta-nw .nopasswd').toggleClass('hidden',!d),$('#sta-nw .ip').html(0<c.length?tr('wifi.connected_ip_is')+c:tr('wifi.not_conn'))}function d(a,b){if(200!==b)return void f(5e3);try{a=JSON.parse(a)}catch(a){return console.log(a),void f(5e3)}var d=!bool(a.result.inProgress)&&0<a.result.APs.length;if(f(d?15000:1e3),!!d){var e=$('#ap-list');$('#ap-list .AP').remove(),e.toggleClass('hidden',!d),$('#ap-loader').toggleClass('hidden',d),a.result.APs.sort(function(c,a){return a.rssi-c.rssi}).forEach(function(a){if(a.enc=parseInt(a.enc),!(4<a.enc)){var b=mk('div');var d=$(b).data('ssid',a.essid).data('pwd',a.enc).attr('tabindex',0).addClass('AP');a.essid===h&&d.addClass('selected');var f=mk('div');var i=$.htmlEscape(a.essid);$(f).addClass('inner').htmlAppend('<div class="rssi">'+a.rssi_perc+'</div>').htmlAppend('<div class="essid" title="'+i+'">'+i+'</div>').htmlAppend('<div class="auth">'+g[a.enc]+'</div>'),d.on('click',function(){var a=$(this);var b=a.data('ssid');var d='';+a.data('pwd')&&(d=prompt(tr('wifi.enter_passwd').replace(':ssid:',b)),!d)||($('#sta_password').val(d),$('#sta_ssid').val(b),c(b,d,''))}),b.appendChild(f),e[0].appendChild(b)}})}}function e(){_demo?d(_demo_aps,200):$.get('http://'+_root+'/cfg/wifi/scan',d)}function f(a){setTimeout(e,a)}var g=['Open','WEP','WPA','WPA2','WPA/WPA2'];var h;a.init=function(a){$('.Row.range').forEach(function(a){var c=a.querySelector('input');var d=a.querySelector('.x-disp1');var e=a.querySelector('.x-disp2');var f=b(c);$(d).html(f),$(e).html(f),$(c).on('input',function(){f=b(c),$(d).html(f),$(e).html(f)})}),$('#forget-sta').on('click',function(){return c('','',''),!1}),c(a.sta_ssid,a.sta_password,a.sta_active_ip),h=a.sta_active_ssid},a.startScanning=function(){$('#ap-loader').removeClass('hidden'),$('#ap-scan').addClass('hidden'),$('#ap-loader .anim-dots').html('.'),e()}})(window.WiFi={});
'use strict';window.Conn=function(a){function b(){console.log('CONNECTED'),g(),e('i')}function c(a){console.warn('SOCKET CLOSED, code '+a.code+'. Reconnecting...'),clearTimeout(n),n=setTimeout(function(){f()},2e3)}function d(b){try{switch(b.data.charAt(0)){case'.':break;case'-':l=!0,m=setTimeout(function(){l=!1},250);break;case'+':l=!1,clearTimeout(m);break;default:a.load(b.data),o||(showPage(),o=!0);}g()}catch(a){console.error(a)}}function e(a){return _demo?('undefined'==typeof demoInterface?console.log('TX: '+JSON.stringify(a)):demoInterface.input(a),!0):l?(console.log('Can\'t send, flood control.'),!1):!!i&&(1===i.readyState?('string'!=typeof a&&(a=JSON.stringify(a)),i.send(a),!0):(console.error('Socket not ready'),!1))}function f(){return window._demo?void('undefined'==typeof demoInterface?alert('Demoing non-demo demo!'):(demoInterface.init(a),showPage())):void(clearTimeout(n),clearTimeout(j),i=new WebSocket('ws://'+_root+'/term/update.ws'),i.onopen=b,i.onclose=c,i.onmessage=d,console.log('Opening socket.'),g())}function g(){clearTimeout(j),j=setTimeout(h,2e3)}function h(){console.error('Heartbeat lost, probing server...'),k=setInterval(function(){console.log('> ping'),$.get('http://'+_root+'/system/ping',function(a,b){200===b&&(clearInterval(k),console.info('Server ready, reloading page...'),location.reload())},{timeout:100})},1e3)}var i;var j;var k;var l=!1;var m;var n;var o=!1;return{ws:null,init:f,send:e,canSend:function(){return!l}}};
'use strict';window.Input=function(a){function b(b){return a.send('s'+b)}function c(b){a.send('b'+Chr(b))}function d(a,b){return l.fn_alt?a:b}function e(a,b){return l.cu_alt?a:b}function f(a,b){return l.np_alt?a:b}function g(a){var b={tab:'\t',backspace:'\b',enter:l.crlf_mode?'\r\n':'\r',"ctrl+enter":'\n',esc:'\x1B',up:e('\x1BOA','\x1B[A'),down:e('\x1BOB','\x1B[B'),right:e('\x1BOC','\x1B[C'),left:e('\x1BOD','\x1B[D'),home:e('\x1BOH',d('\x1B[H','\x1B[1~')),insert:'\x1B[2~',delete:'\x1B[3~',end:e('\x1BOF',d('\x1B[F','\x1B[4~')),pageup:'\x1B[5~',pagedown:'\x1B[6~',f1:d('\x1BOP','\x1B[11~'),f2:d('\x1BOQ','\x1B[12~'),f3:d('\x1BOR','\x1B[13~'),f4:d('\x1BOS','\x1B[14~'),f5:'\x1B[15~',f6:'\x1B[17~',f7:'\x1B[18~',f8:'\x1B[19~',f9:'\x1B[20~',f10:'\x1B[21~',f11:'\x1B[23~',f12:'\x1B[24~',"shift+f1":d('\x1BO1;2P','\x1B[25~'),"shift+f2":d('\x1BO1;2Q','\x1B[26~'),"shift+f3":d('\x1BO1;2R','\x1B[28~'),"shift+f4":d('\x1BO1;2S','\x1B[29~'),"shift+f5":d('\x1B[15;2~','\x1B[31~'),"shift+f6":d('\x1B[17;2~','\x1B[32~'),"shift+f7":d('\x1B[18;2~','\x1B[33~'),"shift+f8":d('\x1B[19;2~','\x1B[34~'),"shift+f9":d('\x1B[20;2~','\x1B[35~'),"shift+f10":d('\x1B[21;2~','\x1B[36~'),"shift+f11":d('\x1B[22;2~','\x1B[37~'),"shift+f12":d('\x1B[23;2~','\x1B[38~'),np_0:f('\x1BOp','0'),np_1:f('\x1BOq','1'),np_2:f('\x1BOr','2'),np_3:f('\x1BOs','3'),np_4:f('\x1BOt','4'),np_5:f('\x1BOu','5'),np_6:f('\x1BOv','6'),np_7:f('\x1BOw','7'),np_8:f('\x1BOx','8'),np_9:f('\x1BOy','9'),np_mul:f('\x1BOR','*'),np_add:f('\x1BOl','+'),np_sub:f('\x1BOS','-'),np_point:f('\x1BOn','.'),np_div:f('\x1BOQ','/')};var c=['f5','f11','f12','shift+f5'];for(var g in b)(a||!c.includes(g))&&b.hasOwnProperty(g)&&h(g,b[g])}function h(a,c){-1!==a.indexOf('ctrl+')&&(a+=','+a.replace('ctrl','command')),key.unbind(a),key(a,function(a){l.no_keys||(a.preventDefault(),b(c))})}function i(a){var c=String.fromCharCode;var d=a.allFn;window.addEventListener('keypress',function(a){if(!l.no_keys){var c='';a.key?c=a.key:a.which&&(c=String.fromCodePoint(a.which)),0<c.length&&32<=c.charCodeAt(0)&&(32===a.which&&a.preventDefault(),b(c))}});for(var e=1;26>=e;e++)h('ctrl+'+c(96+e),c(e));h('ctrl+]','\x1B'),h('ctrl+\\','\x1C'),h('ctrl+[','\x1D'),h('ctrl+^','\x1E'),h('ctrl+_','\x1F'),h('ctrl+left','\x1F[1;5D'),h('ctrl+right','\x1F[1;5C'),h('ctrl+up','\x1F[1;5A'),h('ctrl+down','\x1F[1;5B'),h('ctrl+home','\x1F[1;5H'),h('ctrl+end','\x1F[1;5F'),h('shift+left','\x1F[1;2D'),h('shift+right','\x1F[1;2C'),h('shift+up','\x1F[1;2A'),h('shift+down','\x1F[1;2B'),h('shift+home','\x1F[1;2H'),h('shift+end','\x1F[1;2F'),h('\u2325+left','\x1Bb'),h('\u2325+right','\x1Bf'),h('\u2318+left','\x01'),h('\u2318+right','\x05'),h('\u2325+backspace','\x17'),h('\u2318+backspace','\x15'),g(d)}function j(){return(key.isModifier('ctrl')?1:0)|(key.isModifier('shift')?2:0)|(key.isModifier('alt')?4:0)|(key.isModifier('meta')?8:0)}var l={np_alt:!1,cu_alt:!1,fn_alt:!1,mt_click:!1,mt_move:!1,no_keys:!1,crlf_mode:!1};var k=0;var n=0;var o=0;return{init:function(a){i(a),$('#action-buttons button').forEach(function(a){a.addEventListener('click',function(){c(+this.dataset.n)})}),window.addEventListener('mousedown',function(a){0===a.button&&(k=1),1===a.button&&(n=1),2===a.button&&(o=1)}),window.addEventListener('mouseup',function(a){0===a.button&&(k=0),1===a.button&&(n=0),2===a.button&&(o=0)})},sendString:b,setAlts:function setAlts(a,b,c,d){(l.cu_alt!==a||l.np_alt!==b||l.fn_alt!==c||l.crlf_mode!==d)&&(l.cu_alt=a,l.np_alt=b,l.fn_alt=c,l.crlf_mode=d,g())},setMouseMode:function setMouseMode(a,b){l.mt_click=a,l.mt_move=b},onMouseMove:function onMouseMove(c,d){if(l.mt_move){var e=k?1:n?2:o?3:0;var b=j();a.send('m'+encode2B(d)+encode2B(c)+encode2B(e)+encode2B(b))}},onMouseDown:function onMouseDown(c,d,e){if(l.mt_click&&!(3<e||1>e)){var b=j();a.send('p'+encode2B(d)+encode2B(c)+encode2B(e)+encode2B(b))}},onMouseUp:function onMouseUp(c,d,e){if(l.mt_click&&!(3<e||1>e)){var b=j();a.send('r'+encode2B(d)+encode2B(c)+encode2B(e)+encode2B(b))}},onMouseWheel:function onMouseWheel(c,d,e){if(l.mt_click){var f=j();var g=0>e?4:5;a.send('p'+encode2B(d)+encode2B(c)+encode2B(g)+encode2B(f))}},mouseTracksClicks:function mouseTracksClicks(){return l.mt_click},blockKeys:function blockKeys(a){l.no_keys=a}}};
'use strict';var _slicedToArray=function(){function a(a,b){var c=[];var d=!0;var e=!1;var f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}();var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,'value'in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _toConsumableArray(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var frakturExceptions={C:'\u212D',H:'\u210C',I:'\u2111',R:'\u211C',Z:'\u2128'};var SEQ_REPEAT=2;var SEQ_SET_COLORS=3;var SEQ_SET_ATTRS=4;var SEQ_SET_FG=5;var SEQ_SET_BG=6;var SELECTION_BG='#b2d7fe';var SELECTION_FG='#333';var 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']];var colorTable256=Array(16).fill('rgba(0, 0, 0, 0)');for(var red=0;6>red;red++)for(var green=0;6>green;green++)for(var blue=0;6>blue;blue++){var redValue=40*red+(red?55:0);var greenValue=40*green+(green?55:0);var blueValue=40*blue+(blue?55:0);colorTable256.push('rgb('+redValue+', '+greenValue+', '+blueValue+')')}for(var gray=0;24>gray;gray++){var value=10*gray+8;colorTable256.push('rgb('+value+', '+value+', '+value+')')}window.TermScreen=function(){function a(){var b=this;_classCallCheck(this,a),this.canvas=mk('canvas'),this.ctx=this.canvas.getContext('2d'),'AudioContext'in window||'webkitAudioContext'in window?this.audioCtx=new(window.AudioContext||window.webkitAudioContext):console.warn('No AudioContext!'),this.input=new Proxy({},{get:function get(){return function(){return console.warn('TermScreen#input not set!')}}}),this.cursor={x:0,y:0,blinkOn:!1,blinking:!0,visible:!0,hanging:!1,style:'block',blinkInterval:null},this._palette=null,this._window={width:0,height:0,devicePixelRatio:1,fontFamily:'"DejaVu Sans Mono", "Liberation Mono", "Inconsolata", "Menlo", monospace',fontSize:20,gridScaleX:1,gridScaleY:1.2,blinkStyleOn:!0,blinkInterval:null,fitIntoWidth:0,fitIntoHeight:0,debug:!1,graphics:0},this._windowScale=1,this.windowState={width:0,height:0,devicePixelRatio:0,gridScaleX:0,gridScaleY:0,fontFamily:'',fontSize:0,fitIntoWidth:0,fitIntoHeight:0},this.selection={selectable:!0,start:[0,0],end:[0,0]},this.mouseMode={clicks:!1,movement:!1},this._listeners={};var c=this;this.window=new Proxy(this._window,{set:function set(a,b,d){return a[b]=d,c.scheduleSizeUpdate(),c.scheduleDraw('window:'+b+'='+d),!0}}),this.bracketedPaste=!1,this.blinkingCellCount=0,this.screen=[],this.screenFG=[],this.screenBG=[],this.screenAttrs=[],this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.drawnCursor=[-1,-1,''],this.resetBlink(),this.resetCursorBlink();var d=!1;var f=function(a,c){d||(d=!0,b.selection.start=b.selection.end=b.screenToGrid(a,c),b.scheduleDraw('select-start'))};var g=function(a,c){d&&(b.selection.end=b.screenToGrid(a,c),b.scheduleDraw('select-move'))};var h=function(a,c){d&&(d=!1,b.selection.end=b.screenToGrid(a,c),b.scheduleDraw('select-end'),Object.assign(b.selection,b.getNormalizedSelection()))};this.canvas.addEventListener('mousedown',function(a){if((b.selection.selectable||a.altKey)&&0===a.button)f(a.offsetX,a.offsetY);else{var c;(c=b.input).onMouseDown.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([a.button+1]))}}),window.addEventListener('mousemove',function(a){g(a.offsetX,a.offsetY)}),window.addEventListener('mouseup',function(a){h(a.offsetX,a.offsetY)});var i=null;var j=0;var k=!1;var l=function(a){var c=b.canvas.getBoundingClientRect();return[a.clientX-c.left,a.clientY-c.top]};this.canvas.addEventListener('touchstart',function(a){i=l(a.touches[0]),k=!1,j=Date.now()}),this.canvas.addEventListener('touchmove',function(a){i=l(a.touches[0]),d||!1!=k?d&&(a.preventDefault(),g.apply(void 0,_toConsumableArray(i))):j<Date.now()-500&&f.apply(void 0,_toConsumableArray(i)),k=!0}),this.canvas.addEventListener('touchend',function(a){if(a.touches[0]&&(i=l(a.touches[0])),d){a.preventDefault(),h.apply(void 0,_toConsumableArray(i));var c=qs('#touch-select-menu');c.classList.add('open');var e=c.getBoundingClientRect();var f=b.gridToScreen((b.selection.start[0]+b.selection.end[0])/2,b.selection.start[1]-1);f[0]-=e.width/2,f[1]-=e.height/2,c.style.transform='translate('+f[0]+'px, '+f[1]+'px)'}k||b.emit('tap',Object.assign(a,{x:i[0],y:i[1]})),i=null}),this.on('tap',function(a){b.selection.start[0]!==b.selection.end[0]||b.selection.start[1]!==b.selection.end[1]?(b.selection.start=b.selection.end=[0,0],qs('#touch-select-menu').classList.remove('open'),b.scheduleDraw('select-reset')):(a.preventDefault(),b.emit('open-soft-keyboard'))}),$.ready(function(){var a=qs('#touch-select-copy-btn');a&&a.addEventListener('click',function(){b.copySelectionToClipboard()})}),this.canvas.addEventListener('mousemove',function(a){if(!d){var c;(c=b.input).onMouseMove.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)))}}),this.canvas.addEventListener('mouseup',function(a){if(!d){var c;(c=b.input).onMouseUp.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([a.button+1]))}}),this.canvas.addEventListener('wheel',function(a){if(b.mouseMode.clicks){var c;(c=b.input).onMouseWheel.apply(c,_toConsumableArray(b.screenToGrid(a.offsetX,a.offsetY)).concat([0<a.deltaY?1:-1])),a.preventDefault()}}),this.canvas.addEventListener('contextmenu',function(a){b.mouseMode.clicks&&a.preventDefault(),h(a.offsetX,a.offsetY)}),key('\u2303+\u21E7+c',function(a){a.preventDefault(),b.copySelectionToClipboard()})}var b=Math.ceil;var c=Math.floor;return _createClass(a,[{key:'on',value:function on(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b})}},{key:'once',value:function once(a,b){this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push({listener:b,once:!0})}},{key:'off',value:function off(a,b){var c=this._listeners[a];if(c)for(var d in c)if(c[d].listener===b){c.splice(d,1);break}}},{key:'emit',value:function emit(a){var b=this._listeners[a];if(b){var p=[];for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];var f=!0;var g=!1;var h=void 0;try{for(var i,j=b[Symbol.iterator]();!(f=(i=j.next()).done);f=!0){var q=i.value;try{q.listener.apply(q,d),q.once&&p.push(q)}catch(a){console.error(a)}}}catch(a){g=!0,h=a}finally{try{!f&&j.return&&j.return()}finally{if(g)throw h}}var k=!0;var l=!1;var m=void 0;try{for(var n,o=p[Symbol.iterator]();!(k=(n=o.next()).done);k=!0){var r=n.value;b.splice(b.indexOf(r),1)}}catch(a){l=!0,m=a}finally{try{!k&&o.return&&o.return()}finally{if(l)throw m}}}}},{key:'getColor',value:function getColor(a){if(this.palette[a])return this.palette[a];if(-1===a)return SELECTION_FG;if(-2===a)return SELECTION_BG;if(15<a&&256>a)return colorTable256[a];if(255<a){a-=256;var b=255&a>>16;var c=255&a>>8;var d=255&a;return'rgb('+b+', '+c+', '+d+')'}return'rgba(0, 0, 0, 0)'}},{key:'scheduleSizeUpdate',value:function scheduleSizeUpdate(){var a=this;clearTimeout(this._scheduledSizeUpdate),this._scheduledSizeUpdate=setTimeout(function(){return a.updateSize()},1)}},{key:'scheduleDraw',value:function scheduleDraw(a){var b=this;var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;clearTimeout(this._scheduledDraw),this._scheduledDraw=setTimeout(function(){return b.draw(a)},c)}},{key:'getFont',value:function getFont(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var b=a.style||'normal';var c=a.weight||'normal';return b+' normal '+c+' '+this.window.fontSize+'px '+this.window.fontFamily}},{key:'getCharSize',value:function getCharSize(){return this.ctx.font=this.getFont(),{width:c(this.ctx.measureText(' ').width),height:this.window.fontSize}}},{key:'getCellSize',value:function getCellSize(){var a=this.getCharSize();return{width:b(a.width*this.window.gridScaleX),height:b(a.height*this.window.gridScaleY)}}},{key:'updateSize',value:function updateSize(){this._window.devicePixelRatio=this._windowScale*(window.devicePixelRatio||1);var a=!1;for(var i in this.windowState)this.windowState.hasOwnProperty(i)&&this.windowState[i]!==this.window[i]&&(a=!0,this.windowState[i]=this.window[i]);if(a){var b=this.window,c=b.width,d=b.height,e=b.gridScaleX,f=b.gridScaleY,g=b.fitIntoWidth,h=b.fitIntoHeight;var j=this.getCellSize();var k=c*j.width;var l=d*j.height;if(g&&h){var m=k/l;m<g/h?(l=h,k=l*m):(k=g,l=k/m)}else g?(l=g/(k/l),k=g):h&&(k=h*(k/l),l=h);this._windowScale=k/(c*j.width);var n=this._window.devicePixelRatio=this._windowScale*window.devicePixelRatio;this.canvas.width=c*n*j.width,this.canvas.style.width=k+'px',this.canvas.height=d*n*j.height,this.canvas.style.height=l+'px',this.drawnScreen=[],this.drawnScreenFG=[],this.drawnScreenBG=[],this.drawnScreenAttrs=[],this.draw('init')}}},{key:'resetCursorBlink',value:function resetCursorBlink(){var a=this;this.cursor.blinkOn=!0,clearInterval(this.cursor.blinkInterval),this.cursor.blinkInterval=setInterval(function(){a.cursor.blinkOn=!a.cursor.blinking||!a.cursor.blinkOn,a.cursor.blinking&&a.scheduleDraw('cursor-blink')},500)}},{key:'resetBlink',value:function resetBlink(){var a=this;this.window.blinkStyleOn=!0,clearInterval(this.window.blinkInterval);var b=0;this.window.blinkInterval=setInterval(function(){0>=a.blinkingCellCount||(b++,4<=b&&a.window.blinkStyleOn?(a.window.blinkStyleOn=!1,b=0):1<=b&&!a.window.blinkStyleOn&&(a.window.blinkStyleOn=!0,b=0))},200)}},{key:'getNormalizedSelection',value:function getNormalizedSelection(){var a=this.selection,b=a.start,c=a.end;if(b[1]>c[1]||b[1]===c[1]&&b[0]>c[0]){var d=[c,b];b=d[0],c=d[1]}return{start:b,end:c}}},{key:'isInSelection',value:function isInSelection(a,b){var c=this.getNormalizedSelection(),d=c.start,e=c.end;var f=d[0]<=a;var g=a<e[0];var h=b===d[1];var i=b===e[1];return h&&i?f&&g:h?f:i?g:d[1]<b&&b<e[1]}},{key:'getSelectedText',value:function getSelectedText(){var a=this.window.width*this.window.height;var b=[];var d=-1;for(var e=0;e<a;e++){var f=e%this.window.width;var g=c(e/this.window.width);this.isInSelection(f,g)&&(d!==g&&(d=g,b.push('')),b[b.length-1]+=this.screen[e])}return b.join('\n')}},{key:'copySelectionToClipboard',value:function copySelectionToClipboard(){var a=this.getSelectedText();if(a){var b=mk('textarea');document.body.appendChild(b),b.value=a,b.select(),document.execCommand('copy')?Notify.show('Copied to clipboard'):Notify.show('Failed to copy'),document.body.removeChild(b)}}},{key:'screenToGrid',value:function screenToGrid(a,b){var d=this.getCellSize();return[c((a+d.width/2)/d.width),c(b/d.height)]}},{key:'gridToScreen',value:function gridToScreen(a,b){var c=this;var d=2<arguments.length&&void 0!==arguments[2]&&arguments[2];var e=this.getCellSize();return[a*e.width,b*e.height].map(function(a){return d?a*c._windowScale:a})}},{key:'drawCellBackground',value:function drawCellBackground(a){var c=a.x,d=a.y,e=a.cellWidth,f=a.cellHeight,g=a.bg;var h=this.ctx;h.fillStyle=this.getColor(g),h.clearRect(c*e,d*f,b(e),b(f)),h.fillRect(c*e,d*f,b(e),b(f))}},{key:'drawCell',value:function drawCell(b){var c=Math.round;var d=b.x,e=b.y,f=b.charSize,g=b.cellWidth,h=b.cellHeight,i=b.text,j=b.fg,k=b.attrs;if(i){var l=this.ctx;var m=!1;var n=!1;var o=!1;if(2&k&&(l.globalAlpha=0.5),8&k&&(m=!0),32&k&&(i=a.alphaToFraktur(i)),64&k&&(n=!0),128&k&&(o=!0),l.fillStyle=this.getColor(j),l.fillText(i,(d+0.5)*g,(e+0.5)*h),m||n||o){if(l.strokeStyle=this.getColor(j),l.lineWidth=1,l.lineCap='round',l.beginPath(),m){var p=c(e*h+f.height)+0.5;l.moveTo(d*g,p),l.lineTo((d+1)*g,p)}if(n){var q=c((e+0.5)*h)+0.5;l.moveTo(d*g,q),l.lineTo((d+1)*g,q)}if(o){var r=c(e*h)+0.5;l.moveTo(d*g,r),l.lineTo((d+1)*g,r)}l.stroke()}l.globalAlpha=1}}},{key:'getAdjacentCells',value:function getAdjacentCells(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;var c=this.window,d=c.width,e=c.height;var f=[];for(var g=-b;g<=b;g++)for(var h=-b;h<=b;h++)(0!==g||0!==h)&&f.push(a+g+h*d);return f.filter(function(a){return 0<=a&&a<d*e})}},{key:'draw',value:function draw(a){var b=this;var d=this.ctx;var e=this.window,f=e.width,g=e.height,h=e.devicePixelRatio,i=e.gridScaleX,j=e.gridScaleY;var k=this.getCharSize();var l=this.getCellSize(),m=l.width,n=l.height;d.setTransform(h,0,0,h,0,0),this.window.debug&&this._debug&&this._debug.drawStart(a),d.font=this.getFont(),d.textAlign='center',d.textBaseline='middle';var o=new Map;var p=new Map;for(var na=0;na<f*g;na++){var oa=na%f;var x=c(na/f);var y=!this.cursor.hanging&&this.cursor.x===oa&&this.cursor.y===x&&this.cursor.blinkOn&&this.cursor.visible;var pa=oa===this.drawnCursor[0]&&x===this.drawnCursor[1];var qa=this.isInSelection(oa,x);var ra=this.screen[na];var sa=this.screenFG[na];var ta=this.screenBG[na];var ua=this.screenAttrs[na];16&ua&&!this.window.blinkStyleOn&&(ra=''),qa&&(sa=-1,ta=-2);var va=ra!==this.drawnScreen[na]||sa!==this.drawnScreenFG[na]||ta!==this.drawnScreenBG[na]||ua!==this.drawnScreenAttrs[na]||y!==pa||y&&this.cursor.style!==this.drawnCursor[2];var wa=ua&5;o.has(wa)||o.set(wa,[]),o.get(wa).push([na,oa,x,ra,sa,ta,ua,y,qa]),p.set(na,va)}var q=new Map;var r=function(a){return' '!==a&&d.measureText(a).width>=m+0.05};var s=function(a){var c=p.get(a)||q.get(a);var d=b.screen[a];var e=r(d);var f=e?2:1;if(!c){var l=!1;var g=!0;var h=!1;var i=void 0;try{for(var j,k=b.getAdjacentCells(a,f)[Symbol.iterator]();!(g=(j=k.next()).done);g=!0){var m=j.value;if(p.get(m)){l=!0;break}}}catch(a){h=!0,i=a}finally{try{!g&&k.return&&k.return()}finally{if(h)throw i}}l&&(c=!0)}q.set(a,c)};var t=!0;var u=!1;var v=void 0;try{for(var w,z=p.keys()[Symbol.iterator]();!(t=(w=z.next()).done);t=!0){var xa=w.value;s(xa)}}catch(a){u=!0,v=a}finally{try{!t&&z.return&&z.return()}finally{if(u)throw v}}if(1<=this.window.graphics){d.save(),d.beginPath();for(var ya=0;ya<g;ya++){var za=null;for(var Aa=0;Aa<f;Aa++){var Ba=ya*f+Aa;var Ca=q.get(Ba);Ca&&null==za&&(za=Aa),Ca||null===za||(d.rect(za*m,ya*n,(Aa-za)*m,n),za=null)}null!==za&&d.rect(za*m,ya*n,(f-za)*m,n)}d.clip()}var A=!0;var B=!1;var C=void 0;try{for(var D,E=o.keys()[Symbol.iterator]();!(A=(D=E.next()).done);A=!0){var Da=D.value;var F=!0;var G=!1;var H=void 0;try{for(var I,J=o.get(Da)[Symbol.iterator]();!(F=(I=J.next()).done);F=!0){var Ea=I.value;var K=_slicedToArray(Ea,8),L=K[0],M=K[1],N=K[2],O=K[3],P=K[4],Q=K[5],R=K[6],S=K[7];q.get(L)&&this.drawCellBackground({x:M,y:N,cellWidth:m,cellHeight:n,bg:Q})}}catch(a){G=!0,H=a}finally{try{!F&&J.return&&J.return()}finally{if(G)throw H}}}}catch(a){B=!0,C=a}finally{try{!A&&E.return&&E.return()}finally{if(B)throw C}}var T=!0;var U=!1;var V=void 0;try{for(var W,X=o.keys()[Symbol.iterator]();!(T=(W=X.next()).done);T=!0){var Fa=W.value;var Ga={};1&Fa&&(Ga.weight='bold'),4&Fa&&(Ga.style='italic'),d.font=this.getFont(Ga);var Y=!0;var Z=!1;var _=void 0;try{for(var aa,ba=o.get(Fa)[Symbol.iterator]();!(Y=(aa=ba.next()).done);Y=!0){var Ha=aa.value;var ca=_slicedToArray(Ha,9),da=ca[0],ea=ca[1],fa=ca[2],ga=ca[3],ha=ca[4],ia=ca[5],ja=ca[6],ka=ca[7],la=ca[8];if(q.get(da)&&(this.drawCell({x:ea,y:fa,charSize:k,cellWidth:m,cellHeight:n,text:ga,fg:ha,attrs:ja}),this.drawnScreen[da]=ga,this.drawnScreenFG[da]=ha,this.drawnScreenBG[da]=ia,this.drawnScreenAttrs[da]=ja,ka&&(this.drawnCursor=[ea,fa,this.cursor.style]),this.window.debug&&this._debug)){var Ia=1;Ia|=+p.get(da)<<1,Ia|=+r(ga)<<2,this._debug.setCell(da,Ia)}if(ka&&!la){if(d.save(),d.beginPath(),'block'===this.cursor.style)d.rect(ea*m,fa*n,m,n);else if('bar'===this.cursor.style){d.rect(ea*m,fa*n,2,n)}else if('line'===this.cursor.style){d.rect(ea*m,fa*n+k.height,m,2)}d.clip();var ma=[ia,ha];ha=ma[0],ia=ma[1],ha===ia&&(ia=0===ha?7:0),this.drawCellBackground({x:ea,y:fa,cellWidth:m,cellHeight:n,bg:ia}),this.drawCell({x:ea,y:fa,charSize:k,cellWidth:m,cellHeight:n,text:ga,fg:ha,attrs:ja}),d.restore()}}}catch(a){Z=!0,_=a}finally{try{!Y&&ba.return&&ba.return()}finally{if(Z)throw _}}}}catch(a){U=!0,V=a}finally{try{!T&&X.return&&X.return()}finally{if(U)throw V}}1<=this.window.graphics&&d.restore(),this.window.debug&&this._debug&&this._debug.drawEnd()}},{key:'loadContent',value:function loadContent(a){var b=this;var c=0;var d=parse2B(a,c);var e=parse2B(a,c+2);var f=this.window.height!==d||this.window.width!==e;this.window.height=d,this.window.width=e,c+=4;var g=[parse2B(a,c),parse2B(a,c+2)],h=g[0],i=g[1];c+=4;var k=i!==this.cursor.x||h!==this.cursor.y;this.cursor.x=i,this.cursor.y=h,k&&(this.resetCursorBlink(),this.emit('cursor-moved'));var l=parse3B(a,c);c+=3,this.cursor.visible=!!(1&l),this.cursor.hanging=!!(2&l),this.input.setAlts(!!(4&l),!!(8&l),!!(16&l),!!(4096&l));var m=!!(32&l);var n=!!(64&l);var o=7&l>>9;0<o&&o--;var p=o>>1;var q=!(1&o);0==p?this.cursor.style='block':1==p?this.cursor.style='line':2==p&&(this.cursor.style='bar'),this.cursor.blinking!==q&&(this.cursor.blinking=q,this.resetCursorBlink()),this.input.setMouseMode(m,n),this.selection.selectable=!n,$(this.canvas).toggleClass('selectable',!n),this.mouseMode={clicks:m,movement:n};$('.x-term-conf-btn').toggleClass('hidden',!!!(256&l)),$('#action-buttons').toggleClass('hidden',!!!(128&l)),this.bracketedPaste=!!(8192&l);var r=7;var s=0;var t=0;var u=0;var v=' ';var w=this.window.width*this.window.height;f&&(this.updateSize(),this.blinkingCellCount=0,this.screen=Array(w).fill(' '),this.screenFG=Array(w).fill(' '),this.screenBG=Array(w).fill(' '),this.screenAttrs=Array(w).fill(' '));var x=Array(256).fill(0);var y=undef(Array.from)?a.split(''):Array.from(a);var z=16;for(var C=function(){var a=t;0!=(a&z)&&(' '==v&&0==(a&200)||r==s)&&(a^=z),(b.screenAttrs[u]&z)!=(a&z)&&(a&z?b.blinkingCellCount++:b.blinkingCellCount--),x[s]++,b.screen[u]=v,b.screenFG[u]=r,b.screenBG[u]=s,b.screenAttrs[u]=a};c<y.length&&u<w;){var D=y[c++];var E=D.codePointAt(0);var F=void 0;switch(E){case SEQ_REPEAT:var G=parse2B(y[c]+y[c+1]);c+=2;for(var H=0;H<G&&(C(u),!(++u>w));H++);break;case SEQ_SET_COLORS:F=parse3B(y[c]+y[c+1]+y[c+2]),c+=3,r=255&F,s=255&F>>8;break;case SEQ_SET_ATTRS:F=parse2B(y[c]+y[c+1]),c+=2,t=255&F;break;case SEQ_SET_FG:F=parse2B(y[c]+y[c+1]),c+=2,r=255&F;break;case SEQ_SET_BG:F=parse2B(y[c]+y[c+1]),c+=2,s=255&F;break;default:32>E&&(D='\uFFFD'),v=D,C(u),u++;}}this.window.debug&&console.log('Blinky cells = '+this.blinkingCellCount);var A=0;var B=0;for(var j=255;0<=j;j--)x[j]>A&&(A=x[j],B=j);this.canvas.style.backgroundColor=this.getColor(B),this.scheduleDraw('load',16),this.emit('load')}},{key:'loadLabels',value:function loadLabels(a){var b=a.split('\x01');qs('#screen-title').textContent=b[0],$('#action-buttons button').forEach(function(a,c){var d=b[c+1].trim();a.innerHTML=d?esc(d):'&nbsp;',a.style.opacity=d?1:0.2})}},{key:'showNotification',value:function showNotification(a){if(console.info('Notification: '+a),Notification&&'granted'===Notification.permission){var b=new Notification('ESPTerm',{body:a});b.addEventListener('click',function(){return window.focus()})}else Notification&&'denied'!==Notification.permission?Notification.requestPermission():Notify.show(a)}},{key:'load',value:function load(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1;var c=a.substr(1);switch(0<=b&&b<themes.length&&(this.palette=themes[b]),a[0]){case'S':this.loadContent(c);break;case'T':this.loadLabels(c);break;case'B':this.beep();break;case'G':this.showNotification(c);break;default:console.warn('Bad data message type; ignoring.\n'+JSON.stringify(a));}}},{key:'beep',value:function beep(){var a=this.audioCtx;if(a&&!(this._lastBeep&&this._lastBeep>Date.now()-50)){this._lastBeep=Date.now();var b,c;b=a.createOscillator(),c=a.createGain(),b.connect(c),c.connect(a.destination),c.gain.value=0.5,b.frequency.value=750,b.type='sine',b.start(),b.stop(a.currentTime+0.05),b=a.createOscillator(),c=a.createGain(),b.connect(c),c.connect(a.destination),c.gain.value=0.2,b.frequency.value=400,b.type='sine',b.start(a.currentTime+0.05),b.stop(a.currentTime+0.08)}}},{key:'palette',get:function get(){return this._palette||themes[0]},set:function set(a){this._palette!==a&&(this._palette=a,this.scheduleDraw('palette'))}}],[{key:'alphaToFraktur',value:function alphaToFraktur(a){var b=String.fromCodePoint;return'a'<=a&&'z'>=a?a=b(119997+a.charCodeAt(0)):'A'<=a&&'Z'>=a&&(a=frakturExceptions[a]||b(120003+a.charCodeAt(0))),a}}]),a}();
'use strict';window.TermUpl=function(a,b,c){function d(){f('Ready...'),Modal.show('#fu_modal',e),$('#fu_form').toggleClass('busy',!1),b.blockKeys(!0)}function e(){console.log('Upload modal closed.'),clearTimeout(m),l=0,b.blockKeys(!1)}function f(a){qs('#fu_prog').textContent=a}function g(){var a=qs('#fu_text').value;return a.length?void(k=a.split('\n'),l=0,q=0,n=qs('#fu_delay').value,0>n&&(n=0,qs('#fu_delay').value=n),o={CR:'\r',LF:'\n',CRLF:'\r\n'}[qs('#fu_crlf').value],$('#fu_form').toggleClass('busy',!0),f('Starting...'),h()):void j()}function h(){if($('#fu_modal').hasClass('visible')){if(!a.canSend())return void(m=setTimeout(h,1));0===q&&(p='',0===l&&c.bracketedPaste&&(p='\x1B[200~'),p+=k[l++]+o,l===k.length&&c.bracketedPaste&&(p+='\x1B[201~'));var d;if(p.length-q<=r?(d=p.substr(q,r),q=0):(d=p.substr(q,r),q+=r),console.log(d),!b.sendString(d))return void f('FAILED!');var e=Math.round(1e3*(l/k.length))/10;f(l+' / '+k.length+' ('+e+'%)'),k.length>l||0<q?m=setTimeout(h,n):i()}}function i(){a.canSend()?(f('Done.'),j()):(f('Waiting for Tx buffer...'),setTimeout(i,100))}function j(){Modal.hide('#fu_modal')}var k,l,m,n,o,p,q;var r=128;return{init:function init(){qs('#fu_file').addEventListener('change',function(a){var b=new FileReader;var c=a.target.files[0];return console.log('Selected file type: '+c.type),c.type.match(/text\/.*|application\/(json|csv|.*xml.*|.*script.*)/)||confirm('This does not look like a text file: '+c.type+'\nReally load?')?void(b.onload=function(a){var b=a.target.result.replace(/[\r\n]+/,'\n');qs('#fu_text').value=b},console.log('Loading file...'),b.readAsText(c)):void(qs('#fu_file').value='')},!1),qs('#term-fu-open').addEventListener('click',function(){return d(),!1}),qs('#term-fu-start').addEventListener('click',function(){return g(),!1}),qs('#term-fu-close').addEventListener('click',function(){return j(),!1})}}};
'use strict';var _slicedToArray=function(){function a(a,b){var c=[];var d=!0;var e=!1;var f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}();window.attachDebugScreen=function(a){var b=mk('canvas');var c=b.getContext('2d');b.style.position='absolute',b.style.top='6px',b.style.left='6px',b.style.pointerEvents='none';var d=function(){b.parentNode||a.canvas.parentNode.appendChild(b)};var e=function(){b.parentNode&&b.parentNode.removeChild(b)};var f=function(){var c=a.window,d=c.width,e=c.height,f=c.devicePixelRatio;var g=a.getCellSize();b.width=d*g.width*f,b.height=e*g.height*f,b.style.width=d*g.width+'px',b.style.height=e*g.height+'px'};var g,h,i;var j=new Map;var k;a._debug={drawStart:function drawStart(a){i=a,g=Date.now()},drawEnd:function drawEnd(){h=Date.now(),console.log('Draw: '+i+' ('+(h-g)+' ms) with fancy graphics: '+a.window.graphics),k()},setCell:function setCell(a,b){j.set(a,[b,Date.now()])}};var l=!1;var m=function(){l&&requestAnimationFrame(m);var b=a.window,d=b.devicePixelRatio,f=b.width,g=b.height;var h=a.getCellSize(),i=h.width,k=h.height;var n=Date.now();c.setTransform(d,0,0,d,0,0),c.clearRect(0,0,f*i,g*k);var o=0;for(var w=0;w<f*g;w++)if(j.has(w)&&0!==j.get(w)[0]){var p=j.get(w),q=_slicedToArray(p,2),r=q[0],s=q[1];var t=(n-s)/1e3;if(!(1<t)){o++,c.globalAlpha=0.5*Math.max(0,1-t);var u=w%f;var v=Math.floor(w/f);1&r&&(c.fillStyle='#f0f'),2&r&&(c.fillStyle='#0f0'),c.fillRect(u*i,v*k,i,k),4&r&&(c.lineWidth=2,c.strokeStyle='#f00',c.strokeRect(u*i,v*k,i,k))}}0==o&&(l=!1,e())};k=function(){l||(d(),f(),l=!0,m())}};
'use strict';var _slicedToArray=function(){function a(a,b){var c=[];var d=!0;var e=!1;var f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}();window.initSoftKeyboard=function(a,b){var c=qs('#softkb-input');if(c){var d=!1;var e=function(){if(d){var b=a.gridToScreen(a.cursor.x,a.cursor.y,!0),e=_slicedToArray(b,2),f=e[0],g=e[1];c.style.transform='translate('+f+'px, '+g+'px)'}};c.addEventListener('focus',function(){d=!0,e()}),c.addEventListener('blur',function(){return d=!1}),a.on('cursor-moved',e);var f=function(a){d=a,e(),a?c.focus():c.blur()};qs('#term-kb-open').addEventListener('click',function(){return f(!0),!1});var g='';var h=!1;var i=function(a){var c=!1;a.length>g.length?a.startsWith(g)?b.sendString(a.substr(g.length)):c=!0:a.length<g.length?g.startsWith(a)?b.sendString('\b'.repeat(g.length-a.length)):c=!0:a!==g&&(c=!0),c&&b.sendString('\b'.repeat(g.length)+a),g=a};c.addEventListener('keydown',function(a){'Unidentified'===a.key||(c.value='','Backspace'===a.key?(a.preventDefault(),b.sendString('\b')):'Enter'===a.key&&(a.preventDefault(),b.sendString('\r')))}),c.addEventListener('keypress',function(a){a.stopPropagation()}),c.addEventListener('input',function(a){a.stopPropagation(),a.isComposing?i(a.data):'insertCompositionText'===a.inputType?b.sendString(a.data):'deleteContentBackward'===a.inputType?(g='',i('')):'insertText'===a.inputType&&b.sendString(a.data)}),c.addEventListener('compositionstart',function(){g='',h=!0}),c.addEventListener('compositionend',function(){g='',h=!1,c.value=''}),a.on('open-soft-keyboard',function(){return c.focus()})}};
'use strict';window.termInit=function(a){var b=a.labels,c=a.theme,d=a.allFn;var f=new TermScreen;var e=Conn(f);var g=Input(e);var h=TermUpl(e,g,f);f.input=g,e.init(),g.init({allFn:d}),h.init(),Notify.init(),window.onerror=function(a,b,c,d){return Notify.show('<b>JS ERROR!</b><br>'+a+'<br>at '+b+':'+c+':'+d,1e4,!0),!1},qs('#screen').appendChild(f.canvas),f.load(b,c),window.initSoftKeyboard(f,g),window.attachDebugScreen&&window.attachDebugScreen(f);var i=!1;var j=!1;var k=function(){i?(f.window.fitIntoWidth=window.screen.width,f.window.fitIntoHeight=window.screen.height):(f.window.fitIntoWidth=j?window.innerWidth-20:0,f.window.fitIntoHeight=j?window.innerHeight:0)};k(),window.addEventListener('resize',k);var l=function(){j=!j;var a=qs('#resize-button-icon');j?(a.classList.remove('icn-resize-small'),a.classList.add('icn-resize-full')):(a.classList.remove('icn-resize-full'),a.classList.add('icn-resize-small')),k()};if(qs('#term-fit-screen').addEventListener('click',function(){return l(),!1}),Element.prototype.requestFullscreen||Element.prototype.webkitRequestFullscreen){setInterval(function checkForFullscreen(){i&&(innerWidth!==window.screen.width||innerHeight!==window.screen.height)&&(i=!1,k())},500);var m=mk('a');m.href='#',m.addEventListener('click',function(a){a.preventDefault(),i=!0,k(),f.updateSize(),f.canvas.requestFullscreen?f.canvas.requestFullscreen():f.canvas.webkitRequestFullscreen()});var n=mk('i');n.classList.add('icn-resize-full'),m.appendChild(n);var o=mk('span');o.textContent='Fullscreen',m.appendChild(o),qs('#term-nav').insertBefore(m,qs('#term-nav').firstChild)}window.termScreen=f,window.conn=e,window.input=g,window.termUpl=h};
//# sourceMappingURL=app.d7551c3.js.map