function D(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}var u={exports:{}};const t=({onlyFirst:D=!1}={})=>{const u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,D?void 0:"g")};var e={exports:{}};const s=D=>!Number.isNaN(D)&&(D>=4352&&(D<=4447||9001===D||9002===D||11904<=D&&D<=12871&&12351!==D||12880<=D&&D<=19903||19968<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65131||65281<=D&&D<=65376||65504<=D&&D<=65510||110592<=D&&D<=110593||127488<=D&&D<=127569||131072<=D&&D<=262141));e.exports=s,e.exports.default=s;var i=e.exports;const r=D=>"string"==typeof D?D.replace(t(),""):D,F=i,o=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF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F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},n=D=>{if("string"!=typeof D||0===D.length)return 0;if(0===(D=r(D)).length)return 0;D=D.replace(o()," ");let u=0;for(let t=0;t=127&&e<=159||(e>=768&&e<=879||(e>65535&&t++,u+=F(e)?2:1))}return u};u.exports=n,u.exports.default=n;var C,h,a=D(u.exports),E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l={},c={};C=c,Object.defineProperty(C,"__esModule",{value:!0}),C.parseInput=C.InputType=void 0,function(D){D[D.Text=0]="Text",D[D.AltEnter=1]="AltEnter",D[D.ArrowUp=2]="ArrowUp",D[D.ArrowDown=3]="ArrowDown",D[D.ArrowLeft=4]="ArrowLeft",D[D.ArrowRight=5]="ArrowRight",D[D.Delete=6]="Delete",D[D.Backspace=7]="Backspace",D[D.CtrlA=8]="CtrlA",D[D.CtrlC=9]="CtrlC",D[D.CtrlD=10]="CtrlD",D[D.CtrlE=11]="CtrlE",D[D.CtrlK=12]="CtrlK",D[D.CtrlL=13]="CtrlL",D[D.CtrlQ=14]="CtrlQ",D[D.CtrlS=15]="CtrlS",D[D.CtrlU=16]="CtrlU",D[D.End=17]="End",D[D.Enter=18]="Enter",D[D.Home=19]="Home",D[D.ShiftEnter=20]="ShiftEnter",D[D.UnsupportedControlChar=21]="UnsupportedControlChar",D[D.UnsupportedEscape=22]="UnsupportedEscape"}(h=C.InputType||(C.InputType={})),C.parseInput=function(D){return Array.from(function*(D){let u=[];const t=D[Symbol.iterator]();for(let D=t.next();!D.done;D=t.next()){const e=D.value;if(e.length>1){u.push(e);continue}const s=e.charCodeAt(0);if(u.length>0&&(s<32||127===s)&&(yield{inputType:h.Text,data:u},u=[]),27!==s)if(s<32||127===s){let D=h.UnsupportedControlChar;switch(s){case 1:D=h.CtrlA;break;case 3:D=h.CtrlC;break;case 4:D=h.CtrlD;break;case 5:D=h.CtrlE;break;case 11:D=h.CtrlK;break;case 17:D=h.CtrlQ;break;case 19:D=h.CtrlS;break;case 21:D=h.CtrlU;break;case 13:D=h.Enter;break;case 127:D=h.Backspace;break;case 12:D=h.CtrlL}yield{inputType:D,data:[e]}}else u.push(e);else{const D=t.next();if(D.done){u.push("");continue}let e=h.UnsupportedEscape;if("["!==D.value){"\r"===D.value&&(e=h.AltEnter),yield{inputType:e,data:["",D.value]};continue}const s=t.next();if(s.done)continue;if(s.value>="0"&&s.value<="9"){let D=s.value;const u=t.next();if(u.done)return;if(u.value>="0"&&u.value<="9")D+=u.value;else if("~"!==u.value)continue;"3"===D&&(e=h.Delete),yield{inputType:e,data:["","[",D,"~"]};continue}switch(s.value){case"A":e=h.ArrowUp;break;case"B":e=h.ArrowDown;break;case"C":e=h.ArrowRight;break;case"D":e=h.ArrowLeft;break;case"F":e=h.End;break;case"H":e=h.Home;break;case"\r":e=h.AltEnter}yield{inputType:e,data:["","[",s.value]}}}u.length>0&&(yield{inputType:h.Text,data:u})}(D))};var p={},d={};Object.defineProperty(d,"__esModule",{value:!0}),d.LineBuffer=void 0,d.LineBuffer=class{constructor(){this.buf="",this.pos=0}buffer(){return this.buf}pos_buffer(){return this.buf.slice(0,this.pos)}length(){return this.buf.length}char_length(){return[...this.buf].length}update(D,u){this.buf=D,this.pos=u}insert(D){const u=D.length,t=this.pos===this.buf.length;return this.buf=t?this.buf+D:this.buf.slice(0,this.pos)+D+this.buf.slice(this.pos),this.pos+=u,t}moveBack(D){const u=this.prevPos(D);return void 0!==u&&(this.pos=u,!0)}moveForward(D){const u=this.nextPos(D);return void 0!==u&&(this.pos=u,!0)}moveHome(){const D=this.startOfLine();return this.pos>D&&(this.pos=D,!0)}moveEnd(){const D=this.endOfLine();return this.pos!==D&&(this.pos=D,!0)}startOfLine(){const D=this.buf.slice(0,this.pos).lastIndexOf("\n");return-1!==D?D+1:0}endOfLine(){const D=this.buf.slice(this.pos).indexOf("\n");return-1!==D?this.pos+D:this.buf.length}moveLineUp(D){const u=this.buf.slice(0,this.pos).lastIndexOf("\n");if(-1===u)return!1;const t=[...this.buf.slice(u+1,this.pos)].length;let e=this.buf.slice(0,u).lastIndexOf("\n");-1===e?e=0:e+=1;let s=u;for(let u=1;u0&&(r=i.map((D=>D.length)).reduce(((D,u)=>D+u),0),r=e+r),this.pos=r,!0}moveLineDown(D){const u=this.buf.slice(this.pos).indexOf("\n");if(-1===u)return!1;let t=this.buf.slice(0,this.pos).lastIndexOf("\n");-1===t?t=0:t+=1;const e=[...this.buf.slice(t,this.pos)].length;let s=this.pos+u+1,i=this.buf.slice(s).indexOf("\n");i=-1===i?this.buf.length:s+i;for(let u=1;uD.length)).reduce(((D,u)=>D+u),0)+s:this.pos=i,!0}set_pos(D){this.pos=D}prevPos(D){if(0===this.pos)return;const u=this.buf.slice(0,this.pos);return this.pos-[...u].slice(-D).map((D=>D.length)).reduce(((D,u)=>D+u),0)}nextPos(D){if(this.pos===this.buf.length)return;const u=this.buf.slice(this.pos);return this.pos+[...u].slice(0,D).map((D=>D.length)).reduce(((D,u)=>D+u),0)}backspace(D){const u=this.prevPos(D);return void 0!==u&&(this.buf=this.buf.slice(0,u)+this.buf.slice(this.pos),this.pos=u,!0)}delete(D){const u=this.nextPos(D);return void 0!==u&&(this.buf=this.buf.slice(0,this.pos)+this.buf.slice(u),!0)}deleteEndOfLine(){if(0==this.buf.length||this.pos==this.buf.length)return!1;const D=this.pos,u=this.endOfLine();return D==u?this.delete(1):this.buf=this.buf.slice(0,D)+this.buf.slice(u),!0}};var B=E&&E.__importDefault||function(D){return D&&D.__esModule?D:{default:D}};Object.defineProperty(p,"__esModule",{value:!0}),p.State=p.Layout=p.Position=void 0;const f=d,A=B(a);class y{constructor(D,u){this.row=void 0!==D?D:0,this.col=void 0!==u?u:0}}p.Position=y;class g{constructor(D){this.promptSize=D,this.cursor=new y,this.end=new y}}p.Layout=g,p.State=class{constructor(D,u,t,e){this.line=new f.LineBuffer,this.highlighting=!1,this.prompt=D,this.tty=u,this.highlighter=t,this.history=e,this.promptSize=u.calculatePosition(D,new y),this.layout=new g(this.promptSize)}buffer(){return this.line.buffer()}shouldHighlight(){return this.highlighter.highlightChar(this.line.buf,this.line.pos)?(this.highlighting=!0,!0):!!this.highlighting&&(this.highlighting=!1,!0)}clearScreen(){this.tty.clearScreen(),this.layout.cursor=new y,this.layout.end=new y,this.refresh()}editInsert(D){const u=this.line.insert(D),t=D.includes("\n");if(u&&!t){const u=(0,A.default)(D);u>0&&this.layout.cursor.col+u0)return;const D=this.history.prev();void 0!==D&&this.update(D)}nextHistory(){if(-1===this.history.cursor)return;const D=this.history.next();void 0!==D?this.update(D):this.update("")}moveCursor(){const D=this.tty.calculatePosition(this.line.pos_buffer(),this.promptSize);D!==this.layout.cursor&&(this.shouldHighlight()?this.refresh():(this.tty.moveCursor(this.layout.cursor,D),this.layout.promptSize=Object.assign({},this.promptSize),this.layout.cursor=Object.assign({},D)))}};var v={};Object.defineProperty(v,"__esModule",{value:!0}),v.History=void 0,v.History=class{constructor(D){this.entries=[],this.cursor=-1,this.maxEntries=D}saveToLocalStorage(){const D=null===window||void 0===window?void 0:window.localStorage;void 0!==D&&D.setItem("history",JSON.stringify(this.entries))}restoreFromLocalStorage(){const D=null===window||void 0===window?void 0:window.localStorage;if(void 0!==D){const u=D.getItem("history");if(null==u)return;try{const t=JSON.parse(u);Array.isArray(t)&&void 0===t.find((D=>"string"!=typeof D))?this.entries=t:(this.entries=[],D.setItem("history","[]"))}catch(u){this.entries=[],D.setItem("history","[]")}}}append(D){this.resetCursor(),this.entries.includes(D)?(this.entries.splice(this.entries.indexOf(D),1),this.entries.unshift(D)):this.entries.unshift(D),this.entries.length>this.maxEntries&&this.entries.pop(),this.saveToLocalStorage()}resetCursor(){this.cursor=-1}next(){if(-1!==this.cursor)return this.cursor-=1,this.entries[this.cursor]}prev(){if(!(this.cursor+1>=this.entries.length))return this.cursor+=1,this.entries[this.cursor]}};var w={},b=E&&E.__importDefault||function(D){return D&&D.__esModule?D:{default:D}};Object.defineProperty(w,"__esModule",{value:!0}),w.Tty=void 0;const m=b(a);w.Tty=class{constructor(D,u,t,e){this.tabWidth=t,this.col=D,this.row=u,this.out=e}write(D){return this.out.write(D)}print(D){return this.out.print(D)}println(D){return this.out.println(D)}clearScreen(){this.out.write("")}calculatePosition(D,u){const t=Object.assign({},u);let e=0;return[...D].forEach((D=>{if("\n"===D)return t.row+=1,void(t.col=0);let u=0;if("\t"===D)u=this.tabWidth-t.col%this.tabWidth;else{let t;[t,e]=function(D,u){return 1===u?"["===D?[0,2]:[0,0]:2===u?";"===D||D[0]>="0"&&D[0]<="9"?[0,u]:[0,0]:""===D?[0,1]:"\n"===D?[0,u]:[(0,m.default)(D),u]}(D,e),u=t}t.col+=u,t.col>this.col&&(t.row+=1,t.col=u)})),t.col===this.col&&(t.col=0,t.row+=1),t}computeLayout(D,u){const t=Object.assign({},D),e=u.pos,s=this.calculatePosition(u.buf.slice(0,u.pos),D);return{promptSize:t,cursor:s,end:e===u.buf.length?Object.assign({},s):this.calculatePosition(u.buf.slice(e),s)}}refreshLine(D,u,t,e,s){const i=e.cursor,r=e.end;this.clearOldRows(t),this.write(s.highlightPrompt(D)),this.write(s.highlight(u.buf,u.pos)),0===r.col&&r.row>0&&"\n"!==u.buf[u.buf.length-1]&&this.write("\n");const F=r.row-i.row;F>0&&this.write(`[${F}A`),i.col>0?this.write(`\r[${i.col}C`):this.write("\r")}clearOldRows(D){const u=D.cursor.row,t=D.end.row,e=Math.max(t-u,0);e>0&&this.write(`[${e}B`);for(let D=0;DD.row){const t=u.row-D.row;1===t?this.write(""):this.write(`[${t}B`)}else if(u.rowD.col){const t=u.col-D.col;1===t?this.write(""):this.write(`[${t}C`)}else if(u.col",this.tty(),this.highlighter,this.history),this.checkHandler=()=>!0,this.ctrlCHandler=()=>{},this.pauseHandler=D=>{},this.history.restoreFromLocalStorage()}activate(D){this.term=D,this.term.onData(this.readData.bind(this)),this.term.attachCustomKeyEventHandler(this.handleKeyEvent.bind(this))}dispose(){this.disposables.forEach((D=>D.dispose()))}appendHistory(D){this.history.append(D)}setHighlighter(D){this.highlighter=D}setCheckHandler(D){this.checkHandler=D}setCtrlCHandler(D){this.ctrlCHandler=D}setPauseHandler(D){this.pauseHandler=D}writeReady(){return!this.highWater}write(D){const u=(D="\n"===D?"\r\n":(D=D.replace(/^\n/,"\r\n")).replace(/([^\r])\n/g,"$1\r\n")).length;this.watermark+=u,this.watermark>this.highWatermark&&(this.highWater=!0),this.term&&this.term.write(D,(()=>{this.watermark=Math.max(this.watermark-u,0),this.highWater&&this.watermark{void 0!==this.term?(this.state=new x.State(D,this.tty(),this.highlighter,this.history),this.state.refresh(),this.activeRead={prompt:D,resolve:u,reject:t}):t("addon is not active")}))}handleKeyEvent(D){return"Enter"!==D.key||!D.shiftKey||("keydown"===D.type&&this.readKey({inputType:I.InputType.ShiftEnter,data:["\r"]}),!1)}readData(D){const u=(0,I.parseInput)(D);u.length>1||u[0].inputType===I.InputType.Text&&u[0].data.length>1?this.readPaste(u):this.readKey(u[0])}readPaste(D){const u=D.map((D=>D.inputType===I.InputType.Enter?{inputType:I.InputType.Text,data:["\n"]}:D));for(const D of u)D.inputType===I.InputType.Text?this.state.editInsert(D.data.join("")):this.readKey(D)}readKey(D){var u,t,e;if(void 0!==this.activeRead)switch(D.inputType){case I.InputType.Text:this.state.editInsert(D.data.join(""));break;case I.InputType.AltEnter:case I.InputType.ShiftEnter:this.state.editInsert("\n");break;case I.InputType.Enter:this.checkHandler(this.state.buffer())?(this.state.moveCursorToEnd(),null===(u=this.term)||void 0===u||u.write("\r\n"),this.history.append(this.state.buffer()),null===(t=this.activeRead)||void 0===t||t.resolve(this.state.buffer()),this.activeRead=void 0):this.state.editInsert("\n");break;case I.InputType.CtrlC:this.state.moveCursorToEnd(),null===(e=this.term)||void 0===e||e.write("^C\r\n"),this.state=new x.State(this.activeRead.prompt,this.tty(),this.highlighter,this.history),this.state.refresh();break;case I.InputType.CtrlS:this.pauseHandler(!1);break;case I.InputType.CtrlU:this.state.update("");break;case I.InputType.CtrlK:this.state.editDeleteEndOfLine();break;case I.InputType.CtrlQ:this.pauseHandler(!0);break;case I.InputType.CtrlL:this.state.clearScreen();break;case I.InputType.Home:case I.InputType.CtrlA:this.state.moveCursorHome();break;case I.InputType.End:case I.InputType.CtrlE:this.state.moveCursorEnd();break;case I.InputType.Backspace:this.state.editBackspace(1);break;case I.InputType.Delete:case I.InputType.CtrlD:this.state.editDelete(1);break;case I.InputType.ArrowLeft:this.state.moveCursorBack(1);break;case I.InputType.ArrowRight:this.state.moveCursorForward(1);break;case I.InputType.ArrowUp:this.state.moveCursorUp(1);break;case I.InputType.ArrowDown:this.state.moveCursorDown(1);case I.InputType.UnsupportedControlChar:case I.InputType.UnsupportedEscape:}else switch(D.inputType){case I.InputType.CtrlC:this.ctrlCHandler();break;case I.InputType.CtrlL:this.write("")}}};var L=l.__esModule;export{k as Readline,L as __esModule,l as default}; //# sourceMappingURL=xterm-readline-D247p8vq.js.map