blecsd 0.1.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 (109) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +220 -0
  3. package/dist/3d/index.d.ts +5 -0
  4. package/dist/3d/index.js +1 -0
  5. package/dist/audio/index.d.ts +177 -0
  6. package/dist/audio/index.js +1 -0
  7. package/dist/border-D_Jb4ZJV.d.ts +257 -0
  8. package/dist/cell-DwIu2ryP.d.ts +505 -0
  9. package/dist/chunk-2UBBZFE4.js +1 -0
  10. package/dist/chunk-35LCBY6P.js +1 -0
  11. package/dist/chunk-3B7MIVW6.js +1 -0
  12. package/dist/chunk-3EGGGI5J.js +3 -0
  13. package/dist/chunk-4LWWONFK.js +1 -0
  14. package/dist/chunk-4X4N4HNQ.js +2 -0
  15. package/dist/chunk-5PELJRUQ.js +1 -0
  16. package/dist/chunk-AEJIX2MW.js +1 -0
  17. package/dist/chunk-AQ7LW75B.js +1 -0
  18. package/dist/chunk-AXZQAH4X.js +1 -0
  19. package/dist/chunk-B6Z2JFRY.js +1 -0
  20. package/dist/chunk-BCADUCOZ.js +1 -0
  21. package/dist/chunk-C5PCEQ6G.js +1 -0
  22. package/dist/chunk-CIK4AMUA.js +1 -0
  23. package/dist/chunk-DNRXW56C.js +1 -0
  24. package/dist/chunk-FC5FFAAC.js +12 -0
  25. package/dist/chunk-FGHEFXLK.js +1 -0
  26. package/dist/chunk-FYEBZAWN.js +1 -0
  27. package/dist/chunk-G7GIWWLE.js +1 -0
  28. package/dist/chunk-GYHI26UE.js +1 -0
  29. package/dist/chunk-H2YAOJDW.js +1 -0
  30. package/dist/chunk-J4JZ2NU2.js +1 -0
  31. package/dist/chunk-JKVHO4LH.js +1 -0
  32. package/dist/chunk-K2B2OXQ5.js +5 -0
  33. package/dist/chunk-K37L3G4Z.js +4 -0
  34. package/dist/chunk-KD55INV7.js +1 -0
  35. package/dist/chunk-KFAK4A3G.js +1 -0
  36. package/dist/chunk-LCN2ZITE.js +1 -0
  37. package/dist/chunk-LYSK5S63.js +1 -0
  38. package/dist/chunk-NZ55KBM6.js +1 -0
  39. package/dist/chunk-OMMJ7B5P.js +1 -0
  40. package/dist/chunk-OUXUPF3V.js +33 -0
  41. package/dist/chunk-OVT2PPGW.js +19 -0
  42. package/dist/chunk-P6CJO3BC.js +1 -0
  43. package/dist/chunk-PSXXMBVJ.js +1 -0
  44. package/dist/chunk-PXXGH3BV.js +1 -0
  45. package/dist/chunk-QIKIOVP2.js +1 -0
  46. package/dist/chunk-SHUC6JWA.js +1 -0
  47. package/dist/chunk-TDXJDLY6.js +6 -0
  48. package/dist/chunk-TWSWTBYL.js +1 -0
  49. package/dist/chunk-TYMY2TBR.js +3 -0
  50. package/dist/chunk-VNZ6CWJA.js +2 -0
  51. package/dist/chunk-VOCM5T2G.js +5 -0
  52. package/dist/chunk-W5OU7Z6J.js +1 -0
  53. package/dist/chunk-WNG4A3K7.js +4 -0
  54. package/dist/chunk-XQIGERNI.js +1 -0
  55. package/dist/chunk-XZA63ZPO.js +1 -0
  56. package/dist/chunk-YAMOSPWB.js +4 -0
  57. package/dist/chunk-YD6ULIUR.js +1 -0
  58. package/dist/chunk-Z4EZERNE.js +1 -0
  59. package/dist/cli/init.d.ts +86 -0
  60. package/dist/cli/init.js +179 -0
  61. package/dist/color-B78w3zH-.d.ts +79 -0
  62. package/dist/components/index.d.ts +10298 -0
  63. package/dist/components/index.js +1 -0
  64. package/dist/core/index.d.ts +6700 -0
  65. package/dist/core/index.js +1 -0
  66. package/dist/debug/index.d.ts +711 -0
  67. package/dist/debug/index.js +1 -0
  68. package/dist/doubleBuffer-CKQFmlPN.d.ts +95 -0
  69. package/dist/errors/index.d.ts +1110 -0
  70. package/dist/errors/index.js +1 -0
  71. package/dist/events-BbbxkgvX.d.ts +125 -0
  72. package/dist/game/index.d.ts +486 -0
  73. package/dist/game/index.js +1 -0
  74. package/dist/gameLoop-BIPW7-OY.d.ts +219 -0
  75. package/dist/index-zSGJ2eUk.d.ts +3156 -0
  76. package/dist/index.d.ts +246 -0
  77. package/dist/index.js +1 -0
  78. package/dist/input/index.d.ts +158 -0
  79. package/dist/input/index.js +1 -0
  80. package/dist/inputActions-CefRUBuT.d.ts +2637 -0
  81. package/dist/keyParser-Bwm8-l7v.d.ts +229 -0
  82. package/dist/mouseParser-Cfrbn3AX.d.ts +177 -0
  83. package/dist/parser-iMHmQuUh.d.ts +265 -0
  84. package/dist/program-BZaKqDKH.d.ts +141 -0
  85. package/dist/renderable-jTMOA-GK.d.ts +302 -0
  86. package/dist/scheduler-DcfoFuum.d.ts +86 -0
  87. package/dist/schemas/index.d.ts +936 -0
  88. package/dist/schemas/index.js +1 -0
  89. package/dist/systems/index.d.ts +4036 -0
  90. package/dist/systems/index.js +1 -0
  91. package/dist/terminal/index.d.ts +7357 -0
  92. package/dist/terminal/index.js +1 -0
  93. package/dist/terminus-14-bold-HWSPRLJD.js +1 -0
  94. package/dist/terminus-14-normal-T3SWMH4D.js +1 -0
  95. package/dist/tilemap-D1HJvKy3.d.ts +1211 -0
  96. package/dist/types-BcsvoKzf.d.ts +68 -0
  97. package/dist/utils/index.d.ts +6104 -0
  98. package/dist/utils/index.js +1 -0
  99. package/dist/viewport3d-xI33-_wq.d.ts +182 -0
  100. package/dist/virtualScrollback-DvZTRU8a.d.ts +274 -0
  101. package/dist/virtualViewport-Dx2iJliO.d.ts +2334 -0
  102. package/dist/virtualizedLineStore-DwPEvPkk.d.ts +297 -0
  103. package/dist/widgets/bigText.d.ts +230 -0
  104. package/dist/widgets/bigText.js +1 -0
  105. package/dist/widgets/fonts/index.d.ts +211 -0
  106. package/dist/widgets/fonts/index.js +1 -0
  107. package/dist/widgets/index.d.ts +8591 -0
  108. package/dist/widgets/index.js +1 -0
  109. package/package.json +213 -0
@@ -0,0 +1,4 @@
1
+ import {f as f$2,e as e$1}from'./chunk-AEJIX2MW.js';import {e,f as f$4,k as k$2,c,b as b$1}from'./chunk-C5PCEQ6G.js';import {f as f$3,e as e$2,g as g$1,j}from'./chunk-TYMY2TBR.js';import {b,k as k$1,d as d$1,f as f$1}from'./chunk-KFAK4A3G.js';import {g}from'./chunk-W5OU7Z6J.js';import {q as q$1,p as p$1}from'./chunk-Z4EZERNE.js';import {z as z$1}from'zod';var mt="> ",gt=" ",pt=4294967295,dt=6750207,yt=3435973887,ht=255,xt=1717987071,S=1e4,i={isList:new Uint8Array(S),selectedIndex:new Int32Array(S).fill(-1),itemCount:new Uint32Array(S),firstVisible:new Uint32Array(S),visibleCount:new Uint32Array(S),interactive:new Uint8Array(S),mouse:new Uint8Array(S),keys:new Uint8Array(S),searchEnabled:new Uint8Array(S),totalCount:new Uint32Array(S),isLoading:new Uint8Array(S)},p=new Map,P=new Map,H=new Map,J=new Map,Xt="Loading...",V=new Map,k=new Map,D=new Map,I=new Map,M=new Map,Vt={initial:"idle",states:{idle:{on:{focus:"focused",disable:"disabled"}},focused:{on:{blur:"idle",startSelect:"selecting",startSearch:"searching",disable:"disabled"}},selecting:{on:{endSelect:"focused",blur:"idle",disable:"disabled"}},searching:{on:{endSearch:"focused",blur:"idle",disable:"disabled"}},disabled:{on:{enable:"idle"}}}};function tn(e,t,n=[],r={}){z$1.array(q$1).parse(n),p$1.parse(r),i.isList[t]=1,i.selectedIndex[t]=r.selectedIndex??-1,i.itemCount[t]=n.length,i.firstVisible[t]=0,i.visibleCount[t]=r.visibleCount??n.length,i.interactive[t]=r.interactive!==false?1:0,i.mouse[t]=r.mouse!==false?1:0,i.keys[t]=r.keys!==false?1:0,i.searchEnabled[t]=r.search===true?1:0,p.set(t,[...n]),b(e,t,Vt);}function G(e,t){return i.isList[t]===1&&k$1(e,t)}function Et(e,t){return d$1(e,t)??"idle"}function Ct(e,t,n){return Et(e,t)===n}function en(e,t){let n=Et(e,t);return n==="focused"||n==="selecting"}function Pt(e,t){return Ct(e,t,"disabled")}function U(e,t,n){if(!G(e,t))return false;let r=f$1(e,t,n);return r&&g(e,t),r}function nn(e,t){return U(e,t,"focus")}function rn(e,t){return U(e,t,"blur")}function on(e,t){return U(e,t,"disable")}function ln(e,t){return U(e,t,"enable")}function sn(e){return p.get(e)??[]}function an(e,t,n){p.set(t,[...n]),i.itemCount[t]=n.length,(i.selectedIndex[t]??-1)>=n.length&&(i.selectedIndex[t]=n.length>0?n.length-1:-1),(i.firstVisible[t]??0)>=n.length&&(i.firstVisible[t]=Math.max(0,n.length-1)),g(e,t);}function cn(e,t,n,r){let o=p.get(t)??[],l=r??o.length;o.splice(l,0,n),p.set(t,o),i.itemCount[t]=o.length;let s=i.selectedIndex[t]??-1;s>=0&&l<=s&&(i.selectedIndex[t]=s+1),g(e,t);}function un(e,t,n){let r=p.get(t)??[];if(n<0||n>=r.length)return;let o=r.splice(n,1)[0];i.itemCount[t]=r.length;let l=i.selectedIndex[t]??-1;return l>=0&&(n<l?i.selectedIndex[t]=l-1:n===l&&(i.selectedIndex[t]=r.length>0?Math.min(n,r.length-1):-1)),g(e,t),o}function w(e,t){return p.get(e)?.[t]}function fn(e,t,n,r){let o=p.get(t);return !o||n<0||n>=o.length?false:(o[n]=r,g(e,t),true)}function bn(e){return i.itemCount[e]??0}function mn(e,t){p.set(t,[]),i.itemCount[t]=0,i.selectedIndex[t]=-1,i.firstVisible[t]=0,g(e,t);}function gn(e){return i.selectedIndex[e]??-1}function pn(e){let t=i.selectedIndex[e]??-1;if(!(t<0))return w(e,t)}function Yt(e,t,n){return t<-1||t>=n?false:t<0?true:!w(e,t)?.disabled}function Nt(e,t){if(t<0)return;let n=w(e,t);if(!n)return;let r=k.get(e);if(r)for(let o of r)o(t,n);}function L(e,t,n){let r=i.itemCount[t]??0,o=i.selectedIndex[t]??-1;return !Yt(t,n,r)||o===n?false:(i.selectedIndex[t]=n,g(e,t),Nt(t,n),Ot(e,t,n),true)}function dn(e,t,n=true){let r=i.itemCount[t]??0;if(r===0)return false;let o=i.selectedIndex[t]??-1,l=o;do{if(o--,o<0)if(n)o=r-1;else return false;if(!w(t,o)?.disabled)return L(e,t,o)}while(o!==l);return false}function yn(e,t,n=true){let r=i.itemCount[t]??0;if(r===0)return false;let o=i.selectedIndex[t]??-1,l=o;do{if(o++,o>=r)if(n)o=0;else return false;if(!w(t,o)?.disabled)return L(e,t,o)}while(o!==l);return false}function hn(e,t){let n=i.itemCount[t]??0;for(let r=0;r<n;r++)if(!w(t,r)?.disabled)return L(e,t,r);return false}function xn(e,t){let n=i.itemCount[t]??0;for(let r=n-1;r>=0;r--)if(!w(t,r)?.disabled)return L(e,t,r);return false}function En(e,t,n){let o=(p.get(t)??[]).findIndex(l=>l.value===n);return o>=0?L(e,t,o):false}function Cn(e,t){L(e,t,-1);}function Sn(e,t){let n=i.selectedIndex[t]??-1;if(n<0)return false;let r=w(t,n);if(!r||r.disabled)return false;let o=D.get(t);if(o)for(let l of o)l(n,r);return true}function vn(e){return i.firstVisible[e]??0}function Z(e,t,n){let r=i.itemCount[t]??0,o=i.totalCount[t]??r,l=Math.max(0,Math.max(r,o)-1),s=Math.max(0,Math.min(n,l));i.firstVisible[t]=s,g(e,t),zt(t);}function Ln(e){return i.visibleCount[e]??0}function Tn(e,t,n){i.visibleCount[t]=Math.max(1,n),g(e,t);}function Ot(e,t,n){if(n<0)return;let r=i.firstVisible[t]??0,o=i.visibleCount[t]??0,l=r+o-1;n<r?Z(e,t,n):n>l&&Z(e,t,n-o+1);}function An(e,t,n){let r=i.firstVisible[t]??0,o=i.visibleCount[t]??0,l=i.itemCount[t]??0,s=r+n*o;if(s<0||s>=l)return false;Z(e,t,s);let c=i.selectedIndex[t]??-1;if(c>=0){let b=c+n*o;L(e,t,Math.max(0,Math.min(b,l-1)));}return true}function Ht(e){let t=p.get(e)??[],n=i.firstVisible[e]??0,r=i.visibleCount[e]??t.length,o=[];for(let l=0;l<r&&n+l<t.length;l++){let s=n+l,c=t[s];c&&o.push({index:s,item:c});}return o}function In(e,t,n){i.totalCount[t]=n,g(e,t);}function Gt(e){let t=i.totalCount[e]??0;return t===0?i.itemCount[e]??0:t}function wn(e,t){P.set(e,t);}function Bn(e){return P.get(e)}function Wn(e){P.delete(e);}function Fn(e,t){let n=H.get(e);return n||(n=new Set,H.set(e,n)),n.add(t),()=>{n?.delete(t);}}function zt(e,t){let n=H.get(e);if(!n||n.size===0)return;let r=i.firstVisible[e]??0,o=i.visibleCount[e]??0,l=i.itemCount[e]??0,s=i.totalCount[e]??l,c=o,b={firstVisible:r,visibleCount:o,loadedCount:l,totalCount:s,nearEnd:r+o>=l-c,nearStart:r<=c};for(let g of n)g(b);}function bt(e,t,n){i.isLoading[t]=n?1:0,g(e,t);}function kn(e){return i.isLoading[e]===1}function Dn(e,t){J.set(e,t);}function Mn(e){return J.get(e)??Xt}async function Un(e,t,n,r){let o=P.get(t);if(o&&i.isLoading[t]!==1){bt(e,t,true);try{let l=await o(n,r),s=p.get(t)??[];for(;s.length<n+l.length;)s.push({text:"",disabled:!0});for(let c=0;c<l.length;c++){let b=l[c];b&&(s[n+c]=b);}p.set(t,s),i.itemCount[t]=s.length,g(e,t);}finally{bt(e,t,false);}}}function Rn(e){let t=i.firstVisible[e]??0,n=i.visibleCount[e]??0,r=i.totalCount[e]??0,o=p.get(e)??[],l=Math.min(t+n,r);for(let s=t;s<l;s++){let c=o[s];if(!c||c.text==="")return {needsLoad:true,startIndex:t,count:n}}return {needsLoad:false,startIndex:0,count:0}}function _n(e,t){let n=i.firstVisible[e]??0,r=i.visibleCount[e]??0,o=i.itemCount[e]??0,l=Gt(e),s=t??r;return {firstVisible:n,visibleCount:r,loadedCount:o,totalCount:l,nearEnd:n+r>=o-s,nearStart:n<=s}}function Xn(e,t,n){let r=p.get(t)??[];r.push(...n),p.set(t,r),i.itemCount[t]=r.length,g(e,t);}function Vn(e,t){let n=V.get(e);V.set(e,{selectedPrefix:t.selectedPrefix??n?.selectedPrefix??mt,unselectedPrefix:t.unselectedPrefix??n?.unselectedPrefix??gt,selectedFg:t.selectedFg??n?.selectedFg??pt,selectedBg:t.selectedBg??n?.selectedBg??dt,itemFg:t.itemFg??n?.itemFg??yt,itemBg:t.itemBg??n?.itemBg??ht,disabledFg:t.disabledFg??n?.disabledFg??xt});}function Kt(e){return V.get(e)??{selectedPrefix:mt,unselectedPrefix:gt,selectedFg:pt,selectedBg:dt,itemFg:yt,itemBg:ht,disabledFg:xt}}function Pn(e){V.delete(e);}function Yn(e){return i.interactive[e]===1}function Nn(e,t,n){i.interactive[t]=n?1:0,g(e,t);}function On(e){return i.mouse[e]===1}function Hn(e,t,n){i.mouse[t]=n?1:0,g(e,t);}function Qt(e){return i.keys[e]===1}function Gn(e,t,n){i.keys[t]=n?1:0,g(e,t);}function jt(e){return i.searchEnabled[e]===1}function zn(e,t,n){i.searchEnabled[t]=n?1:0,g(e,t);}function $t(e,t){return Ct(e,t,"searching")}function Kn(e,t){if(!G(e,t)||!jt(t))return false;let n=U(e,t,"startSearch");return n&&I.set(t,""),n}function Qn(e,t){if(!G(e,t))return false;let n=U(e,t,"endSearch");return n&&I.delete(t),n}function jn(e){return I.get(e)??""}function q(e,t,n){I.set(t,n),g(e,t);let r=M.get(t);if(r)for(let o of r)o(n);return n.length>0?Zt(e,t,n):false}function $n(e,t,n){let r=I.get(t)??"";return q(e,t,r+n)}function Zn(e,t){let n=I.get(t)??"";return n.length===0?false:q(e,t,n.slice(0,-1))}function Jn(e,t){q(e,t,"");}function Zt(e,t,n){let r=p.get(t)??[],o=n.toLowerCase();for(let l=0;l<r.length;l++){let s=r[l];if(s&&!s.disabled&&s.text.toLowerCase().startsWith(o))return L(e,t,l)}return false}function qn(e,t){let n=I.get(t);if(!n||n.length===0)return false;let r=p.get(t)??[],o=i.selectedIndex[t]??-1,l=n.toLowerCase();for(let s=o+1;s<r.length;s++){let c=r[s];if(c&&!c.disabled&&c.text.toLowerCase().startsWith(l))return L(e,t,s)}for(let s=0;s<=o;s++){let c=r[s];if(c&&!c.disabled&&c.text.toLowerCase().startsWith(l))return L(e,t,s)}return false}function tr(e,t){let n=M.get(e)??[];return n.push(t),M.set(e,n),()=>{let r=M.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function er(e,t){let n=k.get(e)??[];return n.push(t),k.set(e,n),()=>{let r=k.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function nr(e,t){let n=D.get(e)??[];return n.push(t),D.set(e,n),()=>{let r=D.get(e);if(r){let o=r.indexOf(t);o!==-1&&r.splice(o,1);}}}function rr(e){k.delete(e),D.delete(e),M.delete(e);}function or(e,t,n){if(!G(e,t)||Pt(e,t)||!Qt(t))return null;if($t(e,t))return Jt(n);switch(n){case "up":case "k":return {type:"selectPrev"};case "down":case "j":return {type:"selectNext"};case "home":case "g":return {type:"selectFirst"};case "end":case "G":return {type:"selectLast"};case "pageup":return {type:"pageUp"};case "pagedown":return {type:"pageDown"};case "enter":case "space":return {type:"confirm"};case "escape":return {type:"cancel"};case "/":return {type:"startSearch"};default:return null}}function Jt(e){switch(e){case "escape":return {type:"endSearch"};case "enter":return {type:"endSearch"};case "backspace":return {type:"searchBackspace"};case "up":case "down":return {type:"endSearch"};case "tab":case "C-n":return {type:"searchNextMatch"};default:return e.length===1&&e>=" "?{type:"searchChar",char:e}:null}}function lr(e,t){let n=Kt(e),r=Ht(e),o=i.selectedIndex[e]??-1,l=[];for(let{index:s,item:c}of r){let g=s===o?n.selectedPrefix:n.unselectedPrefix,y=c.text,E=t-g.length,C=y.length>E?`${y.slice(0,E-1)}\u2026`:y;l.push(g+C);}return l}function sr(){i.isList.fill(0),i.selectedIndex.fill(-1),i.itemCount.fill(0),i.firstVisible.fill(0),i.visibleCount.fill(0),i.interactive.fill(0),i.mouse.fill(0),i.keys.fill(0),i.searchEnabled.fill(0),i.totalCount.fill(0),i.isLoading.fill(0),p.clear(),V.clear(),k.clear(),D.clear(),I.clear(),M.clear(),P.clear(),H.clear(),J.clear();}var qt=["|","/","-","\\"],ir=[". ",".. ","..."," .."," ."," "],cr=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],ur=["\u2596","\u2598","\u259D","\u2597"],fr=100,m={frame:new Uint8Array(1e4),frameCount:new Uint8Array(1e4),interval:new Uint16Array(1e4),elapsed:new Float32Array(1e4)},R=new Map,Y=new Set;function br(e,t,n={}){let r=n.frames??qt,o=n.interval??100;m.frame[t]=0,m.frameCount[t]=r.length,m.interval[t]=o,m.elapsed[t]=0,R.set(t,r),Y.add(t);}function mr(e,t){Y.has(t)&&(m.frame[t]=0,m.frameCount[t]=0,m.interval[t]=0,m.elapsed[t]=0,R.delete(t),Y.delete(t));}function gr(e,t){return Y.has(t)}function pr(e){let t=R.get(e);if(!t)return "";let n=m.frame[e]??0;return t[n%t.length]??""}function dr(e){let t=R.get(e);return t?{frame:m.frame[e]??0,frameCount:m.frameCount[e]??0,interval:m.interval[e]??100,elapsed:m.elapsed[e]??0,frames:t}:null}function yr(e,t){m.interval[e]=t;}function hr(e,t){R.set(e,t),m.frameCount[e]=t.length,(m.frame[e]??0)>=t.length&&(m.frame[e]=0);}function te(e){let t=m.frameCount[e]??1,n=((m.frame[e]??0)+1)%t;return m.frame[e]=n,n}function xr(e,t){let n=(m.elapsed[e]??0)+t,r=m.interval[e]??100;return n>=r?(te(e),m.elapsed[e]=n%r,true):(m.elapsed[e]=n,false)}function Er(e){m.frame[e]=0,m.elapsed[e]=0;}function Cr(){R.clear(),Y.clear();}var St=4294967295,vt=858993663,Lt=3435973887,Tt=255,At=1717987071,It=255,v=1e4,T={rowCount:new Uint32Array(v),colCount:new Uint16Array(v),headerRows:new Uint8Array(v).fill(1),pad:new Uint8Array(v).fill(1),cellBorders:new Uint8Array(v)},f={isTable:new Uint8Array(v),rowCount:new Uint32Array(v),colCount:new Uint16Array(v),headerRows:new Uint8Array(v).fill(1),pad:new Uint8Array(v).fill(1),cellBorders:new Uint8Array(v)},d=new Map,X=new Map,_=new Map;function Lr(e,t,n={}){f.isTable[t]=1,f.rowCount[t]=0,f.colCount[t]=0,f.headerRows[t]=n.headerRows??1,f.pad[t]=n.pad??1,f.cellBorders[t]=n.cellBorders===true?1:0,T.rowCount[t]=0,T.colCount[t]=0,T.headerRows[t]=n.headerRows??1,T.pad[t]=n.pad??1,T.cellBorders[t]=n.cellBorders===true?1:0,d.set(t,[]),X.set(t,[]);}function Tr(e,t){return f.isTable[t]===1}function Ar(e,t){f.isTable[t]=0,f.rowCount[t]=0,f.colCount[t]=0,f.headerRows[t]=1,f.pad[t]=1,f.cellBorders[t]=0,T.rowCount[t]=0,T.colCount[t]=0,T.headerRows[t]=1,T.pad[t]=1,T.cellBorders[t]=0,d.delete(t),X.delete(t),_.delete(t);}function Ir(e,t,n){let r=n.map(o=>o.map(l=>typeof l=="string"?{value:l}:l));d.set(t,r),f.rowCount[t]=r.length,f.colCount[t]=r.reduce((o,l)=>Math.max(o,l.length),0),g(e,t);}function wr(e){return d.get(e)??[]}function Br(e){return (d.get(e)??[]).map(n=>n.map(r=>r.value))}function Wr(e,t,n,r,o){let l=d.get(t);if(!l||n<0||r<0)return false;for(;l.length<=n;)l.push([]);let s=l[n];if(!s)return false;for(;s.length<=r;)s.push({value:""});s[r]=typeof o=="string"?{value:o}:o;let c=l.reduce((b,g)=>Math.max(b,g.length),0);return f.colCount[t]=c,f.rowCount[t]=l.length,g(e,t),true}function ee(e,t,n){let r=d.get(e);if(!(!r||t<0||n<0))return r[t]?.[n]}function Fr(e,t,n){return ee(e,t,n)?.value}function kr(e,t){return d.get(e)?.[t]}function Dr(e,t){return (d.get(e)??[]).map(r=>r[t]??{value:""})}function Mr(e){return f.rowCount[e]??0}function Ur(e){return f.colCount[e]??0}function Rr(e,t,n){let r=d.get(t)??[],o=n.map(l=>typeof l=="string"?{value:l}:l);r.push(o),f.rowCount[t]=r.length,f.colCount[t]=Math.max(f.colCount[t]??0,o.length),g(e,t);}function _r(e,t,n,r){let o=d.get(t)??[],l=r.map(c=>typeof c=="string"?{value:c}:c),s=Math.max(0,Math.min(n,o.length));o.splice(s,0,l),f.rowCount[t]=o.length,f.colCount[t]=Math.max(f.colCount[t]??0,l.length),g(e,t);}function Xr(e,t,n){let r=d.get(t);if(!r||n<0||n>=r.length)return;let o=r.splice(n,1)[0];return f.rowCount[t]=r.length,f.colCount[t]=r.reduce((l,s)=>Math.max(l,s.length),0),g(e,t),o}function Vr(e,t){d.set(t,[]),f.rowCount[t]=0,f.colCount[t]=0,g(e,t);}function Pr(e,t,n){X.set(t,[...n]);let r=d.get(t)??[];if((f.headerRows[t]??1)>0){let l=n.map(s=>({value:s.header,align:s.align??"left"}));r.length===0?r.unshift(l):r[0]=l,f.rowCount[t]=r.length,f.colCount[t]=n.length;}g(e,t);}function Yr(e){return X.get(e)??[]}function Nr(e){let t=d.get(e)??[],n=f.headerRows[e]??1;return t.slice(0,n)}function Or(e){let t=d.get(e)??[],n=f.headerRows[e]??1;return t.slice(n)}function Hr(e,t,n){f.headerRows[t]=Math.max(0,Math.min(255,n)),g(e,t);}function Gr(e){return f.headerRows[e]??1}function zr(e,t){let n=_.get(e),r=t.altRowBg??n?.altRowBg,o=t.selectedFg??n?.selectedFg,l=t.selectedBg??n?.selectedBg,s={headerFg:t.headerFg??n?.headerFg??St,headerBg:t.headerBg??n?.headerBg??vt,cellFg:t.cellFg??n?.cellFg??Lt,cellBg:t.cellBg??n?.cellBg??Tt,borderFg:t.borderFg??n?.borderFg??At,borderBg:t.borderBg??n?.borderBg??It,...r!==void 0&&{altRowBg:r},...o!==void 0&&{selectedFg:o},...l!==void 0&&{selectedBg:l}};_.set(e,s);}function Kr(e){return _.get(e)??{headerFg:St,headerBg:vt,cellFg:Lt,cellBg:Tt,borderFg:At,borderBg:It}}function Qr(e){_.delete(e);}function jr(e){return f.pad[e]??1}function $r(e,t,n){f.pad[t]=Math.max(0,Math.min(255,n)),g(e,t);}function Zr(e){return f.cellBorders[e]===1}function Jr(e,t,n){f.cellBorders[t]=n?1:0,g(e,t);}function ne(e,t,n){let r=new Array(t).fill(0);for(let o of e)for(let l=0;l<o.length;l++){let s=o[l];s&&(r[l]=Math.max(r[l]??0,s.value.length+n*2));}return r}function re(e,t){for(let n=0;n<t.length;n++){let r=t[n];r&&(r.width!==void 0?e[n]=r.width:(r.minWidth!==void 0&&(e[n]=Math.max(e[n]??0,r.minWidth)),r.maxWidth!==void 0&&(e[n]=Math.min(e[n]??0,r.maxWidth))));}}function oe(e,t){let n=e.reduce((r,o)=>r+o,0);if(n>t){let r=t/n;for(let o=0;o<e.length;o++)e[o]=Math.floor((e[o]??0)*r);}}function le(e,t){let n=d.get(e)??[],r=X.get(e)??[],o=f.colCount[e]??0,l=f.pad[e]??1,s=ne(n,o,l);return re(s,r),t!==void 0&&oe(s,t),s}function se(e,t,n){if(n==="right")return e.padStart(t);if(n==="center"){let r=Math.floor((t-e.length)/2);return e.padStart(r+e.length).padEnd(t)}return e.padEnd(t)}function ae(e,t,n,r){let o=t-n*2,l=e.value;l.length>o&&(l=`${l.slice(0,o-1)}\u2026`);let s=se(l,o,e.align??"left");return r+s+r}function ie(e,t,n,r){let o=" ".repeat(n),l=r?"\u2502":"",s="";for(let c=0;c<t.length;c++){let b=e[c]??{value:""};c>0&&r&&(s+=l),s+=ae(b,t[c]??0,n,o);}return s}function qr(e,t){let n=d.get(e)??[],r=le(e,t),o=f.pad[e]??1,l=f.cellBorders[e]===1,s=f.headerRows[e]??1,c=[];for(let b=0;b<n.length;b++)c.push(ie(n[b]??[],r,o,l)),l&&b===s-1&&b<n.length-1&&c.push(r.map(g=>"\u2500".repeat(g)).join("\u253C"));return c}function to(){f.isTable.fill(0),f.rowCount.fill(0),f.colCount.fill(0),f.headerRows.fill(1),f.pad.fill(1),f.cellBorders.fill(0),d.clear(),X.clear(),_.clear();}var B=1e4,ce=80,ue=24,fe=1e3,a={isTerminal:new Uint8Array(B),width:new Uint16Array(B),height:new Uint16Array(B),cursorX:new Uint16Array(B),cursorY:new Uint16Array(B),cursorVisible:new Uint8Array(B),scrollOffset:new Uint32Array(B),altScreenActive:new Uint8Array(B)},x=new Map,be=z$1.object({width:z$1.number().int().positive().default(ce),height:z$1.number().int().positive().default(ue),scrollbackLines:z$1.number().int().nonnegative().default(fe),cursorVisible:z$1.boolean().default(true),cursorShape:z$1.enum(["block","underline","bar"]).default("block"),cursorBlink:z$1.boolean().default(true)});function me(e,t,n,r,o){let l={maxLines:n,chunkSize:Math.min(n,1e3)};return {buffer:k$2(e,t),scrollback:e$2(l),currentAttr:e$1(),escapeBuffer:"",inEscape:false,savedCursorX:0,savedCursorY:0,savedAttr:e$1(),altBuffer:null,cursorShape:r,cursorBlink:o}}function ge(e,t,n){return n*e+t}function pe(e){let t=b$1,n=c,r=[255,2852126975,11141375,2863268095,43775,2852170495,11184895,2863311615,1431655935,4283782655,1442797055,4294923775,1431699455,4283826175,1442840575,4294967295];return e.fg.type===1?t=r[e.fg.value]??b$1:e.fg.type===3&&(t=e.fg.value<<8|255),e.bg.type===1?n=r[e.bg.value]??c:e.bg.type===3&&(n=e.bg.value<<8|255),{fg:t,bg:n,attrs:e.styles}}function et(e$1,t,n){let r=de(e$1.buffer,0,t);g$1(e$1.scrollback,r);for(let l=0;l<n-1;l++)for(let s=0;s<t;s++){let c=(l+1)*t+s,b=l*t+s,g=e$1.buffer.cells[c];g&&(e$1.buffer.cells[b]=f$4(g));}let o=e();for(let l=0;l<t;l++){let s=(n-1)*t+l;e$1.buffer.cells[s]=f$4(o);}}function de(e,t,n){let r="";for(let o=0;o<n;o++){let l=t*n+o,s=e.cells[l];r+=s?.char??" ";}return r.trimEnd()}function ao(e,t,n={}){let r=be.parse(n);a.isTerminal[t]=1,a.width[t]=r.width,a.height[t]=r.height,a.cursorX[t]=0,a.cursorY[t]=0,a.cursorVisible[t]=r.cursorVisible?1:0,a.scrollOffset[t]=0,a.altScreenActive[t]=0;let o=me(r.width,r.height,r.scrollbackLines,r.cursorShape,r.cursorBlink);x.set(t,o),g(e,t);}function ye(e){return a.isTerminal[e]===1}function io(e){return x.get(e)}function co(e){if(ye(e))return {width:a.width[e]??0,height:a.height[e]??0,cursorX:a.cursorX[e]??0,cursorY:a.cursorY[e]??0,cursorVisible:a.cursorVisible[e]===1,scrollOffset:a.scrollOffset[e]??0}}function he(e,t,n,r,o){let l=(a.cursorY[t]??0)+1;l>=o&&(et(n,r,o),l=o-1),a.cursorX[t]=0,a.cursorY[t]=l,g(e,t);}function xe(e,t,n){let r=a.cursorX[t]??0,o=Math.min((Math.floor(r/8)+1)*8,n-1);a.cursorX[t]=o,g(e,t);}function Ee(e$1,t,n,r,o,l){let s=a.cursorX[t]??0,c=a.cursorY[t]??0,{fg:b,bg:g$1,attrs:y}=pe(n.currentAttr),E=ge(o,s,c);n.buffer.cells[E]=e(r,b,g$1,y);let C=s+1;C>=o&&(C=0,c++,c>=l&&(et(n,o,l),c=l-1)),a.cursorX[t]=C,a.cursorY[t]=c,g(e$1,t);}function Ce(e,t,n){let r=x.get(t);if(!r)return;let o=a.width[t]??0,l=a.height[t]??0;if(n===`
2
+ `){he(e,t,r,o,l);return}if(n==="\r"){a.cursorX[t]=0,g(e,t);return}if(n==="\b"){let s=a.cursorX[t]??0;s>0&&(a.cursorX[t]=s-1),g(e,t);return}if(n===" "){xe(e,t,o);return}Ee(e,t,r,n,o,l);}function uo(e,t,n){let r=x.get(t);if(r)for(let o=0;o<n.length;o++){let l=n[o];if(l!==void 0){if(l==="\x1B"){r.inEscape=true,r.escapeBuffer=l;continue}if(r.inEscape){r.escapeBuffer+=l,Se(r.escapeBuffer)&&(ve(e,t,r,r.escapeBuffer),r.inEscape=false,r.escapeBuffer="");continue}Ce(e,t,l);}}}function Se(e){if(e.length<2)return false;if(e[1]==="["){let t=e[e.length-1];return t===void 0?false:/[A-Za-z@`~]/.test(t)}return e[1]==="]"?e.endsWith("\x07")||e.endsWith("\x1B\\"):e.length>=2}function ve(e,t,n,r){if(r.length<2)return;let o=r[1];if(o==="["){Le(e,t,n,r);return}switch(o){case "c":Ke(e,t);break;case "7":n.savedCursorX=a.cursorX[t]??0,n.savedCursorY=a.cursorY[t]??0,n.savedAttr=f$2(n.currentAttr);break;case "8":a.cursorX[t]=n.savedCursorX,a.cursorY[t]=n.savedCursorY,n.currentAttr=f$2(n.savedAttr),g(e,t);break;case "D":z(e,t,n,1);break;case "M":tt(e,t,1);break;case "E":a.cursorX[t]=0,z(e,t,n,1);break}}function Le(e,t,n,r){let o=r.match(/^\x1b\[(\??[\d;]*)([A-Za-z@`~])$/);if(!o)return;let l=o[1]??"",s=o[2],c=l===""?[]:l.split(";").map(C=>parseInt(C,10)||0),b=c[0]??1,g$1=c[1]??1,y=a.width[t]??0,E=a.height[t]??0;switch(s){case "A":tt(e,t,b);break;case "B":z(e,t,n,b);break;case "C":we(e,t,b,y);break;case "D":Be(e,t,b);break;case "E":a.cursorX[t]=0,z(e,t,n,b);break;case "F":a.cursorX[t]=0,tt(e,t,b);break;case "G":a.cursorX[t]=Math.min(Math.max(b-1,0),y-1),g(e,t);break;case "H":case "f":a.cursorY[t]=Math.min(Math.max(b-1,0),E-1),a.cursorX[t]=Math.min(Math.max(g$1-1,0),y-1),g(e,t);break;case "J":ke(e,t,n,c[0]??0);break;case "K":De(e,t,n,c[0]??0);break;case "m":Ge(n,c.length===0?[0]:c);break;case "h":wt(e,t,n,l,true);break;case "l":wt(e,t,n,l,false);break;case "s":n.savedCursorX=a.cursorX[t]??0,n.savedCursorY=a.cursorY[t]??0;break;case "u":a.cursorX[t]=n.savedCursorX,a.cursorY[t]=n.savedCursorY,g(e,t);break}}function Te(e,t,n){a.cursorVisible[t]=n?1:0,g(e,t);}function Ae(e,t,n,r){r?(n.savedCursorX=a.cursorX[t]??0,n.savedCursorY=a.cursorY[t]??0,Wt(e,t,n)):(Ft(e,t,n),a.cursorX[t]=n.savedCursorX,a.cursorY[t]=n.savedCursorY),g(e,t);}function Ie(e,t,n,r,o){o?(Wt(e,t,n),r==="1047"&&kt(n,0,n.buffer.cells.length)):Ft(e,t,n),g(e,t);}function wt(e,t,n,r,o){let l=r.startsWith("?")?r.slice(1):r;if(l==="25"){Te(e,t,o);return}if(l==="1049"){Ae(e,t,n,o);return}if(l==="47"||l==="1047"){Ie(e,t,n,l,o);return}}function Wt(e$1,t,n){if(a.altScreenActive[t]===1)return;let r=a.width[t]??0,o=a.height[t]??0;n.altBuffer||(n.altBuffer=k$2(r,o));for(let s=0;s<n.buffer.cells.length&&s<n.altBuffer.cells.length;s++){let c=n.buffer.cells[s];c&&(n.altBuffer.cells[s]=f$4(c));}let l=e();for(let s=0;s<n.buffer.cells.length;s++)n.buffer.cells[s]=f$4(l);a.cursorX[t]=0,a.cursorY[t]=0,a.altScreenActive[t]=1;}function Ft(e,t,n){if(a.altScreenActive[t]!==0){if(n.altBuffer)for(let r=0;r<n.altBuffer.cells.length&&r<n.buffer.cells.length;r++){let o=n.altBuffer.cells[r];o&&(n.buffer.cells[r]=f$4(o));}a.altScreenActive[t]=0;}}function tt(e,t,n){let r=a.cursorY[t]??0;a.cursorY[t]=Math.max(0,r-n),g(e,t);}function z(e,t,n,r){let o=a.width[t]??0,l=a.height[t]??0,s=a.cursorY[t]??0;for(s+=r;s>=l;)et(n,o,l),s--;a.cursorY[t]=s,g(e,t);}function we(e,t,n,r){let o=a.cursorX[t]??0;a.cursorX[t]=Math.min(r-1,o+n),g(e,t);}function Be(e,t,n){let r=a.cursorX[t]??0;a.cursorX[t]=Math.max(0,r-n),g(e,t);}function kt(e$1,t,n){let r=e();for(let o=t;o<n;o++)e$1.buffer.cells[o]=f$4(r);}function Dt(e$1,t,n,r,o){let l=e();for(let s=r;s<=o;s++){let c=n*t+s;e$1.buffer.cells[c]=f$4(l);}}function Mt(e$1,t,n,r){let o=e();for(let l=n;l<r;l++)for(let s=0;s<t;s++){let c=l*t+s;e$1.buffer.cells[c]=f$4(o);}}function We(e,t,n,r,o){Dt(e,t,o,r,t-1),Mt(e,t,o+1,n);}function Fe(e,t,n,r){Mt(e,t,0,r),Dt(e,t,r,0,n);}function ke(e,t,n,r){let o=a.width[t]??0,l=a.height[t]??0,s=a.cursorX[t]??0,c=a.cursorY[t]??0;r===0?We(n,o,l,s,c):r===1?Fe(n,o,s,c):(r===2||r===3)&&(kt(n,0,n.buffer.cells.length),r===3&&f$3(n.scrollback)),g(e,t);}function De(e$1,t,n,r){let o=a.width[t]??0,l=a.cursorX[t]??0,s=a.cursorY[t]??0,c=e();switch(r){case 0:for(let b=l;b<o;b++){let g=s*o+b;n.buffer.cells[g]=f$4(c);}break;case 1:for(let b=0;b<=l;b++){let g=s*o+b;n.buffer.cells[g]=f$4(c);}break;case 2:for(let b=0;b<o;b++){let g=s*o+b;n.buffer.cells[g]=f$4(c);}break}g(e$1,t);}function Me(e){return e.currentAttr=e$1(),1}function Ue(e,t,n){let r=t[n]??0;return e.currentAttr.styles|=1<<r-1,1}function Re(e,t,n){let r=t[n]??0;return e.currentAttr.styles&=~(1<<r-22+1),1}function _e(e,t,n){let r=t[n]??0;return e.currentAttr.fg={type:1,value:r-30},1}function Xe(e){return e.currentAttr.fg={type:0,value:0},1}function Ve(e,t,n){let r=t[n]??0;return e.currentAttr.bg={type:1,value:r-40},1}function Pe(e){return e.currentAttr.bg={type:0,value:0},1}function Ye(e,t,n){let r=t[n]??0;return e.currentAttr.fg={type:1,value:r-90+8},1}function Ne(e,t,n){let r=t[n]??0;return e.currentAttr.bg={type:1,value:r-100+8},1}function Oe(e){return e===0?Me:e>=1&&e<=9?Ue:e>=22&&e<=29?Re:e>=30&&e<=37?_e:e===39?Xe:e>=90&&e<=97?Ye:e>=40&&e<=47?Ve:e===49?Pe:e>=100&&e<=107?Ne:null}function He(e,t,n){let r=t[n]??0;if(r===38){let l=Bt(e,t,n,"fg");return l>0?l:1}if(r===48){let l=Bt(e,t,n,"bg");return l>0?l:1}let o=Oe(r);return o?o(e,t,n):1}function Bt(e,t,n,r){if(n+1>=t.length)return 0;let o=t[n+1];if(o===5&&n+2<t.length){let l=t[n+2]??0;return e.currentAttr[r]={type:2,value:l},3}if(o===2&&n+4<t.length){let l=t[n+2]??0,s=t[n+3]??0,c=t[n+4]??0;return e.currentAttr[r]={type:3,value:l<<16|s<<8|c},5}return 0}function Ge(e,t){let n=0;for(;n<t.length;){let r=He(e,t,n);n+=r;}}function ze(e$2,t){let n=x.get(t);if(!n)return;let r=e();for(let o=0;o<n.buffer.cells.length;o++)n.buffer.cells[o]=f$4(r);a.cursorX[t]=0,a.cursorY[t]=0,n.currentAttr=e$1(),g(e$2,t);}function Ke(e,t){let n=x.get(t);n&&(ze(e,t),f$3(n.scrollback),n.escapeBuffer="",n.inEscape=false,n.savedCursorX=0,n.savedCursorY=0,n.savedAttr=e$1(),a.cursorVisible[t]=1,a.scrollOffset[t]=0,g(e,t));}function fo(e,t,n,r){let o=a.width[t]??0,l=a.height[t]??0;a.cursorX[t]=Math.min(Math.max(n,0),o-1),a.cursorY[t]=Math.min(Math.max(r,0),l-1),g(e,t);}function bo(e,t,n){a.cursorVisible[t]=n?1:0,g(e,t);}function mo(e,t,n){let r=x.get(t);if(!r)return;let o=a.scrollOffset[t]??0,l=r.scrollback.totalLines;a.scrollOffset[t]=Math.min(o+n,l),g(e,t);}function go(e,t,n){let r=a.scrollOffset[t]??0;a.scrollOffset[t]=Math.max(0,r-n),g(e,t);}function po(e,t){let n=x.get(t);n&&(a.scrollOffset[t]=n.scrollback.totalLines,g(e,t));}function yo(e,t){a.scrollOffset[t]=0,g(e,t);}function ho(e,t,n,r){let o=x.get(t);if(!o)return;let l=a.width[t]??0,s=a.height[t]??0,c=k$2(n,r),b=Math.min(l,n),g$1=Math.min(s,r);for(let C=0;C<g$1;C++)for(let N=0;N<b;N++){let Ut=C*l+N,Rt=C*n+N,nt=o.buffer.cells[Ut];nt&&(c.cells[Rt]=f$4(nt));}o.buffer=c,a.width[t]=n,a.height[t]=r;let y=a.cursorX[t]??0,E=a.cursorY[t]??0;a.cursorX[t]=Math.min(y,n-1),a.cursorY[t]=Math.min(E,r-1),g(e,t);}function xo(e){a.isTerminal[e]=0,a.width[e]=0,a.height[e]=0,a.cursorX[e]=0,a.cursorY[e]=0,a.cursorVisible[e]=0,a.scrollOffset[e]=0,a.altScreenActive[e]=0,x.delete(e);}function Qe(e,t,n){let r=j(e.scrollback,e.scrollback.totalLines-n,e.scrollback.totalLines-n+t),o="";for(let l of r.lines)o+=l.ansi??l.text,o+=`
3
+ `;return o}function je(e,t){let n="";return (e.fg!==t.fg||e.bg!==t.bg)&&(n+="\x1B[0m",t.fg=e.fg,t.bg=e.bg),n+=e.char,{output:n,fg:t.fg,bg:t.bg}}function Eo(e){let t=x.get(e);if(!t)return "";let n=a.width[e]??0,r=a.height[e]??0,o=a.scrollOffset[e]??0;if(o>0)return Qe(t,r,o);let l="",s={fg:-1,bg:-1};for(let c=0;c<r;c++){for(let b=0;b<n;b++){let g=c*n+b,y=t.buffer.cells[g];if(!y)continue;let E=je(y,s);l+=E.output,s.fg=E.fg,s.bg=E.bg;}c<r-1&&(l+=`
4
+ `);}return l}function Co(e){return x.get(e)?.buffer.cells}function So(){a.isTerminal.fill(0),a.width.fill(0),a.height.fill(0),a.cursorX.fill(0),a.cursorY.fill(0),a.cursorVisible.fill(0),a.scrollOffset.fill(0),a.altScreenActive.fill(0),x.clear();}export{Dn as $,Tt as $a,go as $b,bn as A,tr as Aa,Gr as Ab,mn as B,er as Ba,zr as Bb,gn as C,nr as Ca,Kr as Cb,pn as D,rr as Da,Qr as Db,L as E,or as Ea,jr as Eb,dn as F,lr as Fa,$r as Fb,yn as G,sr as Ga,Zr as Gb,hn as H,qt as Ha,Jr as Hb,xn as I,ir as Ia,le as Ib,En as J,cr as Ja,qr as Jb,Cn as K,ur as Ka,to as Kb,Sn as L,fr as La,ce as Lb,vn as M,m as Ma,ue as Mb,Z as N,br as Na,fe as Nb,Ln as O,mr as Oa,a as Ob,Tn as P,gr as Pa,be as Pb,Ot as Q,pr as Qa,ao as Qb,An as R,dr as Ra,ye as Rb,Ht as S,yr as Sa,io as Sb,In as T,hr as Ta,co as Tb,Gt as U,te as Ua,Ce as Ub,wn as V,xr as Va,uo as Vb,Bn as W,Er as Wa,ze as Wb,Wn as X,Cr as Xa,Ke as Xb,Fn as Y,St as Ya,fo as Yb,bt as Z,vt as Za,bo as Zb,kn as _,Lt as _a,mo as _b,mt as a,Mn as aa,At as ab,po as ac,gt as b,Un as ba,It as bb,yo as bc,pt as c,Rn as ca,T as cb,ho as cc,dt as d,_n as da,f as db,xo as dc,yt as e,Xn as ea,Lr as eb,Eo as ec,ht as f,Vn as fa,Tr as fb,Co as fc,xt as g,Kt as ga,Ar as gb,So as gc,i as h,Pn as ha,Ir as hb,Vt as i,Yn as ia,wr as ib,tn as j,Nn as ja,Br as jb,G as k,On as ka,Wr as kb,Et as l,Hn as la,ee as lb,Ct as m,Qt as ma,Fr as mb,en as n,Gn as na,kr as nb,Pt as o,jt as oa,Dr as ob,U as p,zn as pa,Mr as pb,nn as q,$t as qa,Ur as qb,rn as r,Kn as ra,Rr as rb,on as s,Qn as sa,_r as sb,ln as t,jn as ta,Xr as tb,sn as u,q as ua,Vr as ub,an as v,$n as va,Pr as vb,cn as w,Zn as wa,Yr as wb,un as x,Jn as xa,Nr as xb,w as y,Zt as ya,Or as yb,fn as z,qn as za,Hr as zb};
@@ -0,0 +1 @@
1
+ import {n,i as i$1,h as h$1}from'./chunk-PXXGH3BV.js';n();var a=1e4,y=4294967295,E=0,t={clickable:new Uint8Array(a),draggable:new Uint8Array(a),hoverable:new Uint8Array(a),hovered:new Uint8Array(a),pressed:new Uint8Array(a),keyable:new Uint8Array(a),focusable:new Uint8Array(a),focused:new Uint8Array(a),tabIndex:new Int16Array(a),hoverEffectFg:new Uint32Array(a),hoverEffectBg:new Uint32Array(a),focusEffectFg:new Uint32Array(a),focusEffectBg:new Uint32Array(a)},i=4278255615,g=0;function v(n){t.clickable[n]=0,t.draggable[n]=0,t.hoverable[n]=0,t.hovered[n]=0,t.pressed[n]=0,t.keyable[n]=0,t.focusable[n]=0,t.focused[n]=0,t.tabIndex[n]=0,t.hoverEffectFg[n]=y,t.hoverEffectBg[n]=E,t.focusEffectFg[n]=i,t.focusEffectBg[n]=g;}function f(n,e){i$1(n,e,t)||(h$1(n,e,t),v(e));}function l(n,e,r){r!==void 0&&(e[n]=r?1:0);}function c(n,e,r){r!==void 0&&(e[n]=r);}function p(n,e,r){return f(n,e),l(e,t.clickable,r.clickable),l(e,t.draggable,r.draggable),l(e,t.hoverable,r.hoverable),l(e,t.keyable,r.keyable),l(e,t.focusable,r.focusable),c(e,t.tabIndex,r.tabIndex),c(e,t.hoverEffectFg,r.hoverEffectFg),c(e,t.hoverEffectBg,r.hoverEffectBg),c(e,t.focusEffectFg,r.focusEffectFg),c(e,t.focusEffectBg,r.focusEffectBg),e}function h(n,e,r){return f(n,e),t.clickable[e]=r?1:0,e}function W(n,e,r){return f(n,e),t.draggable[e]=r?1:0,e}function k(n,e,r){return f(n,e),t.hoverable[e]=r?1:0,e}function F(n,e,r){return f(n,e),t.keyable[e]=r?1:0,e}function m(n,e){return i$1(n,e,t)?t.hovered[e]===1:false}function I(n,e){return i$1(n,e,t)?t.pressed[e]===1:false}function d(n,e){return i$1(n,e,t)?t.clickable[e]===1:false}function A(n,e){return i$1(n,e,t)?t.draggable[e]===1:false}function B(n,e){return i$1(n,e,t)?t.hoverable[e]===1:false}function U(n,e){return i$1(n,e,t)?t.keyable[e]===1:false}function w(n,e,r){return f(n,e),t.hovered[e]=r?1:0,e}function D(n,e,r){return f(n,e),t.pressed[e]=r?1:0,e}function _(n,e){return i$1(n,e,t)?t.focusable[e]===1:false}function C(n,e,r){return f(n,e),t.focused[e]=r?1:0,e}function O(n,e){if(i$1(n,e,t))return {fg:t.focusEffectFg[e],bg:t.focusEffectBg[e]}}function T(n,e,r,b){return f(n,e),t.focusEffectFg[e]=r,t.focusEffectBg[e]=b,e}function H(n,e){if(i$1(n,e,t))return {clickable:t.clickable[e]===1,draggable:t.draggable[e]===1,hoverable:t.hoverable[e]===1,hovered:t.hovered[e]===1,pressed:t.pressed[e]===1,keyable:t.keyable[e]===1,focusable:t.focusable[e]===1,focused:t.focused[e]===1,tabIndex:t.tabIndex[e],hoverEffectFg:t.hoverEffectFg[e],hoverEffectBg:t.hoverEffectBg[e],focusEffectFg:t.focusEffectFg[e],focusEffectBg:t.focusEffectBg[e]}}function K(n,e){return i$1(n,e,t)}function L(n,e){return i$1(n,e,t)&&(t.hovered[e]=0,t.pressed[e]=0,t.focused[e]=0),e}function G(n,e){return f(n,e),t.clickable[e]=1,t.hoverable[e]=1,e}function S(n,e){return i$1(n,e,t)&&(t.clickable[e]=0,t.hoverable[e]=0),e}function M(n,e){return f(n,e),t.keyable[e]=1,e}function P(n,e){return i$1(n,e,t)&&(t.keyable[e]=0),e}function R(n,e){return f(n,e),t.clickable[e]=1,t.hoverable[e]=1,t.keyable[e]=1,e}function V(n,e){return i$1(n,e,t)&&(t.clickable[e]=0,t.hoverable[e]=0,t.keyable[e]=0),e}function N(n,e){return i$1(n,e,t)?t.clickable[e]===1||t.hoverable[e]===1:false}function Y(n,e){return i$1(n,e,t)?t.keyable[e]===1:false}function j(n,e){return i$1(n,e,t)?t.clickable[e]===1||t.hoverable[e]===1||t.keyable[e]===1:false}export{P as A,R as B,V as C,N as D,Y as E,j as F,y as a,E as b,t as c,p as d,h as e,W as f,k as g,F as h,m as i,I as j,d as k,A as l,B as m,U as n,w as o,D as p,_ as q,C as r,O as s,T as t,H as u,K as v,L as w,G as x,S as y,M as z};
@@ -0,0 +1 @@
1
+ import {n,h as h$1,i,j as j$1,l as l$1,m}from'./chunk-PXXGH3BV.js';import {z}from'zod';n();function A(t){return typeof t=="string"?{target:t}:t}function I(t){let e=t.initial,n=t.context,a=new Set;function r(o){if(o)for(let u of o)u(n);}function i(o){if(o!==e)for(let u of a)u(e,o);}let d=t.states[e];if(d?.entry)for(let o of d.entry)o(n);let p={get current(){return e},get context(){return n},send(o){let u=t.states[e];if(!u?.on)return false;let x=u.on[o];if(x===void 0)return false;let{target:m,actions:U,guard:b}=A(x);if(b&&!b(n))return false;let T=e;return r(u.exit),r(U),e=m,r(t.states[e]?.entry),i(T),true},can(o){let u=t.states[e];if(!u?.on)return false;let x=u.on[o];if(x===void 0)return false;let{guard:m}=A(x);return !(m&&!m(n))},matches(o){return e===o},subscribe(o){return a.add(o),()=>{a.delete(o);}},validEvents(){let o=t.states[e];if(!o?.on)return [];let u=[];for(let x of Object.keys(o.on))p.can(x)&&u.push(x);return u},reset(){let o=e;r(t.states[e]?.exit),e=t.initial,r(t.states[e]?.entry),i(o);}};return p}var R=z.union([z.string(),z.object({target:z.string()})]),j=z.object({entry:z.array(z.function()).optional(),exit:z.array(z.function()).optional(),on:z.record(z.string(),R).optional()});z.object({initial:z.string(),states:z.record(z.string(),j),context:z.unknown().optional()});var D=1e4;function N(t=D){return {machineId:new Uint32Array(t),currentState:new Uint16Array(t),previousState:new Uint16Array(t),stateAge:new Float32Array(t)}}var s=N(),k=new WeakSet,w=null;function g(t){return k.has(t)||(w=l$1(t,m(()=>s)),k.add(t)),w}var h=new Map,l=new Map,C=new Map,W=1,f={register(t){let e=W++,n=I(t);h.set(e,n);let a=Object.keys(t.states),r=new Map;for(let i=0;i<a.length;i++){let d=a[i];d!==void 0&&r.set(d,i);}return l.set(e,r),C.set(e,a),e},getMachine(t){return h.get(t)},getStateIndex(t,e){return l.get(t)?.get(e)??0},getStateName(t,e){return C.get(t)?.[e]??""},unregister(t){h.delete(t),l.delete(t),C.delete(t);},clear(){h.clear(),l.clear(),C.clear(),W=1;}};function Y(t,e,n){let a=g(t),r=f.register(n),i=f.getStateIndex(r,n.initial);return h$1(t,e,a),s.machineId[e]=r,s.currentState[e]=i,s.previousState[e]=i,s.stateAge[e]=0,r}function q(t,e){let n=g(t);if(!i(t,e,n))return;let a=s.machineId[e]??0;f.unregister(a),j$1(t,e,n);}function _(t,e){let n=g(t);if(!i(t,e,n))return "";let a=s.machineId[e]??0,r=s.currentState[e]??0;return f.getStateName(a,r)}function B(t,e){let n=g(t);if(!i(t,e,n))return "";let a=s.machineId[e]??0,r=s.previousState[e]??0;return f.getStateName(a,r)}function H(t,e,n){let a=g(t);if(!i(t,e,a))return false;let r=s.machineId[e]??0,i$1=f.getMachine(r);if(!i$1)return false;let d=i$1.current,p=i$1.send(n);if(p){let o=f.getStateIndex(r,i$1.current),u=f.getStateIndex(r,d);s.previousState[e]=u,s.currentState[e]=o,s.stateAge[e]=0;}return p}function J(t,e,n){let a=g(t);if(!i(t,e,a))return false;let r=s.machineId[e]??0,i$1=f.getMachine(r);return i$1?i$1.can(n):false}function K(t,e){let n=g(t);return i(t,e,n)?s.stateAge[e]??0:0}function Q(t,e,n){return _(t,e)===n}function V(t,e,n){let a=g(t);for(let r of e)if(i(t,r,a)){let i=s.stateAge[r]??0;s.stateAge[r]=i+n;}}function X(t,e){let n=g(t);return i(t,e,n)}export{f as a,Y as b,q as c,_ as d,B as e,H as f,J as g,K as h,Q as i,V as j,X as k};
@@ -0,0 +1 @@
1
+ import {f,e as e$1}from'./chunk-SHUC6JWA.js';import {i,n,h}from'./chunk-PXXGH3BV.js';import {c,b as b$1}from'./chunk-5PELJRUQ.js';var _={};c(_,{BORDER_ASCII:()=>E,BORDER_BOLD:()=>L,BORDER_DOUBLE:()=>R,BORDER_ROUNDED:()=>s,BORDER_SINGLE:()=>a,Border:()=>r,BorderType:()=>b,DEFAULT_BORDER_BG:()=>p,DEFAULT_BORDER_FG:()=>m,disableAllBorders:()=>w,enableAllBorders:()=>T,getBorder:()=>D,getBorderChar:()=>W,hasBorder:()=>v,hasBorderVisible:()=>O,setBorder:()=>U,setBorderChars:()=>z});function d(o){r.type[o]=0,r.left[o]=1,r.top[o]=1,r.right[o]=1,r.bottom[o]=1,r.fg[o]=m,r.bg[o]=p,r.charTopLeft[o]=a.topLeft,r.charTopRight[o]=a.topRight,r.charBottomLeft[o]=a.bottomLeft,r.charBottomRight[o]=a.bottomRight,r.charHorizontal[o]=a.horizontal,r.charVertical[o]=a.vertical;}function l(o,t){i(o,t,r)||(h(o,t,r),d(t));}function A(o,t){t.left!==void 0&&(r.left[o]=t.left?1:0),t.top!==void 0&&(r.top[o]=t.top?1:0),t.right!==void 0&&(r.right[o]=t.right?1:0),t.bottom!==void 0&&(r.bottom[o]=t.bottom?1:0);}function C(o,t){t.type!==void 0&&(r.type[o]=t.type),A(o,t),t.fg!==void 0&&(r.fg[o]=e$1(t.fg)),t.bg!==void 0&&(r.bg[o]=e$1(t.bg)),t.chars!==void 0&&u(o,t.chars);}function U(o,t,f){return l(o,t),C(t,f),t}function u(o,t){r.charTopLeft[o]=t.topLeft,r.charTopRight[o]=t.topRight,r.charBottomLeft[o]=t.bottomLeft,r.charBottomRight[o]=t.bottomRight,r.charHorizontal[o]=t.horizontal,r.charVertical[o]=t.vertical;}function z(o,t,f){return l(o,t),u(t,f),t}function D(o,t){if(i(o,t,r))return {type:r.type[t],left:r.left[t]===1,top:r.top[t]===1,right:r.right[t]===1,bottom:r.bottom[t]===1,fg:r.fg[t],bg:r.bg[t],charTopLeft:r.charTopLeft[t],charTopRight:r.charTopRight[t],charBottomLeft:r.charBottomLeft[t],charBottomRight:r.charBottomRight[t],charHorizontal:r.charHorizontal[t],charVertical:r.charVertical[t]}}function v(o,t){return i(o,t,r)}function O(o,t){return !i(o,t,r)||r.type[t]===0?false:r.left[t]===1||r.top[t]===1||r.right[t]===1||r.bottom[t]===1}function T(o,t){return l(o,t),r.left[t]=1,r.top[t]=1,r.right[t]=1,r.bottom[t]=1,t}function w(o,t){return l(o,t),r.left[t]=0,r.top[t]=0,r.right[t]=0,r.bottom[t]=0,t}function W(o,t,f){if(i(o,t,r))switch(f){case "topLeft":return r.charTopLeft[t];case "topRight":return r.charTopRight[t];case "bottomLeft":return r.charBottomLeft[t];case "bottomRight":return r.charBottomRight[t];case "horizontal":return r.charHorizontal[t];case "vertical":return r.charVertical[t]}}var e,b,a,R,s,L,E,m,p,r,V=b$1(()=>{n();f();e=1e4,b=(n=>(n[n.None=0]="None",n[n.Line=1]="Line",n[n.Background=2]="Background",n[n.Custom=3]="Custom",n))(b||{}),a={topLeft:9484,topRight:9488,bottomLeft:9492,bottomRight:9496,horizontal:9472,vertical:9474},R={topLeft:9556,topRight:9559,bottomLeft:9562,bottomRight:9565,horizontal:9552,vertical:9553},s={topLeft:9581,topRight:9582,bottomLeft:9584,bottomRight:9583,horizontal:9472,vertical:9474},L={topLeft:9487,topRight:9491,bottomLeft:9495,bottomRight:9499,horizontal:9473,vertical:9475},E={topLeft:43,topRight:43,bottomLeft:43,bottomRight:43,horizontal:45,vertical:124},m=4294967295,p=0,r={type:new Uint8Array(e),left:new Uint8Array(e),top:new Uint8Array(e),right:new Uint8Array(e),bottom:new Uint8Array(e),fg:new Uint32Array(e),bg:new Uint32Array(e),charTopLeft:new Uint32Array(e),charTopRight:new Uint32Array(e),charBottomLeft:new Uint32Array(e),charBottomRight:new Uint32Array(e),charHorizontal:new Uint32Array(e),charVertical:new Uint32Array(e)};});export{b as a,a as b,R as c,s as d,L as e,E as f,m as g,p as h,r as i,U as j,z as k,D as l,v as m,O as n,T as o,w as p,W as q,_ as r,V as s};
@@ -0,0 +1 @@
1
+ import {n,i,h,k}from'./chunk-PXXGH3BV.js';import {z}from'zod';var ie=z.enum(["braille","halfblock","sextant","sixel","kitty"]),Pt=z.object({maxColors:z.number().int().positive().describe("Max simultaneous colors"),supportsAlpha:z.boolean().describe("Whether backend supports alpha transparency"),pixelsPerCellX:z.number().int().positive().describe("Horizontal pixel resolution per terminal cell"),pixelsPerCellY:z.number().int().positive().describe("Vertical pixel resolution per terminal cell"),supportsAnimation:z.boolean().describe("Whether backend supports efficient frame updates"),requiresEscapeSequences:z.boolean().describe("True if output is raw escape sequences vs cell-based")}),ur=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),char:z.string().min(1).max(4),fg:z.number().int().nonnegative(),bg:z.number().int().nonnegative()}),kt=z.object({cells:z.array(ur).optional(),escape:z.string().optional(),cursorX:z.number().int().nonnegative().optional(),cursorY:z.number().int().nonnegative().optional()}).refine(e=>e.cells!==void 0||e.escape!==void 0,{message:"EncodedOutput must have either cells or escape"}),cr=z.union([ie,z.literal("auto")]),Se=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),colorMode:z.enum(["average","dominant","brightness"]).default("average").describe("How to pick fg color from the lit pixels in a 2x4 block"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Ae=z.object({backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),Be=z.object({threshold:z.number().int().min(0).max(255).default(128).describe("Alpha threshold: pixels with alpha >= threshold are lit"),backgroundColor:z.number().int().nonnegative().default(0).describe("Background color as 24-bit RGB")}),we=z.object({maxColors:z.number().int().min(2).max(256).default(256).describe("Maximum palette colors"),rleEnabled:z.boolean().default(true).describe("Enable run-length encoding for repeated columns")}),Pe=z.object({imageId:z.number().int().positive().default(1).describe("Unique image ID for reuse"),chunkSize:z.number().int().positive().default(4096).describe("Max base64 bytes per chunk")}),ke=z.object({preferred:cr.default("auto"),fallback:ie.default("braille"),forceBackend:z.boolean().default(false).describe("Skip detection, use preferred directly")});var mr=10240,q=[1,8,2,16,4,32,64,128],lr=(()=>{let e=new Array(256);for(let r=0;r<256;r++)e[r]=String.fromCharCode(mr+r);return e})(),br=q[0],fr=q[1],pr=q[2],dr=q[3],xr=q[4],hr=q[5],yr=q[6],gr=q[7];function H(e,r,n,t,o){e[r+3]>=n&&(o.dotPattern|=t,o.rSum+=e[r],o.gSum+=e[r+1],o.bSum+=e[r+2],o.litCount++);}function Cr(e){if(e.litCount===0)return 0;let r=1/e.litCount;return (e.rSum*r+.5|0)<<16|(e.gSum*r+.5|0)<<8|(e.bSum*r+.5|0)}function De(e){let r=Se.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"braille",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:4,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/4),m=u*c,l=new Array(m),b=a.colorBuffer,h=a.width*4,p={dotPattern:0,rSum:0,gSum:0,bSum:0,litCount:0},M=0;for(let S=0;S<c;S++){let F=S*4*h,v=F+h,j=v+h,W=j+h;for(let z=0;z<u;z++){let E=z*2*4;p.dotPattern=0,p.rSum=0,p.gSum=0,p.bSum=0,p.litCount=0,H(b,F+E,n,br,p),H(b,F+E+4,n,fr,p),H(b,v+E,n,pr,p),H(b,v+E+4,n,dr,p),H(b,j+E,n,xr,p),H(b,j+E+4,n,hr,p),H(b,W+E,n,yr,p),H(b,W+E+4,n,gr,p),l[M++]={x:i+z,y:s+S,char:lr[p.dotPattern]??"\u2800",fg:Cr(p),bg:t};}}return {cells:l}},getPixelDimensions(a,i){return {width:a*2,height:i*4}}}}var Mr="\u2580",Sr="\u2588";function Ee(e,r){return e[r]<<16|e[r+1]<<8|e[r+2]}function Ve(e,r){return e[r+3]===0}function Ar(e,r,n){return e===r?e===n?{char:" ",fg:n,bg:n}:{char:Sr,fg:e,bg:n}:{char:Mr,fg:e,bg:r}}function Fe(e){let n=Ae.parse(e??{}).backgroundColor;return {type:"halfblock",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:2,supportsAnimation:true,requiresEscapeSequences:false},encode(o,a,i){let s=o.width,u=Math.floor(o.height/2),c=[],m=o.colorBuffer,l=o.width;for(let b=0;b<u;b++)for(let d=0;d<s;d++){let h=(b*2*l+d)*4,p=((b*2+1)*l+d)*4,M=Ve(m,h)?n:Ee(m,h),S=Ve(m,p)?n:Ee(m,p),k=Ar(M,S,n);c.push({x:a+d,y:i+b,char:k.char,fg:k.fg,bg:k.bg});}return {cells:c}},getPixelDimensions(o,a){return {width:o,height:a*2}}}}var se="\x1B_G",ue="\x1B\\";function Br(e){if(typeof Buffer<"u")return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}function wr(e,r){if(e.length<=r)return [e];let n=[];for(let t=0;t<e.length;t+=r)n.push(e.slice(t,t+r));return n}function Pr(e,r,n,t){if(e.length===0)return "";let o=[],a=e[0],i=e.length>1?1:0;o.push(`${se}a=t,f=32,s=${r},v=${n},i=${t},m=${i};${a}${ue}`);for(let s=1;s<e.length;s++){let u=s===e.length-1;o.push(`${se}m=${u?0:1};${e[s]}${ue}`);}return o.join("")}function kr(e,r){return `${se}a=p,i=${e},p=1,C=1;${ue}${se}a=d,d=i,i=${r};${ue}`}function me(e){let r=Pe.parse(e??{}),n=r.imageId,t=r.chunkSize,o={maxColors:16777216,supportsAlpha:true,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:true,requiresEscapeSequences:true},a=0,i=[n,n+1];return {type:"kitty",capabilities:o,encode(s,u,c){let m=s.width,l=s.height,b=Br(s.colorBuffer),d=wr(b,t),h=a;a=a===0?1:0;let p=i[a]??n,M=i[h]??n+1,S=Pr(d,m,l,p),k=kr(p,M);return {escape:S+k,cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}var Dr=129792,Er="\u2588";function Vr(e,r,n,t,o,a){for(let i=0;i<3;i++)for(let s=0;s<2;s++){let u=r+s,m=((n+i)*t+u)*4;if(e[m+3]>=o){let b=i*2+s;a.pattern|=1<<b,a.rSum+=e[m],a.gSum+=e[m+1],a.bSum+=e[m+2],a.litCount++;}}}function Fr(e){return e===0?" ":e===63?Er:String.fromCodePoint(Dr+e-1)}function Tr(e){if(e.litCount===0)return 0;let r=Math.round(e.rSum/e.litCount),n=Math.round(e.gSum/e.litCount),t=Math.round(e.bSum/e.litCount);return r<<16|n<<8|t}function le(e){let r=Be.parse(e??{}),n=r.threshold,t=r.backgroundColor;return {type:"sextant",capabilities:{maxColors:2,supportsAlpha:false,pixelsPerCellX:2,pixelsPerCellY:3,supportsAnimation:true,requiresEscapeSequences:false},encode(a,i,s){let u=Math.floor(a.width/2),c=Math.floor(a.height/3),m=[],l=a.colorBuffer,b=a.width,d={pattern:0,rSum:0,gSum:0,bSum:0,litCount:0};for(let h=0;h<c;h++)for(let p=0;p<u;p++)d.pattern=0,d.rSum=0,d.gSum=0,d.bSum=0,d.litCount=0,Vr(l,p*2,h*3,b,n,d),m.push({x:i+p,y:s+h,char:Fr(d.pattern),fg:Tr(d),bg:t});return {cells:m}},getPixelDimensions(a,i){return {width:a*2,height:i*3}}}}var zr="\x1BPq",vr="\x1B\\";function jr(e,r){let n=new Map;for(let t=0;t<r;t++){let o=t*4;if(e[o+3]===0)continue;let i=e[o]<<16|e[o+1]<<8|e[o+2];n.set(i,(n.get(i)??0)+1);}return n}function Rr(e,r){let n=[];for(let a of e)n.push(a);n.sort((a,i)=>i[1]-a[1]);let t=Math.min(n.length,r)||1,o=new Uint8Array(t*3);for(let a=0;a<t;a++){let i=n[a];if(i){let s=i[0];o[a*3]=s>>16&255,o[a*3+1]=s>>8&255,o[a*3+2]=s&255;}}return {paletteFlat:o,paletteCount:t}}function Wr(e,r,n,t,o){let a=2147483647,i=0;for(let s=0;s<o;s++){let u=s*3,c=e-t[u],m=r-t[u+1],l=n-t[u+2],b=c*c+m*m+l*l;if(b<a&&(a=b,i=s,b===0))break}return i}function Ur(e,r,n,t,o){let a=o&&o.length===r?o:new Uint8Array(r);for(let i=0;i<r;i++){let s=i*4;if(e[s+3]===0){a[i]=0;continue}a[i]=Wr(e[s],e[s+1],e[s+2],n,t);}return a}function Ir(e,r,n){let t=e.colorBuffer,o=e.width*e.height,a=jr(t,o),{paletteFlat:i,paletteCount:s}=Rr(a,r),u=Ur(t,o,i,s,n);return {paletteFlat:i,paletteCount:s,indexMap:u}}function Lr(e,r,n){let t=false,o=0;for(;o<r;){let a=e[o],i=1;for(;o+i<r&&e[o+i]===a;)i++;let s=String.fromCharCode(63+a);if(a>0&&(t=true),i>=3)n.push("!",String(i),s);else for(let u=0;u<i;u++)n.push(s);o+=i;}return t}function Or(e,r){let n=[];for(let t=0;t<r;t++){let o=t*3,a=Math.round(e[o]/255*100),i=Math.round(e[o+1]/255*100),s=Math.round(e[o+2]/255*100);n.push("#",String(t),";2;",String(a),";",String(i),";",String(s));}return n}function Yr(e,r,n,t,o,a){let i=0;for(let s=0;s<t;s++){let u=(n+s)*o+a;e[u]===r&&(i|=1<<s);}return i}function Xr(e,r){let n=[],t=false;for(let o=0;o<r;o++){let a=e[o];a>0&&(t=true),n.push(String.fromCharCode(63+a));}return {chars:n,hasPixels:t}}function Te(e,r,n,t){if(t){e.push("#",String(r));for(let o of n)e.push(o);e.push("$");}}function _r(e,r,n,t,o,a,i,s){for(let u=0;u<o;u++)a[u]=Yr(e,r,n,t,o,u);if(i){let u=[],c=Lr(a,o,u);Te(s,r,u,c);}else {let{chars:u,hasPixels:c}=Xr(a,o);Te(s,r,u,c);}}function Hr(e,r,n,t,o,a,i){let s=Math.ceil(t/6);for(let u=0;u<s;u++){let c=u*6,m=Math.min(6,t-c);for(let l=0;l<r;l++)_r(e,l,c,m,n,o,a,i);u<s-1&&i.push("-");}}function be(e){let r=we.parse(e??{}),n=r.maxColors,t=r.rleEnabled,o={maxColors:n,supportsAlpha:false,pixelsPerCellX:1,pixelsPerCellY:1,supportsAnimation:false,requiresEscapeSequences:true},a=null,i=null;return {type:"sixel",capabilities:o,encode(s,u,c){let{paletteFlat:m,paletteCount:l,indexMap:b}=Ir(s,n,a);a=b;let d=s.width,h=s.height,p=[zr];return p.push(...Or(m,l)),(!i||i.length<d)&&(i=new Uint8Array(d)),Hr(b,l,d,h,i,t,p),p.push(vr),{escape:p.join(""),cursorX:u,cursorY:c}},getPixelDimensions(s,u){return {width:s*8,height:u*16}}}}function fe(e){switch(ie.parse(e),e){case "braille":return De();case "halfblock":return Fe();case "sextant":return le();case "sixel":return be();case "kitty":return me()}}function Ht(e,r){let n=ke.parse(r??{});if(n.forceBackend&&n.preferred!=="auto"||n.preferred!=="auto")return fe(n.preferred);let t=e.graphics;return t==="kitty"?me():t==="sixel"?be():e.truecolor?le():fe(n.fallback)}var ze=z.object({tx:z.number().default(0),ty:z.number().default(0),tz:z.number().default(0),rx:z.number().default(0),ry:z.number().default(0),rz:z.number().default(0),sx:z.number().default(1),sy:z.number().default(1),sz:z.number().default(1)}).describe("3D transform: translation (t), rotation in radians (r), scale (s)"),ve=z.object({fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(100),aspect:z.number().positive().default(16/9),projectionMode:z.enum(["perspective","orthographic"]).default("perspective")}).refine(e=>e.near<e.far,{message:"near must be less than far"}),je=z.object({wireColor:z.number().int().min(0).max(16777215).default(16777215),fillColor:z.number().int().min(0).max(16777215).default(8421504),renderMode:z.enum(["wireframe","filled","both"]).default("wireframe"),backfaceCull:z.boolean().default(true),flatShading:z.boolean().default(false),antiAlias:z.boolean().default(false)}).describe("3D material configuration"),Re=z.object({left:z.number().int().min(0).default(0),top:z.number().int().min(0).default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),cameraEntity:z.number().int().min(0),backendType:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto")}).describe("3D viewport configuration"),Nt=z.object({rotateSpeed:z.object({x:z.number().default(0),y:z.number().default(0),z:z.number().default(0)}).default(()=>({x:0,y:0,z:0})).describe("Radians per second of continuous rotation"),orbitCenter:z.tuple([z.number(),z.number(),z.number()]).optional().describe("Point to orbit around"),orbitSpeed:z.number().default(0).describe("Radians per second of orbit"),orbitRadius:z.number().positive().optional().describe("Distance from orbit center")}).describe("3D animation configuration"),Kt=z.object({rotationSensitivity:z.number().positive().default(.01).describe("Radians per pixel of mouse movement"),zoomSensitivity:z.number().positive().default(.5).describe("Units per scroll tick"),zoomMin:z.number().positive().default(1),zoomMax:z.number().positive().default(100),invertY:z.boolean().default(false)}).describe("Mouse-based 3D camera interaction");n();var $=1e4,w={fov:new Float32Array($),near:new Float32Array($),far:new Float32Array($),aspect:new Float32Array($),projectionMode:new Uint8Array($),projMatrix:new Float32Array($*16),viewMatrix:new Float32Array($*16),dirty:new Uint8Array($)};function Qt(e,r,n){let t=ve.parse(n);return i(e,r,w)||h(e,r,w),w.fov[r]=t.fov,w.near[r]=t.near,w.far[r]=t.far,w.aspect[r]=t.aspect,w.projectionMode[r]=t.projectionMode==="orthographic"?1:0,w.dirty[r]=1,r}function en(e,r){if(i(e,r,w))return {fov:w.fov[r],near:w.near[r],far:w.far[r],aspect:w.aspect[r],projectionMode:w.projectionMode[r]===1?"orthographic":"perspective"}}function rn(e){let r=e*16;return w.projMatrix.subarray(r,r+16)}function tn(e){let r=e*16;return w.viewMatrix.subarray(r,r+16)}n();var ee=1e4,qr=0,We=1,Ue=2,P={wireColor:new Uint32Array(ee),fillColor:new Uint32Array(ee),renderMode:new Uint8Array(ee),backfaceCull:new Uint8Array(ee),flatShading:new Uint8Array(ee),antiAlias:new Uint8Array(ee)};function sn(e,r,n){let t=je.parse(n);return i(e,r,P)||h(e,r,P),P.wireColor[r]=t.wireColor,P.fillColor[r]=t.fillColor,t.renderMode==="filled"?P.renderMode[r]=We:t.renderMode==="both"?P.renderMode[r]=Ue:P.renderMode[r]=qr,P.backfaceCull[r]=t.backfaceCull?1:0,P.flatShading[r]=t.flatShading?1:0,P.antiAlias[r]=t.antiAlias?1:0,r}function un(e,r){if(!i(e,r,P))return;let n=P.renderMode[r],t="wireframe";return n===We?t="filled":n===Ue&&(t="both"),{wireColor:P.wireColor[r],fillColor:P.fillColor[r],renderMode:t,backfaceCull:P.backfaceCull[r]===1,flatShading:P.flatShading[r]===1,antiAlias:P.antiAlias[r]===1}}n();var $r=1e4,N={meshId:new Uint32Array($r)},Ie=1,ne=new Map;function Nr(e,r,n,t){let o=Ie++;return ne.set(o,{name:e,vertices:r,vertexCount:Math.floor(r.length/3),indices:n,triangleCount:Math.floor(n.length/3),normals:t}),o}function ln(e,r,n){let t=new Float32Array(r.length*3);for(let i=0;i<r.length;i++){let s=r[i];s&&(t[i*3]=s.x,t[i*3+1]=s.y,t[i*3+2]=s.z);}let o=[];for(let i of n)if(!(i.length<3))for(let s=1;s<i.length-1;s++)o.push(i[0],i[s],i[s+1]);let a=new Uint32Array(o);return Nr(e,t,a)}function Le(e){return ne.get(e)}function bn(e){return ne.delete(e)}function fn(e,r,n){return i(e,r,N)||h(e,r,N),N.meshId[r]=n,r}function pn(e,r){if(i(e,r,N))return N.meshId[r]}function dn(){return ne.size}function xn(){ne.clear(),Ie=1;}n();var Y=1e4,f={tx:new Float32Array(Y),ty:new Float32Array(Y),tz:new Float32Array(Y),rx:new Float32Array(Y),ry:new Float32Array(Y),rz:new Float32Array(Y),sx:new Float32Array(Y),sy:new Float32Array(Y),sz:new Float32Array(Y),worldMatrix:new Float32Array(Y*16),dirty:new Uint8Array(Y)};function Cn(e,r,n){let t=ze.parse(n);return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=t.tx,f.ty[r]=t.ty,f.tz[r]=t.tz,f.rx[r]=t.rx,f.ry[r]=t.ry,f.rz[r]=t.rz,f.sx[r]=t.sx,f.sy[r]=t.sy,f.sz[r]=t.sz,f.dirty[r]=1,r}function Mn(e,r){if(i(e,r,f))return {tx:f.tx[r],ty:f.ty[r],tz:f.tz[r],rx:f.rx[r],ry:f.ry[r],rz:f.rz[r],sx:f.sx[r],sy:f.sy[r],sz:f.sz[r]}}function Sn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.tx[r]=n,f.ty[r]=t,f.tz[r]=o,f.dirty[r]=1,r}function An(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.rx[r]=n,f.ry[r]=t,f.rz[r]=o,f.dirty[r]=1,r}function Bn(e,r,n,t,o){return i(e,r,f)||(h(e,r,f),f.sx[r]=1,f.sy[r]=1,f.sz[r]=1),f.sx[r]=n,f.sy[r]=t,f.sz[r]=o,f.dirty[r]=1,r}function wn(e){let r=e*16;return f.worldMatrix.subarray(r,r+16)}function Pn(e){f.dirty[e]=1;}function kn(e){return f.dirty[e]===1}n();var K=1e4,pe=0,Oe=1,Ye=2,Xe=3,_e=4,He=5,A={left:new Uint16Array(K),top:new Uint16Array(K),width:new Uint16Array(K),height:new Uint16Array(K),cameraEntity:new Uint32Array(K),backendType:new Uint8Array(K),pixelWidth:new Uint16Array(K),pixelHeight:new Uint16Array(K)},Kr={auto:pe,braille:Oe,halfblock:Ye,sextant:Xe,sixel:_e,kitty:He},Gr={[pe]:"auto",[Oe]:"braille",[Ye]:"halfblock",[Xe]:"sextant",[_e]:"sixel",[He]:"kitty"};function Fn(e,r,n){let t=Re.parse(n);return i(e,r,A)||h(e,r,A),A.left[r]=t.left,A.top[r]=t.top,A.width[r]=t.width,A.height[r]=t.height,A.cameraEntity[r]=t.cameraEntity,A.backendType[r]=Kr[t.backendType]??pe,r}function Tn(e,r){if(i(e,r,A))return {left:A.left[r],top:A.top[r],width:A.width[r],height:A.height[r],cameraEntity:A.cameraEntity[r],backendType:Gr[A.backendType[r]]??"auto",pixelWidth:A.pixelWidth[r],pixelHeight:A.pixelHeight[r]}}var de=z.tuple([z.number().finite(),z.number().finite(),z.number().finite()]),jn=z.union([de,z.object({x:z.number().finite(),y:z.number().finite(),z:z.number().finite()})]),Rn=z.instanceof(Float32Array).refine(e=>e.length===16,{message:"Mat4 must be Float32Array of length 16"}),Wn=z.object({x:z.number().finite().describe("Rotation around X axis in radians"),y:z.number().finite().describe("Rotation around Y axis in radians"),z:z.number().finite().describe("Rotation around Z axis in radians")}),qe=z.object({fov:z.number().positive().max(Math.PI).describe("Field of view in radians"),aspect:z.number().positive().describe("Width / height ratio"),near:z.number().positive().describe("Near clipping plane"),far:z.number().positive().describe("Far clipping plane")}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"}),$e=z.object({left:z.number().finite(),right:z.number().finite(),bottom:z.number().finite(),top:z.number().finite(),near:z.number().finite(),far:z.number().finite()}).refine(e=>e.left<e.right&&e.bottom<e.top&&e.near<e.far,{message:"Invalid orthographic bounds: left < right, bottom < top, near < far required"}),xe=z.object({x:z.number().int().nonnegative(),y:z.number().int().nonnegative(),width:z.number().int().positive(),height:z.number().int().positive()}),Un=z.object({xMin:z.number().finite(),xMax:z.number().finite(),yMin:z.number().finite(),yMax:z.number().finite()}).refine(e=>e.xMin<e.xMax&&e.yMin<e.yMax,{message:"Invalid clip rectangle: xMin < xMax and yMin < yMax required"});function T(e,r,n){let t=new Float32Array(3);return t[0]=e,t[1]=r,t[2]=n,t}function On(e){let r=de.parse(e);return T(r[0],r[1],r[2])}function Yn(e,r){return T(e[0]+r[0],e[1]+r[1],e[2]+r[2])}function he(e,r){return T(e[0]-r[0],e[1]-r[1],e[2]-r[2])}function Xn(e,r){return T(e[0]*r,e[1]*r,e[2]*r)}function _n(e,r){return e[0]*r[0]+e[1]*r[1]+e[2]*r[2]}function ye(e,r){let n=e[0],t=e[1],o=e[2],a=r[0],i=r[1],s=r[2];return T(t*s-o*i,o*a-n*s,n*i-t*a)}function Zr(e){let r=e[0],n=e[1],t=e[2];return r*r+n*n+t*t}function Ne(e){return Math.sqrt(Zr(e))}function ge(e){let r=Ne(e);if(r===0)return T(0,0,0);let n=1/r;return T(e[0]*n,e[1]*n,e[2]*n)}function Hn(e,r,n){let t=Math.max(0,Math.min(1,n)),o=1-t;return T(e[0]*o+r[0]*t,e[1]*o+r[1]*t,e[2]*o+r[2]*t)}function qn(e){return T(-e[0],-e[1],-e[2])}function $n(e,r){return Ne(he(e,r))}function Nn(e,r,n=1e-6){return Math.abs(e[0]-r[0])<=n&&Math.abs(e[1]-r[1])<=n&&Math.abs(e[2]-r[2])<=n}function Kn(){return T(0,0,0)}function G(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function X(e,r){let n=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++){let a=t*4+o;n[a]=e[o]*r[t*4]+e[4+o]*r[t*4+1]+e[8+o]*r[t*4+2]+e[12+o]*r[t*4+3];}return n}function Jr(e,r,n,t){let o=G();return o[12]=r,o[13]=n,o[14]=t,X(e,o)}function Qr(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[5]=n,o[6]=t,o[9]=-t,o[10]=n,X(e,o)}function et(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[2]=-t,o[8]=t,o[10]=n,X(e,o)}function rt(e,r){let n=Math.cos(r),t=Math.sin(r),o=G();return o[0]=n,o[1]=t,o[4]=-t,o[5]=n,X(e,o)}function tt(e,r,n,t){let o=G();return o[0]=r,o[5]=n,o[10]=t,X(e,o)}function Jn(e){let r=new Float32Array(16);for(let n=0;n<4;n++)for(let t=0;t<4;t++)r[n*4+t]=e[t*4+n];return r}function Qn(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p;return S*O-k*L+F*I+v*U-j*E+W*z}function Ke(e){let r=e[0],n=e[1],t=e[2],o=e[3],a=e[4],i=e[5],s=e[6],u=e[7],c=e[8],m=e[9],l=e[10],b=e[11],d=e[12],h=e[13],p=e[14],M=e[15],S=r*i-n*a,k=r*s-t*a,F=r*u-o*a,v=n*s-t*i,j=n*u-o*i,W=t*u-o*s,z=c*h-m*d,E=c*p-l*d,U=c*M-b*d,I=m*p-l*h,L=m*M-b*h,O=l*M-b*p,ae=S*O-k*L+F*I+v*U-j*E+W*z;if(Math.abs(ae)<1e-10)return null;let D=1/ae,V=new Float32Array(16);return V[0]=(i*O-s*L+u*I)*D,V[1]=(t*L-n*O-o*I)*D,V[2]=(h*W-p*j+M*v)*D,V[3]=(l*j-m*W-b*v)*D,V[4]=(s*U-a*O-u*E)*D,V[5]=(r*O-t*U+o*E)*D,V[6]=(p*F-d*W-M*k)*D,V[7]=(c*W-l*F+b*k)*D,V[8]=(a*L-i*U+u*z)*D,V[9]=(n*U-r*L-o*z)*D,V[10]=(d*j-h*F+M*S)*D,V[11]=(m*F-c*j-b*S)*D,V[12]=(i*E-a*I-s*z)*D,V[13]=(r*I-n*E+t*z)*D,V[14]=(h*k-d*v-p*S)*D,V[15]=(c*v-m*k+l*S)*D,V}function Ce(e,r){let n=r[0],t=r[1],o=r[2],a=e[3]*n+e[7]*t+e[11]*o+e[15],i=a!==0?1/a:1;return T((e[0]*n+e[4]*t+e[8]*o+e[12])*i,(e[1]*n+e[5]*t+e[9]*o+e[13])*i,(e[2]*n+e[6]*t+e[10]*o+e[14])*i)}function eo(e,r){let n=r[0],t=r[1],o=r[2];return T(e[0]*n+e[4]*t+e[8]*o,e[1]*n+e[5]*t+e[9]*o,e[2]*n+e[6]*t+e[10]*o)}function ro(e,r,n){let t=G();return t=Jr(t,e[0],e[1],e[2]),t=Qr(t,r[0]),t=et(t,r[1]),t=rt(t,r[2]),t=tt(t,n[0],n[1],n[2]),t}function to(e,r=1e-6){for(let n=0;n<4;n++)for(let t=0;t<4;t++){let o=n*4+t,a=n===t?1:0;if(Math.abs(e[o]-a)>r)return false}return true}function no(e,r,n=1e-5){for(let t=0;t<16;t++)if(Math.abs(e[t]-r[t])>n)return false;return true}function Ge(e){let r=qe.parse(e),{fov:n,aspect:t,near:o,far:a}=r,i=1/Math.tan(n/2),s=1/(o-a),u=new Float32Array(16);return u[0]=i/t,u[5]=i,u[10]=(o+a)*s,u[11]=-1,u[14]=2*o*a*s,u}function Ze(e){let r=$e.parse(e),{left:n,right:t,bottom:o,top:a,near:i,far:s}=r,u=1/(n-t),c=1/(o-a),m=1/(i-s),l=new Float32Array(16);return l[0]=-2*u,l[5]=-2*c,l[10]=2*m,l[12]=(n+t)*u,l[13]=(a+o)*c,l[14]=(s+i)*m,l[15]=1,l}function uo(e,r,n){let t=ge(he(e,r)),o=ge(ye(n,t)),a=ye(t,o),i=G();return i[0]=o[0],i[4]=o[1],i[8]=o[2],i[1]=a[0],i[5]=a[1],i[9]=a[2],i[2]=t[0],i[6]=t[1],i[10]=t[2],i[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),i[13]=-(a[0]*e[0]+a[1]*e[1]+a[2]*e[2]),i[14]=-(t[0]*e[0]+t[1]*e[1]+t[2]*e[2]),i}function Je(e){let r=xe.parse(e),{x:n,y:t,width:o,height:a}=r,i=o/2,s=a/2;return u=>({x:u[0]*i+(n+i),y:-u[1]*s+(t+s),depth:(u[2]+1)/2})}function co(e,r){return Ce(e,r)}function mo(e,r,n){let t=xe.parse(n),{x:o,y:a,width:i,height:s}=t,u=(r[0]-o)/i*2-1,c=-((r[1]-a)/s*2-1),m=r[2]*2-1,l=T(u,c,m);return Ce(e,l)}function lo(e,r,n){return X(n,X(r,e))}var Qe=z.object({width:z.number().int().positive().max(4096).describe("Buffer width in pixels"),height:z.number().int().positive().max(4096).describe("Buffer height in pixels"),enableDepthBuffer:z.boolean().default(true)}),po=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1).optional(),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),er=z.object({r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),xo=z.object({x:z.number(),y:z.number(),depth:z.number().min(0).max(1),r:z.number().int().min(0).max(255),g:z.number().int().min(0).max(255),b:z.number().int().min(0).max(255),a:z.number().int().min(0).max(255).default(255)}),ho=z.object({direction:z.tuple([z.number(),z.number(),z.number()]).describe("Normalized light direction"),intensity:z.number().min(0).max(1).default(1),color:er.optional()}),yo=z.object({intensity:z.number().min(0).max(1).default(.1),color:er.optional()});function rr(e){let r=Qe.parse(e),{width:n,height:t,enableDepthBuffer:o}=r,a=n*t,i=new Uint8ClampedArray(a*4),s=o?new Float32Array(a):null;return s&&s.fill(1),{width:n,height:t,colorBuffer:i,depthBuffer:s}}function tr(e,r,n){let t=e.colorBuffer;if(!r||r.r===0&&r.g===0&&r.b===0&&r.a===0)t.fill(0);else {let o=r.r,a=r.g,i=r.b,s=r.a;for(let u=0;u<t.length;u+=4)t[u]=o,t[u+1]=a,t[u+2]=i,t[u+3]=s;}e.depthBuffer&&e.depthBuffer.fill(n??1);}function Z(e,r,n){return r>=0&&r<e.width&&n>=0&&n<e.height}function Mo(e,r,n){if(!Z(e,r,n))return {r:0,g:0,b:0,a:0};let t=(n*e.width+r)*4;return {r:e.colorBuffer[t],g:e.colorBuffer[t+1],b:e.colorBuffer[t+2],a:e.colorBuffer[t+3]}}function So(e,r,n,t){if(!Z(e,r,n))return;let o=(n*e.width+r)*4;e.colorBuffer[o]=t.r,e.colorBuffer[o+1]=t.g,e.colorBuffer[o+2]=t.b,e.colorBuffer[o+3]=t.a;}function Q(e,r,n,t,o,a,i){let s=(n*e.width+r)*4;e.colorBuffer[s]=t,e.colorBuffer[s+1]=o,e.colorBuffer[s+2]=a,e.colorBuffer[s+3]=i;}function Ao(e,r,n){if(!e.depthBuffer||!Z(e,r,n))return 1;let t=n*e.width+r;return e.depthBuffer[t]}function re(e,r,n,t){if(!e.depthBuffer||!Z(e,r,n))return false;let o=n*e.width+r;return t<e.depthBuffer[o]?(e.depthBuffer[o]=t,true):false}function Bo(e,r,n,t,o,a){let i=Math.max(0,Math.floor(r)),s=Math.max(0,Math.floor(n)),u=Math.min(e.width,Math.floor(r+t)),c=Math.min(e.height,Math.floor(n+o));for(let m=s;m<c;m++)for(let l=i;l<u;l++){let b=(m*e.width+l)*4;e.colorBuffer[b]=a.r,e.colorBuffer[b+1]=a.g,e.colorBuffer[b+2]=a.b,e.colorBuffer[b+3]=a.a;}}function nr(e,r,n,t,o,a,i){if(e.x===r&&e.y===n)return true;let s=2*e.err;return s>-o&&(e.err-=o,e.x+=a),s<t&&(e.err+=t,e.y+=i),e.step++,false}function nt(e,r,n,t,o,a,i,s){Z(e,r,n)&&re(e,r,n,t)&&Q(e,r,n,o,a,i,s);}function ot(e,r,n,t,o,a,i,s,u){return {r:Math.round(e+(o-e)*u),g:Math.round(r+(a-r)*u),b:Math.round(n+(i-n)*u),a:Math.round(t+(s-t)*u)}}function at(e,r,n,t,o){return !o||!e.depthBuffer?true:re(e,r,n,t)}function it(e,r,n,t,o,a){let i=ot(t.r,t.g,t.b,t.a??255,o.r,o.g,o.b,o.a??255,a);Q(e,r,n,i.r,i.g,i.b,i.a);}function ko(e,r,n,t,o,a,i,s,u=255){let c=Math.round(r),m=Math.round(n),l=Math.round(t),b=Math.round(o),d=Math.abs(l-c),h=Math.abs(b-m),p=c<l?1:-1,M=m<b?1:-1,S=d-h;for(;Z(e,c,m)&&Q(e,c,m,a,i,s,u),!(c===l&&m===b);){let k=2*S;k>-h&&(S-=h,c+=p),k<d&&(S+=d,m+=M);}}function or(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.r,p=r.g,M=r.b,S=r.a??255;for(;;){let k=a.step*l,F=b+(d-b)*k;if(nt(e,a.x,a.y,F,h,p,M,S),nr(a,t,o,i,s,u,c))break}}function Do(e,r,n){let t=Math.round(n.x),o=Math.round(n.y),a={x:Math.round(r.x),y:Math.round(r.y),err:0,step:0},i=Math.abs(t-a.x),s=Math.abs(o-a.y),u=a.x<t?1:-1,c=a.y<o?1:-1;a.err=i-s;let m=Math.max(i,s),l=m>0?1/m:0,b=r.depth??0,d=n.depth??0,h=r.depth!==void 0||n.depth!==void 0;for(;;){if(Z(e,a.x,a.y)){let p=a.step*l,M=b+(d-b)*p;at(e,a.x,a.y,M,h)&&it(e,a.x,a.y,r,n,p);}if(nr(a,t,o,i,s,u,c))break}}function ar(e,r,n,t){let o=ct(r,n,t);if(Math.abs(o)<.5)return null;let a=1/o,i=Math.max(0,Math.floor(Math.min(r.x,n.x,t.x))),s=Math.max(0,Math.floor(Math.min(r.y,n.y,t.y))),u=Math.min(e.width-1,Math.ceil(Math.max(r.x,n.x,t.x))),c=Math.min(e.height-1,Math.ceil(Math.max(r.y,n.y,t.y)));if(i>u||s>c)return null;let m=i+.5,l=s+.5;return {invArea:a,minX:i,minY:s,maxX:u,maxY:c,A01:(n.y-t.y)*a,B01:(t.x-n.x)*a,A12:(t.y-r.y)*a,B12:(r.x-t.x)*a,hasDepth:e.depthBuffer!==null&&e.depthBuffer!==void 0,startW0:((n.y-t.y)*(m-t.x)+(t.x-n.x)*(l-t.y))*a,startW1:((t.y-r.y)*(m-t.x)+(r.x-t.x)*(l-t.y))*a}}function st(e,r,n,t,o,a,i,s,u,c,m,l){let b=1-t-o;if(t<0||o<0||b<0)return;let d=a.depth*t+i.depth*o+s.depth*b;if(l&&!re(e,r,n,d))return;let h=a.r*t+i.r*o+s.r*b+.5|0,p=a.g*t+i.g*o+s.g*b+.5|0,M=a.b*t+i.b*o+s.b*b+.5|0,S=u*t+c*o+m*b+.5|0;Q(e,r,n,h,p,M,S);}function ut(e,r,n,t,o,a,i,s,u,c){let m=1-t-o;if(t<0||o<0||m<0)return;let l=a.depth*t+i.depth*o+s.depth*m;c&&!re(e,r,n,l)||Q(e,r,n,u.r,u.g,u.b,u.a);}function ct(e,r,n){return (r.x-e.x)*(n.y-e.y)-(n.x-e.x)*(r.y-e.y)}function Fo(e,r,n){return {minX:Math.min(e.x,r.x,n.x),minY:Math.min(e.y,r.y,n.y),maxX:Math.max(e.x,r.x,n.x),maxY:Math.max(e.y,r.y,n.y)}}function To(e,r,n,t){let o=ar(e,r,n,t);if(!o)return;let a=r.a??255,i=n.a??255,s=t.a??255,u=o.startW0,c=o.startW1;for(let m=o.minY;m<=o.maxY;m++){let l=u,b=c;for(let d=o.minX;d<=o.maxX;d++)st(e,d,m,l,b,r,n,t,a,i,s,o.hasDepth),l+=o.A01,b+=o.A12;u+=o.B01,c+=o.B12;}}function ir(e,r,n,t,o){let a=ar(e,r,n,t);if(!a)return;let i=a.startW0,s=a.startW1;for(let u=a.minY;u<=a.maxY;u++){let c=i,m=s;for(let l=a.minX;l<=a.maxX;l++)ut(e,l,u,c,m,r,n,t,o,a.hasDepth),c+=a.A01,m+=a.A12;i+=a.B01,s+=a.B12;}}var jo=z.object({left:z.number().int().nonnegative().default(0),top:z.number().int().nonnegative().default(0),width:z.number().int().positive().default(80),height:z.number().int().positive().default(24),fov:z.number().positive().max(Math.PI).default(Math.PI/3),near:z.number().positive().default(.1),far:z.number().positive().default(1e3),projectionMode:z.enum(["perspective","orthographic"]).default("perspective"),backend:z.enum(["auto","braille","halfblock","sextant","sixel","kitty"]).default("auto"),label:z.string().optional()}).refine(e=>e.near<e.far,{message:"Near plane must be less than far plane"});n();var ce=new Float32Array(3),oe=new Map;function _o(){oe.clear();}function mt(e){let r=w.projectionMode[e],n=w.fov[e],t=w.near[e],o=w.far[e],a=w.aspect[e];if(r===1){let i=n,s=i*a;return Ze({left:-s,right:s,bottom:-i,top:i,near:t,far:o})}return Ge({fov:n,aspect:a,near:t,far:o})}function lt(e){let r=e*16,n=f.worldMatrix.subarray(r,r+16);return Ke(n)}function bt(e,r,n,t,o){let a=t[0],i=t[1],s=t[2],u=t[3],c=t[4],m=t[5],l=t[6],b=t[7],d=t[8],h=t[9],p=t[10],M=t[11],S=t[12],k=t[13],F=t[14],v=t[15],j=a*e+c*r+d*n+S,W=i*e+m*r+h*n+k,z=s*e+l*r+p*n+F,E=u*e+b*r+M*n+v,U=E!==0?1/E:0,I=j*U,L=W*U,O=z*U,ae=I>=-1&&I<=1&&L>=-1&&L<=1&&O>=-1&&O<=1;ce[0]=I,ce[1]=L,ce[2]=O;let D=o(ce);return {x:D.x,y:D.y,depth:D.depth,visible:ae}}function ft(e,r,n){let t=N.meshId[e],o=Le(t);if(!o)return null;let a=e*16,i=f.worldMatrix.subarray(a,a+16),s=X(r,i),u=o.vertexCount,c=new Array(u),m=o.vertices;for(let l=0;l<u;l++){let b=l*3;c[l]=bt(m[b],m[b+1],m[b+2],s,n);}return {meshEid:e,projectedVertices:c,triangleIndices:o.indices,mvpMatrix:s}}function pt(e,r){return i(e,r,w)&&i(e,r,f)}function dt(e,r,n){let t=A.cameraEntity[r];if(!pt(e,t))return null;let o=mt(t),a=lt(t);if(!a)return null;let i=X(o,a),s=A.pixelWidth[r],u=A.pixelHeight[r],c=Je({x:0,y:0,width:s,height:u}),m=[];for(let l of n){let b=ft(l,i,c);b&&m.push(b);}return {viewportEid:r,cameraEid:t,meshes:m,vpMatrix:i,pixelWidth:s,pixelHeight:u}}var Ho=e=>{oe.clear();let r=k(e,[A]),n=k(e,[N,f]);for(let t of r){let o=dt(e,t,n);o&&oe.set(t,o);}return e};n();var Me=new Map;function ea(){Me.clear();}function sr(e){return {r:e>>16&255,g:e>>8&255,b:e&255,a:255}}function xt(e,r,n){let t=Me.get(e);if(t&&t.width===r&&t.height===n)return t;let o=rr({width:r,height:n,enableDepthBuffer:true});return Me.set(e,o),o}function ht(e){let r=new Set,n=[];for(let t=0;t<e.length;t+=3){let o=e[t],a=e[t+1],i=e[t+2],s=[[o,a],[a,i],[i,o]];for(let[u,c]of s){let m=u<c?`${u}_${c}`:`${c}_${u}`;r.has(m)||(r.add(m),n.push([u,c]));}}return n}function yt(e,r){return i(e,r,P)?{renderMode:P.renderMode[r],wireColor:P.wireColor[r],fillColor:P.fillColor[r],backfaceCull:P.backfaceCull[r]!==0}:{renderMode:0,wireColor:16777215,fillColor:8421504,backfaceCull:true}}function gt(e,r,n){return (r.x-e.x)*(n.y-e.y)-(r.y-e.y)*(n.x-e.x)>0}function Ct(e,r,n,t,o){ir(e,{x:r.x,y:r.y,depth:r.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:n.x,y:n.y,depth:n.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:t.x,y:t.y,depth:t.depth,r:o.r,g:o.g,b:o.b,a:o.a},o);}function Mt(e,r,n,t,o){let a=sr(t);for(let i=0;i<n.length;i+=3){let s=r[n[i]],u=r[n[i+1]],c=r[n[i+2]];!s||!u||!c||o&&!gt(s,u,c)||Ct(e,s,u,c,a);}}function St(e,r,n,t){let o=sr(t),a=ht(n);for(let[i,s]of a){let u=r[i],c=r[s];!u||!c||or(e,{x:Math.round(u.x),y:Math.round(u.y),depth:u.depth,r:o.r,g:o.g,b:o.b,a:o.a},{x:Math.round(c.x),y:Math.round(c.y),depth:c.depth,r:o.r,g:o.g,b:o.b,a:o.a});}}function At(e,r,n,t,o){let a=yt(e,n),i=a.renderMode===1||a.renderMode===2,s=a.renderMode===0||a.renderMode===2;i&&Mt(r,t,o,a.fillColor,a.backfaceCull),s&&St(r,t,o,a.wireColor);}function Bt(e,r){let n=oe.get(r);if(!n)return;let t=n.pixelWidth,o=n.pixelHeight;if(t<=0||o<=0)return;let a=xt(r,t,o);tr(a);for(let i of n.meshes)At(e,a,i.meshEid,i.projectedVertices,i.triangleIndices);}var ra=e=>{let r=k(e,[A]);for(let n of r)Bt(e,n);return e};export{de as $,Mo as $a,en as A,et as Aa,rn as B,rt as Ba,tn as C,tt as Ca,P as D,Jn as Da,sn as E,Qn as Ea,un as F,Ke as Fa,N as G,Ce as Ga,Nr as H,eo as Ha,ln as I,ro as Ia,Le as J,to as Ja,bn as K,no as Ka,fn as L,Ge as La,pn as M,Ze as Ma,dn as N,uo as Na,xn as O,Je as Oa,f as P,co as Pa,Cn as Q,mo as Qa,Mn as R,lo as Ra,Sn as S,Qe as Sa,An as T,po as Ta,Bn as U,er as Ua,wn as V,xo as Va,Pn as W,ho as Wa,kn as X,yo as Xa,A as Y,rr as Ya,Fn as Z,tr as Za,Tn as _,Z as _a,ie as a,jn as aa,So as ab,Pt as b,Rn as ba,Q as bb,ur as c,Wn as ca,Ao as cb,kt as d,qe as da,re as db,cr as e,$e as ea,Bo as eb,Se as f,xe as fa,ko as fb,Ae as g,Un as ga,or as gb,Be as h,T as ha,Do as hb,we as i,On as ia,ct as ib,Pe as j,Yn as ja,Fo as jb,ke as k,he as ka,To as kb,De as l,Xn as la,ir as lb,Fe as m,_n as ma,jo as mb,me as n,ye as na,oe as nb,le as o,Zr as oa,_o as ob,be as p,Ne as pa,Ho as pb,fe as q,ge as qa,Me as qb,Ht as r,Hn as ra,ea as rb,ze as s,qn as sa,ra as sb,ve as t,$n as ta,je as u,Nn as ua,Re as v,Kn as va,Nt as w,G as wa,Kt as x,X as xa,w as y,Jr as ya,Qt as z,Qr as za};
@@ -0,0 +1 @@
1
+ var u={Music:0,SFX:1},f={play:()=>{},stop:()=>{},stopAll:()=>{},setVolume:()=>{},setMuted:()=>{}};function h(m){let l=m,s=1,p=1,i=false,r=false,A=[];function t(){return l??f}function v(e){return e===u.Music?s:p}function c(e){return e===u.Music?i:r}function y(e,n){return c(e)?0:n*v(e)}let a={getState(){return {musicVolume:s,sfxVolume:p,musicMuted:i,sfxMuted:r,adapter:l}},setAdapter(e){l=e;},clearAdapter(){l=void 0;},play(e){let n=e.channel??u.SFX,o=e.volume??1,d=y(n,o);t().play({...e,volume:d,channel:n});},playSound(e,n){a.play({id:e,channel:n??u.SFX});},playMusic(e,n){a.play({id:e,loop:true,volume:n??1,channel:u.Music});},stop(e){t().stop(e);},stopAll(){t().stopAll();},setVolume(e,n){let o=Math.max(0,Math.min(1,n));e===u.Music?s=o:p=o,t().setVolume(e,o);},getVolume(e){return v(e)},mute(e){e===u.Music?i=true:r=true,t().setMuted(e,true);},unmute(e){e===u.Music?i=false:r=false,t().setMuted(e,false);},toggleMute(e){c(e)?a.unmute(e):a.mute(e);},isMuted(e){return c(e)},onEvent(e,n){let o=e.on(n.event,d=>{n.when&&!n.when(d)||a.play({id:n.soundId,...n.options});});return A.push(o),o},onEvents(e,n){let o=[];for(let d of n)o.push(a.onEvent(e,d));return ()=>{for(let d of o)d();}},destroy(){for(let e of A)e();A.length=0,t().stopAll(),l=void 0;}};return a}export{u as a,h as b};
@@ -0,0 +1 @@
1
+ var r=new Map;function u(t,n,e){let a=r.get(t);if(!a)return e;let i=a.get(n);return i===void 0?e:i}function o(t,n,e){let a=r.get(t);a||(a=new Map,r.set(t,a)),a.set(n,e);}function s(t,n){return r.get(t)?.has(n)??false}function y(t,n){return r.get(t)?.delete(n)??false}function c(t){let n=r.get(t);return n?Array.from(n.keys()):[]}function l(t){let n=r.get(t);if(!n)return {};let e={};for(let[a,i]of n)e[a]=i;return e}function f(t,n){for(let[e,a]of Object.entries(n))o(t,e,a);}function E(t){r.delete(t);}function p(){r.clear();}function d(){return r.size}function D(t){let n=r.get(t);return n!==void 0&&n.size>0}function g(t,n,e){let a=u(t,n);o(t,n,e(a));}export{u as a,o as b,s as c,y as d,c as e,l as f,f as g,E as h,p as i,d as j,D as k,g as l};
@@ -0,0 +1,33 @@
1
+ import {s,b as b$1,c as c$1,d,e}from'./chunk-LCN2ZITE.js';import {f}from'./chunk-SHUC6JWA.js';import {c}from'./chunk-5PELJRUQ.js';import {z as z$1}from'zod';import*as Un from'fs';import*as k from'path';s();function _(e){return {topLeft:String.fromCodePoint(e.topLeft),topRight:String.fromCodePoint(e.topRight),bottomLeft:String.fromCodePoint(e.bottomLeft),bottomRight:String.fromCodePoint(e.bottomRight),horizontal:String.fromCodePoint(e.horizontal),vertical:String.fromCodePoint(e.vertical)}}var wr=_(b$1),Er=_(c$1),Mr=_(d),Wr=_(e),Ir={topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|"},Dr={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u254C",vertical:"\u254E"};function vr(e,t,n=4294967295,r=0){let o=[];for(let i=0;i<t;i++){let a=[];for(let l=0;l<e;l++)a.push({char:" ",fg:n,bg:r});o.push(a);}return {width:e,height:t,cells:o,setCell(i,a,l,s,u){if(i<0||i>=e||a<0||a>=t)return;let d=o[a]?.[i];d&&(d.char=l,s!==void 0&&(d.fg=s),u!==void 0&&(d.bg=u));}}}function Br(e,t,n,r,o,i,a,l,s,u){e.setCell(t,n,l.topLeft,s,u),i>1&&e.setCell(r,n,l.topRight,s,u),a>1&&e.setCell(t,o,l.bottomLeft,s,u),i>1&&a>1&&e.setCell(r,o,l.bottomRight,s,u);}function Fr(e,t,n,r,o,i,a,l,s,u){for(let d=t+1;d<r;d++)e.setCell(d,n,l.horizontal,s,u),a>1&&e.setCell(d,o,l.horizontal,s,u);for(let d=n+1;d<o;d++)e.setCell(t,d,l.vertical,s,u),i>1&&e.setCell(r,d,l.vertical,s,u);}function Pr(e,t,n,r,o,i,a={}){let{fg:l,bg:s,fill:u=false,fillChar:d=" "}=a;if(r<1||o<1)return;let f=t+r-1,c=n+o-1;Br(e,t,n,f,c,r,o,i,l,s),Fr(e,t,n,f,c,r,o,i,l,s),u&&r>2&&o>2&&At(e,t+1,n+1,r-2,o-2,d,l,s);}function _r(e,t,n,r,o="\u2500",i,a){for(let l=0;l<r;l++)e.setCell(t+l,n,o,i,a);}function Or(e,t,n,r,o="\u2502",i,a){for(let l=0;l<r;l++)e.setCell(t,n+l,o,i,a);}function At(e,t,n,r,o,i=" ",a,l){for(let s=0;s<o;s++)for(let u=0;u<r;u++)e.setCell(t+u,n+s,i,a,l);}function Nr(e,t,n,r,o,i){for(let a=0;a<r.length;a++){let l=r[a];l!==void 0&&e.setCell(t+a,n,l,o,i);}}function zr(e){let t=[];for(let n=0;n<e.height;n++){let r="";for(let o=0;o<e.width;o++)r+=e.cells[n]?.[o]?.char??" ";t.push(r);}return t.join(`
2
+ `)}var Hr={maxDelayMs:16,maxBatchSize:100,immediateCursor:true};function Gr(e,t){return {config:{...Hr,...t},pending:[],flushCallback:e,flushTimer:null,totalProcessed:0,totalFlushes:0}}function Ur(e,t){if(e.pending.push(t),e.pending.length>=e.config.maxBatchSize){Y(e);return}e.flushTimer||(e.flushTimer=setTimeout(()=>{Y(e);},e.config.maxDelayMs));}function Y(e){if(e.flushTimer&&(clearTimeout(e.flushTimer),e.flushTimer=null),e.pending.length===0)return;let t=[...e.pending];e.pending=[];let n=qr(t),r=t.length>1?(t[t.length-1]?.timestamp??0)-(t[0]?.timestamp??0):0,o={dirtyRegion:n,changeCount:t.length,timeSpanMs:r,changes:t};return e.totalProcessed+=t.length,e.totalFlushes++,e.flushCallback&&e.flushCallback(o),o}function Vr(e){return {config:e.config,pendingCount:e.pending.length,flushScheduled:e.flushTimer!==null,totalProcessed:e.totalProcessed,totalFlushes:e.totalFlushes,avgChangesPerFlush:e.totalFlushes>0?e.totalProcessed/e.totalFlushes:0}}function jr(e,t,n){return {startLine:e,startColumn:t,endLine:e,endColumn:t,text:n,timestamp:Date.now()}}function $r(e,t,n,r){return {startLine:e,startColumn:t,endLine:n,endColumn:r,text:"",timestamp:Date.now()}}function Zr(e,t,n,r,o){return {startLine:e,startColumn:t,endLine:n,endColumn:r,text:o,timestamp:Date.now()}}function Kr(e){let t=Y(e);return e.flushCallback=null,t}function qr(e){if(e.length===0)return {startLine:0,endLine:0,lineCountChanged:false,lineDelta:0};let t=Number.POSITIVE_INFINITY,n=0,r=0;for(let o of e){t=Math.min(t,o.startLine),n=Math.max(n,o.endLine);let i=0;for(let l=0;l<o.text.length;l++)o.text[l]===`
3
+ `&&i++;let a=o.endLine-o.startLine;r+=i-a,n=Math.max(n,o.startLine+i);}return {startLine:t===Number.POSITIVE_INFINITY?0:t,endLine:n,lineCountChanged:r!==0,lineDelta:r}}f();function Xr(e){let t=new Map;return {get:n=>t.get(n),set:(n,r)=>{t.set(n,r);},has:n=>t.has(n),delete:n=>t.delete(n),get size(){return t.size},entries:()=>t.entries(),clear:()=>t.clear(),memoryUsage:()=>64+t.size*120}}function Yr(){let e=new Map,t=0,n=0;function r(i){let a=1;for(;a<i;)a*=2;return a}function o(i){let a=r(i),l=e.get(a);return l&&l.arrays.length>0?(n-=a,l.arrays.pop()):(t+=a,new ArrayBuffer(a))}return {allocateF32(i){let a=o(i*4);return new Float32Array(a,0,i)},allocateU32(i){let a=o(i*4);return new Uint32Array(a,0,i)},allocateU8(i){let a=o(i);return new Uint8Array(a,0,i)},release(i){let a=i.buffer,l=r(a.byteLength),s=e.get(l);s||(s={arrays:[]},e.set(l,s)),s.arrays.push(a),n+=l;},get totalAllocated(){return t},get totalFree(){return n},reset(){e.clear(),t=0,n=0;}}}function wt(e,t,n=4,r=4){let i=e*t*r*n,a=e*8;return i+a}function Jr(e,t){let n=new Map,r=0,o=0;for(let[a,l]of Object.entries(t)){let s=0;for(let u of Object.values(l))ArrayBuffer.isView(u)&&(s+=u.byteLength,o=Math.max(o,u.length));n.set(a,s),r+=s;}let i=o*n.size*4;return {totalBytes:r,componentBytes:n,entityCount:o,avgBytesPerEntity:o>0?r/o:0,efficiency:i>0?r/i:1}}function Qr(e,t=100,n=5){return wt(e,n)<t*1024*1024}var J={scrollPadding:5,horizontalPadding:5,lineWrap:true,tabWidth:4};function eo(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
4
+ `&&t.push(n+1);return {offsets:t,lineCount:t.length}}function to(e){let t=[0],n=0;for(let r=0;r<e.length-1;r++)n+=e[r]??0,t.push(n);return {offsets:t,lineCount:e.length}}function no(e,t){let n=e.offsets,r=0,o=n.length-1;for(;r<=o;){let i=r+o>>>1;(n[i]??0)<=t?r=i+1:o=i-1;}return Math.max(0,r-1)}function ro(e,t){return t<0||t>=e.lineCount?-1:e.offsets[t]??-1}function Q(e=0,t=0){return {line:Math.max(0,e),column:Math.max(0,t)}}function oo(e=0,t=24,n=0,r=80){return {topLine:Math.max(0,e),height:Math.max(1,t),leftColumn:Math.max(0,n),width:Math.max(1,r)}}function io(e){return {...J,...e}}function I(e,t,n,r){let o={...J,...r},{topLine:i,leftColumn:a}=t,l=false,s=e.line-t.height+1+o.scrollPadding,u=e.line-o.scrollPadding;i>u&&(i=Math.max(0,u),l=true),i<s&&(i=Math.min(Math.max(0,n-t.height),Math.max(0,s)),l=true);let d=e.column-t.width+1+o.horizontalPadding,f=e.column-o.horizontalPadding;return a>f&&(a=Math.max(0,f),l=true),a<d&&(a=Math.max(0,d),l=true),l?{viewport:{...t,topLine:i,leftColumn:a},scrolled:true}:{viewport:t,scrolled:false}}function Ee(e,t,n){let r=Math.max(0,Math.min(e.line,t-1)),o=r<t?n(r):0,i=Math.max(0,Math.min(e.column,o));return {line:r,column:i}}function Et(e,t,n,r,o){let i=Q(e.line-t,e.column),a=Ee(i,r,()=>e.column),{viewport:l,scrolled:s}=I(a,n,r,o);return {cursor:a,viewport:l,scrolled:s}}function Mt(e,t,n,r,o){let i=Q(e.line+t,e.column),a=Ee(i,r,()=>e.column),{viewport:l,scrolled:s}=I(a,n,r,o);return {cursor:a,viewport:l,scrolled:s}}function Me(e,t,n,r){let o=Math.max(0,Math.min(e,n-1)),i=Q(o,0),{viewport:a,scrolled:l}=I(i,t,n,r);return {cursor:i,viewport:a,scrolled:l}}function ao(e,t,n,r){return Et(e,t.height-1,t,n,r)}function lo(e,t,n,r){return Mt(e,t.height-1,t,n,r)}function so(e,t,n){return Me(0,e,t,n)}function uo(e,t,n){return Me(t-1,e,t,n)}function fo(e,t,n,r,o,i){let a={...J,...i},{line:l,column:s}=e;s-=t,s<0&&a.lineWrap&&l>0?(l--,s=o(l)):s=Math.max(0,s);let u={line:l,column:s},{viewport:d,scrolled:f}=I(u,n,r,i);return {cursor:u,viewport:d,scrolled:f}}function co(e,t,n,r,o,i){let a={...J,...i},{line:l,column:s}=e,u=o(l);s+=t,s>u&&a.lineWrap&&l<r-1?(l++,s=0):s=Math.min(s,u);let d={line:l,column:s},{viewport:f,scrolled:c}=I(d,n,r,i);return {cursor:d,viewport:f,scrolled:c}}var mo=3,ho=10;function Wt(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r|0;}return t}function go(e,t){let n=e.length,r=t.length,o=n+r,i=Do(e,t);if(i)return i;let a=vo(e,t,o);return po(a.trace,e,t,a.offset)}function po(e,t,n,r){let o=[],i=t.length,a=n.length;for(let l=e.length-1;l>=0;l--){let s=e[l]??[],u=i-a,d=Po(u,l,s,r),f=s[d+r]??0,c=f-d,m=_o(o,t,i,a,f,c);i=m.x,a=m.y;let h=Oo(o,t,n,l,i,a,f);i=h.x,a=h.y;}return o}function bo(e,t){let n=e.length,r=t.length,o=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let i=1;i<=n;i++){let a=o[i];if(a)for(let l=1;l<=r;l++)e[i-1]===t[l-1]?a[l]=(o[i-1]?.[l-1]??0)+1:a[l]=Math.max(o[i-1]?.[l]??0,a[l-1]??0);}return o}function xo(e,t,n){let r=[],o=t.length,i=n.length,a=[];for(;o>0||i>0;){let l=Vo(e,t,n,o,i);a.unshift(l.op),o=l.nextI,i=l.nextJ;}for(let l of a)r.push({type:l.type,content:l.line,oldLineNo:l.oldNo,newLineNo:l.newNo});return r}function yo(e,t){let n=e.length,r=t.length;if(n>100||r>100)return go(e,t);let o=bo(e,t);return xo(o,e,t)}function Co(e,t,n){if(e.length===0)return [];let r=[],o=[],i=0,a=1,l=1,s=0,u=0;function d(){if(o.length===0)return;let f=o.filter(m=>m.type==="remove"||m.type==="context").length,c=o.filter(m=>m.type==="add"||m.type==="context").length;r.push({id:i++,oldStart:a,oldCount:f,newStart:l,newCount:c,lines:o,collapsed:false,contextBefore:u,contextAfter:s}),a+=f,l+=c,o=[],u=0;}for(let f of e)if(f.type==="context")if(s++,s>t*2+n){let c=o.slice(-t);o=o.slice(0,-t),o.length>0&&(s=t,d()),o=[...c,f],u=c.length+1,s=1;}else o.push(f);else s=0,o.push(f);return d(),r}function vt(e,t,n={}){let r=performance.now(),o=n.contextLines??3,i=n.collapseThreshold??10,{oldLines:a,newLines:l}=No(e,t),s=yo(a,l),u=Co(s,o,i);n.initiallyCollapsed&&zo(u);let d=Ho(s);return {chunks:u,additions:d.additions,deletions:d.deletions,contextLines:d.contextLines,computeTimeMs:performance.now()-r}}function So(){return {oldHash:0,newHash:0,result:null,expandedChunks:new Set}}function Lo(e){e.oldHash=0,e.newHash=0,e.result=null,e.expandedChunks.clear();}function ko(e,t,n,r={}){let o=Wt(t),i=Wt(n);if(e.oldHash===o&&e.newHash===i&&e.result)return e.result;let a=vt(t,n,r);e.oldHash=o,e.newHash=i,e.result=a;for(let l of a.chunks)e.expandedChunks.has(l.id)&&(l.collapsed=false);return a}function Bt(e,t,n){let r=t.chunks.find(o=>o.id===n);r&&(r.collapsed=false,e.expandedChunks.add(n));}function Ft(e,t,n){let r=t.chunks.find(o=>o.id===n);r&&(r.collapsed=true,e.expandedChunks.delete(n));}function To(e,t,n){let r=t.chunks.find(o=>o.id===n);return r?r.collapsed?(Bt(e,t,n),false):(Ft(e,t,n),true):false}function Ro(e,t){for(let n of t.chunks)n.collapsed=false,e.expandedChunks.add(n.id);}function Ao(e,t){for(let n of t.chunks)n.lines.some(o=>o.type==="add"||o.type==="remove")||(n.collapsed=true,e.expandedChunks.delete(n.id));}function wo(e,t,n){let r=[];for(let l of e.chunks)if(l.collapsed)r.push({line:{type:"header",content:`... ${l.lines.length} lines hidden ...`},chunkId:l.id,collapsed:true});else for(let s of l.lines)r.push({line:s,chunkId:l.id,collapsed:false});let o=Math.max(0,t),i=Math.min(r.length,t+n),a=r.slice(o,i);return {lines:a.map(l=>l.line),startIndex:o,totalLines:r.length,chunkInfo:a.map(l=>({chunkId:l.chunkId,collapsed:l.collapsed}))}}function Eo(e){let t=0;for(let n of e.chunks)n.collapsed?t+=1:t+=n.lines.length;return t}function Mo(e,t,n){let r=Go(e),o=Math.max(0,t),i=Math.min(r.length,t+n);return r.slice(o,i)}function Wo(e,t="a",n="b"){let r=[];r.push(`--- ${t}`),r.push(`+++ ${n}`);for(let o of e.chunks){r.push(`@@ -${o.oldStart},${o.oldCount} +${o.newStart},${o.newCount} @@`);for(let i of o.lines){let a=i.type==="add"?"+":i.type==="remove"?"-":" ";r.push(a+i.content);}}return r.join(`
5
+ `)}function Io(e){let t=performance.now(),n=e.split(`
6
+ `),r=[],o=null,i=[],a=0,l=0,s=0,u=0,d=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;for(let f of n){if(f.startsWith("---")||f.startsWith("+++"))continue;let c=d.exec(f);if(c){let h=Uo(c,a);a+=1;let g=Dt(r,o,i);o=h,i=g;continue}if(!o)continue;let m=jo(f);m&&(i.push(m.line),l+=m.additions,s+=m.deletions,u+=m.contextLines);}return Dt(r,o,i),{chunks:r,additions:l,deletions:s,contextLines:u,computeTimeMs:performance.now()-t}}function Do(e,t){let n=e.length,r=t.length;return n===0&&r===0?[]:n===0?t.map((o,i)=>({type:"add",content:o,newLineNo:i+1})):r===0?e.map((o,i)=>({type:"remove",content:o,oldLineNo:i+1})):null}function vo(e,t,n){let r=e.length,o=t.length,i=2*n+1,a=new Array(i).fill(0),l=n,s=[];e:for(let u=0;u<=n;u++){s.push(a.slice());for(let d=-u;d<=u;d+=2){let f=Bo(a,d,u,l),c=Fo(e,t,f,d);if(a[d+l]=c.x,c.x>=r&&c.y>=o)break e}}return {trace:s,offset:l}}function Bo(e,t,n,r){return t===-n||t!==n&&(e[t-1+r]??0)<(e[t+1+r]??0)?e[t+1+r]??0:(e[t-1+r]??0)+1}function Fo(e,t,n,r){let o=n,i=o-r;for(;o<e.length&&i<t.length&&e[o]===t[i];)o++,i++;return {x:o,y:i}}function Po(e,t,n,r){return e===-t||e!==t&&(n[e-1+r]??0)<(n[e+1+r]??0)?e+1:e-1}function _o(e,t,n,r,o,i){let a=n,l=r;for(;a>o&&l>i;)a--,l--,e.unshift({type:"context",content:t[a]??"",oldLineNo:a+1,newLineNo:l+1});return {x:a,y:l}}function Oo(e,t,n,r,o,i,a){if(r<=0)return {x:o,y:i};if(o===a){let s=i-1;return e.unshift({type:"add",content:n[s]??"",newLineNo:s+1}),{x:o,y:s}}let l=o-1;return e.unshift({type:"remove",content:t[l]??"",oldLineNo:l+1}),{x:l,y:i}}function No(e,t){return {oldLines:e===""?[]:e.split(`
7
+ `),newLines:t===""?[]:t.split(`
8
+ `)}}function zo(e){for(let t of e)t.lines.some(r=>r.type==="add"||r.type==="remove")||(t.collapsed=true);}function Ho(e){let t=0,n=0,r=0;for(let o of e)o.type==="add"?t++:o.type==="remove"?n++:o.type==="context"&&r++;return {additions:t,deletions:n,contextLines:r}}function Go(e){let t=[];for(let n of e.chunks){if(n.collapsed){t.push({left:void 0,right:void 0});continue}let r=[],o=[];for(let i of n.lines){if(i.type==="context"){It(t,r,o),t.push({left:ee(i,"context","left"),right:ee(i,"context","right")});continue}if(i.type==="remove"){r.push(i);continue}i.type==="add"&&o.push(i);}It(t,r,o);}return t}function It(e,t,n){for(;t.length>0||n.length>0;){let r=t.shift(),o=n.shift();e.push({left:r?ee(r,"remove","left"):void 0,right:o?ee(o,"add","right"):void 0});}}function ee(e,t,n){return {lineNo:(n==="left"?e.oldLineNo:e.newLineNo)??0,content:e.content,type:t}}function Uo(e,t){return {id:t,oldStart:parseInt(e[1]??"0",10),oldCount:parseInt(e[2]??"1",10),newStart:parseInt(e[3]??"0",10),newCount:parseInt(e[4]??"1",10),lines:[],collapsed:false,contextBefore:0,contextAfter:0}}function Vo(e,t,n,r,o){let i=r>0?t[r-1]:void 0,a=o>0?n[o-1]:void 0;return i!==void 0&&a!==void 0&&i===a?{op:{type:"context",line:i,oldNo:r,newNo:o},nextI:r-1,nextJ:o-1}:a!==void 0&&(r===0||(e[r]?.[o-1]??0)>=(e[r-1]?.[o]??0))?{op:{type:"add",line:a,newNo:o},nextI:r,nextJ:o-1}:{op:{type:"remove",line:i??"",oldNo:r},nextI:r-1,nextJ:o}}function Dt(e,t,n){return !t||n.length===0?n:(e.push({...t,lines:n}),[])}function jo(e){return e.startsWith("+")?{line:{type:"add",content:e.slice(1)},additions:1,deletions:0,contextLines:0}:e.startsWith("-")?{line:{type:"remove",content:e.slice(1)},additions:0,deletions:1,contextLines:0}:e.startsWith(" ")?{line:{type:"context",content:e.slice(1)},additions:0,deletions:0,contextLines:1}:null}function $o(e){return {additions:e.additions,deletions:e.deletions,totalChanges:e.additions+e.deletions,chunks:e.chunks.length,collapsedChunks:e.chunks.filter(t=>t.collapsed).length}}var Ut={};c(Ut,{CP1252_HIGH_BYTES:()=>ve,CP437_CONTROL_CHARS:()=>O,CP437_HIGH_BYTES:()=>We,CP850_HIGH_BYTES:()=>Ie,CP866_HIGH_BYTES:()=>De,CodePageSchema:()=>C,ConversionOptionsSchema:()=>Zo,UnmappableModeSchema:()=>Ot,bufferToString:()=>Yo,byteToChar:()=>Fe,charToByte:()=>Xo,getCodePageMap:()=>ti,getSupportedCodePages:()=>ei,isCodePageSupported:()=>Qo,stringToBuffer:()=>Jo});var We=["\xC7","\xFC","\xE9","\xE2","\xE4","\xE0","\xE5","\xE7","\xEA","\xEB","\xE8","\xEF","\xEE","\xEC","\xC4","\xC5","\xC9","\xE6","\xC6","\xF4","\xF6","\xF2","\xFB","\xF9","\xFF","\xD6","\xDC","\xA2","\xA3","\xA5","\u20A7","\u0192","\xE1","\xED","\xF3","\xFA","\xF1","\xD1","\xAA","\xBA","\xBF","\u2310","\xAC","\xBD","\xBC","\xA1","\xAB","\xBB","\u2591","\u2592","\u2593","\u2502","\u2524","\u2561","\u2562","\u2556","\u2555","\u2563","\u2551","\u2557","\u255D","\u255C","\u255B","\u2510","\u2514","\u2534","\u252C","\u251C","\u2500","\u253C","\u255E","\u255F","\u255A","\u2554","\u2569","\u2566","\u2560","\u2550","\u256C","\u2567","\u2568","\u2564","\u2565","\u2559","\u2558","\u2552","\u2553","\u256B","\u256A","\u2518","\u250C","\u2588","\u2584","\u258C","\u2590","\u2580","\u03B1","\xDF","\u0393","\u03C0","\u03A3","\u03C3","\xB5","\u03C4","\u03A6","\u0398","\u03A9","\u03B4","\u221E","\u03C6","\u03B5","\u2229","\u2261","\xB1","\u2265","\u2264","\u2320","\u2321","\xF7","\u2248","\xB0","\u2219","\xB7","\u221A","\u207F","\xB2","\u25A0","\xA0"],O=["\0","\u263A","\u263B","\u2665","\u2666","\u2663","\u2660","\u2022","\u25D8","\u25CB","\u25D9","\u2642","\u2640","\u266A","\u266B","\u263C","\u25BA","\u25C4","\u2195","\u203C","\xB6","\xA7","\u25AC","\u21A8","\u2191","\u2193","\u2192","\u2190","\u221F","\u2194","\u25B2","\u25BC"],Ie=["\xC7","\xFC","\xE9","\xE2","\xE4","\xE0","\xE5","\xE7","\xEA","\xEB","\xE8","\xEF","\xEE","\xEC","\xC4","\xC5","\xC9","\xE6","\xC6","\xF4","\xF6","\xF2","\xFB","\xF9","\xFF","\xD6","\xDC","\xF8","\xA3","\xD8","\xD7","\u0192","\xE1","\xED","\xF3","\xFA","\xF1","\xD1","\xAA","\xBA","\xBF","\xAE","\xAC","\xBD","\xBC","\xA1","\xAB","\xBB","\u2591","\u2592","\u2593","\u2502","\u2524","\xC1","\xC2","\xC0","\xA9","\u2563","\u2551","\u2557","\u255D","\xA2","\xA5","\u2510","\u2514","\u2534","\u252C","\u251C","\u2500","\u253C","\xE3","\xC3","\u255A","\u2554","\u2569","\u2566","\u2560","\u2550","\u256C","\xA4","\xF0","\xD0","\xCA","\xCB","\xC8","\u0131","\xCD","\xCE","\xCF","\u2518","\u250C","\u2588","\u2584","\xA6","\xCC","\u2580","\xD3","\xDF","\xD4","\xD2","\xF5","\xD5","\xB5","\xFE","\xDE","\xDA","\xDB","\xD9","\xFD","\xDD","\xAF","\xB4","\xAD","\xB1","\u2017","\xBE","\xB6","\xA7","\xF7","\xB8","\xB0","\xA8","\xB7","\xB9","\xB3","\xB2","\u25A0","\xA0"],De=["\u0410","\u0411","\u0412","\u0413","\u0414","\u0415","\u0416","\u0417","\u0418","\u0419","\u041A","\u041B","\u041C","\u041D","\u041E","\u041F","\u0420","\u0421","\u0422","\u0423","\u0424","\u0425","\u0426","\u0427","\u0428","\u0429","\u042A","\u042B","\u042C","\u042D","\u042E","\u042F","\u0430","\u0431","\u0432","\u0433","\u0434","\u0435","\u0436","\u0437","\u0438","\u0439","\u043A","\u043B","\u043C","\u043D","\u043E","\u043F","\u2591","\u2592","\u2593","\u2502","\u2524","\u2561","\u2562","\u2556","\u2555","\u2563","\u2551","\u2557","\u255D","\u255C","\u255B","\u2510","\u2514","\u2534","\u252C","\u251C","\u2500","\u253C","\u255E","\u255F","\u255A","\u2554","\u2569","\u2566","\u2560","\u2550","\u256C","\u2567","\u2568","\u2564","\u2565","\u2559","\u2558","\u2552","\u2553","\u256B","\u256A","\u2518","\u250C","\u2588","\u2584","\u258C","\u2590","\u2580","\u0440","\u0441","\u0442","\u0443","\u0444","\u0445","\u0446","\u0447","\u0448","\u0449","\u044A","\u044B","\u044C","\u044D","\u044E","\u044F","\u0401","\u0451","\u0404","\u0454","\u0407","\u0457","\u040E","\u045E","\xB0","\u2219","\xB7","\u221A","\u2116","\xA4","\u25A0","\xA0"],ve=["\u20AC","\x81","\u201A","\u0192","\u201E","\u2026","\u2020","\u2021","\u02C6","\u2030","\u0160","\u2039","\u0152","\x8D","\u017D","\x8F","\x90","\u2018","\u2019","\u201C","\u201D","\u2022","\u2013","\u2014","\u02DC","\u2122","\u0161","\u203A","\u0153","\x9D","\u017E","\u0178","\xA0","\xA1","\xA2","\xA3","\xA4","\xA5","\xA6","\xA7","\xA8","\xA9","\xAA","\xAB","\xAC","\xAD","\xAE","\xAF","\xB0","\xB1","\xB2","\xB3","\xB4","\xB5","\xB6","\xB7","\xB8","\xB9","\xBA","\xBB","\xBC","\xBD","\xBE","\xBF","\xC0","\xC1","\xC2","\xC3","\xC4","\xC5","\xC6","\xC7","\xC8","\xC9","\xCA","\xCB","\xCC","\xCD","\xCE","\xCF","\xD0","\xD1","\xD2","\xD3","\xD4","\xD5","\xD6","\xD7","\xD8","\xD9","\xDA","\xDB","\xDC","\xDD","\xDE","\xDF","\xE0","\xE1","\xE2","\xE3","\xE4","\xE5","\xE6","\xE7","\xE8","\xE9","\xEA","\xEB","\xEC","\xED","\xEE","\xEF","\xF0","\xF1","\xF2","\xF3","\xF4","\xF5","\xF6","\xF7","\xF8","\xF9","\xFA","\xFB","\xFC","\xFD","\xFE","\xFF"],Be={cp437:We,cp850:Ie,cp866:De,cp1252:ve},Pt={cp437:O,cp850:void 0,cp866:void 0,cp1252:void 0};var C=z$1.enum(["cp437","cp850","cp866","cp1252"]),Ot=z$1.enum(["replace","skip","error"]),Zo=z$1.object({codepage:C,unmappable:Ot.default("replace"),replacement:z$1.string().default("\uFFFD"),interpretControlChars:z$1.boolean().default(false)}).strict(),Nt=128,zt=32,Ko=128,Ht=255;function qo(e,t){let n=new Map;for(let r=0;r<e.length;r++){let o=e[r];o&&n.set(o,Nt+r);}if(t)for(let r=0;r<t.length;r++){let o=t[r];o&&o!=="\0"&&n.set(o,r);}for(let r=0;r<zt;r++)n.set(String.fromCharCode(r),r);for(let r=32;r<=126;r++)n.set(String.fromCharCode(r),r);return n.set("\x7F",127),n}var _t=new Map;function Gt(e){let t=_t.get(e);if(t)return t;let n=Be[e],r=Pt[e];if(!n)throw new Error(`Unknown codepage: ${e}`);let o=qo(n,r);return _t.set(e,o),o}function Fe(e,t,n){let r=C.parse(t);if(e<0||e>Ht)throw new RangeError(`Byte value must be 0-255, got: ${e}`);let o=e|0;if(o<zt){if(n?.interpretControlChars&&r==="cp437"){let s=O[o];if(s)return s}return String.fromCharCode(o)}if(o<Ko)return String.fromCharCode(o);let i=Be[r];if(!i)throw new Error(`Unknown codepage: ${r}`);let a=o-Nt,l=i[a];return l||(n?.replacement??"\uFFFD")}function Xo(e,t){let n=C.parse(t),r=Gt(n),i=[...e][0];if(i)return r.get(i)}function Yo(e,t,n){let r=C.parse(t),o={replacement:"\uFFFD",interpretControlChars:false,...n},i=[];for(let a=0;a<e.length;a++){let l=e[a];if(l===void 0)continue;let s=Fe(l,r,o);i.push(s);}return i.join("")}function Jo(e,t,n){let r=C.parse(t),o={unmappable:"replace",replacement:"?",...n},i=Gt(r),a=[],l=[...e];for(let s=0;s<l.length;s++){let u=l[s];if(!u)continue;let d=i.get(u);if(d!==void 0){a.push(d);continue}switch(o.unmappable){case "error":throw new Error(`Character '${u}' (U+${u.codePointAt(0)?.toString(16).toUpperCase().padStart(4,"0")}) cannot be encoded in ${r}`);case "skip":break;default:{let f=o.replacement??"?",c=i.get(f);c!==void 0?a.push(c):a.push(63);break}}}return Buffer.from(a)}function Qo(e){return C.safeParse(e).success}function ei(){return ["cp437","cp850","cp866","cp1252"]}function ti(e,t){let n=C.parse(e),r=[];for(let o=0;o<=Ht;o++)r.push(Fe(o,n,t));return r}var Vt=55296,jt=56319,$t=56320,Zt=57343;function Pe(e){return e>=55296&&e<=56319}function _e(e){return e>=56320&&e<=57343}function z(e){return e>=55296&&e<=57343}function Kt(e,t){if(t<0||t>=e.length)return false;let n=e.charCodeAt(t);return z(n)}function qt(e,t){if(!Pe(e))throw new Error(`Invalid high surrogate: 0x${e.toString(16)}`);if(!_e(t))throw new Error(`Invalid low surrogate: 0x${t.toString(16)}`);return (e-55296)*1024+(t-56320)+65536}function Xt(e){if(e<=65535)throw new Error(`Code point 0x${e.toString(16)} doesn't need surrogate encoding`);if(e>1114111)throw new Error(`Invalid code point: 0x${e.toString(16)} (exceeds U+10FFFF)`);let t=e-65536,n=(t>>10)+55296,r=(t&1023)+56320;return [n,r]}function Yt(e,t){if(t<0||t>=e.length)return -1;let n=e.codePointAt(t);return n===void 0?-1:n}function Jt(...e){return String.fromCodePoint(...e)}function*Oe(e){for(let t of e){let n=t.codePointAt(0);n!==void 0&&(yield n);}}function Qt(e){return [...Oe(e)]}function*en(e){for(let t of e)yield t;}function tn(e){let t=0;for(let n of e)t++;return t}function nn(e){return !(e<0||e>1114111||e>=55296&&e<=57343)}function rn(e){return e>=0&&e<=65535}function te(e){return e>=65536&&e<=1114111}function on(e,t){if(t<0)return "";let n=0;for(let r of e){if(n===t)return r;n++;}return ""}function an(e,t,n){let r=t<0?0:t,o="",i=0;for(let a of e){if(n!==void 0&&i>=n)break;i>=r&&(o+=a),i++;}return o}var ne=[[768,879],[6832,6911],[7616,7679],[8400,8447],[65056,65071],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2260,2273],[2275,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2901,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6159,6159],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[65024,65039],[917760,917999]],re=new Set((function*(){for(let[e,t]of ne)for(let n=e;n<=t;n++)yield n;})());function ni(e,t){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t[o];if(!i)break;let[a,l]=i;if(e<a)r=o-1;else if(e>l)n=o+1;else return true}return false}function H(e){return e<768?false:re.has(e)}function ln(e){return e<768?false:ni(e,ne)}function sn(){return re.size}var Ne=[[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12352,12447],[12448,12543],[12544,12591],[12592,12687],[12688,12703],[12704,12735],[12736,12783],[12784,12799],[12800,13055],[13056,13311],[13312,19903],[19968,40959],[40960,42127],[42128,42191],[44032,55203],[63744,64255],[65040,65055],[65072,65103],[65104,65135],[65280,65376],[65504,65510],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[194560,195103],[196608,201551],[201552,205743]],un=[[65281,65374],[65504,65510]],ze=[[0,31],[127,159],[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2260,2273],[2275,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[6832,6845],[6846,6846],[6847,6848],[7616,7679],[8203,8207],[8288,8292],[8294,8303],[8400,8447],[65024,65039],[65056,65071],[65279,65279],[917760,917999]],He=[[161,161],[164,164],[167,168],[170,170],[173,174],[176,180],[182,186],[188,191],[198,198],[208,208],[215,216],[222,225],[230,230],[232,234],[236,237],[240,240],[242,243],[247,250],[252,252],[254,254],[913,929],[931,937],[945,961],[963,969],[1025,1025],[1040,1103],[1105,1105],[9472,9599],[9600,9631],[9632,9727],[9728,9983],[9984,10175]],Ge=[[127744,128511],[128512,128591],[128640,128767],[129280,129535],[129536,129647],[129648,129791]];function oe(e,t){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t[o];if(!i)break;let[a,l]=i;if(e<a)r=o-1;else if(e>l)n=o+1;else return true}return false}function D(e){return e<4352?false:!!(oe(e,Ne)||oe(e,Ge))}function S(e){return oe(e,ze)}function Ue(e){return oe(e,He)}function p(e,t=false){return S(e)?0:D(e)||t&&Ue(e)?2:1}var dn=typeof Intl<"u"&&"Segmenter"in Intl,Ve=null;function fn(){return dn?(Ve||(Ve=new Intl.Segmenter(void 0,{granularity:"grapheme"})),Ve):null}function*A(e){if(e.length===0)return;let t=fn();if(t)for(let n of t.segment(e))yield n.segment;else for(let n of e)yield n;}function je(e){return [...A(e)]}function cn(e){if(e.length===0)return 0;let t=fn();if(t){let r=0;for(let o of t.segment(e))r++;return r}let n=0;for(let r of e)n++;return n}function mn(e,t){if(t<0)return;let n=0;for(let r of A(e)){if(n===t)return r;n++;}}function hn(e,t,n){let r=t<0?0:t,o="",i=0;for(let a of A(e)){if(n!==void 0&&i>=n)break;i>=r&&(o+=a),i++;}return o}function le(e){if(e.length===0)return 0;let t=e.codePointAt(0);return t===void 0?0:ri(e)?2:p(t)}function ri(e){if(e.length===0)return false;let t=e.codePointAt(0);return t===void 0?false:!!(t>=127462&&t<=127487||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=9728&&t<=9983||t>=9984&&t<=10175||e.includes("\uFE0F")||e.includes("\u200D"))}function ie(e){let t=0;for(let n of A(e))t+=le(n);return t}function ae(e,t){let n=0,r="";for(let o of A(e)){let i=le(o);if(n+i>t)return {text:r,width:n,truncated:true};n+=i,r+=o;}return {text:r,width:n,truncated:false}}function gn(e,t,n="\u2026"){if(ie(e)<=t)return e;let o=ie(n);if(o>=t)return ae(n,t).text;let i=t-o;return ae(e,i).text+n}function pn(){return dn}function bn(e){return je(e).reverse().join("")}var oi={replacement:"?",dropWide:true,dropCombining:true,dropAstral:true,dropZeroWidth:true,dropControl:false};function xn(e){return e>=0&&e<=31?e!==9&&e!==10&&e!==13:e===127||e>=128&&e<=159}function ii(e){return e===9||e===10||e===13}function ai(e,t,n){return n&&S(t)?ii(t)?e:"":null}function li(e,t,n,r,o){return te(t)?n||r&&D(t)?o:e:null}function si(e,t,n){if(z(t))return n.replacement;if(H(t))return n.dropCombining?"":e;if(xn(t))return n.dropControl?"":e;let r=ai(e,t,n.dropZeroWidth);if(r!==null)return r;let o=li(e,t,n.dropAstral,n.dropWide,n.replacement);return o!==null?o:n.dropWide&&D(t)?n.replacement:e}function yn(e,t){let n={...oi,...t},r="";for(let o of e){let i=o.codePointAt(0);if(i===void 0){r+=n.replacement;continue}r+=si(o,i,n);}return r}function Cn(e,t="?"){let n="";for(let r of e){let o=r.codePointAt(0);if(o===void 0){n+=t;continue}o>=32&&o<=126||o===9||o===10||o===13?n+=r:n+=t;}return n}function Sn(e){let t="";for(let n of e){let r=n.codePointAt(0);r!==void 0&&!S(r)&&(t+=n);}return t}function Ln(e){let t="";for(let n of e){let r=n.codePointAt(0);r!==void 0&&!H(r)&&(t+=n);}return t}function kn(e){let t="";for(let n of e){let r=n.codePointAt(0);r!==void 0&&!xn(r)&&(t+=n);}return t}function Tn(e){return e.normalize("NFC")}function Rn(e){return e.normalize("NFD")}function An(e){return e.normalize("NFKC")}function wn(e){return e.normalize("NFKD")}function En(e,t=false){return p(e,t)}function G(e,t=false){if(e.length===0)return 0;let n=e.codePointAt(0);return n===void 0?0:p(n,t)}function Mn(e,t,n=false){if(t<0)return -1;let r=0;for(let o of e){if(r===t){let i=o.codePointAt(0);return i===void 0?0:p(i,n)}r++;}return -1}var ue=8,de=9;function b(e,t){let n=t?.tabWidth??ue,r=t?.ambiguousAsWide??false,o=0;for(let i of e){let a=i.codePointAt(0);if(a!==void 0){if(a===de){let l=o%n;o+=n-l;continue}o+=p(a,r);}}return o}function Wn(e,t){return b(e,t)}function $e(e,t,n){let r=n?.ambiguousAsWide??false,o=n?.tabWidth??ue,i=0,a="";for(let l of e){let s=l.codePointAt(0);if(s===void 0)continue;let u;if(s===de){let d=i%o;u=o-d;}else u=p(s,r);if(i+u>t)return {text:a,width:i,truncated:true};i+=u,a+=l;}return {text:a,width:i,truncated:false}}function se(e,t,n){return $e(e,t,n).text}function In(e,t,n="\u2026",r){if(b(e,r)<=t)return e;let i=b(n,r);if(i>=t)return se(n,t,r);let a=t-i;return se(e,a,r)+n}function Dn(e,t,n=" ",r){let o=b(e,r);if(o>=t)return e;let i=G(n,r?.ambiguousAsWide);if(i===0)return e;let a=t-o,l=Math.floor(a/i);return e+n.repeat(l)}function vn(e,t,n=" ",r){let o=b(e,r);if(o>=t)return e;let i=G(n,r?.ambiguousAsWide);if(i===0)return e;let a=t-o,l=Math.floor(a/i);return n.repeat(l)+e}function Bn(e,t,n=" ",r){let o=b(e,r);if(o>=t)return e;let i=G(n,r?.ambiguousAsWide);if(i===0)return e;let a=t-o,l=Math.floor(a/2),s=a-l,u=Math.floor(l/i),d=Math.floor(s/i);return n.repeat(u)+e+n.repeat(d)}function Fn(e,t,n){let r=n?.ambiguousAsWide??false,o=n?.tabWidth??ue;if(t<0)return -1;let i=0,a=0;for(let l of e){let s=l.codePointAt(0);if(s===void 0){a++;continue}let u;if(s===de){let d=i%o;u=o-d;}else u=p(s,r);if(t>=i&&t<i+u||u===0&&t===i)return a;i+=u,a++;}return -1}function Pn(e,t,n){let r=n?.ambiguousAsWide??false,o=n?.tabWidth??ue;if(t<0)return -1;let i=0,a=0;for(let l of e){if(a===t)return i;let s=l.codePointAt(0);if(s===void 0){a++;continue}let u;if(s===de){let d=i%o;u=o-d;}else u=p(s,r);i+=u,a++;}return -1}function _n(e){for(let t of e){let n=t.codePointAt(0);if(n!==void 0&&p(n)===2)return true}return false}function On(e){for(let t of e){let n=t.codePointAt(0);if(n!==void 0&&S(n))return true}return false}var Nn=z$1.object({codePoint:z$1.number().int().nonnegative(),width:z$1.number().int().min(0).max(2)}),zn=z$1.object({terminal:z$1.string().min(1),overrides:z$1.array(Nn)});function ui(){return [{label:"Family emoji (ZWJ sequence)",input:"\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}",expectedWidth:2,category:"emoji-zwj",notes:"Most terminals render as single 2-wide glyph, some render 8-wide"},{label:"Couple with heart (ZWJ)",input:"\u{1F469}\u200D\u2764\uFE0F\u200D\u{1F468}",expectedWidth:2,category:"emoji-zwj",notes:"ZWJ joins three characters into one grapheme"},{label:"Person with white hair (ZWJ)",input:"\u{1F9D1}\u200D\u{1F9B3}",expectedWidth:2,category:"emoji-zwj"},{label:"Pirate flag (ZWJ)",input:"\u{1F3F4}\u200D\u2620\uFE0F",expectedWidth:2,category:"emoji-zwj"},{label:"ZWJ character alone",input:"\u200D",expectedWidth:0,category:"emoji-zwj"},{label:"US flag (regional indicators)",input:"\u{1F1FA}\u{1F1F8}",expectedWidth:2,category:"regional-indicators",notes:"Two regional indicators form a flag"},{label:"Japan flag",input:"\u{1F1EF}\u{1F1F5}",expectedWidth:2,category:"regional-indicators"},{label:"Single regional indicator",input:"\u{1F1FA}",expectedWidth:2,category:"regional-indicators",notes:"Unpaired regional indicators vary by terminal"},{label:"Text presentation (VS15)",input:"\u2764\uFE0E",expectedWidth:1,category:"variation-selectors",notes:"VS15 forces text presentation (narrow)"},{label:"Emoji presentation (VS16)",input:"\u2764\uFE0F",expectedWidth:2,category:"variation-selectors",notes:"VS16 forces emoji presentation (wide)"},{label:"Number sign with VS16",input:"#\uFE0F\u20E3",expectedWidth:2,category:"variation-selectors",notes:"Keycap sequence"},{label:"Variation selector alone",input:"\uFE0F",expectedWidth:0,category:"variation-selectors"},{label:"CJK ideograph (U+4E2D)",input:"\u4E2D",expectedWidth:2,category:"cjk"},{label:'CJK string "\u4E2D\u6587\u6D4B\u8BD5"',input:"\u4E2D\u6587\u6D4B\u8BD5",expectedWidth:8,category:"cjk"},{label:"Hangul syllable (\uAC00)",input:"\uAC00",expectedWidth:2,category:"cjk"},{label:"Katakana (\u30AB\u30BF\u30AB\u30CA)",input:"\u30AB\u30BF\u30AB\u30CA",expectedWidth:8,category:"cjk"},{label:"CJK compatibility ideograph",input:"\uF900",expectedWidth:2,category:"cjk"},{label:"Latin a + combining acute",input:"a\u0301",expectedWidth:1,category:"combining"},{label:"Multiple combining marks (Zalgo-style)",input:"a\u0300\u0301\u0302\u0303",expectedWidth:1,category:"combining",notes:"All combining marks are zero-width"},{label:"Devanagari with combining",input:"\u0915\u094D\u0937",expectedWidth:2,category:"combining",notes:"Consonant cluster"},{label:"Korean jamo with combining",input:"\u1100\u1161",expectedWidth:2,category:"combining",notes:"Lead + vowel jamo"},{label:"Single tab",input:" ",expectedWidth:8,category:"tabs",notes:"Default tab width is 8"},{label:"Tab after 3 chars",input:"abc ",expectedWidth:8,category:"tabs",notes:"Tab extends to next 8-column boundary"},{label:"Null character",input:"\0",expectedWidth:0,category:"control"},{label:"Bell character",input:"\x07",expectedWidth:0,category:"control"},{label:"Backspace",input:"\b",expectedWidth:0,category:"control"},{label:"Soft hyphen",input:"\xAD",expectedWidth:1,category:"control",notes:"Soft hyphen is technically a format character but width=1 in most terminals"},{label:"Fullwidth A",input:"\uFF21",expectedWidth:2,category:"fullwidth"},{label:"Fullwidth digits",input:"\uFF10\uFF11\uFF12",expectedWidth:6,category:"fullwidth"},{label:"Fullwidth exclamation mark",input:"\uFF01",expectedWidth:2,category:"fullwidth"},{label:"Halfwidth katakana",input:"\uFF66",expectedWidth:1,category:"halfwidth"},{label:"Halfwidth Hangul",input:"\uFFA0",expectedWidth:1,category:"halfwidth"},{label:"Greek alpha",input:"\u03B1",expectedWidth:1,category:"ambiguous",notes:"Ambiguous width - 1 in Western locale, 2 in CJK locale"},{label:"Box drawing (light horizontal)",input:"\u2500",expectedWidth:1,category:"ambiguous"},{label:"Bullet (\u2022)",input:"\u2022",expectedWidth:1,category:"ambiguous"},{label:"Musical symbol (U+1D11E)",input:"\u{1D11E}",expectedWidth:1,category:"surrogate-pairs"},{label:"Emoji face (U+1F600)",input:"\u{1F600}",expectedWidth:2,category:"surrogate-pairs"},{label:"Skin tone modifier (U+1F3FD)",input:"\u{1F44B}\u{1F3FD}",expectedWidth:2,category:"surrogate-pairs",notes:"Waving hand + medium skin tone"},{label:"ASCII + CJK mixed",input:"Hello\u4E16\u754C",expectedWidth:9,category:"mixed"},{label:"Emoji + text mixed",input:"\u{1F389} Party!",expectedWidth:9,category:"mixed"},{label:"Empty string",input:"",expectedWidth:0,category:"mixed"},{label:"Newline only",input:`
9
+ `,expectedWidth:0,category:"mixed"}]}function di(){return [{label:"Family ZWJ emoji",input:"\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}",expectedWidth:2,terminalWidths:{"xterm-256color":8,kitty:2,alacritty:2,wezterm:2,"gnome-terminal":2,iterm2:2,"windows-terminal":2},severity:"major"},{label:"Flag sequence (regional indicators)",input:"\u{1F1FA}\u{1F1F8}",expectedWidth:2,terminalWidths:{"xterm-256color":4,kitty:2,alacritty:2,wezterm:2,iterm2:2},severity:"major"},{label:"Unpaired regional indicator",input:"\u{1F1FA}",expectedWidth:2,terminalWidths:{"xterm-256color":2,kitty:1,alacritty:2},severity:"minor"},{label:"Skin tone emoji",input:"\u{1F44B}\u{1F3FD}",expectedWidth:2,terminalWidths:{"xterm-256color":4,kitty:2,alacritty:2,iterm2:2},severity:"major"},{label:"VS16 heart emoji",input:"\u2764\uFE0F",expectedWidth:2,terminalWidths:{"xterm-256color":1,kitty:2,alacritty:2,iterm2:2},severity:"minor"},{label:"Keycap sequence #\uFE0F\u20E3",input:"#\uFE0F\u20E3",expectedWidth:2,terminalWidths:{"xterm-256color":2,kitty:2,alacritty:1},severity:"minor"},{label:"Devanagari conjunct",input:"\u0915\u094D\u0937",expectedWidth:2,terminalWidths:{"xterm-256color":1,kitty:2,alacritty:1},severity:"minor"},{label:"Zalgo text (heavy combining)",input:"a\u0300\u0301\u0302\u0303\u0304\u0305\u0306\u0307",expectedWidth:1,terminalWidths:{"xterm-256color":1,kitty:1,alacritty:1},severity:"critical"}]}var B=new Map;function fi(e){let t=zn.parse(e);for(let n of t.overrides)B.set(n.codePoint,n.width);}function ci(){B.clear();}function mi(){return B.size}function hi(e){return B.get(e)??null}function gi(e,t){if(B.size===0)return b(e,t);let n=t?.tabWidth??8,r=0,o=0;for(let i=0;i<e.length;i++){let a=e.codePointAt(i);if(a===void 0)continue;if(a===10){o=0;continue}if(a===9){let s=n-o%n;r+=s,o+=s;continue}let l=B.get(a);if(l!==void 0)r+=l,o+=l;else {let s=p(a);r+=s,o+=s;}a>65535&&i++;}return r}function pi(e,t){let n=[],r=0;for(let o of e){let i=b(o.input,t);i===o.expectedWidth?r++:n.push({testCase:o,actualWidth:i});}return {total:e.length,passed:r,failed:n.length,failures:n}}function bi(e,t){return e.filter(n=>n.category===t)}function xi(e){let t=new Set;for(let n of e)t.add(n.category);return [...t]}function yi(e){let t=[];if(t.push(`Width Test Results: ${e.passed}/${e.total} passed`),t.push(""),e.failures.length===0)return t.push("All tests passed!"),t.join(`
10
+ `);t.push(`Failures (${e.failed}):`);for(let n of e.failures)t.push(` [${n.testCase.category}] ${n.testCase.label}`),t.push(` Expected: ${n.testCase.expectedWidth}, Got: ${n.actualWidth}`),t.push(` Input: ${JSON.stringify(n.testCase.input)}`),n.testCase.notes&&t.push(` Note: ${n.testCase.notes}`);return t.join(`
11
+ `)}var Ci=1e3,Hn=100;function fe(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Si(e){return {width:e,entries:new Map,dirty:new Set,totalLines:0,lineOffsets:[],fullInvalidate:true}}function Li(e){e.entries.clear(),e.dirty.clear(),e.totalLines=0,e.lineOffsets.length=0,e.fullInvalidate=true;}function ki(e,t){if(e.width!==t){e.width=t,e.fullInvalidate=true;for(let[n]of e.entries)e.dirty.add(n);}}function Ti(e,t,n,r){if(t<=0)return {lines:[""],breakPoints:[0]};if(e.length===0)return {lines:[""],breakPoints:[0]};let o=Ri();for(let i=0;i<=e.length;i++)Ii(o,e,i,t,n,r);return {lines:o.lines,breakPoints:o.breakPoints}}function Ri(){return {lines:[],breakPoints:[0],lineStart:0,lineWidth:0,wordWidth:0,lastBreakable:-1,lastBreakableWidth:0}}function Ai(e,t,n,r){let o=t.slice(e.lineStart,n);(o.length>0||e.lines.length===0)&&(e.lines.push(o),r||e.breakPoints.push(n+1)),wi(e,n+1);}function wi(e,t){e.lineStart=t,e.lineWidth=0,e.wordWidth=0,e.lastBreakable=-1,e.lastBreakableWidth=0;}function Ei(e,t,n){e.lastBreakable=t,e.lastBreakableWidth=e.lineWidth,e.wordWidth=0,e.lineWidth+=n;}function Mi(e,t){e.wordWidth+=t,e.lineWidth+=t;}function Wi(e,t,n,r,o,i){if(e.lastBreakable>=e.lineStart&&!i){let a=t.slice(e.lineStart,e.lastBreakable);e.lines.push(a),e.breakPoints.push(e.lastBreakable+1),e.lineStart=e.lastBreakable+1,e.lineWidth=e.lineWidth-e.lastBreakableWidth-1,e.lastBreakable=-1;return}if(i||e.wordWidth>o){let a=t.slice(e.lineStart,n);e.lines.push(a),e.breakPoints.push(n),e.lineStart=n,e.lineWidth=r,e.wordWidth=r,e.lastBreakable=-1;}}function Ii(e,t,n,r,o,i){let a=n<t.length?t[n]:void 0,l=n===t.length;if(a===`
12
+ `||l){Ai(e,t,n,l);return}let u=i?b(a??""):1;a===" "||a===" "?Ei(e,n,u):Mi(e,u),e.lineWidth>r&&Wi(e,t,n,u,r,o);}function Ze(e,t,n,r){let{lines:o,breakPoints:i}=Ti(e,t,n,r);return {text:e,hash:fe(e),width:t,lines:o,breakPoints:i}}function Di(e,t,n){let r=n?.width??e.width,o=n?.breakWord??false,i=n?.unicodeWidth??true,a=t.split(`
13
+ `),l=[];e.lineOffsets.length=0;let s=0;for(let u=0;u<a.length;u++){let d=a[u];if(d===void 0)continue;e.lineOffsets.push(s);let f=e.entries.get(u),c=fe(d);if(f&&f.hash===c&&f.width===r&&!e.dirty.has(u)&&!e.fullInvalidate){l.push(...f.lines),s+=f.lines.length;continue}let m=Ze(d,r,o,i);e.entries.set(u,m),e.dirty.delete(u),l.push(...m.lines),s+=m.lines.length;}e.totalLines=s,e.fullInvalidate=false;for(let[u]of e.entries)u>=a.length&&e.entries.delete(u);return l}function vi(e,t,n,r,o){let i=performance.now(),a=o?.width??e.width,l=o?.breakWord??false,s=o?.unicodeWidth??true,u=t.split(`
14
+ `),d=[],f=Bi(e,n),c=f.currentLine,m=f.targetParagraph,h=0,g=u.length;for(let x=m;x<g&&c<r;x++){let St=u[x];if(St===void 0)continue;let kr=Fi(e,x,St,a,l,s);c=Pi(d,kr.lines,c,n,r),h=x+1;}let W=performance.now()-i;return {lines:d,hasMore:h<g,nextParagraph:h,timeMs:W}}function Bi(e,t){let n=0,r=0;if(e.lineOffsets.length===0||e.fullInvalidate)return {targetParagraph:n,currentLine:r};for(let o=0;o<e.lineOffsets.length;o++){let i=e.lineOffsets[o];if(i!==void 0&&i<=t)n=o,r=i;else break}return {targetParagraph:n,currentLine:r}}function Fi(e,t,n,r,o,i){let a=e.entries.get(t),l=fe(n);if(a&&a.hash===l&&a.width===r&&!e.dirty.has(t)&&!e.fullInvalidate)return a;let s=Ze(n,r,o,i);return e.entries.set(t,s),e.dirty.delete(t),s}function Pi(e,t,n,r,o){let i=n;for(let a=0;a<t.length;a++){if(i>=r&&i<o){let l=t[a];l!==void 0&&e.push(l);}i++;}return i}function _i(e,t,n,r=Hn,o){let i=performance.now(),a=o?.width??e.width,l=o?.breakWord??false,s=o?.unicodeWidth??true,u=t.split(`
15
+ `),d=[],f=Math.min(n+r,u.length);for(let m=n;m<f;m++){let h=u[m];if(h===void 0)continue;let g=e.entries.get(m),W=fe(h),x;g&&g.hash===W&&g.width===a&&!e.dirty.has(m)&&!e.fullInvalidate?x=g:(x=Ze(h,a,l,s),e.entries.set(m,x),e.dirty.delete(m)),d.push(...x.lines);}let c=performance.now()-i;return {lines:d,hasMore:f<u.length,nextParagraph:f,timeMs:c}}function Oi(e,t,n){for(let r=t;r<n;r++)e.dirty.add(r);}function Ni(e,t){e.dirty.add(t);}function zi(e){e.fullInvalidate=true;}function Hi(e,t){if(t<0||t>=e.totalLines)return;let n=0,r=e.lineOffsets.length-1,o=0;for(;n<=r;){let u=Math.floor((n+r)/2),d=e.lineOffsets[u];if(d===void 0)break;d<=t?(o=u,n=u+1):r=u-1;}let i=e.lineOffsets[o]??0,a=t-i,s=e.entries.get(o)?.breakPoints[a]??0;return {paragraph:o,lineInParagraph:a,charOffset:s}}function Gi(e,t,n=0){if(t<0||t>=e.lineOffsets.length)return -1;let r=e.lineOffsets[t];return r===void 0?-1:r+n}function Ui(e){return {cachedParagraphs:e.entries.size,dirtyParagraphs:e.dirty.size,totalLines:e.totalLines,width:e.width,fullInvalidate:e.fullInvalidate}}var Vi={minFoldableLines:2,labelTemplate:"... {count} lines",maxDepth:10};function ji(e,t){return {config:{...Vi,...t},regions:new Map,totalDocumentLines:e,nextId:0}}function $i(e,t,n,r){let o=n-t;if(o<e.config.minFoldableLines||t<0||n>=e.totalDocumentLines||t>=n)return;let i=`fold-${e.nextId++}`,a=la(e,t,n);if(a>=e.config.maxDepth)return;let l=r??e.config.labelTemplate.replace("{count}",String(o)),s={id:i,startLine:t,endLine:n,folded:false,label:l,depth:a};return e.regions.set(i,s),i}function Zi(e,t){return e.regions.delete(t)}function Ki(e,t){let n=e.regions.get(t);return !n||n.folded?false:(e.regions.set(t,{...n,folded:true}),true)}function qi(e,t){let n=e.regions.get(t);return !n||!n.folded?false:(e.regions.set(t,{...n,folded:false}),true)}function Xi(e,t){let n=e.regions.get(t);if(!n)return;let r=!n.folded;return e.regions.set(t,{...n,folded:r}),r}function Yi(e){let t=0;for(let[n,r]of e.regions)r.folded||(e.regions.set(n,{...r,folded:true}),t++);return t}function Ji(e){let t=0;for(let[n,r]of e.regions)r.folded&&(e.regions.set(n,{...r,folded:false}),t++);return t}function Qi(e,t){let n=0;for(let[r,o]of e.regions)o.depth>=t&&!o.folded&&(e.regions.set(r,{...o,folded:true}),n++);return n}function ea(e,t){let n;for(let r of e.regions.values())t>=r.startLine&&t<=r.endLine&&(!n||r.depth>n.depth)&&(n=r);return n}function ta(e){return Array.from(e.regions.values()).sort((t,n)=>t.startLine-n.startLine)}function na(e,t,n){let r=me(e),o=[],i=0,a=0;for(;i<t&&a<e.totalDocumentLines;){let l=ce(r,a);l?(i++,a=l.endLine+1):(i++,a++);}for(;o.length<n&&a<e.totalDocumentLines;){let l=ce(r,a);l?(o.push({originalLine:l.startLine,isFoldPlaceholder:true,foldId:l.id,foldLabel:l.label,hiddenLines:l.endLine-l.startLine}),a=l.endLine+1):(o.push({originalLine:a,isFoldPlaceholder:false,foldId:void 0,foldLabel:void 0,hiddenLines:0}),a++);}return o}function ra(e,t){let n=me(e),r=0,o=0;for(;r<t&&o<e.totalDocumentLines;){let i=ce(n,o);i?(r++,o=i.endLine+1):(r++,o++);}return o}function oa(e,t){let n=me(e),r=0,o=0;for(;o<t&&o<e.totalDocumentLines;){let i=ce(n,o);if(i){if(r++,t>i.startLine&&t<=i.endLine)return -1;o=i.endLine+1;}else r++,o++;}return r}function ia(e){let t=0,n=0,r=0,o=me(e);for(let i of o)t++,n+=i.endLine-i.startLine;for(let i of e.regions.values())i.depth>r&&(r=i.depth),i.folded&&(t=Math.max(t,t));return {totalRegions:e.regions.size,foldedRegions:t,hiddenLines:n,visibleLines:e.totalDocumentLines-n,maxDepth:r}}function aa(e,t){e.totalDocumentLines=t;for(let[n,r]of e.regions)(r.startLine>=t||r.endLine>=t)&&e.regions.delete(n);}function la(e,t,n){let r=0;for(let o of e.regions.values())o.startLine<=t&&o.endLine>=n&&(r=Math.max(r,o.depth+1));return r}function me(e){let t=[];for(let r of e.regions.values())r.folded&&t.push({id:r.id,startLine:r.startLine,endLine:r.endLine,label:r.label});t.sort((r,o)=>r.startLine-o.startLine);let n=[];for(let r of t){let o=n[n.length-1];if(o&&r.startLine<=o.endLine){r.endLine>o.endLine&&(n[n.length-1]={...o,endLine:r.endLine});continue}n.push(r);}return n}function ce(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=n+r>>>1,i=e[o];if(!i)break;if(t<i.startLine)r=o-1;else if(t>i.endLine)n=o+1;else return i}}var sa=z$1.object({caseSensitive:z$1.boolean().default(false),threshold:z$1.number().min(0).max(1).default(0),limit:z$1.number().int().positive().optional(),consecutiveBonus:z$1.number().min(0).max(1).default(.3),wordBoundaryBonus:z$1.number().min(0).max(1).default(.2),prefixBonus:z$1.number().min(0).max(1).default(.5),gapPenalty:z$1.number().min(0).max(1).default(.1)}),ua={caseSensitive:false,threshold:0,limit:void 0,consecutiveBonus:.3,wordBoundaryBonus:.2,prefixBonus:.5,gapPenalty:.1};function Ke(e={}){return {...ua,...e}}function da(e,t){if(t===0)return true;let n=e[t-1],r=e[t];return !n||!r?false:n===" "||n==="_"||n==="-"||n==="/"||n===n.toLowerCase()&&r===r.toUpperCase()}function fa(e,t,n,r,o,i){let a=e.length/Math.max(t.length,e.length),l=0,s=-2;for(let u=0;u<o.length;u++){let d=o[u];if(d!==void 0){if(d===s+1)l++,a+=i.consecutiveBonus*(l/e.length);else if(l=0,s>=0){let f=d-s-1;a-=i.gapPenalty*(f/t.length);}da(t,d)&&(a+=i.wordBoundaryBonus/e.length),s=d;}}return o[0]===0&&(a+=i.prefixBonus),n===r&&(a=1),Math.max(0,Math.min(1,a))}function he(e,t,n={}){let r=Ke(n);if(!e)return {item:t,text:t,score:1,indices:[]};let o=r.caseSensitive?e:e.toLowerCase(),i=r.caseSensitive?t:t.toLowerCase(),a=[],l=0,s=0;for(;l<o.length&&s<i.length;)o[l]===i[s]&&(a.push(s),l++),s++;if(l!==o.length)return null;let u=fa(e,t,o,i,a,r);return {item:t,text:t,score:u,indices:a}}function Gn(e,t,n={}){let r=Ke(n),o=[];for(let i of t){let a=he(e,i,r);a&&a.score>=(r.threshold||0)&&o.push(a);}return o.sort((i,a)=>a.score-i.score),r.limit!==void 0&&o.length>r.limit?o.slice(0,r.limit):o}function ca(e,t,n){let{getText:r=String,...o}=n,i=Ke(o),a=[];for(let l of t){let s=r(l),u=he(e,s,i);u&&u.score>=(i.threshold||0)&&a.push({item:l,text:s,score:u.score,indices:u.indices});}return a.sort((l,s)=>s.score-l.score),i.limit!==void 0&&a.length>i.limit?a.slice(0,i.limit):a}function ma(e,t,n=r=>`[${r}]`){let r=new Set(t),o="";for(let i=0;i<e.length;i++){let a=e[i];a!==void 0&&(r.has(i)?o+=n(a):o+=a);}return o}function ha(e,t,n={}){return Gn(e,t,n).map(o=>o.item)}function ga(e,t,n={}){let r=he(e,t,n);return r!==null&&r.score>=(n.threshold??0)}function Vn(e,t){let n={...e};for(let r in t)if(Object.hasOwn(t,r)){let o=t[r],i=n[r];o!==null&&typeof o=="object"&&!Array.isArray(o)&&i!==null&&typeof i=="object"&&!Array.isArray(i)?n[r]=Vn(i,o):n[r]=o;}return n}function pa(e,t){return {...e,...t}}function ba(e){return [...e].sort((t,n)=>{let r=t.name.startsWith("."),o=n.name.startsWith(".");return r&&!o?1:!r&&o?-1:t.name.toLowerCase().localeCompare(n.name.toLowerCase())})}function xa(e){return [...e].sort((t,n)=>t.index-n.index)}function ya(e){return [...e].sort((t,n)=>n.priority-t.priority)}function Ca(e,t,n=false){return [...e].sort((r,o)=>{let i=t(r),a=t(o),l;return typeof i=="string"&&typeof a=="string"?l=i.localeCompare(a):l=i-a,n?-l:l})}var jn=new Set(["node_modules",".git",".svn",".hg","dist","build","coverage",".cache",".next","__pycache__"]);function Sa(e,t,n){let r=n?.maxDepth??10,o=new Set([...jn,...n?.excludeDirs??[]]);function i(a,l){if(l>r)return null;let s=$n(a);if(!s)return null;let u=ka(s,a,t);return u||Ta(s,a,l,r,o,i)}return i(k.resolve(e),0)}function La(e,t,n){let r=n?.maxDepth??10,o=new Set([...jn,...n?.excludeDirs??[]]),i=n?.maxResults??Number.POSITIVE_INFINITY,a=[];function l(s,u){if(u>r||a.length>=i)return;let d=$n(s);d&&(Ra(d,s,t,a,i),Aa(d,s,u,r,o,a,i,l));}return l(k.resolve(e),0),a}function $n(e){try{return Un.readdirSync(e,{withFileTypes:!0})}catch{return null}}function ka(e,t,n){for(let r of e)if(r.name===n&&r.isFile())return k.join(t,r.name);return null}function Ta(e,t,n,r,o,i){for(let a of e){if(!a.isDirectory()||o.has(a.name))continue;let l=i(k.join(t,a.name),n+1);if(l)return l}return null}function Ra(e,t,n,r,o){for(let i of e){if(r.length>=o)return;i.name===n&&i.isFile()&&r.push(k.join(t,i.name));}}function Aa(e,t,n,r,o,i,a,l){for(let s of e){if(i.length>=a)return;!s.isDirectory()||o.has(s.name)||l(k.join(t,s.name),n+1);}}function wa(e){return [...new Set(e)]}function Ea(e,t){let n=new Set,r=[];for(let o of e){let i=t(o);n.has(i)||(n.add(i),r.push(o));}return r}function Ma(e,t){let n=new Map;for(let r of e){let o=t(r),i=n.get(o);i?i.push(r):n.set(o,[r]);}return n}function Wa(e,t){let n=[],r=[];for(let o of e)t(o)?n.push(o):r.push(o);return [n,r]}var Ia={chunkSize:1e3,maxCachedChunks:50,readAheadLines:500,readBehindLines:200,maxMemoryBytes:104857600};function Da(e,t){return {config:{...Ia,...t},source:e,chunks:new Map,accessOrder:[],hits:0,misses:0}}function va(e,t,n){let r={start:Math.max(0,t),end:Math.min(n,e.source.totalLines)},o=[],i=e.config.chunkSize,a=Math.floor(r.start/i),l=Math.floor(Math.max(0,r.end-1)/i);for(let s=a;s<=l;s++){let u=Kn(e,s);if(!u)continue;let d=s*i,f=Math.max(0,r.start-d),c=Math.min(u.lines.length,r.end-d);for(let m=f;m<c;m++){let h=u.lines[m];h!==void 0&&o.push(h);}}return o}function Ba(e,t,n){let{readAheadLines:r,readBehindLines:o,chunkSize:i}=e.config,a=Math.max(0,t-o),l=Math.min(e.source.totalLines,n+r),s=Math.floor(a/i),u=Math.floor(Math.max(0,l-1)/i);for(let d=s;d<=u;d++)Kn(e,d);}function Zn(e,t){let n=t??e.config.maxCachedChunks,r=0;for(;e.chunks.size>n&&e.accessOrder.length>0;){let o=e.accessOrder.shift();if(o===void 0)break;e.chunks.has(o)&&(e.chunks.delete(o),r++);}return r}function Fa(e){e.chunks.clear(),e.accessOrder=[],e.hits=0,e.misses=0;}function Pa(e){let t=0;for(let r of e.chunks.values())t+=r.byteSize;let n=e.hits+e.misses;return {config:e.config,totalLines:e.source.totalLines,loadedChunks:e.chunks.size,memoryUsage:t,hitRate:n>0?e.hits/n:0}}function _a(e,t,n){let r=e.config.chunkSize,o=Math.floor(t/r),i=Math.floor(Math.max(0,n-1)/r);for(let a=o;a<=i;a++)if(!e.chunks.has(a))return false;return true}function Oa(e){return {totalLines:e.length,isExactCount:true,loadRange:(t,n)=>e.slice(t,n)}}function Kn(e,t){let n=e.chunks.get(t);if(n)return e.hits++,Na(e,t),{...n,lastAccessedAt:Date.now()};e.misses++;let r=e.config.chunkSize,o=t*r,i=Math.min(o+r,e.source.totalLines);if(o>=e.source.totalLines)return;e.chunks.size>=e.config.maxCachedChunks&&Zn(e,e.config.maxCachedChunks-1);let a=e.source.loadRange(o,i),l=0;for(let u of a)l+=u.length*2;let s={index:t,startLine:o,endLine:i,lines:a,byteSize:l,lastAccessedAt:Date.now()};return e.chunks.set(t,s),e.accessOrder.push(t),s}function Na(e,t){let n=e.accessOrder.indexOf(t);n>=0&&e.accessOrder.splice(n,1),e.accessOrder.push(t);}var qe={mode:"absolute",minWidth:3,rightPadding:1,padChar:" ",separator:"\u2502",highlightCurrent:true};function ge(e,t){if(e<=0)return t;let n=Math.floor(Math.log10(e))+1;return Math.max(n,t)}function qn(e,t){let n={...qe,...t};return e+n.rightPadding+1}function za(e){return {...qe,...e}}function Xn(e,t,n,r){let o=e===t;if(r==="absolute")return String(e).padStart(n," ");if(r==="relative"){if(o)return String(e).padStart(n," ");let a=Math.abs(e-t);return String(a).padStart(n," ")}if(o)return String(e).padStart(n," ");let i=Math.abs(e-t);return String(i).padStart(n," ")}function Ha(e,t,n,r,o){let i={...qe,...o},a=ge(e,i.minWidth),l=qn(a,i),s=[],u=Math.min(t+n,e);for(let d=t;d<u;d++){let f=d+1,c=f===r,h=Xn(f,r,a,i.mode)+i.padChar.repeat(i.rightPadding)+i.separator;s.push({text:h,isCurrent:c,lineNumber:f,width:l});}return {lines:s,gutterWidth:l,digitWidth:a,totalLines:e}}function Ga(e,t,n=3){return ge(e,n)!==ge(t,n)}function Ua(e,t,n,r="\x1B[0m"){return e.lines.map(o=>`${o.isCurrent?t:n}${o.text}${r}`)}var Va=100,pe={inString:null,inComment:false,templateDepth:0,commentDepth:0},U={name:"javascript",extensions:[".js",".jsx",".ts",".tsx",".mjs",".cjs"],keywords:new Set(["async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","if","implements","import","in","instanceof","interface","let","new","of","package","private","protected","public","return","static","super","switch","this","throw","try","type","typeof","var","void","while","with","yield","as","is","keyof","readonly","declare","namespace","abstract","satisfies"]),builtins:new Set(["Array","Boolean","Date","Error","Function","JSON","Math","Number","Object","Promise","RegExp","String","Symbol","Map","Set","WeakMap","WeakSet","console","window","document","globalThis","process","require","module","exports","Buffer","setTimeout","setInterval","clearTimeout","clearInterval","fetch","Response","Request","Headers","URL","URLSearchParams","FormData","Blob","File","FileReader","Intl","Proxy","Reflect","BigInt"]),types:new Set(["any","boolean","number","string","void","never","unknown","null","undefined","object","symbol","bigint"]),constants:new Set(["true","false","null","undefined","NaN","Infinity"]),operators:/[+\-*/%=<>!&|^~?:]+/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",stringDelimiters:["'",'"'],templateLiteralStart:"`",templateLiteralEnd:"`",numberPattern:/\b(?:0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+|(?:\d[\d_]*)?\.?\d[\d_]*(?:[eE][+-]?\d[\d_]*)?n?)\b/,identifierPattern:/[a-zA-Z_$][a-zA-Z0-9_$]*/,nestedComments:false},V={name:"python",extensions:[".py",".pyw",".pyi"],keywords:new Set(["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","match","case"]),builtins:new Set(["abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__"]),types:new Set(["int","float","str","bool","list","dict","set","tuple","bytes","None"]),constants:new Set(["True","False","None","Ellipsis","NotImplemented","__debug__"]),operators:/[+\-*/%=<>!@&|^~:]+/,lineComment:"#",blockCommentStart:null,blockCommentEnd:null,stringDelimiters:["'",'"',"'''",'"""'],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/\b(?:0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+|(?:\d[\d_]*)?\.?\d[\d_]*(?:[eE][+-]?\d[\d_]*)?[jJ]?)\b/,identifierPattern:/[a-zA-Z_][a-zA-Z0-9_]*/,nestedComments:false},be={name:"rust",extensions:[".rs"],keywords:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","macro_rules"]),builtins:new Set(["Option","Some","None","Result","Ok","Err","Box","Vec","String","HashMap","HashSet","Rc","Arc","RefCell","Cell","Mutex","RwLock","println","eprintln","print","eprint","format","panic","assert","assert_eq","assert_ne","debug_assert","todo","unimplemented","unreachable","cfg","derive"]),types:new Set(["bool","char","str","u8","u16","u32","u64","u128","usize","i8","i16","i32","i64","i128","isize","f32","f64","()"]),constants:new Set(["true","false"]),operators:/[+\-*/%=<>!&|^~?:@]+/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",stringDelimiters:['"'],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/\b(?:0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+|(?:\d[\d_]*)?\.?\d[\d_]*(?:[eE][+-]?\d[\d_]*)?(?:_?(?:u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|f32|f64))?)\b/,identifierPattern:/[a-zA-Z_][a-zA-Z0-9_]*/,nestedComments:true},Xe={name:"go",extensions:[".go"],keywords:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"]),builtins:new Set(["append","cap","close","complex","copy","delete","imag","len","make","new","panic","print","println","real","recover"]),types:new Set(["bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),constants:new Set(["true","false","nil","iota"]),operators:/[+\-*/%=<>!&|^~:]+/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",stringDelimiters:['"',"'","`"],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/\b(?:0[xX][0-9a-fA-F_]+|0[oO][0-7_]+|0[bB][01_]+|(?:\d[\d_]*)?\.?\d[\d_]*(?:[eE][+-]?\d[\d_]*)?i?)\b/,identifierPattern:/[a-zA-Z_][a-zA-Z0-9_]*/,nestedComments:false},xe={name:"shell",extensions:[".sh",".bash",".zsh",".fish"],keywords:new Set(["if","then","else","elif","fi","case","esac","for","while","until","do","done","in","function","select","time","coproc","return","exit","break","continue","local","declare","typeset","readonly","export","unset","shift","source","alias","unalias"]),builtins:new Set(["echo","printf","read","cd","pwd","pushd","popd","dirs","set","shopt","test","eval","exec","trap","wait","kill","jobs","fg","bg","suspend","disown","builtin","command","type","hash","help","let","true","false","getopts","bind","complete","compgen","compopt","caller","enable","mapfile","readarray","ulimit","umask"]),types:new Set([]),constants:new Set(["true","false"]),operators:/[+\-*/%=<>!&|^~?:;]+/,lineComment:"#",blockCommentStart:null,blockCommentEnd:null,stringDelimiters:['"',"'"],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/\b\d+\b/,identifierPattern:/[a-zA-Z_][a-zA-Z0-9_]*/,nestedComments:false},Ye={name:"json",extensions:[".json",".jsonc",".json5"],keywords:new Set([]),builtins:new Set([]),types:new Set([]),constants:new Set(["true","false","null"]),operators:/[:]/,lineComment:null,blockCommentStart:null,blockCommentEnd:null,stringDelimiters:['"'],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/\b-?(?:\d+)?\.?\d+(?:[eE][+-]?\d+)?\b/,identifierPattern:/[a-zA-Z_][a-zA-Z0-9_]*/,nestedComments:false},$={name:"plaintext",extensions:[".txt",".text"],keywords:new Set([]),builtins:new Set([]),types:new Set([]),constants:new Set([]),operators:/(?!)/,lineComment:null,blockCommentStart:null,blockCommentEnd:null,stringDelimiters:[],templateLiteralStart:null,templateLiteralEnd:null,numberPattern:/(?!)/,identifierPattern:/(?!)/,nestedComments:false},Je=[U,V,be,Xe,xe,Ye,$];function Qe(e){return {grammar:e,entries:new Map,dirty:new Set,lineCount:0,fullInvalidate:true}}function ja(e){e.entries.clear(),e.dirty.clear(),e.lineCount=0,e.fullInvalidate=true;}function et(e,t){if(e.grammar.name!==t.name){e.grammar=t,e.fullInvalidate=true;for(let n=0;n<e.lineCount;n++)e.dirty.add(n);}}function $a(e){return {cachedLines:e.entries.size,dirtyLines:e.dirty.size,grammar:e.grammar.name,lineCount:e.lineCount,fullInvalidate:e.fullInvalidate}}function Za(e,t,n){for(let r=t;r<n;r++)e.dirty.add(r);}function Ka(e,t){e.dirty.add(t);}function qa(e){e.fullInvalidate=true;for(let t=0;t<e.lineCount;t++)e.dirty.add(t);}function j(e,t){return e.inString===t.inString&&e.inComment===t.inComment&&e.templateDepth===t.templateDepth&&e.commentDepth===t.commentDepth}function F(e,t,n){let o=Ja(e,t,n,[]),i=Qa(e),a=Xa(i);for(;o.pos<t.length;)Ya(o,a)||o.pos++;return {text:t,tokens:o.tokens,startState:n,endState:o.state}}function Xa(e){return [el,tl,nl,rl,ol,il,al,t=>ll(t,e),fl,cl,ml,hl]}function Ya(e,t){for(let n of t)if(n(e))return true;return false}function Ja(e,t,n,r){return {grammar:e,line:t,tokens:r,pos:0,state:{...n},addToken:(o,i,a)=>{a>i&&r.push({type:o,start:i,end:a,text:t.slice(i,a)});},startsWithAt:(o,i)=>t.slice(i,i+o.length)===o}}function Qa(e){return [...e.stringDelimiters].sort((t,n)=>n.length-t.length)}function el(e){if(e.state.inString===null)return false;let t=e.state.inString,n=e.pos;for(;e.pos<e.line.length;){let r=e.line[e.pos];if(r==="\\"&&e.pos+1<e.line.length)e.pos+=2;else if(t.length===3&&e.startsWithAt(t,e.pos)||t.length===1&&r===t){e.pos+=t.length,e.state={...e.state,inString:null};break}else e.pos++;}return e.addToken("string",n,e.pos),true}function tl(e){if(!e.state.inComment||!e.grammar.blockCommentEnd)return false;let t=e.pos;for(;e.pos<e.line.length;)if(e.grammar.nestedComments&&e.grammar.blockCommentStart&&e.startsWithAt(e.grammar.blockCommentStart,e.pos))e.state={...e.state,commentDepth:e.state.commentDepth+1},e.pos+=e.grammar.blockCommentStart.length;else if(e.startsWithAt(e.grammar.blockCommentEnd,e.pos))if(e.grammar.nestedComments&&e.state.commentDepth>0)e.state={...e.state,commentDepth:e.state.commentDepth-1},e.pos+=e.grammar.blockCommentEnd.length;else {e.pos+=e.grammar.blockCommentEnd.length,e.state={...e.state,inComment:false,commentDepth:0};break}else e.pos++;return e.addToken("comment",t,e.pos),true}function nl(e){if(e.state.templateDepth<=0||!e.grammar.templateLiteralEnd)return false;let t=e.pos;for(;e.pos<e.line.length;)if(e.line[e.pos]==="\\"&&e.pos+1<e.line.length)e.pos+=2;else if(e.startsWithAt("${",e.pos)){e.addToken("string",t,e.pos),e.pos+=2,e.addToken("punctuation",e.pos-2,e.pos);break}else if(e.startsWithAt(e.grammar.templateLiteralEnd,e.pos)){e.pos+=e.grammar.templateLiteralEnd.length,e.state={...e.state,templateDepth:e.state.templateDepth-1};break}else e.pos++;return e.pos>t&&e.addToken("string",t,e.pos),true}function rl(e){if(!/\s/.test(e.line[e.pos]||""))return false;let t=e.pos;for(;e.pos<e.line.length&&/\s/.test(e.line[e.pos]||"");)e.pos++;return e.addToken("text",t,e.pos),true}function ol(e){return !e.grammar.lineComment||!e.startsWithAt(e.grammar.lineComment,e.pos)?false:(e.addToken("comment",e.pos,e.line.length),e.pos=e.line.length,true)}function il(e){if(!e.grammar.blockCommentStart||!e.startsWithAt(e.grammar.blockCommentStart,e.pos))return false;let t=e.pos;return sl(e)||(e.state={...e.state,inComment:true}),e.addToken("comment",t,e.pos),true}function al(e){if(!e.grammar.templateLiteralStart||!e.startsWithAt(e.grammar.templateLiteralStart,e.pos))return false;let t=e.pos;for(e.pos+=e.grammar.templateLiteralStart.length;e.pos<e.line.length&&e.grammar.templateLiteralEnd;)if(e.line[e.pos]==="\\"&&e.pos+1<e.line.length)e.pos+=2;else if(e.startsWithAt("${",e.pos)){e.addToken("string",t,e.pos),e.pos+=2,e.addToken("punctuation",e.pos-2,e.pos),e.state={...e.state,templateDepth:e.state.templateDepth+1};break}else if(e.startsWithAt(e.grammar.templateLiteralEnd,e.pos)){e.pos+=e.grammar.templateLiteralEnd.length,e.addToken("string",t,e.pos);break}else e.pos++;return e.pos>=e.line.length&&e.pos>t+1&&(e.state={...e.state,templateDepth:e.state.templateDepth+1},e.addToken("string",t,e.pos)),true}function ll(e,t){let n=ul(e,t);if(!n)return false;let r=e.pos;return e.pos+=n.length,dl(e,n),e.pos>=e.line.length&&n.length===3&&(e.state={...e.state,inString:n}),e.addToken("string",r,e.pos),true}function sl(e){if(!e.grammar.blockCommentStart||!e.grammar.blockCommentEnd)return false;for(e.pos+=e.grammar.blockCommentStart.length;e.pos<e.line.length;){if(e.grammar.nestedComments&&e.startsWithAt(e.grammar.blockCommentStart,e.pos)){e.state={...e.state,commentDepth:e.state.commentDepth+1},e.pos+=e.grammar.blockCommentStart.length;continue}if(e.startsWithAt(e.grammar.blockCommentEnd,e.pos)){if(e.grammar.nestedComments&&e.state.commentDepth>0){e.state={...e.state,commentDepth:e.state.commentDepth-1},e.pos+=e.grammar.blockCommentEnd.length;continue}return e.pos+=e.grammar.blockCommentEnd.length,true}e.pos++;}return false}function ul(e,t){for(let n of t)if(e.startsWithAt(n,e.pos))return n;return null}function dl(e,t){for(;e.pos<e.line.length;){if(e.line[e.pos]==="\\"&&e.pos+1<e.line.length){e.pos+=2;continue}if(t.length===3&&e.startsWithAt(t,e.pos)||t.length===1&&e.line[e.pos]===t){e.pos+=t.length;break}e.pos++;}}function fl(e){let t=e.grammar.numberPattern.exec(e.line.slice(e.pos));return !t||t.index!==0?false:(e.addToken("number",e.pos,e.pos+t[0].length),e.pos+=t[0].length,true)}function cl(e){let t=e.grammar.identifierPattern.exec(e.line.slice(e.pos));if(!t||t.index!==0)return false;let n=t[0],r="identifier";return e.grammar.keywords.has(n)?r="keyword":e.grammar.constants.has(n)?r="constant":e.grammar.builtins.has(n)?r="builtin":(e.grammar.types.has(n)||/^[A-Z]/.test(n))&&(r="type"),e.line.slice(e.pos+n.length).trimStart().startsWith("(")&&r==="identifier"&&(r="function"),e.addToken(r,e.pos,e.pos+n.length),e.pos+=n.length,true}function ml(e){let t=e.grammar.operators.exec(e.line.slice(e.pos));return !t||t.index!==0?false:(e.addToken("operator",e.pos,e.pos+t[0].length),e.pos+=t[0].length,true)}function hl(e){let t=e.line[e.pos]||"";return /[()[\]{},;.]/.test(t)?(e.addToken("punctuation",e.pos,e.pos+1),e.pos++,true):false}function tt(e,t){let n=t.split(`
16
+ `);e.lineCount=n.length,e.fullInvalidate&&(e.entries.clear(),e.dirty.clear(),e.fullInvalidate=false);let r=[],o=pe;for(let i=0;i<n.length;i++){let a=n[i]??"",l=e.entries.get(i);if(l&&l.text===a&&j(l.startState,o)&&!e.dirty.has(i))r.push(l),o=l.endState;else {let s=F(e.grammar,a,o);e.entries.set(i,s),e.dirty.delete(i),r.push(s),o=s.endState;let u=e.entries.get(i+1);u&&!j(o,u.startState)&&e.dirty.add(i+1);}}return r}function gl(e,t,n,r){let o=performance.now(),i=t.split(`
17
+ `);e.lineCount=i.length;let a=Math.max(0,n),l=Math.min(i.length,r);e.fullInvalidate&&(e.entries.clear(),e.dirty.clear(),e.fullInvalidate=false);let s=pe;for(let c=0;c<a;c++){let m=i[c]??"",h=e.entries.get(c);if(h&&h.text===m&&j(h.startState,s)&&!e.dirty.has(c))s=h.endState;else {let g=F(e.grammar,m,s);e.entries.set(c,g),e.dirty.delete(c),s=g.endState;}}let u=[];for(let c=a;c<l;c++){let m=i[c]??"",h=e.entries.get(c);if(h&&h.text===m&&j(h.startState,s)&&!e.dirty.has(c))u.push(h),s=h.endState;else {let g=F(e.grammar,m,s);e.entries.set(c,g),e.dirty.delete(c),u.push(g),s=g.endState;}}let d=l<i.length,f=performance.now()-o;return {lines:u,hasMore:d,nextLine:l,timeMs:f}}function pl(e,t,n,r=100){let o=performance.now(),i=t.split(`
18
+ `);e.lineCount=i.length;let a=Math.max(0,Math.min(n,i.length)),l=Math.min(a+r,i.length),s=pe,u=e.entries.get(a-1);if(a>0&&u)s=u.endState;else if(a>0)for(let m=0;m<a;m++){let h=i[m]??"",g=e.entries.get(m);if(g&&g.text===h&&j(g.startState,s))s=g.endState;else {let W=F(e.grammar,h,s);e.entries.set(m,W),s=W.endState;}}let d=[];for(let m=a;m<l;m++){let h=i[m]??"",g=F(e.grammar,h,s);e.entries.set(m,g),e.dirty.delete(m),d.push(g),s=g.endState;}let f=l<i.length,c=performance.now()-o;return {lines:d,hasMore:f,nextLine:l,timeMs:c}}function nt(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();for(let n of Je)if(n.extensions.includes(t))return n;return $}function bl(e){let t=e.split(`
19
+ `)[0]||"";if(t.startsWith("#!")){if(/python/.test(t))return V;if(/node|deno|bun/.test(t))return U;if(/bash|sh|zsh/.test(t))return xe}return /^package\s+\w+/.test(t)?Xe:/^(use\s+|mod\s+|fn\s+|struct\s+|impl\s+|pub\s+)/.test(t)?be:/^(import|from|def|class)\s+/.test(t)?V:/^(import|export|const|let|var|function|class)\s+/.test(t)?U:/^\s*\{/.test(t)?Ye:$}function rt(e){let t=e.toLowerCase();for(let n of Je)if(n.name===t)return n;return t==="ts"||t==="typescript"||t==="tsx"||t==="jsx"?U:t==="py"?V:t==="rs"?be:t==="bash"||t==="sh"||t==="zsh"?xe:$}var xl=100,Qn=/^(#{1,6})\s+(.+)$/,er=/^(`{3,}|~{3,})(\w*)?$/,tr=/^([-*_])\s*\1\s*\1\s*(\1|\s)*$/,ye=/^(\s*)[-*+]\s+(.*)$/,Ce=/^(\s*)(\d+)[.)]\s+(.*)$/,yl=/^\[([ xX])\]\s+(.*)$/,ot=/^>\s?(.*)$/,Cl=/^\|?[\s:-]+\|[\s:|+-]+\|?$/,Yn=/^\|(.+)\|$/;function T(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return t}function w(e){let t=[],n=e,r=0;for(;r<n.length;){let o=Ll(n.slice(r));if(o){r>0&&(t.push({type:"text",content:n.slice(0,r)}),n=n.slice(r),r=0),t.push(o.element),n=n.slice(o.length);continue}r++;}return n.length>0&&t.push({type:"text",content:n}),t}var Sl=[kl,Tl,Rl,Al,wl,El];function Ll(e){for(let t of Sl){let n=t(e);if(n)return n}return null}function kl(e){let t=e.match(/^`([^`]+)`/);return t?{element:{type:"code",content:t[1]??""},length:t[0].length}:null}function Tl(e){let t=e.match(/^(\*\*|__)(.+?)\1/);if(!t)return null;let n=t[2]??"";return {element:{type:"bold",content:n,children:w(n)},length:t[0].length}}function Rl(e){let t=e.match(/^(\*|_)(.+?)\1/);if(!t)return null;let n=t[2]??"";return {element:{type:"italic",content:n,children:w(n)},length:t[0].length}}function Al(e){let t=e.match(/^\[([^\]]+)\]\(([^)]+)\)/);return t?{element:{type:"link",content:t[1]??"",href:t[2]??""},length:t[0].length}:null}function wl(e){let t=e.match(/^!\[([^\]]*)\]\(([^)]+)\)/);return t?{element:{type:"image",content:t[1]??"",href:t[2]??""},length:t[0].length}:null}function El(e){let t=e.match(/^~~(.+?)~~/);return t?{element:{type:"strikethrough",content:t[1]??""},length:t[0].length}:null}function it(e){let t=performance.now(),n=e.split(`
20
+ `),r=[],o=0;for(;o<n.length;){let i=n[o];if(i===void 0){o++;continue}if(i.trim()===""){o++;continue}let a=Wl(n,o);if(a){r.push(a.block),o=a.nextIndex;continue}o++;}return {blocks:r,parseTimeMs:performance.now()-t}}var Ml=[Il,Dl,vl,Bl,Fl,Pl,_l];function Wl(e,t){for(let n of Ml){let r=n(e,t);if(r)return r}return null}function Il(e,t){let n=e[t];if(n===void 0)return null;let r=n.match(Qn);if(!r)return null;let o=r[2]??"";return {block:{type:"heading",source:n,lineStart:t,lineEnd:t+1,hash:T(n),data:{kind:"heading",level:r[1]?.length??1,text:o,inline:w(o)}},nextIndex:t+1}}function Dl(e,t){let n=e[t];return n===void 0||!tr.test(n)?null:{block:{type:"hr",source:n,lineStart:t,lineEnd:t+1,hash:T(n),data:{kind:"hr"}},nextIndex:t+1}}function vl(e,t){let n=e[t];if(n===void 0)return null;let r=n.match(er);if(!r)return null;let o=r[1]??"",i=r[2]??"",a=[],l=t,s=t+1;for(;s<e.length;){let d=e[s];if(d===void 0)break;if(d.startsWith(o)&&d.trim()===o){s++;break}a.push(d),s++;}let u=a.join(`
21
+ `);return {block:{type:"code",source:e.slice(l,s).join(`
22
+ `),lineStart:l,lineEnd:s,hash:T(u+i),data:{kind:"code",language:i||nt("code.txt").name||"",code:u}},nextIndex:s}}function Bl(e,t){let n=e[t];if(n===void 0||!ot.test(n))return null;let r=[],o=t,i=t;for(;i<e.length;){let s=e[i];if(s===void 0)break;let u=s.match(ot);if(!u&&s.trim()!=="")break;r.push(u?u[1]??"":""),i++;}let a=r.join(`
23
+ `),l=it(a);return {block:{type:"blockquote",source:e.slice(o,i).join(`
24
+ `),lineStart:o,lineEnd:i,hash:T(a),data:{kind:"blockquote",content:a,blocks:l.blocks}},nextIndex:i}}function Fl(e,t){let n=e[t],r=e[t+1];if(n===void 0||r===void 0||!Yn.test(n)||!Cl.test(r))return null;let o=t,i=Jn(n),a=Ol(r),l=[],s=t+2;for(;s<e.length;){let u=e[s];if(u===void 0||!Yn.test(u))break;l.push(Jn(u)),s++;}return {block:{type:"table",source:e.slice(o,s).join(`
25
+ `),lineStart:o,lineEnd:s,hash:T(e.slice(o,s).join(`
26
+ `)),data:{kind:"table",headers:i,alignments:a,rows:l}},nextIndex:s}}function Pl(e,t){let n=e[t];if(n===void 0)return null;let r=zl(n);if(!r)return null;let o=t,i=Hl(e,t,r.ordered);return {block:{type:"list",source:e.slice(o,i.nextIndex).join(`
27
+ `),lineStart:o,lineEnd:i.nextIndex,hash:T(e.slice(o,i.nextIndex).join(`
28
+ `)),data:{kind:"list",ordered:r.ordered,start:r.start,items:i.items}},nextIndex:i.nextIndex}}function _l(e,t){let n=[],r=t,o=t;for(;o<e.length;){let a=e[o];if(a===void 0||a.trim()===""||n.length>0&&Ul(a))break;n.push(a),o++;}if(n.length===0)return null;let i=n.join(" ");return {block:{type:"paragraph",source:n.join(`
29
+ `),lineStart:r,lineEnd:o,hash:T(i),data:{kind:"paragraph",text:i,inline:w(i)}},nextIndex:o}}function Jn(e){return nr(e).map(t=>{let n=t.trim();return {content:n,inline:w(n)}})}function Ol(e){return nr(e).map(t=>{let n=t.trim();return n.startsWith(":")&&n.endsWith(":")?"center":n.endsWith(":")?"right":n.startsWith(":")?"left":null})}function nr(e){return e.slice(1,-1).split("|")}function Nl(e,t,n){let r=e[t];return r===void 0?false:n?Ce.test(r):ye.test(r)}function zl(e){let t=e.match(ye),n=e.match(Ce);return !t&&!n?null:{ordered:!!n,start:n?parseInt(n[2]??"1",10):void 0}}function Hl(e,t,n){let r=[],o=t;for(;o<e.length;){let i=e[o];if(i===void 0)break;let a=n?i.match(Ce):i.match(ye);if(!a&&i.trim()===""){if(!Nl(e,o+1,n))break;o++;continue}if(!a)break;r.push(Gl(a,n)),o++;}return {items:r,nextIndex:o}}function Gl(e,t){let n=(e[1]??"").length,r=t?e[3]??"":e[2]??"",o=r.match(yl),i=o?o[2]??"":r;return {content:i,inline:w(i),indent:n,checked:o?o[1]?.toLowerCase()==="x":void 0}}function Ul(e){return Qn.test(e)||tr.test(e)||er.test(e)||ye.test(e)||Ce.test(e)||ot.test(e)}function Vl(){return {blocks:new Map,sourceHash:0,highlightCaches:new Map,renderedLines:null}}function jl(e){e.blocks.clear(),e.sourceHash=0,e.highlightCaches.clear(),e.renderedLines=null;}function $l(e,t){let n=T(t);if(e.sourceHash===n&&e.renderedLines)return {blocks:Array.from(e.blocks.values()),parseTimeMs:0};let r=it(t);e.blocks.clear();for(let o of r.blocks){let i=`${o.lineStart}-${o.lineEnd}`;e.blocks.set(i,o);}return e.sourceHash=n,e.renderedLines=null,r}function Zl(e,t,n){for(let[r,o]of e.blocks)o.lineStart<n&&o.lineEnd>t&&e.blocks.delete(r);e.renderedLines=null;}function at(e,t){let n=[],r={},o=Kl[e.data.kind];return o&&o(e,t,n,r),n}function lt(e,t){if(t.renderedLines)return t.renderedLines;let n=[],r=0;for(let[o,i]of e.blocks.entries()){let a=at(i,t);for(let l of a)n.push({...l,blockIndex:o}),r++;o<e.blocks.length-1&&(n.push({content:"",style:{},blockIndex:o,lineInBlock:-1}),r++);}return t.renderedLines=n,n}var Kl={heading:ql,paragraph:Xl,code:Yl,list:Jl,table:Ql,blockquote:es,hr:ts,html:ns};function ql(e,t,n,r){let o=e.data;o.kind==="heading"&&n.push({content:`${"#".repeat(o.level)} ${o.text}`,style:{bold:true},blockIndex:0,lineInBlock:0});}function Xl(e,t,n,r){let o=e.data;o.kind==="paragraph"&&n.push({content:o.text,style:r,blockIndex:0,lineInBlock:0});}function Yl(e,t,n,r){let o=e.data;if(o.kind!=="code")return;let i=rt(o.language||"plaintext"),a=t.highlightCaches.get(e.hash.toString());a?a.grammar.name!==i.name&&et(a,i):(a=Qe(i),t.highlightCaches.set(e.hash.toString(),a)),tt(a,o.code);for(let[l,s]of o.code.split(`
30
+ `).entries())n.push({content:s,style:{dim:true},blockIndex:0,lineInBlock:l});}function Jl(e,t,n,r){let o=e.data;if(o.kind==="list")for(let[i,a]of o.items.entries()){let l=o.ordered?`${(o.start||1)+i}. `:`${" ".repeat(a.indent/2)}- `,s=a.checked!==void 0?a.checked?"[x] ":"[ ] ":"";n.push({content:l+s+a.content,style:r,blockIndex:0,lineInBlock:i});}}function Ql(e,t,n,r){let o=e.data;if(o.kind!=="table")return;let i=o.headers.map(l=>l.content).join(" | ");n.push({content:`| ${i} |`,style:{bold:true},blockIndex:0,lineInBlock:0});let a=o.headers.map((l,s)=>{let u=o.alignments[s];return u==="center"?":---:":u==="right"?"---:":u==="left"?":---":"---"}).join(" | ");n.push({content:`| ${a} |`,style:r,blockIndex:0,lineInBlock:1});for(let[l,s]of o.rows.entries()){let u=s.map(d=>d.content).join(" | ");n.push({content:`| ${u} |`,style:r,blockIndex:0,lineInBlock:l+2});}}function es(e,t,n,r){let o=e.data;if(o.kind==="blockquote"){for(let i of o.blocks){let a=at(i,t);for(let l of a)n.push({...l,content:`> ${l.content}`,style:{...l.style,italic:true}});}n.length===0&&n.push({content:">",style:{italic:true},blockIndex:0,lineInBlock:0});}}function ts(e,t,n,r){e.data.kind==="hr"&&n.push({content:"---",style:{dim:true},blockIndex:0,lineInBlock:0});}function ns(e,t,n,r){let o=e.data;if(o.kind==="html")for(let[i,a]of o.html.split(`
31
+ `).entries())n.push({content:a,style:{dim:true},blockIndex:0,lineInBlock:i});}function rs(e,t,n,r){let o=lt(e,t),i=Math.min(n+r,o.length);return {lines:o.slice(n,i),totalLines:o.length,startIndex:n,endIndex:i}}function os(e,t){return lt(e,t).length}function is(e){let t=0,n=0,r=0,o=0,i=0,a=0;for(let l of e.blocks){switch(a+=l.lineEnd-l.lineStart,l.type){case "heading":t++;break;case "code":n++;break;case "list":r++;break;case "table":o++;break}let s=u=>{let d=0;for(let f of u)f.type==="link"&&d++,f.children&&(d+=s(f.children));return d};(l.data.kind==="paragraph"||l.data.kind==="heading")&&(i+=s(l.data.inline));}return {blockCount:e.blocks.length,lineCount:a,headingCount:t,codeBlockCount:n,listCount:r,tableCount:o,linkCount:i}}var as=512,ls=256,ss=48;function us(e){let t=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function ds(e){let t=[];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n);return t}function Z(e){let t=ds(e);return {type:"leaf",text:e,length:e.length,newlines:t.length,lineBreaks:t}}function K(){return {type:"leaf",text:"",length:0,newlines:0,lineBreaks:[]}}function Se(e,t){let n=e.type==="node"?e.depth:0,r=t.type==="node"?t.depth:0;return {type:"node",left:e,right:t,leftLength:e.length,length:e.length+t.length,newlines:e.newlines+t.newlines,depth:Math.max(n,r)+1}}function fs(e){let t=e.left.type==="node"?e.left.depth:0,n=e.right.type==="node"?e.right.depth:0;return Math.abs(t-n)>1||e.depth>48}function Le(e,t){if(e.type==="leaf"){e.length>0&&t.push(e.text);return}Le(e.left,t),Le(e.right,t);}function ke(e){if(e.length===0)return K();if(e.length===1){let o=e[0];return o===void 0?K():Z(o)}let t=Math.floor(e.length/2),n=ke(e.slice(0,t)),r=ke(e.slice(t));return Se(n,r)}function cs(e){if(e.type==="leaf"||!fs(e))return e;let t=[];Le(e,t);let n=[];for(let r of t)if(r.length<=512)n.push(r);else for(let o=0;o<r.length;o+=512)n.push(r.slice(o,o+512));return ke(n)}function rr(e=""){if(e.length===0)return K();if(e.length<=512)return Z(e);let t=[];for(let n=0;n<e.length;n+=512)t.push(e.slice(n,n+512));return ke(t)}function ms(){return K()}function hs(e){return e.length}function gs(e){return e.newlines}function ps(e){return e.newlines+1}function bs(e){return e.length===0}function st(e,t){if(!(t<0||t>=e.length))return e.type==="leaf"?e.text.charAt(t):t<e.leftLength?st(e.left,t):st(e.right,t-e.leftLength)}function R(e,t,n){let r=n??e.length,o=t;if(o<0&&(o=0),r>e.length)return R(e,o,e.length);if(o>=r)return "";if(e.type==="leaf")return e.text.slice(o,r);let i=e.leftLength;if(r<=i)return R(e.left,o,r);if(o>=i)return R(e.right,o-i,r-i);let a=R(e.left,o,i),l=R(e.right,0,r-i);return a+l}function xs(e){if(e.type==="leaf")return e.text;let t=[];return Le(e,t),t.join("")}function ut(e,t){if(t<=0)return 0;if(t>=e.length)return e.newlines;if(e.type==="leaf"){let r=0;for(let o of e.lineBreaks){if(o>=t)break;r++;}return r}return t<e.leftLength?ut(e.left,t):e.left.newlines+ut(e.right,t-e.leftLength)}function or(e,t){return t<0?-1:t===0?0:t>e.newlines?-1:dt(e,t,0)}function dt(e,t,n){if(e.type==="leaf"){let o=0;for(let i of e.lineBreaks)if(o++,o===t)return n+i+1;return -1}let r=e.left.newlines;return t<=r?dt(e.left,t,n):dt(e.right,t-r,n+e.leftLength)}function ir(e,t){return t<0||t>e.newlines?-1:t===e.newlines?e.length:ft(e,t,0)}function ft(e,t,n){if(e.type==="leaf"){let o=0;for(let i of e.lineBreaks){if(o===t)return n+i;o++;}return -1}let r=e.left.newlines;return t<r?ft(e.left,t,n):ft(e.right,t-r,n+e.leftLength)}function ar(e,t){if(t<0||t>e.newlines)return;let n=or(e,t),r=ir(e,t);return n===-1?{text:R(e,0,r===-1?e.length:r),start:0,end:r===-1?e.length:r,lineNumber:t}:{text:R(e,n,r===-1?e.length:r),start:n,end:r===-1?e.length:r,lineNumber:t}}function ys(e,t,n){let r=[],o=e.newlines+1;for(let i=t;i<n&&i<o;i++){let a=ar(e,i);a&&r.push(a);}return r}function q(e,t){if(t<=0)return {left:null,right:e};if(t>=e.length)return {left:e,right:null};if(e.type==="leaf"){let o=e.text.slice(0,t),i=e.text.slice(t);return {left:o.length>0?Z(o):null,right:i.length>0?Z(i):null}}if(t<=e.leftLength){let{left:o,right:i}=q(e.left,t);return i===null?{left:o,right:e.right}:{left:o,right:Se(i,e.right)}}let{left:n,right:r}=q(e.right,t-e.leftLength);return n===null?{left:e.left,right:r}:{left:Se(e.left,n),right:r}}function ct(e,t){if(e===null||e.length===0)return t??K();if(t===null||t.length===0)return e;if(e.type==="leaf"&&t.type==="leaf"&&e.length+t.length<=512)return Z(e.text+t.text);let n=Se(e,t);return cs(n)}function Te(e,t,n){if(n.length===0)return e;let r=t;r<0&&(r=0),r>e.length&&(r=e.length);let o=rr(n),{left:i,right:a}=q(e,r);return ct(ct(i,o),a)}function Cs(e,t){return Te(e,e.length,t)}function Ss(e,t){return Te(e,0,t)}function lr(e,t,n){let r=t,o=n;if(r<0&&(r=0),o>e.length&&(o=e.length),r>=o)return e;let{left:i}=q(e,r),{right:a}=q(e,o);return ct(i,a)}function Ls(e,t,n,r){let o=lr(e,t,n);return Te(o,t,r)}function ks(e){let t=0,n=0,r=0;function o(i,a){if(i.type==="leaf"){t++,n+=i.length,r=Math.max(r,a);return}o(i.left,a+1),o(i.right,a+1);}return o(e,0),{length:e.length,newlines:e.newlines,leafCount:t,depth:r,avgLeafSize:t>0?n/t:0}}function mt(e){return e.type==="leaf"?e.length===e.text.length&&e.newlines===us(e.text)&&e.lineBreaks.length===e.newlines:e.leftLength!==e.left.length||e.length!==e.left.length+e.right.length||e.newlines!==e.left.newlines+e.right.newlines?false:mt(e.left)&&mt(e.right)}var sr=(u=>(u[u.NONE=0]="NONE",u[u.BOLD=1]="BOLD",u[u.UNDERLINE=2]="UNDERLINE",u[u.BLINK=4]="BLINK",u[u.INVERSE=8]="INVERSE",u[u.INVISIBLE=16]="INVISIBLE",u[u.DIM=32]="DIM",u[u.ITALIC=64]="ITALIC",u[u.STRIKETHROUGH=128]="STRIKETHROUGH",u))(sr||{});function ht(e){let t=0;return e.bold&&(t|=1),e.underline&&(t|=2),e.blink&&(t|=4),e.inverse&&(t|=8),e.invisible&&(t|=16),e.dim&&(t|=32),e.italic&&(t|=64),e.strikethrough&&(t|=128),t}function Ts(e){return {bold:(e&1)!==0,underline:(e&2)!==0,blink:(e&4)!==0,inverse:(e&8)!==0,invisible:(e&16)!==0,dim:(e&32)!==0,italic:(e&64)!==0,strikethrough:(e&128)!==0}}function Rs(e,t=4294967295,n=0){return {fg:e.fg??t,bg:e.bg??n,attrs:ht(e)}}function As(e){return {fg:e.fg,bg:e.bg,attrs:ht(e)}}function ws(e,t){return e.fg===t.fg&&e.bg===t.bg&&e.attrs===t.attrs}function Es(e){return {fg:e.fg,bg:e.bg,attrs:e.attrs}}function Ms(e,t){return {fg:t.fg??e.fg,bg:t.bg??e.bg,attrs:t.attrs!==void 0?t.attrs:e.attrs}}function Ws(e,t){return (e.attrs&t)!==0}function Is(e,t){return {fg:e.fg,bg:e.bg,attrs:e.attrs|t}}function Ds(e,t){return {fg:e.fg,bg:e.bg,attrs:e.attrs&~t}}function vs(e){return {fg:e.bg,bg:e.fg,attrs:e.attrs}}function Bs(){return {fg:4294967295,bg:0,attrs:0}}function Fs(e){let t=BigInt(e.fg>>>0),n=BigInt(e.bg>>>0)<<32n,r=BigInt(e.attrs)<<64n;return t|n|r}function Ps(e){let t=Number(e&0xffffffffn),n=Number(e>>32n&0xffffffffn),r=Number(e>>64n&0xffn);return {fg:t,bg:n,attrs:r}}var E=4294967295,M=0,P=/\{(\/?[a-zA-Z0-9_#-]+|\/)\}/g,Re="\0LBRACE\0",Ae="\0RBRACE\0",gt={black:255,red:4278190335,green:16711935,yellow:4294902015,blue:65535,magenta:4278255615,cyan:16777215,white:4294967295,"bright-black":2155905279,gray:2155905279,grey:2155905279,"bright-red":4286611711,"bright-green":2164228351,"bright-yellow":4294934783,"bright-blue":2155937791,"bright-magenta":4286644223,"bright-cyan":2164260863,"bright-white":4294967295,orange:4289003775,pink:4290825215,purple:2147516671,brown:2771004159,lime:852308735,navy:33023,teal:8421631,olive:2155872511,maroon:2147483903,aqua:16777215,silver:3233857791,default:0,transparent:0},ur={bold:1,underline:2,ul:2,blink:4,inverse:8,invisible:16,hidden:16,dim:32,italic:64,strikethrough:128,strike:128},dr={left:"left",center:"center",right:"right"};function _s(e){let t=e.startsWith("#")?e.slice(1):e;if(!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(t))return null;let n,r,o;if(t.length===3){let i=t[0]??"0",a=t[1]??"0",l=t[2]??"0";n=Number.parseInt(i+i,16),r=Number.parseInt(a+a,16),o=Number.parseInt(l+l,16);}else n=Number.parseInt(t.slice(0,2),16),r=Number.parseInt(t.slice(2,4),16),o=Number.parseInt(t.slice(4,6),16);return (n<<24|r<<16|o<<8|255)>>>0}function bt(e){let t=e.toLowerCase();if(t in gt)return gt[t]??null;let n=_s(e);if(n!==null)return n;let r=Number.parseInt(e,10);return !Number.isNaN(r)&&r>=0&&r<=255?Os(r):null}function Os(e){if(e<8)return [255,2147483903,8388863,2155872511,33023,2147516671,8421631,3233857791][e]??255;if(e<16)return [2155905279,4278190335,16711935,4294902015,65535,4278255615,16777215,4294967295][e-8]??2155905279;if(e<232){let n=e-16,r=Math.floor(n/36)*51,o=Math.floor(n/6)%6*51,i=n%6*51;return (r<<24|o<<16|i<<8|255)>>>0}let t=(e-232)*10+8;return (t<<24|t<<16|t<<8|255)>>>0}function Ns(){return {fg:[],bg:[],attrs:new Map}}function zs(e,t){e.fg=E,e.bg=M,e.attrs=0,t.fg=[],t.bg=[],t.attrs.clear();}function Hs(e,t,n){n.attrs.get(e)?.pop()?.prevValue?t.attrs|=e:t.attrs&=~e;}function Gs(e,t,n,r){let o=r.attrs.get(e);o||(o=[],r.attrs.set(e,o)),o.push({type:"attr",prevValue:n.attrs&e,tagName:t}),n.attrs|=e;}function Us(e,t,n,r){if(!(e in ur))return false;let o=ur[e];return o===void 0?false:(t?Hs(o,n,r):Gs(o,e,n,r),true)}function Vs(e,t,n,r){let o=e.match(/^(.+)-fg$/);if(!o?.[1])return false;if(t)if(r.fg.length>0){let i=r.fg.pop();i&&(n.fg=i.prevValue);}else n.fg=E;else {let i=bt(o[1]);i!==null&&(r.fg.push({type:"fg",prevValue:n.fg,tagName:e}),n.fg=i);}return true}function js(e,t,n,r){let o=e.match(/^(.+)-bg$/);if(!o?.[1])return false;if(t)if(r.bg.length>0){let i=r.bg.pop();i&&(n.bg=i.prevValue);}else n.bg=M;else {let i=bt(o[1]);i!==null&&(r.bg.push({type:"bg",prevValue:n.bg,tagName:e}),n.bg=i);}return true}function $s(e,t,n,r){if(t)return false;let o=bt(e);return o===null?false:(r.fg.push({type:"fg",prevValue:n.fg,tagName:e}),n.fg=o,true)}function Zs(e,t,n){if(e==="/")return zs(t,n),null;let r=e.startsWith("/"),o=r?e.slice(1):e;return o in dr?dr[o]??null:(Us(o,r,t,n)||Vs(o,r,t,n)||js(o,r,t,n)||$s(o,r,t,n),null)}function Ks(e){let t=[],n="left",r="",o=e.replace(/\{\{/g,Re).replace(/\}\}/g,Ae),i={fg:E,bg:M,attrs:0},a=Ns(),l=0,s;for(P.lastIndex=0;(s=P.exec(o))!==null;){if(s.index>l){let d=fr(o.slice(l,s.index));r=cr(t,i,d,r);}let u=s[1];if(u!==void 0){let d=Zs(u,i,a);d!==null&&(n=d);}l=P.lastIndex;}if(l<o.length){let u=fr(o.slice(l));r=cr(t,i,u,r);}return t.length===0&&e.length===0?{segments:[],alignment:n,plainText:""}:{segments:t,alignment:n,plainText:r}}function fr(e){return e.replaceAll(Re,"{").replaceAll(Ae,"}")}function cr(e,t,n,r){return n.length===0?r:(e.push({text:n,fg:t.fg,bg:t.bg,attrs:t.attrs}),r+n)}function xt(e){return e.replace(/\{\{/g,Re).replace(/\}\}/g,Ae).replace(P,"").replaceAll(Re,"{").replaceAll(Ae,"}")}function qs(e){return xt(e).trim()}function we(e){return e.replace(/\{/g,"{{").replace(/\}/g,"}}")}function Xs(e,t){let n=[];if(t.bold&&n.push("{bold}"),t.underline&&n.push("{underline}"),t.blink&&n.push("{blink}"),t.inverse&&n.push("{inverse}"),t.invisible&&n.push("{invisible}"),t.dim&&n.push("{dim}"),t.italic&&n.push("{italic}"),t.strikethrough&&n.push("{strikethrough}"),t.fg!==void 0&&t.fg!==E){let o=pt(t.fg);n.push(`{#${o}-fg}`);}if(t.bg!==void 0&&t.bg!==M){let o=pt(t.bg);n.push(`{#${o}-bg}`);}let r=we(e);return n.length===0?r:`${n.join("")}${r}{/}`}function pt(e){let t=e>>>24&255,n=e>>>16&255,r=e>>>8&255;return t.toString(16).padStart(2,"0")+n.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")}function Ys(e){if(e.length===0)return [];let t=e[0];if(!t)return [];let n=[],r={...t};for(let o=1;o<e.length;o++){let i=e[o];i&&(i.fg===r.fg&&i.bg===r.bg&&i.attrs===r.attrs?r={...r,text:r.text+i.text}:(n.push(r),r={...i}));}return n.push(r),n}function Js(e){return xt(e).length}function Qs(e){let t=e.replace(/\{\{/g,"").replace(/\}\}/g,"");return P.lastIndex=0,P.test(t)}var mr=z$1.enum(["left","center","right"]);function X(e,t){for(let[r,o]of Object.entries(gt))if(o===e)return `{${r}-${t}}`;return `{#${pt(e)}-${t}}`}function eu(e){return e&1?"{bold}":e&2?"{underline}":e&4?"{blink}":e&8?"{inverse}":e&16?"{invisible}":e&32?"{dim}":e&64?"{italic}":e&128?"{strikethrough}":""}function tu(e){let t=[];return e.bold&&t.push("{bold}"),e.underline&&t.push("{underline}"),e.blink&&t.push("{blink}"),e.inverse&&t.push("{inverse}"),e.invisible&&t.push("{invisible}"),e.dim&&t.push("{dim}"),e.italic&&t.push("{italic}"),e.strikethrough&&t.push("{strikethrough}"),e.fg!==void 0&&e.fg!==E&&t.push(X(e.fg,"fg")),e.bg!==void 0&&e.bg!==M&&t.push(X(e.bg,"bg")),t}function nu(e){let t=[];return e.bg!==void 0&&e.bg!==M&&t.push("{/bg}"),e.fg!==void 0&&e.fg!==E&&t.push("{/fg}"),e.strikethrough&&t.push("{/strikethrough}"),e.italic&&t.push("{/italic}"),e.dim&&t.push("{/dim}"),e.invisible&&t.push("{/invisible}"),e.inverse&&t.push("{/inverse}"),e.blink&&t.push("{/blink}"),e.underline&&t.push("{/underline}"),e.bold&&t.push("{/bold}"),t}function ru(e,t,n){let r=we(e),o=t.join(""),i=n?n.join(""):"{/}";return `${o}${r}${i}`}function hr(e){let t=[];return e&1&&t.push("{bold}"),e&2&&t.push("{underline}"),e&4&&t.push("{blink}"),e&8&&t.push("{inverse}"),e&16&&t.push("{invisible}"),e&32&&t.push("{dim}"),e&64&&t.push("{italic}"),e&128&&t.push("{strikethrough}"),t}function gr(e){let t=[],n=hr(e.attrs);t.push(...n),e.fg!==E&&t.push(X(e.fg,"fg")),e.bg!==M&&t.push(X(e.bg,"bg"));let r=we(e.text);return t.length===0?r:`${t.join("")}${r}{/}`}function ou(e){let t=[];e.alignment!=="left"&&t.push(`{${e.alignment}}`);for(let n of e.segments)t.push(gr(n));return t.join("")}var pr=z$1.object({text:z$1.string(),fg:z$1.number(),bg:z$1.number(),attrs:z$1.number()}),iu=z$1.object({segments:z$1.array(pr),alignment:mr,plainText:z$1.string()});var au=5e3,lu=1e5,su=/(?:^|[^\w])/,uu=/(?:$|[^\w])/;function du(e){let t=new Map,n=e.length;for(let r=0;r<n-1;r++){let o=e[r];o!==void 0&&t.set(o,n-1-r);}return t}function br(e,t,n=true,r=0){if(t.length===0)return [];let o=n?e:e.toLowerCase(),i=n?t:t.toLowerCase(),a=o.length,l=i.length,s=[];if(l>a)return s;let u=du(i),d=r+l-1;for(;d<a;){let f=l-1,c=d;for(;f>=0&&o[c]===i[f];)f--,c--;if(f<0)s.push(c+1),d++;else {let m=o[d],h=m!==void 0?u.get(m)??l:l;d+=Math.max(1,h);}}return s}function fu(e){let t=0,n=Math.min(e.length,1e3);for(let r=0;r<n;r++){let o=e.charCodeAt(r);t=(t<<5)-t+o|0;}return t=(t<<5)-t+e.length|0,t}function cu(e,t){let n=0,r=0;for(let o=0;o<t&&o<e.length;o++)e[o]===`
32
+ `&&(n++,r=o+1);return {line:n,column:t-r}}function xr(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
33
+ `&&t.push(n+1);return t}function mu(e,t){let n=0,r=e.length-1;for(;n<r;){let o=Math.floor((n+r+1)/2),i=e[o];i!==void 0&&i<=t?n=o:r=o-1;}return n}function yr(e,t,n={}){let r=performance.now(),o=n.caseSensitive??false,i=n.wholeWord??false,a=n.maxMatches,l=n.startPosition??0;if(t.length===0)return yt(t,r);let s=br(e,t,o,l),u=xr(e),{matches:d,truncated:f}=gu(e,t,s,u,i,a);return {matches:d,totalCount:f?s.length:d.length,truncated:f,timedOut:false,timeMs:performance.now()-r,query:t}}function Cr(e,t,n={}){let r=performance.now(),o=n.caseSensitive??false,i=n.maxMatches,a=n.timeout??5e3,l=n.startPosition??0;if(t.length===0)return yt(t,r);let s=hu(t,o);if(!s)return yt(t,r);let u=xr(e),d=bu(e,s,u,l,r+a,i);return {matches:d.matches,totalCount:d.matches.length,truncated:d.truncated,timedOut:d.timedOut,timeMs:performance.now()-r,query:t}}function yt(e,t){return {matches:[],totalCount:0,truncated:false,timedOut:false,timeMs:performance.now()-t,query:e}}function hu(e,t){try{let n=t?"g":"gi";return new RegExp(e,n)}catch{return null}}function gu(e,t,n,r,o,i){let a=[],l=false;for(let s of n)if(!(o&&!pu(e,s,t.length))&&(a.push(Sr(e,r,s,t.length)),i&&a.length>=i)){l=true;break}return {matches:a,truncated:l}}function pu(e,t,n){let r=t>0?e[t-1]:"",o=e[t+n]??"";return !(r&&/\w/.test(r)||o&&/\w/.test(o))}function Sr(e,t,n,r){let o=mu(t,n),i=t[o]??0,a=e.slice(n,n+r);return {start:n,end:n+r,line:o,column:n-i,text:a}}function bu(e,t,n,r,o,i){let a=[],l=false,s=false,u=r;t.lastIndex=r;let d=t.exec(e);for(;d!==null;){if(a.length%1e3===0&&performance.now()>o){s=true;break}if(d.index===u&&(t.lastIndex=u+1),u=t.lastIndex,a.push(Sr(e,n,d.index,d[0].length)),i&&a.length>=i){l=true;break}d=t.exec(e);}return {matches:a,truncated:l,timedOut:s}}function Ct(e,t,n={}){return n.regex?Cr(e,t,n):yr(e,t,n)}function Lr(e,t,n,r=1e5,o={}){let i=performance.now();if(t.length===0||n>=e.length)return {matches:[],hasMore:false,nextPosition:e.length,timeMs:performance.now()-i};let a=Math.min(n+r,e.length),l=e.slice(0,a),u=Ct(l,t,{...o,startPosition:n}).matches.filter(f=>f.start>=n&&f.start<a),d=a<e.length;return {matches:u,hasMore:d,nextPosition:a,timeMs:performance.now()-i}}function xu(){return {query:"",options:{},matches:[],textHash:0,currentIndex:-1,complete:false,lastPosition:0}}function yu(e){e.query="",e.options={},e.matches=[],e.textHash=0,e.currentIndex=-1,e.complete=false,e.lastPosition=0;}function Cu(e,t,n,r={}){let o=fu(t),i=e.query!==n,a=e.options.caseSensitive!==r.caseSensitive||e.options.wholeWord!==r.wholeWord||e.options.regex!==r.regex,l=e.textHash!==o;return i||a||l?(e.query=n,e.options=r,e.matches=[],e.textHash=o,e.currentIndex=-1,e.complete=false,e.lastPosition=0,true):false}function Su(e,t,n=1e5){let r=performance.now();if(e.query.length===0)return {matches:e.matches,totalCount:0,truncated:false,timedOut:false,timeMs:performance.now()-r,query:e.query};if(e.complete)return {matches:e.matches,totalCount:e.matches.length,truncated:false,timedOut:false,timeMs:performance.now()-r,query:e.query};let o=Lr(t,e.query,e.lastPosition,n,e.options);return e.matches.push(...o.matches),e.lastPosition=o.nextPosition,e.complete=!o.hasMore,{matches:e.matches,totalCount:e.matches.length,truncated:false,timedOut:false,timeMs:performance.now()-r,query:e.query}}function Lu(e){if(e.matches.length!==0)return e.currentIndex=(e.currentIndex+1)%e.matches.length,e.matches[e.currentIndex]}function ku(e){if(e.matches.length!==0)return e.currentIndex=e.currentIndex<=0?e.matches.length-1:e.currentIndex-1,e.matches[e.currentIndex]}function Tu(e,t){if(!(t<0||t>=e.matches.length))return e.currentIndex=t,e.matches[t]}function Ru(e,t,n=true){if(e.matches.length===0)return;let r=0,o=e.matches.length-1;for(;r<o;){let l=Math.floor((r+o)/2),s=e.matches[l];s&&s.start<t?r=l+1:o=l;}let i=e.matches[r],a=r>0?e.matches[r-1]:void 0;if(n&&i)return e.currentIndex=r,{match:i,index:r};if(!n&&a)return e.currentIndex=r-1,{match:a,index:r-1};if(i)return e.currentIndex=r,{match:i,index:r};if(a)return e.currentIndex=r-1,{match:a,index:r-1}}function Au(e,t,n){return e.matches.filter(r=>r.line>=t&&r.line<n)}function wu(e){return {current:e.currentIndex+1,total:e.matches.length,complete:e.complete}}function Eu(e,t,n={}){let r=Ct(e,t,n);return {...r,matches:[...r.matches].reverse()}}export{To as $,pn as $a,$i as $b,Xe as $c,mt as $d,wu as $e,Qr as A,rn as Aa,zn as Ab,Ca as Ac,lt as Ad,tu as Ae,eo as B,te as Ba,ui as Bb,Sa as Bc,rs as Bd,nu as Be,to as C,on as Ca,di as Cb,La as Cc,os as Cd,ru as Ce,no as D,an as Da,fi as Db,wa as Dc,is as Dd,hr as De,ro as E,ne as Ea,ci as Eb,Ea as Ec,as as Ed,gr as Ee,Q as F,re as Fa,mi as Fb,Ma as Fc,ls as Fd,ou as Fe,oo as G,H as Ga,hi as Gb,Wa as Gc,ss as Gd,pr as Ge,io as H,ln as Ha,gi as Hb,Da as Hc,rr as Hd,iu as He,I,sn as Ia,pi as Ib,va as Ic,ms as Id,au as Ie,Ee as J,Ne as Ja,bi as Jb,Ba as Jc,hs as Jd,lu as Je,Et as K,un as Ka,xi as Kb,Zn as Kc,gs as Kd,su as Ke,Mt as L,ze as La,yi as Lb,Fa as Lc,ps as Ld,uu as Le,Me as M,He as Ma,Ci as Mb,Pa as Mc,bs as Md,br as Me,ao as N,Ge as Na,Hn as Nb,_a as Nc,st as Nd,cu as Ne,lo as O,D as Oa,Si as Ob,Oa as Oc,R as Od,yr as Oe,so as P,S as Pa,Li as Pb,ge as Pc,xs as Pd,Cr as Pe,uo as Q,Ue as Qa,ki as Qb,qn as Qc,ut as Qd,Ct as Qe,fo as R,p as Ra,Di as Rb,za as Rc,or as Rd,Lr as Re,co as S,A as Sa,vi as Sb,Xn as Sc,ir as Sd,xu as Se,mo as T,je as Ta,_i as Tb,Ha as Tc,ar as Td,yu as Te,ho as U,cn as Ua,Oi as Ub,Ga as Uc,ys as Ud,Cu as Ue,vt as V,mn as Va,Ni as Vb,Ua as Vc,Te as Vd,Su as Ve,So as W,hn as Wa,zi as Wb,Va as Wc,Cs as Wd,Lu as We,Lo as X,le as Xa,Hi as Xb,pe as Xc,Ss as Xd,ku as Xe,ko as Y,ie as Ya,Gi as Yb,U as Yc,lr as Yd,Tu as Ye,Bt as Z,ae as Za,Ui as Zb,V as Zc,Ls as Zd,Ru as Ze,Ft as _,gn as _a,ji as _b,be as _c,ks as _d,Au as _e,_ as a,Ro as aa,bn as ab,Zi as ac,xe as ad,sr as ae,Eu as af,wr as b,Ao as ba,yn as bb,Ki as bc,Ye as bd,ht as be,Er as c,wo as ca,Cn as cb,qi as cc,$ as cd,Ts as ce,Mr as d,Eo as da,Sn as db,Xi as dc,Je as dd,Rs as de,Wr as e,Mo as ea,Ln as eb,Yi as ec,Qe as ed,As as ee,Ir as f,Wo as fa,kn as fb,Ji as fc,ja as fd,ws as fe,Dr as g,Io as ga,Tn as gb,Qi as gc,et as gd,Es as ge,vr as h,$o as ha,Rn as hb,ea as hc,$a as hd,Ms as he,Pr as i,Ut as ia,An as ib,ta as ic,Za as id,Ws as ie,_r as j,Vt as ja,wn as jb,na as jc,Ka as jd,Is as je,Or as k,jt as ka,En as kb,ra as kc,qa as kd,Ds as ke,At as l,$t as la,G as lb,oa as lc,F as ld,vs as le,Nr as m,Zt as ma,Mn as mb,ia as mc,tt as md,Bs as me,zr as n,Pe as na,b as nb,aa as nc,gl as nd,Fs as ne,Gr as o,_e as oa,Wn as ob,sa as oc,pl as od,Ps as oe,Ur as p,z as pa,$e as pb,he as pc,nt as pd,Ks as pe,Y as q,Kt as qa,se as qb,Gn as qc,bl as qd,xt as qe,Vr as r,qt as ra,In as rb,ca as rc,rt as rd,qs as re,jr as s,Xt as sa,Dn as sb,ma as sc,xl as sd,we as se,$r as t,Yt as ta,vn as tb,ha as tc,w as td,Xs as te,Zr as u,Jt as ua,Bn as ub,ga as uc,it as ud,Ys as ue,Kr as v,Oe as va,Fn as vb,Vn as vc,Vl as vd,Js as ve,Xr as w,Qt as wa,Pn as wb,pa as wc,jl as wd,Qs as we,Yr as x,en as xa,_n as xb,ba as xc,$l as xd,mr as xe,wt as y,tn as ya,On as yb,xa as yc,Zl as yd,X as ye,Jr as z,nn as za,Nn as zb,ya as zc,at as zd,eu as ze};