blecsd 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -2
- package/README.md +209 -66
- package/dist/3d/index.d.ts +2 -2
- package/dist/3d/index.js +1 -1
- package/dist/audio/index.d.ts +2 -2
- package/dist/{border-D_Jb4ZJV.d.ts → border-Jb7TrMob.d.ts} +20 -10
- package/dist/chunk-2IEMMRUO.js +1 -0
- package/dist/chunk-3AV52GY5.js +1 -0
- package/dist/chunk-3LHLSY3Y.js +1 -0
- package/dist/chunk-3O4TQHGK.js +4 -0
- package/dist/chunk-3UJWZ5ZN.js +1 -0
- package/dist/chunk-5N3O25O7.js +1 -0
- package/dist/chunk-6M2J5QUA.js +1 -0
- package/dist/chunk-7IQEUVGF.js +1 -0
- package/dist/chunk-A6M6TFBL.js +1 -0
- package/dist/chunk-CUEUJAHK.js +3 -0
- package/dist/chunk-D42Q2KKR.js +1 -0
- package/dist/chunk-DYEXOFUU.js +2 -0
- package/dist/chunk-DYU72XLL.js +1 -0
- package/dist/chunk-E4CJRSND.js +1 -0
- package/dist/chunk-EAY7B5GL.js +1 -0
- package/dist/chunk-FCMTWFSE.js +1 -0
- package/dist/chunk-FL56THSI.js +25 -0
- package/dist/{chunk-2UBBZFE4.js → chunk-G437VE43.js} +1 -1
- package/dist/chunk-GGXNWT36.js +8 -0
- package/dist/chunk-HLFORKXS.js +1 -0
- package/dist/chunk-J7MBKEBY.js +1 -0
- package/dist/{chunk-TYMY2TBR.js → chunk-JHCKPCUH.js} +3 -3
- package/dist/chunk-K3SX2LY5.js +1 -0
- package/dist/chunk-LDAFEXN5.js +1 -0
- package/dist/chunk-MKMFUXLB.js +33 -0
- package/dist/chunk-MQWPHPUM.js +1 -0
- package/dist/chunk-MTI376CU.js +5 -0
- package/dist/chunk-MTV2RJZD.js +1 -0
- package/dist/chunk-NPDPBAW6.js +4 -0
- package/dist/chunk-OB66FB4F.js +1 -0
- package/dist/chunk-OR3BZY7C.js +1 -0
- package/dist/{chunk-VNZ6CWJA.js → chunk-R7AICVRN.js} +2 -2
- package/dist/{chunk-3B7MIVW6.js → chunk-RZ7FGVI6.js} +1 -1
- package/dist/chunk-UMGTXSQB.js +11 -0
- package/dist/chunk-X3Q3T2SS.js +4 -0
- package/dist/{chunk-JKVHO4LH.js → chunk-XZJRWFOS.js} +1 -1
- package/dist/chunk-ZAHG7Y3X.js +1 -0
- package/dist/cli/init.d.ts +1 -1
- package/dist/componentStorage-CJTh-TPO.d.ts +246 -0
- package/dist/components/index.d.ts +1942 -514
- package/dist/components/index.js +1 -1
- package/dist/core/index.d.ts +857 -259
- package/dist/core/index.js +1 -1
- package/dist/debug/index.d.ts +491 -98
- package/dist/debug/index.js +1 -1
- package/dist/dirtyTracking-C4v8MmM9.d.ts +235 -0
- package/dist/errors/index.d.ts +12 -12
- package/dist/errors/index.js +1 -1
- package/dist/{events-BbbxkgvX.d.ts → events-9ForpTfM.d.ts} +75 -2
- package/dist/game/index.d.ts +7 -7
- package/dist/game/index.js +1 -1
- package/dist/{gameLoop-BIPW7-OY.d.ts → gameLoop-C-Ez_i54.d.ts} +2 -2
- package/dist/{index-zSGJ2eUk.d.ts → index-DBS5Uefn.d.ts} +2 -2
- package/dist/index.d.ts +283 -20
- package/dist/index.js +3 -1
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/{inputActions-CefRUBuT.d.ts → inputActions-CRsUtTHM.d.ts} +10 -721
- package/dist/packedStore-BgvnEdE7.d.ts +191 -0
- package/dist/{renderable-jTMOA-GK.d.ts → renderable-CwqGwrEV.d.ts} +9 -9
- package/dist/{scheduler-DcfoFuum.d.ts → scheduler-CMcYew9Z.d.ts} +65 -3
- package/dist/systems/index.d.ts +356 -55
- package/dist/systems/index.js +1 -1
- package/dist/terminal/index.d.ts +2233 -2299
- package/dist/terminal/index.js +1 -1
- package/dist/{tilemap-D1HJvKy3.d.ts → tilemap-BirMJdbu.d.ts} +92 -3
- package/dist/{types-BcsvoKzf.d.ts → types-CPB4CpbH.d.ts} +2 -2
- package/dist/utils/index.d.ts +27 -180
- package/dist/utils/index.js +1 -1
- package/dist/{virtualScrollback-DvZTRU8a.d.ts → virtualScrollback-D9uLFe8l.d.ts} +4 -4
- package/dist/{virtualViewport-Dx2iJliO.d.ts → virtualViewport-Bpv6jlKt.d.ts} +283 -761
- package/dist/widgets/bigText.d.ts +1 -1
- package/dist/widgets/bigText.js +1 -1
- package/dist/widgets/index.d.ts +10519 -5463
- package/dist/widgets/index.js +1 -1
- package/package.json +102 -6
- package/dist/chunk-35I22JJO.js +0 -1
- package/dist/chunk-3EGGGI5J.js +0 -3
- package/dist/chunk-4X4N4HNQ.js +0 -2
- package/dist/chunk-AQ7LW75B.js +0 -1
- package/dist/chunk-AXZQAH4X.js +0 -1
- package/dist/chunk-BCADUCOZ.js +0 -1
- package/dist/chunk-EJ5WVDDZ.js +0 -6
- package/dist/chunk-FT7BMYSN.js +0 -1
- package/dist/chunk-FYEBZAWN.js +0 -1
- package/dist/chunk-GYHI26UE.js +0 -1
- package/dist/chunk-H2YAOJDW.js +0 -1
- package/dist/chunk-K2B2OXQ5.js +0 -5
- package/dist/chunk-K37L3G4Z.js +0 -4
- package/dist/chunk-KD55INV7.js +0 -1
- package/dist/chunk-KFAK4A3G.js +0 -1
- package/dist/chunk-LCN2ZITE.js +0 -1
- package/dist/chunk-OUXUPF3V.js +0 -33
- package/dist/chunk-P6CJO3BC.js +0 -1
- package/dist/chunk-PI5UOHOH.js +0 -1
- package/dist/chunk-PSXXMBVJ.js +0 -1
- package/dist/chunk-TRK4422V.js +0 -12
- package/dist/chunk-W5OU7Z6J.js +0 -1
- package/dist/chunk-WNG4A3K7.js +0 -4
- package/dist/chunk-XRJNAHNG.js +0 -19
- package/dist/chunk-XZA63ZPO.js +0 -1
- package/dist/chunk-YAMOSPWB.js +0 -4
- package/dist/chunk-YD6ULIUR.js +0 -1
- package/dist/{keyParser-Bwm8-l7v.d.ts → keyParser-BnHbg2iD.d.ts} +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {i as i$2,k as k$2}from'./chunk-VOCM5T2G.js';import {b}from'./chunk-7IQEUVGF.js';import {A as A$1,ha,Q}from'./chunk-XZJRWFOS.js';import {a}from'./chunk-3LHLSY3Y.js';import {c as c$2}from'./chunk-OR3BZY7C.js';import {u,k as k$1}from'./chunk-DYU72XLL.js';import {E as E$1,v as v$1,c as c$1,X}from'./chunk-ZAHG7Y3X.js';import {f,e}from'./chunk-SHUC6JWA.js';import {b as b$1}from'./chunk-G7GIWWLE.js';import {n,i as i$1,h,j,k as k$3}from'./chunk-PXXGH3BV.js';import {z}from'zod';u();n();var H=1e4,i={current:new Float32Array(H),max:new Float32Array(H),regen:new Float32Array(H),invulnerable:new Uint8Array(H),invulnerableTime:new Float32Array(H)};function he(t){i.current[t]=0,i.max[t]=0,i.regen[t]=0,i.invulnerable[t]=0,i.invulnerableTime[t]=0;}function ge(t,e,r){return i$1(t,e,i)||(h(t,e,i),he(e)),i.max[e]=r.max,i.current[e]=r.current??r.max,i.regen[e]=r.regen??0,e}function Te(t,e){if(i$1(t,e,i))return {current:i.current[e],max:i.max[e],regen:i.regen[e],invulnerable:i.invulnerable[e]===1,invulnerableTime:i.invulnerableTime[e]}}function ye(t,e){return i$1(t,e,i)}function xe(t,e){return i$1(t,e,i)&&j(t,e,i),e}function Ee(t,e,r){return i$1(t,e,i)?r<=0?i.current[e]<=0:i.invulnerable[e]===1?false:(i.current[e]=Math.max(0,i.current[e]-r),i.current[e]<=0):false}function Le(t,e,r){i$1(t,e,i)&&(r<=0||(i.current[e]=Math.min(i.max[e],i.current[e]+r)));}function De(t,e,r){i$1(t,e,i)&&(i.invulnerable[e]=1,i.invulnerableTime[e]=r);}function Ae(t,e){i$1(t,e,i)&&(i.invulnerable[e]=0,i.invulnerableTime[e]=0);}function Ie(t,e){return i$1(t,e,i)?i.current[e]<=0:false}function ve(t,e){return i$1(t,e,i)?i.invulnerable[e]===1:false}function _e(t,e){if(!i$1(t,e,i))return 0;let r=i.max[e];return r<=0?0:i.current[e]/r}function Be(t,e,r){i$1(t,e,i)&&(i.current[e]=Math.max(0,Math.min(i.max[e],r)));}function Re(t,e,r){i$1(t,e,i)&&(i.max[e]=r,i.current[e]>r&&(i.current[e]=r));}function Fe(t,e,r){i$1(t,e,i)&&(i.regen[e]=r);}function Pe(t,e,r){if(!i$1(t,e,i))return;if(i.invulnerable[e]===1){let a=i.invulnerableTime[e];a>0&&(i.invulnerableTime[e]=a-r,i.invulnerableTime[e]<=0&&(i.invulnerable[e]=0,i.invulnerableTime[e]=0));}let n=i.regen[e];n>0&&i.current[e]<i.max[e]&&(i.current[e]=Math.min(i.max[e],i.current[e]+n*r));}n();var N=1e4,ae=(u=>(u[u.TopLeft=0]="TopLeft",u[u.TopCenter=1]="TopCenter",u[u.TopRight=2]="TopRight",u[u.BottomLeft=3]="BottomLeft",u[u.BottomCenter=4]="BottomCenter",u[u.BottomRight=5]="BottomRight",u[u.Left=6]="Left",u[u.Right=7]="Right",u))(ae||{}),k=new Map,oe=1,I={set(t){let e=oe++;return k.set(e,t),e},update(t,e){t>0&&k.set(t,e);},get(t){return k.get(t)??""},delete(t){k.delete(t);},clear(){k.clear(),oe=1;}};function Oe(){I.clear();}var p={labelId:new Uint32Array(N),position:new Uint8Array(N),offsetX:new Int8Array(N),offsetY:new Int8Array(N)};function Me(t,e){return i$1(t,e,p)}function Ue(t,e,r,n={}){i$1(t,e,p)||(h(t,e,p),p.labelId[e]=0,p.position[e]=0,p.offsetX[e]=0,p.offsetY[e]=0);let a=p.labelId[e]??0;return a>0?I.update(a,r):p.labelId[e]=I.set(r),n.position!==void 0&&(p.position[e]=n.position),n.offsetX!==void 0&&(p.offsetX[e]=n.offsetX),n.offsetY!==void 0&&(p.offsetY[e]=n.offsetY),e}function He(t,e){if(!i$1(t,e,p))return "";let r=p.labelId[e]??0;return I.get(r)}function ke(t,e){return i$1(t,e,p)?{text:I.get(p.labelId[e]??0),position:p.position[e]??0,offsetX:p.offsetX[e]??0,offsetY:p.offsetY[e]??0}:null}function Ve(t,e){return i$1(t,e,p)?p.position[e]:0}function we(t,e,r){return i$1(t,e,p)&&(p.position[e]=r),e}function Ne(t,e,r,n){return i$1(t,e,p)&&(p.offsetX[e]=r,p.offsetY[e]=n),e}function We(t,e){if(!i$1(t,e,p))return e;let r=p.labelId[e]??0;return r>0&&I.delete(r),j(t,e,p),e}function Ke(t,e){if(!i$1(t,e,p))return false;let r=p.labelId[e]??0;return r>0&&I.get(r).length>0}u();function Ge(){b(E$1,"Position"),b(v$1,"Dimensions"),b(c$1,"Renderable"),b(b$1,"Hierarchy"),b(k$1,"Border"),b(a,"Padding"),b(p,"Label"),b(c$2,"Interactive"),b(X,"Focusable"),b(A$1,"Animation"),b(ha,"Velocity"),b(Q,"Collider");}n();f();var E=1e4,ie=9474,te=9608,le=9472,se=4281545523,ce=4287137928,c={enabled:new Uint8Array(E),vertical:new Uint8Array(E),horizontal:new Uint8Array(E),trackChar:new Uint32Array(E),thumbChar:new Uint32Array(E),trackCharH:new Uint32Array(E),thumbCharH:new Uint32Array(E),trackColor:new Uint32Array(E),thumbColor:new Uint32Array(E),alwaysShow:new Uint8Array(E)};function Ye(t){c.enabled[t]=1,c.vertical[t]=1,c.horizontal[t]=1,c.trackChar[t]=ie,c.thumbChar[t]=te,c.trackCharH[t]=le,c.thumbCharH[t]=te,c.trackColor[t]=se,c.thumbColor[t]=ce,c.alwaysShow[t]=0;}function W(t,e){i$1(t,e,c)||(h(t,e,c),Ye(e));}function ze(t,e){e.enabled!==void 0&&(c.enabled[t]=e.enabled?1:0),e.vertical!==void 0&&(c.vertical[t]=e.vertical?1:0),e.horizontal!==void 0&&(c.horizontal[t]=e.horizontal?1:0),e.alwaysShow!==void 0&&(c.alwaysShow[t]=e.alwaysShow?1:0);}function Xe(t,e){e.trackChar!==void 0&&(c.trackChar[t]=e.trackChar),e.thumbChar!==void 0&&(c.thumbChar[t]=e.thumbChar),e.trackCharH!==void 0&&(c.trackCharH[t]=e.trackCharH),e.thumbCharH!==void 0&&(c.thumbCharH[t]=e.thumbCharH);}function je(t,e$1){e$1.trackColor!==void 0&&(c.trackColor[t]=e(e$1.trackColor)),e$1.thumbColor!==void 0&&(c.thumbColor[t]=e(e$1.thumbColor));}function Ze(t,e){ze(t,e),Xe(t,e),je(t,e);}function Qe(t,e,r){return W(t,e),Ze(e,r),e}function qe(t,e){if(i$1(t,e,c))return {enabled:c.enabled[e]===1,vertical:c.vertical[e]===1,horizontal:c.horizontal[e]===1,trackChar:c.trackChar[e],thumbChar:c.thumbChar[e],trackCharH:c.trackCharH[e],thumbCharH:c.thumbCharH[e],trackColor:c.trackColor[e],thumbColor:c.thumbColor[e],alwaysShow:c.alwaysShow[e]===1}}function Je(t,e){return i$1(t,e,c)}function $e(t,e){return i$1(t,e,c)?c.enabled[e]===1:false}function et(t,e){return W(t,e),c.enabled[e]=1,e}function tt(t,e){return i$1(t,e,c)&&(c.enabled[e]=0),e}function rt(t,e,r,n){return W(t,e),c.trackChar[e]=r,c.thumbChar[e]=n,e}function nt(t,e$1,r,n){return W(t,e$1),c.trackColor[e$1]=e(r),c.thumbColor[e$1]=e(n),e$1}function ot(t,e,r,n,a,l,m,d,u,y){let S=[];if(r<=0||a<=0||l<=0)return S;let b=Math.max(0,a-l);if(b===0)return S;let h=Math.min(1,l/a),f=Math.max(1,Math.round(r*h)),B=b>0?n/b:0,L=Math.round((r-f)*B);for(let g=0;g<r;g++){let R=g>=L&&g<L+f;S.push({x:t,y:e+g,char:R?d:m,color:R?y:u,isThumb:R});}return S}function at(t,e,r,n,a,l,m,d,u,y){let S=[];if(r<=0||a<=0||l<=0)return S;let b=Math.max(0,a-l);if(b===0)return S;let h=Math.min(1,l/a),f=Math.max(1,Math.round(r*h)),B=b>0?n/b:0,L=Math.round((r-f)*B);for(let g=0;g<r;g++){let R=g>=L&&g<L+f;S.push({x:t+g,y:e,char:R?d:m,color:R?y:u,isThumb:R});}return S}function it(t,e,r){return r?true:t>e}function lt(t,e,r){return r?true:t>e}var st=5e4,ue=1e4,ct=2**31-1;function T(t){if(!Number.isFinite(t))return 0;let e=Math.trunc(t);return Math.max(0,Math.min(e,ct))}var ut=z.object({line:z.number().int().nonnegative(),col:z.number().int().nonnegative()}),mt=z.enum(["stream","rectangular"]),V=new Map;function me(){return {anchorLine:0,anchorCol:0,focusLine:0,focusCol:0,active:false,mode:"stream"}}function pt(t){let e=me();return V.set(t,e),e}function dt(t){return V.get(t)}function St(t){return V.has(t)}function bt(t){V.delete(t);}function ft(){V.clear();}function Ct(t,e,r,n="stream"){let a=T(e),l=T(r);t.anchorLine=a,t.anchorCol=l,t.focusLine=a,t.focusCol=l,t.active=true,t.mode=n;}function ht(t,e,r){t.active&&(t.focusLine=T(e),t.focusCol=T(r));}function gt(t){t.active=false,t.anchorLine=0,t.anchorCol=0,t.focusLine=0,t.focusCol=0,t.mode="stream";}function Tt(t){return t.active?t.anchorLine!==t.focusLine||t.anchorCol!==t.focusCol:false}function yt(t,e,r){let n=T(e),a=T(r);t.anchorLine=n,t.anchorCol=0,t.focusLine=n,t.focusCol=a,t.active=true,t.mode="stream";}function xt(t,e,r,n){let a=T(e),l=T(r),m=T(n);t.anchorLine=a,t.anchorCol=0,t.focusLine=l,t.focusCol=m,t.active=true,t.mode="stream";}function Et(t,e,r){let n=T(e);if(n===0)return;let a=T(r);t.anchorLine=0,t.anchorCol=0,t.focusLine=n-1,t.focusCol=a,t.active=true,t.mode="stream";}function Lt(t,e){t.mode=e;}function D(t){return t.active?t.anchorLine<t.focusLine||t.anchorLine===t.focusLine&&t.anchorCol<=t.focusCol?{start:{line:t.anchorLine,col:t.anchorCol},end:{line:t.focusLine,col:t.focusCol},mode:t.mode}:{start:{line:t.focusLine,col:t.focusCol},end:{line:t.anchorLine,col:t.anchorCol},mode:t.mode}:null}function Dt(t){let e=D(t);return e?e.end.line-e.start.line+1:0}function At(t,e){let r=D(t);return r?e>=r.start.line&&e<=r.end.line:false}function It(t,e,r){let n=D(t);if(!n||e<n.start.line||e>n.end.line)return {fullLine:false,startCol:-1,endCol:-1};if(n.mode==="rectangular"){let l=Math.min(n.start.col,n.end.col),m=Math.max(n.start.col,n.end.col),d=Math.min(l,r),u=Math.min(m,r);return {fullLine:d===0&&u>=r,startCol:d,endCol:u}}return n.start.line===n.end.line?{fullLine:n.start.col===0&&n.end.col>=r,startCol:Math.min(n.start.col,r),endCol:Math.min(n.end.col,r)}:e===n.start.line?{fullLine:n.start.col===0,startCol:Math.min(n.start.col,r),endCol:r}:e===n.end.line?{fullLine:n.end.col>=r,startCol:0,endCol:Math.min(n.end.col,r)}:{fullLine:true,startCol:0,endCol:r}}function vt(t,e,r){let n=D(t);if(!n)return [];let a=Math.max(n.start.line,e),l=Math.min(n.end.line,r-1);if(a>l)return [];let m=[];for(let d=a;d<=l;d++)m.push(d);return m}function _t(t,e){let r=D(t);if(!r)return "";let n=e.lineCount-1;if(n<0)return "";let a={start:{line:Math.max(0,Math.min(r.start.line,n)),col:r.start.col},end:{line:Math.max(0,Math.min(r.end.line,n)),col:r.end.col},mode:r.mode};return a.start.line>a.end.line?"":a.mode==="rectangular"?Rt(a,e):Bt(a,e)}function Bt(t,e){let{start:r,end:n}=t;if(r.line===n.line){let d=i$2(e,r.line);return d?d.slice(r.col,n.col):""}let a=[],l=i$2(e,r.line);if(a.push(l!==void 0?l.slice(r.col):""),n.line-r.line>1){let d=k$2(e,r.line+1,n.line);for(let u of d.lines)a.push(u);}let m=i$2(e,n.line);return a.push(m!==void 0?m.slice(0,n.col):""),a.join(`
|
|
2
|
+
`)}function Rt(t,e){let r=Math.min(t.start.col,t.end.col),n=Math.max(t.start.col,t.end.col),a=k$2(e,t.start.line,t.end.line+1),l=[];for(let m of a.lines){let d=Math.min(r,m.length),u=Math.min(n,m.length);l.push(m.slice(d,u));}return l.join(`
|
|
3
|
+
`)}function Ft(t,e){let r=e.lineCount-1;if(r<0)return null;let n=Math.max(0,Math.min(t.start.line,r)),a=Math.max(0,Math.min(t.end.line,r));return n>a?null:{startLine:n,endLine:a,totalLines:a-n+1}}function*Pt(t,e,r,n,a,l){let m=Math.min(t.start.col,t.end.col),d=Math.max(t.start.col,t.end.col),u=[],y=0;for(let S=r;S<=n;S+=l){let b=Math.min(S+l,n+1),h=k$2(e,S,b);for(let f of h.lines){let B=Math.min(m,f.length),L=Math.min(d,f.length);u.push(f.slice(B,L));}y+=b-S,b<=n&&(yield {done:false,linesProcessed:y,totalLines:a,text:""});}yield {done:true,linesProcessed:y,totalLines:a,text:u.join(`
|
|
4
|
+
`)};}function*Ot(t,e,r,n,a,l){let m=[],d=0,u=i$2(e,r);if(u!==void 0){if(r===n){m.push(u.slice(t.start.col,t.end.col)),yield {done:true,linesProcessed:1,totalLines:a,text:m[0]??""};return}m.push(u.slice(t.start.col));}d=1;let y=r+1,S=n;for(let h=y;h<S;h+=l){let f=Math.min(h+l,S),B=k$2(e,h,f);for(let L of B.lines)m.push(L);d+=f-h,f<S&&(yield {done:false,linesProcessed:d,totalLines:a,text:""});}let b=i$2(e,n);b!==void 0&&m.push(b.slice(0,t.end.col)),d=a,yield {done:true,linesProcessed:d,totalLines:a,text:m.join(`
|
|
5
|
+
`)};}function*Mt(t,e,r=ue){let n=D(t);if(!n){yield {done:true,linesProcessed:0,totalLines:0,text:""};return}let a=Ft(n,e);if(!a){yield {done:true,linesProcessed:0,totalLines:0,text:""};return}let{startLine:l,endLine:m,totalLines:d}=a;if(n.mode==="rectangular"){yield*Pt(n,e,l,m,d,r);return}yield*Ot(n,e,l,m,d,r);}function Ut(t,e,r,n){let a=[],l=Math.min(t.start.line,e.start.line);l<r&&a.push([l,r-1]);let m=Math.max(t.end.line,e.end.line);return n<m&&a.push([n+1,m]),a}function Ht(t,e,r,n){if(r>n)return [];if(t.mode==="rectangular")return t.start.col!==e.start.col||t.end.col!==e.end.col?[[r,n]]:[];let a=[],l=t.start.line===e.start.line,m=t.start.col!==e.start.col;l&&m&&a.push([t.start.line,t.start.line]);let d=t.end.line===e.end.line,u=t.end.col!==e.end.col;return d&&u&&a.push([t.end.line,t.end.line]),a}function kt(t,e){if(t.mode!==e.mode)return [[Math.min(t.start.line,e.start.line),Math.max(t.end.line,e.end.line)]];let r=Math.max(t.start.line,e.start.line),n=Math.min(t.end.line,e.end.line),a=[...Ut(t,e,r,n),...Ht(t,e,r,n)];return Vt(a)}function Vt(t){if(t.length<=1)return t;t.sort((r,n)=>r[0]-n[0]);let e=[];for(let r of t){let n=e[e.length-1];if(!n){e.push(r);continue}r[0]<=n[1]+1?r[1]>n[1]&&(n[1]=r[1]):e.push(r);}return e}function wt(t,e){let r=t?D(t):null,n=D(e);return !r&&!n?[]:!r&&n?[[n.start.line,n.end.line]]:r&&!n?[[r.start.line,r.end.line]]:r&&n?kt(r,n):[]}function Nt(t){return {anchorLine:t.anchorLine,anchorCol:t.anchorCol,focusLine:t.focusLine,focusCol:t.focusCol,active:t.active,mode:t.mode}}n();var v=1e4,o={duration:new Float32Array(v),elapsed:new Float32Array(v),remaining:new Float32Array(v),repeat:new Uint16Array(v),repeatCount:new Uint16Array(v),active:new Uint8Array(v),paused:new Uint8Array(v),autoDestroy:new Uint8Array(v)},pe=65535,_=new Map;function Wt(t){o.duration[t]=0,o.elapsed[t]=0,o.remaining[t]=0,o.repeat[t]=0,o.repeatCount[t]=0,o.active[t]=0,o.paused[t]=0,o.autoDestroy[t]=0;}function Kt(t,e,r){return i$1(t,e,o)||(h(t,e,o),Wt(e)),o.duration[e]=r.duration,o.elapsed[e]=0,o.remaining[e]=r.duration,o.repeat[e]=r.repeat??0,o.repeatCount[e]=0,o.active[e]=r.active!==false?1:0,o.autoDestroy[e]=r.autoDestroy?1:0,o.paused[e]=0,e}function Gt(t,e){i$1(t,e,o)&&(o.active[e]=1,o.paused[e]=0);}function Yt(t,e){i$1(t,e,o)&&(o.paused[e]=1);}function zt(t,e){i$1(t,e,o)&&(o.paused[e]=0);}function Xt(t,e){i$1(t,e,o)&&(o.active[e]=0,o.paused[e]=0,o.elapsed[e]=0,o.remaining[e]=o.duration[e],o.repeatCount[e]=0);}function jt(t,e){i$1(t,e,o)&&(o.elapsed[e]=0,o.remaining[e]=o.duration[e],o.repeatCount[e]=0,o.active[e]=1,o.paused[e]=0);}function de(t,e){i$1(t,e,o)&&j(t,e,o),_.delete(e);}function Zt(t,e){if(i$1(t,e,o))return {duration:o.duration[e],elapsed:o.elapsed[e],remaining:o.remaining[e],repeat:o.repeat[e],repeatCount:o.repeatCount[e],active:o.active[e]===1,paused:o.paused[e]===1,autoDestroy:o.autoDestroy[e]===1}}function Qt(t,e){return i$1(t,e,o)}function qt(t,e){return i$1(t,e,o)?o.active[e]===1&&o.paused[e]===0:false}function Jt(t,e){return i$1(t,e,o)?o.active[e]===0&&o.elapsed[e]>0:false}function $t(t,e){if(!i$1(t,e,o))return 0;let r=o.duration[e];if(r<=0)return 0;let n=o.remaining[e];return Math.max(0,Math.min(1,1-n/r))}function er(t,e){let r=_.get(t)??{};r.onFire=e,_.set(t,r);}function tr(t,e){let r=_.get(t)??{};r.onComplete=e,_.set(t,r);}function rr(t){_.delete(t);}function nr(){_.clear();}function or(t,e){let r=[],n=[],a=ir(t);for(let l of a)o.active[l]!==1||o.paused[l]===1||(o.elapsed[l]=o.elapsed[l]+e,o.remaining[l]=o.remaining[l]-e,o.remaining[l]<=0&&(r.push(l),ar(t,l,n)));for(let l of n)de(t,l);return r}function ar(t,e,r){o.repeatCount[e]=o.repeatCount[e]+1;let n=_.get(e);n?.onFire&&n.onFire(t,e);let a=o.repeat[e],l=o.repeatCount[e];if(a===pe||l<=a){o.remaining[e]=o.duration[e];return}o.active[e]=0,o.remaining[e]=0,n?.onComplete&&n.onComplete(t,e),o.autoDestroy[e]===1&&r.push(e);}function ir(t){return k$3(t,[o])}n();var lr=1e4,A={hasData:new Uint8Array(lr)},w=new Map;function Se(t,e,r){return i$1(t,e,A)||h(t,e,A),A.hasData[e]=1,w.set(e,r),e}function be(t,e){if(!(!i$1(t,e,A)||A.hasData[e]===0))return w.get(e)}function sr(t,e){let r=be(t,e);return r||(r={},Se(t,e,r)),r}function fe(t,e){return i$1(t,e,A)&&A.hasData[e]===1}function cr(t,e){return fe(t,e)?(A.hasData[e]=0,w.delete(e)):false}function ur(){w.clear();}function mr(){return w.size}export{pt as $,Ne as A,zt as Aa,We as B,Xt as Ba,Ke as C,jt as Ca,Ge as D,de as Da,ie as E,Zt as Ea,te as F,Qt as Fa,le as G,qt as Ga,se as H,Jt as Ha,ce as I,$t as Ia,c as J,er as Ja,Qe as K,tr as Ka,qe as L,rr as La,Je as M,nr as Ma,$e as N,or as Na,et as O,A as Oa,tt as P,Se as Pa,rt as Q,be as Qa,nt as R,sr as Ra,ot as S,fe as Sa,at as T,cr as Ta,it as U,ur as Ua,lt as V,mr as Va,st as W,ue as X,ut as Y,mt as Z,me as _,i as a,dt as aa,ge as b,St as ba,Te as c,bt as ca,ye as d,ft as da,xe as e,Ct as ea,Ee as f,ht as fa,Le as g,gt as ga,De as h,Tt as ha,Ae as i,yt as ia,Ie as j,xt as ja,ve as k,Et as ka,_e as l,Lt as la,Be as m,D as ma,Re as n,Dt as na,Fe as o,At as oa,Pe as p,It as pa,ae as q,vt as qa,I as r,_t as ra,Oe as s,Mt as sa,p as t,wt as ta,Me as u,Nt as ua,Ue as v,o as va,He as w,pe as wa,ke as x,Kt as xa,Ve as y,Gt as ya,we as z,Yt as za};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {c,a}from'./chunk-3AV52GY5.js';import {j as j$1,a as a$1,f,b}from'./chunk-K3SX2LY5.js';import {c as c$1,p,E as E$1}from'./chunk-ZAHG7Y3X.js';import {n,i,k as k$1}from'./chunk-PXXGH3BV.js';import {z as z$1}from'zod';n();function j(e,o){let n=e*o,t=Math.ceil(n/8);return {width:e,height:o,dirtyCells:new Uint8Array(t),dirtyEntities:new Set,entityBoundsCache:new Map,dirtyRegions:[],regionsStale:false,forceFullRedraw:false,frameCount:0}}function X(e,o,n){if(e.dirtyEntities.add(n),!c(o,n))return;let t=Math.floor(a.x[n]),r=Math.floor(a.y[n]),i$1=Math.floor(a.width[n]),d=Math.floor(a.height[n]),s=i(o,n,c$1)&&p(o,n),a$1=e.entityBoundsCache.get(n);a$1?(a$1.wasVisible&&h(e,a$1.prevX,a$1.prevY,a$1.prevWidth,a$1.prevHeight),s&&h(e,t,r,i$1,d),a$1.prevX=t,a$1.prevY=r,a$1.prevWidth=i$1,a$1.prevHeight=d,a$1.wasVisible=s):(e.entityBoundsCache.set(n,{prevX:t,prevY:r,prevWidth:i$1,prevHeight:d,wasVisible:s}),s&&h(e,t,r,i$1,d)),e.regionsStale=true;}function G(e,o){e.dirtyEntities.delete(o),e.entityBoundsCache.delete(o);}function J(e,o,n){if(o<0||o>=e.width||n<0||n>=e.height)return;let t=n*e.width+o,r=Math.floor(t/8),i=t%8,d=e.dirtyCells[r];d!==void 0&&(e.dirtyCells[r]=d|1<<i),e.regionsStale=true;}function E(e,o,n){if(o<0||o>=e.width||n<0||n>=e.height)return false;let t=n*e.width+o,r=Math.floor(t/8),i=t%8,d=e.dirtyCells[r];return d!==void 0&&(d&1<<i)!==0}function h(e,o,n,t,r){let i=Math.max(0,o),d=Math.max(0,n),s=Math.min(e.width,o+t),a=Math.min(e.height,n+r);if(!(s<=i||a<=d)){for(let u=d;u<a;u++)for(let b=i;b<s;b++){let T=u*e.width+b,x=Math.floor(T/8),Q=T%8,w=e.dirtyCells[x];w!==void 0&&(e.dirtyCells[x]=w|1<<Q);}e.regionsStale=true;}}function P(e,o,n){let t=1;for(;o+t<e.width&&E(e,o+t,n);)t++;return t}function k(e,o,n,t){for(let r=0;r<t;r++)if(!E(e,o+r,n))return false;return true}function z(e,o,n,t){let r=1;for(;n+r<e.height&&k(e,o,n+r,t);)r++;return r}function H(e,o,n,t,r,i){for(let d=0;d<r;d++)for(let s=0;s<t;s++)i.add((n+d)*e.width+(o+s));}function Z(e){if(e.forceFullRedraw)return [{x:0,y:0,width:e.width,height:e.height}];if(!e.regionsStale&&e.dirtyRegions.length>0)return e.dirtyRegions;e.dirtyRegions.length=0;let o=[],n=new Set;for(let t=0;t<e.height;t++)for(let r=0;r<e.width;r++){let i=t*e.width+r;if(n.has(i)||!E(e,r,t))continue;let d=P(e,r,t),s=z(e,r,t,d);H(e,r,t,d,s,n),o.push({x:r,y:t,width:d,height:s});}return e.dirtyRegions.length=0,e.dirtyRegions.push(...o),e.regionsStale=false,e.dirtyRegions}function $(e){if(e.forceFullRedraw||e.dirtyEntities.size>0)return true;for(let o=0;o<e.dirtyCells.length;o++)if(e.dirtyCells[o]!==0)return true;return false}function ee(e){e.dirtyCells.fill(0),e.dirtyEntities.clear(),e.dirtyRegions.length=0,e.regionsStale=false,e.forceFullRedraw=false,e.frameCount++;}function te(e){e.forceFullRedraw=true,e.regionsStale=true;}function ne(e){let o=0;for(let n=0;n<e.dirtyCells.length;n++){let t=e.dirtyCells[n];if(t!==void 0)for(let r=0;r<8;r++)t&1<<r&&o++;}return {dirtyCellCount:o,dirtyEntityCount:e.dirtyEntities.size,cachedEntityCount:e.entityBoundsCache.size,dirtyRegionCount:e.regionsStale?0:e.dirtyRegions.length,frameCount:e.frameCount}}function L(){let e=new Map;function o(t,r,i){let d=e.get(t);d||(d=new Set,e.set(t,d));let s={handler:r,once:i};return d.add(s),()=>{d.delete(s),d.size===0&&e.delete(t);}}let n={on(t,r){return o(t,r,false)},once(t,r){return o(t,r,true)},off(t,r){let i=e.get(t);if(!i)return n;for(let d of i)if(d.handler===r){i.delete(d);break}return i.size===0&&e.delete(t),n},emit(t,r){let i=e.get(t);if(!i||i.size===0)return false;let d=[];for(let s of i)s.handler(r),s.once&&d.push(s);for(let s of d)i.delete(s);return i.size===0&&e.delete(t),true},removeAllListeners(t){return t===void 0?e.clear():e.delete(t),n},listenerCount(t){return e.get(t)?.size??0},eventNames(){return Array.from(e.keys())},hasListeners(t){return n.listenerCount(t)>0}};return n}function oe(){let e=new Map;return {get(o,n){return e.get(n)},getOrCreate(o,n){let t=e.get(n);return t||(t=L(),e.set(n,t)),t},set(o,n,t){e.set(n,t);},has(o,n){return e.has(n)},delete(o,n){return e.delete(n)},clear(){e.clear();}}}n();var q=z$1.object({name:z$1.string().min(1),components:z$1.array(z$1.unknown()).min(1)}),I=z$1.object({queries:z$1.array(q),initialCapacity:z$1.number().int().positive().optional()}),_=Object.freeze([]),U=Object.freeze([]);function F(e){return k$1(e,[E$1,c$1])}var m={type:"bitecs",queryRenderables:F},v=new WeakMap;function ye(e={}){return {...m,...e,type:e.type??m.type,queryRenderables:e.queryRenderables??m.queryRenderables}}function ce(e,o){v.set(e,o);}function fe(e){return v.get(e)??m}function me(e){v.delete(e);}function D(e,o,n){return {name:e,components:o,store:a$1(n),handleMap:new Map}}function N(e,o){let n=k$1(o,[...e.components]),{store:t,handleMap:r}=e,i=new Set;for(let s of n)i.add(s);let d=j$1(t);for(let s=t.size-1;s>=0;s--){let a=d[s];if(a===void 0||i.has(a))continue;let u=r.get(a);u&&(f(t,u),r.delete(a));}for(let s of n){let a=s;if(r.has(a))continue;let u=b(t,a);r.set(a,u);}}function M(e){let o=j$1(e.store),n=[];for(let t=0;t<e.store.size;t++){let r=o[t];r!==void 0&&n.push(r);}return n}function be(e){I.parse(e);let o=e.initialCapacity??64,n=new Map;for(let r of e.queries)n.set(r.name,D(r.name,r.components,o));n.has("renderables")||n.set("renderables",D("renderables",[E$1,c$1],o));let t=Object.freeze([...n.keys()]);return {type:"custom",queryRenderables(r){let i=n.get("renderables");return i?M(i):_},queryByName(r,i){let d=n.get(r);if(d)return M(d)},sync(r){for(let i of n.values())N(i,r);},getQueryData(r){let i=n.get(r);return i?j$1(i.store):U},getQuerySize(r){let i=n.get(r);return i?i.store.size:0},getRegisteredQueries(){return t}}}function pe(e){return "sync"in e&&"getQueryData"in e&&"getQuerySize"in e&&"getRegisteredQueries"in e}export{j as a,X as b,G as c,J as d,E as e,h as f,Z as g,$ as h,ee as i,te as j,ne as k,L as l,oe as m,q as n,I as o,m as p,ye as q,ce as r,fe as s,me as t,be as u,pe as v};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {z as z$1}from'zod';z$1.number().int().min(1).max(16);var W=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\].*?\x1b\\|\x1b\][^\x07]*\x07/g,x=/^\x1b\[[0-9;]*[a-zA-Z]/;function h(n){return n.replace(W,"")}function c(n){return h(n).length}function d(n,r){let i=n.slice(r).match(x);return i?{code:i[0],length:i[0].length}:null}function S(n,r,t="\u2026"){if(r<=0)return "";if(h(n).length<=r)return n;let e=c(t),o=r-e;if(o<=0)return t.slice(0,r);let s="",u=0,a=0;for(;u<o&&a<n.length;){let f=n[a];if(f==="\x1B"){let l=d(n,a);if(l){s+=l.code,a+=l.length;continue}}s+=f,u++,a++;}return s.includes("\x1B[")&&(s+="\x1B[0m"),s+t}function g(n,r,t){let i=c(n);if(i>=r)return n;let e=r-i;switch(t){case "left":return n+" ".repeat(e);case "right":return " ".repeat(e)+n;case "center":{let o=Math.floor(e/2),s=e-o;return " ".repeat(o)+n+" ".repeat(s)}}}function A(n){let r={result:[],current:"",inAnsi:false};for(let t=0;t<n.length;t++){let i=n[t];i!==void 0&&T(r,i);}return b(r),r.result}function P(n,r){let t=[],i=n;for(;c(i)>r;){let e=z(i,r);t.push(i.slice(0,e)),i=i.slice(e);}return i.length>0&&t.push(i),t}function k(n,r){if(r<=0)return [""];let t=[],i=n.split(`
|
|
2
|
+
`);for(let e of i){if(e.length===0){t.push("");continue}let o=L(e,r);t.push(...o);}return t}function L(n,r){let t={lines:[],currentLine:"",currentWidth:0},i=A(n);for(let e of i){if(y(e)){E(t,r);continue}let o=c(e);if(M(t,o,r)){C(t,e,o);continue}if(o<=r){p(t),I(t,e,o);continue}p(t);let s=Z(e,r);t.lines.push(...s.lines),t.currentLine=s.tail.text,t.currentWidth=s.tail.width;}return p(t),t.lines}function v(n,r){let t=[],i=n.split(`
|
|
3
|
+
`);for(let e of i){if(e.length===0){t.push("");continue}let o=w(e,r);t.push(...o);}return t}function w(n,r){let t=[],i=n;for(;c(i)>r;){let e=B(i,r);t.push(i.slice(0,e)),i=i.slice(e);}return i.length>0&&t.push(i),t}function T(n,r){if(r==="\x1B"){n.inAnsi=true,n.current+=r;return}if(n.inAnsi){n.current+=r,/[a-zA-Z\\]/.test(r)&&(n.inAnsi=false);return}if(r===" "||r===" "){b(n),n.result.push(r);return}n.current+=r;}function b(n){n.current.length>0&&(n.result.push(n.current),n.current="");}function z(n,r){let t=0,i=0;for(let e=0;e<n.length;e++){let o=n[e];if(o!==void 0){if(o==="\x1B"){let s=d(n,e);if(s){t=e+s.length;continue}}if(i>=r)break;t=e+1,i++;}}return t===0?Math.min(n.length,1):t}function y(n){return n===" "||n===" "}function E(n,r){n.currentWidth+1<=r&&(n.currentLine+=" ",n.currentWidth+=1);}function M(n,r,t){return n.currentWidth+r<=t}function C(n,r,t){n.currentLine+=r,n.currentWidth+=t;}function p(n){n.currentLine.length>0&&(n.lines.push(n.currentLine.trimEnd()),n.currentLine="",n.currentWidth=0);}function I(n,r,t){n.currentLine=r,n.currentWidth=t;}function Z(n,r){let t=P(n,r),i=t.slice(0,Math.max(0,t.length-1)),e=t[t.length-1]??"";return {lines:i,tail:{text:e,width:c(e)}}}function B(n,r){let t=0,i=0,e=false;for(let o=0;o<n.length&&i<r;o++){let s=n[o];if(s!==void 0){if(s==="\x1B"){e=true;continue}if(e){/[a-zA-Z\\]/.test(s)&&(e=false);continue}i++,t=o+1;}}return t===0?Math.min(n.length,1):t}function G(n,r){let{width:t,wrap:i=true,align:e="left",breakWord:o=false}=r;return t<=0?[""]:i?(o?v(n,t):k(n,t)).map(u=>g(u,t,e)):n.split(`
|
|
4
|
+
`).map(u=>c(u)>t?S(u,t):g(u,t,e))}function N(n,r,t,i="top"){if(n.length>=r)return n.slice(0,r);let e=" ".repeat(t),o=r-n.length;switch(i){case "top":return [...n,...Array(o).fill(e)];case "bottom":return [...Array(o).fill(e),...n];case "middle":{let s=Math.floor(o/2),u=o-s;return [...Array(s).fill(e),...n,...Array(u).fill(e)]}}}export{h as a,c as b,S as c,g as d,k as e,G as f,N as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a,b as b$1,j as j$1,f,g as g$1}from'./chunk-K3SX2LY5.js';import {n,d,h as h$1,i,j as j$2}from'./chunk-PXXGH3BV.js';function v(e=1024){let t=Math.max(1,e),n=new Uint32Array(t),o=new Int32Array(t);for(let a=0;a<t-1;a++)o[a]=a+1;return o[t-1]=-1,{generations:n,freeList:o,freeHead:0,capacity:t,size:0}}function H(e){let t=e.capacity,n=t*2,o=new Uint32Array(n);o.set(e.generations);let a=new Int32Array(n);a.set(e.freeList);for(let i=t;i<n-1;i++)a[i]=i+1;a[n-1]=e.freeHead,e.freeHead=t,e.generations=o,e.freeList=a,e.capacity=n;}function b(e){e.freeHead===-1&&H(e);let t=e.freeHead,n=e.freeList[t];e.freeHead=n!==void 0?n:-1,e.freeList[t]=-2,e.size++;let o=e.generations[t];return {index:t,gen:o!==void 0?o:0}}function g(e,t){return t.index<0||t.index>=e.capacity?false:e.generations[t.index]===t.gen&&e.freeList[t.index]===-2}function z(e,t){if(!g(e,t))return false;let{index:n}=t,o=e.generations[n];return o!==void 0&&(e.generations[n]=o+1),e.freeList[n]=e.freeHead,e.freeHead=n,e.size--,true}function R(e){let{capacity:t}=e;for(let n=0;n<t;n++){let o=e.generations[n];o!==void 0&&(e.generations[n]=o+1);}for(let n=0;n<t-1;n++)e.freeList[n]=n+1;e.freeList[t-1]=-1,e.freeHead=0,e.size=0;}function h(e){return e.size}function C(e){return e.capacity}function F(e,t){if(!g(e,t))throw new Error(`Invalid entity handle: index=${t.index}, gen=${t.gen}, current_gen=${e.generations[t.index]??"out of bounds"}`)}n();var c=new Map,I={maxSize:0,preallocate:0};function Y(e,t){c.has(e.name)||c.set(e.name,{definition:e,config:{...I,...t},freeStore:a(),freeHandles:new Map,activeStore:a(),activeHandles:new Map,totalAllocations:0,totalRecycles:0,maxPoolSize:0});}function q(e,t,n){let o=c.get(t);if(!o)return;let a=n??o.config.preallocate;for(let i=0;i<a;i++){let r=d(e);for(let u of o.definition.components)h$1(e,r,u);let f=b$1(o.freeStore,r);o.freeHandles.set(r,f);}o.maxPoolSize=Math.max(o.maxPoolSize,o.freeStore.size);}function j(e,t){let n=c.get(t);if(!n)return null;if(n.totalAllocations++,n.freeStore.size>0){let r=j$1(n.freeStore)[n.freeStore.size-1];if(r!==void 0){n.totalRecycles++;let f$1=n.freeHandles.get(r);if(f$1&&(f(n.freeStore,f$1),n.freeHandles.delete(r)),n.definition.resetFns)for(let x of n.definition.resetFns)x(e,r);let u=b$1(n.activeStore,r);return n.activeHandles.set(r,u),r}}let o=d(e);for(let i of n.definition.components)h$1(e,o,i);let a=b$1(n.activeStore,o);return n.activeHandles.set(o,a),o}function B(e,t,n){let o=c.get(t);if(!o)return false;let a=o.activeHandles.get(n);if(!a)return false;if(f(o.activeStore,a),o.activeHandles.delete(n),o.config.maxSize>0&&o.freeStore.size>=o.config.maxSize){for(let r of o.definition.components)i(e,n,r)&&j$2(e,n,r);return false}if(o.definition.resetFns)for(let r of o.definition.resetFns)r(e,n);let i$1=b$1(o.freeStore,n);return o.freeHandles.set(n,i$1),o.maxPoolSize=Math.max(o.maxPoolSize,o.freeStore.size),true}function L(e){let t=c.get(e);return t?{name:e,pooled:t.freeStore.size,active:t.activeStore.size,totalAllocations:t.totalAllocations,totalRecycles:t.totalRecycles,hitRate:t.totalAllocations>0?t.totalRecycles/t.totalAllocations:0,maxPoolSize:t.maxPoolSize}:null}function J(){let e=[],t=0,n=0,o=0,a=0;for(let[i]of c){let r=L(i);r&&(e.push(r),t+=r.active,n+=r.pooled,o+=r.totalAllocations,a+=r.totalRecycles);}return {archetypes:e,totalActive:t,totalPooled:n,overallHitRate:o>0?a/o:0}}function K(e){let t=c.get(e);t&&(g$1(t.freeStore),t.freeHandles.clear(),g$1(t.activeStore),t.activeHandles.clear());}function Q(e){let t=c.get(e);t&&(g$1(t.freeStore),t.freeHandles.clear(),g$1(t.activeStore),t.activeHandles.clear(),c.delete(e));}function X(){for(let e of c.values())g$1(e.freeStore),e.freeHandles.clear(),g$1(e.activeStore),e.activeHandles.clear();c.clear();}export{v as a,b,g as c,z as d,R as e,h as f,C as g,F as h,Y as i,q as j,j as k,B as l,L as m,J as n,K as o,Q as p,X as q};
|
|
@@ -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),enabled:new Uint8Array(a),hoverEffectFg:new Uint32Array(a),hoverEffectBg:new Uint32Array(a),focusEffectFg:new Uint32Array(a),focusEffectBg:new Uint32Array(a)},i=4278255615,g=0;function x(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.enabled[n]=1,t.hoverEffectFg[n]=y,t.hoverEffectBg[n]=E,t.focusEffectFg[n]=i,t.focusEffectBg[n]=g;}function l(n,e){i$1(n,e,t)||(h$1(n,e,t),x(e));}function f(n,e,r){r!==void 0&&(e[n]=r?1:0);}function u(n,e,r){r!==void 0&&(e[n]=r);}function p(n,e,r){return l(n,e),f(e,t.clickable,r.clickable),f(e,t.draggable,r.draggable),f(e,t.hoverable,r.hoverable),f(e,t.keyable,r.keyable),f(e,t.focusable,r.focusable),f(e,t.enabled,r.enabled),u(e,t.tabIndex,r.tabIndex),u(e,t.hoverEffectFg,r.hoverEffectFg),u(e,t.hoverEffectBg,r.hoverEffectBg),u(e,t.focusEffectFg,r.focusEffectFg),u(e,t.focusEffectBg,r.focusEffectBg),e}function h(n,e,r){return l(n,e),t.clickable[e]=r?1:0,e}function W(n,e,r){return l(n,e),t.draggable[e]=r?1:0,e}function d(n,e,r){return l(n,e),t.hoverable[e]=r?1:0,e}function k(n,e,r){return l(n,e),t.keyable[e]=r?1:0,e}function F(n,e){return i$1(n,e,t)?t.hovered[e]===1:false}function m(n,e){return i$1(n,e,t)?t.pressed[e]===1:false}function I(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 U(n,e){return i$1(n,e,t)?t.hoverable[e]===1:false}function B(n,e){return i$1(n,e,t)?t.keyable[e]===1:false}function w(n,e,r){return l(n,e),t.hovered[e]=r?1:0,e}function D(n,e,r){return l(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 l(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 l(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],enabled:t.enabled[e]===1,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 l(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 l(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 l(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}function q(n,e){return l(n,e),t.enabled[e]=1,e}function z(n,e){return l(n,e),t.enabled[e]=0,t.hovered[e]=0,t.pressed[e]=0,t.focused[e]=0,e}function J(n,e){return i$1(n,e,t)?t.enabled[e]===1:true}export{P as A,R as B,V as C,N as D,Y as E,j as F,q as G,z as H,J as I,y as a,E as b,t as c,p as d,h as e,W as f,d as g,k as h,F as i,m as j,I as k,A as l,U as m,B 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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {Oa,va,ka,la,qa,sa,ra,oa,pa,ia,ua,ma,ta,na,ja,ha,K,Qa,jb,ib,db,Z,S,Q,U,T,bb,ab,L as L$1,E,z,H as H$1,sb,pb,nb,Pa,La,Ma,Da,ya,Ga,Ha,Ca,Ba,Aa,za,xa,Ja,Fa,wa,Ia,Ka,Ea,W,Na,_a,X,V,_,C,R as R$1,B as B$1,$a,J,N,M as M$1,F as F$1,cb,A,qb,lb,kb,eb,gb,hb,fb,r,p,o,Ya,I as I$1,n,m,l,q,ob,O,rb,Za,Ra,fa,mb,v,Y,$,aa,Va,s,P,i,h,Ua,Sa,da,ea,x,G as G$1,u,D as D$1,ba,Ta,j,g,ca,d,c as c$1,Wa,ga,t,y as y$1,f,a,e,k as k$1,b as b$1,w,Xa}from'./chunk-LYSK5S63.js';import {
|
|
2
|
-
`);for(let r of n){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let a=o.split(/\s+/);on(a,e);}return e}function ye(t){if(t.length===0)return {min:{x:0,y:0,z:0},max:{x:0,y:0,z:0},center:{x:0,y:0,z:0}};let e=1/0,n=1/0,r=1/0,o=-1/0,a=-1/0,s=-1/0;for(let i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.z<r&&(r=i.z),i.x>o&&(o=i.x),i.y>a&&(a=i.y),i.z>s&&(s=i.z);return {min:{x:e,y:n,z:r},max:{x:o,y:a,z:s},center:{x:(e+o)/2,y:(n+a)/2,z:(r+s)/2}}}function Br(t,e){let n=ce.parse(e),r=be(t),o=[...r.vertices];if(n.flipYZ&&(o=o.map(s=>({x:s.x,y:s.z,z:s.y}))),n.scale!==1){let s=n.scale;o=o.map(i=>({x:i.x*s,y:i.y*s,z:i.z*s}));}if(n.centerOrigin&&o.length>0){let s=ye(o),i=s.center.x,c=s.center.y,p=s.center.z;o=o.map(m=>({x:m.x-i,y:m.y-c,z:m.z-p}));}let a=r.faces.map(s=>[...s.vertexIndices]);return I$1(n.name,o,a)}var an=0,sn=1,Er=2,Vr=4,jr=8;function L(t,e,n){let r=an;return t<n.xMin?r|=sn:t>n.xMax&&(r|=Er),e<n.yMin?r|=Vr:e>n.yMax&&(r|=jr),r}function mn(t,e,n,r,o,a){return t&jr?{x:e+r*(a.yMax-n)/o,y:a.yMax}:t&Vr?{x:e+r*(a.yMin-n)/o,y:a.yMin}:t&Er?{x:a.xMax,y:n+o*(a.xMax-e)/r}:{x:a.xMin,y:n+o*(a.xMin-e)/r}}function Tr(t,e,n,r,o){let a=t,s=e,i=n,c=r,p=L(a,s,o),m=L(i,c,o);for(;;){if((p|m)===0)return {x0:a,y0:s,x1:i,y1:c};if((p&m)!==0)return null;let u=p!==0?p:m,f=i-a,h=c-s,d=mn(u,a,s,f,h,o);u===p?(a=d.x,s=d.y,p=L(a,s,o)):(i=d.x,c=d.y,m=L(i,c,o));}}function kr(t){let e=t,n=[];return n.push(k(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12])),n.push(k(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12])),n.push(k(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13])),n.push(k(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13])),n.push(k(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14])),n.push(k(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])),n}function k(t,e,n,r){let o=Math.sqrt(t*t+e*e+n*n);if(o===0)return {normal:ha(0,0,0),distance:0};let a=1/o;return {normal:ha(t*a,e*a,n*a),distance:r*a}}function Lr(t,e){for(let n of e)if(ma(n.normal,t)+n.distance<0)return false;return true}function Rr(t,e,n){for(let r of n)if(ma(r.normal,t)+r.distance<-e)return false;return true}function M(t,e,n,r,o,a,s,i){if(!_a(t,e,n)||i<=0)return;if(i>=1){bb(t,e,n,r,o,a,s);return}let c=$a(t,e,n),p=1-i,m=Math.round(c.r*p+r*i),u=Math.round(c.g*p+o*i),f=Math.round(c.b*p+a*i),h=Math.round(c.a*p+s*i);bb(t,e,n,m,u,f,h);}function Yr(t,e,n,r,o,a,s,i,c=255){let p=Math.abs(o-n)>Math.abs(r-e),m=e,u=n,f=r,h=o;p&&([m,u]=[u,m],[f,h]=[h,f]),m>f&&([m,f]=[f,m],[u,h]=[h,u]);let d=f-m,v=h-u,P=d===0?1:v/d,E=Math.round(m),S=u+P*(E-m),O=1-F(m+.5),Y=E,q=Math.floor(S);p?(M(t,q,Y,a,s,i,c,R(S)*O),M(t,q+1,Y,a,s,i,c,F(S)*O)):(M(t,Y,q,a,s,i,c,R(S)*O),M(t,Y,q+1,a,s,i,c,F(S)*O));let V=S+P;E=Math.round(f),S=h+P*(E-f),O=F(f+.5);let W=E,U=Math.floor(S);p?(M(t,U,W,a,s,i,c,R(S)*O),M(t,U+1,W,a,s,i,c,F(S)*O)):(M(t,W,U,a,s,i,c,R(S)*O),M(t,W,U+1,a,s,i,c,F(S)*O));for(let j=Y+1;j<W;j++){let _=Math.floor(V);p?(M(t,_,j,a,s,i,c,R(V)),M(t,_+1,j,a,s,i,c,F(V))):(M(t,j,_,a,s,i,c,R(V)),M(t,j,_+1,a,s,i,c,F(V))),V+=P;}}function F(t){return t-Math.floor(t)}function R(t){return 1-F(t)}function de(t,e,n){let r=ka(e,t),o=ka(n,t);return qa(na(r,o))}function he(t,e,n,r){let o=e.direction,a=e.intensity??1,s=n.intensity??.1,i=-(t[0]*o[0]+t[1]*o[1]+t[2]*o[2]),c=Math.max(0,i)*a,p=Math.min(1,s+c),m=e.color??{r:255,g:255,b:255},u=n.color??{r:255,g:255,b:255},f=(u.r*s+m.r*c)/Math.max(.001,p),h=(u.g*s+m.g*c)/Math.max(.001,p),d=(u.b*s+m.b*c)/Math.max(.001,p);return {r:Math.round(Math.min(255,r.r*p*f/255)),g:Math.round(Math.min(255,r.g*p*h/255)),b:Math.round(Math.min(255,r.b*p*d/255)),a:r.a}}function Wr(t,e,n,r,o,a){let s=de(t,e,n);return he(s,r,o,a)}function Nr(t){let e=ue.parse(t??{}),n=e.size,r=[{x:-n,y:-n,z:-n},{x:n,y:-n,z:-n},{x:n,y:n,z:-n},{x:-n,y:n,z:-n},{x:-n,y:-n,z:n},{x:n,y:-n,z:n},{x:n,y:n,z:n},{x:-n,y:n,z:n}],o=[[0,1,2,3],[5,4,7,6],[4,0,3,7],[1,5,6,2],[3,2,6,7],[4,5,1,0]];return I$1(e.name,r,o)}function Zr(t){let e=pe.parse(t??{}),{radius:n,widthSegments:r,heightSegments:o,name:a}=e,s=[],i=[];for(let c=0;c<=o;c++){let p=c*Math.PI/o,m=Math.sin(p),u=Math.cos(p);for(let f=0;f<=r;f++){let h=f*2*Math.PI/r,d=n*m*Math.cos(h),v=n*u,P=n*m*Math.sin(h);s.push({x:d,y:v,z:P});}}for(let c=0;c<o;c++)for(let p=0;p<r;p++){let m=c*(r+1)+p,u=m+r+1;c!==0&&i.push([m,u,m+1]),c!==o-1&&i.push([u,u+1,m+1]);}return I$1(a,s,i)}function Xr(t){let e=le.parse(t??{}),{width:n,height:r,widthSegments:o,heightSegments:a,name:s}=e,i=[],c=[],p=n/2,m=r/2;for(let f=0;f<=a;f++){let h=f/a*r-m;for(let d=0;d<=o;d++){let v=d/o*n-p;i.push({x:v,y:0,z:h});}}let u=o+1;for(let f=0;f<a;f++)for(let h=0;h<o;h++){let d=f*u+h,v=d+1,P=d+u+1,E=d+u;c.push([d,v,P,E]);}return I$1(s,i,c)}function Gr(t){let e=fe.parse(t??{}),{radiusTop:n,radiusBottom:r,height:o,segments:a,name:s}=e,i=[],c=[],p=o/2;for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:n*Math.cos(u),y:p,z:n*Math.sin(u)});}for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:r*Math.cos(u),y:-p,z:r*Math.sin(u)});}for(let m=0;m<a;m++){let u=(m+1)%a,f=m,h=u,d=m+a,v=u+a;c.push([f,h,v,d]);}if(n>0){let m=i.length;i.push({x:0,y:p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,u,f]);}}if(r>0){let m=i.length;i.push({x:0,y:-p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,f+a,u+a]);}}return I$1(s,i,c)}n$1();var Hr=t=>{let e=
|
|
1
|
+
import {Oa,va,ka,la,qa,sa,ra,oa,pa,ia,ua,ma,ta,na,ja,ha,K,Qa,jb,ib,db,Z,S,Q,U,T,bb,ab,L as L$1,E,z,H as H$1,sb,pb,nb,Pa,La,Ma,Da,ya,Ga,Ha,Ca,Ba,Aa,za,xa,Ja,Fa,wa,Ia,Ka,Ea,W,Na,_a,X,V,_,C,R as R$1,B as B$1,$a,J,N,M as M$1,F as F$1,cb,A,qb,lb,kb,eb,gb,hb,fb,r,p,o,Ya,I as I$1,n,m,l,q,ob,O,rb,Za,Ra,fa,mb,v,Y,$,aa,Va,s,P,i,h,Ua,Sa,da,ea,x,G as G$1,u,D as D$1,ba,Ta,j,g,ca,d,c as c$1,Wa,ga,t,y as y$1,f,a,e,k as k$1,b as b$1,w,Xa}from'./chunk-LYSK5S63.js';import {a as a$1}from'./chunk-D42Q2KKR.js';import {b as b$2,a as a$2,f as f$1}from'./chunk-G7GIWWLE.js';import {n as n$1,i as i$1,h as h$1,j as j$1,k as k$2}from'./chunk-PXXGH3BV.js';import {c}from'./chunk-5PELJRUQ.js';import {z as z$1}from'zod';var fn={};c(fn,{AmbientLightSchema:()=>Xa,Animation3D:()=>y,Animation3DConfigSchema:()=>w,BackendCapabilitiesSchema:()=>b$1,BackendPreferenceSchema:()=>k$1,BackendSelectionSchema:()=>e,BackendTypeSchema:()=>a,BrailleConfigSchema:()=>f,Camera3D:()=>y$1,Camera3DConfigSchema:()=>t,ClipRectSchema:()=>ga,CubeMeshOptionsSchema:()=>ue,CylinderMeshOptionsSchema:()=>fe,DirectionalLightSchema:()=>Wa,EncodedCellSchema:()=>c$1,EncodedOutputSchema:()=>d,EulerAnglesSchema:()=>ca,HalfBlockConfigSchema:()=>g,KittyConfigSchema:()=>j,LineEndpointSchema:()=>Ta,Mat4Schema:()=>ba,Material3D:()=>D$1,Material3DConfigSchema:()=>u,Mesh:()=>G$1,MouseInteraction3D:()=>b,MouseInteraction3DConfigSchema:()=>x,ObjLoadOptionsSchema:()=>ce,OrthographicConfigSchema:()=>ea,PerspectiveConfigSchema:()=>da,PixelBufferConfigSchema:()=>Sa,PlaneMeshOptionsSchema:()=>le,RGBAColorSchema:()=>Ua,SextantConfigSchema:()=>h,SixelConfigSchema:()=>i,SphereMeshOptionsSchema:()=>pe,Transform3D:()=>P,Transform3DConfigSchema:()=>s,TriangleVertexSchema:()=>Va,Vec3InputSchema:()=>aa,Vec3Schema:()=>$,Viewport3D:()=>Y,Viewport3DConfigSchema:()=>v,Viewport3DWidgetConfigSchema:()=>mb,ViewportConfigSchema:()=>fa,animation3DSystem:()=>Hr,backendStore:()=>G,blendPixel:()=>M,buildMVP:()=>Ra,clearBackendStore:()=>Jr,clearFramebuffer:()=>Za,clearFramebufferStore:()=>rb,clearMeshStore:()=>O,clearMouseInputStore:()=>me,clearOutputStore:()=>Qr,clearProjectionStore:()=>ob,clipLine:()=>Tr,computeBoundingBox:()=>ye,computeFaceNormal:()=>de,computeFlatShading:()=>he,computeOutcode:()=>L,createBackendByType:()=>q,createBrailleBackend:()=>l,createCubeMesh:()=>Nr,createCylinderMesh:()=>Gr,createHalfBlockBackend:()=>m,createKittyBackend:()=>n,createMeshFromArrays:()=>I$1,createPixelFramebuffer:()=>Ya,createPlaneMesh:()=>Xr,createSextantBackend:()=>o,createSixelBackend:()=>p,createSphereMesh:()=>Zr,detectBestBackend:()=>r,disableMouseInteraction:()=>Fr,drawLine:()=>fb,drawLineAA:()=>Yr,drawLineColor:()=>hb,drawLineDepth:()=>gb,enableMouseInteraction:()=>Ir,extractFrustumPlanes:()=>kr,feedMouseDrag:()=>Ar,feedMouseScroll:()=>zr,fillRect:()=>eb,fillTriangle:()=>kb,fillTriangleFlat:()=>lb,framebufferStore:()=>qb,getAnimation3D:()=>Or,getCamera3D:()=>A,getDepth:()=>cb,getMaterial3D:()=>F$1,getMesh:()=>M$1,getMeshCount:()=>N,getMeshData:()=>J,getMouseInteraction3D:()=>Pr,getPixel:()=>$a,getProjMatrix:()=>B$1,getTransform3D:()=>R$1,getViewMatrix:()=>C,getViewport3D:()=>_,getWorldMatrix:()=>V,isDirty:()=>X,isInBounds:()=>_a,isPointInFrustum:()=>Lr,isSphereInFrustum:()=>Rr,loadObjAsMesh:()=>Br,lookAt:()=>Na,markDirty:()=>W,mat4Determinant:()=>Ea,mat4Equals:()=>Ka,mat4FromTRS:()=>Ia,mat4Identity:()=>wa,mat4Invert:()=>Fa,mat4IsIdentity:()=>Ja,mat4Multiply:()=>xa,mat4RotateX:()=>za,mat4RotateY:()=>Aa,mat4RotateZ:()=>Ba,mat4Scale:()=>Ca,mat4TransformDirection:()=>Ha,mat4TransformVec3:()=>Ga,mat4Translate:()=>ya,mat4Transpose:()=>Da,mouseInputStore:()=>I,mouseInteraction3DSystem:()=>Ur,orthographicMatrix:()=>Ma,outputStore:()=>H,parseObj:()=>be,perspectiveMatrix:()=>La,projectVertex:()=>Pa,projectionStore:()=>nb,projectionSystem:()=>pb,rasterSystem:()=>sb,registerMesh:()=>H$1,sceneGraphSystem:()=>Kr,setAnimation3D:()=>vr,setCamera3D:()=>z,setMaterial3D:()=>E,setMesh:()=>L$1,setPixel:()=>ab,setPixelUnsafe:()=>bb,setRotation:()=>T,setScale:()=>U,setTransform3D:()=>Q,setTranslation:()=>S,setViewport3D:()=>Z,shadeFace:()=>Wr,testAndSetDepth:()=>db,triangleArea2:()=>ib,triangleBoundingBox:()=>jb,unprojectVertex:()=>Qa,unregisterMesh:()=>K,vec3:()=>ha,vec3Add:()=>ja,vec3Cross:()=>na,vec3Distance:()=>ta,vec3Dot:()=>ma,vec3Equals:()=>ua,vec3FromArray:()=>ia,vec3Length:()=>pa,vec3LengthSq:()=>oa,vec3Lerp:()=>ra,vec3Negate:()=>sa,vec3Normalize:()=>qa,vec3Scale:()=>la,vec3Sub:()=>ka,vec3Zero:()=>va,viewportOutputSystem:()=>$r,viewportTransform:()=>Oa});n$1();var D=1e4,y={rotateSpeedX:new Float32Array(D),rotateSpeedY:new Float32Array(D),rotateSpeedZ:new Float32Array(D),orbitCenterX:new Float32Array(D),orbitCenterY:new Float32Array(D),orbitCenterZ:new Float32Array(D),orbitSpeed:new Float32Array(D),orbitRadius:new Float32Array(D),orbitAngle:new Float32Array(D),orbitEnabled:new Uint8Array(D)};function vr(t,e,n){let r=w.parse(n);return i$1(t,e,y)||h$1(t,e,y),y.rotateSpeedX[e]=r.rotateSpeed.x,y.rotateSpeedY[e]=r.rotateSpeed.y,y.rotateSpeedZ[e]=r.rotateSpeed.z,r.orbitCenter&&(y.orbitCenterX[e]=r.orbitCenter[0],y.orbitCenterY[e]=r.orbitCenter[1],y.orbitCenterZ[e]=r.orbitCenter[2],y.orbitEnabled[e]=1),y.orbitSpeed[e]=r.orbitSpeed,r.orbitRadius!==void 0&&(y.orbitRadius[e]=r.orbitRadius),e}function Or(t,e){if(i$1(t,e,y))return {rotateSpeedX:y.rotateSpeedX[e],rotateSpeedY:y.rotateSpeedY[e],rotateSpeedZ:y.rotateSpeedZ[e],orbitCenterX:y.orbitCenterX[e],orbitCenterY:y.orbitCenterY[e],orbitCenterZ:y.orbitCenterZ[e],orbitSpeed:y.orbitSpeed[e],orbitRadius:y.orbitRadius[e],orbitAngle:y.orbitAngle[e],orbitEnabled:y.orbitEnabled[e]===1}}n$1();var B=1e4,b={rotationSensitivity:new Float32Array(B),zoomSensitivity:new Float32Array(B),zoomMin:new Float32Array(B),zoomMax:new Float32Array(B),invertY:new Uint8Array(B),distance:new Float32Array(B),yaw:new Float32Array(B),pitch:new Float32Array(B)},I=new Map;function me(){I.clear();}function Ar(t,e,n){let r=I.get(t);r?(r.dragDx+=e,r.dragDy+=n):I.set(t,{dragDx:e,dragDy:n,scrollDelta:0});}function zr(t,e){let n=I.get(t);n?n.scrollDelta+=e:I.set(t,{dragDx:0,dragDy:0,scrollDelta:e});}function Ir(t,e,n={},r=5){let o=x.parse(n);i$1(t,e,b)||h$1(t,e,b),b.rotationSensitivity[e]=o.rotationSensitivity,b.zoomSensitivity[e]=o.zoomSensitivity,b.zoomMin[e]=o.zoomMin,b.zoomMax[e]=o.zoomMax,b.invertY[e]=o.invertY?1:0;let a=Math.max(o.zoomMin,Math.min(o.zoomMax,r));return b.distance[e]=a,b.yaw[e]=0,b.pitch[e]=0,e}function Fr(t,e){i$1(t,e,b)&&j$1(t,e,b);}function Pr(t,e){if(i$1(t,e,b))return {rotationSensitivity:b.rotationSensitivity[e],zoomSensitivity:b.zoomSensitivity[e],zoomMin:b.zoomMin[e],zoomMax:b.zoomMax[e],invertY:b.invertY[e]===1,distance:b.distance[e],yaw:b.yaw[e],pitch:b.pitch[e]}}var ce=z$1.object({name:z$1.string().min(1).describe("Name for the mesh in meshStore"),flipYZ:z$1.boolean().default(false).describe("Swap Y and Z axes (some models use Z-up)"),scale:z$1.number().positive().default(1).describe("Uniform scale factor"),centerOrigin:z$1.boolean().default(true).describe("Center model at origin")}),ue=z$1.object({size:z$1.number().positive().default(1).describe("Half-extent of cube"),name:z$1.string().default("cube")}),pe=z$1.object({radius:z$1.number().positive().default(1),widthSegments:z$1.number().int().min(3).max(128).default(16),heightSegments:z$1.number().int().min(2).max(64).default(12),name:z$1.string().default("sphere")}),le=z$1.object({width:z$1.number().positive().default(2),height:z$1.number().positive().default(2),widthSegments:z$1.number().int().min(1).max(128).default(1),heightSegments:z$1.number().int().min(1).max(128).default(1),name:z$1.string().default("plane")}),fe=z$1.object({radiusTop:z$1.number().nonnegative().default(1),radiusBottom:z$1.number().nonnegative().default(1),height:z$1.number().positive().default(2),segments:z$1.number().int().min(3).max(128).default(16),name:z$1.string().default("cylinder")}).refine(t=>t.radiusTop>0||t.radiusBottom>0,{message:"At least one radius must be positive"});function wr(t){return t.length<4?null:{x:Number.parseFloat(t[1]),y:Number.parseFloat(t[2]),z:Number.parseFloat(t[3])}}function tn(t){return t.length<3?null:{u:Number.parseFloat(t[1]),v:Number.parseFloat(t[2])}}function rn(t,e,n,r){let o=t.split("/"),a=Number.parseInt(o[0],10);a=a<0?e+a:a-1;let s={vi:a};if(o.length>=2&&o[1]!==""){let i=Number.parseInt(o[1],10);i=i<0?n+i:i-1,s.ti=i;}if(o.length>=3&&o[2]!==""){let i=Number.parseInt(o[2],10);i=i<0?r+i:i-1,s.ni=i;}return s}function nn(t,e,n,r){if(t.length<4)return null;let o=[],a=[],s=[],i=false,c=false;for(let p=1;p<t.length;p++){let m=rn(t[p],e,n,r);o.push(m.vi),m.ti!==void 0&&(s.push(m.ti),c=true),m.ni!==void 0&&(a.push(m.ni),i=true);}return {vertexIndices:o,...i?{normalIndices:a}:{},...c?{texCoordIndices:s}:{}}}function on(t,e){let n=t[0];if(n==="v"){let r=wr(t);r&&e.vertices.push(r);return}if(n==="vn"){let r=wr(t);r&&e.normals.push(r);return}if(n==="vt"){let r=tn(t);r&&e.texCoords.push(r);return}if(n==="f"){let r=nn(t,e.vertices.length,e.texCoords.length,e.normals.length);r&&e.faces.push(r);return}(n==="g"||n==="o")&&t.length>=2&&e.groups.push({name:t.slice(1).join(" "),startFace:e.faces.length});}function be(t){let e={vertices:[],normals:[],texCoords:[],faces:[],groups:[]},n=t.split(`
|
|
2
|
+
`);for(let r of n){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let a=o.split(/\s+/);on(a,e);}return e}function ye(t){if(t.length===0)return {min:{x:0,y:0,z:0},max:{x:0,y:0,z:0},center:{x:0,y:0,z:0}};let e=1/0,n=1/0,r=1/0,o=-1/0,a=-1/0,s=-1/0;for(let i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.z<r&&(r=i.z),i.x>o&&(o=i.x),i.y>a&&(a=i.y),i.z>s&&(s=i.z);return {min:{x:e,y:n,z:r},max:{x:o,y:a,z:s},center:{x:(e+o)/2,y:(n+a)/2,z:(r+s)/2}}}function Br(t,e){let n=ce.parse(e),r=be(t),o=[...r.vertices];if(n.flipYZ&&(o=o.map(s=>({x:s.x,y:s.z,z:s.y}))),n.scale!==1){let s=n.scale;o=o.map(i=>({x:i.x*s,y:i.y*s,z:i.z*s}));}if(n.centerOrigin&&o.length>0){let s=ye(o),i=s.center.x,c=s.center.y,p=s.center.z;o=o.map(m=>({x:m.x-i,y:m.y-c,z:m.z-p}));}let a=r.faces.map(s=>[...s.vertexIndices]);return I$1(n.name,o,a)}var an=0,sn=1,Er=2,Vr=4,jr=8;function L(t,e,n){let r=an;return t<n.xMin?r|=sn:t>n.xMax&&(r|=Er),e<n.yMin?r|=Vr:e>n.yMax&&(r|=jr),r}function mn(t,e,n,r,o,a){return t&jr?{x:e+r*(a.yMax-n)/o,y:a.yMax}:t&Vr?{x:e+r*(a.yMin-n)/o,y:a.yMin}:t&Er?{x:a.xMax,y:n+o*(a.xMax-e)/r}:{x:a.xMin,y:n+o*(a.xMin-e)/r}}function Tr(t,e,n,r,o){let a=t,s=e,i=n,c=r,p=L(a,s,o),m=L(i,c,o);for(;;){if((p|m)===0)return {x0:a,y0:s,x1:i,y1:c};if((p&m)!==0)return null;let u=p!==0?p:m,f=i-a,h=c-s,d=mn(u,a,s,f,h,o);u===p?(a=d.x,s=d.y,p=L(a,s,o)):(i=d.x,c=d.y,m=L(i,c,o));}}function kr(t){let e=t,n=[];return n.push(k(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12])),n.push(k(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12])),n.push(k(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13])),n.push(k(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13])),n.push(k(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14])),n.push(k(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])),n}function k(t,e,n,r){let o=Math.sqrt(t*t+e*e+n*n);if(o===0)return {normal:ha(0,0,0),distance:0};let a=1/o;return {normal:ha(t*a,e*a,n*a),distance:r*a}}function Lr(t,e){for(let n of e)if(ma(n.normal,t)+n.distance<0)return false;return true}function Rr(t,e,n){for(let r of n)if(ma(r.normal,t)+r.distance<-e)return false;return true}function M(t,e,n,r,o,a,s,i){if(!_a(t,e,n)||i<=0)return;if(i>=1){bb(t,e,n,r,o,a,s);return}let c=$a(t,e,n),p=1-i,m=Math.round(c.r*p+r*i),u=Math.round(c.g*p+o*i),f=Math.round(c.b*p+a*i),h=Math.round(c.a*p+s*i);bb(t,e,n,m,u,f,h);}function Yr(t,e,n,r,o,a,s,i,c=255){let p=Math.abs(o-n)>Math.abs(r-e),m=e,u=n,f=r,h=o;p&&([m,u]=[u,m],[f,h]=[h,f]),m>f&&([m,f]=[f,m],[u,h]=[h,u]);let d=f-m,v=h-u,P=d===0?1:v/d,E=Math.round(m),S=u+P*(E-m),O=1-F(m+.5),Y=E,q=Math.floor(S);p?(M(t,q,Y,a,s,i,c,R(S)*O),M(t,q+1,Y,a,s,i,c,F(S)*O)):(M(t,Y,q,a,s,i,c,R(S)*O),M(t,Y,q+1,a,s,i,c,F(S)*O));let V=S+P;E=Math.round(f),S=h+P*(E-f),O=F(f+.5);let W=E,U=Math.floor(S);p?(M(t,U,W,a,s,i,c,R(S)*O),M(t,U+1,W,a,s,i,c,F(S)*O)):(M(t,W,U,a,s,i,c,R(S)*O),M(t,W,U+1,a,s,i,c,F(S)*O));for(let j=Y+1;j<W;j++){let _=Math.floor(V);p?(M(t,_,j,a,s,i,c,R(V)),M(t,_+1,j,a,s,i,c,F(V))):(M(t,j,_,a,s,i,c,R(V)),M(t,j,_+1,a,s,i,c,F(V))),V+=P;}}function F(t){return t-Math.floor(t)}function R(t){return 1-F(t)}function de(t,e,n){let r=ka(e,t),o=ka(n,t);return qa(na(r,o))}function he(t,e,n,r){let o=e.direction,a=e.intensity??1,s=n.intensity??.1,i=-(t[0]*o[0]+t[1]*o[1]+t[2]*o[2]),c=Math.max(0,i)*a,p=Math.min(1,s+c),m=e.color??{r:255,g:255,b:255},u=n.color??{r:255,g:255,b:255},f=(u.r*s+m.r*c)/Math.max(.001,p),h=(u.g*s+m.g*c)/Math.max(.001,p),d=(u.b*s+m.b*c)/Math.max(.001,p);return {r:Math.round(Math.min(255,r.r*p*f/255)),g:Math.round(Math.min(255,r.g*p*h/255)),b:Math.round(Math.min(255,r.b*p*d/255)),a:r.a}}function Wr(t,e,n,r,o,a){let s=de(t,e,n);return he(s,r,o,a)}function Nr(t){let e=ue.parse(t??{}),n=e.size,r=[{x:-n,y:-n,z:-n},{x:n,y:-n,z:-n},{x:n,y:n,z:-n},{x:-n,y:n,z:-n},{x:-n,y:-n,z:n},{x:n,y:-n,z:n},{x:n,y:n,z:n},{x:-n,y:n,z:n}],o=[[0,1,2,3],[5,4,7,6],[4,0,3,7],[1,5,6,2],[3,2,6,7],[4,5,1,0]];return I$1(e.name,r,o)}function Zr(t){let e=pe.parse(t??{}),{radius:n,widthSegments:r,heightSegments:o,name:a}=e,s=[],i=[];for(let c=0;c<=o;c++){let p=c*Math.PI/o,m=Math.sin(p),u=Math.cos(p);for(let f=0;f<=r;f++){let h=f*2*Math.PI/r,d=n*m*Math.cos(h),v=n*u,P=n*m*Math.sin(h);s.push({x:d,y:v,z:P});}}for(let c=0;c<o;c++)for(let p=0;p<r;p++){let m=c*(r+1)+p,u=m+r+1;c!==0&&i.push([m,u,m+1]),c!==o-1&&i.push([u,u+1,m+1]);}return I$1(a,s,i)}function Xr(t){let e=le.parse(t??{}),{width:n,height:r,widthSegments:o,heightSegments:a,name:s}=e,i=[],c=[],p=n/2,m=r/2;for(let f=0;f<=a;f++){let h=f/a*r-m;for(let d=0;d<=o;d++){let v=d/o*n-p;i.push({x:v,y:0,z:h});}}let u=o+1;for(let f=0;f<a;f++)for(let h=0;h<o;h++){let d=f*u+h,v=d+1,P=d+u+1,E=d+u;c.push([d,v,P,E]);}return I$1(s,i,c)}function Gr(t){let e=fe.parse(t??{}),{radiusTop:n,radiusBottom:r,height:o,segments:a,name:s}=e,i=[],c=[],p=o/2;for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:n*Math.cos(u),y:p,z:n*Math.sin(u)});}for(let m=0;m<a;m++){let u=m/a*Math.PI*2;i.push({x:r*Math.cos(u),y:-p,z:r*Math.sin(u)});}for(let m=0;m<a;m++){let u=(m+1)%a,f=m,h=u,d=m+a,v=u+a;c.push([f,h,v,d]);}if(n>0){let m=i.length;i.push({x:0,y:p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,u,f]);}}if(r>0){let m=i.length;i.push({x:0,y:-p,z:0});for(let u=0;u<a;u++){let f=(u+1)%a;c.push([m,f+a,u+a]);}}return I$1(s,i,c)}n$1();var Hr=t=>{let e=a$1();if(e<=0)return t;let n=k$2(t,[y,P]);for(let r of n){let o=false,a=y.rotateSpeedX[r],s=y.rotateSpeedY[r],i=y.rotateSpeedZ[r];a!==0&&(P.rx[r]=P.rx[r]+a*e,o=true),s!==0&&(P.ry[r]=P.ry[r]+s*e,o=true),i!==0&&(P.rz[r]=P.rz[r]+i*e,o=true);let c=y.orbitEnabled[r],p=y.orbitSpeed[r];if(c===1&&p!==0){let m=y.orbitRadius[r],u=y.orbitCenterX[r],f=y.orbitCenterY[r],h=y.orbitCenterZ[r],d=y.orbitAngle[r]+p*e;y.orbitAngle[r]=d,P.tx[r]=u+Math.cos(d)*m,P.ty[r]=f,P.tz[r]=h+Math.sin(d)*m,o=true;}o&&(P.dirty[r]=1);}return t};n$1();var qr=Math.PI/2-.01,Ur=t=>{let e=k$2(t,[Y]);for(let n of e){let r=I.get(n);if(!r)continue;let o=Y.cameraEntity[n];if(o===0||!i$1(t,o,b))continue;let a=b.rotationSensitivity[o];if(r.dragDx!==0||r.dragDy!==0){let m=b.invertY[o]===1?-1:1,u=r.dragDx*a,f=r.dragDy*a*m,h=b.yaw[o]+u,d=Math.max(-qr,Math.min(qr,b.pitch[o]+f));b.yaw[o]=h,b.pitch[o]=d;}if(r.scrollDelta!==0){let m=b.zoomSensitivity[o],u=b.zoomMin[o],f=b.zoomMax[o],h=b.distance[o],d=Math.max(u,Math.min(f,h+r.scrollDelta*m));b.distance[o]=d;}let s=b.yaw[o],i=b.pitch[o],c=b.distance[o],p=Math.cos(i);P.tx[o]=Math.sin(s)*p*c,P.ty[o]=Math.sin(i)*c,P.tz[o]=Math.cos(s)*p*c,P.rx[o]=-i,P.ry[o]=-s,P.rz[o]=0,P.dirty[o]=1;}return me(),t};n$1();function cn(t){let e=ha(P.tx[t],P.ty[t],P.tz[t]),n=ha(P.rx[t],P.ry[t],P.rz[t]),r=ha(P.sx[t],P.sy[t],P.sz[t]);return Ia(e,n,r)}function un(t,e){let n=t*16;for(let r=0;r<16;r++)P.worldMatrix[n+r]=e[r];}function _r(t,e,n){if(!i$1(t,e,P))return;let r=P.dirty[e]!==0;if(r){let s=cn(e),i=n?xa(n,s):s;un(e,i),P.dirty[e]=0;}let o=e*16,a=P.worldMatrix.subarray(o,o+16);if(i$1(t,e,b$2)){let s=f$1(t,e);for(let i of s)r&&i$1(t,i,P)&&(P.dirty[i]=1),_r(t,i,a);}}var Kr=t=>{let e=k$2(t,[P]),n=[];for(let r of e){if(!i$1(t,r,b$2)){n.push(r);continue}let o=b$2.parent[r];(o===a$2||!i$1(t,o,P))&&n.push(r);}for(let r of n)_r(t,r,null);return t};n$1();var pn=["braille","braille","halfblock","sextant","sixel","kitty"],G=new Map,H=new Map;function Jr(){G.clear();}function Qr(){H.clear();}function ln(t){let e=Y.backendType[t],n=pn[e]??"braille",r=G.get(t);if(r&&r.type===n)return r;let o=q(n);return G.set(t,o),o}var $r=t=>{H.clear();let e=k$2(t,[Y]);for(let n of e){let r=qb.get(n);if(!r)continue;let o=ln(n),a=Y.left[n],s=Y.top[n],i=o.encode(r,a,s);H.set(n,{viewportEid:n,screenX:a,screenY:s,backendType:o.type,encoded:i});}return t};export{de as A,he as B,Wr as C,Nr as D,Zr as E,Xr as F,Gr as G,Hr as H,Ur as I,Kr as J,G as K,H as L,Jr as M,Qr as N,$r as O,fn as P,y as a,vr as b,Or as c,b as d,I as e,me as f,Ar as g,zr as h,Ir as i,Fr as j,Pr as k,ce as l,ue as m,pe as n,le as o,fe as p,be as q,ye as r,Br as s,L as t,Tr as u,kr as v,Lr as w,Rr as x,M as y,Yr as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=Symbol.for("blecsd.error");var
|
|
1
|
+
var E=Symbol.for("blecsd.error");var t={INVALID_INPUT:"VALIDATION_INVALID_INPUT",INVALID_HEX_COLOR:"VALIDATION_INVALID_HEX_COLOR",INVALID_HEX_LENGTH:"VALIDATION_INVALID_HEX_LENGTH",INVALID_COLOR_OBJECT:"VALIDATION_INVALID_COLOR_OBJECT",INVALID_COLOR_VALUE:"VALIDATION_INVALID_COLOR_VALUE",INVALID_PALETTE_INDEX:"VALIDATION_INVALID_PALETTE_INDEX",INVALID_CUBE_INDEX:"VALIDATION_INVALID_CUBE_INDEX",INVALID_GRAYSCALE_INDEX:"VALIDATION_INVALID_GRAYSCALE_INDEX",INVALID_DIMENSION:"VALIDATION_INVALID_DIMENSION",INVALID_BUFFER_DIMENSIONS:"VALIDATION_INVALID_BUFFER_DIMENSIONS",INVALID_SURROGATE_PAIR:"VALIDATION_INVALID_SURROGATE_PAIR",SCHEMA_VALIDATION_FAILED:"VALIDATION_SCHEMA_FAILED",REQUIRED_FIELD_MISSING:"VALIDATION_REQUIRED_FIELD_MISSING",VALUE_OUT_OF_RANGE:"VALIDATION_VALUE_OUT_OF_RANGE"},i={TERMINAL_ERROR:"TERMINAL_ERROR",NOT_INITIALIZED:"TERMINAL_NOT_INITIALIZED",ALREADY_INITIALIZED:"TERMINAL_ALREADY_INITIALIZED",TERMINFO_NOT_FOUND:"TERMINAL_TERMINFO_NOT_FOUND",NEGOTIATION_NOT_STARTED:"TERMINAL_NEGOTIATION_NOT_STARTED",NEGOTIATION_ALREADY_STARTED:"TERMINAL_NEGOTIATION_ALREADY_STARTED",CAPABILITY_NOT_SUPPORTED:"TERMINAL_CAPABILITY_NOT_SUPPORTED",WRITE_FAILED:"TERMINAL_WRITE_FAILED",READ_FAILED:"TERMINAL_READ_FAILED",CLEANUP_FAILED:"TERMINAL_CLEANUP_FAILED"},d={SYSTEM_ERROR:"SYSTEM_ERROR",LOOP_ALREADY_RUNNING:"SYSTEM_LOOP_ALREADY_RUNNING",LOOP_NOT_RUNNING:"SYSTEM_LOOP_NOT_RUNNING",CANNOT_CHANGE_WORLD:"SYSTEM_CANNOT_CHANGE_WORLD",SYSTEM_EXECUTION_FAILED:"SYSTEM_EXECUTION_FAILED",PHASE_NOT_FOUND:"SYSTEM_PHASE_NOT_FOUND",PHASE_ALREADY_EXISTS:"SYSTEM_PHASE_ALREADY_EXISTS",INVALID_PHASE_ORDER:"SYSTEM_INVALID_PHASE_ORDER",SCHEDULER_NOT_INITIALIZED:"SYSTEM_SCHEDULER_NOT_INITIALIZED"},I={ENTITY_ERROR:"ENTITY_ERROR",NOT_FOUND:"ENTITY_NOT_FOUND",ALREADY_EXISTS:"ENTITY_ALREADY_EXISTS",SCREEN_ALREADY_EXISTS:"ENTITY_SCREEN_ALREADY_EXISTS",INVALID_ID:"ENTITY_INVALID_ID",MISSING_COMPONENT:"ENTITY_MISSING_COMPONENT",HIERARCHY_ERROR:"ENTITY_HIERARCHY_ERROR"},a={COMPONENT_ERROR:"COMPONENT_ERROR",NOT_FOUND:"COMPONENT_NOT_FOUND",ALREADY_EXISTS:"COMPONENT_ALREADY_EXISTS",INVALID_DATA:"COMPONENT_INVALID_DATA",STORE_NOT_INITIALIZED:"COMPONENT_STORE_NOT_INITIALIZED"},T={INPUT_ERROR:"INPUT_ERROR",INVALID_KEY_SEQUENCE:"INPUT_INVALID_KEY_SEQUENCE",INVALID_MOUSE_EVENT:"INPUT_INVALID_MOUSE_EVENT",HANDLER_NOT_REGISTERED:"INPUT_HANDLER_NOT_REGISTERED",BUFFER_OVERFLOW:"INPUT_BUFFER_OVERFLOW"},p={RENDER_ERROR:"RENDER_ERROR",BUFFER_NOT_INITIALIZED:"RENDER_BUFFER_NOT_INITIALIZED",INVALID_COORDINATES:"RENDER_INVALID_COORDINATES",BUFFER_OVERFLOW:"RENDER_BUFFER_OVERFLOW",CYCLE_TIMEOUT:"RENDER_CYCLE_TIMEOUT"},s={CONFIG_ERROR:"CONFIG_ERROR",INVALID_GAME_CONFIG:"CONFIG_INVALID_GAME_CONFIG",INVALID_SCREEN_CONFIG:"CONFIG_INVALID_SCREEN_CONFIG",INVALID_WIDGET_CONFIG:"CONFIG_INVALID_WIDGET_CONFIG",MISSING_REQUIRED:"CONFIG_MISSING_REQUIRED"},C={INTERNAL_ERROR:"INTERNAL_ERROR",UNEXPECTED_STATE:"INTERNAL_UNEXPECTED_STATE",ASSERTION_FAILED:"INTERNAL_ASSERTION_FAILED",NOT_IMPLEMENTED:"INTERNAL_NOT_IMPLEMENTED",UNREACHABLE:"INTERNAL_UNREACHABLE"},O={...t,...i,...d,...I,...a,...T,...p,...s,...C};function S(r,e,o){return {kind:"validation",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.zodIssues?{...o.context,zodIssues:o.zodIssues}:o?.context}}function A(r,e,o){return {kind:"terminal",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function c(r,e,o){return {kind:"system",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function f(r,e,o){return {kind:"entity",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function D(r,e,o){return {kind:"component",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function L(r,e,o){return {kind:"input",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function m(r,e,o){return {kind:"render",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function x(r,e,o){return {kind:"config",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function N(r,e,o){return {kind:"internal",code:r,message:e,timestamp:Date.now(),cause:o?.cause,context:o?.context}}function B(r){let e=new Error(r.message);return e.name=`BlECSd${k(r.kind)}Error`,e[E]=r,r.cause&&(e.cause=r.cause),e}function _(r){return r==null||typeof r!="object"?null:E in r?r[E]:null}function V(r,e,o){let n=_(r);if(n)return n;let y=r instanceof Error?r:void 0,u=r instanceof Error?`${o}: ${r.message}`:`${o}: ${String(r)}`;return N(e,u,{cause:y})}function k(r){return r.charAt(0).toUpperCase()+r.slice(1)}function U(r){return r.kind==="validation"}function g(r){return r.kind==="terminal"}function M(r){return r.kind==="system"}function F(r){return r.kind==="entity"}function Y(r){return r.kind==="component"}function P(r){return r.kind==="input"}function G(r){return r.kind==="render"}function w(r){return r.kind==="config"}function H(r){return r.kind==="internal"}function v(r,e){return r.kind===e}function X(r,e){return r.code===e}function h(r){return r!=null&&typeof r=="object"&&E in r}function K(r){if(r==null||typeof r!="object")return false;let e=r;return typeof e.kind=="string"&&typeof e.code=="string"&&typeof e.message=="string"&&typeof e.timestamp=="number"}function Z(r){return r.context!=null}function b(r){return r.cause!=null}function z(r){return r.context!=null&&r.context.zodIssues!=null&&r.context.zodIssues.length>0}function R(r){return {ok:true,value:r}}function l(r){return {ok:false,error:r}}function W(r){return r.ok===true}function $(r){return r.ok===false}function Q(r){if(r.ok)return r.value;let e=r.error instanceof Error?r.error.message:typeof r.error=="object"&&r.error!==null&&"message"in r.error?String(r.error.message):String(r.error);throw new Error(`Called unwrap on Err: ${e}`)}function j(r,e){return r.ok?r.value:e}function J(r,e){return r.ok?r.value:e(r.error)}function q(r,e){return r.ok?R(e(r.value)):r}function rr(r,e){return r.ok?r:l(e(r.error))}function er(r,e){return r.ok?e(r.value):r}export{F as A,Y as B,P as C,G as D,w as E,H as F,v as G,X as H,h as I,K as J,Z as K,b as L,z as M,R as N,l as O,W as P,$ as Q,Q as R,j as S,J as T,q as U,rr as V,er as W,E as a,t as b,i as c,d,I as e,a as f,T as g,p as h,s as i,C as j,O as k,S as l,A as m,c as n,f as o,D as p,L as q,m as r,x as s,N as t,B as u,_ as v,V as w,U as x,g as y,M as z};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {c as c$1,d,z as z$2,y as y$1,ba as ba$1}from'./chunk-J7MBKEBY.js';import {g}from'./chunk-4LWWONFK.js';import {e,c,b,a as a$1}from'./chunk-C5PCEQ6G.js';import {t}from'./chunk-XQIGERNI.js';import {l}from'./chunk-MTV2RJZD.js';import {g as g$1}from'./chunk-3AV52GY5.js';import {f,r,s}from'./chunk-6M2J5QUA.js';import {a as a$2}from'./chunk-5PELJRUQ.js';import {z as z$1}from'zod';import {writeFileSync,appendFileSync,existsSync,mkdirSync,unlinkSync,readFileSync,statSync,renameSync}from'fs';import {dirname,join}from'path';import {inspect}from'util';import {spawn,spawnSync}from'child_process';import {tmpdir}from'os';import {EventEmitter}from'events';var a="\x1B[",L="\x1B]",se="\x1BP",U="\x1B\\",Z="\x07",N="\x1B";var vt={deiconify(){return `${"\x1B["}1t`},iconify(){return `${"\x1B["}2t`},move(e,t){return `${"\x1B["}3;${e};${t}t`},resizePixels(e,t){return `${"\x1B["}4;${t};${e}t`},raise(){return `${"\x1B["}5t`},lower(){return `${"\x1B["}6t`},refresh(){return `${"\x1B["}7t`},resizeChars(e,t){return `${"\x1B["}8;${t};${e}t`},restoreMaximized(){return `${"\x1B["}9;0t`},maximize(){return `${"\x1B["}9;1t`},maximizeVertical(){return `${"\x1B["}9;2t`},maximizeHorizontal(){return `${"\x1B["}9;3t`},exitFullScreen(){return `${"\x1B["}10;0t`},enterFullScreen(){return `${"\x1B["}10;1t`},toggleFullScreen(){return `${"\x1B["}10;2t`},pushTitle(e="both"){return `${"\x1B["}22;${e==="both"?0:e==="icon"?1:2}t`},popTitle(e="both"){return `${"\x1B["}23;${e==="both"?0:e==="icon"?1:2}t`},setLines(e){let t=Math.max(24,Math.floor(e));return `${"\x1B["}${t}t`}},We=["http:","https:","mailto:","file:","tel:"];function Ve(e){try{let t=new URL(e);return We.includes(t.protocol)}catch{return false}}var j={link(e,t,r){return `${j.start(e,r)}${t}${j.end()}`},start(e,t){let r=t?.id?`id=${t.id}`:"";return `${"\x1B]"}8;${r};${e}${"\x1B\\"}`},end(){return `${"\x1B]"}8;;${"\x1B\\"}`},safeLink(e,t,r){return Ve(e)?j.link(e,t,r):t},mailto(e,t,r){return j.link(`mailto:${e}`,t??e,r)},file(e,t,r){return j.link(`file://${e}`,t??e,r)}},_t={PRINT_SCREEN:0,PRINTER_OFF:4,PRINTER_ON:5,PRINT_LINE:1,PRINT_DISPLAY:10,PRINT_ALL_PAGES:11},At={mc(e){return `${"\x1B["}${e}i`},printScreen(){return `${"\x1B["}0i`},printLine(){return `${"\x1B["}1i`},printerOn(){return `${"\x1B["}5i`},printerOff(){return `${"\x1B["}4i`},printerForBytes(e){return `${"\x1B["}5;${e}i`},printDisplay(){return `${"\x1B["}10i`},printAllPages(){return `${"\x1B["}11i`},autoPrintOn(){return `${"\x1B["}?5i`},autoPrintOff(){return `${"\x1B["}?4i`},printCursorPosition(){return `${"\x1B["}?1i`}},wt={setAttrs(e,t,r,n,o){let i=o.length>0?`;${o.join(";")}`:"";return `${"\x1B["}${e};${t};${r};${n}${i}$r`},reverseAttrs(e,t,r,n,o){let i=o.length>0?`;${o.join(";")}`:"";return `${"\x1B["}${e};${t};${r};${n}${i}$t`},copy(e,t,r,n,o,i,s=1,l=1){return `${"\x1B["}${e};${t};${r};${n};${s};${o};${i};${l}$v`},fill(e,t,r,n,o){let i=typeof o=="string"?o.charCodeAt(0):o;return `${"\x1B["}${i};${e};${t};${r};${n}$x`},erase(e,t,r,n){return `${"\x1B["}${e};${t};${r};${n}$z`},selectiveErase(e,t,r,n){return `${"\x1B["}${e};${t};${r};${n}\${`},setProtection(e){return `${"\x1B["}${e?1:0}"q`},requestChecksum(e,t,r,n,o,i){return `${"\x1B["}${e};${t};${r};${n};${o};${i}*y`}};var lo={"dec-graphics":"0","us-ascii":"B",uk:"A",dutch:"4",finnish:"C",french:"R","french-canadian":"Q",german:"K",italian:"Y","norwegian-danish":"E",spanish:"Z",swedish:"H",swiss:"=","iso-latin":"/A"},co={0:"(",1:")",2:"*",3:"+"},It={j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",q:"\u2500",x:"\u2502",n:"\u253C",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",o:"\u23BA",p:"\u23BB",r:"\u23BC",s:"\u23BD","`":"\u25C6",a:"\u2592",f:"\xB0",g:"\xB1",h:"\u2424",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7",b:" ",c:"\f",d:"\r",e:`
|
|
2
|
+
`,i:"\v"},Mt={"\u25C6":"*","\u2592":" ","\xB0":"*","\xB1":"+","\u2424":`
|
|
3
|
+
`,"\u2518":"+","\u2510":"+","\u250C":"+","\u2514":"+","\u253C":"+","\u23BA":"-","\u23BB":"-","\u2500":"-","\u23BC":"-","\u23BD":"_","\u251C":"+","\u2524":"+","\u2534":"+","\u252C":"+","\u2502":"|","\u2264":"<","\u2265":">",\u03C0:"*","\u2260":"!","\xA3":"#","\xB7":"."},we={designate(e,t=0){let r=lo[e],n=co[t];return `${"\x1B"}${n}${r}`},invokeG0(){return ""},invokeG1(){return ""},invokeG2(){return `${"\x1B"}n`},invokeG3(){return `${"\x1B"}o`},invokeG1R(){return `${"\x1B"}~`},invokeG2R(){return `${"\x1B"}}`},invokeG3R(){return `${"\x1B"}|`},singleShiftG2(){return `${"\x1B"}N`},singleShiftG3(){return `${"\x1B"}O`},enterAcs(){return `${"\x1B"}(0`},exitAcs(){return `${"\x1B"}(B`},smacs(){return we.enterAcs()},rmacs(){return we.exitAcs()}},Pt={unicode:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",teeRight:"\u251C",teeLeft:"\u2524",teeUp:"\u2534",teeDown:"\u252C"},unicodeDouble:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",teeRight:"\u2560",teeLeft:"\u2563",teeUp:"\u2569",teeDown:"\u2566"},unicodeRounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",teeRight:"\u251C",teeLeft:"\u2524",teeUp:"\u2534",teeDown:"\u252C"},ascii:{topLeft:"+",topRight:"+",bottomLeft:"+",bottomRight:"+",horizontal:"-",vertical:"|",cross:"+",teeRight:"+",teeLeft:"+",teeUp:"+",teeDown:"+"},decGraphics:{topLeft:"l",topRight:"k",bottomLeft:"m",bottomRight:"j",horizontal:"q",vertical:"x",cross:"n",teeRight:"t",teeLeft:"u",teeUp:"v",teeDown:"w"}};var y={RESET:0,BOLD:1,DIM:2,ITALIC:3,UNDERLINE:4,BLINK:5,RAPID_BLINK:6,INVERSE:7,HIDDEN:8,STRIKETHROUGH:9,RESET_BOLD:22,RESET_DIM:22,RESET_ITALIC:23,RESET_UNDERLINE:24,RESET_BLINK:25,RESET_INVERSE:27,RESET_HIDDEN:28,RESET_STRIKETHROUGH:29,FG_BLACK:30,FG_RED:31,FG_GREEN:32,FG_YELLOW:33,FG_BLUE:34,FG_MAGENTA:35,FG_CYAN:36,FG_WHITE:37,FG_DEFAULT:39,FG_BRIGHT_BLACK:90,FG_BRIGHT_RED:91,FG_BRIGHT_GREEN:92,FG_BRIGHT_YELLOW:93,FG_BRIGHT_BLUE:94,FG_BRIGHT_MAGENTA:95,FG_BRIGHT_CYAN:96,FG_BRIGHT_WHITE:97,BG_BLACK:40,BG_RED:41,BG_GREEN:42,BG_YELLOW:43,BG_BLUE:44,BG_MAGENTA:45,BG_CYAN:46,BG_WHITE:47,BG_DEFAULT:49,BG_BRIGHT_BLACK:100,BG_BRIGHT_RED:101,BG_BRIGHT_GREEN:102,BG_BRIGHT_YELLOW:103,BG_BRIGHT_BLUE:104,BG_BRIGHT_MAGENTA:105,BG_BRIGHT_CYAN:106,BG_BRIGHT_WHITE:107,FG_256:38,BG_256:48},Ye={black:y.FG_BLACK,red:y.FG_RED,green:y.FG_GREEN,yellow:y.FG_YELLOW,blue:y.FG_BLUE,magenta:y.FG_MAGENTA,cyan:y.FG_CYAN,white:y.FG_WHITE,brightBlack:y.FG_BRIGHT_BLACK,brightRed:y.FG_BRIGHT_RED,brightGreen:y.FG_BRIGHT_GREEN,brightYellow:y.FG_BRIGHT_YELLOW,brightBlue:y.FG_BRIGHT_BLUE,brightMagenta:y.FG_BRIGHT_MAGENTA,brightCyan:y.FG_BRIGHT_CYAN,brightWhite:y.FG_BRIGHT_WHITE,default:y.FG_DEFAULT},qe={black:y.BG_BLACK,red:y.BG_RED,green:y.BG_GREEN,yellow:y.BG_YELLOW,blue:y.BG_BLUE,magenta:y.BG_MAGENTA,cyan:y.BG_CYAN,white:y.BG_WHITE,brightBlack:y.BG_BRIGHT_BLACK,brightRed:y.BG_BRIGHT_RED,brightGreen:y.BG_BRIGHT_GREEN,brightYellow:y.BG_BRIGHT_YELLOW,brightBlue:y.BG_BRIGHT_BLUE,brightMagenta:y.BG_BRIGHT_MAGENTA,brightCyan:y.BG_BRIGHT_CYAN,brightWhite:y.BG_BRIGHT_WHITE,default:y.BG_DEFAULT};function Ie(e){return typeof e=="object"&&"r"in e&&"g"in e&&"b"in e}function Me(e){return typeof e=="string"}function P(...e){return `${"\x1B["}${e.join(";")}m`}var A={move(e,t){return `${"\x1B["}${t};${e}H`},column(e){return `${"\x1B["}${e}G`},up(e=1){return `${"\x1B["}${e}A`},down(e=1){return `${"\x1B["}${e}B`},forward(e=1){return `${"\x1B["}${e}C`},back(e=1){return `${"\x1B["}${e}D`},nextLine(e=1){return `${"\x1B["}${e}E`},prevLine(e=1){return `${"\x1B["}${e}F`},save(){return `${"\x1B["}s`},restore(){return `${"\x1B["}u`},show(){return `${"\x1B["}?25h`},hide(){return `${"\x1B["}?25l`},requestPosition(){return `${"\x1B["}6n`},home(){return `${"\x1B["}H`},setShape(e){return `${"\x1B["}${e} q`},blinkingBlock(){return `${"\x1B["}1 q`},steadyBlock(){return `${"\x1B["}2 q`},blinkingUnderline(){return `${"\x1B["}3 q`},steadyUnderline(){return `${"\x1B["}4 q`},blinkingBar(){return `${"\x1B["}5 q`},steadyBar(){return `${"\x1B["}6 q`},resetShape(){return `${"\x1B["}0 q`},setColor(e){return `${"\x1B]"}12;${e}${"\x07"}`},resetColor(){return `${"\x1B]"}112${"\x07"}`},saveStyle(){return `${"\x1B"}[s`},restoreStyle(){return `${"\x1B"}[u`}},Ot={DEFAULT:0,BLINKING_BLOCK:1,STEADY_BLOCK:2,BLINKING_UNDERLINE:3,STEADY_UNDERLINE:4,BLINKING_BAR:5,STEADY_BAR:6};var V={begin(){return `${"\x1B["}?2026h`},end(){return `${"\x1B["}?2026l`},wrap(e){return `${"\x1B["}?2026h${e}${"\x1B["}?2026l`}},me={enable(){return `${"\x1B["}?2004h`},disable(){return `${"\x1B["}?2004l`},START_MARKER:`${"\x1B["}200~`,END_MARKER:`${"\x1B["}201~`},W={CLIPBOARD:"c",PRIMARY:"p",SECONDARY:"s",SELECT:"s",CUT0:"0",CUT1:"1",CUT2:"2",CUT3:"3",CUT4:"4",CUT5:"5",CUT6:"6",CUT7:"7"},Xe=1024*1024,J={write(e,t=W.CLIPBOARD,r=Xe){if(Buffer.byteLength(e,"utf8")>r)return "";let o=Buffer.from(e,"utf8").toString("base64");return `${"\x1B]"}52;${t};${o}${"\x1B\\"}`},requestRead(e=W.CLIPBOARD){return `${"\x1B]"}52;${e};?${"\x1B\\"}`},clear(e=W.CLIPBOARD){return `${"\x1B]"}52;${e};${"\x1B\\"}`},decodeResponse(e){let t=e.match(/\x1b\]52;([^;]+);([A-Za-z0-9+/=]*)\x1b\\/);if(!t)return null;let r=t[2];if(!r)return "";try{return Buffer.from(r,"base64").toString("utf8")}catch{return null}},isClipboardResponse(e){return e.startsWith("\x1B]52;")}},Pe={PT_START:`${"\x1BP"}tmux;`,wrap(e){let t=e.replace(/\x1b/g,"\x1B\x1B");return `${"\x1BP"}tmux;${t}${"\x1B\\"}`},unwrap(e){let t=e.match(/^\x1bPtmux;([\s\S]*)\x1b\\$/);return t?(t[1]??"").replace(/\x1b\x1b/g,"\x1B"):null},isWrapped(e){return e.startsWith(`${"\x1BP"}tmux;`)&&e.endsWith("\x1B\\")},wrapIf(e,t){return !t||Pe.isWrapped(e)?e:Pe.wrap(e)},begin(){return `${"\x1BP"}tmux;`},end(){return "\x1B\\"}};var R={X10:9,NORMAL:1e3,HIGHLIGHT:1001,BUTTON_EVENT:1002,ANY_EVENT:1003,FOCUS:1004,UTF8:1005,SGR:1006,URXVT:1015,SGR_PIXELS:1016},w={enableX10(){return `${"\x1B["}?${R.X10}h`},disableX10(){return `${"\x1B["}?${R.X10}l`},enableNormal(){return `${"\x1B["}?${R.NORMAL}h`},disableNormal(){return `${"\x1B["}?${R.NORMAL}l`},enableButtonEvent(){return `${"\x1B["}?${R.BUTTON_EVENT}h`},disableButtonEvent(){return `${"\x1B["}?${R.BUTTON_EVENT}l`},enableAnyEvent(){return `${"\x1B["}?${R.ANY_EVENT}h`},disableAnyEvent(){return `${"\x1B["}?${R.ANY_EVENT}l`},enableFocus(){return `${"\x1B["}?${R.FOCUS}h`},disableFocus(){return `${"\x1B["}?${R.FOCUS}l`},enableSGR(){return `${"\x1B["}?${R.SGR}h`},disableSGR(){return `${"\x1B["}?${R.SGR}l`},enableURXVT(){return `${"\x1B["}?${R.URXVT}h`},disableURXVT(){return `${"\x1B["}?${R.URXVT}l`},enableUTF8(){return `${"\x1B["}?${R.UTF8}h`},disableUTF8(){return `${"\x1B["}?${R.UTF8}l`},disableAll(){return [`${"\x1B["}?${R.X10}l`,`${"\x1B["}?${R.NORMAL}l`,`${"\x1B["}?${R.BUTTON_EVENT}l`,`${"\x1B["}?${R.ANY_EVENT}l`,`${"\x1B["}?${R.FOCUS}l`,`${"\x1B["}?${R.UTF8}l`,`${"\x1B["}?${R.SGR}l`,`${"\x1B["}?${R.URXVT}l`].join("")},enableRecommended(){return `${"\x1B["}?${R.SGR}h${"\x1B["}?${R.ANY_EVENT}h`}},Nt={NONE:0,BUTTON_DOWN:1,BUTTON_UP:2,BUTTON_DOWN_UP:3},Bt={NONE:0,RIGHT:1,MIDDLE:2,LEFT:3,M4:4},Lt={enable(e=2,t=2){return `${"\x1B["}${e};${t}'z`},disable(){return `${"\x1B["}0'z`},setFilterRectangle(e,t,r,n){return `${"\x1B["}${e};${t};${r};${n}'w`},clearFilterRectangle(){return `${"\x1B["}'w`},setEvents(e){return `${"\x1B["}${e.join(";")}'{`},requestPosition(e){return e===void 0?`${"\x1B["}'|`:`${"\x1B["}${e}'|`},enableKeyMode(){return `${"\x1B["}?99h`},disableKeyMode(){return `${"\x1B["}?99l`},enableExtended(){return `${"\x1B["}?1003h`},disableExtended(){return `${"\x1B["}?1003l`},enableHighlight(){return `${"\x1B["}?1001h`},disableHighlight(){return `${"\x1B["}?1001l`}};var z={reset(){return P(y.RESET)},bold(){return P(y.BOLD)},dim(){return P(y.DIM)},italic(){return P(y.ITALIC)},underline(){return P(y.UNDERLINE)},blink(){return P(y.BLINK)},inverse(){return P(y.INVERSE)},hidden(){return P(y.HIDDEN)},strikethrough(){return P(y.STRIKETHROUGH)},fg(e){return Me(e)?P(Ye[e]):Ie(e)?P(y.FG_256,2,e.r,e.g,e.b):P(y.FG_256,5,e)},bg(e){return Me(e)?P(qe[e]):Ie(e)?P(y.BG_256,2,e.r,e.g,e.b):P(y.BG_256,5,e)},combine(...e){return P(...e)}},I={clear(){return `${"\x1B["}2J`},clearDown(){return `${"\x1B["}J`},clearUp(){return `${"\x1B["}1J`},clearLine(){return `${"\x1B["}2K`},clearLineRight(){return `${"\x1B["}K`},clearLineLeft(){return `${"\x1B["}1K`},eraseChars(e=1){return `${"\x1B["}${e}X`},alternateOn(){return `${"\x1B["}?1049h`},enterAlt(){return `${"\x1B["}?1049h`},alternateOff(){return `${"\x1B["}?1049l`},exitAlt(){return `${"\x1B["}?1049l`},scrollUp(e=1){return `${"\x1B["}${e}S`},scrollDown(e=1){return `${"\x1B["}${e}T`},setScrollRegion(e,t){return `${"\x1B["}${e};${t}r`},resetScrollRegion(){return `${"\x1B["}r`}},kt={set(e){return `${"\x1B]"}2;${e}${"\x07"}`},setIcon(e){return `${"\x1B]"}1;${e}${"\x07"}`},setBoth(e){return `${"\x1B]"}0;${e}${"\x07"}`}};var Po=z$1.object({type:z$1.literal("paste"),text:z$1.string(),timestamp:z$1.number(),sanitized:z$1.boolean(),originalLength:z$1.number().int().nonnegative()}),Oo=z$1.object({sanitize:z$1.boolean().default(true),maxLength:z$1.number().int().nonnegative().default(1024*1024),enabled:z$1.boolean().default(true)}),_r={sanitize:true,maxLength:1024*1024,enabled:true},Y="\x1B[200~",ae="\x1B[201~";function Ze(e){return e.replace(/\x1b(?:\[[0-9;?]*[a-zA-Z~]|\][^\x07\x1b]*(?:\x07|\x1b\\)?|[^[\]])/g,"")}function je(e,t){return t<=0||e.length<=t?e:e.slice(0,t)}function Ar(e){return e.length<Y.length?false:new TextDecoder().decode(e.subarray(0,Y.length))===Y}function No(e){if(e.length===0)return false;if(e.length>=Y.length)return Ar(e);let t=new TextDecoder().decode(e);return Y.startsWith(t)}function Bo(e){return new TextDecoder().decode(e).indexOf(ae)}function Lo(e,t){let r={..._r,...t},n=new TextDecoder().decode(e);if(!n.startsWith(Y))return {pasteStarted:false,pasteEnded:false,text:null,consumed:0};let o=n.indexOf(ae);if(o===-1)return {pasteStarted:true,pasteEnded:false,text:null,consumed:0};let i=Y.length,s=n.slice(i,o);r.sanitize&&(s=Ze(s)),s=je(s,r.maxLength);let l=o+ae.length;return {pasteStarted:true,pasteEnded:true,text:s,consumed:l}}function ko(e){return {isPasting:false,buffer:"",config:{..._r,...e}}}function Do(e,t){let r=new TextDecoder().decode(t);if(!e.isPasting){if(!r.startsWith(Y))return {state:e,event:null,consumed:0,remaining:t};let u=Y.length,c=r.indexOf(ae,u);if(c===-1){let C=r.slice(u);return {state:{...e,isPasting:true,buffer:C},event:null,consumed:t.length,remaining:new Uint8Array(0)}}let d=r.slice(u,c),p=d.length;e.config.sanitize&&(d=Ze(d)),d=je(d,e.config.maxLength);let m=c+ae.length,S=new TextEncoder().encode(r.slice(m));return {state:{...e,isPasting:false,buffer:""},event:{type:"paste",text:d,timestamp:Date.now(),sanitized:e.config.sanitize,originalLength:p},consumed:m,remaining:S}}let n=r.indexOf(ae);if(n===-1)return {state:{...e,buffer:e.buffer+r},event:null,consumed:t.length,remaining:new Uint8Array(0)};let o=e.buffer+r.slice(0,n),i=o.length;e.config.sanitize&&(o=Ze(o)),o=je(o,e.config.maxLength);let s=n+ae.length,l=new TextEncoder().encode(r.slice(s));return {state:{...e,isPasting:false,buffer:""},event:{type:"paste",text:o,timestamp:Date.now(),sanitized:e.config.sanitize,originalLength:i},consumed:s,remaining:l}}function $o(){return me.enable()}function Fo(){return me.disable()}var E={PRIMARY_DA:"primary_da",SECONDARY_DA:"secondary_da",TERTIARY_DA:"tertiary_da",CURSOR_POSITION:"cursor_position",DEVICE_STATUS:"device_status",OPERATING_STATUS:"operating_status",WINDOW_TITLE:"window_title",ICON_LABEL:"icon_label",WINDOW_STATE:"window_state",WINDOW_POSITION:"window_position",WINDOW_SIZE_PIXELS:"window_size_pixels",TEXT_AREA_SIZE:"text_area_size",SCREEN_SIZE:"screen_size",CHAR_CELL_SIZE:"char_cell_size",LOCATOR_POSITION:"locator_position",UNKNOWN:"unknown"},Uo=z$1.object({type:z$1.literal(E.CURSOR_POSITION),raw:z$1.string(),row:z$1.number().int().positive(),column:z$1.number().int().positive()}),B="\x1B[",Go=/^\x1b\[\?([0-9;]+)c$/,Ko=/^\x1b\[>([0-9;]+)c$/,zo=/^\x1b\[(\d+);(\d+)R$/,Ho=/^\x1b\[(\d+)n$/,Wo=/^\x1b\[(\d+)(?:;(\d+))?(?:;(\d+))?t$/,Vo=/^\x1b\](\d+);([^\x07\x1b]*)(?:\x07|\x1b\\)$/,Yo=/^\x1b\[(\d+);(\d+);(\d+);(\d+);(\d+)&w$/;function Dt(e){let t=[qo,Xo,Zo,jo,Jo,Qo,ei];for(let r of t){let n=r(e);if(n)return n}return {type:E.UNKNOWN,raw:e}}function qo(e){let t=e.match(Go);if(!t?.[1])return null;let r=t[1].split(";").map(Number),n=r[0]??0,o=r.slice(1);return {type:E.PRIMARY_DA,raw:e,deviceClass:n,attributes:o}}function Xo(e){let t=e.match(Ko);if(!t?.[1])return null;let r=t[1].split(";").map(Number);return {type:E.SECONDARY_DA,raw:e,terminalType:r[0]??0,firmwareVersion:r[1]??0,romCartridge:r[2]??0}}function Zo(e){let t=e.match(zo);return !t?.[1]||!t[2]?null:{type:E.CURSOR_POSITION,raw:e,row:Number.parseInt(t[1],10),column:Number.parseInt(t[2],10)}}function jo(e){let t=e.match(Ho);if(!t?.[1])return null;let r=Number.parseInt(t[1],10);return {type:E.DEVICE_STATUS,raw:e,status:r,ok:r===0}}function Jo(e){let t=e.match(Wo);if(!t?.[1])return null;let r=Number.parseInt(t[1],10),n=t[2]?Number.parseInt(t[2],10):0,o=t[3]?Number.parseInt(t[3],10):0;switch(r){case 1:case 2:return {type:E.WINDOW_STATE,raw:e,state:r,iconified:r===2};case 3:return {type:E.WINDOW_POSITION,raw:e,x:n,y:o};case 4:return {type:E.WINDOW_SIZE_PIXELS,raw:e,height:n,width:o};case 8:return {type:E.TEXT_AREA_SIZE,raw:e,rows:n,columns:o};case 9:return {type:E.SCREEN_SIZE,raw:e,rows:n,columns:o};case 6:return {type:E.CHAR_CELL_SIZE,raw:e,height:n,width:o};default:return null}}function Qo(e){let t=e.match(Vo);if(!t?.[1])return null;let r=Number.parseInt(t[1],10),n=t[2]??"";return r===76||e.startsWith("\x1B]L;")?{type:E.WINDOW_TITLE,raw:e,title:n}:r===108||e.startsWith("\x1B]l;")?{type:E.ICON_LABEL,raw:e,label:n}:null}function ei(e){let t=e.match(Yo);return !t?.[1]||!t[2]||!t[3]||!t[4]||!t[5]?null:{type:E.LOCATOR_POSITION,raw:e,status:Number.parseInt(t[1],10),button:Number.parseInt(t[2],10),row:Number.parseInt(t[3],10),column:Number.parseInt(t[4],10),page:Number.parseInt(t[5],10)}}function $t(e){return e.type===E.PRIMARY_DA}function Ft(e){return e.type===E.SECONDARY_DA}function ti(e){return e.type===E.CURSOR_POSITION}function ri(e){return e.type===E.DEVICE_STATUS}function ni(e){return e.type===E.WINDOW_TITLE}function oi(e){return e.type===E.ICON_LABEL}function ii(e){return e.type===E.WINDOW_STATE}function si(e){return e.type===E.WINDOW_POSITION}function ai(e){return e.type===E.WINDOW_SIZE_PIXELS}function ui(e){return e.type===E.TEXT_AREA_SIZE}function li(e){return e.type===E.SCREEN_SIZE}function ci(e){return e.type===E.CHAR_CELL_SIZE}function pi(e){return e.type===E.LOCATOR_POSITION}function di(e){return e.type===E.UNKNOWN}var ge={primaryDA(){return `${B}c`},secondaryDA(){return `${B}>c`},tertiaryDA(){return `${B}=c`},cursorPosition(){return `${B}6n`},deviceStatus(){return `${B}5n`},windowState(){return `${B}11t`},windowPosition(){return `${B}13t`},windowSizePixels(){return `${B}14t`},textAreaSize(){return `${B}18t`},screenSize(){return `${B}19t`},charCellSize(){return `${B}16t`},windowTitle(){return `${B}21t`},iconLabel(){return `${B}20t`},enableLocator(e=1){return `${B}${e}'z`},locatorPosition(){return `${B}'|`}};var Ut=100,Le=10,ke=5e3,Ir="\x1B[",Ne={DISABLED:0,DISAMBIGUATE:1,REPORT_EVENTS:2,REPORT_ALTERNATES:4,REPORT_ALL:8,REPORT_TEXT:16},ye={NONE:"none",KITTY:"kitty",ITERM2:"iterm2",SIXEL:"sixel"},Be={EAGER:"eager",LAZY:"lazy",SKIP:"skip"},Mr=z$1.object({timeout:z$1.number().int().min(Le).max(ke).optional(),timing:z$1.enum(["eager","lazy","skip"]).optional(),forceCapabilities:z$1.record(z$1.string(),z$1.unknown()).optional()});function wr(){let e=process.env.COLORTERM;if(e==="truecolor"||e==="24bit")return true;let t=process.env.TERM??"";if(t.includes("truecolor")||t.includes("24bit")||t.includes("direct"))return true;let r=process.env.TERM_PROGRAM??"";if(["iTerm.app","Apple_Terminal","Hyper","vscode"].includes(r)||process.env.KITTY_WINDOW_ID!==void 0||t==="alacritty"||process.env.WT_SESSION!==void 0)return true;let o=process.env.VTE_VERSION;if(o!==void 0){let i=Number.parseInt(o,10);if(!Number.isNaN(i)&&i>=3600)return true}return false}function fi(){return process.env.KITTY_WINDOW_ID!==void 0||process.env.TERM_PROGRAM==="WezTerm"||process.env.TERM==="foot"||process.env.TERM==="foot-extra"?Ne.REPORT_ALL:false}function mi(){return process.env.KITTY_WINDOW_ID!==void 0?ye.KITTY:process.env.TERM_PROGRAM==="iTerm.app"?ye.ITERM2:(process.env.TERM??"").includes("sixel")?ye.SIXEL:false}function gi(){let e=process.env.TERM_PROGRAM??"";return !!(["iTerm.app","WezTerm","vscode","Hyper"].includes(e)||process.env.KITTY_WINDOW_ID!==void 0||process.env.WT_SESSION!==void 0)}function bi(){let e=process.env.TERM_PROGRAM??"";if(["iTerm.app","WezTerm","vscode","Hyper"].includes(e)||process.env.KITTY_WINDOW_ID!==void 0||process.env.WT_SESSION!==void 0)return true;let r=process.env.VTE_VERSION;if(r!==void 0){let n=Number.parseInt(r,10);if(!Number.isNaN(n)&&n>=5e3)return true}return false}function yi(){return {truecolor:wr(),kittyKeyboard:fi(),graphics:mi(),focusEvents:true,bracketedPaste:true,synchronizedOutput:gi(),hyperlinks:bi(),styledUnderlines:wr(),primaryDA:null,secondaryDA:null,terminalType:null,firmwareVersion:null}}function xi(){return `${Ir}>q`}function Ci(){return `${Ir}?u`}function Si(e){return e.attributes.includes(4)}function hi(e){return {terminalType:e.terminalType,firmwareVersion:e.firmwareVersion}}async function Ei(e,t,r,n){return new Promise(o=>{let i={buffer:"",timeout:setTimeout(()=>{l(),o(i.responses);},t),responses:[]},s=u=>{i.buffer+=u.toString(),Ri(i);},l=()=>{clearTimeout(i.timeout),r.removeListener("data",s);};r.on("data",s);for(let u of e)n.write(u);})}function Ri(e){let t=e.buffer,r=/\x1b\[[^a-zA-Z]*[a-zA-Z]/g,n;for(n=r.exec(t);n!==null;)e.responses.push(n[0]),n=r.exec(t);let o=/\x1bP[^\x1b]*\x1b\\/g;for(n=o.exec(t);n!==null;)e.responses.push(n[0]),n=o.exec(t);let i=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;for(n=i.exec(t);n!==null;)e.responses.push(n[0]),n=i.exec(t);}function Gt(e={}){let t=Math.max(Le,Math.min(ke,e.timeout??Ut)),r=e.timing??Be.EAGER,n=e.input??process.stdin,o=e.output??process.stdout,i=e.forceCapabilities,s=null,l=null,u=false;async function c(){let x=yi();if(i)return {...x,...i};if(r===Be.SKIP||!d())return x;let h=[ge.primaryDA(),ge.secondaryDA()],b=await p(h,t,n,o);return b?m(x,b):x}function d(){return !!(process.stdin.isTTY&&process.stdout.isTTY)}async function p(x,h,b,f){let g=b.isRaw;try{return !g&&b.setRawMode&&b.setRawMode(!0),await Ei(x,h,b,f)}catch{return null}finally{!g&&b.setRawMode&&b.setRawMode(false);}}function m(x,h){let{primaryDA:b,secondaryDA:f}=S(h),{terminalType:g,firmwareVersion:M}=f?hi(f):{terminalType:null,firmwareVersion:null},G=b&&Si(b)&&!x.graphics?ye.SIXEL:x.graphics;return {...x,primaryDA:b,secondaryDA:f,terminalType:g,firmwareVersion:M,graphics:G}}function S(x){let h=null,b=null;for(let f of x){let g=Dt(f);$t(g)?h=g:Ft(g)&&(b=g);}return {primaryDA:h,secondaryDA:b}}let C={async getCapabilities(){if(u)throw new Error("Negotiator has been destroyed");return s||(l||(l=c().then(x=>(s=x,x))),l)},getCachedCapabilities(){return s},async renegotiate(){if(u)throw new Error("Negotiator has been destroyed");return s=null,l=null,C.getCapabilities()},isNegotiated(){return s!==null},getTimeout(){return t},setTimeout(x){t=Math.max(Le,Math.min(ke,x));},destroy(){u=true,s=null,l=null;}};return r===Be.EAGER&&(l=c().then(x=>(s=x,x))),C}var xe=null;function Kt(){return xe||(xe=Gt()),xe}function Pr(){xe&&(xe.destroy(),xe=null);}async function zt(){return Kt().getCapabilities()}async function Or(e){let r=(await zt())[e];return typeof r=="boolean"?r:r!=null}var Nr={primaryDA:ge.primaryDA,secondaryDA:ge.secondaryDA,xtversion:xi,kittyKeyboard:Ci};var Je=null;function Br(e){try{e.write(I.alternateOff()),e.write(A.show()),e.write(z.reset()),e.write(`
|
|
4
|
+
`);}catch{}}function Ti(){let e=new Map,t=new Set,r=false,n=false;function o(C,x){if(n)return;n=true;let h=x!==void 0?{reason:C,error:x}:{reason:C};for(let b of t)try{b(h);}catch{}for(let b of e.values())try{Br(b.output),b.cleanup();}catch{}}let i=()=>{o("SIGINT"),process.exit(130);},s=()=>{o("SIGTERM"),process.exit(143);},l=()=>{o("SIGQUIT"),process.exit(131);},u=()=>{o("SIGHUP"),process.exit(129);},c=()=>{o("exit");},d=C=>{throw o("uncaughtException",C),C},p=C=>{let x=C instanceof Error?C:new Error(String(C));o("unhandledRejection",x);};function m(){r||(process.on("SIGINT",i),process.on("SIGTERM",s),process.on("SIGQUIT",l),process.on("SIGHUP",u),process.on("exit",c),process.on("uncaughtException",d),process.on("unhandledRejection",p),r=true);}function S(){r&&(process.off("SIGINT",i),process.off("SIGTERM",s),process.off("SIGQUIT",l),process.off("SIGHUP",u),process.off("exit",c),process.off("uncaughtException",d),process.off("unhandledRejection",p),r=false);}return {get instanceCount(){return e.size},get hasCleanedUp(){return n},register(C,x,h){e.set(C,{id:C,output:x,cleanup:h}),r||m();},unregister(C){e.delete(C),e.size===0&&S();},onExit(C){return t.add(C),()=>{t.delete(C);}},async runCleanup(C,x){if(n)return;n=true;let h=x!==void 0?{reason:C,error:x}:{reason:C};for(let b of t)try{await b(h);}catch{}for(let b of e.values())try{Br(b.output),await b.cleanup();}catch{}},runCleanupSync:o}}var Qe={get instance(){return Je||(Je=Ti()),Je},reset(){Je=null;}};function vi(e,t,r){Qe.instance.register(e,t,r);}function _i(e){Qe.instance.unregister(e);}function Ai(e){return Qe.instance.onExit(e)}var wi=z$1.object({chunkSize:z$1.number().int().positive(),maxSize:z$1.number().int().positive(),useOSC52:z$1.boolean()}),Ii={chunkSize:64*1024,maxSize:10*1024*1024,useOSC52:true};function Mi(e){let t={...Ii,...e},r=wi.parse(t),n="",o=false;function i(c,d){return c.length<=r.maxSize?null:{success:false,error:`Content too large (${c.length} bytes, max ${r.maxSize})`,bytesProcessed:0,elapsedMs:performance.now()-d}}function s(c){if(!r.useOSC52)return;let d=J.write(c,W.CLIPBOARD,r.maxSize);d&&process.stdout.write(d);}function l(c,d,p){return s(c),p?.({processed:c.length,total:c.length,percentage:100,complete:true}),{success:true,bytesProcessed:c.length,elapsedMs:performance.now()-d}}async function u(c,d,p){let m=0,S=c.length;for(;m<S&&!o;)m=Math.min(m+r.chunkSize,S),p?.({processed:m,total:S,percentage:Math.round(m/S*100),complete:m>=S}),await new Promise(x=>setTimeout(x,0));return o?{success:false,error:"Operation cancelled",bytesProcessed:m,elapsedMs:performance.now()-d}:(s(c),{success:true,bytesProcessed:S,elapsedMs:performance.now()-d})}return {async copy(c,d){let p=performance.now();o=false;let m=i(c,p);return m||(n=c,c.length<=r.chunkSize?l(c,p,d):u(c,p,d))},writeToTerminal(c){let d=performance.now();if(c.length>r.maxSize)return {success:false,error:`Content too large (${c.length} bytes, max ${r.maxSize})`,bytesProcessed:0,elapsedMs:performance.now()-d};n=c;let p=J.write(c,W.CLIPBOARD,r.maxSize);return p&&process.stdout.write(p),{success:true,bytesProcessed:c.length,elapsedMs:performance.now()-d}},requestRead(){let c=J.requestRead();process.stdout.write(c);},clear(){n="";let c=J.clear();process.stdout.write(c);},getBuffer(){return n},cancel(){o=true;}}}function Lr(e,t){if(e.length<=t)return [e];let r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}async function Pi(e,t,r=64*1024){let n=e.length,o=0,i=Lr(e,r);for(let s of i)o+=s.length,t(s,{processed:o,total:n,percentage:Math.round(o/n*100),complete:o>=n}),o<n&&await new Promise(l=>setTimeout(l,0));}var Oi=0;function Ni(){return `cursor_${++Oi}`}function Ht(e={}){return {x:e.x??0,y:e.y??0,visible:e.visible??true,shape:e.shape??"block",blink:e.blink??true,blinkRate:e.blinkRate??530,fgColor:e.fgColor,bgColor:e.bgColor,lastBlinkTime:0,blinkOn:true,id:e.id??Ni()}}function kr(e,t,r){return {...e,x:t,y:r}}function Dr(e,t,r){return {...e,x:e.x+t,y:e.y+r}}function $r(e,t){return {...e,visible:t}}function Fr(e,t){return {...e,shape:t}}function Ur(e,t,r){return {...e,blink:t,blinkRate:r??e.blinkRate,blinkOn:t?e.blinkOn:true}}function Gr(e,t,r){return {...e,fgColor:t,bgColor:r}}function Wt(e,t){if(!e.blink)return e;let r=e.blinkRate/2;return t-e.lastBlinkTime>=r?{...e,blinkOn:!e.blinkOn,lastBlinkTime:t}:e}function Kr(e,t){return {...e,blinkOn:true,lastBlinkTime:t}}function Vt(e){return e.visible?e.blink?e.blinkOn:true:false}var Yt="\u2588",tt="\u2581",rt="\u258F";function zr(e$1,t){let r=t??e(),n=r.char||" ",o,i;switch(e$1.fgColor!==void 0&&e$1.bgColor!==void 0?(o=e$1.fgColor,i=e$1.bgColor):(o=r.bg||c,i=r.fg||b),e$1.shape){case "block":return {cell:{char:n,fg:o,bg:i,attrs:r.attrs},fullCell:true};case "underline":return {cell:{char:tt,fg:e$1.fgColor??(r.fg||b),bg:r.bg,attrs:r.attrs},fullCell:false};case "bar":return {cell:{char:rt,fg:e$1.fgColor??(r.fg||b),bg:r.bg,attrs:r.attrs},fullCell:false}}}function Hr(e){let t=e.fgColor??b,r=e.bgColor??c;switch(e.shape){case "block":return {char:Yt,fg:t,bg:r,attrs:a$1.NONE};case "underline":return {char:tt,fg:t,bg:r,attrs:a$1.NONE};case "bar":return {char:rt,fg:t,bg:r,attrs:a$1.NONE}}}function Wr(e){let t=e??Ht(),r=new Map;return r.set(t.id,t),{cursors:r,primaryId:t.id}}function Vr(e){let t=e.cursors.get(e.primaryId);if(!t)throw new Error(`Primary cursor ${e.primaryId} not found`);return t}function Yr(e,t){let r=new Map(e.cursors);return r.set(t.id,t),{...e,cursors:r}}function qr(e,t){if(t===e.primaryId)throw new Error("Cannot remove primary cursor");let r=new Map(e.cursors);return r.delete(t),{...e,cursors:r}}function Xr(e,t){let r=new Map(e.cursors);return r.set(t.id,t),{...e,cursors:r}}function Zr(e){return Array.from(e.cursors.values()).filter(Vt)}function jr(e,t){let r=new Map;for(let[n,o]of e.cursors)r.set(n,Wt(o,t));return {...e,cursors:r}}function Jr(e,t,r){for(let n of e.cursors.values())if(n.x===t&&n.y===r&&n.visible)return n}var qt="\x1B[?25l",Xt="\x1B[?25h";function Qr(){return qt}function en(){return Xt}var _={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Ki="blecsd-debug.log",zi=10*1024*1024,Hi={[_.TRACE]:"TRACE",[_.DEBUG]:"DEBUG",[_.INFO]:"INFO",[_.WARN]:"WARN",[_.ERROR]:"ERROR",[_.SILENT]:"SILENT"};function Wi(){let e=process.env.DEBUG??"",t=process.env.BLECSD_DEBUG??"";if(t==="1"||t.toLowerCase()==="true")return true;let r=e.split(",").map(n=>n.trim());for(let n of r)if(n==="blecsd"||n==="blecsd:*"||n==="*"||n.startsWith("blecsd:"))return true;return false}function tn(e){let t=e??process.env.DEBUG??"";return t?t.split(",").map(r=>r.trim()).filter(r=>r.length>0):["*"]}function rn(e,t){return !!(t===e||t==="*"||t.endsWith("*")&&e.startsWith(t.slice(0,-1)))}function Vi(e,t){if(!t.startsWith("-"))return false;let r=t.slice(1);return rn(e,r)}function Yi(e,t){for(let r of t){if(Vi(e,r))return false;if(rn(e,r))return true}return false}var v={enabled:Wi(),logFile:Ki,level:_.DEBUG,timestamps:true,includeLevel:true,maxFileSize:zi,namespaceFilter:tn(),initialized:false};function nn(){return new Date().toISOString().replace("T"," ").replace("Z","")}function on(e){return e===void 0?"undefined":e===null?"null":typeof e=="string"?e:e instanceof Error?`${e.name}: ${e.message}
|
|
5
|
+
${e.stack??""}`:inspect(e,{depth:4,colors:false,maxArrayLength:100,maxStringLength:1e3})}function sn(e){let t=dirname(e);t&&t!=="."&&!existsSync(t)&&mkdirSync(t,{recursive:true});}function qi(e,t){try{let r=existsSync(e)?statSync(e):null;if(r&&r.size>t){let n=`${e}.old`;existsSync(n)&&unlinkSync(n),renameSync(e,n);}}catch{}}function k(e,t,r,...n){if(!v.enabled||e<v.level||!Yi(t,v.namespaceFilter))return;let o=[];v.timestamps&&o.push(`[${nn()}]`),v.includeLevel&&o.push(`[${Hi[e]}]`),o.push(`[${t}]`),o.push(r);for(let s of n)o.push(on(s));let i=`${o.join(" ")}
|
|
6
|
+
`;try{sn(v.logFile),qi(v.logFile,v.maxFileSize),appendFileSync(v.logFile,i,"utf8");}catch{}}function Xi(e){e.enabled!==void 0&&(v.enabled=e.enabled),e.logFile!==void 0&&(v.logFile=e.logFile),e.level!==void 0&&(v.level=e.level),e.timestamps!==void 0&&(v.timestamps=e.timestamps),e.includeLevel!==void 0&&(v.includeLevel=e.includeLevel),e.maxFileSize!==void 0&&(v.maxFileSize=e.maxFileSize),e.namespaceFilter!==void 0&&(v.namespaceFilter=tn(e.namespaceFilter)),v.initialized=true;}function Zi(){return v.enabled}function ji(){return v.logFile}function ue(e){let t=(r,...n)=>{k(_.DEBUG,e,r,...n);};return t.trace=(r,...n)=>{k(_.TRACE,e,r,...n);},t.debug=(r,...n)=>{k(_.DEBUG,e,r,...n);},t.info=(r,...n)=>{k(_.INFO,e,r,...n);},t.warn=(r,...n)=>{k(_.WARN,e,r,...n);},t.error=(r,...n)=>{k(_.ERROR,e,r,...n);},t.namespace=e,t}function Ji(e,t){if(!v.enabled)return;let r={},n=process.env.TERM,o=process.env.COLORTERM,i=process.env.TERM_PROGRAM;n!==void 0&&(r.TERM=n),o!==void 0&&(r.COLORTERM=o),i!==void 0&&(r.TERM_PROGRAM=i);let s={timestamp:nn(),...e,environment:r},l=t?`=== Terminal State Dump: ${t} ===`:"=== Terminal State Dump ===",u="=".repeat(l.length);k(_.DEBUG,"blecsd:dump",l),k(_.DEBUG,"blecsd:dump",on(s)),k(_.DEBUG,"blecsd:dump",u);}function Qi(e,t){if(!v.enabled)return;let r=Buffer.isBuffer(e)?e.toString("hex").match(/.{1,2}/g)?.join(" ")??"":Buffer.from(e,"utf8").toString("hex").match(/.{1,2}/g)?.join(" ")??"",n=/[\x00-\x1f\x7f-\x9f]/g,o=Buffer.isBuffer(e)?e.toString("utf8").replace(n,"."):e.replace(n,"."),i=t?`Raw dump: ${t}`:"Raw dump";k(_.TRACE,"blecsd:raw",i),k(_.TRACE,"blecsd:raw",` Length: ${e.length}`),k(_.TRACE,"blecsd:raw",` Hex: ${r}`),k(_.TRACE,"blecsd:raw",` Print: ${o}`);}function es(){try{sn(v.logFile),writeFileSync(v.logFile,"","utf8");}catch{}}var ts={input:ue("blecsd:input"),render:ue("blecsd:render"),mouse:ue("blecsd:mouse"),program:ue("blecsd:program"),detect:ue("blecsd:detect"),ecs:ue("blecsd:ecs")};var rs=z$1.union([z$1.literal(2),z$1.literal(16),z$1.literal(256),z$1.literal("truecolor")]);z$1.object({name:z$1.string(),version:z$1.string().optional(),colorSupport:rs,unicodeSupport:z$1.boolean(),mouseSupport:z$1.boolean(),bracketedPaste:z$1.boolean(),tmux:z$1.boolean(),screen:z$1.boolean(),vscode:z$1.boolean(),cols:z$1.number().int().positive(),rows:z$1.number().int().positive()});function T(e){return process.env[e]}function nt(){return process.stdout.isTTY===true}function ns(){return process.stdout.columns&&process.stdout.rows?{cols:process.stdout.columns,rows:process.stdout.rows}:{cols:80,rows:24}}function ot(){return T("TMUX")!==void 0}function it(){return (T("TERM")??"").startsWith("screen")||T("STY")!==void 0}function st(){return T("TERM_PROGRAM")==="vscode"}function at(){let e=T("TERM")??"",t=T("TERM_PROGRAM")??"";return e.includes("xterm")||t==="Apple_Terminal"}function ut(){return T("VTE_VERSION")!==void 0}function le(){return T("TERM_PROGRAM")==="iTerm.app"}function Ce(){return T("TERM")==="alacritty"}function Se(){return T("TERM")==="xterm-kitty"||T("KITTY_WINDOW_ID")!==void 0}function he(){return T("WT_SESSION")!==void 0}function an(){return T("TERM_PROGRAM")==="Hyper"}function os(){if(le())return "iTerm2";if(Se())return "Kitty";if(Ce())return "Alacritty";if(he())return "Windows Terminal";if(an())return "Hyper";if(st())return "VSCode";if(ut())return "VTE";if(ot())return "tmux";if(it())return "screen";if(at())return "xterm";let e=T("TERM");return e||"unknown"}function is(){if(T("NO_COLOR")!==void 0)return 2;let e=T("FORCE_COLOR");return e==="0"?2:e==="1"?16:e==="2"?256:e==="3"?"truecolor":null}function ss(){let e=T("COLORTERM");if(e==="truecolor"||e==="24bit"||le()||Se()||Ce()||he()||an())return true;let t=T("VTE_VERSION");return !!(t&&Number.parseInt(t,10)>=3600)}function as(){let e=T("TERM")??"";return e.includes("256color")||e.includes("256-color")?256:e.includes("color")||e.includes("ansi")?16:e.startsWith("xterm")||e.startsWith("screen")||e.startsWith("vt100")?256:null}function lt(){let e=is();if(e!==null)return e;if(ss())return "truecolor";let t=as();return t!==null?t:nt()?16:2}function us(){return lt()!==2}function ls(){return lt()==="truecolor"}function un(){let e=T("LANG")??"",t=T("LC_ALL")??"";if(e.includes("UTF-8")||e.includes("utf8")||t.includes("UTF-8")||t.includes("utf8")||le()||Se()||Ce()||he()||st())return true;let r=T("TERM")??"";return r.includes("utf")||r.includes("unicode")?true:nt()}function ln(){if(at()||ut()||le()||Se()||Ce()||he()||ot()||it())return true;let e=T("TERM")??"";return e.includes("xterm")||e.includes("256color")?true:nt()}function cn(){return at()||ut()||le()||Se()||Ce()||he()?true:nt()}function pn(){let e=T("VTE_VERSION");if(e){let r=Number.parseInt(e,10),n=Math.floor(r/1e4),o=Math.floor(r%1e4/100),i=r%100;return `${n}.${o}.${i}`}let t=T("TERM_PROGRAM_VERSION");if(t&&le())return t}function cs(){let e=ns();return {name:os(),version:pn(),colorSupport:lt(),unicodeSupport:un(),mouseSupport:ln(),bracketedPaste:cn(),tmux:ot(),screen:it(),vscode:st(),cols:e.cols,rows:e.rows}}var ct=null,De=new WeakMap;function dn(){return ct||(ct=l()),ct}function ps(){ct=null;}function ds(e){let r={inputHandler:e,enabled:false,focused:true,handler:n=>{fn(n,r);},unsubscribe:null};return De.set(e,r),r}function fn(e,t){if(!t.enabled||e.focused===t.focused)return;t.focused=e.focused;let r=dn();e.focused?r.emit("focus",void 0):r.emit("blur",void 0);}function fs(e){if(e.enabled)return;let t=w.enableFocus();process.stdout.write(t),e.unsubscribe=e.inputHandler.onFocus(e.handler),e.enabled=true;}function ms(e){if(!e.enabled)return;let t=w.disableFocus();process.stdout.write(t),e.unsubscribe&&(e.unsubscribe(),e.unsubscribe=null),e.enabled=false,De.delete(e.inputHandler);}function gs(e){return De.get(e)}function bs(e){return De.get(e)?.focused}function ys(e,t){let r=De.get(e);if(r){let n={focused:t};fn(n,r);}}var $e={MOVE:1,DRAG:2,DOWN:4,UP:8,SINGLE:16,DOUBLE:32,TRIPLE:64,MFLAG:128,HARD:256,ENTER:512,LEAVE:1024},ee={NONE:0,LEFT:4,MIDDLE:2,RIGHT:1,FOURTH:8,UP:16,DOWN:32},xs=z$1.object({socketPath:z$1.string().default("/dev/gpmctl"),eventMask:z$1.number().int().default(65535),defaultMask:z$1.number().int().default(0),minMod:z$1.number().int().default(0),maxMod:z$1.number().int().default(65535),pid:z$1.number().int().positive().default(0),vc:z$1.number().int().nonnegative().default(0)}),Cs={socketPath:"/dev/gpmctl",eventMask:65535,defaultMask:0,minMod:0,maxMod:65535,pid:0,vc:0},pt=20;function mn(e){if(e.length<pt)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return {buttons:e[0]??0,modifiers:e[1]??0,vc:t.getUint16(2,true),dx:t.getInt16(4,true),dy:t.getInt16(6,true),x:t.getInt16(8,true),y:t.getInt16(10,true),type:t.getInt16(12,true),clicks:t.getInt32(14,true)}}function gn(e){return e&ee.LEFT?"left":e&ee.MIDDLE?"middle":e&ee.RIGHT?"right":e&ee.UP?"wheelUp":e&ee.DOWN?"wheelDown":"unknown"}function bn(e,t){return t&(ee.UP|ee.DOWN)?"wheel":e&$e.DOWN?"press":e&$e.UP?"release":e&($e.MOVE|$e.DRAG)?"move":"press"}function yn(e){return {shift:!!(e&1),ctrl:!!(e&4),meta:!!(e&8)}}function xn(e){let t=gn(e.buttons),r=bn(e.type,e.buttons),n=yn(e.modifiers),o=Math.max(0,e.x-1),i=Math.max(0,e.y-1);return {x:o,y:i,button:t,action:r,ctrl:n.ctrl,meta:n.meta,shift:n.shift,protocol:"x10",raw:new Uint8Array(0)}}function Cn(e){let t=new ArrayBuffer(16),r=new DataView(t);return r.setUint16(0,e.eventMask,true),r.setUint16(2,e.defaultMask,true),r.setUint16(4,e.minMod,true),r.setUint16(6,e.maxMod,true),r.setInt32(8,e.pid||process.pid,true),r.setInt32(12,e.vc,true),new Uint8Array(t)}function Ss(){let e=process.env.GPM_TTY??"",t=/tty(\d+)/.exec(e);return t?.[1]?Number.parseInt(t[1],10):0}function dt(){if(process.platform!=="linux")return false;let e=process.env.TERM??"";return e==="linux"||e==="console"}function hs(e){let t={...Cs,...e},r=false,n=null,o=new Set,i=new Set;function s(d){for(let p of o)try{p(d);}catch{}}function l(d){for(let p of i)try{p(d);}catch{}}function u(d){let p=0;for(;p+pt<=d.length;){let m=new Uint8Array(d.buffer,d.byteOffset+p,pt),S=mn(m);if(S){let C=xn(S);s(C);}p+=pt;}}return {get state(){return {connected:r,available:dt(),config:t}},onMouse(d){return o.add(d),()=>{o.delete(d);}},onConnectionChange(d){return i.add(d),()=>{i.delete(d);}},connect(){if(r)return true;if(!dt())return false;try{n=a$2("net").createConnection(t.socketPath);let p=n;return p.on("connect",()=>{r=!0;let m=Cn(t);p.write(m),l(!0);}),p.on("data",m=>{u(m);}),p.on("error",()=>{r=!1,n=null,l(!1);}),p.on("close",()=>{r=!1,n=null,l(!1);}),!0}catch{return false}},disconnect(){n&&(n.destroy(),n=null),r=false,l(false);},isAvailable(){return dt()}}}function Es(e){switch(e){case 0:return "left";case 1:return "middle";case 2:return "right";default:return "unknown"}}function Rs(e){switch(e){case "mousedown":return "press";case "mouseup":return "release";case "mousemove":return "move";case "wheel":return "wheel"}}var Ee={OFF:0,NORMAL:1,BUTTON:2,ANY:3,SGR:4},q=new WeakMap,ft=null;function ce(){return ft||(ft=l()),ft}function Ts(){ft=null;}function vs(e,t$1,r={}){let n=s=>{t(s)||(c$1({name:s.name,sequence:s.sequence,ctrl:s.ctrl,meta:s.meta,shift:s.shift,raw:new Uint8Array(Buffer.from(s.sequence))}),ce().emit("key",s));},o=s=>{d({x:s.x,y:s.y,button:Es(s.button),action:Rs(s.action),ctrl:s.ctrl,meta:s.meta,shift:s.shift,protocol:"sgr",raw:new Uint8Array(0)}),ce().emit("mouse",s);},i={world:e,program:t$1,keysEnabled:false,mouseEnabled:false,mouseMode:r.mouseMode??Ee.NORMAL,keyHandler:n,mouseHandler:o};return q.set(e,i),r.keys&&Sn(i),r.mouse&&hn(i),i}function _s(e){return q.get(e)}function As(e){mt(e),Fe(e),q.delete(e.world);}function Sn(e){e.keysEnabled||(e.program.on("key",e.keyHandler),e.keysEnabled=true);}function jt(e){Sn(e),ce().emit("keysEnabled",void 0);}function mt(e){e.keysEnabled&&(e.program.off("key",e.keyHandler),e.keysEnabled=false,ce().emit("keysDisabled",void 0));}function ws(e){return e.keysEnabled}function hn(e,t){if(e.mouseEnabled)return;let r=t??e.mouseMode;e.mouseMode=r;let n=e.program.output;if(n&&typeof n.write=="function")switch(r){case Ee.NORMAL:n.write(w.enableNormal());break;case Ee.BUTTON:n.write(w.enableButtonEvent());break;case Ee.ANY:n.write(w.enableAnyEvent());break;case Ee.SGR:n.write(w.enableSGR());break}e.program.on("mouse",e.mouseHandler),e.mouseEnabled=true;}function gt(e,t){hn(e,t),ce().emit("mouseEnabled",e.mouseMode);}function Fe(e){if(!e.mouseEnabled)return;let t=e.program.output;t&&typeof t.write=="function"&&t.write(w.disableAll()),e.program.off("mouse",e.mouseHandler),e.mouseEnabled=false,ce().emit("mouseDisabled",void 0);}function Is(e){return e.mouseEnabled}function Ms(e){return e.mouseMode}function Ps(e,t){let r=e.mouseEnabled;r&&Fe(e),e.mouseMode=t,r&>(e,t);}function En(e,t){jt(e),gt(e,t);}function Rn(e){mt(e),Fe(e);}function Os(e){return e.keysEnabled||e.mouseEnabled}function Ns(e){let t=q.get(e);return t?(jt(t),true):false}function Bs(e){let t=q.get(e);return t?(mt(t),true):false}function Ls(e,t){let r=q.get(e);return r?(gt(r,t),true):false}function ks(e){let t=q.get(e);return t?(Fe(t),true):false}function Ds(e,t){let r=q.get(e);return r?(En(r,t),true):false}function $s(e){let t=q.get(e);return t?(Rn(t),true):false}var vn=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","up","down","left","right","home","end","pageup","pagedown","insert","delete","clear","return","enter","tab","backspace","escape","space","!","@","#","$","%","^","&","*","(",")","-","_","=","+","[","]","{","}","\\","|",";",":","'",'"',",",".","<",">","/","?","`","~","undefined"],Fs=z$1.object({sequence:z$1.string(),name:z$1.enum(vn),ctrl:z$1.boolean(),meta:z$1.boolean(),shift:z$1.boolean(),code:z$1.string().optional(),raw:z$1.instanceof(Uint8Array)}),Ue="\x1B",Tn=27,Us=/^(?:\x1b)([a-zA-Z0-9])$/,Gs=/(?:\x1b)([a-zA-Z0-9])/,Ks=new RegExp("^(?:\\x1b+)(O|N|\\[|\\[\\[)(?:"+["(\\d+)(?:;(\\d+))?([~^$])","(?:1;)?(\\d+)?([a-zA-Z])"].join("|")+")"),zs=new RegExp("(?:\\x1b+)(O|N|\\[|\\[\\[)(?:"+["(\\d+)(?:;(\\d+))?([~^$])","(?:1;)?(\\d+)?([a-zA-Z])"].join("|")+")"),Hs={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Ws=new Set(["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"]),Vs=new Set(["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"]),Ys={"\r":{name:"return"},"\n":{name:"enter"}," ":{name:"tab"},"\b":{name:"backspace"},"\x7F":{name:"backspace"},"\x1B\x7F":{name:"backspace",meta:true},"\x1B\b":{name:"backspace",meta:true},[Ue]:{name:"escape"},[Ue+Ue]:{name:"escape",meta:true}," ":{name:"space"},[`${Ue} `]:{name:"space",meta:true}};function X(e,t,r,n={},o){let i={sequence:e,name:t,ctrl:n.ctrl??false,meta:n.meta??false,shift:n.shift??false,raw:r};return o!==void 0?{...i,code:o}:i}function qs(e){let t=e-1;return {shift:!!(t&1),meta:!!(t>>1&1)||!!(t>>3&1),ctrl:!!(t>>2&1)}}function Xs(e,t){let r=Ys[e];return r?X(e,r.name,t,{meta:r.meta??false}):null}function Zs(e,t){if(e.length!==1||e>"")return null;let r=e.charCodeAt(0),n=String.fromCharCode(r+97-1);return X(e,n,t,{ctrl:true})}function js(e,t){return e.length!==1||e<"a"||e>"z"?null:X(e,e,t)}function Js(e,t){return e.length!==1||e<"A"||e>"Z"?null:X(e,e.toLowerCase(),t,{shift:true})}function Qs(e,t){return e.length!==1||e<"0"||e>"9"?null:X(e,e,t)}function ea(e,t){if(e.length!==1)return null;let r=e.charCodeAt(0);return r<33||r>126||!vn.includes(e)?null:X(e,e,t)}function ta(e,t){let r=Xs(e,t);if(r)return r;let n=Zs(e,t);if(n)return n;let o=js(e,t);if(o)return o;let i=Js(e,t);if(i)return i;let s=Qs(e,t);return s||ea(e,t)}function ra(e,t){let r=Us.exec(e);if(r?.[1]){let m=r[1],S=m.toLowerCase(),C=/^[A-Z]$/.test(m);return X(e,S,t,{meta:true,shift:C})}let n=Ks.exec(e);if(!n)return null;let o=n[1]||"",i=n[2]||"",s=n[4]||"",l=n[6]||"",u=o+i+s+l,c=Number(n[3]||n[5]||1),d=qs(c);Ws.has(u)&&(d.shift=true),Vs.has(u)&&(d.ctrl=true);let p=Hs[u];return p?X(e,p,t,d,u):X(e,"undefined",t,d,u)}function Ge(e){if(e.length<3)return false;if(e[0]===Tn&&e[1]===91&&e[2]===77||e[0]===Tn&&e[1]===91&&e[2]===60)return true;let t=new TextDecoder().decode(e),r=/\x1b\[M/,n=/\x1b\[(\d+;\d+;\d+)M/,o=/\x1b\[<(\d+;\d+;\d+)([mM])/,i=/\x1b\[(O|I)/;return r.test(t)||n.test(t)||o.test(t)||i.test(t)}function bt(e){if(e.length===0||Ge(e))return null;let t=e,r,n=e[0];if(n!==void 0&&n>127&&e.length===1){let i=new Uint8Array([n-128]);r=`${Ue}${new TextDecoder().decode(i)}`;}else r=new TextDecoder().decode(e);let o=ta(r,t);return o||ra(r,t)}function Jt(e){if(e.length===0)return [];if(Ge(e))return [];let t=[],r=new TextDecoder().decode(e),n=new RegExp([zs.source,Gs.source,"\\x1b."].join("|"),"g"),o=[],i=0;for(;;){let s=n.exec(r);if(s===null)break;if(s.index>i){let l=r.slice(i,s.index);o.push(...l.split(""));}o.push(s[0]),i=s.index+s[0].length;}i<r.length&&o.push(...r.slice(i).split(""));for(let s of o){let l=new TextEncoder().encode(s),u=bt(l);u&&t.push(u);}return t}var na=["left","middle","right","wheelUp","wheelDown","unknown"],oa=["press","release","move","wheel"],ia=["x10","sgr","urxvt","dec","vt300"],sa=z$1.object({x:z$1.number().int().nonnegative(),y:z$1.number().int().nonnegative(),button:z$1.enum(na),action:z$1.enum(oa),ctrl:z$1.boolean(),meta:z$1.boolean(),shift:z$1.boolean(),protocol:z$1.enum(ia),raw:z$1.instanceof(Uint8Array)}),aa=27,ua=/^\x1b\[M([\x00\u0020-\uffff]{3})/,la=/^\x1b\[<(\d+);(\d+);(\d+)([mM])/,ca=/^\x1b\[(\d+);(\d+);(\d+)M/,pa=/^\x1b\[<(\d+);(\d+);(\d+);(\d+)&w/,da=/^\x1b\[24([0135])~\[(\d+),(\d+)\]\r/,fa=/^\x1b\[(O|I)/;function Qt(e){let t=e>>2;return {shift:!!(t&1),meta:!!(t>>1&1),ctrl:!!(t>>2&1)}}function Re(e,t){if(t)return e&1?"wheelDown":"wheelUp";let r=e&3;return r===0?"left":r===1?"middle":r===2?"right":"unknown"}function er(e){return !!(e>>6&1)}function tr(e){return e===35||e===39||e===51||e===43}function $(e,t,r,n,o,i,s){return {x:e,y:t,button:r,action:n,ctrl:o.ctrl,meta:o.meta,shift:o.shift,protocol:i,raw:s}}function ma(e,t){let r=ua.exec(e);if(!r?.[1])return null;let n=r[1];if(n.length<3)return null;let o=n.charCodeAt(0),i=n.charCodeAt(1),s=n.charCodeAt(2);i=i-32,s=s-32,i===-32&&(i=255),s===-32&&(s=255),i=Math.max(0,i-1),s=Math.max(0,s-1);let l=Qt(o);if(o-=32,er(o)){let c=Re(o,true);return $(i,s,c,"wheel",l,"x10",t)}if(o===3)return $(i,s,"unknown","release",l,"x10",t);if(tr(o))return $(i,s,"unknown","move",l,"x10",t);let u=Re(o,false);return $(i,s,u,"press",l,"x10",t)}function ga(e,t){let r=la.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),i=Number(r[3]),s=r[4]==="M";o=Math.max(0,o-1),i=Math.max(0,i-1);let l=Qt(n);if(er(n)){let d=Re(n,true);return $(o,i,d,"wheel",l,"sgr",t)}if(tr(n))return $(o,i,"unknown","move",l,"sgr",t);let u=Re(n,false);return $(o,i,u,s?"press":"release",l,"sgr",t)}function ba(e,t){let r=ca.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),i=Number(r[3]);o=Math.max(0,o-1),i=Math.max(0,i-1);let s=Qt(n);if((n===128||n===129)&&(n=67),n-=32,er(n)){let u=Re(n,true);return $(o,i,u,"wheel",s,"urxvt",t)}if(n===3)return $(o,i,"unknown","release",s,"urxvt",t);if(tr(n))return $(o,i,"unknown","move",s,"urxvt",t);let l=Re(n,false);return $(o,i,l,"press",s,"urxvt",t)}function ya(e,t){let r=pa.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),i=Number(r[3]);o=Math.max(0,o-1),i=Math.max(0,i-1);let s=n===3?"release":"press",l;return n===2?l="left":n===4?l="middle":n===6?l="right":l="unknown",$(o,i,l,s,{shift:false,meta:false,ctrl:false},"dec",t)}function xa(e,t){let r=da.exec(e);if(!r)return null;let n=Number(r[1]),o=Number(r[2]),i=Number(r[3]);o=Math.max(0,o-1),i=Math.max(0,i-1);let s;return n===1?s="left":n===2||n===3?s="middle":n===5?s="right":s="unknown",$(o,i,s,"press",{shift:false,meta:false,ctrl:false},"vt300",t)}var Ca=z$1.object({focused:z$1.boolean(),raw:z$1.instanceof(Uint8Array)});function Sa(e,t){let r=fa.exec(e);return r?.[1]?{focused:r[1]==="I",raw:t}:null}function yt(e){if(e.length<3||e[0]!==aa||e[1]!==91)return null;let t=new TextDecoder().decode(e),r=Sa(t,e);if(r)return {type:"focus",event:r};let n=ga(t,e);if(n)return {type:"mouse",event:n};let o=ma(t,e);if(o)return {type:"mouse",event:o};let i=ba(t,e);if(i)return {type:"mouse",event:i};let s=ya(t,e);if(s)return {type:"mouse",event:s};let l=xa(t,e);return l?{type:"mouse",event:l}:null}function ha(e){return yt(e)!==null}var Ea=z$1.object({maxBufferSize:z$1.number().int().positive().optional(),escapeTimeout:z$1.number().int().positive().optional()}),Ra={maxBufferSize:4096,escapeTimeout:100};function _n(e){return e>=65&&e<=90||e>=97&&e<=122}function Ta(e){return e>=48&&e<=57}function va(e,t){for(let r=t;r<e.length;r++){let n=e[r]??0;if(n===77||n===109)return true}return false}function _a(e,t){for(let r=t;r<e.length;r++){let n=e[r]??0;if(n===126||_n(n))return true}return false}function Aa(e){let t=e[2]??0;return _n(t)?false:t===60?!va(e,3):Ta(t)?!_a(e,3):false}function wa(e){return e.length===0?false:e[e.length-1]===27?true:e[0]!==27?false:e.length===1||e.length===2&&e[1]===91?true:e.length>=3&&e[1]===91?Aa(e):false}function Ia(e,t){if(!t)return 0;let r=new TextDecoder().decode(e),n=/^\x1b\[<\d+;\d+;\d+[mM]/.exec(r);if(n)return n[0].length;if(e.length>=6&&e[0]===27&&e[1]===91&&e[2]===77)return 6;if(e.length>=3&&e[0]===27&&e[1]===91&&(e[2]===73||e[2]===79))return 3;let o=/^\x1b\[\d+;\d+;\d+M/.exec(r);return o?o[0].length:t.event.raw.length}function Ma(e,t={}){let r={...Ra,...t},n=new Uint8Array(0),o=new Set,i=new Set,s=new Set,l=null,u=false,c=null;function d(f){for(let g of o)try{g(f);}catch{}}function p(f){for(let g of i)try{g(f);}catch{}}function m(f){for(let g of s)try{g(f);}catch{}}function S(f){let g=yt(f);if(!g)return null;let M=Ia(f,g);return g.type==="mouse"?p(g.event):g.type==="focus"&&m(g.event),{consumed:M}}function C(f){if(Ge(f))return null;let g=bt(f);if(g)return d(g),{consumed:g.raw.length};let M=Jt(f);if(M.length>0){for(let F of M)d(F);let G=0;for(let F of M)G+=F.raw.length;return {consumed:Math.max(G,1)}}return f.length>0?{consumed:1}:null}function x(f){let g=0;for(;g<f.length;){let M=f.slice(g);if(M[0]===27&&M.length>=3){let F=S(M);if(F){g+=F.consumed;continue}}let G=C(M);if(G){g+=G.consumed;continue}g++;}}function h(){if(n.length===0)return;let f=n;n=new Uint8Array(0),x(f);}function b(f){let g=new Uint8Array(n.length+f.length);if(g.set(n),g.set(new Uint8Array(f),n.length),n=g,n.length>=r.maxBufferSize){h();return}if(l&&(clearTimeout(l),l=null),wa(n)){l=setTimeout(()=>{l=null,h();},r.escapeTimeout);return}h();}return {start(){u||(u=true,c=f=>b(f),e.on("data",c));},stop(){u&&(u=false,c&&(e.removeListener("data",c),c=null),l&&(clearTimeout(l),l=null),h(),n=new Uint8Array(0));},onKey(f){return o.add(f),()=>{o.delete(f);}},onMouse(f){return i.add(f),()=>{i.delete(f);}},onFocus(f){return s.add(f),()=>{s.delete(f);}},isRunning(){return u},getBufferSize(){return n.length}}}var xt={NONE:0,DISAMBIGUATE:1,REPORT_EVENTS:2,REPORT_ALTERNATE:4,REPORT_ALL:8,REPORT_TEXT:16},Pa={flags:xt.DISAMBIGUATE|xt.REPORT_EVENTS,escTimeout:50},Oa={shift:false,alt:false,ctrl:false,super:false,hyper:false,meta:false,capsLock:false,numLock:false};function An(e){return `\x1B[>${e}u`}function wn(){return "\x1B[<u"}function In(){return "\x1B[?u"}function nr(e){return e.length<4||e[0]!==27||e[1]!==91||e[2]!==63?false:e[e.length-1]===117}function Mn(e){if(!nr(e))return;let t="";for(let r=3;r<e.length-1;r++){let n=e[r]??0;if(n>=48&&n<=57)t+=String.fromCharCode(n);else return}return t.length>0?Number.parseInt(t,10):0}function or(e){if(e.length<3||e[0]!==27||e[1]!==91)return false;let t=e[e.length-1];if(t!==117&&t!==126)return false;for(let r=2;r<e.length-1;r++){let n=e[r]??0;if(n>=48&&n<=57)return true}return false}function Na(e){let t="";for(let r=2;r<e.length-1;r++)t+=String.fromCharCode(e[r]??0);return t}function Ba(e){let t=e.split(":"),r=Number.parseInt(t[0]??"0",10),n=t[1]?Number.parseInt(t[1],10):void 0,o=t[2]?Number.parseInt(t[2],10):void 0;return {keyCode:r,shiftedKey:n,baseKey:o}}function La(e){let t=e.split(":"),r=t[0]?Number.parseInt(t[0],10)-1:0,n=t[1]?Number.parseInt(t[1],10):1,o=Da(Math.max(0,r)),i=$a(n);return {modifiers:o,eventType:i}}function ka(e){if(!e)return "";let t="",r=e.split(":");for(let n of r){let o=Number.parseInt(n,10);!Number.isNaN(o)&&o>0&&(t+=String.fromCodePoint(o));}return t}function Pn(e){if(!or(e))return;let t=Na(e),r=t,n=t.split(";"),{keyCode:o,shiftedKey:i,baseKey:s}=Ba(n[0]??""),{modifiers:l,eventType:u}=La(n[1]??""),c=ka(n[2]);return {keyCode:o,shiftedKey:i,baseKey:s,eventType:u,isRepeat:u==="repeat",isRelease:u==="release",text:c,modifiers:l,rawParams:r}}function On(e){return {...Pa,...e}}function Nn(){return {active:false,pushedFlags:0,detectedLevel:void 0}}function Bn(e,t){return {...e,detectedLevel:t}}function Ln(e,t){return {...e,active:true,pushedFlags:t}}function kn(e){return {...e,active:false,pushedFlags:0}}function Dn(e){let t=e.keyCode,r={27:"escape",13:"return",9:"tab",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57364:"f13",57365:"f14",57366:"f15",57367:"f16",57368:"f17",57369:"f18",57370:"f19",57371:"f20",57372:"f21",57373:"f22",57374:"f23",57375:"f24",57376:"f25",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpminus",57413:"kpplus",57414:"kpenter",57415:"kpequal",57441:"lshift",57442:"lctrl",57443:"lalt",57444:"lsuper",57445:"lhyper",57446:"lmeta",57447:"rshift",57448:"rctrl",57449:"ralt",57450:"rsuper",57451:"rhyper",57452:"rmeta"};if(r[t])return r[t];let n={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"};return n[t]?n[t]:t===57352?"up":t===57353?"down":t===57354?"right":t===57355?"left":t>=32&&t<=126?String.fromCharCode(t):t>0?String.fromCodePoint(t):"unknown"}function $n(e){return e.kittyKeyboard!==false}function Da(e){return e===0?Oa:{shift:(e&1)!==0,alt:(e&2)!==0,ctrl:(e&4)!==0,super:(e&8)!==0,hyper:(e&16)!==0,meta:(e&32)!==0,capsLock:(e&64)!==0,numLock:(e&128)!==0}}function $a(e){return e===2?"repeat":e===3?"release":"press"}var Wa=10*1024*1024;function Ct(e){let t=e.output??process.stdout,r=e.input??process.stdin,n=e.isAlternateBuffer??false,o=e.isMouseEnabled??false,i={wasAlternateBuffer:n,wasMouseEnabled:o,wasRawMode:r.isRaw??false},s="";return n&&(s+=I.alternateOff()),s+=A.show(),o&&(s+=w.disableAll()),s+=z.reset(),s&&t.write(s),r.setRawMode&&i.wasRawMode&&r.setRawMode(false),i}function Te(e,t){let r=t.output??process.stdout,n=t.input??process.stdin;n.setRawMode&&e.wasRawMode&&n.setRawMode(true);let o="";e.wasAlternateBuffer&&(o+=I.alternateOn()),e.wasMouseEnabled&&(o+=w.enableNormal()),o&&r.write(o);}function Va(e,t=[],r={}){let n=Ct(r),{output:o,input:i,isAlternateBuffer:s,isMouseEnabled:l,onExit:u,...c}=r,d=spawn(e,t,{stdio:"inherit",...c});return d.on("exit",(p,m)=>{Te(n,{output:o,input:i}),u?.(p,m);}),d}function Ya(e,t=[],r={}){return new Promise((n,o)=>{let i=r.maxBuffer??Wa,s=r.encoding??"utf8",l=Ct(r),{output:u,input:c,isAlternateBuffer:d,isMouseEnabled:p,onExit:m,timeout:S,maxBuffer:C,encoding:x,...h}=r,b="",f="",g=0,M=0,G=false,F=spawn(e,t,{...h,stdio:["inherit","pipe","pipe"]}),ve;S&&(ve=setTimeout(()=>{G=true,F.kill("SIGTERM");},S)),F.stdout?.on("data",K=>{let pe=K.toString(s);g+=K.length,g<=i&&(b+=pe);}),F.stderr?.on("data",K=>{let pe=K.toString(s);M+=K.length,M<=i&&(f+=pe);}),F.on("close",(K,pe)=>{if(ve&&clearTimeout(ve),Te(l,{output:u,input:c}),m?.(K,pe),G){o(new Error(`Process timed out after ${S}ms`));return}if(g>i||M>i){o(new Error(`Output exceeded maxBuffer of ${i} bytes`));return}n({stdout:b,stderr:f,exitCode:K,signal:pe});}),F.on("error",K=>{ve&&clearTimeout(ve),Te(l,{output:u,input:c}),o(K);});})}function qa(e,t=[],r={}){let n=Ct(r);try{let o=spawnSync(e,t,{encoding:"utf8",stdio:["inherit","pipe","pipe"]});return {stdout:o.stdout??"",stderr:o.stderr??"",exitCode:o.status,signal:o.signal}}finally{let{output:o,input:i}=r;Te(n,{output:o,input:i});}}function Un(){return process.env.EDITOR||process.env.VISUAL||"vi"}function Xa(e=".txt"){let t=Date.now(),r=Math.random().toString(36).substring(2,8),n=`blecsd-edit-${t}-${r}${e}`;return join(tmpdir(),n)}function ir(e){try{unlinkSync(e);}catch{}}function Za(e,t){try{return existsSync(e)?{content:readFileSync(e,"utf8")}:{content:t}}catch(r){return {content:t,error:r}}}function ja(e={}){return new Promise((t,r)=>{let n=e.editor??Un(),o=e.extension??".txt",i=e.content??"",s=Xa(o);try{writeFileSync(s,i,"utf8");}catch(m){r(new Error(`Failed to create temp file: ${m}`));return}let l=n.split(/\s+/),u=l[0]??n,c=[...l.slice(1),s],d=Ct(e),p=spawn(u,c,{stdio:"inherit"});p.on("exit",(m,S)=>{if(Te(d,{output:e.output,input:e.input}),S){ir(s),r(new Error(`Editor was killed by signal: ${S}`));return}let{content:C,error:x}=Za(s,i);if(ir(s),x){r(new Error(`Failed to read edited content: ${x}`));return}t(C);}),p.on("error",m=>{Te(d,{output:e.output,input:e.input}),ir(s),r(new Error(`Failed to start editor '${u}': ${m}`));});})}var Ja={commandExists(e){try{return spawnSync(process.platform==="win32"?"where":"which",[e],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).status===0}catch{return false}},getShell(){return process.platform==="win32"?{shell:process.env.COMSPEC||"cmd.exe",args:["/c"]}:{shell:process.env.SHELL||"/bin/sh",args:["-c"]}},shellEscape(e){return process.platform==="win32"?`"${e.replace(/"/g,'""')}"`:`'${e.replace(/'/g,"'\\''")}'`}};function Qa(e,t,r){switch(e){case `
|
|
7
|
+
`:return {cx:1,cy:r+1};case "\r":return {cx:1,cy:r};case " ":return {cx:Math.floor((t-1)/8)*8+9,cy:r};case "\b":return {cx:Math.max(1,t-1),cy:r};default:return e>=" "&&e!=="\x7F"?{cx:t+1,cy:r}:{cx:t,cy:r}}}function eu(e,t,r){return e>="0"&&e<="9"?{done:false,currentParam:t+e}:e===";"?(r.push(t?Number.parseInt(t,10):0),{done:false,currentParam:""}):e==="?"?{done:false,currentParam:t}:e>="@"&&e<="~"?(t&&r.push(Number.parseInt(t,10)),{done:true,result:e,currentParam:t}):{done:true,currentParam:t}}function tu(e,t){let r=t+2,n=[],o="";for(;r<e.length;){let i=e[r]??"",s=eu(i,o,n);if(s.done)return s.result?{command:s.result,params:n,endIndex:r+1}:null;o=s.currentParam,r++;}return null}function ru(e,t,r,n){let o=t[0]??1;switch(e){case "A":return {cx:r,cy:Math.max(1,n-o)};case "B":return {cx:r,cy:n+o};case "C":return {cx:r+o,cy:n};case "D":return {cx:Math.max(1,r-o),cy:n};case "E":return {cx:1,cy:n+o};case "F":return {cx:1,cy:Math.max(1,n-o)};case "G":return {cx:o,cy:n};case "H":case "f":return {cx:t[1]??1,cy:t[0]??1};default:return {cx:r,cy:n}}}function nu(e,t,r){let n=t,o=r,i=0;for(;i<e.length;){let s=e[i]??"";if(s==="\x1B"&&e[i+1]==="["){let u=tu(e,i);if(u){let c=ru(u.command,u.params,n,o);n=c.cx,o=c.cy,i=u.endIndex;continue}}let l=Qa(s,n,o);n=l.cx,o=l.cy,i++;}return {cx:n,cy:o}}function Gn(e={}){let t=[],r=1,n=1,o=e.trackCursor??true,i=e.autoFlush??false,s=null,l=null;function u(){s&&(clearImmediate(s),s=null);}function c(){if(s||!l)return;let p=l;s=setImmediate(()=>{s=null,p&&d.flush(p);});}let d={get cursorX(){return r},get cursorY(){return n},get cursorPosition(){return {x:r,y:n}},get length(){return t.reduce((p,m)=>p+m.length,0)},get chunkCount(){return t.length},get isEmpty(){return t.length===0},write(p){if(p.length!==0){if(t.push(p),o){let m=nu(p,r,n);r=m.cx,n=m.cy;}i&&l&&!s&&c();}},writeln(p){d.write(p),d.write(`
|
|
8
|
+
`);},writeAt(p,m,S){d.write(A.move(p,m)),d.write(S);},flush(p){if(u(),t.length===0)return;let m=t.join("");p.write(m),t=[];},setAutoFlushTarget(p){l=p,p||u();},clear(){u(),t=[];},getContents(){return t.join("")},resetCursor(p=1,m=1){r=p,n=m;}};return d}function Kn(e){let t=false,r=new Set,n=false;function o(u){e.write(u);}function i(){for(let u of r)try{u();}catch{}t&&(o(I.exitAlt()),t=false);}function s(){n||(process.on("SIGINT",i),process.on("SIGTERM",i),process.on("exit",i),process.on("uncaughtException",u=>{throw i(),u}),process.on("unhandledRejection",u=>{throw i(),u}),n=true);}function l(){n&&(process.off("SIGINT",i),process.off("SIGTERM",i),process.off("exit",i),n=false);}return {get isAlternate(){return t},enterAlternateScreen(){t||(o(I.enterAlt()),t=true,s());},exitAlternateScreen(){t&&(o(I.exitAlt()),t=false);},onCleanup(u){return r.add(u),()=>{r.delete(u);}},cleanup(){i();},destroy(){i(),l(),r.clear();}}}var zn=z$1.object({input:z$1.custom().optional(),output:z$1.custom().optional(),useAlternateScreen:z$1.boolean().default(true),hideCursor:z$1.boolean().default(true),title:z$1.string().optional(),forceWidth:z$1.number().int().positive().optional(),forceHeight:z$1.number().int().positive().optional()});function iu(){let e=new EventEmitter;return {on(t,r){e.on(t,r);},off(t,r){e.off(t,r);},once(t,r){e.once(t,r);},emit(t,...r){return e.emit(t,...r)},removeAllListeners(t){e.removeAllListeners(t);}}}function Ke(e){return "isTTY"in e&&e.isTTY===true}function su(e={}){let t=zn.parse(e),r=t.input??process.stdin,n=t.output??process.stdout,o=Gn({trackCursor:true}),i=Kn(n),s=iu(),l=80,u=24,c=false,d=false,p=false;function m(){if(t.forceWidth&&t.forceHeight){l=t.forceWidth,u=t.forceHeight;return}let f=n;Ke(n)&&(l=f.columns??80,u=f.rows??24);}function S(){let f=l,g=u;m(),(l!==f||u!==g)&&s.emit("resize",{cols:l,rows:u});}function C(){p||Ke(r)&&"setRawMode"in r&&(r.setRawMode(true),p=true);}function x(){p&&Ke(r)&&"setRawMode"in r&&(r.setRawMode(false),p=false);}function h(){d&&(n.write(A.show()),d=false),n.write(z.reset()),x();}let b={get input(){return r},get output(){return n},get cols(){return l},get rows(){return u},get x(){return o.cursorX},get y(){return o.cursorY},get initialized(){return c},on(f,g){s.on(f,g);},off(f,g){s.off(f,g);},once(f,g){s.once(f,g);},removeAllListeners(f){s.removeAllListeners(f);},async init(){c||(m(),t.useAlternateScreen&&i.enterAlternateScreen(),t.hideCursor&&(n.write(A.hide()),d=true),t.title&&b.setTitle(t.title),n.write(I.clear()),n.write(A.home()),Ke(n)&&n.on("resize",S),C(),i.onCleanup(()=>{h();}),c=true);},destroy(){c&&(h(),i.destroy(),s.removeAllListeners(),Ke(n)&&n.off("resize",S),c=false);},write(f){o.write(f);},rawWrite(f){n.write(f);},flush(){o.flush(n);},clear(){b.write(I.clear()),b.write(A.home()),o.resetCursor();},move(f,g){b.write(A.move(f,g));},cursorTo(f,g){b.move(f,g);},showCursor(){b.write(A.show()),d=false;},hideCursor(){b.write(A.hide()),d=true;},setTitle(f){n.write(`\x1B]2;${f}\x07`);},resetStyle(){b.write(z.reset());}};return b}var St=null,ht=new WeakMap;function Et(){return St||(St=l()),St}function au(){St=null;}function uu(e){let t=f(e),r$1=80,n=24;if(t){let s=r(e,t);s&&(r$1=s.width,n=s.height);}let i={world:e,lastWidth:r$1,lastHeight:n,handler:s=>{ar(e,s.cols,s.rows,i);}};return ht.set(e,i),i}function ar(e,t,r,n){if(t===n.lastWidth&&r===n.lastHeight)return;let o=n.lastWidth,i=n.lastHeight;n.lastWidth=t,n.lastHeight=r;let s$1=f(e);s$1&&s(e,s$1,t,r);let l=z$2();if(l){let c=g(l,t,r);y$1(c);}g$1(e),ba$1(e),Et().emit("resize",{width:t,height:r,previousWidth:o,previousHeight:i});}function lu(e,t){e.on("resize",t.handler);}function cu(e,t){e.off("resize",t.handler),ht.delete(t.world);}function pu(e){return ht.get(e)}function Hn(e,t,r$1){let n=ht.get(e);if(n)ar(e,t,r$1,n);else {let o=f(e),i=80,s=24;if(o){let u=r(e,o);u&&(i=u.width,s=u.height);}ar(e,t,r$1,{lastWidth:i,lastHeight:s});}}function du(e){let t=()=>{let r=process.stdout.columns??80,n=process.stdout.rows??24;Hn(e,r,n);};return process.on("SIGWINCH",t),()=>{process.off("SIGWINCH",t);}}var Pu=z$1.object({allowUnicode:z$1.boolean().optional(),maxLength:z$1.number().int().min(0).optional(),stripControl:z$1.boolean().optional(),stripNull:z$1.boolean().optional(),allowTab:z$1.boolean().optional(),allowNewline:z$1.boolean().optional(),replacementChar:z$1.string().max(4).optional()}),ur={allowUnicode:true,maxLength:0,stripControl:true,stripNull:true,allowTab:true,allowNewline:true,replacementChar:"\uFFFD"};function Wn(e){return e>=0&&e<=31}function Vn(e){return e>=128&&e<=159}function Ou(e){return e===0}function Yn(e,t){let r={...ur,...t},n=e;return r.stripNull&&(n=qn(n)),r.stripControl&&(n=Xn(n,r.allowTab,r.allowNewline)),n=Zn(n),n=jn(n,r.replacementChar),r.allowUnicode||(n=Jn(n,r.replacementChar)),r.maxLength>0&&n.length>r.maxLength&&(n=n.slice(0,r.maxLength)),n}function Nu(e,t){let r={...ur,...t},n=e.length,o=Yn(e,t),i=r.maxLength>0&&n>r.maxLength;return {text:o,modified:o!==e,strippedCount:n-o.length,truncated:i,originalLength:n}}function qn(e){if(!e.includes("\0"))return e;let t="";for(let r=0;r<e.length;r++)e.charCodeAt(r)!==0&&(t+=e[r]);return t}function Xn(e,t=true,r=true){let n="";for(let o=0;o<e.length;o++){let i=e.charCodeAt(o);if(!Ou(i)){if(Wn(i)){if(t&&i===9){n+=e[o];continue}if(r&&(i===10||i===13)){n+=e[o];continue}continue}n+=e[o];}}return n}function Zn(e){let t="";for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);Vn(n)||(t+=e[r]);}return t}function jn(e,t="\uFFFD"){let r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o>=55296&&o<=56319){let i=n+1<e.length?e.charCodeAt(n+1):0;i>=56320&&i<=57343?(r+=e[n],r+=e[n+1],n++):r+=t;}else o>=56320&&o<=57343?r+=t:r+=e[n];}return r}function Jn(e,t="\uFFFD"){let r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o>=32&&o<=126||o===9||o===10||o===13?r+=e[n]:r+=t;}return r}function Bu(e){for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=t+1<e.length?e.charCodeAt(t+1):0;if(n<56320||n>57343)return false;t++;}else if(r>=56320&&r<=57343)return false}return true}function Lu(e){for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(Wn(r)||Vn(r))return true}return false}function ku(e){return e.includes("\0")}var Du=z$1.object({allowColors:z$1.boolean().optional(),allowCursor:z$1.boolean().optional(),stripAllEscapes:z$1.boolean().optional(),replacementChar:z$1.string().max(1).optional()}),lr={allowColors:false,allowCursor:false,stripAllEscapes:true,replacementChar:""},$u="\x1B",cr=/\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/g,Fu=/\x1b\[[\d;]*m/g,Uu=/\x1b\[[\d;]*[ABCDEFGHJKLMSTfsu]/g,Gu=/^\x1b\[[\d;]*[ABCDEFGHJKLMSTfsu]$/,Ku=/^\x1b\[[\d;]*m$/,pr=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,dr=/\x1bP[^\x1b]*\x1b\\/g,fr=/\x1b_[^\x1b]*\x1b\\/g,mr=/\x1bX[^\x1b]*\x1b\\/g,gr=/\x1b\^[^\x1b]*\x1b\\/g,zu=/\x1b(?:\[[^\x1b]*?[\x40-\x7e]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[PX_^][^\x1b]*\x1b\\|[78DEHMNOZ=>cnol|}~])/g,Qn=/\x1b(?![[\]PX_^])/g,eo=/[\x00-\x08\x0b\x0c\x0e-\x1a\x7f]/g,Hu=/[\x00-\x08\x0b\x0c\x0e-\x1a\x7f]/;function to(e,t={}){let r={...lr,...t},n=r.replacementChar,o=e;return r.stripAllEscapes?(o=o.replace(zu,n),o=o.replace(Qn,n),o=o.replace(eo,n),o):(o=o.replace(pr,n),o=o.replace(dr,n),o=o.replace(fr,n),o=o.replace(mr,n),o=o.replace(gr,n),o=o.replace(eo,n),r.allowCursor||(o=o.replace(Uu,n)),r.allowColors||(o=o.replace(Fu,n)),o=o.replace(cr,i=>r.allowColors&&Ku.test(i)||r.allowCursor&&Gu.test(i)?i:n),o=o.replace(Qn,n),o)}function ro(e){return e.includes($u)||Hu.test(e)}function Wu(e){return !ro(e)}function Vu(e={}){let t=[],r={...lr,...e},n={append(o){return t.push(o),n},appendUntrusted(o,i){let s=i?{...r,...i}:r;return t.push(to(o,s)),n},clear(){return t=[],n},toString(){return t.join("")},get length(){return t.reduce((o,i)=>o+i.length,0)}};return n}function Yu(e){let t=[],r=new RegExp(cr.source,"g");for(let u of e.matchAll(r))t.push(u[0]);let n=new RegExp(pr.source,"g");for(let u of e.matchAll(n))t.push(u[0]);let o=new RegExp(dr.source,"g");for(let u of e.matchAll(o))t.push(u[0]);let i=new RegExp(fr.source,"g");for(let u of e.matchAll(i))t.push(u[0]);let s=new RegExp(mr.source,"g");for(let u of e.matchAll(s))t.push(u[0]);let l=new RegExp(gr.source,"g");for(let u of e.matchAll(l))t.push(u[0]);return t}function qu(e){let t={csi:[],osc:[],dcs:[],apc:[],sos:[],pm:[],other:[]};for(let r of e.matchAll(new RegExp(cr.source,"g")))t.csi.push(r[0]);for(let r of e.matchAll(new RegExp(pr.source,"g")))t.osc.push(r[0]);for(let r of e.matchAll(new RegExp(dr.source,"g")))t.dcs.push(r[0]);for(let r of e.matchAll(new RegExp(fr.source,"g")))t.apc.push(r[0]);for(let r of e.matchAll(new RegExp(mr.source,"g")))t.sos.push(r[0]);for(let r of e.matchAll(new RegExp(gr.source,"g")))t.pm.push(r[0]);return t}function Xu(e={}){let t=e.output??process.stdout,r=e.input??process.stdin,n=e.onSuspend,o=e.onResume,i=null,s=null,l=false;function u(m){t.write(m);}function c(){let m=n?.(),S={wasAlternateBuffer:p.isAlternateBuffer,wasMouseEnabled:p.isMouseEnabled,wasRawMode:r.isRaw??false,customState:m};return p.isAlternateBuffer&&u(I.alternateOff()),u(A.show()),p.isMouseEnabled&&u(w.disableAll()),r.setRawMode&&S.wasRawMode&&r.setRawMode(false),r.pause(),S}function d(m){r.resume(),r.setRawMode&&m.wasRawMode&&r.setRawMode(true),m.wasAlternateBuffer&&u(I.alternateOn()),m.wasMouseEnabled&&u(w.enableNormal()),o?.(m);}let p={get enabled(){return l},isAlternateBuffer:e.isAlternateBuffer??false,isMouseEnabled:e.isMouseEnabled??false,enable(){l||(i=()=>{p.suspend();},process.on("SIGTSTP",i),l=true);},disable(){l&&(i&&(process.removeListener("SIGTSTP",i),i=null),s&&(process.removeListener("SIGCONT",s),s=null),l=false);},suspend(m){let S=c();s=()=>{d(S),m&&m();},process.once("SIGCONT",s),process.kill(process.pid,"SIGTSTP");},setAlternateBuffer(m){p.isAlternateBuffer=m;},setMouseEnabled(m){p.isMouseEnabled=m;}};return p}var br={prepareForSuspend(e,t){let r="";return e&&(r+=I.alternateOff()),r+=A.show(),t&&(r+=w.disableAll()),r},restoreAfterResume(e,t){let r="";return e&&(r+=I.alternateOn()),t&&(r+=w.enableNormal()),r}};function Zu(e){return new Promise(t=>{let r=e.output??process.stdout,n=e.input??process.stdin,o=e.isAlternateBuffer??false,i=e.isMouseEnabled??false,s=n.isRaw??false;r.write(br.prepareForSuspend(o,i)),n.setRawMode&&s&&n.setRawMode(false),n.pause();let l=()=>{n.resume(),n.setRawMode&&s&&n.setRawMode(true),r.write(br.restoreAfterResume(o,i)),t();};process.once("SIGCONT",l),process.kill(process.pid,"SIGTSTP");})}function ju(e,t={}){let r=t.supported??true,n=t.autoSync??false,o=false,i={get supported(){return r},set supported(s){r=s;},get autoSync(){return n},set autoSync(s){n=s;},get inFrame(){return o},beginFrame(){!r||o||(e.write(V.begin()),o=true);},endFrame(){!r||!o||(e.write(V.end()),o=false);},renderFrame(s){i.beginFrame();try{s();}finally{i.endFrame();}},async renderFrameAsync(s){i.beginFrame();try{await s();}finally{i.endFrame();}},writeFrame(s){if(!r){e.write(s);return}e.write(V.wrap(s));},write(s){n&&r&&!o?i.writeFrame(s):e.write(s);},getBeginMarker(){return r?V.begin():""},getEndMarker(){return r?V.end():""}};return i}function Ju(){return (process.env.TERM??"")==="xterm-kitty"||process.env.KITTY_WINDOW_ID!==void 0}function Qu(){let e=process.env.TERM??"";return e==="foot"||e==="foot-extra"}function el(){return process.env.TERMINAL_VERSION_STRING?.includes("contour")??false}function tl(){return process.env.TERM_PROGRAM==="WezTerm"}function rl(){if(process.env.TERM_PROGRAM!=="iTerm.app")return false;let e=process.env.TERM_PROGRAM_VERSION;if(!e)return false;let t=Number.parseInt(e.split(".")[0]??"0",10),r=Number.parseInt(e.split(".")[1]??"0",10);return t>3||t===3&&r>=5}function nl(){return process.env.TERM_PROGRAM==="mintty"}function ol(){return !!(Ju()||Qu()||el()||tl()||rl()||nl())}var no={name:"xterm-256color",names:["xterm-256color","xterm"],description:"xterm with 256 colors",booleans:{auto_left_margin:false,auto_right_margin:true,back_color_erase:true,has_meta_key:true,move_insert_mode:true,move_standout_mode:true},numbers:{columns:80,lines:24,max_colors:256,max_pairs:65536,init_tabs:8},strings:{cursor_address:"\x1B[%i%p1%d;%p2%dH",cursor_down:`
|
|
9
|
+
`,cursor_home:"\x1B[H",cursor_left:"\b",cursor_right:"\x1B[C",cursor_up:"\x1B[A",cursor_invisible:"\x1B[?25l",cursor_normal:"\x1B[?12l\x1B[?25h",cursor_visible:"\x1B[?12;25h",clear_screen:"\x1B[H\x1B[2J",clr_eol:"\x1B[K",clr_eos:"\x1B[J",scroll_forward:`
|
|
10
|
+
`,scroll_reverse:"\x1BM",change_scroll_region:"\x1B[%i%p1%d;%p2%dr",insert_line:"\x1B[L",delete_line:"\x1B[M",parm_insert_line:"\x1B[%p1%dL",parm_delete_line:"\x1B[%p1%dM",enter_bold_mode:"\x1B[1m",enter_dim_mode:"\x1B[2m",enter_blink_mode:"\x1B[5m",enter_reverse_mode:"\x1B[7m",enter_standout_mode:"\x1B[7m",enter_underline_mode:"\x1B[4m",exit_attribute_mode:"\x1B(B\x1B[m",exit_standout_mode:"\x1B[27m",exit_underline_mode:"\x1B[24m",set_attributes:"\x1B[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\x1B(0%e\x1B(B%;",set_a_foreground:"\x1B[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m",set_a_background:"\x1B[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m",orig_pair:"\x1B[39;49m",orig_colors:"\x1B]104\x07",enter_ca_mode:"\x1B[?1049h\x1B[22;0;0t",exit_ca_mode:"\x1B[?1049l\x1B[23;0;0t",keypad_local:"\x1B[?1l\x1B>",keypad_xmit:"\x1B[?1h\x1B=",bell:"\x07",flash_screen:"\x1B[?5h$<100/>\x1B[?5l",insert_character:"\x1B[@",delete_character:"\x1B[P",parm_ich:"\x1B[%p1%d@",parm_dch:"\x1B[%p1%dP",enter_insert_mode:"\x1B[4h",exit_insert_mode:"\x1B[4l",acs_chars:"``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~",enter_alt_charset_mode:"\x1B(0",exit_alt_charset_mode:"\x1B(B",tab:" ",back_tab:"\x1B[Z",newline:`
|
|
11
|
+
`,carriage_return:"\r",reset_1string:"\x1Bc",init_2string:"\x1B[!p\x1B[?3;4l\x1B[4l\x1B>",repeat_char:"\x1B[%p1%d%p2%c"}};function il(e){e.params.length>0&&e.params[0]!==void 0&&e.params[0]++,e.params.length>1&&e.params[1]!==void 0&&e.params[1]++;}function sl(e,t){if(e.index++,e.index<t.length){let r=Number.parseInt(t[e.index]??"0",10);e.stack.push(e.params[r-1]??0);}return e.index}function al(e,t){let r="";for(e.index++;e.index<t.length&&t[e.index]!=="}";)r+=t[e.index],e.index++;return e.stack.push(Number.parseInt(r,10)||0),e.index}function ul(e,t){let r=e.stack.pop()??0,n=e.stack.pop()??0;switch(t){case "+":e.stack.push(n+r);break;case "-":e.stack.push(n-r);break;case "*":e.stack.push(n*r);break;case "/":e.stack.push(r!==0?Math.floor(n/r):0);break;case "m":e.stack.push(r!==0?n%r:0);break;case "=":e.stack.push(n===r?1:0);break;case "<":e.stack.push(n<r?1:0);break;case ">":e.stack.push(n>r?1:0);break}}function oo(e,t,r){let n=1,o=t;for(;o<e.length&&n>0;)if(o++,e[o]==="%"){if(o++,e[o]==="?")n++;else if(e[o]===";")n--;else if(e[o]==="e"&&n===1&&r)return o}return o}function ll(e,t){return (e.stack.pop()??0)||(e.index=oo(t,e.index,true)),e.index}function cl(e,t){return e.index=oo(t,e.index,false),e.index}function pl(e,t,r){switch(r){case "%":e.result+="%";break;case "i":il(e);break;case "p":e.index=sl(e,t);break;case "d":e.result+=String(e.stack.pop()??0);break;case "s":case "c":e.result+=String.fromCharCode(e.stack.pop()??0);break;case "{":e.index=al(e,t);break;case "+":case "-":case "*":case "/":case "m":case "=":case "<":case ">":ul(e,r);break;case "?":break;case "t":e.index=ll(e,t);break;case "e":e.index=cl(e,t);break;}}function dl(e,t){let r={stack:[],params:[...t],index:0,result:""};for(;r.index<e.length;){let n=e[r.index];if(n!=="%"){r.result+=n,r.index++;continue}if(r.index++,r.index>=e.length)break;let o=e[r.index];o&&pl(r,e,o),r.index++;}return r.result}function yr(e={}){let t=e.terminal??process.env.TERM??"xterm-256color",r=e.data??no,n={terminal:t,data:r,has(o){return r.booleans[o]===true},getNumber(o){let i=r.numbers[o];return i!==void 0?i:null},getString(o){let i=r.strings[o];return i!==void 0?i:null},tparm(o,...i){let s=r.strings[o];return s===void 0?null:dl(s,i)},cup(o,i){return n.tparm("cursor_address",o,i)??`\x1B[${o+1};${i+1}H`},sgr(o){return `\x1B[${o}m`},setaf(o){let i=n.tparm("set_a_foreground",o);return i||(o<8?`\x1B[3${o}m`:o<16?`\x1B[9${o-8}m`:`\x1B[38;5;${o}m`)},setab(o){let i=n.tparm("set_a_background",o);return i||(o<8?`\x1B[4${o}m`:o<16?`\x1B[10${o-8}m`:`\x1B[48;5;${o}m`)}};return n}var Rt=null;function io(){return Rt||(Rt=yr()),Rt}function so(){Rt=null;}function ao(){return no}var fl={maxRate:30,debounceMs:150,showIntermediate:true};function ml(e,t,r){let n={...fl,...r},o=false,i=process.stdout.columns??80,s$1=process.stdout.rows??24,l=0,u=null,c=false,d=1e3/n.maxRate;function p(h,b){return !(c||h===i&&b===s$1)}function m(h,b,f$1){if(f$1-l<d)return;l=f$1;let M=f(e);M&&s(e,M,h,b),n.showIntermediate&&t(h,b,false);}function S(){u!==null&&clearTimeout(u),u=setTimeout(()=>{if(c)return;o=false,u=null;let h=f(e);h&&s(e,h,i,s$1),t(i,s$1,true),Et().emit("resize",{width:i,height:s$1,previousWidth:i,previousHeight:s$1});},n.debounceMs);}function C(){let h=process.stdout.columns??80,b=process.stdout.rows??24;if(!p(h,b))return;o=true,i=h,s$1=b;let f=performance.now();m(h,b,f),S();}return process.on("SIGWINCH",C),{world:e,config:n,get isResizing(){return o},get lastWidth(){return i},get lastHeight(){return s$1},dispose(){c=true,process.off("SIGWINCH",C),u!==null&&(clearTimeout(u),u=null);}}}function gl(e,t){let r=0,n=1e3/t;return((...o)=>{let i=performance.now();i-r>=n&&(r=i,e(...o));})}function bl(e,t){let r=null;return {fn:((...o)=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,e(...o);},t);}),cancel:()=>{r!==null&&(clearTimeout(r),r=null);}}}export{ni as $,qt as $a,_s as $b,uu as $c,R as A,Ai as Aa,cn as Ab,Ea as Ac,br as Ad,w as B,Mi as Ba,pn as Bb,Ma as Bc,Zu as Bd,Nt as C,Lr as Ca,cs as Cb,xt as Cc,ju as Cd,Bt as D,Pi as Da,dn as Db,An as Dc,ol as Dd,Lt as E,Ht as Ea,ps as Eb,wn as Ec,yr as Ed,z as F,kr as Fa,ds as Fb,In as Fc,io as Fd,I as G,Dr as Ga,fs as Gb,nr as Gc,so as Gd,kt as H,$r as Ha,ms as Hb,Mn as Hc,ao as Hd,Po as I,Fr as Ia,gs as Ib,or as Ic,ml as Id,Oo as J,Ur as Ja,bs as Jb,Pn as Jc,gl as Jd,Ze as K,Gr as Ka,ys as Kb,On as Kc,bl as Kd,je as L,Wt as La,$e as Lb,Nn as Lc,Ar as M,Kr as Ma,ee as Mb,Bn as Mc,No as N,Vt as Na,xs as Nb,Ln as Nc,Bo as O,Yt as Oa,mn as Ob,kn as Oc,Lo as P,tt as Pa,gn as Pb,Dn as Pc,ko as Q,rt as Qa,bn as Qb,$n as Qc,Do as R,zr as Ra,yn as Rb,Va as Rc,$o as S,Hr as Sa,xn as Sb,Ya as Sc,Fo as T,Wr as Ta,Cn as Tb,qa as Tc,E as U,Vr as Ua,Ss as Ub,Un as Uc,Uo as V,Yr as Va,dt as Vb,ja as Vc,Dt as W,qr as Wa,hs as Wb,Ja as Wc,$t as X,Xr as Xa,Ee as Xb,zn as Xc,Ft as Y,Zr as Ya,ce as Yb,su as Yc,ti as Z,jr as Za,Ts as Zb,Et as Zc,ri as _,Jr as _a,vs as _b,au as _c,a,oi as aa,Xt as ab,As as ac,lu as ad,L as b,ii as ba,Qr as bb,jt as bc,cu as bd,se as c,si as ca,en as cb,mt as cc,pu as cd,U as d,ai as da,_ as db,ws as dc,Hn as dd,Z as e,ui as ea,Xi as eb,gt as ec,du as ed,N as f,li as fa,Zi as fb,Fe as fc,Pu as fd,vt as g,ci as ga,ji as gb,Is as gc,ur as gd,We as h,pi as ha,ue as hb,Ms as hc,Yn as hd,Ve as i,di as ia,Ji as ib,Ps as ic,Nu as id,j,ge as ja,Qi as jb,En as jc,qn as jd,_t as k,Ut as ka,es as kb,Rn as kc,Xn as kd,At as l,Le as la,ts as lb,Os as lc,Zn as ld,wt as m,ke as ma,ot as mb,Ns as mc,jn as md,It as n,Ne as na,it as nb,Bs as nc,Jn as nd,Mt as o,ye as oa,st as ob,Ls as oc,Bu as od,we as p,Be as pa,at as pb,ks as pc,Lu as pd,Pt as q,Mr as qa,ut as qb,Ds as qc,ku as qd,y as r,Gt as ra,le as rb,$s as rc,Du as rd,A as s,Kt as sa,Ce as sb,Fs as sc,lr as sd,Ot as t,Pr as ta,Se as tb,Ge as tc,to as td,V as u,zt as ua,he as ub,bt as uc,ro as ud,me as v,Or as va,lt as vb,Jt as vc,Wu as vd,W as w,Nr as wa,us as wb,sa as wc,Vu as wd,Xe as x,Qe as xa,ls as xb,Ca as xc,Yu as xd,J as y,vi as ya,un as yb,yt as yc,qu as yd,Pe as z,_i as za,ln as zb,ha as zc,Xu as zd};
|