'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":'>','"':'"',"'":''',"/":'/',"`":'`',"=":'='};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;cj;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;di||1114111=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=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=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.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=0this.cursor.x&&(this.cursor.x=0=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;cthis.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._lastLoadf;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;cb[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++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=0a;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=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'+a.rssi_perc+'').htmlAppend('
'+i+'
').htmlAppend('
'+g[a.enc]+'
'),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=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&&!(3e)){var b=j();a.send('p'+encode2B(d)+encode2B(c)+encode2B(e)+encode2B(b))}},onMouseUp:function onMouseUp(c,d,e){if(l.mt_click&&!(3e)){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;cred;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))):ja)return colorTable256[a];if(255>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=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=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>9;0>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};cw));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):' ',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=1Date.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||0g.length?a.startsWith(g)?b.sendString(a.substr(g.length)):c=!0:a.lengthJS ERROR!
'+a+'
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