blecsd 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +4 -2
  2. package/README.md +209 -66
  3. package/dist/3d/index.d.ts +2 -2
  4. package/dist/3d/index.js +1 -1
  5. package/dist/audio/index.d.ts +2 -2
  6. package/dist/{border-D_Jb4ZJV.d.ts → border-Jb7TrMob.d.ts} +20 -10
  7. package/dist/chunk-2IEMMRUO.js +1 -0
  8. package/dist/chunk-3AV52GY5.js +1 -0
  9. package/dist/chunk-3LHLSY3Y.js +1 -0
  10. package/dist/chunk-3O4TQHGK.js +4 -0
  11. package/dist/chunk-3UJWZ5ZN.js +1 -0
  12. package/dist/chunk-5N3O25O7.js +1 -0
  13. package/dist/chunk-6M2J5QUA.js +1 -0
  14. package/dist/chunk-7IQEUVGF.js +1 -0
  15. package/dist/chunk-A6M6TFBL.js +1 -0
  16. package/dist/chunk-CUEUJAHK.js +3 -0
  17. package/dist/chunk-D42Q2KKR.js +1 -0
  18. package/dist/chunk-DYEXOFUU.js +2 -0
  19. package/dist/chunk-DYU72XLL.js +1 -0
  20. package/dist/chunk-E4CJRSND.js +1 -0
  21. package/dist/chunk-EAY7B5GL.js +1 -0
  22. package/dist/chunk-FCMTWFSE.js +1 -0
  23. package/dist/chunk-FL56THSI.js +25 -0
  24. package/dist/{chunk-2UBBZFE4.js → chunk-G437VE43.js} +1 -1
  25. package/dist/chunk-GGXNWT36.js +8 -0
  26. package/dist/chunk-HLFORKXS.js +1 -0
  27. package/dist/chunk-J7MBKEBY.js +1 -0
  28. package/dist/{chunk-TYMY2TBR.js → chunk-JHCKPCUH.js} +3 -3
  29. package/dist/chunk-K3SX2LY5.js +1 -0
  30. package/dist/chunk-LDAFEXN5.js +1 -0
  31. package/dist/chunk-MKMFUXLB.js +33 -0
  32. package/dist/chunk-MQWPHPUM.js +1 -0
  33. package/dist/chunk-MTI376CU.js +5 -0
  34. package/dist/chunk-MTV2RJZD.js +1 -0
  35. package/dist/chunk-NPDPBAW6.js +4 -0
  36. package/dist/chunk-OB66FB4F.js +1 -0
  37. package/dist/chunk-OR3BZY7C.js +1 -0
  38. package/dist/{chunk-VNZ6CWJA.js → chunk-R7AICVRN.js} +2 -2
  39. package/dist/{chunk-3B7MIVW6.js → chunk-RZ7FGVI6.js} +1 -1
  40. package/dist/chunk-UMGTXSQB.js +11 -0
  41. package/dist/chunk-X3Q3T2SS.js +4 -0
  42. package/dist/{chunk-JKVHO4LH.js → chunk-XZJRWFOS.js} +1 -1
  43. package/dist/chunk-ZAHG7Y3X.js +1 -0
  44. package/dist/cli/init.d.ts +1 -1
  45. package/dist/componentStorage-CJTh-TPO.d.ts +246 -0
  46. package/dist/components/index.d.ts +1942 -514
  47. package/dist/components/index.js +1 -1
  48. package/dist/core/index.d.ts +857 -259
  49. package/dist/core/index.js +1 -1
  50. package/dist/debug/index.d.ts +491 -98
  51. package/dist/debug/index.js +1 -1
  52. package/dist/dirtyTracking-C4v8MmM9.d.ts +235 -0
  53. package/dist/errors/index.d.ts +12 -12
  54. package/dist/errors/index.js +1 -1
  55. package/dist/{events-BbbxkgvX.d.ts → events-9ForpTfM.d.ts} +75 -2
  56. package/dist/game/index.d.ts +7 -7
  57. package/dist/game/index.js +1 -1
  58. package/dist/{gameLoop-BIPW7-OY.d.ts → gameLoop-C-Ez_i54.d.ts} +2 -2
  59. package/dist/{index-zSGJ2eUk.d.ts → index-DBS5Uefn.d.ts} +2 -2
  60. package/dist/index.d.ts +283 -20
  61. package/dist/index.js +3 -1
  62. package/dist/input/index.d.ts +1 -1
  63. package/dist/input/index.js +1 -1
  64. package/dist/{inputActions-CefRUBuT.d.ts → inputActions-CRsUtTHM.d.ts} +10 -721
  65. package/dist/packedStore-BgvnEdE7.d.ts +191 -0
  66. package/dist/{renderable-jTMOA-GK.d.ts → renderable-CwqGwrEV.d.ts} +9 -9
  67. package/dist/{scheduler-DcfoFuum.d.ts → scheduler-CMcYew9Z.d.ts} +65 -3
  68. package/dist/systems/index.d.ts +356 -55
  69. package/dist/systems/index.js +1 -1
  70. package/dist/terminal/index.d.ts +2233 -2299
  71. package/dist/terminal/index.js +1 -1
  72. package/dist/{tilemap-D1HJvKy3.d.ts → tilemap-BirMJdbu.d.ts} +92 -3
  73. package/dist/{types-BcsvoKzf.d.ts → types-CPB4CpbH.d.ts} +2 -2
  74. package/dist/utils/index.d.ts +27 -180
  75. package/dist/utils/index.js +1 -1
  76. package/dist/{virtualScrollback-DvZTRU8a.d.ts → virtualScrollback-D9uLFe8l.d.ts} +4 -4
  77. package/dist/{virtualViewport-Dx2iJliO.d.ts → virtualViewport-Bpv6jlKt.d.ts} +283 -761
  78. package/dist/widgets/bigText.d.ts +1 -1
  79. package/dist/widgets/bigText.js +1 -1
  80. package/dist/widgets/index.d.ts +10519 -5463
  81. package/dist/widgets/index.js +1 -1
  82. package/package.json +102 -6
  83. package/dist/chunk-35I22JJO.js +0 -1
  84. package/dist/chunk-3EGGGI5J.js +0 -3
  85. package/dist/chunk-4X4N4HNQ.js +0 -2
  86. package/dist/chunk-AQ7LW75B.js +0 -1
  87. package/dist/chunk-AXZQAH4X.js +0 -1
  88. package/dist/chunk-BCADUCOZ.js +0 -1
  89. package/dist/chunk-EJ5WVDDZ.js +0 -6
  90. package/dist/chunk-FT7BMYSN.js +0 -1
  91. package/dist/chunk-FYEBZAWN.js +0 -1
  92. package/dist/chunk-GYHI26UE.js +0 -1
  93. package/dist/chunk-H2YAOJDW.js +0 -1
  94. package/dist/chunk-K2B2OXQ5.js +0 -5
  95. package/dist/chunk-K37L3G4Z.js +0 -4
  96. package/dist/chunk-KD55INV7.js +0 -1
  97. package/dist/chunk-KFAK4A3G.js +0 -1
  98. package/dist/chunk-LCN2ZITE.js +0 -1
  99. package/dist/chunk-OUXUPF3V.js +0 -33
  100. package/dist/chunk-P6CJO3BC.js +0 -1
  101. package/dist/chunk-PI5UOHOH.js +0 -1
  102. package/dist/chunk-PSXXMBVJ.js +0 -1
  103. package/dist/chunk-TRK4422V.js +0 -12
  104. package/dist/chunk-W5OU7Z6J.js +0 -1
  105. package/dist/chunk-WNG4A3K7.js +0 -4
  106. package/dist/chunk-XRJNAHNG.js +0 -19
  107. package/dist/chunk-XZA63ZPO.js +0 -1
  108. package/dist/chunk-YAMOSPWB.js +0 -4
  109. package/dist/chunk-YD6ULIUR.js +0 -1
  110. package/dist/{keyParser-Bwm8-l7v.d.ts → keyParser-BnHbg2iD.d.ts} +1 -1
@@ -1,12 +0,0 @@
1
- import {c as c$1,d,z as z$2,y,Z}from'./chunk-FT7BMYSN.js';import {g}from'./chunk-4LWWONFK.js';import {e,c,b as b$1,a}from'./chunk-C5PCEQ6G.js';import {t}from'./chunk-XQIGERNI.js';import {a as a$2}from'./chunk-AQ7LW75B.js';import {g as g$1}from'./chunk-XZA63ZPO.js';import {f,r,s}from'./chunk-BCADUCOZ.js';import {a as a$1}from'./chunk-5PELJRUQ.js';import {z as z$1}from'zod';import {writeFileSync,appendFileSync,existsSync,mkdirSync,unlinkSync,readFileSync,statSync,renameSync}from'fs';import {dirname,join}from'path';import {inspect}from'util';import {spawn,spawnSync}from'child_process';import {tmpdir}from'os';import {EventEmitter}from'events';var Jn="\x1B[",Qn="\x1B]",eo="\x1BP",to="\x1B\\",ro="\x07",no="\x1B",b={RESET:0,BOLD:1,DIM:2,ITALIC:3,UNDERLINE:4,BLINK:5,RAPID_BLINK:6,INVERSE:7,HIDDEN:8,STRIKETHROUGH:9,RESET_BOLD:22,RESET_DIM:22,RESET_ITALIC:23,RESET_UNDERLINE:24,RESET_BLINK:25,RESET_INVERSE:27,RESET_HIDDEN:28,RESET_STRIKETHROUGH:29,FG_BLACK:30,FG_RED:31,FG_GREEN:32,FG_YELLOW:33,FG_BLUE:34,FG_MAGENTA:35,FG_CYAN:36,FG_WHITE:37,FG_DEFAULT:39,FG_BRIGHT_BLACK:90,FG_BRIGHT_RED:91,FG_BRIGHT_GREEN:92,FG_BRIGHT_YELLOW:93,FG_BRIGHT_BLUE:94,FG_BRIGHT_MAGENTA:95,FG_BRIGHT_CYAN:96,FG_BRIGHT_WHITE:97,BG_BLACK:40,BG_RED:41,BG_GREEN:42,BG_YELLOW:43,BG_BLUE:44,BG_MAGENTA:45,BG_CYAN:46,BG_WHITE:47,BG_DEFAULT:49,BG_BRIGHT_BLACK:100,BG_BRIGHT_RED:101,BG_BRIGHT_GREEN:102,BG_BRIGHT_YELLOW:103,BG_BRIGHT_BLUE:104,BG_BRIGHT_MAGENTA:105,BG_BRIGHT_CYAN:106,BG_BRIGHT_WHITE:107,FG_256:38,BG_256:48},oo={black:b.FG_BLACK,red:b.FG_RED,green:b.FG_GREEN,yellow:b.FG_YELLOW,blue:b.FG_BLUE,magenta:b.FG_MAGENTA,cyan:b.FG_CYAN,white:b.FG_WHITE,brightBlack:b.FG_BRIGHT_BLACK,brightRed:b.FG_BRIGHT_RED,brightGreen:b.FG_BRIGHT_GREEN,brightYellow:b.FG_BRIGHT_YELLOW,brightBlue:b.FG_BRIGHT_BLUE,brightMagenta:b.FG_BRIGHT_MAGENTA,brightCyan:b.FG_BRIGHT_CYAN,brightWhite:b.FG_BRIGHT_WHITE,default:b.FG_DEFAULT},so={black:b.BG_BLACK,red:b.BG_RED,green:b.BG_GREEN,yellow:b.BG_YELLOW,blue:b.BG_BLUE,magenta:b.BG_MAGENTA,cyan:b.BG_CYAN,white:b.BG_WHITE,brightBlack:b.BG_BRIGHT_BLACK,brightRed:b.BG_BRIGHT_RED,brightGreen:b.BG_BRIGHT_GREEN,brightYellow:b.BG_BRIGHT_YELLOW,brightBlue:b.BG_BRIGHT_BLUE,brightMagenta:b.BG_BRIGHT_MAGENTA,brightCyan:b.BG_BRIGHT_CYAN,brightWhite:b.BG_BRIGHT_WHITE,default:b.BG_DEFAULT};function tr(e){return typeof e=="object"&&"r"in e&&"g"in e&&"b"in e}function rr(e){return typeof e=="string"}function M(...e){return `\x1B[${e.join(";")}m`}var E={move(e,t){return `\x1B[${t};${e}H`},column(e){return `\x1B[${e}G`},up(e=1){return `\x1B[${e}A`},down(e=1){return `\x1B[${e}B`},forward(e=1){return `\x1B[${e}C`},back(e=1){return `\x1B[${e}D`},nextLine(e=1){return `\x1B[${e}E`},prevLine(e=1){return `\x1B[${e}F`},save(){return "\x1B[s"},restore(){return "\x1B[u"},show(){return "\x1B[?25h"},hide(){return "\x1B[?25l"},requestPosition(){return "\x1B[6n"},home(){return "\x1B[H"},setShape(e){return `\x1B[${e} q`},blinkingBlock(){return "\x1B[1 q"},steadyBlock(){return "\x1B[2 q"},blinkingUnderline(){return "\x1B[3 q"},steadyUnderline(){return "\x1B[4 q"},blinkingBar(){return "\x1B[5 q"},steadyBar(){return "\x1B[6 q"},resetShape(){return "\x1B[0 q"},setColor(e){return `\x1B]12;${e}\x07`},resetColor(){return "\x1B]112\x07"},saveStyle(){return "\x1B[s"},restoreStyle(){return "\x1B[u"}},io={DEFAULT:0,BLINKING_BLOCK:1,STEADY_BLOCK:2,BLINKING_UNDERLINE:3,STEADY_UNDERLINE:4,BLINKING_BAR:5,STEADY_BAR:6},G={reset(){return M(b.RESET)},bold(){return M(b.BOLD)},dim(){return M(b.DIM)},italic(){return M(b.ITALIC)},underline(){return M(b.UNDERLINE)},blink(){return M(b.BLINK)},inverse(){return M(b.INVERSE)},hidden(){return M(b.HIDDEN)},strikethrough(){return M(b.STRIKETHROUGH)},fg(e){return rr(e)?M(oo[e]):tr(e)?M(b.FG_256,2,e.r,e.g,e.b):M(b.FG_256,5,e)},bg(e){return rr(e)?M(so[e]):tr(e)?M(b.BG_256,2,e.r,e.g,e.b):M(b.BG_256,5,e)},combine(...e){return M(...e)}},A={clear(){return "\x1B[2J"},clearDown(){return "\x1B[J"},clearUp(){return "\x1B[1J"},clearLine(){return "\x1B[2K"},clearLineRight(){return "\x1B[K"},clearLineLeft(){return "\x1B[1K"},eraseChars(e=1){return `\x1B[${e}X`},alternateOn(){return "\x1B[?1049h"},enterAlt(){return "\x1B[?1049h"},alternateOff(){return "\x1B[?1049l"},exitAlt(){return "\x1B[?1049l"},scrollUp(e=1){return `\x1B[${e}S`},scrollDown(e=1){return `\x1B[${e}T`},setScrollRegion(e,t){return `\x1B[${e};${t}r`},resetScrollRegion(){return "\x1B[r"}},ao={set(e){return `\x1B]2;${e}\x07`},setIcon(e){return `\x1B]1;${e}\x07`},setBoth(e){return `\x1B]0;${e}\x07`}},R={X10:9,NORMAL:1e3,HIGHLIGHT:1001,BUTTON_EVENT:1002,ANY_EVENT:1003,FOCUS:1004,UTF8:1005,SGR:1006,URXVT:1015,SGR_PIXELS:1016},P={enableX10(){return `\x1B[?${R.X10}h`},disableX10(){return `\x1B[?${R.X10}l`},enableNormal(){return `\x1B[?${R.NORMAL}h`},disableNormal(){return `\x1B[?${R.NORMAL}l`},enableButtonEvent(){return `\x1B[?${R.BUTTON_EVENT}h`},disableButtonEvent(){return `\x1B[?${R.BUTTON_EVENT}l`},enableAnyEvent(){return `\x1B[?${R.ANY_EVENT}h`},disableAnyEvent(){return `\x1B[?${R.ANY_EVENT}l`},enableFocus(){return `\x1B[?${R.FOCUS}h`},disableFocus(){return `\x1B[?${R.FOCUS}l`},enableSGR(){return `\x1B[?${R.SGR}h`},disableSGR(){return `\x1B[?${R.SGR}l`},enableURXVT(){return `\x1B[?${R.URXVT}h`},disableURXVT(){return `\x1B[?${R.URXVT}l`},enableUTF8(){return `\x1B[?${R.UTF8}h`},disableUTF8(){return `\x1B[?${R.UTF8}l`},disableAll(){return [`\x1B[?${R.X10}l`,`\x1B[?${R.NORMAL}l`,`\x1B[?${R.BUTTON_EVENT}l`,`\x1B[?${R.ANY_EVENT}l`,`\x1B[?${R.FOCUS}l`,`\x1B[?${R.UTF8}l`,`\x1B[?${R.SGR}l`,`\x1B[?${R.URXVT}l`].join("")},enableRecommended(){return `\x1B[?${R.SGR}h\x1B[?${R.ANY_EVENT}h`}},K={begin(){return "\x1B[?2026h"},end(){return "\x1B[?2026l"},wrap(e){return `\x1B[?2026h${e}\x1B[?2026l`}},ke={enable(){return "\x1B[?2004h"},disable(){return "\x1B[?2004l"},START_MARKER:"\x1B[200~",END_MARKER:"\x1B[201~"},Q={CLIPBOARD:"c",PRIMARY:"p",SECONDARY:"s",SELECT:"s",CUT0:"0",CUT1:"1",CUT2:"2",CUT3:"3",CUT4:"4",CUT5:"5",CUT6:"6",CUT7:"7"},nr=1024*1024,ie={write(e,t=Q.CLIPBOARD,r=nr){if(Buffer.byteLength(e,"utf8")>r)return "";let o=Buffer.from(e,"utf8").toString("base64");return `\x1B]52;${t};${o}\x1B\\`},requestRead(e=Q.CLIPBOARD){return `\x1B]52;${e};?\x1B\\`},clear(e=Q.CLIPBOARD){return `\x1B]52;${e};\x1B\\`},decodeResponse(e){let t=e.match(/\x1b\]52;([^;]+);([A-Za-z0-9+/=]*)\x1b\\/);if(!t)return null;let r=t[2];if(!r)return "";try{return Buffer.from(r,"base64").toString("utf8")}catch{return null}},isClipboardResponse(e){return e.startsWith("\x1B]52;")}},uo={PT_START:"\x1BPtmux;",wrap(e){return `\x1BPtmux;${e.replace(/\x1b/g,"\x1B\x1B")}\x1B\\`},unwrap(e){let t=e.match(/^\x1bPtmux;([\s\S]*)\x1b\\$/);return t?(t[1]??"").replace(/\x1b\x1b/g,"\x1B"):null},isWrapped(e){return e.startsWith("\x1BPtmux;")&&e.endsWith("\x1B\\")},wrapIf(e,t){return !t||this.isWrapped(e)?e:this.wrap(e)},begin(){return "\x1BPtmux;"},end(){return "\x1B\\"}},lo={"dec-graphics":"0","us-ascii":"B",uk:"A",dutch:"4",finnish:"C",french:"R","french-canadian":"Q",german:"K",italian:"Y","norwegian-danish":"E",spanish:"Z",swedish:"H",swiss:"=","iso-latin":"/A"},co={0:"(",1:")",2:"*",3:"+"},po={j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",q:"\u2500",x:"\u2502",n:"\u253C",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",o:"\u23BA",p:"\u23BB",r:"\u23BC",s:"\u23BD","`":"\u25C6",a:"\u2592",f:"\xB0",g:"\xB1",h:"\u2424",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7",b:" ",c:"\f",d:"\r",e:`
2
- `,i:"\v"},fo={"\u25C6":"*","\u2592":" ","\xB0":"*","\xB1":"+","\u2424":`
3
- `,"\u2518":"+","\u2510":"+","\u250C":"+","\u2514":"+","\u253C":"+","\u23BA":"-","\u23BB":"-","\u2500":"-","\u23BC":"-","\u23BD":"_","\u251C":"+","\u2524":"+","\u2534":"+","\u252C":"+","\u2502":"|","\u2264":"<","\u2265":">",\u03C0:"*","\u2260":"!","\xA3":"#","\xB7":"."},mo={designate(e,t=0){let r=lo[e];return `\x1B${co[t]}${r}`},invokeG0(){return ""},invokeG1(){return ""},invokeG2(){return "\x1Bn"},invokeG3(){return "\x1Bo"},invokeG1R(){return "\x1B~"},invokeG2R(){return "\x1B}"},invokeG3R(){return "\x1B|"},singleShiftG2(){return "\x1BN"},singleShiftG3(){return "\x1BO"},enterAcs(){return "\x1B(0"},exitAcs(){return "\x1B(B"},smacs(){return this.enterAcs()},rmacs(){return this.exitAcs()}},go={unicode:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",teeRight:"\u251C",teeLeft:"\u2524",teeUp:"\u2534",teeDown:"\u252C"},unicodeDouble:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",teeRight:"\u2560",teeLeft:"\u2563",teeUp:"\u2569",teeDown:"\u2566"},unicodeRounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",teeRight:"\u251C",teeLeft:"\u2524",teeUp:"\u2534",teeDown:"\u252C"},ascii:{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|",cross:"+",teeRight:"+",teeLeft:"+",teeUp:"+",teeDown:"+"},decGraphics:{topLeft:"l",topRight:"k",bottomLeft:"m",bottomRight:"j",horizontal:"q",vertical:"x",cross:"n",teeRight:"t",teeLeft:"u",teeUp:"v",teeDown:"w"}},bo={deiconify(){return "\x1B[1t"},iconify(){return "\x1B[2t"},move(e,t){return `\x1B[3;${e};${t}t`},resizePixels(e,t){return `\x1B[4;${t};${e}t`},raise(){return "\x1B[5t"},lower(){return "\x1B[6t"},refresh(){return "\x1B[7t"},resizeChars(e,t){return `\x1B[8;${t};${e}t`},restoreMaximized(){return "\x1B[9;0t"},maximize(){return "\x1B[9;1t"},maximizeVertical(){return "\x1B[9;2t"},maximizeHorizontal(){return "\x1B[9;3t"},exitFullScreen(){return "\x1B[10;0t"},enterFullScreen(){return "\x1B[10;1t"},toggleFullScreen(){return "\x1B[10;2t"},pushTitle(e="both"){return `\x1B[22;${e==="both"?0:e==="icon"?1:2}t`},popTitle(e="both"){return `\x1B[23;${e==="both"?0:e==="icon"?1:2}t`},setLines(e){return `\x1B[${Math.max(24,Math.floor(e))}t`}},or=["http:","https:","mailto:","file:","tel:"];function sr(e){try{let t=new URL(e);return or.includes(t.protocol)}catch{return false}}var yo={link(e,t,r){return `${this.start(e,r)}${t}${this.end()}`},start(e,t){return `\x1B]8;${t?.id?`id=${t.id}`:""};${e}\x1B\\`},end(){return "\x1B]8;;\x1B\\"},safeLink(e,t,r){return sr(e)?this.link(e,t,r):t},mailto(e,t,r){return this.link(`mailto:${e}`,t??e,r)},file(e,t,r){return this.link(`file://${e}`,t??e,r)}},xo={PRINT_SCREEN:0,PRINTER_OFF:4,PRINTER_ON:5,PRINT_LINE:1,PRINT_DISPLAY:10,PRINT_ALL_PAGES:11},Co={mc(e){return `\x1B[${e}i`},printScreen(){return "\x1B[0i"},printLine(){return "\x1B[1i"},printerOn(){return "\x1B[5i"},printerOff(){return "\x1B[4i"},printerForBytes(e){return `\x1B[5;${e}i`},printDisplay(){return "\x1B[10i"},printAllPages(){return "\x1B[11i"},autoPrintOn(){return "\x1B[?5i"},autoPrintOff(){return "\x1B[?4i"},printCursorPosition(){return "\x1B[?1i"}},So={setAttrs(e,t,r,n,o){let s=o.length>0?`;${o.join(";")}`:"";return `\x1B[${e};${t};${r};${n}${s}$r`},reverseAttrs(e,t,r,n,o){let s=o.length>0?`;${o.join(";")}`:"";return `\x1B[${e};${t};${r};${n}${s}$t`},copy(e,t,r,n,o,s,i=1,u=1){return `\x1B[${e};${t};${r};${n};${i};${o};${s};${u}$v`},fill(e,t,r,n,o){return `\x1B[${typeof o=="string"?o.charCodeAt(0):o};${e};${t};${r};${n}$x`},erase(e,t,r,n){return `\x1B[${e};${t};${r};${n}$z`},selectiveErase(e,t,r,n){return `\x1B[${e};${t};${r};${n}\${`},setProtection(e){return `\x1B[${e?1:0}"q`},requestChecksum(e,t,r,n,o,s){return `\x1B[${e};${t};${r};${n};${o};${s}*y`}},ho={NONE:0,BUTTON_DOWN:1,BUTTON_UP:2,BUTTON_DOWN_UP:3},Ro={NONE:0,RIGHT:1,MIDDLE:2,LEFT:3,M4:4},Eo={enable(e=2,t=2){return `\x1B[${e};${t}'z`},disable(){return "\x1B[0'z"},setFilterRectangle(e,t,r,n){return `\x1B[${e};${t};${r};${n}'w`},clearFilterRectangle(){return "\x1B['w"},setEvents(e){return `\x1B[${e.join(";")}'{`},requestPosition(e){return e===void 0?"\x1B['|":`\x1B[${e}'|`},enableKeyMode(){return "\x1B[?99h"},disableKeyMode(){return "\x1B[?99l"},enableExtended(){return "\x1B[?1003h"},disableExtended(){return "\x1B[?1003l"},enableHighlight(){return "\x1B[?1001h"},disableHighlight(){return "\x1B[?1001l"}};var To=z$1.object({type:z$1.literal("paste"),text:z$1.string(),timestamp:z$1.number(),sanitized:z$1.boolean(),originalLength:z$1.number().int().nonnegative()}),vo=z$1.object({sanitize:z$1.boolean().default(true),maxLength:z$1.number().int().nonnegative().default(1024*1024),enabled:z$1.boolean().default(true)}),ir={sanitize:true,maxLength:1024*1024,enabled:true},z="\x1B[200~",ee="\x1B[201~";function Be(e){return e.replace(/\x1b(?:\[[0-9;?]*[a-zA-Z~]|\][^\x07\x1b]*(?:\x07|\x1b\\)?|[^[\]])/g,"")}function Ne(e,t){return t<=0||e.length<=t?e:e.slice(0,t)}function ar(e){return e.length<z.length?false:new TextDecoder().decode(e.subarray(0,z.length))===z}function _o(e){if(e.length===0)return false;if(e.length>=z.length)return ar(e);let t=new TextDecoder().decode(e);return z.startsWith(t)}function Io(e){return new TextDecoder().decode(e).indexOf(ee)}function Ao(e,t){let r={...ir,...t},n=new TextDecoder().decode(e);if(!n.startsWith(z))return {pasteStarted:false,pasteEnded:false,text:null,consumed:0};let o=n.indexOf(ee);if(o===-1)return {pasteStarted:true,pasteEnded:false,text:null,consumed:0};let s=z.length,i=n.slice(s,o);r.sanitize&&(i=Be(i)),i=Ne(i,r.maxLength);let u=o+ee.length;return {pasteStarted:true,pasteEnded:true,text:i,consumed:u}}function wo(e){return {isPasting:false,buffer:"",config:{...ir,...e}}}function Mo(e,t){let r=new TextDecoder().decode(t);if(!e.isPasting){if(!r.startsWith(z))return {state:e,event:null,consumed:0,remaining:t};let a=z.length,d=r.indexOf(ee,a);if(d===-1){let y=r.slice(a);return {state:{...e,isPasting:true,buffer:y},event:null,consumed:t.length,remaining:new Uint8Array(0)}}let c=r.slice(a,d),l=c.length;e.config.sanitize&&(c=Be(c)),c=Ne(c,e.config.maxLength);let f=d+ee.length,S=new TextEncoder().encode(r.slice(f));return {state:{...e,isPasting:false,buffer:""},event:{type:"paste",text:c,timestamp:Date.now(),sanitized:e.config.sanitize,originalLength:l},consumed:f,remaining:S}}let n=r.indexOf(ee);if(n===-1)return {state:{...e,buffer:e.buffer+r},event:null,consumed:t.length,remaining:new Uint8Array(0)};let o=e.buffer+r.slice(0,n),s=o.length;e.config.sanitize&&(o=Be(o)),o=Ne(o,e.config.maxLength);let i=n+ee.length,u=new TextEncoder().encode(r.slice(i));return {state:{...e,isPasting:false,buffer:""},event:{type:"paste",text:o,timestamp:Date.now(),sanitized:e.config.sanitize,originalLength:s},consumed:i,remaining:u}}function Oo(){return ke.enable()}function Po(){return ke.disable()}var h={PRIMARY_DA:"primary_da",SECONDARY_DA:"secondary_da",TERTIARY_DA:"tertiary_da",CURSOR_POSITION:"cursor_position",DEVICE_STATUS:"device_status",OPERATING_STATUS:"operating_status",WINDOW_TITLE:"window_title",ICON_LABEL:"icon_label",WINDOW_STATE:"window_state",WINDOW_POSITION:"window_position",WINDOW_SIZE_PIXELS:"window_size_pixels",TEXT_AREA_SIZE:"text_area_size",SCREEN_SIZE:"screen_size",CHAR_CELL_SIZE:"char_cell_size",LOCATOR_POSITION:"locator_position",UNKNOWN:"unknown"},ko=z$1.object({type:z$1.literal(h.CURSOR_POSITION),raw:z$1.string(),row:z$1.number().int().positive(),column:z$1.number().int().positive()}),k="\x1B[",Bo=/^\x1b\[\?([0-9;]+)c$/,No=/^\x1b\[>([0-9;]+)c$/,Lo=/^\x1b\[(\d+);(\d+)R$/,Do=/^\x1b\[(\d+)n$/,$o=/^\x1b\[(\d+)(?:;(\d+))?(?:;(\d+))?t$/,Uo=/^\x1b\](\d+);([^\x07\x1b]*)(?:\x07|\x1b\\)$/,Go=/^\x1b\[(\d+);(\d+);(\d+);(\d+);(\d+)&w$/;function ut(e){let t=[Ko,Fo,zo,Wo,Ho,Vo,Yo];for(let r of t){let n=r(e);if(n)return n}return {type:h.UNKNOWN,raw:e}}function Ko(e){let t=e.match(Bo);if(!t?.[1])return null;let r=t[1].split(";").map(Number),n=r[0]??0,o=r.slice(1);return {type:h.PRIMARY_DA,raw:e,deviceClass:n,attributes:o}}function Fo(e){let t=e.match(No);if(!t?.[1])return null;let r=t[1].split(";").map(Number);return {type:h.SECONDARY_DA,raw:e,terminalType:r[0]??0,firmwareVersion:r[1]??0,romCartridge:r[2]??0}}function zo(e){let t=e.match(Lo);return !t?.[1]||!t[2]?null:{type:h.CURSOR_POSITION,raw:e,row:Number.parseInt(t[1],10),column:Number.parseInt(t[2],10)}}function Wo(e){let t=e.match(Do);if(!t?.[1])return null;let r=Number.parseInt(t[1],10);return {type:h.DEVICE_STATUS,raw:e,status:r,ok:r===0}}function Ho(e){let t=e.match($o);if(!t?.[1])return null;let r=Number.parseInt(t[1],10),n=t[2]?Number.parseInt(t[2],10):0,o=t[3]?Number.parseInt(t[3],10):0;switch(r){case 1:case 2:return {type:h.WINDOW_STATE,raw:e,state:r,iconified:r===2};case 3:return {type:h.WINDOW_POSITION,raw:e,x:n,y:o};case 4:return {type:h.WINDOW_SIZE_PIXELS,raw:e,height:n,width:o};case 8:return {type:h.TEXT_AREA_SIZE,raw:e,rows:n,columns:o};case 9:return {type:h.SCREEN_SIZE,raw:e,rows:n,columns:o};case 6:return {type:h.CHAR_CELL_SIZE,raw:e,height:n,width:o};default:return null}}function Vo(e){let t=e.match(Uo);if(!t?.[1])return null;let r=Number.parseInt(t[1],10),n=t[2]??"";return r===76||e.startsWith("\x1B]L;")?{type:h.WINDOW_TITLE,raw:e,title:n}:r===108||e.startsWith("\x1B]l;")?{type:h.ICON_LABEL,raw:e,label:n}:null}function Yo(e){let t=e.match(Go);return !t?.[1]||!t[2]||!t[3]||!t[4]||!t[5]?null:{type:h.LOCATOR_POSITION,raw:e,status:Number.parseInt(t[1],10),button:Number.parseInt(t[2],10),row:Number.parseInt(t[3],10),column:Number.parseInt(t[4],10),page:Number.parseInt(t[5],10)}}function lt(e){return e.type===h.PRIMARY_DA}function ct(e){return e.type===h.SECONDARY_DA}function qo(e){return e.type===h.CURSOR_POSITION}function Xo(e){return e.type===h.DEVICE_STATUS}function jo(e){return e.type===h.WINDOW_TITLE}function Zo(e){return e.type===h.ICON_LABEL}function Jo(e){return e.type===h.WINDOW_STATE}function Qo(e){return e.type===h.WINDOW_POSITION}function es(e){return e.type===h.WINDOW_SIZE_PIXELS}function ts(e){return e.type===h.TEXT_AREA_SIZE}function rs(e){return e.type===h.SCREEN_SIZE}function ns(e){return e.type===h.CHAR_CELL_SIZE}function os(e){return e.type===h.LOCATOR_POSITION}function ss(e){return e.type===h.UNKNOWN}var ae={primaryDA(){return `${k}c`},secondaryDA(){return `${k}>c`},tertiaryDA(){return `${k}=c`},cursorPosition(){return `${k}6n`},deviceStatus(){return `${k}5n`},windowState(){return `${k}11t`},windowPosition(){return `${k}13t`},windowSizePixels(){return `${k}14t`},textAreaSize(){return `${k}18t`},screenSize(){return `${k}19t`},charCellSize(){return `${k}16t`},windowTitle(){return `${k}21t`},iconLabel(){return `${k}20t`},enableLocator(e=1){return `${k}${e}'z`},locatorPosition(){return `${k}'|`}};var pt=100,Ee=10,Te=5e3,lr="\x1B[",he={DISABLED:0,DISAMBIGUATE:1,REPORT_EVENTS:2,REPORT_ALTERNATES:4,REPORT_ALL:8,REPORT_TEXT:16},le={NONE:"none",KITTY:"kitty",ITERM2:"iterm2",SIXEL:"sixel"},Re={EAGER:"eager",LAZY:"lazy",SKIP:"skip"},cr=z$1.object({timeout:z$1.number().int().min(Ee).max(Te).optional(),timing:z$1.enum(["eager","lazy","skip"]).optional(),forceCapabilities:z$1.record(z$1.string(),z$1.unknown()).optional()});function ur(){let e=process.env.COLORTERM;if(e==="truecolor"||e==="24bit")return true;let t=process.env.TERM??"";if(t.includes("truecolor")||t.includes("24bit")||t.includes("direct"))return true;let r=process.env.TERM_PROGRAM??"";if(["iTerm.app","Apple_Terminal","Hyper","vscode"].includes(r)||process.env.KITTY_WINDOW_ID!==void 0||t==="alacritty"||process.env.WT_SESSION!==void 0)return true;let o=process.env.VTE_VERSION;if(o!==void 0){let s=Number.parseInt(o,10);if(!Number.isNaN(s)&&s>=3600)return true}return false}function is(){return process.env.KITTY_WINDOW_ID!==void 0||process.env.TERM_PROGRAM==="WezTerm"||process.env.TERM==="foot"||process.env.TERM==="foot-extra"?he.REPORT_ALL:false}function as(){return process.env.KITTY_WINDOW_ID!==void 0?le.KITTY:process.env.TERM_PROGRAM==="iTerm.app"?le.ITERM2:(process.env.TERM??"").includes("sixel")?le.SIXEL:false}function us(){let e=process.env.TERM_PROGRAM??"";return !!(["iTerm.app","WezTerm","vscode","Hyper"].includes(e)||process.env.KITTY_WINDOW_ID!==void 0||process.env.WT_SESSION!==void 0)}function ls(){let e=process.env.TERM_PROGRAM??"";if(["iTerm.app","WezTerm","vscode","Hyper"].includes(e)||process.env.KITTY_WINDOW_ID!==void 0||process.env.WT_SESSION!==void 0)return true;let r=process.env.VTE_VERSION;if(r!==void 0){let n=Number.parseInt(r,10);if(!Number.isNaN(n)&&n>=5e3)return true}return false}function cs(){return {truecolor:ur(),kittyKeyboard:is(),graphics:as(),focusEvents:true,bracketedPaste:true,synchronizedOutput:us(),hyperlinks:ls(),styledUnderlines:ur(),primaryDA:null,secondaryDA:null,terminalType:null,firmwareVersion:null}}function ps(){return `${lr}>q`}function ds(){return `${lr}?u`}function fs(e){return e.attributes.includes(4)}function ms(e){return {terminalType:e.terminalType,firmwareVersion:e.firmwareVersion}}async function gs(e,t,r,n){return new Promise(o=>{let s={buffer:"",timeout:setTimeout(()=>{u(),o(s.responses);},t),responses:[]},i=a=>{s.buffer+=a.toString(),bs(s);},u=()=>{clearTimeout(s.timeout),r.removeListener("data",i);};r.on("data",i);for(let a of e)n.write(a);})}function bs(e){let t=e.buffer,r=/\x1b\[[^a-zA-Z]*[a-zA-Z]/g,n;for(n=r.exec(t);n!==null;)e.responses.push(n[0]),n=r.exec(t);let o=/\x1bP[^\x1b]*\x1b\\/g;for(n=o.exec(t);n!==null;)e.responses.push(n[0]),n=o.exec(t);let s=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;for(n=s.exec(t);n!==null;)e.responses.push(n[0]),n=s.exec(t);}function dt(e={}){let t=Math.max(Ee,Math.min(Te,e.timeout??pt)),r=e.timing??Re.EAGER,n=e.input??process.stdin,o=e.output??process.stdout,s=e.forceCapabilities,i=null,u=null,a=false;async function d(){let x=cs();if(s)return {...x,...s};if(r===Re.SKIP||!c())return x;let C=[ae.primaryDA(),ae.secondaryDA()],g=await l(C,t,n,o);return g?f(x,g):x}function c(){return !!(process.stdin.isTTY&&process.stdout.isTTY)}async function l(x,C,g,p){let m=g.isRaw;try{return !m&&g.setRawMode&&g.setRawMode(!0),await gs(x,C,g,p)}catch{return null}finally{!m&&g.setRawMode&&g.setRawMode(false);}}function f(x,C){let{primaryDA:g,secondaryDA:p}=S(C),{terminalType:m,firmwareVersion:I}=p?ms(p):{terminalType:null,firmwareVersion:null},$=g&&fs(g)&&!x.graphics?le.SIXEL:x.graphics;return {...x,primaryDA:g,secondaryDA:p,terminalType:m,firmwareVersion:I,graphics:$}}function S(x){let C=null,g=null;for(let p of x){let m=ut(p);lt(m)?C=m:ct(m)&&(g=m);}return {primaryDA:C,secondaryDA:g}}let y={async getCapabilities(){if(a)throw new Error("Negotiator has been destroyed");return i||(u||(u=d().then(x=>(i=x,x))),u)},getCachedCapabilities(){return i},async renegotiate(){if(a)throw new Error("Negotiator has been destroyed");return i=null,u=null,y.getCapabilities()},isNegotiated(){return i!==null},getTimeout(){return t},setTimeout(x){t=Math.max(Ee,Math.min(Te,x));},destroy(){a=true,i=null,u=null;}};return r===Re.EAGER&&(u=d().then(x=>(i=x,x))),y}var ce=null;function ft(){return ce||(ce=dt()),ce}function pr(){ce&&(ce.destroy(),ce=null);}async function mt(){return ft().getCapabilities()}async function dr(e){let r=(await mt())[e];return typeof r=="boolean"?r:r!=null}var fr={primaryDA:ae.primaryDA,secondaryDA:ae.secondaryDA,xtversion:ps,kittyKeyboard:ds};var Le=null;function mr(e){try{e.write(A.alternateOff()),e.write(E.show()),e.write(G.reset()),e.write(`
4
- `);}catch{}}function ys(){let e=new Map,t=new Set,r=false,n=false;function o(y,x){if(n)return;n=true;let C=x!==void 0?{reason:y,error:x}:{reason:y};for(let g of t)try{g(C);}catch{}for(let g of e.values())try{mr(g.output),g.cleanup();}catch{}}let s=()=>{o("SIGINT"),process.exit(130);},i=()=>{o("SIGTERM"),process.exit(143);},u=()=>{o("SIGQUIT"),process.exit(131);},a=()=>{o("SIGHUP"),process.exit(129);},d=()=>{o("exit");},c=y=>{throw o("uncaughtException",y),y},l=y=>{let x=y instanceof Error?y:new Error(String(y));o("unhandledRejection",x);};function f(){r||(process.on("SIGINT",s),process.on("SIGTERM",i),process.on("SIGQUIT",u),process.on("SIGHUP",a),process.on("exit",d),process.on("uncaughtException",c),process.on("unhandledRejection",l),r=true);}function S(){r&&(process.off("SIGINT",s),process.off("SIGTERM",i),process.off("SIGQUIT",u),process.off("SIGHUP",a),process.off("exit",d),process.off("uncaughtException",c),process.off("unhandledRejection",l),r=false);}return {get instanceCount(){return e.size},get hasCleanedUp(){return n},register(y,x,C){e.set(y,{id:y,output:x,cleanup:C}),r||f();},unregister(y){e.delete(y),e.size===0&&S();},onExit(y){return t.add(y),()=>{t.delete(y);}},async runCleanup(y,x){if(n)return;n=true;let C=x!==void 0?{reason:y,error:x}:{reason:y};for(let g of t)try{await g(C);}catch{}for(let g of e.values())try{mr(g.output),await g.cleanup();}catch{}},runCleanupSync:o}}var De={get instance(){return Le||(Le=ys()),Le},reset(){Le=null;}};function xs(e,t,r){De.instance.register(e,t,r);}function Cs(e){De.instance.unregister(e);}function Ss(e){return De.instance.onExit(e)}var hs={chunkSize:64*1024,maxSize:10*1024*1024,useOSC52:true};function Rs(e){let t={...hs,...e},r="",n=false;function o(a,d){return a.length<=t.maxSize?null:{success:false,error:`Content too large (${a.length} bytes, max ${t.maxSize})`,bytesProcessed:0,elapsedMs:performance.now()-d}}function s(a){if(!t.useOSC52)return;let d=ie.write(a,Q.CLIPBOARD,t.maxSize);d&&process.stdout.write(d);}function i(a,d,c){return s(a),c?.({processed:a.length,total:a.length,percentage:100,complete:true}),{success:true,bytesProcessed:a.length,elapsedMs:performance.now()-d}}async function u(a,d,c){let l=0,f=a.length;for(;l<f&&!n;)l=Math.min(l+t.chunkSize,f),c?.({processed:l,total:f,percentage:Math.round(l/f*100),complete:l>=f}),await new Promise(y=>setTimeout(y,0));return n?{success:false,error:"Operation cancelled",bytesProcessed:l,elapsedMs:performance.now()-d}:(s(a),{success:true,bytesProcessed:f,elapsedMs:performance.now()-d})}return {async copy(a,d){let c=performance.now();n=false;let l=o(a,c);return l||(r=a,a.length<=t.chunkSize?i(a,c,d):u(a,c,d))},writeToTerminal(a){let d=performance.now();if(a.length>t.maxSize)return {success:false,error:`Content too large (${a.length} bytes, max ${t.maxSize})`,bytesProcessed:0,elapsedMs:performance.now()-d};r=a;let c=ie.write(a,Q.CLIPBOARD,t.maxSize);return c&&process.stdout.write(c),{success:true,bytesProcessed:a.length,elapsedMs:performance.now()-d}},requestRead(){let a=ie.requestRead();process.stdout.write(a);},clear(){r="";let a=ie.clear();process.stdout.write(a);},getBuffer(){return r},cancel(){n=true;}}}function gr(e,t){if(e.length<=t)return [e];let r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}async function Es(e,t,r=64*1024){let n=e.length,o=0,s=gr(e,r);for(let i of s)o+=i.length,t(i,{processed:o,total:n,percentage:Math.round(o/n*100),complete:o>=n}),o<n&&await new Promise(u=>setTimeout(u,0));}var Ts=0;function vs(){return `cursor_${++Ts}`}function gt(e={}){return {x:e.x??0,y:e.y??0,visible:e.visible??true,shape:e.shape??"block",blink:e.blink??true,blinkRate:e.blinkRate??530,fgColor:e.fgColor,bgColor:e.bgColor,lastBlinkTime:0,blinkOn:true,id:e.id??vs()}}function br(e,t,r){return {...e,x:t,y:r}}function yr(e,t,r){return {...e,x:e.x+t,y:e.y+r}}function xr(e,t){return {...e,visible:t}}function Cr(e,t){return {...e,shape:t}}function Sr(e,t,r){return {...e,blink:t,blinkRate:r??e.blinkRate,blinkOn:t?e.blinkOn:true}}function hr(e,t,r){return {...e,fgColor:t,bgColor:r}}function bt(e,t){if(!e.blink)return e;let r=e.blinkRate/2;return t-e.lastBlinkTime>=r?{...e,blinkOn:!e.blinkOn,lastBlinkTime:t}:e}function Rr(e,t){return {...e,blinkOn:true,lastBlinkTime:t}}function yt(e){return e.visible?e.blink?e.blinkOn:true:false}var xt="\u2588",$e="\u2581",Ue="\u258F";function Er(e$1,t){let r=t??e(),n=r.char||" ",o,s;switch(e$1.fgColor!==void 0&&e$1.bgColor!==void 0?(o=e$1.fgColor,s=e$1.bgColor):(o=r.bg||c,s=r.fg||b$1),e$1.shape){case "block":return {cell:{char:n,fg:o,bg:s,attrs:r.attrs},fullCell:true};case "underline":return {cell:{char:$e,fg:e$1.fgColor??(r.fg||b$1),bg:r.bg,attrs:r.attrs},fullCell:false};case "bar":return {cell:{char:Ue,fg:e$1.fgColor??(r.fg||b$1),bg:r.bg,attrs:r.attrs},fullCell:false}}}function Tr(e){let t=e.fgColor??b$1,r=e.bgColor??c;switch(e.shape){case "block":return {char:xt,fg:t,bg:r,attrs:a.NONE};case "underline":return {char:$e,fg:t,bg:r,attrs:a.NONE};case "bar":return {char:Ue,fg:t,bg:r,attrs:a.NONE}}}function vr(e){let t=e??gt(),r=new Map;return r.set(t.id,t),{cursors:r,primaryId:t.id}}function _r(e){let t=e.cursors.get(e.primaryId);if(!t)throw new Error(`Primary cursor ${e.primaryId} not found`);return t}function Ir(e,t){let r=new Map(e.cursors);return r.set(t.id,t),{...e,cursors:r}}function Ar(e,t){if(t===e.primaryId)throw new Error("Cannot remove primary cursor");let r=new Map(e.cursors);return r.delete(t),{...e,cursors:r}}function wr(e,t){let r=new Map(e.cursors);return r.set(t.id,t),{...e,cursors:r}}function Mr(e){return Array.from(e.cursors.values()).filter(yt)}function Or(e,t){let r=new Map;for(let[n,o]of e.cursors)r.set(n,bt(o,t));return {...e,cursors:r}}function Pr(e,t,r){for(let n of e.cursors.values())if(n.x===t&&n.y===r&&n.visible)return n}var Ct="\x1B[?25l",St="\x1B[?25h";function kr(){return Ct}function Br(){return St}var _={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Bs="blecsd-debug.log",Ns=10*1024*1024,Ls={[_.TRACE]:"TRACE",[_.DEBUG]:"DEBUG",[_.INFO]:"INFO",[_.WARN]:"WARN",[_.ERROR]:"ERROR",[_.SILENT]:"SILENT"};function Ds(){let e=process.env.DEBUG??"",t=process.env.BLECSD_DEBUG??"";if(t==="1"||t.toLowerCase()==="true")return true;let r=e.split(",").map(n=>n.trim());for(let n of r)if(n==="blecsd"||n==="blecsd:*"||n==="*"||n.startsWith("blecsd:"))return true;return false}function Nr(e){let t=e??process.env.DEBUG??"";return t?t.split(",").map(r=>r.trim()).filter(r=>r.length>0):["*"]}function Lr(e,t){return !!(t===e||t==="*"||t.endsWith("*")&&e.startsWith(t.slice(0,-1)))}function $s(e,t){if(!t.startsWith("-"))return false;let r=t.slice(1);return Lr(e,r)}function Us(e,t){for(let r of t){if($s(e,r))return false;if(Lr(e,r))return true}return false}var v={enabled:Ds(),logFile:Bs,level:_.DEBUG,timestamps:true,includeLevel:true,maxFileSize:Ns,namespaceFilter:Nr(),initialized:false};function Dr(){return new Date().toISOString().replace("T"," ").replace("Z","")}function $r(e){return e===void 0?"undefined":e===null?"null":typeof e=="string"?e:e instanceof Error?`${e.name}: ${e.message}
5
- ${e.stack??""}`:inspect(e,{depth:4,colors:false,maxArrayLength:100,maxStringLength:1e3})}function Ur(e){let t=dirname(e);t&&t!=="."&&!existsSync(t)&&mkdirSync(t,{recursive:true});}function Gs(e,t){try{let r=existsSync(e)?statSync(e):null;if(r&&r.size>t){let n=`${e}.old`;existsSync(n)&&unlinkSync(n),renameSync(e,n);}}catch{}}function B(e,t,r,...n){if(!v.enabled||e<v.level||!Us(t,v.namespaceFilter))return;let o=[];v.timestamps&&o.push(`[${Dr()}]`),v.includeLevel&&o.push(`[${Ls[e]}]`),o.push(`[${t}]`),o.push(r);for(let i of n)o.push($r(i));let s=`${o.join(" ")}
6
- `;try{Ur(v.logFile),Gs(v.logFile,v.maxFileSize),appendFileSync(v.logFile,s,"utf8");}catch{}}function Ks(e){e.enabled!==void 0&&(v.enabled=e.enabled),e.logFile!==void 0&&(v.logFile=e.logFile),e.level!==void 0&&(v.level=e.level),e.timestamps!==void 0&&(v.timestamps=e.timestamps),e.includeLevel!==void 0&&(v.includeLevel=e.includeLevel),e.maxFileSize!==void 0&&(v.maxFileSize=e.maxFileSize),e.namespaceFilter!==void 0&&(v.namespaceFilter=Nr(e.namespaceFilter)),v.initialized=true;}function Fs(){return v.enabled}function zs(){return v.logFile}function te(e){let t=(r,...n)=>{B(_.DEBUG,e,r,...n);};return t.trace=(r,...n)=>{B(_.TRACE,e,r,...n);},t.debug=(r,...n)=>{B(_.DEBUG,e,r,...n);},t.info=(r,...n)=>{B(_.INFO,e,r,...n);},t.warn=(r,...n)=>{B(_.WARN,e,r,...n);},t.error=(r,...n)=>{B(_.ERROR,e,r,...n);},t.namespace=e,t}function Ws(e,t){if(!v.enabled)return;let r={},n=process.env.TERM,o=process.env.COLORTERM,s=process.env.TERM_PROGRAM;n!==void 0&&(r.TERM=n),o!==void 0&&(r.COLORTERM=o),s!==void 0&&(r.TERM_PROGRAM=s);let i={timestamp:Dr(),...e,environment:r},u=t?`=== Terminal State Dump: ${t} ===`:"=== Terminal State Dump ===",a="=".repeat(u.length);B(_.DEBUG,"blecsd:dump",u),B(_.DEBUG,"blecsd:dump",$r(i)),B(_.DEBUG,"blecsd:dump",a);}function Hs(e,t){if(!v.enabled)return;let r=Buffer.isBuffer(e)?e.toString("hex").match(/.{1,2}/g)?.join(" ")??"":Buffer.from(e,"utf8").toString("hex").match(/.{1,2}/g)?.join(" ")??"",n=/[\x00-\x1f\x7f-\x9f]/g,o=Buffer.isBuffer(e)?e.toString("utf8").replace(n,"."):e.replace(n,"."),s=t?`Raw dump: ${t}`:"Raw dump";B(_.TRACE,"blecsd:raw",s),B(_.TRACE,"blecsd:raw",` Length: ${e.length}`),B(_.TRACE,"blecsd:raw",` Hex: ${r}`),B(_.TRACE,"blecsd:raw",` Print: ${o}`);}function Vs(){try{Ur(v.logFile),writeFileSync(v.logFile,"","utf8");}catch{}}var Ys={input:te("blecsd:input"),render:te("blecsd:render"),mouse:te("blecsd:mouse"),program:te("blecsd:program"),detect:te("blecsd:detect"),ecs:te("blecsd:ecs")};var qs=z$1.union([z$1.literal(2),z$1.literal(16),z$1.literal(256),z$1.literal("truecolor")]);z$1.object({name:z$1.string(),version:z$1.string().optional(),colorSupport:qs,unicodeSupport:z$1.boolean(),mouseSupport:z$1.boolean(),bracketedPaste:z$1.boolean(),tmux:z$1.boolean(),screen:z$1.boolean(),vscode:z$1.boolean(),cols:z$1.number().int().positive(),rows:z$1.number().int().positive()});function T(e){return process.env[e]}function Ge(){return process.stdout.isTTY===true}function Xs(){return process.stdout.columns&&process.stdout.rows?{cols:process.stdout.columns,rows:process.stdout.rows}:{cols:80,rows:24}}function Ke(){return T("TMUX")!==void 0}function Fe(){return (T("TERM")??"").startsWith("screen")||T("STY")!==void 0}function ze(){return T("TERM_PROGRAM")==="vscode"}function We(){let e=T("TERM")??"",t=T("TERM_PROGRAM")??"";return e.includes("xterm")||t==="Apple_Terminal"}function He(){return T("VTE_VERSION")!==void 0}function re(){return T("TERM_PROGRAM")==="iTerm.app"}function pe(){return T("TERM")==="alacritty"}function de(){return T("TERM")==="xterm-kitty"||T("KITTY_WINDOW_ID")!==void 0}function fe(){return T("WT_SESSION")!==void 0}function Gr(){return T("TERM_PROGRAM")==="Hyper"}function js(){if(re())return "iTerm2";if(de())return "Kitty";if(pe())return "Alacritty";if(fe())return "Windows Terminal";if(Gr())return "Hyper";if(ze())return "VSCode";if(He())return "VTE";if(Ke())return "tmux";if(Fe())return "screen";if(We())return "xterm";let e=T("TERM");return e||"unknown"}function Zs(){if(T("NO_COLOR")!==void 0)return 2;let e=T("FORCE_COLOR");return e==="0"?2:e==="1"?16:e==="2"?256:e==="3"?"truecolor":null}function Js(){let e=T("COLORTERM");if(e==="truecolor"||e==="24bit"||re()||de()||pe()||fe()||Gr())return true;let t=T("VTE_VERSION");return !!(t&&Number.parseInt(t,10)>=3600)}function Qs(){let e=T("TERM")??"";return e.includes("256color")||e.includes("256-color")?256:e.includes("color")||e.includes("ansi")?16:e.startsWith("xterm")||e.startsWith("screen")||e.startsWith("vt100")?256:null}function Ve(){let e=Zs();if(e!==null)return e;if(Js())return "truecolor";let t=Qs();return t!==null?t:Ge()?16:2}function ei(){return Ve()!==2}function ti(){return Ve()==="truecolor"}function Kr(){let e=T("LANG")??"",t=T("LC_ALL")??"";if(e.includes("UTF-8")||e.includes("utf8")||t.includes("UTF-8")||t.includes("utf8")||re()||de()||pe()||fe()||ze())return true;let r=T("TERM")??"";return r.includes("utf")||r.includes("unicode")?true:Ge()}function Fr(){if(We()||He()||re()||de()||pe()||fe()||Ke()||Fe())return true;let e=T("TERM")??"";return e.includes("xterm")||e.includes("256color")?true:Ge()}function zr(){return We()||He()||re()||de()||pe()||fe()?true:Ge()}function Wr(){let e=T("VTE_VERSION");if(e){let r=Number.parseInt(e,10),n=Math.floor(r/1e4),o=Math.floor(r%1e4/100),s=r%100;return `${n}.${o}.${s}`}let t=T("TERM_PROGRAM_VERSION");if(t&&re())return t}function ri(){let e=Xs();return {name:js(),version:Wr(),colorSupport:Ve(),unicodeSupport:Kr(),mouseSupport:Fr(),bracketedPaste:zr(),tmux:Ke(),screen:Fe(),vscode:ze(),cols:e.cols,rows:e.rows}}var ve={MOVE:1,DRAG:2,DOWN:4,UP:8,SINGLE:16,DOUBLE:32,TRIPLE:64,MFLAG:128,HARD:256,ENTER:512,LEAVE:1024},Y={NONE:0,LEFT:4,MIDDLE:2,RIGHT:1,FOURTH:8,UP:16,DOWN:32},ni=z$1.object({socketPath:z$1.string().default("/dev/gpmctl"),eventMask:z$1.number().int().default(65535),defaultMask:z$1.number().int().default(0),minMod:z$1.number().int().default(0),maxMod:z$1.number().int().default(65535),pid:z$1.number().int().positive().default(0),vc:z$1.number().int().nonnegative().default(0)}),oi={socketPath:"/dev/gpmctl",eventMask:65535,defaultMask:0,minMod:0,maxMod:65535,pid:0,vc:0},Ye=20;function Hr(e){if(e.length<Ye)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return {buttons:e[0]??0,modifiers:e[1]??0,vc:t.getUint16(2,true),dx:t.getInt16(4,true),dy:t.getInt16(6,true),x:t.getInt16(8,true),y:t.getInt16(10,true),type:t.getInt16(12,true),clicks:t.getInt32(14,true)}}function Vr(e){return e&Y.LEFT?"left":e&Y.MIDDLE?"middle":e&Y.RIGHT?"right":e&Y.UP?"wheelUp":e&Y.DOWN?"wheelDown":"unknown"}function Yr(e,t){return t&(Y.UP|Y.DOWN)?"wheel":e&ve.DOWN?"press":e&ve.UP?"release":e&(ve.MOVE|ve.DRAG)?"move":"press"}function qr(e){return {shift:!!(e&1),ctrl:!!(e&4),meta:!!(e&8)}}function Xr(e){let t=Vr(e.buttons),r=Yr(e.type,e.buttons),n=qr(e.modifiers),o=Math.max(0,e.x-1),s=Math.max(0,e.y-1);return {x:o,y:s,button:t,action:r,ctrl:n.ctrl,meta:n.meta,shift:n.shift,protocol:"x10",raw:new Uint8Array(0)}}function jr(e){let t=new ArrayBuffer(16),r=new DataView(t);return r.setUint16(0,e.eventMask,true),r.setUint16(2,e.defaultMask,true),r.setUint16(4,e.minMod,true),r.setUint16(6,e.maxMod,true),r.setInt32(8,e.pid||process.pid,true),r.setInt32(12,e.vc,true),new Uint8Array(t)}function si(){let e=process.env.GPM_TTY??"",t=/tty(\d+)/.exec(e);return t?.[1]?Number.parseInt(t[1],10):0}function qe(){if(process.platform!=="linux")return false;let e=process.env.TERM??"";return e==="linux"||e==="console"}function ii(e){let t={...oi,...e},r=false,n=null,o=new Set,s=new Set;function i(c){for(let l of o)try{l(c);}catch{}}function u(c){for(let l of s)try{l(c);}catch{}}function a(c){let l=0;for(;l+Ye<=c.length;){let f=new Uint8Array(c.buffer,c.byteOffset+l,Ye),S=Hr(f);if(S){let y=Xr(S);i(y);}l+=Ye;}}return {get state(){return {connected:r,available:qe(),config:t}},onMouse(c){return o.add(c),()=>{o.delete(c);}},onConnectionChange(c){return s.add(c),()=>{s.delete(c);}},connect(){if(r)return true;if(!qe())return false;try{n=a$1("net").createConnection(t.socketPath);let l=n;return l.on("connect",()=>{r=!0;let f=jr(t);l.write(f),u(!0);}),l.on("data",f=>{a(f);}),l.on("error",()=>{r=!1,n=null,u(!1);}),l.on("close",()=>{r=!1,n=null,u(!1);}),!0}catch{return false}},disconnect(){n&&(n.destroy(),n=null),r=false,u(false);},isAvailable(){return qe()}}}function ai(e){switch(e){case 0:return "left";case 1:return "middle";case 2:return "right";default:return "unknown"}}function ui(e){switch(e){case "mousedown":return "press";case "mouseup":return "release";case "mousemove":return "move";case "wheel":return "wheel"}}var me={OFF:0,NORMAL:1,BUTTON:2,ANY:3,SGR:4},W=new WeakMap,Xe=null;function ne(){return Xe||(Xe=a$2()),Xe}function li(){Xe=null;}function ci(e,t$1,r={}){let n=i=>{t(i)||(c$1({name:i.name,sequence:i.sequence,ctrl:i.ctrl,meta:i.meta,shift:i.shift,raw:new Uint8Array(Buffer.from(i.sequence))}),ne().emit("key",i));},o=i=>{d({x:i.x,y:i.y,button:ai(i.button),action:ui(i.action),ctrl:i.ctrl,meta:i.meta,shift:i.shift,protocol:"sgr",raw:new Uint8Array(0)}),ne().emit("mouse",i);},s={world:e,program:t$1,keysEnabled:false,mouseEnabled:false,mouseMode:r.mouseMode??me.NORMAL,keyHandler:n,mouseHandler:o};return W.set(e,s),r.keys&&Zr(s),r.mouse&&Jr(s),s}function pi(e){return W.get(e)}function di(e){je(e),_e(e),W.delete(e.world);}function Zr(e){e.keysEnabled||(e.program.on("key",e.keyHandler),e.keysEnabled=true);}function Rt(e){Zr(e),ne().emit("keysEnabled",void 0);}function je(e){e.keysEnabled&&(e.program.off("key",e.keyHandler),e.keysEnabled=false,ne().emit("keysDisabled",void 0));}function fi(e){return e.keysEnabled}function Jr(e,t){if(e.mouseEnabled)return;let r=t??e.mouseMode;e.mouseMode=r;let n=e.program.output;if(n&&typeof n.write=="function")switch(r){case me.NORMAL:n.write(P.enableNormal());break;case me.BUTTON:n.write(P.enableButtonEvent());break;case me.ANY:n.write(P.enableAnyEvent());break;case me.SGR:n.write(P.enableSGR());break}e.program.on("mouse",e.mouseHandler),e.mouseEnabled=true;}function Ze(e,t){Jr(e,t),ne().emit("mouseEnabled",e.mouseMode);}function _e(e){if(!e.mouseEnabled)return;let t=e.program.output;t&&typeof t.write=="function"&&t.write(P.disableAll()),e.program.off("mouse",e.mouseHandler),e.mouseEnabled=false,ne().emit("mouseDisabled",void 0);}function mi(e){return e.mouseEnabled}function gi(e){return e.mouseMode}function bi(e,t){let r=e.mouseEnabled;r&&_e(e),e.mouseMode=t,r&&Ze(e,t);}function Qr(e,t){Rt(e),Ze(e,t);}function en(e){je(e),_e(e);}function yi(e){return e.keysEnabled||e.mouseEnabled}function xi(e){let t=W.get(e);return t?(Rt(t),true):false}function Ci(e){let t=W.get(e);return t?(je(t),true):false}function Si(e,t){let r=W.get(e);return r?(Ze(r,t),true):false}function hi(e){let t=W.get(e);return t?(_e(t),true):false}function Ri(e,t){let r=W.get(e);return r?(Qr(r,t),true):false}function Ei(e){let t=W.get(e);return t?(en(t),true):false}var rn=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","up","down","left","right","home","end","pageup","pagedown","insert","delete","clear","return","enter","tab","backspace","escape","space","!","@","#","$","%","^","&","*","(",")","-","_","=","+","[","]","{","}","\\","|",";",":","'",'"',",",".","<",">","/","?","`","~","undefined"],Ti=z$1.object({sequence:z$1.string(),name:z$1.enum(rn),ctrl:z$1.boolean(),meta:z$1.boolean(),shift:z$1.boolean(),code:z$1.string().optional(),raw:z$1.instanceof(Uint8Array)}),Ie="\x1B",tn=27,vi=/^(?:\x1b)([a-zA-Z0-9])$/,_i=/(?:\x1b)([a-zA-Z0-9])/,Ii=new RegExp("^(?:\\x1b+)(O|N|\\[|\\[\\[)(?:"+["(\\d+)(?:;(\\d+))?([~^$])","(?:1;)?(\\d+)?([a-zA-Z])"].join("|")+")"),Ai=new RegExp("(?:\\x1b+)(O|N|\\[|\\[\\[)(?:"+["(\\d+)(?:;(\\d+))?([~^$])","(?:1;)?(\\d+)?([a-zA-Z])"].join("|")+")"),wi={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Mi=new Set(["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"]),Oi=new Set(["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"]),Pi={"\r":{name:"return"},"\n":{name:"enter"}," ":{name:"tab"},"\b":{name:"backspace"},"\x7F":{name:"backspace"},"\x1B\x7F":{name:"backspace",meta:true},"\x1B\b":{name:"backspace",meta:true},[Ie]:{name:"escape"},[Ie+Ie]:{name:"escape",meta:true}," ":{name:"space"},[`${Ie} `]:{name:"space",meta:true}};function H(e,t,r,n={},o){let s={sequence:e,name:t,ctrl:n.ctrl??false,meta:n.meta??false,shift:n.shift??false,raw:r};return o!==void 0?{...s,code:o}:s}function ki(e){let t=e-1;return {shift:!!(t&1),meta:!!(t>>1&1)||!!(t>>3&1),ctrl:!!(t>>2&1)}}function Bi(e,t){let r=Pi[e];return r?H(e,r.name,t,{meta:r.meta??false}):null}function Ni(e,t){if(e.length!==1||e>"")return null;let r=e.charCodeAt(0),n=String.fromCharCode(r+97-1);return H(e,n,t,{ctrl:true})}function Li(e,t){return e.length!==1||e<"a"||e>"z"?null:H(e,e,t)}function Di(e,t){return e.length!==1||e<"A"||e>"Z"?null:H(e,e.toLowerCase(),t,{shift:true})}function $i(e,t){return e.length!==1||e<"0"||e>"9"?null:H(e,e,t)}function Ui(e,t){if(e.length!==1)return null;let r=e.charCodeAt(0);return r<33||r>126||!rn.includes(e)?null:H(e,e,t)}function Gi(e,t){let r=Bi(e,t);if(r)return r;let n=Ni(e,t);if(n)return n;let o=Li(e,t);if(o)return o;let s=Di(e,t);if(s)return s;let i=$i(e,t);return i||Ui(e,t)}function Ki(e,t){let r=vi.exec(e);if(r?.[1]){let f=r[1],S=f.toLowerCase(),y=/^[A-Z]$/.test(f);return H(e,S,t,{meta:true,shift:y})}let n=Ii.exec(e);if(!n)return null;let o=n[1]||"",s=n[2]||"",i=n[4]||"",u=n[6]||"",a=o+s+i+u,d=Number(n[3]||n[5]||1),c=ki(d);Mi.has(a)&&(c.shift=true),Oi.has(a)&&(c.ctrl=true);let l=wi[a];return l?H(e,l,t,c,a):H(e,"undefined",t,c,a)}function Ae(e){if(e.length<3)return false;if(e[0]===tn&&e[1]===91&&e[2]===77||e[0]===tn&&e[1]===91&&e[2]===60)return true;let t=new TextDecoder().decode(e),r=/\x1b\[M/,n=/\x1b\[(\d+;\d+;\d+)M/,o=/\x1b\[<(\d+;\d+;\d+)([mM])/,s=/\x1b\[(O|I)/;return r.test(t)||n.test(t)||o.test(t)||s.test(t)}function Je(e){if(e.length===0||Ae(e))return null;let t=e,r,n=e[0];if(n!==void 0&&n>127&&e.length===1){let s=new Uint8Array([n-128]);r=`${Ie}${new TextDecoder().decode(s)}`;}else r=new TextDecoder().decode(e);let o=Gi(r,t);return o||Ki(r,t)}function Et(e){if(e.length===0)return [];if(Ae(e))return [];let t=[],r=new TextDecoder().decode(e),n=new RegExp([Ai.source,_i.source,"\\x1b."].join("|"),"g"),o=[],s=0;for(;;){let i=n.exec(r);if(i===null)break;if(i.index>s){let u=r.slice(s,i.index);o.push(...u.split(""));}o.push(i[0]),s=i.index+i[0].length;}s<r.length&&o.push(...r.slice(s).split(""));for(let i of o){let u=new TextEncoder().encode(i),a=Je(u);a&&t.push(a);}return t}var Fi=["left","middle","right","wheelUp","wheelDown","unknown"],zi=["press","release","move","wheel"],Wi=["x10","sgr","urxvt","dec","vt300"],Hi=z$1.object({x:z$1.number().int().nonnegative(),y:z$1.number().int().nonnegative(),button:z$1.enum(Fi),action:z$1.enum(zi),ctrl:z$1.boolean(),meta:z$1.boolean(),shift:z$1.boolean(),protocol:z$1.enum(Wi),raw:z$1.instanceof(Uint8Array)}),Vi=27,Yi=/^\x1b\[M([\x00\u0020-\uffff]{3})/,qi=/^\x1b\[<(\d+);(\d+);(\d+)([mM])/,Xi=/^\x1b\[(\d+);(\d+);(\d+)M/,ji=/^\x1b\[<(\d+);(\d+);(\d+);(\d+)&w/,Zi=/^\x1b\[24([0135])~\[(\d+),(\d+)\]\r/,Ji=/^\x1b\[(O|I)/;function Tt(e){let t=e>>2;return {shift:!!(t&1),meta:!!(t>>1&1),ctrl:!!(t>>2&1)}}function ge(e,t){if(t)return e&1?"wheelDown":"wheelUp";let r=e&3;return r===0?"left":r===1?"middle":r===2?"right":"unknown"}function vt(e){return !!(e>>6&1)}function _t(e){return e===35||e===39||e===51||e===43}function L(e,t,r,n,o,s,i){return {x:e,y:t,button:r,action:n,ctrl:o.ctrl,meta:o.meta,shift:o.shift,protocol:s,raw:i}}function Qi(e,t){let r=Yi.exec(e);if(!r?.[1])return null;let n=r[1];if(n.length<3)return null;let o=n.charCodeAt(0),s=n.charCodeAt(1),i=n.charCodeAt(2);s=s-32,i=i-32,s===-32&&(s=255),i===-32&&(i=255),s=Math.max(0,s-1),i=Math.max(0,i-1);let u=Tt(o);if(o-=32,vt(o)){let d=ge(o,true);return L(s,i,d,"wheel",u,"x10",t)}if(o===3)return L(s,i,"unknown","release",u,"x10",t);if(_t(o))return L(s,i,"unknown","move",u,"x10",t);let a=ge(o,false);return L(s,i,a,"press",u,"x10",t)}function ea(e,t){let r=qi.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),s=Number(r[3]),i=r[4]==="M";o=Math.max(0,o-1),s=Math.max(0,s-1);let u=Tt(n);if(vt(n)){let c=ge(n,true);return L(o,s,c,"wheel",u,"sgr",t)}if(_t(n))return L(o,s,"unknown","move",u,"sgr",t);let a=ge(n,false);return L(o,s,a,i?"press":"release",u,"sgr",t)}function ta(e,t){let r=Xi.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),s=Number(r[3]);o=Math.max(0,o-1),s=Math.max(0,s-1);let i=Tt(n);if((n===128||n===129)&&(n=67),n-=32,vt(n)){let a=ge(n,true);return L(o,s,a,"wheel",i,"urxvt",t)}if(n===3)return L(o,s,"unknown","release",i,"urxvt",t);if(_t(n))return L(o,s,"unknown","move",i,"urxvt",t);let u=ge(n,false);return L(o,s,u,"press",i,"urxvt",t)}function ra(e,t){let r=ji.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),s=Number(r[3]);o=Math.max(0,o-1),s=Math.max(0,s-1);let i=n===3?"release":"press",u;return n===2?u="left":n===4?u="middle":n===6?u="right":u="unknown",L(o,s,u,i,{shift:false,meta:false,ctrl:false},"dec",t)}function na(e,t){let r=Zi.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),s=Number(r[3]);o=Math.max(0,o-1),s=Math.max(0,s-1);let i;return n===1?i="left":n===2||n===3?i="middle":n===5?i="right":i="unknown",L(o,s,i,"press",{shift:false,meta:false,ctrl:false},"vt300",t)}var oa=z$1.object({focused:z$1.boolean(),raw:z$1.instanceof(Uint8Array)});function sa(e,t){let r=Ji.exec(e);return r?.[1]?{focused:r[1]==="I",raw:t}:null}function Qe(e){if(e.length<3||e[0]!==Vi||e[1]!==91)return null;let t=new TextDecoder().decode(e),r=sa(t,e);if(r)return {type:"focus",event:r};let n=ea(t,e);if(n)return {type:"mouse",event:n};let o=Qi(t,e);if(o)return {type:"mouse",event:o};let s=ta(t,e);if(s)return {type:"mouse",event:s};let i=ra(t,e);if(i)return {type:"mouse",event:i};let u=na(t,e);return u?{type:"mouse",event:u}:null}function ia(e){return Qe(e)!==null}var aa=z$1.object({maxBufferSize:z$1.number().int().positive().optional(),escapeTimeout:z$1.number().int().positive().optional()}),ua={maxBufferSize:4096,escapeTimeout:100};function nn(e){return e>=65&&e<=90||e>=97&&e<=122}function la(e){return e>=48&&e<=57}function ca(e,t){for(let r=t;r<e.length;r++){let n=e[r]??0;if(n===77||n===109)return true}return false}function pa(e,t){for(let r=t;r<e.length;r++){let n=e[r]??0;if(n===126||nn(n))return true}return false}function da(e){let t=e[2]??0;return nn(t)?false:t===60?!ca(e,3):la(t)?!pa(e,3):false}function fa(e){return e.length===0?false:e[e.length-1]===27?true:e[0]!==27?false:e.length===1||e.length===2&&e[1]===91?true:e.length>=3&&e[1]===91?da(e):false}function ma(e,t){if(!t)return 0;let r=new TextDecoder().decode(e),n=/^\x1b\[<\d+;\d+;\d+[mM]/.exec(r);if(n)return n[0].length;if(e.length>=6&&e[0]===27&&e[1]===91&&e[2]===77)return 6;if(e.length>=3&&e[0]===27&&e[1]===91&&(e[2]===73||e[2]===79))return 3;let o=/^\x1b\[\d+;\d+;\d+M/.exec(r);return o?o[0].length:t.event.raw.length}function ga(e,t={}){let r={...ua,...t},n=new Uint8Array(0),o=new Set,s=new Set,i=new Set,u=null,a=false,d=null;function c(p){for(let m of o)try{m(p);}catch{}}function l(p){for(let m of s)try{m(p);}catch{}}function f(p){for(let m of i)try{m(p);}catch{}}function S(p){let m=Qe(p);if(!m)return null;let I=ma(p,m);return m.type==="mouse"?l(m.event):m.type==="focus"&&f(m.event),{consumed:I}}function y(p){if(Ae(p))return null;let m=Je(p);if(m)return c(m),{consumed:m.raw.length};let I=Et(p);if(I.length>0){for(let D of I)c(D);let $=0;for(let D of I)$+=D.raw.length;return {consumed:Math.max($,1)}}return p.length>0?{consumed:1}:null}function x(p){let m=0;for(;m<p.length;){let I=p.slice(m);if(I[0]===27&&I.length>=3){let D=S(I);if(D){m+=D.consumed;continue}}let $=y(I);if($){m+=$.consumed;continue}m++;}}function C(){if(n.length===0)return;let p=n;n=new Uint8Array(0),x(p);}function g(p){let m=new Uint8Array(n.length+p.length);if(m.set(n),m.set(new Uint8Array(p),n.length),n=m,n.length>=r.maxBufferSize){C();return}if(u&&(clearTimeout(u),u=null),fa(n)){u=setTimeout(()=>{u=null,C();},r.escapeTimeout);return}C();}return {start(){a||(a=true,d=p=>g(p),e.on("data",d));},stop(){a&&(a=false,d&&(e.removeListener("data",d),d=null),u&&(clearTimeout(u),u=null),C(),n=new Uint8Array(0));},onKey(p){return o.add(p),()=>{o.delete(p);}},onMouse(p){return s.add(p),()=>{s.delete(p);}},onFocus(p){return i.add(p),()=>{i.delete(p);}},isRunning(){return a},getBufferSize(){return n.length}}}var et={NONE:0,DISAMBIGUATE:1,REPORT_EVENTS:2,REPORT_ALTERNATE:4,REPORT_ALL:8,REPORT_TEXT:16},ba={flags:et.DISAMBIGUATE|et.REPORT_EVENTS,escTimeout:50},ya={shift:false,alt:false,ctrl:false,super:false,hyper:false,meta:false,capsLock:false,numLock:false};function on(e){return `\x1B[>${e}u`}function sn(){return "\x1B[<u"}function an(){return "\x1B[?u"}function At(e){return e.length<4||e[0]!==27||e[1]!==91||e[2]!==63?false:e[e.length-1]===117}function un(e){if(!At(e))return;let t="";for(let r=3;r<e.length-1;r++){let n=e[r]??0;if(n>=48&&n<=57)t+=String.fromCharCode(n);else return}return t.length>0?Number.parseInt(t,10):0}function wt(e){if(e.length<3||e[0]!==27||e[1]!==91)return false;let t=e[e.length-1];if(t!==117&&t!==126)return false;for(let r=2;r<e.length-1;r++){let n=e[r]??0;if(n>=48&&n<=57)return true}return false}function xa(e){let t="";for(let r=2;r<e.length-1;r++)t+=String.fromCharCode(e[r]??0);return t}function Ca(e){let t=e.split(":"),r=Number.parseInt(t[0]??"0",10),n=t[1]?Number.parseInt(t[1],10):void 0,o=t[2]?Number.parseInt(t[2],10):void 0;return {keyCode:r,shiftedKey:n,baseKey:o}}function Sa(e){let t=e.split(":"),r=t[0]?Number.parseInt(t[0],10)-1:0,n=t[1]?Number.parseInt(t[1],10):1,o=Ra(Math.max(0,r)),s=Ea(n);return {modifiers:o,eventType:s}}function ha(e){if(!e)return "";let t="",r=e.split(":");for(let n of r){let o=Number.parseInt(n,10);!Number.isNaN(o)&&o>0&&(t+=String.fromCodePoint(o));}return t}function ln(e){if(!wt(e))return;let t=xa(e),r=t,n=t.split(";"),{keyCode:o,shiftedKey:s,baseKey:i}=Ca(n[0]??""),{modifiers:u,eventType:a}=Sa(n[1]??""),d=ha(n[2]);return {keyCode:o,shiftedKey:s,baseKey:i,eventType:a,isRepeat:a==="repeat",isRelease:a==="release",text:d,modifiers:u,rawParams:r}}function cn(e){return {...ba,...e}}function pn(){return {active:false,pushedFlags:0,detectedLevel:void 0}}function dn(e,t){return {...e,detectedLevel:t}}function fn(e,t){return {...e,active:true,pushedFlags:t}}function mn(e){return {...e,active:false,pushedFlags:0}}function gn(e){let t=e.keyCode,r={27:"escape",13:"return",9:"tab",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57364:"f13",57365:"f14",57366:"f15",57367:"f16",57368:"f17",57369:"f18",57370:"f19",57371:"f20",57372:"f21",57373:"f22",57374:"f23",57375:"f24",57376:"f25",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpminus",57413:"kpplus",57414:"kpenter",57415:"kpequal",57441:"lshift",57442:"lctrl",57443:"lalt",57444:"lsuper",57445:"lhyper",57446:"lmeta",57447:"rshift",57448:"rctrl",57449:"ralt",57450:"rsuper",57451:"rhyper",57452:"rmeta"};if(r[t])return r[t];let n={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"};return n[t]?n[t]:t===57352?"up":t===57353?"down":t===57354?"right":t===57355?"left":t>=32&&t<=126?String.fromCharCode(t):t>0?String.fromCodePoint(t):"unknown"}function bn(e){return e.kittyKeyboard!==false}function Ra(e){return e===0?ya:{shift:(e&1)!==0,alt:(e&2)!==0,ctrl:(e&4)!==0,super:(e&8)!==0,hyper:(e&16)!==0,meta:(e&32)!==0,capsLock:(e&64)!==0,numLock:(e&128)!==0}}function Ea(e){return e===2?"repeat":e===3?"release":"press"}var xn=1,Cn=2,Sn=4,hn=8,Rn=16,En=32,Tn=64,vn=128,w=-1;function Ta(e={}){return {chunks:[],cursorX:0,cursorY:0,knownCursorX:0,knownCursorY:0,cursorKnown:false,colorState:{fg:w,bg:w,attrs:0},syncMode:e.syncMode??true,inSyncFrame:false,stats:{cellsWritten:0,cursorMoves:0,cursorMovesSkipped:0,colorChanges:0,colorChangesSkipped:0,bytesWritten:0,bytesSaved:0},trackStats:e.trackStats??false,screenWidth:80,screenHeight:24}}function va(e,t,r){e.screenWidth=t,e.screenHeight=r;}function _a(e){(e.colorState.fg!==w||e.colorState.bg!==w||e.colorState.attrs!==0)&&(e.chunks.push(G.reset()),e.colorState.fg=w,e.colorState.bg=w,e.colorState.attrs=0);}function Mt(e,t){if(e.colorState.fg===t){e.trackStats&&(e.stats.colorChangesSkipped++,e.stats.bytesSaved+=11);return}if(t===w)e.chunks.push("\x1B[39m");else {let r=t>>16&255,n=t>>8&255,o=t&255;e.chunks.push(`\x1B[38;2;${r};${n};${o}m`);}e.colorState.fg=t,e.trackStats&&e.stats.colorChanges++;}function Ot(e,t){if(e.colorState.bg===t){e.trackStats&&(e.stats.colorChangesSkipped++,e.stats.bytesSaved+=11);return}if(t===w)e.chunks.push("\x1B[49m");else {let r=t>>16&255,n=t>>8&255,o=t&255;e.chunks.push(`\x1B[48;2;${r};${n};${o}m`);}e.colorState.bg=t,e.trackStats&&e.stats.colorChanges++;}function Pt(e,t){let r=e.colorState.attrs;if(r===t)return;let n=t&~r;if((r&~t)!==0){e.chunks.push("\x1B[0m"),e.colorState.attrs=0,e.colorState.fg=w,e.colorState.bg=w,yn(e,t),e.colorState.attrs=t;return}yn(e,n),e.colorState.attrs=t;}function yn(e,t){t&xn&&e.chunks.push("\x1B[1m"),t&Cn&&e.chunks.push("\x1B[2m"),t&Sn&&e.chunks.push("\x1B[3m"),t&hn&&e.chunks.push("\x1B[4m"),t&Rn&&e.chunks.push("\x1B[5m"),t&En&&e.chunks.push("\x1B[7m"),t&Tn&&e.chunks.push("\x1B[8m"),t&vn&&e.chunks.push("\x1B[9m");}function kt(e,t,r){if(e.cursorKnown&&e.knownCursorX===t&&e.knownCursorY===r){_n(e,8);return}e.cursorKnown&&Ia(e,t,r)||(e.chunks.push(E.move(t+1,r+1)),e.knownCursorX=t,e.knownCursorY=r,e.cursorKnown=true,tt(e));}function tt(e){e.trackStats&&e.stats.cursorMoves++;}function _n(e,t){e.trackStats&&(e.stats.cursorMovesSkipped++,e.stats.bytesSaved+=t);}function Ia(e,t,r){let n=t-e.knownCursorX,o=r-e.knownCursorY;return n===0&&o===0?(_n(e,0),e.knownCursorX=t,e.knownCursorY=r,true):o===0?(e.chunks.push(Aa(n)),e.knownCursorX=t,tt(e),true):n===0?(e.chunks.push(wa(o)),e.knownCursorY=r,tt(e),true):t===0&&o===1?(e.chunks.push(`\r
7
- `),e.knownCursorX=0,e.knownCursorY=r,tt(e),true):false}function Aa(e){return e===1?"\x1B[C":e===-1?"\x1B[D":e>0?E.forward(e):E.back(-e)}function wa(e){return e===1?"\x1B[B":e===-1?"\x1B[A":e>0?E.down(e):E.up(-e)}function In(e,t){e.chunks.push(t),e.cursorKnown&&(e.knownCursorX++,e.knownCursorX>=e.screenWidth&&(e.knownCursorX=0,e.knownCursorY++)),e.trackStats&&e.stats.cellsWritten++;}function Ma(e,t,r,n,o=w,s=w,i=0){kt(e,t,r),Mt(e,o),Ot(e,s),Pt(e,i),In(e,n);}function Oa(e,t,r,n,o=w,s=w,i=0){if(kt(e,t,r),Mt(e,o),Ot(e,s),Pt(e,i),e.chunks.push(n),e.cursorKnown)for(e.knownCursorX+=n.length;e.knownCursorX>=e.screenWidth;)e.knownCursorX-=e.screenWidth,e.knownCursorY++;e.trackStats&&(e.stats.cellsWritten+=n.length);}function Pa(e,t){e.chunks.push(t),e.cursorKnown=false;}function ka(e){e.syncMode&&!e.inSyncFrame&&(e.chunks.push(K.begin()),e.inSyncFrame=true);}function Ba(e){e.syncMode&&e.inSyncFrame&&(e.chunks.push(K.end()),e.inSyncFrame=false);}function Na(e){return e.chunks.join("")}function La(e){return e.chunks.reduce((t,r)=>t+r.length,0)}function Da(e,t){if(e.chunks.length===0)return;let r=e.chunks.join("");t.write(r),e.trackStats&&(e.stats.bytesWritten+=r.length),e.chunks.length=0;}function $a(e){e.chunks.length=0,e.inSyncFrame=false;}function Ua(e){e.chunks.length=0,e.cursorX=0,e.cursorY=0,e.knownCursorX=0,e.knownCursorY=0,e.cursorKnown=false,e.colorState.fg=w,e.colorState.bg=w,e.colorState.attrs=0,e.inSyncFrame=false;}function Ga(e){e.stats.cellsWritten=0,e.stats.cursorMoves=0,e.stats.cursorMovesSkipped=0,e.stats.colorChanges=0,e.stats.colorChangesSkipped=0,e.stats.bytesWritten=0,e.stats.bytesSaved=0;}function Ka(e){return {...e.stats}}function Fa(e){e.chunks.push(E.hide());}function za(e){e.chunks.push(E.show());}function Wa(e){e.chunks.push("\x1B[2J"),e.cursorKnown=false;}function Ha(e){e.chunks.push("\x1B[J");}function Va(e){e.chunks.push("\x1B[2K");}function Ya(e){let t=e.stats,r=t.cursorMovesSkipped*8,n=t.colorChangesSkipped*12;return r+n}var eu=10*1024*1024;function rt(e){let t=e.output??process.stdout,r=e.input??process.stdin,n=e.isAlternateBuffer??false,o=e.isMouseEnabled??false,s={wasAlternateBuffer:n,wasMouseEnabled:o,wasRawMode:r.isRaw??false},i="";return n&&(i+=A.alternateOff()),i+=E.show(),o&&(i+=P.disableAll()),i+=G.reset(),i&&t.write(i),r.setRawMode&&s.wasRawMode&&r.setRawMode(false),s}function be(e,t){let r=t.output??process.stdout,n=t.input??process.stdin;n.setRawMode&&e.wasRawMode&&n.setRawMode(true);let o="";e.wasAlternateBuffer&&(o+=A.alternateOn()),e.wasMouseEnabled&&(o+=P.enableNormal()),o&&r.write(o);}function tu(e,t=[],r={}){let n=rt(r),{output:o,input:s,isAlternateBuffer:i,isMouseEnabled:u,onExit:a,...d}=r,c=spawn(e,t,{stdio:"inherit",...d});return c.on("exit",(l,f)=>{be(n,{output:o,input:s}),a?.(l,f);}),c}function ru(e,t=[],r={}){return new Promise((n,o)=>{let s=r.maxBuffer??eu,i=r.encoding??"utf8",u=rt(r),{output:a,input:d,isAlternateBuffer:c,isMouseEnabled:l,onExit:f,timeout:S,maxBuffer:y,encoding:x,...C}=r,g="",p="",m=0,I=0,$=false,D=spawn(e,t,{...C,stdio:["inherit","pipe","pipe"]}),ye;S&&(ye=setTimeout(()=>{$=true,D.kill("SIGTERM");},S)),D.stdout?.on("data",U=>{let oe=U.toString(i);m+=U.length,m<=s&&(g+=oe);}),D.stderr?.on("data",U=>{let oe=U.toString(i);I+=U.length,I<=s&&(p+=oe);}),D.on("close",(U,oe)=>{if(ye&&clearTimeout(ye),be(u,{output:a,input:d}),f?.(U,oe),$){o(new Error(`Process timed out after ${S}ms`));return}if(m>s||I>s){o(new Error(`Output exceeded maxBuffer of ${s} bytes`));return}n({stdout:g,stderr:p,exitCode:U,signal:oe});}),D.on("error",U=>{ye&&clearTimeout(ye),be(u,{output:a,input:d}),o(U);});})}function nu(e,t=[],r={}){let n=rt(r);try{let o=spawnSync(e,t,{encoding:"utf8",stdio:["inherit","pipe","pipe"]});return {stdout:o.stdout??"",stderr:o.stderr??"",exitCode:o.status,signal:o.signal}}finally{let{output:o,input:s}=r;be(n,{output:o,input:s});}}function wn(){return process.env.EDITOR||process.env.VISUAL||"vi"}function ou(e=".txt"){let t=Date.now(),r=Math.random().toString(36).substring(2,8),n=`blecsd-edit-${t}-${r}${e}`;return join(tmpdir(),n)}function Bt(e){try{unlinkSync(e);}catch{}}function su(e,t){try{return existsSync(e)?{content:readFileSync(e,"utf8")}:{content:t}}catch(r){return {content:t,error:r}}}function iu(e={}){return new Promise((t,r)=>{let n=e.editor??wn(),o=e.extension??".txt",s=e.content??"",i=ou(o);try{writeFileSync(i,s,"utf8");}catch(f){r(new Error(`Failed to create temp file: ${f}`));return}let u=n.split(/\s+/),a=u[0]??n,d=[...u.slice(1),i],c=rt(e),l=spawn(a,d,{stdio:"inherit"});l.on("exit",(f,S)=>{if(be(c,{output:e.output,input:e.input}),S){Bt(i),r(new Error(`Editor was killed by signal: ${S}`));return}let{content:y,error:x}=su(i,s);if(Bt(i),x){r(new Error(`Failed to read edited content: ${x}`));return}t(y);}),l.on("error",f=>{be(c,{output:e.output,input:e.input}),Bt(i),r(new Error(`Failed to start editor '${a}': ${f}`));});})}var au={commandExists(e){try{return spawnSync(process.platform==="win32"?"where":"which",[e],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).status===0}catch{return false}},getShell(){return process.platform==="win32"?{shell:process.env.COMSPEC||"cmd.exe",args:["/c"]}:{shell:process.env.SHELL||"/bin/sh",args:["-c"]}},shellEscape(e){return process.platform==="win32"?`"${e.replace(/"/g,'""')}"`:`'${e.replace(/'/g,"'\\''")}'`}};function uu(e,t,r){switch(e){case `
8
- `:return {cx:1,cy:r+1};case "\r":return {cx:1,cy:r};case " ":return {cx:Math.floor((t-1)/8)*8+9,cy:r};case "\b":return {cx:Math.max(1,t-1),cy:r};default:return e>=" "&&e!=="\x7F"?{cx:t+1,cy:r}:{cx:t,cy:r}}}function lu(e,t,r){return e>="0"&&e<="9"?{done:false,currentParam:t+e}:e===";"?(r.push(t?Number.parseInt(t,10):0),{done:false,currentParam:""}):e==="?"?{done:false,currentParam:t}:e>="@"&&e<="~"?(t&&r.push(Number.parseInt(t,10)),{done:true,result:e,currentParam:t}):{done:true,currentParam:t}}function cu(e,t){let r=t+2,n=[],o="";for(;r<e.length;){let s=e[r]??"",i=lu(s,o,n);if(i.done)return i.result?{command:i.result,params:n,endIndex:r+1}:null;o=i.currentParam,r++;}return null}function pu(e,t,r,n){let o=t[0]??1;switch(e){case "A":return {cx:r,cy:Math.max(1,n-o)};case "B":return {cx:r,cy:n+o};case "C":return {cx:r+o,cy:n};case "D":return {cx:Math.max(1,r-o),cy:n};case "E":return {cx:1,cy:n+o};case "F":return {cx:1,cy:Math.max(1,n-o)};case "G":return {cx:o,cy:n};case "H":case "f":return {cx:t[1]??1,cy:t[0]??1};default:return {cx:r,cy:n}}}function du(e,t,r){let n=t,o=r,s=0;for(;s<e.length;){let i=e[s]??"";if(i==="\x1B"&&e[s+1]==="["){let a=cu(e,s);if(a){let d=pu(a.command,a.params,n,o);n=d.cx,o=d.cy,s=a.endIndex;continue}}let u=uu(i,n,o);n=u.cx,o=u.cy,s++;}return {cx:n,cy:o}}function Mn(e={}){let t=[],r=1,n=1,o=e.trackCursor??true,s=e.autoFlush??false,i=null,u=null;function a(){i&&(clearImmediate(i),i=null);}function d(){if(i||!u)return;let l=u;i=setImmediate(()=>{i=null,l&&c.flush(l);});}let c={get cursorX(){return r},get cursorY(){return n},get cursorPosition(){return {x:r,y:n}},get length(){return t.reduce((l,f)=>l+f.length,0)},get chunkCount(){return t.length},get isEmpty(){return t.length===0},write(l){if(l.length!==0){if(t.push(l),o){let f=du(l,r,n);r=f.cx,n=f.cy;}s&&u&&!i&&d();}},writeln(l){c.write(l),c.write(`
9
- `);},writeAt(l,f,S){c.write(E.move(l,f)),c.write(S);},flush(l){if(a(),t.length===0)return;let f=t.join("");l.write(f),t=[];},setAutoFlushTarget(l){u=l,l||a();},clear(){a(),t=[];},getContents(){return t.join("")},resetCursor(l=1,f=1){r=l,n=f;}};return c}function On(e){let t=false,r=new Set,n=false;function o(a){e.write(a);}function s(){for(let a of r)try{a();}catch{}t&&(o(A.exitAlt()),t=false);}function i(){n||(process.on("SIGINT",s),process.on("SIGTERM",s),process.on("exit",s),process.on("uncaughtException",a=>{throw s(),a}),process.on("unhandledRejection",a=>{throw s(),a}),n=true);}function u(){n&&(process.off("SIGINT",s),process.off("SIGTERM",s),process.off("exit",s),n=false);}return {get isAlternate(){return t},enterAlternateScreen(){t||(o(A.enterAlt()),t=true,i());},exitAlternateScreen(){t&&(o(A.exitAlt()),t=false);},onCleanup(a){return r.add(a),()=>{r.delete(a);}},cleanup(){s();},destroy(){s(),u(),r.clear();}}}var Pn=z$1.object({input:z$1.custom().optional(),output:z$1.custom().optional(),useAlternateScreen:z$1.boolean().default(true),hideCursor:z$1.boolean().default(true),title:z$1.string().optional(),forceWidth:z$1.number().int().positive().optional(),forceHeight:z$1.number().int().positive().optional()});function mu(){let e=new EventEmitter;return {on(t,r){e.on(t,r);},off(t,r){e.off(t,r);},once(t,r){e.once(t,r);},emit(t,...r){return e.emit(t,...r)},removeAllListeners(t){e.removeAllListeners(t);}}}function we(e){return "isTTY"in e&&e.isTTY===true}function gu(e={}){let t=Pn.parse(e),r=t.input??process.stdin,n=t.output??process.stdout,o=Mn({trackCursor:true}),s=On(n),i=mu(),u=80,a=24,d=false,c=false,l=false;function f(){if(t.forceWidth&&t.forceHeight){u=t.forceWidth,a=t.forceHeight;return}let p=n;we(n)&&(u=p.columns??80,a=p.rows??24);}function S(){let p=u,m=a;f(),(u!==p||a!==m)&&i.emit("resize",{cols:u,rows:a});}function y(){l||we(r)&&"setRawMode"in r&&(r.setRawMode(true),l=true);}function x(){l&&we(r)&&"setRawMode"in r&&(r.setRawMode(false),l=false);}function C(){c&&(n.write(E.show()),c=false),n.write(G.reset()),x();}let g={get input(){return r},get output(){return n},get cols(){return u},get rows(){return a},get x(){return o.cursorX},get y(){return o.cursorY},get initialized(){return d},on(p,m){i.on(p,m);},off(p,m){i.off(p,m);},once(p,m){i.once(p,m);},removeAllListeners(p){i.removeAllListeners(p);},async init(){d||(f(),t.useAlternateScreen&&s.enterAlternateScreen(),t.hideCursor&&(n.write(E.hide()),c=true),t.title&&g.setTitle(t.title),n.write(A.clear()),n.write(E.home()),we(n)&&n.on("resize",S),y(),s.onCleanup(()=>{C();}),d=true);},destroy(){d&&(C(),s.destroy(),i.removeAllListeners(),we(n)&&n.off("resize",S),d=false);},write(p){o.write(p);},rawWrite(p){n.write(p);},flush(){o.flush(n);},clear(){g.write(A.clear()),g.write(E.home()),o.resetCursor();},move(p,m){g.write(E.move(p,m));},cursorTo(p,m){g.move(p,m);},showCursor(){g.write(E.show()),c=false;},hideCursor(){g.write(E.hide()),c=true;},setTitle(p){n.write(`\x1B]2;${p}\x07`);},resetStyle(){g.write(G.reset());}};return g}var nt=null,ot=new WeakMap;function st(){return nt||(nt=a$2()),nt}function bu(){nt=null;}function yu(e){let t=f(e),r$1=80,n=24;if(t){let i=r(e,t);i&&(r$1=i.width,n=i.height);}let s={world:e,lastWidth:r$1,lastHeight:n,handler:i=>{Lt(e,i.cols,i.rows,s);}};return ot.set(e,s),s}function Lt(e,t,r,n){if(t===n.lastWidth&&r===n.lastHeight)return;let o=n.lastWidth,s$1=n.lastHeight;n.lastWidth=t,n.lastHeight=r;let i=f(e);i&&s(e,i,t,r);let u=z$2();if(u){let d=g(u,t,r);y(d);}g$1(e),Z(e),st().emit("resize",{width:t,height:r,previousWidth:o,previousHeight:s$1});}function xu(e,t){e.on("resize",t.handler);}function Cu(e,t){e.off("resize",t.handler),ot.delete(t.world);}function Su(e){return ot.get(e)}function kn(e,t,r$1){let n=ot.get(e);if(n)Lt(e,t,r$1,n);else {let o=f(e),s=80,i=24;if(o){let a=r(e,o);a&&(s=a.width,i=a.height);}Lt(e,t,r$1,{lastWidth:s,lastHeight:i});}}function hu(e){let t=()=>{let r=process.stdout.columns??80,n=process.stdout.rows??24;kn(e,r,n);};return process.on("SIGWINCH",t),()=>{process.off("SIGWINCH",t);}}var Gu=z$1.object({allowUnicode:z$1.boolean().optional(),maxLength:z$1.number().int().min(0).optional(),stripControl:z$1.boolean().optional(),stripNull:z$1.boolean().optional(),allowTab:z$1.boolean().optional(),allowNewline:z$1.boolean().optional(),replacementChar:z$1.string().max(4).optional()}),Dt={allowUnicode:true,maxLength:0,stripControl:true,stripNull:true,allowTab:true,allowNewline:true,replacementChar:"\uFFFD"};function Bn(e){return e>=0&&e<=31}function Nn(e){return e>=128&&e<=159}function Ku(e){return e===0}function Ln(e,t){let r={...Dt,...t},n=e;return r.stripNull&&(n=Dn(n)),r.stripControl&&(n=$n(n,r.allowTab,r.allowNewline)),n=Un(n),n=Gn(n,r.replacementChar),r.allowUnicode||(n=Kn(n,r.replacementChar)),r.maxLength>0&&n.length>r.maxLength&&(n=n.slice(0,r.maxLength)),n}function Fu(e,t){let r={...Dt,...t},n=e.length,o=Ln(e,t),s=r.maxLength>0&&n>r.maxLength;return {text:o,modified:o!==e,strippedCount:n-o.length,truncated:s,originalLength:n}}function Dn(e){if(!e.includes("\0"))return e;let t="";for(let r=0;r<e.length;r++)e.charCodeAt(r)!==0&&(t+=e[r]);return t}function $n(e,t=true,r=true){let n="";for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);if(!Ku(s)){if(Bn(s)){if(t&&s===9){n+=e[o];continue}if(r&&(s===10||s===13)){n+=e[o];continue}continue}n+=e[o];}}return n}function Un(e){let t="";for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);Nn(n)||(t+=e[r]);}return t}function Gn(e,t="\uFFFD"){let r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o>=55296&&o<=56319){let s=n+1<e.length?e.charCodeAt(n+1):0;s>=56320&&s<=57343?(r+=e[n],r+=e[n+1],n++):r+=t;}else o>=56320&&o<=57343?r+=t:r+=e[n];}return r}function Kn(e,t="\uFFFD"){let r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o>=32&&o<=126||o===9||o===10||o===13?r+=e[n]:r+=t;}return r}function zu(e){for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=t+1<e.length?e.charCodeAt(t+1):0;if(n<56320||n>57343)return false;t++;}else if(r>=56320&&r<=57343)return false}return true}function Wu(e){for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(Bn(r)||Nn(r))return true}return false}function Hu(e){return e.includes("\0")}var Vu=z$1.object({allowColors:z$1.boolean().optional(),allowCursor:z$1.boolean().optional(),stripAllEscapes:z$1.boolean().optional(),replacementChar:z$1.string().max(1).optional()}),$t={allowColors:false,allowCursor:false,stripAllEscapes:true,replacementChar:""},Yu="\x1B",Ut=/\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/g,qu=/\x1b\[[\d;]*m/g,Xu=/\x1b\[[\d;]*[ABCDEFGHJKLMSTfsu]/g,ju=/^\x1b\[[\d;]*[ABCDEFGHJKLMSTfsu]$/,Zu=/^\x1b\[[\d;]*m$/,Gt=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,Kt=/\x1bP[^\x1b]*\x1b\\/g,Ft=/\x1b_[^\x1b]*\x1b\\/g,zt=/\x1bX[^\x1b]*\x1b\\/g,Wt=/\x1b\^[^\x1b]*\x1b\\/g,Ju=/\x1b(?:\[[^\x1b]*?[\x40-\x7e]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[PX_^][^\x1b]*\x1b\\|[78DEHMNOZ=>cnol|}~])/g,Fn=/\x1b(?![[\]PX_^])/g,zn=/[\x00-\x08\x0b\x0c\x0e-\x1a\x7f]/g,Qu=/[\x00-\x08\x0b\x0c\x0e-\x1a\x7f]/;function Wn(e,t={}){let r={...$t,...t},n=r.replacementChar,o=e;return r.stripAllEscapes?(o=o.replace(Ju,n),o=o.replace(Fn,n),o=o.replace(zn,n),o):(o=o.replace(Gt,n),o=o.replace(Kt,n),o=o.replace(Ft,n),o=o.replace(zt,n),o=o.replace(Wt,n),o=o.replace(zn,n),r.allowCursor||(o=o.replace(Xu,n)),r.allowColors||(o=o.replace(qu,n)),o=o.replace(Ut,s=>r.allowColors&&Zu.test(s)||r.allowCursor&&ju.test(s)?s:n),o=o.replace(Fn,n),o)}function Hn(e){return e.includes(Yu)||Qu.test(e)}function el(e){return !Hn(e)}function tl(e={}){let t=[],r={...$t,...e},n={append(o){return t.push(o),n},appendUntrusted(o,s){let i=s?{...r,...s}:r;return t.push(Wn(o,i)),n},clear(){return t=[],n},toString(){return t.join("")},get length(){return t.reduce((o,s)=>o+s.length,0)}};return n}function rl(e){let t=[],r=new RegExp(Ut.source,"g");for(let a of e.matchAll(r))t.push(a[0]);let n=new RegExp(Gt.source,"g");for(let a of e.matchAll(n))t.push(a[0]);let o=new RegExp(Kt.source,"g");for(let a of e.matchAll(o))t.push(a[0]);let s=new RegExp(Ft.source,"g");for(let a of e.matchAll(s))t.push(a[0]);let i=new RegExp(zt.source,"g");for(let a of e.matchAll(i))t.push(a[0]);let u=new RegExp(Wt.source,"g");for(let a of e.matchAll(u))t.push(a[0]);return t}function nl(e){let t={csi:[],osc:[],dcs:[],apc:[],sos:[],pm:[],other:[]};for(let r of e.matchAll(new RegExp(Ut.source,"g")))t.csi.push(r[0]);for(let r of e.matchAll(new RegExp(Gt.source,"g")))t.osc.push(r[0]);for(let r of e.matchAll(new RegExp(Kt.source,"g")))t.dcs.push(r[0]);for(let r of e.matchAll(new RegExp(Ft.source,"g")))t.apc.push(r[0]);for(let r of e.matchAll(new RegExp(zt.source,"g")))t.sos.push(r[0]);for(let r of e.matchAll(new RegExp(Wt.source,"g")))t.pm.push(r[0]);return t}function ol(e={}){let t=e.output??process.stdout,r=e.input??process.stdin,n=e.onSuspend,o=e.onResume,s=null,i=null,u=false;function a(f){t.write(f);}function d(){let f=n?.(),S={wasAlternateBuffer:l.isAlternateBuffer,wasMouseEnabled:l.isMouseEnabled,wasRawMode:r.isRaw??false,customState:f};return l.isAlternateBuffer&&a(A.alternateOff()),a(E.show()),l.isMouseEnabled&&a(P.disableAll()),r.setRawMode&&S.wasRawMode&&r.setRawMode(false),r.pause(),S}function c(f){r.resume(),r.setRawMode&&f.wasRawMode&&r.setRawMode(true),f.wasAlternateBuffer&&a(A.alternateOn()),f.wasMouseEnabled&&a(P.enableNormal()),o?.(f);}let l={get enabled(){return u},isAlternateBuffer:e.isAlternateBuffer??false,isMouseEnabled:e.isMouseEnabled??false,enable(){u||(s=()=>{l.suspend();},process.on("SIGTSTP",s),u=true);},disable(){u&&(s&&(process.removeListener("SIGTSTP",s),s=null),i&&(process.removeListener("SIGCONT",i),i=null),u=false);},suspend(f){let S=d();i=()=>{c(S),f&&f();},process.once("SIGCONT",i),process.kill(process.pid,"SIGTSTP");},setAlternateBuffer(f){l.isAlternateBuffer=f;},setMouseEnabled(f){l.isMouseEnabled=f;}};return l}var Ht={prepareForSuspend(e,t){let r="";return e&&(r+=A.alternateOff()),r+=E.show(),t&&(r+=P.disableAll()),r},restoreAfterResume(e,t){let r="";return e&&(r+=A.alternateOn()),t&&(r+=P.enableNormal()),r}};function sl(e){return new Promise(t=>{let r=e.output??process.stdout,n=e.input??process.stdin,o=e.isAlternateBuffer??false,s=e.isMouseEnabled??false,i=n.isRaw??false;r.write(Ht.prepareForSuspend(o,s)),n.setRawMode&&i&&n.setRawMode(false),n.pause();let u=()=>{n.resume(),n.setRawMode&&i&&n.setRawMode(true),r.write(Ht.restoreAfterResume(o,s)),t();};process.once("SIGCONT",u),process.kill(process.pid,"SIGTSTP");})}function il(e,t={}){let r=t.supported??true,n=t.autoSync??false,o=false,s={get supported(){return r},set supported(i){r=i;},get autoSync(){return n},set autoSync(i){n=i;},get inFrame(){return o},beginFrame(){!r||o||(e.write(K.begin()),o=true);},endFrame(){!r||!o||(e.write(K.end()),o=false);},renderFrame(i){s.beginFrame();try{i();}finally{s.endFrame();}},async renderFrameAsync(i){s.beginFrame();try{await i();}finally{s.endFrame();}},writeFrame(i){if(!r){e.write(i);return}e.write(K.wrap(i));},write(i){n&&r&&!o?s.writeFrame(i):e.write(i);},getBeginMarker(){return r?K.begin():""},getEndMarker(){return r?K.end():""}};return s}function al(){return (process.env.TERM??"")==="xterm-kitty"||process.env.KITTY_WINDOW_ID!==void 0}function ul(){let e=process.env.TERM??"";return e==="foot"||e==="foot-extra"}function ll(){return process.env.TERMINAL_VERSION_STRING?.includes("contour")??false}function cl(){return process.env.TERM_PROGRAM==="WezTerm"}function pl(){if(process.env.TERM_PROGRAM!=="iTerm.app")return false;let e=process.env.TERM_PROGRAM_VERSION;if(!e)return false;let t=Number.parseInt(e.split(".")[0]??"0",10),r=Number.parseInt(e.split(".")[1]??"0",10);return t>3||t===3&&r>=5}function dl(){return process.env.TERM_PROGRAM==="mintty"}function fl(){return !!(al()||ul()||ll()||cl()||pl()||dl())}var Vn={name:"xterm-256color",names:["xterm-256color","xterm"],description:"xterm with 256 colors",booleans:{auto_left_margin:false,auto_right_margin:true,back_color_erase:true,has_meta_key:true,move_insert_mode:true,move_standout_mode:true},numbers:{columns:80,lines:24,max_colors:256,max_pairs:65536,init_tabs:8},strings:{cursor_address:"\x1B[%i%p1%d;%p2%dH",cursor_down:`
10
- `,cursor_home:"\x1B[H",cursor_left:"\b",cursor_right:"\x1B[C",cursor_up:"\x1B[A",cursor_invisible:"\x1B[?25l",cursor_normal:"\x1B[?12l\x1B[?25h",cursor_visible:"\x1B[?12;25h",clear_screen:"\x1B[H\x1B[2J",clr_eol:"\x1B[K",clr_eos:"\x1B[J",scroll_forward:`
11
- `,scroll_reverse:"\x1BM",change_scroll_region:"\x1B[%i%p1%d;%p2%dr",insert_line:"\x1B[L",delete_line:"\x1B[M",parm_insert_line:"\x1B[%p1%dL",parm_delete_line:"\x1B[%p1%dM",enter_bold_mode:"\x1B[1m",enter_dim_mode:"\x1B[2m",enter_blink_mode:"\x1B[5m",enter_reverse_mode:"\x1B[7m",enter_standout_mode:"\x1B[7m",enter_underline_mode:"\x1B[4m",exit_attribute_mode:"\x1B(B\x1B[m",exit_standout_mode:"\x1B[27m",exit_underline_mode:"\x1B[24m",set_attributes:"\x1B[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\x1B(0%e\x1B(B%;",set_a_foreground:"\x1B[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",set_a_background:"\x1B[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",orig_pair:"\x1B[39;49m",orig_colors:"\x1B]104\x07",enter_ca_mode:"\x1B[?1049h\x1B[22;0;0t",exit_ca_mode:"\x1B[?1049l\x1B[23;0;0t",keypad_local:"\x1B[?1l\x1B>",keypad_xmit:"\x1B[?1h\x1B=",bell:"\x07",flash_screen:"\x1B[?5h$<100/>\x1B[?5l",insert_character:"\x1B[@",delete_character:"\x1B[P",parm_ich:"\x1B[%p1%d@",parm_dch:"\x1B[%p1%dP",enter_insert_mode:"\x1B[4h",exit_insert_mode:"\x1B[4l",acs_chars:"``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",enter_alt_charset_mode:"\x1B(0",exit_alt_charset_mode:"\x1B(B",tab:" ",back_tab:"\x1B[Z",newline:`
12
- `,carriage_return:"\r",reset_1string:"\x1Bc",init_2string:"\x1B[!p\x1B[?3;4l\x1B[4l\x1B>",repeat_char:"\x1B[%p1%d%p2%c"}};function ml(e){e.params.length>0&&e.params[0]!==void 0&&e.params[0]++,e.params.length>1&&e.params[1]!==void 0&&e.params[1]++;}function gl(e,t){if(e.index++,e.index<t.length){let r=Number.parseInt(t[e.index]??"0",10);e.stack.push(e.params[r-1]??0);}return e.index}function bl(e,t){let r="";for(e.index++;e.index<t.length&&t[e.index]!=="}";)r+=t[e.index],e.index++;return e.stack.push(Number.parseInt(r,10)||0),e.index}function yl(e,t){let r=e.stack.pop()??0,n=e.stack.pop()??0;switch(t){case "+":e.stack.push(n+r);break;case "-":e.stack.push(n-r);break;case "*":e.stack.push(n*r);break;case "/":e.stack.push(r!==0?Math.floor(n/r):0);break;case "m":e.stack.push(r!==0?n%r:0);break;case "=":e.stack.push(n===r?1:0);break;case "<":e.stack.push(n<r?1:0);break;case ">":e.stack.push(n>r?1:0);break}}function Yn(e,t,r){let n=1,o=t;for(;o<e.length&&n>0;)if(o++,e[o]==="%"){if(o++,e[o]==="?")n++;else if(e[o]===";")n--;else if(e[o]==="e"&&n===1&&r)return o}return o}function xl(e,t){return (e.stack.pop()??0)||(e.index=Yn(t,e.index,true)),e.index}function Cl(e,t){return e.index=Yn(t,e.index,false),e.index}function Sl(e,t,r){switch(r){case "%":e.result+="%";break;case "i":ml(e);break;case "p":e.index=gl(e,t);break;case "d":e.result+=String(e.stack.pop()??0);break;case "s":case "c":e.result+=String.fromCharCode(e.stack.pop()??0);break;case "{":e.index=bl(e,t);break;case "+":case "-":case "*":case "/":case "m":case "=":case "<":case ">":yl(e,r);break;case "?":break;case "t":e.index=xl(e,t);break;case "e":e.index=Cl(e,t);break;}}function hl(e,t){let r={stack:[],params:[...t],index:0,result:""};for(;r.index<e.length;){let n=e[r.index];if(n!=="%"){r.result+=n,r.index++;continue}if(r.index++,r.index>=e.length)break;let o=e[r.index];o&&Sl(r,e,o),r.index++;}return r.result}function Vt(e={}){let t=e.terminal??process.env.TERM??"xterm-256color",r=e.data??Vn,n={terminal:t,data:r,has(o){return r.booleans[o]===true},getNumber(o){let s=r.numbers[o];return s!==void 0?s:null},getString(o){let s=r.strings[o];return s!==void 0?s:null},tparm(o,...s){let i=r.strings[o];return i===void 0?null:hl(i,s)},cup(o,s){return n.tparm("cursor_address",o,s)??`\x1B[${o+1};${s+1}H`},sgr(o){return `\x1B[${o}m`},setaf(o){let s=n.tparm("set_a_foreground",o);return s||(o<8?`\x1B[3${o}m`:o<16?`\x1B[9${o-8}m`:`\x1B[38;5;${o}m`)},setab(o){let s=n.tparm("set_a_background",o);return s||(o<8?`\x1B[4${o}m`:o<16?`\x1B[10${o-8}m`:`\x1B[48;5;${o}m`)}};return n}var it=null;function qn(){return it||(it=Vt()),it}function Xn(){it=null;}function jn(){return Vn}var Rl={maxRate:30,debounceMs:150,showIntermediate:true};function El(e,t,r){let n={...Rl,...r},o=false,s$1=process.stdout.columns??80,i=process.stdout.rows??24,u=0,a=null,d=false,c=1e3/n.maxRate;function l(C,g){return !(d||C===s$1&&g===i)}function f$1(C,g,p){if(p-u<c)return;u=p;let I=f(e);I&&s(e,I,C,g),n.showIntermediate&&t(C,g,false);}function S(){a!==null&&clearTimeout(a),a=setTimeout(()=>{if(d)return;o=false,a=null;let C=f(e);C&&s(e,C,s$1,i),t(s$1,i,true),st().emit("resize",{width:s$1,height:i,previousWidth:s$1,previousHeight:i});},n.debounceMs);}function y(){let C=process.stdout.columns??80,g=process.stdout.rows??24;if(!l(C,g))return;o=true,s$1=C,i=g;let p=performance.now();f$1(C,g,p),S();}return process.on("SIGWINCH",y),{world:e,config:n,get isResizing(){return o},get lastWidth(){return s$1},get lastHeight(){return i},dispose(){d=true,process.off("SIGWINCH",y),a!==null&&(clearTimeout(a),a=null);}}}function Tl(e,t){let r=0,n=1e3/t;return((...o)=>{let s=performance.now();s-r>=n&&(r=s,e(...o));})}function vl(e,t){let r=null;return {fn:((...o)=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,e(...o);},t);}),cancel:()=>{r!==null&&(clearTimeout(r),r=null);}}}export{jo as $,Ct as $a,gi as $b,Oa as $c,Ht as $d,sr as A,Ss as Aa,zr as Ab,wt as Ac,yu as Ad,yo as B,Rs as Ba,Wr as Bb,ln as Bc,xu as Bd,xo as C,gr as Ca,ri as Cb,cn as Cc,Cu as Cd,Co as D,Es as Da,ve as Db,pn as Dc,Su as Dd,So as E,gt as Ea,Y as Eb,dn as Ec,kn as Ed,ho as F,br as Fa,ni as Fb,fn as Fc,hu as Fd,Ro as G,yr as Ga,Hr as Gb,mn as Gc,Gu as Gd,Eo as H,xr as Ha,Vr as Hb,gn as Hc,Dt as Hd,To as I,Cr as Ia,Yr as Ib,bn as Ic,Ln as Id,vo as J,Sr as Ja,qr as Jb,xn as Jc,Fu as Jd,Be as K,hr as Ka,Xr as Kb,Cn as Kc,Dn as Kd,Ne as L,bt as La,jr as Lb,Sn as Lc,$n as Ld,ar as M,Rr as Ma,si as Mb,hn as Mc,Un as Md,_o as N,yt as Na,qe as Nb,Rn as Nc,Gn as Nd,Io as O,xt as Oa,ii as Ob,En as Oc,Kn as Od,Ao as P,$e as Pa,me as Pb,Tn as Pc,zu as Pd,wo as Q,Ue as Qa,ne as Qb,vn as Qc,Wu as Qd,Mo as R,Er as Ra,li as Rb,w as Rc,Hu as Rd,Oo as S,Tr as Sa,ci as Sb,Ta as Sc,Vu as Sd,Po as T,vr as Ta,pi as Tb,va as Tc,$t as Td,h as U,_r as Ua,di as Ub,_a as Uc,Wn as Ud,ko as V,Ir as Va,Rt as Vb,Mt as Vc,Hn as Vd,ut as W,Ar as Wa,je as Wb,Ot as Wc,el as Wd,lt as X,wr as Xa,fi as Xb,Pt as Xc,tl as Xd,ct as Y,Mr as Ya,Ze as Yb,kt as Yc,rl as Yd,qo as Z,Or as Za,_e as Zb,In as Zc,nl as Zd,Xo as _,Pr as _a,mi as _b,Ma as _c,ol as _d,Jn as a,Zo as aa,St as ab,bi as ac,Pa as ad,sl as ae,Qn as b,Jo as ba,kr as bb,Qr as bc,ka as bd,il as be,eo as c,Qo as ca,Br as cb,en as cc,Ba as cd,fl as ce,to as d,es as da,_ as db,yi as dc,Na as dd,Vt as de,ro as e,ts as ea,Ks as eb,xi as ec,La as ed,qn as ee,no as f,rs as fa,Fs as fb,Ci as fc,Da as fd,Xn as fe,b as g,ns as ga,zs as gb,Si as gc,$a as gd,jn as ge,E as h,os as ha,te as hb,hi as hc,Ua as hd,El as he,io as i,ss as ia,Ws as ib,Ri as ic,Ga as id,Tl as ie,G as j,ae as ja,Hs as jb,Ei as jc,Ka as jd,vl as je,A as k,pt as ka,Vs as kb,Ti as kc,Fa as kd,ao as l,Ee as la,Ys as lb,Ae as lc,za as ld,R as m,Te as ma,Ke as mb,Je as mc,Wa as md,P as n,he as na,Fe as nb,Et as nc,Ha as nd,K as o,le as oa,ze as ob,Hi as oc,Va as od,ke as p,Re as pa,We as pb,oa as pc,Ya as pd,Q as q,cr as qa,He as qb,Qe as qc,tu as qd,nr as r,dt as ra,re as rb,ia as rc,ru as rd,ie as s,ft as sa,pe as sb,aa as sc,nu as sd,uo as t,pr as ta,de as tb,ga as tc,wn as td,po as u,mt as ua,fe as ub,et as uc,iu as ud,fo as v,dr as va,Ve as vb,on as vc,au as vd,mo as w,fr as wa,ei as wb,sn as wc,Pn as wd,go as x,De as xa,ti as xb,an as xc,gu as xd,bo as y,xs as ya,Kr as yb,At as yc,st as yd,or as z,Cs as za,Fr as zb,un as zc,bu as zd};
@@ -1 +0,0 @@
1
- import {i as i$1,a as a$1,b,c,e}from'./chunk-Z4EZERNE.js';import {f as f$1,a,e as e$1}from'./chunk-SHUC6JWA.js';import {k as k$1,g as g$1,l}from'./chunk-G7GIWWLE.js';import {n,i as i$2,h as h$1}from'./chunk-PXXGH3BV.js';n();f$1();f$1();var m=1e4,Y=a(255,255,255),L=a(0,0,0,0),r={visible:new Uint8Array(m),dirty:new Uint8Array(m),fg:new Uint32Array(m),bg:new Uint32Array(m),bold:new Uint8Array(m),underline:new Uint8Array(m),blink:new Uint8Array(m),inverse:new Uint8Array(m),transparent:new Uint8Array(m),opacity:new Uint8Array(m)};function M(t){r.visible[t]=1,r.dirty[t]=1,r.fg[t]=Y,r.bg[t]=L,r.bold[t]=0,r.underline[t]=0,r.blink[t]=0,r.inverse[t]=0,r.transparent[t]=0,r.opacity[t]=255;}function O(t,n){i$2(t,n,r)||(h$1(t,n,r),M(n));}function fn(t,n,e){return i$1.parse(e),O(t,n),j(n,e),r.dirty[n]=1,n}function G(t,n){n.fg!==void 0&&(r.fg[t]=e$1(n.fg)),n.bg!==void 0&&(r.bg[t]=e$1(n.bg));}function g(t,n,e){e!==void 0&&(n[t]=e?1:0);}function $(t,n){if(g(t,r.bold,n.bold),g(t,r.underline,n.underline),g(t,r.blink,n.blink),g(t,r.inverse,n.inverse),g(t,r.transparent,n.transparent),n.opacity!==void 0){let e=Math.max(0,Math.min(1,n.opacity));r.opacity[t]=Math.round(e*255);}}function j(t,n){G(t,n),$(t,n);}function sn(t,n){if(i$2(t,n,r))return {fg:r.fg[n],bg:r.bg[n],bold:r.bold[n]===1,underline:r.underline[n]===1,blink:r.blink[n]===1,inverse:r.inverse[n]===1,transparent:r.transparent[n]===1,opacity:r.opacity[n]/255}}function ln(t,n){if(i$2(t,n,r))return {visible:r.visible[n]===1,dirty:r.dirty[n]===1,fg:r.fg[n],bg:r.bg[n],bold:r.bold[n]===1,underline:r.underline[n]===1,blink:r.blink[n]===1,inverse:r.inverse[n]===1,transparent:r.transparent[n]===1,opacity:r.opacity[n]/255}}function cn(t,n){return O(t,n),r.dirty[n]=1,n}function bn(t,n){return i$2(t,n,r)&&(r.dirty[n]=0),n}function yn(t,n){return i$2(t,n,r)?r.dirty[n]===1:false}function H(t,n,e){O(t,n);let o=r.visible[n]===1;return r.visible[n]=e?1:0,o!==e&&(r.dirty[n]=1),n}function k(t,n){return i$2(t,n,r)?r.visible[n]===1:false}function mn(t,n){return i$2(t,n,r)}function pn(t,n){return H(t,n,true)}function xn(t,n){return H(t,n,false)}function En(t,n){let e=k(t,n);return H(t,n,!e)}function hn(t,n){if(!k(t,n))return false;if(!k$1(t,n))return true;let e=g$1(t,n);for(let o of e)if(!k(t,o))return false;return true}function gn(t,n){if(!k$1(t,n)||l(t,n))return false;let e=g$1(t,n);if(e.length===0)return true;let o=e[e.length-1];return o===void 0?true:!l(t,o)}n();var F=1e4,i={x:new Float32Array(F),y:new Float32Array(F),z:new Uint16Array(F),absolute:new Uint8Array(F)};function An(t,n,e,o,s=0){return a$1.parse({x:e,y:o,z:s}),i$2(t,n,i)||(h$1(t,n,i),i.absolute[n]=0),i.x[n]=e,i.y[n]=o,i.z[n]=s,n}function Dn(t,n){if(i$2(t,n,i))return {x:i.x[n],y:i.y[n],z:i.z[n],absolute:i.absolute[n]===1}}function vn(t,n,e){return i$2(t,n,i)||(h$1(t,n,i),i.x[n]=0,i.y[n]=0,i.z[n]=0),i.absolute[n]=e?1:0,n}function Tn(t,n){return i$2(t,n,i)?i.absolute[n]===1:false}function Sn(t,n){return i$2(t,n,i)}function Cn(t,n,e,o){return i$2(t,n,i)||(h$1(t,n,i),i.x[n]=0,i.y[n]=0,i.z[n]=0,i.absolute[n]=0),i.x[n]=i.x[n]+e,i.y[n]=i.y[n]+o,n}function h(t,n,e){return b.parse(e),i$2(t,n,i)||(h$1(t,n,i),i.x[n]=0,i.y[n]=0,i.absolute[n]=0),i.z[n]=e,n}function A(t,n){return i$2(t,n,i)?i.z[n]:0}function Un(t,n,e){let o=0;for(let l of e)if(l!==n&&i$2(t,l,i)){let c=i.z[l];c>o&&(o=c);}let s=Math.min(o+1,65535);return h(t,n,s)}function kn(t,n,e){let o=65535;for(let l of e)if(l!==n&&i$2(t,l,i)){let c=i.z[l];c<o&&(o=c);}let s=Math.max(o-1,0);return h(t,n,s)}function On(t,n,e){let o=A(t,n),s=65535,l=false;for(let c of e)if(c!==n&&i$2(t,c,i)){let x=i.z[c];x>o&&x<s&&(s=x,l=true);}return l?h(t,n,Math.min(s+1,65535)):n}function Hn(t,n,e){let o=A(t,n),s=0,l=false;for(let c of e)if(c!==n&&i$2(t,c,i)){let x=i.z[c];x<o&&x>s&&(s=x,l=true);}return l?h(t,n,Math.max(s-1,0)):n}function zn(t,n){let e=[];for(let o of n)i$2(t,o,i)&&e.push({entity:o,z:i.z[o]});e.sort((o,s)=>o.z-s.z);for(let o=0;o<e.length;o++){let s=e[o];s&&(i.z[s.entity]=o);}}function Nn(t,n,e){let o=A(t,n),s=A(t,e);h(t,n,s),h(t,e,o);}n();var E=1e4,p=-1;function q(t){return -(t+2)}function w(t){if(t>=p)return null;let n=-(t+2);return n===0?0:n}function Bn(t){return t<p}var u={width:new Float32Array(E),height:new Float32Array(E),minWidth:new Float32Array(E),minHeight:new Float32Array(E),maxWidth:new Float32Array(E),maxHeight:new Float32Array(E),shrink:new Uint8Array(E)};function B(t){if(t==="auto")return p;if(typeof t=="string"){let n=Number.parseFloat(t);return q(n)}return t}function wn(t,n,e,o){return c.parse(e),c.parse(o),i$2(t,n,u)||(h$1(t,n,u),u.minWidth[n]=0,u.minHeight[n]=0,u.maxWidth[n]=Number.POSITIVE_INFINITY,u.maxHeight[n]=Number.POSITIVE_INFINITY,u.shrink[n]=0),u.width[n]=B(e),u.height[n]=B(o),n}function Zn(t,n){if(i$2(t,n,u))return {width:u.width[n],height:u.height[n],minWidth:u.minWidth[n],minHeight:u.minHeight[n],maxWidth:u.maxWidth[n],maxHeight:u.maxHeight[n],shrink:u.shrink[n]===1}}function Rn(t,n,e$1){return e.parse(e$1),i$2(t,n,u)||(h$1(t,n,u),u.width[n]=p,u.height[n]=p,u.minWidth[n]=0,u.minHeight[n]=0,u.maxWidth[n]=Number.POSITIVE_INFINITY,u.maxHeight[n]=Number.POSITIVE_INFINITY,u.shrink[n]=0),e$1.minWidth!==void 0&&(u.minWidth[n]=e$1.minWidth),e$1.minHeight!==void 0&&(u.minHeight[n]=e$1.minHeight),e$1.maxWidth!==void 0&&(u.maxWidth[n]=e$1.maxWidth),e$1.maxHeight!==void 0&&(u.maxHeight[n]=e$1.maxHeight),n}function Yn(t,n,e){return i$2(t,n,u)||(h$1(t,n,u),u.width[n]=p,u.height[n]=p,u.minWidth[n]=0,u.minHeight[n]=0,u.maxWidth[n]=Number.POSITIVE_INFINITY,u.maxHeight[n]=Number.POSITIVE_INFINITY),u.shrink[n]=e?1:0,n}function Ln(t,n){return i$2(t,n,u)?u.shrink[n]===1:false}function Mn(t,n){return i$2(t,n,u)}function Gn(t,n,e){if(!i$2(t,n,u))return;let o=u.width[n];if(o===p)return;let s=w(o);return s!==null?s/100*e:o}function $n(t,n,e){if(!i$2(t,n,u))return;let o=u.height[n];if(o===p)return;let s=w(o);return s!==null?s/100*e:o}n();var d=1e4,J=4294967295,K=0,f={focusable:new Uint8Array(d),focused:new Uint8Array(d),tabIndex:new Int16Array(d),focusEffectFg:new Uint32Array(d),focusEffectBg:new Uint32Array(d)},y=null;function Q(t){f.focusable[t]=1,f.focused[t]=0,f.tabIndex[t]=0,f.focusEffectFg[t]=J,f.focusEffectBg[t]=K;}function D(t,n){i$2(t,n,f)||(h$1(t,n,f),Q(n));}function Jn(t,n,e){return D(t,n),e.focusable!==void 0&&(f.focusable[n]=e.focusable?1:0),e.tabIndex!==void 0&&(f.tabIndex[n]=e.tabIndex),e.focusEffectFg!==void 0&&(f.focusEffectFg[n]=e.focusEffectFg),e.focusEffectBg!==void 0&&(f.focusEffectBg[n]=e.focusEffectBg),n}function Kn(t,n,e){return D(t,n),f.focusable[n]=e?1:0,n}function Qn(t,n){return i$2(t,n,f)?f.focused[n]===1:false}function Xn(t,n){return i$2(t,n,f)?f.focusable[n]===1:false}function Z(t,n){return D(t,n),f.focusable[n]!==1||(y!==null&&y!==n&&i$2(t,y,f)&&(f.focused[y]=0),f.focused[n]=1,y=n),n}function nt(t,n){return i$2(t,n,f)&&(f.focused[n]=0,y===n&&(y=null)),n}function tt(t,n){if(i$2(t,n,f))return {focusable:f.focusable[n]===1,focused:f.focused[n]===1,tabIndex:f.tabIndex[n],focusEffectFg:f.focusEffectFg[n],focusEffectBg:f.focusEffectBg[n]}}function et(t,n){return i$2(t,n,f)}function rt(){return y}function ot(t,n,e){return D(t,n),f.tabIndex[n]=e,n}function it(t,n){return i$2(t,n,f)?f.tabIndex[n]:-1}function X(t,n){return i$2(t,n,f)?f.tabIndex[n]>=0&&f.focusable[n]===1:false}function R(t,n){return n.filter(e=>X(t,e)).sort((e,o)=>f.tabIndex[e]-f.tabIndex[o])}function ut(t,n){let e=R(t,n);if(e.length===0)return null;let s=((y!==null?e.indexOf(y):-1)+1)%e.length,l=e[s];return l!==void 0?(Z(t,l),l):null}function at(t,n){let e=R(t,n);if(e.length===0)return null;let s=((y!==null?e.indexOf(y):0)-1+e.length)%e.length,l=e[s];return l!==void 0?(Z(t,l),l):null}function ft(){y=null;}export{nt as $,Un as A,kn as B,On as C,Hn as D,zn as E,Nn as F,p as G,q as H,w as I,Bn as J,u as K,wn as L,Zn as M,Rn as N,Yn as O,Ln as P,Mn as Q,Gn as R,$n as S,J as T,K as U,f as V,Jn as W,Kn as X,Qn as Y,Xn as Z,Z as _,Y as a,tt as aa,L as b,et as ba,r as c,rt as ca,fn as d,ot as da,sn as e,it as ea,ln as f,X as fa,cn as g,R as ga,bn as h,ut as ha,yn as i,at as ia,H as j,ft as ja,k,mn as l,pn as m,xn as n,En as o,hn as p,gn as q,i as r,An as s,Dn as t,vn as u,Tn as v,Sn as w,Cn as x,h as y,A as z};
@@ -1,4 +0,0 @@
1
- var W=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\].*?\x1b\\|\x1b\][^\x07]*\x07/g,m=/^\x1b\[[0-9;]*[a-zA-Z]/;function h(n){return n.replace(W,"")}function c(n){return h(n).length}function d(n,r){let i=n.slice(r).match(m);return i?{code:i[0],length:i[0].length}:null}function x(n,r,t="\u2026"){if(r<=0)return "";if(h(n).length<=r)return n;let e=c(t),s=r-e;if(s<=0)return t.slice(0,r);let o="",u=0,a=0;for(;u<s&&a<n.length;){let f=n[a];if(f==="\x1B"){let l=d(n,a);if(l){o+=l.code,a+=l.length;continue}}o+=f,u++,a++;}return o.includes("\x1B[")&&(o+="\x1B[0m"),o+t}function g(n,r,t){let i=c(n);if(i>=r)return n;let e=r-i;switch(t){case "left":return n+" ".repeat(e);case "right":return " ".repeat(e)+n;case "center":{let s=Math.floor(e/2),o=e-s;return " ".repeat(s)+n+" ".repeat(o)}}}function A(n){let r={result:[],current:"",inAnsi:false};for(let t=0;t<n.length;t++){let i=n[t];i!==void 0&&w(r,i);}return b(r),r.result}function P(n,r){let t=[],i=n;for(;c(i)>r;){let e=y(i,r);t.push(i.slice(0,e)),i=i.slice(e);}return i.length>0&&t.push(i),t}function S(n,r){if(r<=0)return [""];let t=[],i=n.split(`
2
- `);for(let e of i){if(e.length===0){t.push("");continue}let s=k(e,r);t.push(...s);}return t}function k(n,r){let t={lines:[],currentLine:"",currentWidth:0},i=A(n);for(let e of i){if(T(e)){z(t,r);continue}let s=c(e);if(E(t,s,r)){M(t,e,s);continue}if(s<=r){p(t),C(t,e,s);continue}p(t);let o=I(e,r);t.lines.push(...o.lines),t.currentLine=o.tail.text,t.currentWidth=o.tail.width;}return p(t),t.lines}function L(n,r){let t=[],i=n.split(`
3
- `);for(let e of i){if(e.length===0){t.push("");continue}let s=v(e,r);t.push(...s);}return t}function v(n,r){let t=[],i=n;for(;c(i)>r;){let e=Z(i,r);t.push(i.slice(0,e)),i=i.slice(e);}return i.length>0&&t.push(i),t}function w(n,r){if(r==="\x1B"){n.inAnsi=true,n.current+=r;return}if(n.inAnsi){n.current+=r,/[a-zA-Z\\]/.test(r)&&(n.inAnsi=false);return}if(r===" "||r===" "){b(n),n.result.push(r);return}n.current+=r;}function b(n){n.current.length>0&&(n.result.push(n.current),n.current="");}function y(n,r){let t=0,i=0;for(let e=0;e<n.length;e++){let s=n[e];if(s!==void 0){if(s==="\x1B"){let o=d(n,e);if(o){t=e+o.length;continue}}if(i>=r)break;t=e+1,i++;}}return t===0?Math.min(n.length,1):t}function T(n){return n===" "||n===" "}function z(n,r){n.currentWidth+1<=r&&(n.currentLine+=" ",n.currentWidth+=1);}function E(n,r,t){return n.currentWidth+r<=t}function M(n,r,t){n.currentLine+=r,n.currentWidth+=t;}function p(n){n.currentLine.length>0&&(n.lines.push(n.currentLine.trimEnd()),n.currentLine="",n.currentWidth=0);}function C(n,r,t){n.currentLine=r,n.currentWidth=t;}function I(n,r){let t=P(n,r),i=t.slice(0,Math.max(0,t.length-1)),e=t[t.length-1]??"";return {lines:i,tail:{text:e,width:c(e)}}}function Z(n,r){let t=0,i=0,e=false;for(let s=0;s<n.length&&i<r;s++){let o=n[s];if(o!==void 0){if(o==="\x1B"){e=true;continue}if(e){/[a-zA-Z\\]/.test(o)&&(e=false);continue}i++,t=s+1;}}return t===0?Math.min(n.length,1):t}function B(n,r){let{width:t,wrap:i=true,align:e="left",breakWord:s=false}=r;return t<=0?[""]:i?(s?L(n,t):S(n,t)).map(u=>g(u,t,e)):n.split(`
4
- `).map(u=>c(u)>t?x(u,t):g(u,t,e))}function O(n,r,t,i="top"){if(n.length>=r)return n.slice(0,r);let e=" ".repeat(t),s=r-n.length;switch(i){case "top":return [...n,...Array(s).fill(e)];case "bottom":return [...Array(s).fill(e),...n];case "middle":{let o=Math.floor(s/2),u=s-o;return [...Array(o).fill(e),...n,...Array(u).fill(e)]}}}export{h as a,c as b,x as c,g as d,S as e,B as f,O as g};