var bcurses=new function(){var C,A,G,F,H,E,I,J;C=this;function B(K,L){this.w=K;this.h=L;this.p={r:0,c:0};this.data=new Array(K*L);this.flags=0;this.clear()}A=B.prototype;A.CLEAROK=1;A.clear=function(){this.p={r:0,c:0};for(var K=this.data.length-1;K>=0;K--){this.data[K]=" "}};A.clrtoeol=function(){var K=this.p.r,L=this.p.c;while(L<this.w){this.data[K*this.w+L++]=" "}};A.clrtobot=function(){var L,K=this.p.r*this.w+this.p.c;for(L=this.data.length-1;L>=K;L--){this.data[L]=" "}};A.printw=function(L){var K,M,N;for(K=0,M=this.p.r,N=this.p.c;K<L.length;K++){if(L.charAt(K)=="\n"){M+=1;N=0}else{if(L.charAt(K)=="\b"){if(N){N--}}else{this.data[M*this.w+N]=L.charAt(K);N+=1;if(N>=this.w){M+=1;N=0}}}}this.p.r=M;this.p.c=N};A.to_markup=function(){var L,K;for(L=0,K=[];L<this.data.length;L+=this.w){K.push(this.data.slice(L,L+this.w).join(""))}return K.join("\n")};F=0;H=undefined;E=undefined;I=undefined;J=undefined;function D(K){E.push(K.key().string);K.stop()}C.A_REVERSE=0;C.A_NORMAL=0;C.ERR=0;C.initscr=function(){H=document.getElementById("screen");H.spellcheck=false;E=[];I=new B(H.cols,H.rows);J=-1;disconnectAll(document,"onkeydown");connect(document,"onkeydown",D)};C.flushinp=function(){E=[]};C.clear=function(){I.clear();I.flags!=I.CLEAROK};C.clrtoeol=function(){I.clrtoeol()};C.clrtobot=function(){I.clrtobot()};C.printw=function(K){I.printw(K)};C.attrset=function(K){};C.curs_set=function(K){};C.refresh=function(){H.value=I.to_markup()};C.getch=function(M){var K=undefined;if(J>=0){K=new Date();K.setMilliseconds(K.getMilliseconds()+J)}if(F){alert("Uh-Oh")}F++;function L(){if(E.length){F--;M(E.shift())}else{if(K&&(new Date()>=K)){F--;M(C.ERR)}else{setTimeout(L,50)}}}L()};C.move=function(K,L){I.p.r=K;I.p.c=L};C.timeout=function(K){J=K};C.napms=function(K,L){if(F){alert("Uh-Oh")}F++;setTimeout(function(){F--;L()},K)};for(G in this){window[G]=this[G]}}();